diff --git a/.gitignore b/.gitignore index a6d3f3b8f5..aa4a3a5c41 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ tools/ido_recomp/* binary ctx.c graphs/ *.c.m2c +tools/**/*dSYM/ tools/decomp-permuter/ tools/mips_to_c/ diff --git a/Makefile b/Makefile index 0ee73f25eb..98aa5b1b47 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,12 @@ COMPARE ?= 1 NON_MATCHING ?= 0 # If ORIG_COMPILER is 1, compile with QEMU_IRIX and the original compiler ORIG_COMPILER ?= 0 +# if WERROR is 1, pass -Werror to CC_CHECK, so warnings would be treated as errors +WERROR ?= 0 # Keep .mdebug section in build KEEP_MDEBUG ?= 0 +# Disassembles all asm from the ROM instead of skipping files which are entirely in C +FULL_DISASM ?= 0 ifeq ($(NON_MATCHING),1) CFLAGS := -DNON_MATCHING @@ -17,6 +21,10 @@ ifeq ($(NON_MATCHING),1) COMPARE := 0 endif +ifneq ($(FULL_DISASM), 0) + DISASM_FLAGS += --full +endif + PROJECT_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) MAKE = make @@ -36,12 +44,7 @@ else endif endif -# Threads to compress and extract assets with, TODO improve later -ifeq ($(DETECTED_OS),linux) - N_THREADS ?= $(shell nproc) -else - N_THREADS ?= 1 -endif +N_THREADS ?= $(shell nproc) #### Tools #### ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0) @@ -109,6 +112,10 @@ ifneq ($(NON_MATCHING),1) COMPFLAGS += --matching endif +ifneq ($(WERROR), 0) + CC_CHECK += -Werror +endif + #### Files #### # ROM image @@ -140,9 +147,10 @@ TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG:.png=.inc.c),build/$f) \ C_FILES := $(foreach dir,$(SRC_DIRS) $(ASSET_BIN_DIRS),$(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\".*//') O_FILES := $(foreach f,$(S_FILES:.s=.o),build/$f) \ $(foreach f,$(C_FILES:.c=.o),build/$f) \ - $(foreach f,$(wildcard baserom/*),build/$f.o) + $(foreach f,$(BASEROM_FILES),build/$f.o) # Automatic dependency files # (Only asm_processor dependencies are handled for now) @@ -166,6 +174,8 @@ build/src/libultra/flash/%.o: MIPS_VERSION := -mips1 build/src/code/audio/%.o: OPTFLAGS := -O2 +build/assets/%.o: OPTFLAGS := + # file flags build/src/boot_O2_g3/fault.o: CFLAGS += -trapuv build/src/boot_O2_g3/fault_drawer.o: CFLAGS += -trapuv @@ -243,12 +253,12 @@ setup: $(MAKE) -C tools python3 tools/fixbaserom.py python3 tools/extract_baserom.py - python3 extract_assets.py -t $(N_THREADS) + python3 extract_assets.py -j $(N_THREADS) ## Assembly generation disasm: $(RM) -rf asm data - python3 tools/disasm/disasm.py -j $(N_THREADS) + python3 tools/disasm/disasm.py -j $(N_THREADS) $(DISASM_FLAGS) diff-init: uncompressed $(RM) -rf expected/ @@ -283,11 +293,11 @@ build/baserom/%.o: baserom/% $(OBJCOPY) -I binary -O elf32-big $< $@ build/data/%.o: data/%.s - iconv --from UTF-8 --to EUC-JP $< | $(AS) $(ASFLAGS) -o $@ + $(AS) $(ASFLAGS) $< -o $@ build/src/overlays/%.o: src/overlays/%.c - $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< $(CC_CHECK) $< + $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< @$(OBJDUMP) -d $@ > $(@:.o=.s) # TODO: `() || true` is currently necessary to suppress `Error 1 (ignored)` make warnings caused by `test`, but this will go away if # the following is moved to a separate rule that is only run once when all the required objects have been compiled. @@ -296,21 +306,21 @@ build/src/overlays/%.o: src/overlays/%.c $(RM_MDEBUG) build/src/%.o: src/%.c - $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< $(CC_CHECK) $< + $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< @$(OBJDUMP) -d $@ > $(@:.o=.s) $(RM_MDEBUG) build/src/libultra/libc/ll.o: src/libultra/libc/ll.c - $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< $(CC_CHECK) $< + $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ @$(OBJDUMP) -d $@ > $(@:.o=.s) $(RM_MDEBUG) build/src/libultra/libc/llcvt.o: src/libultra/libc/llcvt.c - $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< $(CC_CHECK) $< + $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ @$(OBJDUMP) -d $@ > $(@:.o=.s) $(RM_MDEBUG) diff --git a/README.md b/README.md index 80d1e5d549..845a10cc67 100644 --- a/README.md +++ b/README.md @@ -23,26 +23,35 @@ in an experimental and research phase and cannot currently be used traditionally source code base for general changes. ``` -**This repo does not include any assets or code necessary for compiling the ROM. A prior copy of the game is required to extract the required assets.** +This is a WIP **decompilation** of ***The Legend of Zelda: Majora's Mask***. The purpose of the project is to recreate a source code base for the game from scratch, using information found inside the game along with static and/or dynamic analysis. **It is not producing a PC port.** For more information you can get in touch with the team on our [Discord server](https://discord.zelda64.dev). -This is a decompilation of Legend of Zelda: Majora's Mask (US) 1.0 +The only build currently supported is N64 US, but other versions are planned to be supported. -It builds the following ROM: +It currently builds the following ROM: * mm.us.rev1.rom.z64 `md5: 2a0a8acb61538235bc1094d297fb6556` +**This repo does not include any assets or assembly code necessary for compiling the ROM. A prior copy of the game is required to extract the required assets.** + Please refer to the following for more information: - [Website](https://zelda64.dev/) - [Discord](https://discord.zelda64.dev/) - [How to Contribute](CONTRIBUTING.md) + ## Installation ### Windows For Windows 10, install WSL and a distribution by following this [Windows Subsystem for Linux Installation Guide](https://docs.microsoft.com/en-us/windows/wsl/install-win10). -We recommend using Debian or Ubuntu 18.04 Linux distributions. +We recommend using Debian or Ubuntu 20.04 Linux distributions. + + +### MacOS + +Preparation is covered in a [separate document](docsBUILDING_MACOS.md). + ### Linux (Native or under WSL / VM) @@ -110,30 +119,23 @@ This means that something is wrong with the ROM's contents. Either the baserom f Running `make init` will also make the `./expected` directory and copy all of the files there, which will be useful when running the diff script. The diff script is useful in decompiling functions and can be ran with this command: `./tools/asm-differ/diff.py -wmo3 ` -**Note**: to speed up the build, you can either: -* Pass `-jN` to `make setup` and `make`, where N is the number of threads to use in the build, e.g. `make -j4`. The generally-accepted wisdom is to use the number of virtual cores your computer has. -* Pass `-j` to `make setup` and `make`, to use as many threads as possible, but beware that this can use too much memory on lower-end systems. -Both of these have the disadvantage that the ordering of the terminal output is scrambled, so for debugging it is best to stick to one thread (i.e. not pass `-j` or `-jN`). +**Note**: to speed up the build, you can pass `-jN` to `make setup` and `make`, where N is the number of threads to use in the build, e.g. `make -j4`. The generally-accepted wisdom is to use the number of virtual cores your computer has, which is the output of `nproc` (which should be installed as part of `coreutils`). +The disadvantage that the ordering of the terminal output is scrambled, so for debugging it is best to stick to one thread (i.e. not pass `-jN`). +(`-j` also exists, which uses unlimited jobs, but is generally slower.) -**Note**: if you rename symbols, it is recommended that you use the `tools/rename_sym.sh` to ensure that you cover all instances, including the tables which are used to generate the `asm/` directory. - -Usage: `tools/rename_sym.sh old_name new_name`. Example: - -```bash -tools/rename_sym.sh func_808A3428 EnTorch2_UpdateIdle -``` ## Contributing All contributions are welcome. This is a group effort, and even small contributions can make a difference. Some tasks also don't require much knowledge to get started. -Anyone who wishes to contribute to the OOT or MM projects **must not have accessed leaked source code at any point in time** for Nintendo 64 SDK, iQue player SDK, libultra, Ocarina of Time, Majora's Mask, Animal Crossing/Animal Forest, or any other game that shares the same game engine or significant portions of code to a Zelda 64 game or any other console similar to the Nintendo 64. +Please note that is is our strict policy that *Anyone who wishes to contribute to the OOT or MM projects **must not have accessed leaked source code at any point in time** for Nintendo 64 SDK, iQue player SDK, libultra, Ocarina of Time, Majora's Mask, Animal Crossing/Animal Forest, or any other game that shares the same game engine or significant portions of code to a Zelda 64 game or any other console similar to the Nintendo 64.* Most discussions happen on our [Discord Server](https://discord.zelda64.dev), where you are welcome to ask if you need help getting started, or if you have any questions regarding this project and other decompilation projects. For more information on getting started, see our [Contributing Guide](CONTRIBUTING.md) and our [Code Review Guidelines](REVIEWING.md) to see what code quality guidelines we follow. + ## FAQ ### Q: Why does MM use transient assembly? diff --git a/assets/xml/code/eff_shield_particle.xml b/assets/xml/code/eff_shield_particle.xml new file mode 100644 index 0000000000..3ff5535062 --- /dev/null +++ b/assets/xml/code/eff_shield_particle.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/objects/gameplay_dangeon_keep.xml b/assets/xml/objects/gameplay_dangeon_keep.xml index 19fabad2b3..8237f63804 100644 --- a/assets/xml/objects/gameplay_dangeon_keep.xml +++ b/assets/xml/objects/gameplay_dangeon_keep.xml @@ -1,7 +1,7 @@  - - + + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 892749e732..5e5b9b4f5c 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -766,59 +766,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -863,7 +866,7 @@ - + @@ -939,36 +942,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1295,13 +1301,13 @@ - + - + - + - + @@ -1316,7 +1322,7 @@ - + @@ -1324,11 +1330,11 @@ - + - + - + diff --git a/assets/xml/objects/object_aob.xml b/assets/xml/objects/object_aob.xml index f44ec32463..dcdb757484 100644 --- a/assets/xml/objects/object_aob.xml +++ b/assets/xml/objects/object_aob.xml @@ -23,9 +23,9 @@ - - - + + + diff --git a/assets/xml/objects/object_bigpo.xml b/assets/xml/objects/object_bigpo.xml index 5a930c9ac5..c41d5ff793 100644 --- a/assets/xml/objects/object_bigpo.xml +++ b/assets/xml/objects/object_bigpo.xml @@ -1,46 +1,46 @@  - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bigslime.xml b/assets/xml/objects/object_bigslime.xml index d0238adef4..18b7025061 100644 --- a/assets/xml/objects/object_bigslime.xml +++ b/assets/xml/objects/object_bigslime.xml @@ -1,114 +1,130 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_cs.xml b/assets/xml/objects/object_cs.xml index d55f866caf..65cff1d46c 100644 --- a/assets/xml/objects/object_cs.xml +++ b/assets/xml/objects/object_cs.xml @@ -49,18 +49,25 @@ - + - + + + + + - + + + + + - diff --git a/assets/xml/objects/object_dnt.xml b/assets/xml/objects/object_dnt.xml index d75f29cfc0..d2ff328d3e 100644 --- a/assets/xml/objects/object_dnt.xml +++ b/assets/xml/objects/object_dnt.xml @@ -13,7 +13,7 @@ - + diff --git a/assets/xml/objects/object_fall.xml b/assets/xml/objects/object_fall.xml index f84ecffc5f..5a90c5a243 100644 --- a/assets/xml/objects/object_fall.xml +++ b/assets/xml/objects/object_fall.xml @@ -8,6 +8,9 @@ + + + diff --git a/assets/xml/objects/object_fish.xml b/assets/xml/objects/object_fish.xml index 3d02127c6d..c0cbd54c77 100644 --- a/assets/xml/objects/object_fish.xml +++ b/assets/xml/objects/object_fish.xml @@ -1,6 +1,6 @@  - + @@ -35,29 +35,29 @@ - + - + - - + + - - + + - - + + - - - + + + - - + + @@ -73,12 +73,12 @@ - - - + + + - - + + @@ -86,21 +86,23 @@ - + + + - - + + - - + + - + @@ -129,29 +131,32 @@ - - - - + + + + + + + - - + + - - - - + + + + - - - - + + + + - - + + diff --git a/assets/xml/objects/object_giant.xml b/assets/xml/objects/object_giant.xml index 9e1815528e..edaeee0398 100644 --- a/assets/xml/objects/object_giant.xml +++ b/assets/xml/objects/object_giant.xml @@ -1,63 +1,90 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gmo.xml b/assets/xml/objects/object_gmo.xml index 732634d761..4884d79190 100644 --- a/assets/xml/objects/object_gmo.xml +++ b/assets/xml/objects/object_gmo.xml @@ -1,13 +1,15 @@  - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_kibako.xml b/assets/xml/objects/object_kibako.xml index 138894b0fb..43276080a0 100644 --- a/assets/xml/objects/object_kibako.xml +++ b/assets/xml/objects/object_kibako.xml @@ -1,8 +1,9 @@  + - - - - + + + + diff --git a/assets/xml/objects/object_kibako2.xml b/assets/xml/objects/object_kibako2.xml index 098a5318d0..4b6ce5ac72 100644 --- a/assets/xml/objects/object_kibako2.xml +++ b/assets/xml/objects/object_kibako2.xml @@ -1,13 +1,14 @@  + - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_mag.xml b/assets/xml/objects/object_mag.xml index 061ff6bca9..1feae8057c 100644 --- a/assets/xml/objects/object_mag.xml +++ b/assets/xml/objects/object_mag.xml @@ -1,28 +1,30 @@  - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_oF1d_map.xml b/assets/xml/objects/object_oF1d_map.xml index 9eac29aaad..9557dc73e3 100644 --- a/assets/xml/objects/object_oF1d_map.xml +++ b/assets/xml/objects/object_oF1d_map.xml @@ -7,9 +7,9 @@ - + - + @@ -71,7 +71,10 @@ - + + + + @@ -98,7 +101,7 @@ - + diff --git a/assets/xml/objects/object_ssh.xml b/assets/xml/objects/object_ssh.xml index e4072d79e4..a95597ae48 100644 --- a/assets/xml/objects/object_ssh.xml +++ b/assets/xml/objects/object_ssh.xml @@ -11,9 +11,11 @@ - + - + + + diff --git a/assets/xml/objects/object_stream.xml b/assets/xml/objects/object_stream.xml index ac73120799..2e49af9163 100644 --- a/assets/xml/objects/object_stream.xml +++ b/assets/xml/objects/object_stream.xml @@ -1,6 +1,7 @@  + - - + + diff --git a/assets/xml/objects/object_tokei_step.xml b/assets/xml/objects/object_tokei_step.xml index fad13984a3..ecdf14ac38 100644 --- a/assets/xml/objects/object_tokei_step.xml +++ b/assets/xml/objects/object_tokei_step.xml @@ -1,8 +1,8 @@  - - - - + + + + diff --git a/assets/xml/objects/object_warp1.xml b/assets/xml/objects/object_warp1.xml index 9324f1301c..50d4c527a1 100644 --- a/assets/xml/objects/object_warp1.xml +++ b/assets/xml/objects/object_warp1.xml @@ -54,6 +54,6 @@ - + diff --git a/assets/xml/objects/object_wiz.xml b/assets/xml/objects/object_wiz.xml index 6a27c2ba9e..7f41954cf2 100644 --- a/assets/xml/objects/object_wiz.xml +++ b/assets/xml/objects/object_wiz.xml @@ -3,7 +3,7 @@ - + diff --git a/assets/xml/objects/object_zog.xml b/assets/xml/objects/object_zog.xml index aae7b0381f..55f169ad1a 100644 --- a/assets/xml/objects/object_zog.xml +++ b/assets/xml/objects/object_zog.xml @@ -74,7 +74,12 @@ - + + + + + + diff --git a/assets/xml/overlays/ovl_En_Bigslime.xml b/assets/xml/overlays/ovl_En_Bigslime.xml new file mode 100644 index 0000000000..9526daea6f --- /dev/null +++ b/assets/xml/overlays/ovl_En_Bigslime.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Bomjima.xml b/assets/xml/overlays/ovl_En_Bomjima.xml new file mode 100644 index 0000000000..5aada48876 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Bomjima.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/xml/overlays/ovl_En_Bomjimb.xml b/assets/xml/overlays/ovl_En_Bomjimb.xml new file mode 100644 index 0000000000..af42c79568 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Bomjimb.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/xml/overlays/ovl_En_Kanban.xml b/assets/xml/overlays/ovl_En_Kanban.xml new file mode 100644 index 0000000000..386cfc663f --- /dev/null +++ b/assets/xml/overlays/ovl_En_Kanban.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Mm2.xml b/assets/xml/overlays/ovl_En_Mm2.xml new file mode 100644 index 0000000000..5d0be627f7 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Mm2.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/docs/BUILDING_MACOS.md b/docs/BUILDING_MACOS.md new file mode 100644 index 0000000000..17b683442c --- /dev/null +++ b/docs/BUILDING_MACOS.md @@ -0,0 +1,83 @@ +# Building on macOS + +**N.B. C++17 is required to build the asset processing program that we use (ZAPD), so check your OS version can support this before proceeding** + + +## Dependencies + +For macOS, use Homebrew to install the following dependencies: + +* coreutils +* make +* python3 +* libpng +* bash +* clang-format 11 + +You can install them with the following commands: + +```bash +brew update +brew install coreutils make python3 libpng bash clang-format@11 +``` + +(The repository expects Homebrew-installed programs to be either linked correctly in `$PATH` etc. or in their default locations.) + + +## Building mips-linux-binutils + +The following instructions are written for MacOS users but should apply to any Unix-like system, with maybe some modifications at the end regarding the bash_profile. + +Create destination dir for binutils +```bash +sudo mkdir -p /opt/cross +``` + +Create and enter local working dir +```bash +mkdir ~/binutils-tmp +cd ~/binutils-tmp +``` + +Get and extract binutils source +```bash +wget https://ftp.gnu.org/gnu/binutils/binutils-2.35.tar.bz2 +tar xjf binutils-2.35.tar.bz2 +``` +(You may find this command does not work: if so, just access the URL in a browser and save it to `~/binutils-tmp`.) + +Create and enter a build directory +```bash +mkdir build-binutils +cd build-binutils +``` + +Configure the build +```bash +../binutils-2.35/configure --target=mips-linux-gnu --prefix=/opt/cross --disable-gprof --disable-gdb --disable-werror +``` + +Make and install binutils +```bash +make -j +sudo make install +``` + +Edit your `~/.bash_profile`/`~/.zsh_profile` (or whichever shell you use) to add the new binutils binaries to the system PATH +```bash +echo "export PATH=$PATH:/opt/cross/bin" >> ~/.bash_profile +``` + +Reload ~/.bash_profile (or just launch a new terminal tab) +```bash +source ~/.bash_profile +``` + +If this worked, you can now delete the temporary directory `~/binutils-tmp`. + + +## Final note + +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. diff --git a/docs/tutorial/advanced_control_flow.md b/docs/tutorial/advanced_control_flow.md index 953e3e44d7..3420fc5977 100644 --- a/docs/tutorial/advanced_control_flow.md +++ b/docs/tutorial/advanced_control_flow.md @@ -63,7 +63,7 @@ void EnMs_Init(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06003DC0, &D_060005EC, this->jointTable, this->morphTable, 9); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &D_80952BA0); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 35.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); Actor_SetScale(&this->actor, 0.015f); this->actor.colChkInfo.mass = 0xFF; this->actionFunc = func_80952734; @@ -87,7 +87,7 @@ void func_80952734(EnMs* this, GlobalContext* globalCtx) { this->actor.textId = 0x932; } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { this->actionFunc = func_809527F8; return; } @@ -107,12 +107,12 @@ void func_809529AC(EnMs *this, GlobalContext *globalCtx) { func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); this->actionFunc = func_80952A1C; } else { - func_800B8A1C(&this->actor, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } void func_80952A1C(EnMs *this, GlobalContext *globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80151938(globalCtx, 0x936U); this->actionFunc = func_809527F8; } else { @@ -124,7 +124,7 @@ void EnMs_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnMs* this = THIS; - Actor_SetHeight(&this->actor, 20.0f); + Actor_SetFocus(&this->actor, 20.0f); this->actor.targetArrowOffset = 500.0f; Actor_SetScale(&this->actor, 0.015f); SkelAnime_Update(&this->skelAnime); @@ -156,7 +156,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { u8 temp_v0; u8 temp_v0_2; - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 != 4) { if (temp_v0 != 5) { if ((temp_v0 == 6) && (func_80147624(globalCtx) != 0)) { @@ -168,7 +168,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { } if (func_80147624(globalCtx) != 0) { func_801477B4(globalCtx); - func_800B8A1C((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; } @@ -198,7 +198,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { return; } func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; } @@ -208,7 +208,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { which is long, messy, and contains some rather nasty-looking control flow, including horrors like ```C - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 != 4) { if (temp_v0 != 5) { if ((temp_v0 == 6) && (func_80147624(globalCtx) != 0)) { @@ -238,7 +238,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { u8 temp_v0; u8 temp_v0_2; - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -258,7 +258,7 @@ block_5: goto block_17; } func_801477B4(globalCtx); - func_800B8A1C((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: @@ -290,7 +290,7 @@ block_13: return; block_15: func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; return; @@ -340,7 +340,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { u8 temp_v0; u8 temp_v0_2; - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -360,7 +360,7 @@ block_5: goto block_17; } func_801477B4(globalCtx); - func_800B8A1C((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: @@ -390,7 +390,7 @@ block_11: } func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; return; @@ -410,7 +410,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { u8 temp_v0; u8 temp_v0_2; - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -430,7 +430,7 @@ block_5: return; } func_801477B4(globalCtx); - func_800B8A1C((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: @@ -460,7 +460,7 @@ block_11: } func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; return; @@ -509,7 +509,7 @@ So let us rewrite the entire second half as a switch: } func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; return; @@ -540,7 +540,7 @@ There's a couple of other obvious things here: func_80151938(globalCtx, 0x937U); } else { func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; } @@ -568,7 +568,7 @@ can be swapped round and made to wrap the switch. This leaves us with void func_809527F8(EnMs *this, GlobalContext *globalCtx) { u8 temp_v0; - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -588,7 +588,7 @@ block_5: return; } func_801477B4(globalCtx); - func_800B8A1C((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: @@ -605,7 +605,7 @@ block_7: func_80151938(globalCtx, 0x937U); } else { func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; } @@ -623,7 +623,7 @@ block_7: Now, the top of the function also looks like a switch: ```C - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -641,7 +641,7 @@ Putting all this together, we write down a function with no gotos in it: ```C void func_809527F8(EnMs *this, GlobalContext *globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 6: this->actionFunc = func_80952734; break; @@ -651,7 +651,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { return; } func_801477B4(globalCtx); - func_800B8A1C((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; break; @@ -660,7 +660,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); - + if (gSaveContext.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); @@ -669,7 +669,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { func_80151938(globalCtx, 0x937U); } else { func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; } @@ -694,7 +694,7 @@ Lastly, we can simplify `case 5` to replace the return in the if by the rest of ```C void func_809527F8(EnMs *this, GlobalContext *globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 6: this->actionFunc = func_80952734; break; @@ -702,7 +702,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { case 5: if (func_80147624(globalCtx) != 0) { func_801477B4(globalCtx); - func_800B8A1C((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; } break; @@ -712,7 +712,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); - + if (gSaveContext.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); @@ -721,7 +721,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { func_80151938(globalCtx, 0x937U); } else { func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; } diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index 9b2c8e177e..de82b54f93 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -148,9 +148,9 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { } } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { func_80C10290(this); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2000)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) { func_800B8614(&this->actor, globalCtx, 60.0f); if (Player_GetMask(globalCtx) == 2) { this->actor.textId = 0x2367; @@ -188,7 +188,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { } } - temp_v0_2 = func_80152498(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&globalCtx->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; func_80C10148(this); @@ -197,7 +197,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { - Actor_SetSwitchFlag(globalCtx, this->actor.params); + Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); if ((gSaveContext.weekEventReg[63] & 0x80)) { this->actor.textId = 0x2ADF; @@ -476,9 +476,9 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { } } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { func_80C10290(this); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2000)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) { func_800B8614(&this->actor, globalCtx, 60.0f); if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { this->actor.textId = 0x2367; // "... doesn't Kafei want to break off his engagement ... ?" @@ -514,13 +514,13 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { } } - temp_v0_2 = func_80152498(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&globalCtx->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; // hear directions again? func_80C10148(this); } else if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." - Actor_SetSwitchFlag(globalCtx, this->actor.params); + Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); if (gSaveContext.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) @@ -546,7 +546,7 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { } } ``` -All this branching is to make the conversation look more diverse and interesting. Notably, though, `func_80C1019C` is set to start with, and is only changed when `func_800B84D0(&this->actor, globalCtx) != 0`. This is something to do with talking. The other function handles the rest of the conversation, and hands back to the first if `func_80152498(&globalCtx->msgCtx) == 2`. This function is *something* to do with the text state, which will require `z_message` to be decomped. However, observation in-game will reveal this is something to do with ending dialogue. So we can conclude that the action functions are `EnRecepgirl_Wait` and `EnRecepgirl_Talk`. The setup functions are thus `EnRecepgirl_SetupWait` and `EnRecepgirl_SetupTalk`. +All this branching is to make the conversation look more diverse and interesting. Notably, though, `func_80C1019C` is set to start with, and is only changed when `Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0`. This is something to do with talking. The other function handles the rest of the conversation, and hands back to the first if `Message_GetState(&globalCtx->msgCtx) == 2`. This function is *something* to do with the text state, which will require `z_message` to be decomped. However, observation in-game will reveal this is something to do with ending dialogue. So we can conclude that the action functions are `EnRecepgirl_Wait` and `EnRecepgirl_Talk`. The setup functions are thus `EnRecepgirl_SetupWait` and `EnRecepgirl_SetupTalk`. For more complex actors, we have a tool called `graphovl.py` that can produce function flow graphs for actors: running ``` diff --git a/docs/tutorial/introduction.md b/docs/tutorial/introduction.md index 4e2d8324d3..6178019c8a 100644 --- a/docs/tutorial/introduction.md +++ b/docs/tutorial/introduction.md @@ -27,7 +27,7 @@ glabel func_809529AC /* 0003D8 809529F8 C484009C */ lwc1 $f4, 0x9c($a0) /* 0003DC 809529FC 8C870098 */ lw $a3, 0x98($a0) /* 0003E0 80952A00 24060035 */ addiu $a2, $zero, 0x35 -/* 0003E4 80952A04 0C02E287 */ jal func_800B8A1C +/* 0003E4 80952A04 0C02E287 */ jal Actor_PickUp /* 0003E8 80952A08 E7A40010 */ swc1 $f4, 0x10($sp) .L80952A0C: /* 0003EC 80952A0C 8FBF001C */ lw $ra, 0x1c($sp) @@ -46,7 +46,7 @@ void func_809529AC(EnMs *this, GlobalContext *globalCtx) { func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); this->actionFunc = func_80952A1C; } else { - func_800B8A1C(&this->actor, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } ``` diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index bdc49036da..870b490ea6 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -116,11 +116,11 @@ void func_80C1019C(EnRecepgirl *this, GlobalContext *globalCtx) { Animation_ChangeTransitionRepeat(temp_a0, &D_06009890, -4.0f); } } - if (func_800B84D0((Actor *) this, globalCtx) != 0) { + if (Actor_ProcessTalkRequest((Actor *) this, globalCtx) != 0) { func_80C10290(this); return; } - if (Actor_IsActorFacingLink((Actor *) this, 0x2000) != 0) { + if (Actor_IsFacingPlayer((Actor *) this, 0x2000) != 0) { func_800B8614((Actor *) this, globalCtx, 60.0f); if (Player_GetMask(globalCtx) == 2) { this->actor.textId = 0x2367; @@ -168,11 +168,11 @@ void func_80C1019C(EnRecepgirl *this, GlobalContext *globalCtx) { Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, -4.0f); } } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { func_80C10290(this); return; } - if (Actor_IsActorFacingLink(&this->actor, 0x2000) != 0) { + if (Actor_IsFacingPlayer(&this->actor, 0x2000) != 0) { func_800B8614(&this->actor, globalCtx, 60.0f); if (Player_GetMask(globalCtx) == 2) { this->actor.textId = 0x2367; @@ -203,9 +203,9 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { } } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { func_80C10290(this); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2000)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) { func_800B8614(&this->actor, globalCtx, 60.0f); if (Player_GetMask(globalCtx) == 2) { this->actor.textId = 0x2367; @@ -282,7 +282,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { Animation_MorphToPlayOnce(sp20, &D_0600A280, -4.0f); } } - temp_v0_2 = func_80152498(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&globalCtx->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; func_80C10148(this); @@ -291,7 +291,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { temp_v0_3 = this->actor.textId; if (temp_v0_3 == 0x2AD9) { - Actor_SetSwitchFlag(globalCtx, (s32) this->actor.params); + Flags_SetSwitch(globalCtx, (s32) this->actor.params); Animation_MorphToPlayOnce(sp20, &D_0600AD98, 10.0f); if ((*(&gSaveContext + 0xF37) & 0x80) != 0) { this->actor.textId = 0x2ADF; @@ -340,7 +340,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { } } - temp_v0_2 = func_80152498(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&globalCtx->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; func_80C10148(this); @@ -349,7 +349,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { - Actor_SetSwitchFlag(globalCtx, this->actor.params); + Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); if ((*(&gSaveContext + 0xF37) & 0x80) != 0) { this->actor.textId = 0x2ADF; @@ -390,7 +390,7 @@ The yellow shows registers that don't match, the different colours on the regist ``` somehow we skipped over `t0`. Where is this in the code? The `153` in the middle is the line number in the C file (the `3f0`s are the offsets into the assembly file), we have `--source` if you want to see the code explicitly, or you can do it the old-fashioned way, and work it out from nearby function calls. In this case, `func_80C10148` is run straight after, and the only place that is called is ```C - temp_v0_2 = func_80152498(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&globalCtx->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; func_80C10148(this); diff --git a/extract_assets.py b/extract_assets.py index a7825af1fe..dda5efaec7 100755 --- a/extract_assets.py +++ b/extract_assets.py @@ -1,9 +1,8 @@ #!/usr/bin/env python3 -import argparse, json, os, signal, time, colorama -from multiprocessing import Pool, Event, Manager +import argparse, json, os, signal, time, colorama, multiprocessing -colorama.init(); +colorama.init() EXTRACTED_ASSETS_NAMEFILE = ".extracted-assets.json" @@ -71,33 +70,33 @@ def initializeWorker(abort, unaccounted: bool, extractedAssetsTracker: dict, man def main(): parser = argparse.ArgumentParser(description="baserom asset extractor") parser.add_argument("-s", "--single", help="asset path relative to assets/, e.g. objects/gameplay_keep") - parser.add_argument("-t", "--threads", help="Number of cpu cores to extract with.") parser.add_argument("-f", "--force", help="Force the extraction of every xml instead of checking the touched ones.", action="store_true") + parser.add_argument("-j", "--jobs", help="Number of cpu cores to extract with.") parser.add_argument("-u", "--unaccounted", help="Enables ZAPD unaccounted detector warning system.", action="store_true") parser.add_argument("-Z", help="Pass the argument on to ZAPD, e.g. `-ZWunaccounted` to warn about unaccounted blocks in XMLs. Each argument should be passed separately, *without* the leading dash.", metavar="ZAPD_ARG", action="append") args = parser.parse_args() - global ZAPDArgs; - ZAPDArgs = ""; + global ZAPDArgs + ZAPDArgs = "" if args.Z is not None: - badZAPDArg = False; + badZAPDArg = False for i in range(len(args.Z)): z = args.Z[i] if z[0] == '-': - print(f"{colorama.Fore.LIGHTRED_EX}error{colorama.Fore.RESET}: argument \"{z}\" starts with \"-\", which is not supported.", file=os.sys.stderr); - badZAPDArg = True; + print(f"{colorama.Fore.LIGHTRED_EX}error{colorama.Fore.RESET}: argument \"{z}\" starts with \"-\", which is not supported.", file=os.sys.stderr) + badZAPDArg = True else: - args.Z[i] = "-" + z; + args.Z[i] = "-" + z if badZAPDArg: - exit(1); + exit(1) - ZAPDArgs = " ".join(args.Z); - print("Using extra ZAPD arguments: " + ZAPDArgs); + ZAPDArgs = " ".join(args.Z) + print("Using extra ZAPD arguments: " + ZAPDArgs) global mainAbort - mainAbort = Event() - manager = Manager() + mainAbort = multiprocessing.Event() + manager = multiprocessing.Manager() signal.signal(signal.SIGINT, SignalHandler) extractedAssetsTracker = manager.dict() @@ -125,12 +124,20 @@ def main(): if file.endswith(".xml"): xmlFiles.append(fullPath) - numCores = int(args.threads or 0) - if numCores <= 0: - numCores = 1 - print("Extracting assets with " + str(numCores) + " CPU core" + ("s" if numCores > 1 else "") + ".") - with Pool(numCores, initializer=initializeWorker, initargs=(mainAbort, args.unaccounted, extractedAssetsTracker, manager)) as p: - p.map(ExtractFunc, xmlFiles) + try: + numCores = int(args.jobs or 0) + if numCores <= 0: + numCores = 1 + print("Extracting assets with " + str(numCores) + " CPU core" + ("s" if numCores > 1 else "") + ".") + with multiprocessing.get_context("fork").Pool(numCores, initializer=initializeWorker, initargs=(mainAbort, args.unaccounted, extractedAssetsTracker, manager)) as p: + p.map(ExtractFunc, xmlFiles) + except (multiprocessing.ProcessError, TypeError): + print("Warning: Multiprocessing exception ocurred.", file=os.sys.stderr) + print("Disabling mutliprocessing.", file=os.sys.stderr) + + initializeWorker(mainAbort, args.unaccounted, extractedAssetsTracker, manager) + for singlePath in xmlFiles: + ExtractFunc(singlePath) with open(EXTRACTED_ASSETS_NAMEFILE, 'w', encoding='utf-8') as f: serializableDict = dict() diff --git a/format.sh b/format.sh index 89a0906ad1..1c9389a9ac 100755 --- a/format.sh +++ b/format.sh @@ -5,6 +5,16 @@ FORMAT_OPTS="-i -style=file" TIDY_OPTS="-p . --fix --fix-errors" COMPILER_OPTS="-fno-builtin -std=gnu90 -Iinclude -Isrc -D_LANGUAGE_C -DNON_MATCHING" +# https://backreference.org/2010/05/23/sanitizing-files-with-no-trailing-newline/index.html +# "gets the last character of the file pipes it into read, which will exit with a nonzero exit code if it encounters EOF before newline (so, if the last character of the file isn't a newline). If read exits nonzero, then append a newline onto the file using echo (if read exits 0, that satisfies the ||, so the echo command isn't run)." (https://stackoverflow.com/a/34865616) +function add_final_newline () { + for file in "$@" + do + tail -c1 $file | read -r _ || echo >> $file + done +} +export -f add_final_newline + shopt -s globstar if [ -z `command -v clang-format-${FORMAT_VER}` ] @@ -20,7 +30,7 @@ if (( $# > 0 )); then echo "Running clang-tidy..." clang-tidy ${TIDY_OPTS} "$@" -- ${COMPILER_OPTS} &> /dev/null echo "Adding missing final new lines..." - sed -i -e '$a\' "$@" + add_final_newline "$@" echo "Done formatting file(s) $*" exit fi @@ -31,6 +41,6 @@ clang-format-${FORMAT_VER} ${FORMAT_OPTS} src/**/*.c echo "Running clang-tidy..." clang-tidy ${TIDY_OPTS} src/**/*.c -- ${COMPILER_OPTS} &> /dev/null echo "Adding missing final new lines..." -find src/ -type f -name "*.c" -exec sed -i -e '$a\' {} \; -find assets/xml/ -type f -name "*.xml" -exec sed -i -e '$a\' {} \; +find src/ -type f -name "*.c" -exec bash -c 'add_final_newline "$@"' bash {} + +find assets/xml/ -type f -name "*.xml" -exec bash -c 'add_final_newline "$@"' bash {} + echo "Done formatting all files." diff --git a/include/functions.h b/include/functions.h index d4e7edb142..3c20bca11c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -15,8 +15,7 @@ s32 DmaMgr_FindDmaIndex(u32 vromAddr); const char* func_800809F4(u32 param_1); void DmaMgr_ProcessMsg(DmaRequest* req); void DmaMgr_ThreadEntry(void* arg); -s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, uintptr_t vromStart, size_t size, UNK_TYPE4 unused, - OSMesgQueue* callback, void* callbackMesg); +s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, uintptr_t vromStart, size_t size, UNK_TYPE4 unused, OSMesgQueue* callback, void* callbackMesg); s32 DmaMgr_SendRequest0(void* vramStart, uintptr_t vromStart, size_t size); void DmaMgr_Start(void); void DmaMgr_Stop(void); @@ -97,7 +96,7 @@ void FaultDrawer_SetCharPad(s8 padW, s8 padH); void FaultDrawer_SetCursor(s32 x, s32 y); void FaultDrawer_FillScreen(void); void* FaultDrawer_FormatStringFunc(void* arg, const char* str, size_t count); -void FaultDrawer_VPrintf(const char* str, char* args); +void FaultDrawer_VPrintf(const char* fmt, va_list ap); void FaultDrawer_Printf(const char* fmt, ...); void FaultDrawer_DrawText(s32 x, s32 y, const char* fmt, ...); void FaultDrawer_SetDrawerFB(void* fb, u16 w, u16 h); @@ -167,7 +166,7 @@ s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status); // void func_800867B4(void); // void func_800867D4(void); // void func_800867F4(void); -// void func_80086814(void); +f32 func_80086814(f32 x); // void func_80086834(void); // void func_80086880(void); // void func_800869A4(void); @@ -195,16 +194,7 @@ s32 func_80086D40(f64 param_1); f64 func_80086D6C(f64 param_1); s32 func_80086D8C(f32 param_1); s32 func_80086DAC(f64 param_1); -void* SystemArena_Malloc(size_t size); -void* SystemArena_MallocR(size_t size); -void* SystemArena_Realloc(void* oldPtr, size_t newSize); -void SystemArena_Free(void* ptr); -void* SystemArena_Calloc(u32 elements, size_t size); -void SystemArena_AnalyzeArena(size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated); -u32 SystemArena_CheckArena(void); -void SystemArena_InitArena(void* start, size_t size); -void SystemArena_Cleanup(void); -u8 SystemArena_IsInitialized(void); + s32 Rand_Next(void); void Rand_Seed(u32 seed); f32 Rand_ZeroOne(void); @@ -213,20 +203,7 @@ void Rand_Seed_Variable(u32* rndNum, u32 seed); u32 Rand_Next_Variable(u32* param_1); f32 Rand_ZeroOne_Variable(u32* param_1); f32 Rand_Centered_Variable(u32* param_1); -void ArenaImpl_LockInit(Arena* heap); -void ArenaImpl_Lock(Arena* heap); -void ArenaImpl_Unlock(Arena* heap); -ArenaNode* ArenaImpl_GetLastBlock(Arena* param_1); -void __osMallocInit(Arena* heap, void* heapBase, size_t heapSize); -void __osMallocAddBlock(Arena* heap, void* start, s32 size); -void __osMallocCleanup(Arena* heap); -u8 __osMallocIsInitalized(Arena* heap); -void* __osMalloc(Arena* heap, size_t size); -void* __osMallocR(Arena* heap, size_t size); -void __osFree(Arena* heap, void* ptr); -void* __osRealloc(Arena* heap, void* oldPtr, size_t newSize); -void __osAnalyzeArena(Arena* heap, size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated); -u32 __osCheckArena(Arena* heap); + void* proutSprintf(void* s, const char* buf, size_t n); s32 vsprintf(char* dst, char* fmt, va_list args); s32 sprintf(char* s, char* fmt, ...); @@ -305,8 +282,8 @@ void osViBlack(u8 active); s32 __osSiRawReadIo(u32 devAddr, u32* data); OSId osGetThreadId(OSThread* t); void osSpTaskYield(void); -s32 __osPfsGetNextPage(OSPfs* param_1, __OSInode* param_2, u8 param_3, u8 param_4); -s32 osPfsReadWriteFile(OSPfs* pfs, s32 file_no, u8 flag, s32 offset, s32 size_in_bytes, u8* data_buffer); +s32 __osPfsGetNextPage(OSPfs* pfs, u8* bank, __OSInode* inode, __OSInodeUnit* page); +s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8* data); s32 __osPfsGetStatus(OSMesgQueue* queue, s32 channel); // void __osPfsRequestOneChannel(void); // void __osPfsGetOneChannelData(void); @@ -317,8 +294,7 @@ void osViSetMode(OSViMode* modep); void guLookAtF(float mf[4][4], f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp); void guLookAt(Mtx* m, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp); s32 osPfsAllocateFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32 fileSize, s32* fileNo); -s32 __osPfsDeclearPage(OSPfs* pfs, __OSInode* inode, s32 fileSizeInPages, s32* startPage, u8 bank, s32* decleared, - s32* finalPage); +s32 __osPfsDeclearPage(OSPfs* pfs, __OSInode* inode, s32 fileSizeInPages, s32* startPage, u8 bank, s32* decleared, s32* finalPage); s32 osStopTimer(OSTimer* t); u32 __osProbeTLB(void* param_1); void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt); @@ -381,7 +357,7 @@ void guRotateF(float mf[4][4], f32 a, f32 x, f32 y, f32 z); void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z); void __osSetGlobalIntMask(u32 mask); // void osVoiceInit(void); -// void __osContChannelReset(void); +s32 __osContChannelReset(OSMesgQueue* mq, s32 channel); // void __osVoiceSetADConverter(void); s32 osAiSetFrequency(u32 frequency); s32 __osContRamRead(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer); @@ -493,58 +469,43 @@ void* __osMemcpy(void* dst, void* src, size_t size); // void EnItem00_DrawHeartContainer(EnItem00* this, GlobalContext* globalCtx); // void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx); // s16 func_800A7650(s16 dropId); -EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params); -Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params); +Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params); +Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 params); void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3f* spawnPos, s16 params); s32 func_800A8150(s32 index); s32 func_800A817C(s32 index); s32 func_800A81A4(GlobalContext* globalCtx, s32 a1, s32 a2); -void func_800A81F0(EffectBlure* this, Vec3f* p1, Vec3f* p2); -void func_800A8514(void* effectParams); -void EffectBlure_Initcommon(EffectBlure* params); -void EffectBlure_Init1(EffectBlure* params, EffBlureInit1* init); -void EffectBlure_Init2(EffectBlure* params, EffBlureInit2* init); -void EffectBlure_Destroy(EffectBlure* params); -s32 EffectBlure_Update(EffectBlure* params); -// void func_800A8C78(void); -// void func_800A8DE8(void); -// void func_800A92FC(void); -// void func_800A9330(void); -// void func_800A9804(void); -// void func_800AA190(void); -// void func_800AA460(void); -// void func_800AA498(void); -// void func_800AA700(void); -// void func_800AABE0(void); -void EffectBlure_Draw(EffectBlure* params, GraphicsContext* gfxCtx); -void EffectShieldParticle_Init(EffShieldParticleParams* params, EffShieldParticleInit* init); -void EffectShieldParticle_Destroy(EffShieldParticleParams* params); -s32 EffectShieldParticle_Update(EffShieldParticleParams* params); -void EffectShieldParticle_CalculateColors(EffShieldParticleParams* params, Color_RGBA8* primColor, Color_RGBA8* envColor); -void EffectShieldParticle_Draw(EffShieldParticleParams* params, GraphicsContext* gfxCtx); -void EffectSpark_Init(EffSparkParams* params, EffSparkParams* init); -void EffectSpark_Destroy(EffSparkParams* params); -s32 EffectSpark_Update(EffSparkParams* params); -void EffectSpark_Draw(EffSparkParams* params, GraphicsContext* gfxCtx); -void func_800AE2A0(GlobalContext* globalCtx, Color_RGBA8* arg1, s16 arg2, s16 arg3); -void func_800AE434(GlobalContext* globalCtx, Color_RGBA8* color, s16 sParm3, s16 sParm4); +void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2); +void EffectBlure_AddSpace(EffectBlure* this); +void EffectBlure_Init1(void* thisx, void* initParamsx); +void EffectBlure_Init2(void* thisx, void* initParamsx); +void EffectBlure_Destroy(void* thisx); +s32 EffectBlure_Update(void* thisx); +void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx); +void EffectShieldParticle_Init(void* thisx, void* initParamsx); +void EffectShieldParticle_Destroy(void* thisx); +s32 EffectShieldParticle_Update(void* thisx); +void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx); +void EffectSpark_Init(void* thisx, void* initParamsx); +void EffectSpark_Destroy(void* thisx); +s32 EffectSpark_Update(void* thisx); +void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx); +void func_800AE2A0(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3); +void func_800AE434(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3); void func_800AE5A0(GlobalContext* globalCtx); -void func_800AE5E4(GlobalContext* globalCtx, Color_RGBA8* arg1, s16 arg2, s16 arg3); -void func_800AE778(GlobalContext* globalCtx, Color_RGBA8* color, s16 param_3, s16 param_4); +void func_800AE5E4(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3); +void func_800AE778(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3); void func_800AE8EC(GlobalContext* globalCtx); -void func_800AE930(CollisionContext* colCtx, s32 param_2, Vec3f* param_3, f32 param_4, s16 param_5, CollisionPoly* param_6, s32 param_7); -void func_800AEF44(s32 arg0); -void EffectTireMark_InitParticle(EffTireMarkParticle* particle); -void EffectTireMark_Init(EffTireMarkParams* params, EffTireMarkInit* init); -void EffectTireMark_Destroy(EffTireMarkParams* params); -s32 EffectTireMark_Update(EffTireMarkParams* params); -void EffectTireMark_InitVertices(F3DVertexColor* vertices, EffTireMarkParticle* particle, s32 index, s32 alpha); -void EffectTireMark_Draw(EffTireMarkParams* params, GraphicsContext* gfxCtx); -GlobalContext* Effect_GetContext(void); -void* Effect_GetParams(s32 index); -void Effect_InitCommon(EffCommon* common); +void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f32 arg3, s16 angle, CollisionPoly* colPoly, s32 arg6); +void func_800AEF44(EffectTireMark* this); +void EffectTireMark_Init(void* thisx, void* initParamsx); +void EffectTireMark_Destroy(void* thisx); +s32 EffectTireMark_Update(void* thisx); +void EffectTireMark_Draw(void* thisx, GraphicsContext* gfxCtx); +GlobalContext* Effect_GetGlobalCtx(void); +void* Effect_GetByIndex(s32 index); void Effect_Init(GlobalContext* globalCtx); -void Effect_Add(GlobalContext* globalCtx, s32* index, s32 type, u8 param_4, u8 param_5, void* initParams); +void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams); void Effect_DrawAll(GraphicsContext* gfxCtx); void Effect_UpdateAll(GlobalContext* globalCtx); void Effect_Destroy(GlobalContext* globalCtx, s32 index); @@ -566,70 +527,51 @@ s16 func_800B09D0(s16 a0, s16 a1, f32 a2); u8 func_800B0A24(u8 a0, u8 a1, f32 a2); void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* texture); void EffectSsDust_Spawn(GlobalContext* globalCtx, u16 drawFlags, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life, u8 updateMode); -void func_800B0DE0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void func_800B0E48(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void func_800B0EB0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); -void func_800B0F18(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); -void func_800B0F80(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); -void func_800B0FE8(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void func_800B1054(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep); +void func_800B0DE0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); +void func_800B0E48(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); +void func_800B0EB0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); +void func_800B0F18(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); +void func_800B0F80(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); +void func_800B0FE8(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); +void func_800B1054(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); void func_800B10C0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel); void func_800B1130(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel); void func_800B11A0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); void func_800B1210(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); -void func_800B1280(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, - s16 life); -void func_800B12F0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, - s16 life); -void func_800B1360(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor); -void func_800B139C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor); +void func_800B1280(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life); +void func_800B12F0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life); +void func_800B1360(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); +void func_800B139C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); void func_800B13D8(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity, Vec3f* accel); void func_800B14D4(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos); void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos); void EffectSsKiraKira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel); -void EffectSsKiraKira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, - Color_RGBA8* primColor, Color_RGBA8* envColor); -void EffectSsGSpk_SpawnSmall(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, - Color_RGBA8* primColor, Color_RGBA8* envColor); +void EffectSsKiraKira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); +void EffectSsGSpk_SpawnSmall(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life); // void EffectSsKiraKira_SpawnFocused(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); // void EffectSsBomb2_SpawnFade(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4); -void EffectSsBomb2_SpawnLayered(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, - s16 scaleStep); +void EffectSsBomb2_SpawnLayered(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); // void EffectSsBlast_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, Color_RGBA8* param_5, Color_RGBA8* param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); -// void EffectSsBlast_SpawnWhiteCustomScale(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); +void EffectSsBlast_SpawnWhiteCustomScale(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, + s16 scaleStep, s16 life); // void EffectSsBlast_SpawnShockwave(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7); -// void EffectSsBlast_SpawnWhiteShockwave(void); +void EffectSsBlast_SpawnWhiteShockwave(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3); // void EffectSsGSpk_SpawnAccel(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, Vec3f* pzParm4, Vec3f* param_5, Color_RGBA8* param_6, Color_RGBA8* param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9); // void EffectSsGSpk_SpawnNoAccel(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9); // void EffectSsGSpk_SpawnFuse(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void EffectSsGSpk_SpawnRandColor(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); // void EffectSsGSpk_SpawnSmall(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, - s16 alpha, s16 fadeDelay, s16 life, s32 arg9); -void EffectSsBubble_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale, - f32 scale); +void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 alpha, s16 fadeDelay, s16 life, s32 arg9); +void EffectSsBubble_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale, f32 scale); void EffectSsGRipple_Spawn(GlobalContext* globalCtx, Vec3f* pos, s16 radius, s16 radiusMax, s16 life); -void EffectSsGSplash_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, - s16 type, s16 scale); +void EffectSsGSplash_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 type, s16 scale); // void EffectSsGFire_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2); // void EffectSsLightning_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Color_RGBA8* pzParm3, Color_RGBA8* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8); // void EffectSsDtBubble_SpawnColorProfile(UNK_TYPE4 param_1, Vec3f* param_2, Vec3f* param_3, Vec3f* param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8); -void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, - Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 life, s16 randXZ); -void EffectSsHahen_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16 scale, - s16 objId, s16 life, Gfx* dList); -void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstScale, s16 unused, s16 scale, - s16 randScaleRange, s16 count, s16 objId, s16 life, Gfx* dList); +void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 life, s16 randXZ); +void EffectSsHahen_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16 scale, s16 objId, s16 life, Gfx* dList); +void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstScale, s16 unused, s16 scale, s16 randScaleRange, s16 count, s16 objId, s16 life, Gfx* dList); // void func_800B2364(void); // void EffectSsStick_Spawn(UNK_TYPE4 uParm1, UNK_PTR puParm2, UNK_TYPE2 uParm3); // void EffectSsSibuki_Spawn(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); @@ -640,104 +582,85 @@ void EffectSsHitMark_SpawnFixedScale(GlobalContext* globalCtx, s32 type, Vec3f* // void EffectSsHitMark_SpawnCustomScale(void); // void EffectSsFhgFlash_SpawnShock(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE2 uParm4, UNK_TYPE1 param_5); // void EffectSsKFire_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE1 param_6); -void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, - s16* linkDetected, s16 drawFlag); -void EffectSsKakera_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, - s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, - s16 objId, Gfx* dList); +void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16* linkDetected, s16 drawFlag); +void EffectSsKakera_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, s16 objId, Gfx* dList); // void EffectSsIcePiece_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, UNK_TYPE4 uParm3, Vec3f* pzParm4, Vec3f* param_5, UNK_TYPE4 param_6); // void EffectSsIcePiece_SpawnBurst(void); // void EffectSsEnIce_SpawnFlyingVec3f(UNK_TYPE4 uParm1, Actor* pzParm2, Vec3f* pzParm3, Color_RGBA8* pzParm4, Color_RGBA8* param_5, UNK_TYPE4 param_6); // void func_800B2B44(void); // void func_800B2B7C(void); -void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, - Color_RGBA8* primColor, Color_RGBA8* envColor, s32 life); +void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s32 life); // void EffectSsFireTail_Spawn(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE4 uParm4, Vec3f* param_5, UNK_TYPE2 param_6, Color_RGBA8* param_7, Color_RGBA8* param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE4 param_11); // void EffectSsFireTail_SpawnFlame(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); // void EffectSsFireTail_SpawnFlameOnPlayer(void); void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s16 scale, s16 arg4, s16 flags, s16 bodyPart); // void EffectSsEnFire_SpawnVec3s(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); // void EffectSsExtra_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); -void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, - s16 scale, s16 scaleStep, s32 unk); -void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, - s32 colorIndex); +void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk); +void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s32 colorIndex); // void EffectSsDeadDd_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE1* param_5, UNK_TYPE1* param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE4 param_10); // void EffectSsDeadDs_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); // void func_800B31BC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); void EffectSsIceSmoke_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); -// void EffectSsIceBlock_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5); +void EffectSsIceBlock_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); void FlagSet_Update(GameState* gameState); void FlagSet_Draw(GameState* gameState); void Overlay_LoadGameState(GameStateOverlay* gameState); void Overlay_FreeGameState(GameStateOverlay* gameState); -void Actor_PrintLists(ActorContext* actorCtx); -void ActorShape_Init(ActorShape* actorShape, f32 yOffset, ActorShadowFunc func, f32 scale); -void ActorShadow_Draw(Actor* actor, Lights* mapper, GlobalContext* globalCtx, Gfx* displayList, Color_RGBA8* color); -void func_800B3FC0(Actor* actor, Lights* mapper, GlobalContext* globalCtx); -void func_800B4024(Actor* actor, Lights* mapper, GlobalContext* globalCtx); -void func_800B4088(Actor* actor, Lights* mapper, GlobalContext* globalCtx); -void func_800B40B8(Actor* actor, Lights* mapper, GlobalContext* globalCtx); -void func_800B40E0(GlobalContext* globalCtx, Light* light, MtxF* arg2, s32 arg3, f32 arg4, f32 arg5, f32 arg6); -void func_800B42F8(Actor* actor, Lights* mapper, GlobalContext* globalCtx); -// void func_800B4A98(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -void func_800B4AEC(GlobalContext* globalCtx, Actor* actor, f32 param_3); + +void ActorShape_Init(ActorShape* actorShape, f32 yOffset, ActorShadowFunc shadowDraw, f32 shadowScale); +void ActorShadow_DrawCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx); +void ActorShadow_DrawSquare(Actor* actor, Lights* lights, GlobalContext* globalCtx); +void ActorShadow_DrawWhiteCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx); +void ActorShadow_DrawHorse(Actor* actor, Lights* lights, GlobalContext* globalCtx); + +void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx); +void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* leftFootPos, s32 rightFootIndex, Vec3f* rightFootPos); +void func_800B4AEC(GlobalContext* globalCtx, Actor* actor, f32 y); void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx); -void func_800B4EDC(GlobalContext* globalCtx, Vec3f* pzParm2, Vec3f* pzParm3, f32* pfParm4); -// void func_800B4F40(TargetContext* targetCtx, s32 param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4, UNK_TYPE4 param_5); -void func_800B4F78(TargetContext* targetCtx, u8 type, GlobalContext* globalCtx); -void func_800B5040(TargetContext* targetCtx, Actor* actor, u8 type, GlobalContext* globalCtx); -void Actor_TargetContextInit(TargetContext* targetCtx, Actor* actor, GlobalContext* globalCtx); -void func_800B5208(TargetContext* targetCtx, GlobalContext* globalCtx); -void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GlobalContext* globalCtx); -u32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag); -void Actor_SetSwitchFlag(GlobalContext* globalCtx, s32 flag); -void Actor_UnsetSwitchFlag(GlobalContext* globalCtx, s32 flag); -u32 Actor_GetChestFlag(GlobalContext* globalCtx, u32 flag); -void Actor_SetChestFlag(GlobalContext* globalCtx, u32 flag); -void Actor_SetAllChestFlag(GlobalContext* globalCtx, u32 flags); -u32 Actor_GetAllChestFlag(GlobalContext* globalCtx); -u32 Actor_GetRoomCleared(GlobalContext* globalCtx, u32 roomNumber); -void Actor_SetRoomCleared(GlobalContext* globalCtx, u32 roomNumber); -void Actor_UnsetRoomCleared(GlobalContext* globalCtx, u32 roomNumber); -u32 Actor_GetRoomClearedTemp(GlobalContext* globalCtx, u32 roomNumber); -void Actor_SetRoomClearedTemp(GlobalContext* globalCtx, u32 roomNumber); -void Actor_UnsetRoomClearedTemp(GlobalContext* globalCtx, u32 roomNumber); -u32 Actor_GetCollectibleFlag(GlobalContext* globalCtx, s32 index); -void Actor_SetCollectibleFlag(GlobalContext* globalCtx, s32 index); -void Actor_TitleCardContextInit(GlobalContext* globalCtx, TitleCardContext* titleCardCtx); -void Actor_TitleCardCreate(GlobalContext* globalCtx, TitleCardContext* titleCardCtx, u32 texture, s16 param_4, s16 param_5, u8 param_6, u8 param_7); -// void Actor_Nop800B5E50(UNK_TYPE4 param_1, UNK_TYPE4 param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4); -void Actor_TitleCardUpdate(GlobalContext* globalCtx, TitleCardContext* titleCardCtx); -void Actor_TitleCardDraw(GlobalContext* globalCtx, TitleCardContext* titleCardCtx); -// UNK_TYPE4 func_800B6434(GlobalContext* globalCtx, TitleCardContext* titleCardCtx); -// UNK_TYPE4 func_800B645C(void); -void func_800B6468(GlobalContext* globalCtx); -void func_800B6474(GlobalContext* globalCtx); -// UNK_TYPE4 func_800B648C(GlobalContext* globalCtx, UNK_TYPE1 param_2, UNK_TYPE1 param_3, f32 param_4, Vec3f* param_5); -f32 func_800B64FC(GlobalContext* globalCtx, f32 fParm2, Vec3f* pzParm3, u32* puParm4); -void* func_800B6584(GlobalContext* globalCtx, s16 sParm2, void* pvParm3, u32 uParm4); -// UNK_TYPE4 func_800B6608(s32 iParm1, s16 sParm2); -// void func_800B6680(void); +void Actor_GetProjectedPos(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3); + +void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx); + +s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag); +void Flags_SetSwitch(GlobalContext* globalCtx, s32 flag); +void Flags_UnsetSwitch(GlobalContext* globalCtx, s32 flag); +s32 Flags_GetTreasure(GlobalContext* globalCtx, s32 flag); +void Flags_SetTreasure(GlobalContext* globalCtx, s32 flag); +void Flags_SetAllTreasure(GlobalContext* globalCtx, s32 flag); +s32 Flags_GetAllTreasure(GlobalContext* globalCtx); +s32 Flags_GetClear(GlobalContext* globalCtx, s32 roomNumber); +void Flags_SetClear(GlobalContext* globalCtx, s32 roomNumber); +void Flags_UnsetClear(GlobalContext* globalCtx, s32 roomNumber); +s32 Flags_GetClearTemp(GlobalContext* globalCtx, s32 roomNumber); +void Flags_SetClearTemp(GlobalContext* globalCtx, s32 roomNumber); +void Flags_UnsetClearTemp(GlobalContext* globalCtx, s32 roomNumber); +s32 Flags_GetCollectible(GlobalContext* globalCtx, s32 flag); +void Flags_SetCollectible(GlobalContext* globalCtx, s32 flag); + +void TitleCard_InitBossName(GameState* gameState, TitleCardContext* titleCtx, TexturePtr texture, s16 x, s16 y, u8 width, u8 height); + +s32 func_800B648C(GlobalContext* globalCtx, s32 arg1, s32 arg2, f32 arg3, Vec3f* arg4); +f32 func_800B64FC(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2, u32* arg3); +void* func_800B6584(GlobalContext* globalCtx, s16 id, void* arg2, size_t size); +void* func_800B6608(GlobalContext* globalCtx, s16 id); +void* func_800B6680(GlobalContext* globalCtx, s16 id); void Actor_MarkForDeath(Actor* actor); -void Actor_InitCurrPosition(Actor* actor); -void Actor_SetHeight(Actor* actor, f32 height); -void Actor_SetRotationFromDrawRotation(Actor* actor); -void Actor_InitDrawRotation(Actor* actor); +void Actor_SetWorldToHome(Actor* actor); +void Actor_SetFocus(Actor* actor, f32 height); +void Actor_SetWorldRotToShape(Actor* actor); +void Actor_SetShapeRotToWorld(Actor* actor); void Actor_SetScale(Actor* actor, f32 scale); -void Actor_SetObjectSegment(GlobalContext* globalCtx, Actor* actor); -void Actor_InitToDefaultValues(Actor* actor, GlobalContext* globalCtx); -void Actor_FiniActor(Actor* actor, GlobalContext* globalCtx); +void Actor_SetObjectDependency(GlobalContext* globalCtx, Actor* actor); void Actor_SetMovementScale(s32 scale); -void Actor_ApplyMovement(Actor* actor); -void Actor_SetVelocityYRotationAndGravity(Actor* actor); -void Actor_SetVelocityAndMoveYRotationAndGravity(Actor* actor); -void Actor_SetVelocityXYRotation(Actor* actor); -void Actor_SetVelocityAndMoveXYRotation(Actor* actor); -void Actor_SetVelocityXYRotationReverse(Actor* actor); -void Actor_SetVelocityAndMoveXYRotationReverse(Actor* actor); -void func_800B6C04(Actor* actor, f32 fParm2); -// void func_800B6C58(Actor* actor, UNK_TYPE4 param_2); +void Actor_UpdatePos(Actor* actor); +void Actor_UpdateVelocityWithGravity(Actor* actor); +void Actor_MoveWithGravity(Actor* actor); +void Actor_UpdateVelocityWithoutGravity(Actor* actor); +void Actor_MoveWithoutGravity(Actor* actor); +void Actor_UpdateVelocityWithoutGravityReverse(Actor* actor); +void Actor_MoveWithoutGravityReverse(Actor* actor); +void Actor_SetSpeeds(Actor* actor, f32 speed); s16 Actor_YawBetweenActors(Actor* from, Actor* to); s16 Actor_YawBetweenActorsTop(Actor* from, Actor* to); s16 Actor_YawToPoint(Actor* actor, Vec3f* point); @@ -748,171 +671,142 @@ f32 Actor_DistanceBetweenActors(Actor* actor1, Actor* actor2); f32 Actor_DistanceToPoint(Actor* actor, Vec3f* point); f32 Actor_XZDistanceBetweenActors(Actor* actor1, Actor* actor2); f32 Actor_XZDistanceToPoint(Actor* actor, Vec3f* point); -void Actor_CalcOffsetOrientedToDrawRotation(Actor* actor, Vec3f* offset, Vec3f* point); -f32 Actor_YDistance(Actor* actor1, Actor* actor2); -void func_800B6F20(GlobalContext* globalCtx, s32 param_2, f32 param_3, s16 param_4); -float func_800B6FC8(Player* player); -// void func_800B7090(void); -// void func_800B7118(void); -// void func_800B7128(void); +void Actor_OffsetOfPointInActorCoords(Actor* actor, Vec3f* offset, Vec3f* point); +f32 Actor_HeightDiff(Actor* actor1, Actor* actor2); +void func_800B6F20(GlobalContext* globalCtx, Input* input, f32 arg2, s16 arg3); +f32 Player_GetHeight(Player* player); +f32 Player_GetRunSpeedLimit(Player* player); +s32 func_800B7118(Player* player); +s32 func_800B7128(Player* player); s32 func_800B715C(GlobalContext* globalCtx); -// void func_800B7170(void); -// void func_800B71DC(void); -u32 func_800B7200(s32 param_1); -// void func_800B722C(void); -void func_800B724C(GlobalContext* globalCtx, Actor* actor, u8 arg2); -u32 func_800B7298(GlobalContext* globalCtx, Actor* actor, u8 arg2); -void func_800B72E0(s32 param_1); -void func_800B72F8(DynaPolyActor* dpactor, f32 a1, s16 a2); -s32 Actor_IsLinkFacingActor(Actor* actor, s16 tolerance, GlobalContext* globalCtx); -s32 Actor_IsActorFacedByActor(Actor* actor, Actor* other, s16 tolerance); -s32 Actor_IsActorFacingLink(Actor* actor, s16 angle); -s32 Actor_IsActorFacingActor(Actor* actor, Actor* other, s16 tolerance); -s32 Actor_IsActorFacingLinkAndWithinRange(Actor* actor, f32 range, s16 tolerance); -s32 Actor_IsActorFacingActorAndWithinRange(Actor* actor, Actor* other, f32 range, s16 tolerance); -void func_800B75A0(CollisionPoly* param_1, Vec3f* param_2, s16* param_3); -// UNK_TYPE4 func_800B761C(Actor* param_1, UNK_TYPE4 param_2, u32 param_3); -// UNK_TYPE4 func_800B7678(GlobalContext* globalCtx, Actor* param_2, s32 param_3, u32 param_4); +void Actor_SetCameraHorseSetting(GlobalContext* globalCtx, Player* player); +void Actor_MountHorse(GlobalContext* globalCtx, Player* player, Actor* horse); +s32 func_800B724C(GlobalContext* globalCtx, Actor* actor, u8 csMode); +u32 func_800B7298(GlobalContext* globalCtx, Actor* actor, u8 csMode); +void func_800B72F8(DynaPolyActor* dyna, f32 extraPushForce, s16 yRotation); + +s32 Player_IsFacingActor(Actor* actor, s16 maxAngleDiff, GlobalContext* globalCtx); +s32 Actor_ActorBIsFacingActorA(Actor* actorA, Actor* actorB, s16 maxAngleDiff); +s32 Actor_IsFacingPlayer(Actor* actor, s16 angle); +s32 Actor_ActorAIsFacingActorB(Actor* actorA, Actor* actorB, s16 maxAngleDiff); +s32 Actor_IsFacingAndNearPlayer(Actor* actor, f32 range, s16 maxAngleDiff); +s32 Actor_ActorAIsFacingAndNearActorB(Actor* actorA, Actor* actorB, f32 range, s16 maxAngleDiff); + +void func_800B75A0(CollisionPoly* poly, Vec3f* normal, s16* azimuth); void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallCheckHeight, f32 wallCheckRadius, f32 ceilingCheckHeight, u32 flags); -// void func_800B7E04(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -Hilite* func_800B7FE0(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx); -// void func_800B8018(void); -void func_800B8050(Actor* actor, GlobalContext* globalCtx, s32 iParm3); -void func_800B8118(Actor* actor, GlobalContext* globalCtx, s32 iParm3); -// void func_800B81E0(void); -UNK_PTR func_800B8214(PosRot* param_1, Actor* param_2); -f32* func_800B8248(PosRot* param_1, Player* param_2); -// void func_800B82EC(void); -// void func_800B83BC(void); -// void func_800B83F8(void); -s32 func_800B84D0(Actor* actor, GlobalContext* globalCtx); // Actor_IsTalking -s32 func_800B8500(Actor* actor, GlobalContext* globalCtx, f32 fParm3, f32 fParm4, s32 param_5); -s32 func_800B85E0(Actor* actor, GlobalContext* globalCtx, f32 uParm3, s32 uParm4); -s32 func_800B8614(Actor* actor, GlobalContext* globalCtx, f32 uParm3); +Hilite* Hilite_DrawOpa(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx); +void func_800B8050(Actor* actor, GlobalContext* globalCtx, s32 flag); +void func_800B8118(Actor* actor, GlobalContext* globalCtx, s32 flag); +PosRot* Actor_GetFocus(PosRot* dest, Actor* actor); +PosRot* Actor_GetWorld(PosRot* dest, Actor* actor); +PosRot* Actor_GetWorldPosShapeRot(PosRot* dest, Actor* actor); + +s32 func_800B83F8(Actor* actor, Player* player, s32 flag); +s32 Actor_ProcessTalkRequest(Actor* actor, GameState* gameState); +s32 func_800B8500(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId); +s32 func_800B85E0(Actor* actor, GlobalContext* globalCtx, f32 radius, s32 exchangeItemId); +s32 func_800B8614(Actor* actor, GlobalContext* globalCtx, f32 radius); s32 func_800B863C(Actor* actor, GlobalContext* globalCtx); -u32 func_800B867C(Actor* actor, GlobalContext* globalCtx); -UNK_TYPE4 func_800B86C8(Actor* actor1, GlobalContext* globalCtx, Actor* actor2); -s32 func_800B8708(GlobalContext* globalCtx); -s32 func_800B8718(Actor* actor, GlobalContext* globalCtx); -void func_800B874C(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3); -// void func_800B8804(void); -// void func_800B882C(void); -// void func_800B886C(void); -void func_800B8898(GlobalContext* globalCtx, Actor* actor, s16* arg2, s16* arg3); +s32 Actor_TextboxIsClosing(Actor* actor, GlobalContext* globalCtx); +s32 Actor_ChangeFocus(Actor* actor1, GlobalContext* globalCtx, Actor* actor2); +s32 Player_GetExchangeItemId(GlobalContext* globalCtx); +s32 func_800B8718(Actor* actor, GameState* gameState); +s32 func_800B874C(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange); +s32 func_800B8804(Actor* actor, GlobalContext* globalCtx, f32 xzRange); +s32 func_800B886C(Actor* actor, GlobalContext* globalCtx); +void Actor_GetScreenPos(GlobalContext* globalCtx, Actor* actor, s16* x, s16* y); s32 func_800B8934(GlobalContext* globalCtx, Actor* actor); -u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx); -UNK_TYPE4 func_800B8A1C(Actor* actor, GlobalContext* globalCtx, s32 iParm3, f32 fParm4, f32 param_5); -s32 func_800B8B84(Actor* actor, GlobalContext* globalCtx, s32 getItemId); -void func_800B8BB0(Actor* actor, GlobalContext* globalCtx); -// void func_800B8BD0(void); +s32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx); +s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRange, f32 yRange); +s32 Actor_PickUpNearby(Actor* actor, GlobalContext* globalCtx, s32 getItemId); +s32 Actor_LiftActor(Actor* actor, GlobalContext* globalCtx); +s32 Actor_PickUpFar(Actor* actor, GlobalContext* globalCtx, s32 getItemId); s32 Actor_HasNoParent(Actor* actor, GlobalContext* globalCtx); -// void func_800B8C20(void); +void func_800B8C20(Actor* actorA, Actor* actorB, GlobalContext* globalCtx); void func_800B8C50(Actor* actor, GlobalContext* globalCtx); -// void func_800B8C78(void); -// void func_800B8C9C(void); -// void func_800B8CEC(void); -// void func_800B8D10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); +s32 Actor_HasRider(GlobalContext* globalCtx, Actor* horse); +s32 Actor_SetRideActor(GlobalContext* globalCtx, Actor* horse, s32 mountSide); +s32 Actor_HasNoRider(GlobalContext* globalCtx, Actor* horse); +void func_800B8D10(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5, u32 arg6); void func_800B8D50(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 yaw, f32 arg4, u32 arg5); void func_800B8D98(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4); -// void func_800B8DD4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_800B8E1C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -void func_800B8E58(Actor* actor, u16 sfxId); -void Audio_PlayActorSound2(Actor* actor, u16 sfxId); -// void func_800B8FC0(void); +void func_800B8DD4(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5); +void func_800B8E1C(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4); +void func_800B8E58(Player* player, u16 sfxId); +void Actor_PlaySfxAtPos(Actor* actor, u16 sfxId); +void func_800B8EF4(GlobalContext* globalCtx, Actor* actor); void func_800B8F98(Actor* actor, u16 sfxId); +void func_800B8FC0(Actor* actor, u16 sfxId); void func_800B8FE8(Actor* actor, u16 sfxId); void func_800B9010(Actor* actor, u16 sfxId); -// void func_800B9038(void); -// void func_800B9084(void); +void func_800B9038(Actor* actor, s32 timer); +void func_800B9084(Actor* actor); void func_800B9098(Actor* actor); -s32 func_800B90AC(GlobalContext* globalCtx, Actor* actor, UNK_TYPE arg2, UNK_TYPE arg3, UNK_TYPE arg4); -// void func_800B90F4(void); +s32 func_800B90AC(GlobalContext* globalCtx, Actor* actor, CollisionPoly* polygon, s32 index, s32 arg4); +void func_800B90F4(GlobalContext* globalCtx); void func_800B9120(ActorContext* actorCtx); -// void Actor_Init(GlobalContext* globalCtx, ActorContext* actorCtx, UNK_TYPE4 uParm3); -void func_800B9334(GlobalContext* globalCtx, ActorContext* actorCtx); -Actor* Actor_UpdateActor(s800B948C* params); +void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry* actorEntry); void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx); -void Actor_DrawActor(GlobalContext* globalCtx, Actor* actor); -void func_800B9D1C(Actor* actor); -void Actor_DrawAllSetup(GlobalContext* globalCtx); s32 Actor_RecordUndrawnActor(GlobalContext* globalCtx, Actor* actor); -// void func_800B9E84(void); -void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors); -s32 func_800BA2D8(GlobalContext* globalCtx, Actor* actor); -s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* param_3, f32 param_4); void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx); void func_800BA6FC(GlobalContext* globalCtx, ActorContext* actorCtx); void func_800BA798(GlobalContext* globalCtx, ActorContext* actorCtx); -void func_800BA8B8(GlobalContext* globalCtx, ActorContext* actorCtx); -// void func_800BA9B4(void); -void Actor_InsertIntoTypeList(ActorContext* actorCtx, Actor* actor, u8 type); -Actor* Actor_RemoveFromTypeList(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actor); -void Actor_FreeOverlay(ActorOverlay* entry); -Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s16 sParm10); -ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index); -Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s32 variable, u32 cutscene, s32 param_12, Actor* parent); -Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s32 variable); +void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx); +Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params); +Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s32 params, u32 cutscene, s32 arg11, Actor* parent); +Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params); void Actor_SpawnTransitionActors(GlobalContext* globalCtx, ActorContext* actorCtx); -void func_800BB2D0(ActorContext* actorCtx, u16* param_2, GlobalContext* globalCtx); -Actor* func_800BB498(ActorContext* actorCtx, Actor* actor, GlobalContext* globalCtx); -// void func_800BB59C(void); -// void func_800BB604(void); -// void func_800BB8EC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); void Enemy_StartFinishingBlow(GlobalContext* globalCtx, Actor* actor); -// void func_800BBAC0(void); -void func_800BBB74(s16* arg1, UNK_TYPE1 arg2, UNK_TYPE1 arg3, UNK_TYPE4 arg4); -// void func_800BBC20(void); -void func_800BBCEC(Actor* actor, GlobalContext* globalCtx, s16 arg2, Gfx** dList); -void func_800BBDAC(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, f32 arg3, UNK_TYPE4 arg4, f32 arg5, s16 arg6, s16 arg7, u8 arg8); -void func_800BBFB0(GlobalContext* globalCtx, Vec3f* position, f32 param3, s32 param_4, s16 param_5, s16 param_6, u8 param_7); +s16 func_800BBAC0(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3); +s16 func_800BBB74(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3); +void Actor_SpawnBodyParts(Actor* actor, GlobalContext* globalCtx, s32 arg2, Gfx** dList); +void Actor_SpawnFloorDustRing(GlobalContext* globalCtx, Actor* actor, Vec3f* posXZ, f32 radius, s32 countMinusOne, f32 randAccelWeight, s16 scale, s16 scaleStep, u8 useLighting); +void func_800BBFB0(GlobalContext* globalCtx, Vec3f* position, f32 arg2, s32 arg3, s16 arg4, s16 scaleStep, u8 arg6); void func_800BC154(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actor, u8 actorCategory); -// void func_800BC188(void); -// void func_800BC1B4(void); -Actor* func_800BC270(GlobalContext* globalCtx, Actor* actor, f32 arg2, UNK_TYPE4 arg3); +s32 func_800BC188(s32 index); +Actor* func_800BC270(GlobalContext* globalCtx, Actor* actor, f32 arg2, s32 arg3); Actor* func_800BC444(GlobalContext* globalCtx, Actor* actor, f32 arg2); -// void func_800BC4EC(void); -s32 func_800BC5B8(GlobalContext* globalCtx, Actor* actor); -s32 func_800BC5EC(GlobalContext* globalCtx, Actor* actor); -void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 arg2, GlobalContext* globalCtx); -// void func_800BC770(void); -// void func_800BC7D8(void); +s16 Actor_TestFloorInDirection(Actor* actor, GlobalContext* globalCtx, f32 distance, s16 angle); +s32 Actor_IsTargeted(GlobalContext* globalCtx, Actor* actor); +s32 Actor_OtherIsTargeted(GlobalContext* globalCtx, Actor* actor); +void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx); +void func_800BC770(GlobalContext* globalCtx, s16 y, s16 countdown); +void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed); void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 arg2, s16 arg3); -// void func_800BC8B8(void); -// void func_800BCB50(void); -void func_800BCB70(Actor* actor, u16 arg1, u16 arg2, s16 arg3, s16 arg4); -void func_800BCBF4(Vec3f* uParm1, GlobalContext* globalCtx); -void func_800BCC68(Vec3f* param_1, GlobalContext* globalCtx); -UNK_RET func_800BCCDC(Vec3s* points, u8 pathcount, Vec3f* pos1, Vec3f* pos2, UNK_TYPE parm5); -// void func_800BD2B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_800BD384(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE1 param_9); -// void func_800BD6E4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -void func_800BD888(Actor*, struct_800BD888_arg1*, s16, s16); // This function is very similar to OoT's func_80034A14 -// void func_800BD9A0(void); -// void func_800BD9E0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6); -// void func_800BDAA0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6); -// void func_800BDB6C(void); -void func_800BDC5C(SkelAnime* skelAnime, ActorAnimationEntry animation[], s32 index); -// void func_800BDCF4(void); +void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type); +void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 xluFlag, u16 duration); +Hilite* func_800BCBF4(Vec3f* arg0, GlobalContext* globalCtx); +Hilite* func_800BCC68(Vec3f* arg0, GlobalContext* globalCtx); +void func_800BCCDC(Vec3s* points, s32 pathCount, Vec3f* pos1, Vec3f* pos2, s32 parm5); +s32 func_800BD2B4(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 arg3, u16 (*textIdCallback)(GlobalContext*, Actor*), s16 (*arg5)(GlobalContext*, Actor*)); +void func_800BD888(Actor* actor, struct_800BD888_arg1* arg1, s16 arg2, s16 arg3); +void func_800BD9E0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); +void func_800BDAA0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); +void Actor_ChangeAnimation(SkelAnime* skelAnime, ActorAnimationEntry* animation, s32 index); void Actor_Noop(Actor* actor, GlobalContext* globalCtx); -void func_800BDFC0(GlobalContext* globalCtx, Gfx* dl); -void func_800BE03C(GlobalContext* globalCtx, Gfx* dl); -Actor* func_800BE0B8(GlobalContext* globalCtx, Actor* inActor, s16 arg2, u8 arg3, f32 arg4); -s32 func_800BE184(GlobalContext* globalCtx, Actor* actor, f32 arg2, s32 arg3, s32 arg4, s32 arg5); -u8 Actor_ApplyDamage(Actor* actor); // returns current health -void func_800BE258(Actor* actor, UNK_PTR arg1); -void func_800BE2B8(Actor* actor, ColliderJntSph* jntSphere); + +void Gfx_DrawDListOpa(GlobalContext* globalCtx, Gfx* dlist); +void Gfx_DrawDListXlu(GlobalContext* globalCtx, Gfx* dlist); + +Actor* Actor_FindNearby(GlobalContext* globalCtx, Actor* inActor, s16 actorId, u8 actorCategory, f32 distance); +s32 func_800BE184(GlobalContext* globalCtx, Actor* actor, f32 xzDist, s16 arg3, s16 arg4, s16 arg5); +u8 Actor_ApplyDamage(Actor* actor); +void Actor_SetDropFlag(Actor* actor, ColliderInfo* colInfo); +void Actor_SetDropFlagJntSph(Actor* actor, ColliderJntSph* jntSphere); void func_800BE33C(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3); void func_800BE3D0(Actor* actor, s16 angle, Vec3s* arg2); void func_800BE504(Actor* actor, ColliderCylinder* collider); void func_800BE568(Actor* actor, ColliderSphere* collider); -void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 arg2); +void func_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 arg4, f32 arg5, f32 arg6, u8 mode); -void func_800BF7CC(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s32 arg3, s32 arg4, f32 arg5, f32 arg6); -void ActorOverlayTable_FaultPrint(void* arg0, void* arg1); // ActorOverlayTable_FaultPrint -void* ActorOverlayTable_FaultAddrConv(void* arg0, void* arg1); // ActorOverlayTable_FaultAddrConv -void ActorOverlayTable_Init(void); // ActorOverlayTable_Init -void ActorOverlayTable_Cleanup(void); // ActorOverlayTable_Cleanup +void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 arg3, f32 effectScale, f32 steamScale, f32 effectAlpha, u8 mode); +void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s32 limbPosCount, s32 effectsPerLimb, f32 scale, f32 scaleRange); + +void ActorOverlayTable_FaultPrint(void* arg0, void* arg1); +void* ActorOverlayTable_FaultAddrConv(void* arg0, void* arg1); +void ActorOverlayTable_Init(void); +void ActorOverlayTable_Cleanup(void); + void SSNode_SetValue(SSNode* node, s16* polyIndex, u16 next); void SSList_SetNull(SSList* head); void SSNodeList_SetSSListHead(SSNodeList* list, SSList* ssList, s16* polyIndex); @@ -1242,7 +1136,7 @@ void func_800DE0EC(Camera* camera, Actor* actor); Vec3s* Camera_Update(Vec3s* param_1, Camera* camera); // void func_800DF498(void); u32 Camera_SetMode(Camera* camera, s16 mode, s8 param_3); -// void func_800DF840(void); +s32 Camera_ChangeMode(Camera* camera, s16 mode); // void func_800DF86C(void); // void func_800DF8EC(void); s32 func_800DFAC8(Camera* camera, s16 param_2); @@ -1270,7 +1164,7 @@ s16 Camera_ClearFlags(Camera* camera, s16 flags); // void func_800E0238(void); void func_800E02AC(Camera* camera, Actor* actor); void func_800E0308(Camera* camera, Actor* actor); -// void func_800E031C(void); +f32 func_800E031C(Camera* camera); void func_800E0348(Camera* camera); DamageTable* DamageTable_Get(s32 index); void DamageTable_Clear(DamageTable* damageTable); @@ -1548,8 +1442,8 @@ void func_800EDF24(Actor* actor, GlobalContext* globalCtx, u32 arg2); void func_800EDF78(Actor* actor, GlobalContext* globalCtx, s32 iParm3); void func_800EE0CC(Actor* actor, GlobalContext* globalCtx, s32 iParm3); s32 func_800EE1D8(GlobalContext* globalCtx); -u32 func_800EE200(GlobalContext* globalCtx, u32 uParm2); -u32 func_800EE29C(GlobalContext* globalCtx, u32 uParm2); +u32 func_800EE200(GlobalContext* globalCtx, u16 uParm2); +u32 func_800EE29C(GlobalContext* globalCtx, u16 uParm2); u32 func_800EE2F4(GlobalContext* globalCtx); void GetItem_Draw(GlobalContext* globalCtx, s16 index); void func_800EE364(GlobalContext* globalCtx, s16 index); @@ -1579,11 +1473,10 @@ void EffFootmark_Init(GlobalContext* globalCtx); void EffFootmark_Add(GlobalContext* globalCtx, MtxF* displayMatrix, Actor* actor, u8 id, Vec3f* location, u16 size, u8 red, u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay); void EffFootmark_Update(GlobalContext* globalCtx); void EffFootmark_Draw(GlobalContext* globalCtx); -void func_800F0390(GlobalContext* globalCtx); -void func_800F03C0(GlobalContext* globalCtx); -void func_800F048C(GlobalContext* globalCtx, Vec3f* param_2, u8 param_3, u16 param_4, u8 param_5); -void Audio_PlaySoundAtPosition(GlobalContext* globalCtx, Vec3f* position, s32 param_3, u16 sfxId); -void func_800F0590(GlobalContext* globalCtx, Vec3f* arg1, s32 arg2, s32 arg3); +void SoundSource_InitAll(GlobalContext* globalCtx); +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); @@ -1633,14 +1526,11 @@ void ActorCutscene_SetReturnCamera(s16 index); // void func_800F23E0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); f32 func_800F2478(f32 target, TransformData* transData, s32 refIdx); void SkelCurve_Clear(SkelAnimeCurve* skelCurve); -s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, - TransformUpdateIndex* transUpdIdx); +s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, TransformUpdateIndex* transUpdIdx); void SkelCurve_Destroy(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); -void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, - f32 animCurFrame, f32 animSpeed); +void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, f32 animCurFrame, f32 animSpeed); s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); -void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, - OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx); +void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx); void FireObj_SetPosition(FireObj* fire, Vec3f* pos); void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire); void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init, Actor* actor); @@ -1654,14 +1544,14 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor); // void func_800F3B68(void); // void func_800F3C44(void); // void func_800F3ED4(void); -void func_800F40A0(GlobalContext* globalCtx, s32 param_2); +void func_800F40A0(GameState* gameState, Player* player); // void func_800F415C(void); UNK_TYPE func_800F41E4(GlobalContext* globalCtx, ActorContext* actorCtx); void func_800F4A10(GlobalContext* globalCtx); void func_800F4C0C(GlobalContext* globalCtx); -void func_800F4E20(GlobalContext* globalCtx); -void func_800F4F28(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); @@ -1673,7 +1563,7 @@ u32 func_800F5954(u8* param_1, u32 param_2, u32 param_3, u8 param_4, u8 param_5) f32 func_800F5A8C(u16 arg0, u16 arg1, u16 arg2, GlobalContext* globalContext); // void func_800F5B10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); // void func_800F5CD0(void); -// void func_800F6834(void); +void func_800F6834(GlobalContext* globalCtx, s32 waterLightsIndex); // void func_800F694C(void); // void func_800F6A04(void); // void func_800F6A40(void); @@ -1709,7 +1599,7 @@ void Kankyo_FadeOutGameOverLights(GlobalContext* globalCtx); // void func_800FC3DC(void); void func_800FC444(GraphicsContext* gfxCtx, u8 arg1, u8 arg2, u8 arg3, u8 arg4, UNK_TYPE arg5); // void func_800FC64C(void); -// void func_800FD2B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); +s32 func_800FD2B4(GlobalContext* globalCtx, f32 arg1, f32 arg2, f32 arg3, f32 arg4); void func_800FD538(Color_RGB8* param_1, Color_RGB8* param_2, f32 param_3, Vec3s* param_4); void func_800FD59C(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); void func_800FD5E0(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); @@ -1807,7 +1697,7 @@ 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); void func_801000CC(u16 sfxId); -void func_801000F4(s32 a0, u16 a1); +void Lib_PlaySfxAtPos(Vec3f* pos, u16 sfxId); void Lib_Vec3f_TranslateAndRotateY(Vec3f* translation, s16 a, Vec3f* src, Vec3f* dst); void Lib_LerpRGB(Color_RGB8* a, Color_RGB8* b, f32 t, Color_RGB8* dst); f32 Math_Vec3f_StepTo(Vec3f* start, Vec3f* target, f32 speed); @@ -1857,7 +1747,7 @@ void* ZeldaArena_Realloc(void* oldPtr, size_t newSize); void ZeldaArena_Free(void* param_1); void* ZeldaArena_Calloc(u32 num, size_t size); void ZeldaArena_GetSizes(size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated); -void ZeldaArena_Check(); +s32 ZeldaArena_Check(); void ZeldaArena_Init(void* start, size_t size); void ZeldaArena_Cleanup(); u8 ZeldaArena_IsInitialized(); @@ -2079,7 +1969,7 @@ void func_801149A0(s32 arg0, s16 arg1); // void func_80114B84(void); // void func_80114CA0(void); UNK_TYPE func_80114E90(void); -UNK_TYPE func_80114F2C(UNK_TYPE arg0); +UNK_TYPE func_80114F2C(u8 arg0); // void func_80114FD0(void); // void func_80115130(void); // void func_801152B8(void); @@ -2092,7 +1982,7 @@ void func_80115844(GlobalContext* globalCtx, s16 param_2); s32 func_80115908(GlobalContext* globalCtx, u8 param_2); void func_801159c0(s16 param_1); void func_801159EC(s16 arg0); -void func_80115A14(s32 arg0, s16 arg1); +void func_80115A14(s16 arg0, s16 arg1); void Parameter_AddMagic(GlobalContext* globalCtx, s16 arg1); void func_80115D5C(GameState* gamestate); // void func_80115DB4(void); @@ -2151,7 +2041,7 @@ void func_80122F28(Player* player, GlobalContext* globalCtx, Actor* actor); void func_8012301C(s32 iParm1, GlobalContext* globalCtx); void func_80123140(GlobalContext* globalCtx, Player* param_2); u32 func_80123358(GlobalContext* globalCtx, Player* player); -u32 func_801233E4(GlobalContext* globalCtx); +s32 Player_InCsMode(GameState* gameState); // void func_80123420(void); // void func_80123434(void); // void func_80123448(void); @@ -2175,7 +2065,7 @@ void func_80123F2C(GlobalContext* globalCtx, s32 arg1); // void func_80124020(void); u8 Player_GetMask(GlobalContext* globalCtx); void Player_RemoveMask(GlobalContext* globalCtx); -// void func_8012405C(void); +s32 func_8012405C(GlobalContext* globalCtx); // void func_80124088(void); s32 func_801240C8(Player* player); // void func_801240DC(void); @@ -2187,7 +2077,7 @@ s32 func_801240C8(Player* player); // void func_801241E0(void); // void func_8012420C(void); // void func_8012422C(void); -// void func_80124258(void); +s32 Player_GetExplosiveHeld(Player* player); // void func_80124278(void); s32 func_801242B4(Player* player); // void func_801242DC(void); @@ -2480,35 +2370,20 @@ UNK_TYPE func_80133038(GlobalContext* globalCtx, UNK_TYPE* arg1, struct_80133038 void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod, Mtx** mtx); -void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, - OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, - s32 lod); -void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); -void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); -void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, - Mtx** limbMatricies); -void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); -void func_80134148(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor, - Mtx** mtx); -void func_801343C0(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor); +void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod); +void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); +void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); +void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, Mtx** limbMatricies); +void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); +void func_80134148(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor, Mtx** mtx); +void func_801343C0(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor); void SkelAnime_GetFrameData(AnimationHeader* animationSeg, s32 currentFrame, s32 limbCount, Vec3s* dst); s16 Animation_GetLength(void* animation); s16 Animation_GetLastFrame(void* animation); -Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); -Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); -Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, - Mtx** mtx, Gfx* gfx); -Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); +Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); +Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); +Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); +Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); s16 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Vec3s* frameTable); s16 Animation_GetLimbCount2(LegacyAnimationHeader* animation); s16 Animation_GetLength2(LegacyAnimationHeader* animation); @@ -2518,8 +2393,7 @@ void AnimationContext_Reset(AnimationContext* animationCtx); void AnimationContext_SetNextQueue(GlobalContext* globalCtx); void AnimationContext_DisableQueue(GlobalContext* globalCtx); AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, AnimationType type); -void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader* animation, s32 frame, - s32 limbCount, Vec3s* frameTable); +void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable); void AnimationContext_SetCopyAll(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src); void AnimationContext_SetInterp(GlobalContext* globalCtx, s32 limbCount, Vec3s* arg2, Vec3s* arg3, f32 arg4); void AnimationContext_SetCopyTrue(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); @@ -2532,9 +2406,7 @@ void AnimationContext_CopyTrue(GlobalContext* globalCtx, AnimationEntryData* dat void AnimationContext_CopyFalse(GlobalContext* globalCtx, AnimationEntryData* data); void AnimationContext_MoveActor(GlobalContext* globalCtx, AnimationEntryData* data); void AnimationContext_Update(GlobalContext* globalCtx, AnimationContext* animationCtx); -void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, - LinkAnimationHeader* animation, s32 flags, Vec3s* jointTable, - Vec3s* morphTable, s32 limbBufCount); +void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, LinkAnimationHeader* animation, s32 flags, Vec3s* jointTable, Vec3s* morphTable, s32 limbBufCount); void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime); s32 LinkAnimation_Update(GlobalContext* globalCtx, SkelAnime* skelAnime); s32 LinkAnimation_Morph(GlobalContext* globalCtx, SkelAnime* skelAnime); @@ -2558,8 +2430,7 @@ void LinkAnimation_EndLoop(SkelAnime* skelAnime); s32 Animation_OnFrameImpl(SkelAnime* skelAnime, f32 arg1, f32 updateRate); s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 arg1); void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); -void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, - AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); +void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg); void SkelAnime_SetUpdate(SkelAnime* skelAnime); s32 SkelAnime_Update(SkelAnime* skelAnime); @@ -2632,7 +2503,7 @@ void func_8013A46C(s32 flag); u32 func_8013A4C4(s32 flag); s16 func_8013A504(s16 val); s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError); -Actor* func_8013A7C0(GlobalContext* globalCtx, s32 arg1); +struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5); Gfx* func_8013A860(GlobalContext* globalCtx, s32 idx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, UnkActorDraw unkActorDraw, Actor* actor, Mtx** mtx, Gfx* gfx); Gfx* func_8013AB00(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, UnkActorDraw unkActorDraw, Actor* actor, Gfx* gfx); s32 func_8013AD6C(GlobalContext* globalCtx); @@ -2645,7 +2516,7 @@ void func_8013B350(Vec3f* arg0, f32* arg1, f32 arg2, s32 arg3, s32 arg4, Vec3s* s32 func_8013B6B0(Path* path, f32* arg1, s32* arg2, s32 arg3, s32 arg4, s32* arg5, f32* arg6, Vec3f* arg7, s32 arg8); void func_8013B878(GlobalContext* globalCtx, Path* path, s32 arg2, Vec3f* arg3); Path* func_8013BB34(GlobalContext* globalCtx, u8 arg1, s32 arg2); -Actor* func_8013BB7C(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId); +Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId); s32 func_8013BC6C(SkelAnime* skelAnime, ActorAnimationEntryS* arg1, s32 arg2); s32 func_8013BD40(Actor* actor, Path* path, s32 arg2); Path* func_8013BEDC(GlobalContext* globalCtx, u8 arg1, u8 arg2, s32* arg3); @@ -2666,7 +2537,7 @@ s32 func_8013D768(Actor* actor, Vec3f* arg1, s16 arg2); s16 func_8013D83C(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); s8 func_8013D8DC(s8 arg0, GlobalContext* globalCtx); s8 func_8013D924(s16 arg0, GlobalContext* globalCtx); -Actor* func_ActorCategoryIterateById(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); +Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); s32 func_8013D9C8(GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 arg3); s32 func_8013DB90(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2); s32 func_8013DC40(Path* arg0, s32 arg1, s32 arg2, Vec3f* arg3); @@ -2681,17 +2552,17 @@ s32 func_8013E2D4(Actor* actor, s16 arg1, s16 arg2, s32 arg3); s32 func_8013E3B8(Actor* actor, s16 cutscenes[], s16 len); void func_8013E4B0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Plane* plane); s32 func_8013E5CC(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4, Vec3f* arg5); -Actor* func_8013E640(GlobalContext* globalCtx, Actor* arg1, Actor* actorListStart, u8 actorCategory, s16 actorId, void* arg5, func_8013E640_arg6 arg6); +Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, Vec3s* arg5, func_8013E748_arg6 arg6); s32 func_8013E7C0(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2); void func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s16 arg5, s16 arg6); s32 func_8013E950(Vec3f* arg0, Vec3f* arg1, s16 arg2, Vec3f* arg3, Vec3f* arg4, s16* arg5, s16* arg6, s16* arg7, s16* arg8, u16 arg9, u16 arg10, u16 arg11, u16 arg12); // void func_8013EC10(void); -void func_8013EC44(f32 arg0, u8 arg1, u8 arg2, u8 arg3); +void func_8013EC44(f32 a, u8 b, u8 c, u8 d); void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3); void func_8013ED9C(void); void func_8013EDD0(void); -// void func_8013EE04(void); +u32 func_8013EE04(void); void func_8013EE24(void); // void func_8013EE38(void); // void func_8013EE48(void); @@ -2754,8 +2625,7 @@ void VisMono_Draw(void* arg0, Gfx** gfx, u32 arg2); void func_801420C0(void* arg0); void func_801420F4(void* arg0); void func_80142100(void* arg0, Gfx** gfx, u32 arg2); -s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* vtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, - s32 arg8); +s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* vtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8); void func_80143148(SkyboxContext* skyboxCtx, s32 arg1); void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType); @@ -2837,7 +2707,7 @@ void func_80151BB4(GlobalContext* globalCtx, u32 uParm2); // void func_80151DA4(void); void func_80152434(GlobalContext* globalCtx, u16 arg2); // void func_80152464(void); -u8 func_80152498(MessageContext* msgCtx); +u8 Message_GetState(MessageContext* msgCtx); // void func_8015268C(void); // void func_80152C64(void); // void func_80152CAC(void); @@ -2903,17 +2773,17 @@ void ShrinkWindow_Draw(GraphicsContext* gfxCtx); // void func_801631DC(void); // void func_80163334(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_80163660(void); -// void func_80163700(void); -// void func_80163758(void); -// void func_801637B4(void); -void func_80163804(GlobalContext* globalCtx); -// void func_8016388C(void); -// void func_801638D8(void); -// void func_801639A0(void); -void func_801639EC(GlobalContext* globalCtx); -void func_80163A38(GlobalContext* globalCtx); -// void func_80163A58(void); -// void func_80163C0C(void); +void* KaleidoManager_FaultAddrConvFunc(void* address, void* param); +void KaleidoManager_LoadOvl(KaleidoMgrOverlay* ovl); +void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl); +void KaleidoManager_Init(GlobalContext* globalCtx); +void KaleidoManager_Destroy(); +void* KaleidoManager_GetRamAddr(void* vram); +void KaleidoScopeCall_LoadPlayer(void); +void KaleidoScopeCall_Init(GlobalContext* globalCtx); +void KaleidoScopeCall_Destroy(GlobalContext* globalCtx); +void KaleidoScopeCall_Update(GlobalContext* globalCtx); +void KaleidoScopeCall_Draw(GlobalContext* globalCtx); // void func_80163C90(void); // void func_80163D80(void); // void func_80163DC0(void); @@ -2939,7 +2809,7 @@ void* TransitionFade_Init(void* param_1); // void TransitionCircle_Update(void); // void TransitionCircle_SetColor(void); // void TransitionCircle_SetType(void); -// void func_80164C14(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); +void func_80164C14(Gfx** arg0, TexturePtr* arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, f32 arg6); // void TransitionCircle_Draw(void); // void TransitionCircle_IsDone(void); // void func_801651B0(void); @@ -2975,7 +2845,7 @@ void Play_Draw(GlobalContext* globalCtx); void func_80168DAC(GlobalContext* globalCtx); void Play_Update(GlobalContext* globalCtx); s32 func_801690CC(GlobalContext* globalCtx); -// void func_80169100(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); +f32 func_80169100(GlobalContext* globalCtx, MtxF* mtx, CollisionPoly** arg2, s32* arg3, Vec3f* feetPosPtr); // void func_801691F0(void); void* Play_LoadScene(GlobalContext* globalCtx, RomFile* entry); void func_8016927C(GlobalContext* globalCtx, s16 sParm2); @@ -2998,14 +2868,14 @@ void func_801699D4(GlobalContext* globalCtx, s16 arg1, s16 arg2); void func_80169AFC(GlobalContext* globalCtx, s16 camId, s16 arg2); // void func_80169C64(void); // void func_80169C84(void); -// void convert_scene_number_among_shared_scenes(void); +s16 convert_scene_number_among_shared_scenes(s16 arg0); void func_80169D40(GlobalContext* globalCtx); void func_80169DCC(GlobalContext* globalCtx, s32 arg1, u16 arg2, s32 arg3, s32 arg4, Vec3f* arg5, s16 arg6); void func_80169E6C(GlobalContext* globalCtx, s32 param_1, s32 param_2); // void func_80169ECC(void); void func_80169EFC(GlobalContext* globalCtx); void func_80169F78(GlobalContext* globalCtx); -// void func_80169FDC(void); +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); @@ -3053,8 +2923,7 @@ void PreRender_ApplyFiltersSlowlyInit(PreRender* this); void PreRender_ApplyFiltersSlowlyDestroy(PreRender* this); void func_801720C4(PreRender* this); void func_801720FC(PreRenderParams* params, Gfx** gfxp); -void func_80172758(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, u16 arg8, f32 x, - f32 y, f32 xScale, f32 yScale, u32 flags); +void func_80172758(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, u16 arg8, f32 x, f32 y, f32 xScale, f32 yScale, u32 flags); void THGA_Ct(TwoHeadGfxArena* thga, Gfx* start, size_t size); void THGA_Dt(TwoHeadGfxArena* thga); u32 THGA_IsCrash(TwoHeadGfxArena* thga); @@ -3231,7 +3100,7 @@ f32 Rand_ZeroFloat(f32 scale); f32 randPlusMinusPoint5Scaled(f32 scale); f32 Math3D_Normalize(Vec3f* vec); s32 Math3D_PlaneVsLineSegClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, f32 planeBC, f32 planeBDist, Vec3f* linePointA, Vec3f* linePointB, Vec3f* closestPoint); -// UNK_TYPE4 func_80179798(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3, Vec3f* param_4, Vec3f* param_5, Vec3f* param_6); +s32 func_80179798(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3, Vec3f* param_4, Vec3f* param_5, Vec3f* param_6); // void func_80179A44(void); void func_80179B34(float fParm1, f32 fParm2, f32 fParm5, f32 fParm6, f32 param_5, f32 param_6, f32 param_7, float* param_8, float* param_9); // UNK_TYPE4 func_80179B94(f32 fParm1, f32 fParm2, f32 fParm5, f32 param_4, f32 param_5, f32 param_6, f32 param_7, f32 param_8, Vec3f* param_9); @@ -3298,7 +3167,7 @@ s32 Math3D_TriChkLineSegParaZIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, // void func_8017D404(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); void Math3D_TriSetCoords(TriNorm* tri, Vec3f* pointA, Vec3f* pointB, Vec3f* pointC); u32 Math3D_IsPointInSphere(Sphere16* sphere, Vec3f* point); -// void func_8017D668(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); +s32 Math3D_PointDistToLine2D(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32* arg6, f32* arg7, f32* arg8); // returns boolean // void func_8017D7C0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); // void func_8017D814(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8017D91C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); @@ -3657,8 +3526,8 @@ AudioTask* func_80192BE0(void); // void func_80194568(void); // void func_80194668(void); // void func_801946E4(void); -// void func_80194710(void); -// void func_80194750(void); +void Audio_InvalDCache(void* buf, size_t size); +void Audio_WritebackDCache(void* buf, size_t size); // void func_80194790(void); // void func_80194840(void); // void func_801948B0(void); @@ -3797,18 +3666,18 @@ void func_8019E014(void); // void func_8019EB2C(void); // void func_8019F024(void); // void func_8019F05C(void); -void func_8019F170(Vec3f* pos, u16 sfxId); -void func_8019F1C0(Vec3f* pos, u16 sfxId); void play_sound(u16 sfxId); void func_8019F128(u16 sfxId); -void func_8019F208(void); // decide -void func_8019F230(void); // cancel +void func_8019F170(Vec3f* pos, u16 sfxId); +void Audio_PlaySfxAtPos(Vec3f* pos, u16 sfxId); +void func_8019F208(void); // decide sfx +void func_8019F230(void); // cancel sfx // void func_8019F258(void); // void func_8019F300(void); void func_8019F420(Vec3f* pos, u16 sfxId); -// void func_8019F4AC(void); +void func_8019F4AC(Vec3f* pos, u16 sfxId); void func_8019F540(u8 arg0); -// void func_8019F570(void); +void func_8019F570(Vec3f* pos, s8 arg1); // void func_8019F5AC(void); // void func_8019F638(void); // void func_8019F780(void); @@ -3817,7 +3686,7 @@ void func_8019F540(u8 arg0); void func_8019F88C(Vec3f* arg0, u16 sfxId, UNK_TYPE arg2); // void func_8019F900(void); // void func_8019FA18(void); -void func_8019FAD8(Vec3f* param_1, u16 param_2, f32 param_3); +void func_8019FAD8(Vec3f* param_1, u16 sfxId, f32 param_3); // void func_8019FB0C(void); // void func_8019FC20(void); // void func_8019FCB8(void); @@ -3841,7 +3710,7 @@ void func_801A0204(s8 seqId); // void func_801A0554(void); // void func_801A05F0(void); void func_801A0654(Vec3f* arg0, u16 sfxId, s32 arg2); -// void func_801A0810(void); +void func_801A0810(s32* arg0, u16 sfxId, u8 arg2); // void func_801A0868(void); // void func_801A09D4(void); // void func_801A0CB0(void); @@ -3859,7 +3728,7 @@ void func_801A1DB8(Vec3f* vec, u8 seqId, f32 arg2); // void func_801A1E0C(void); void func_801A1F00(u8 arg0, u16 seqId); void func_801A1F88(void); -// void func_801A1FB4(void); +void func_801A1FB4(u8 playerIdx, Vec3f* pos, u16 seqId, f32 maxDist); // void func_801A2090(void); void func_801A246C(u8 param_1, u8 param_2); // void func_801A2544(void); @@ -3899,7 +3768,7 @@ void func_801A3CD8(s8 param_1); // void func_801A3D98(void); // void func_801A3E38(void); // void func_801A3EC0(void); -// void func_801A3F54(void); +void func_801A3F54(s32 arg0); // 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); @@ -3951,7 +3820,7 @@ UNK_TYPE func_801A51F0(UNK_TYPE arg0); void func_801A5BD0(s32 param_1); // void func_801A5C28(void); // void func_801A5C8C(void); -void func_801A5CFC(u16 sfxId, Vec3f* param_2, u8 param_3, f32* param_4, f32* param_5, s8* param_6); +void Audio_PlaySfxGeneral(u16 sfxId, Vec3f* param_2, u8 param_3, f32* param_4, f32* param_5, s8* param_6); // void func_801A5DDC(void); // void func_801A5F7C(void); // void func_801A6430(void); @@ -3960,7 +3829,7 @@ void func_801A5CFC(u16 sfxId, Vec3f* param_2, u8 param_3, f32* param_4, f32* par // void func_801A7084(void); // void func_801A7168(void); // void func_801A7284(void); -void func_801A72CC(Vec3f* uParm1); +void Audio_StopSfxByPos(Vec3f* pos); void func_801A7328(Vec3f* pos, u16 sfxId); // void func_801A7484(void); void func_801A75E8(u16 sfxId); diff --git a/include/initvars.h b/include/initvars.h index a1dbe1fa15..797e738764 100644 --- a/include/initvars.h +++ b/include/initvars.h @@ -1,6 +1,39 @@ #ifndef _INITVARS_H_ #define _INITVARS_H_ +extern EffectSsInit Effect_Ss_Dust_InitVars; +extern EffectSsInit Effect_Ss_Kirakira_InitVars; +extern EffectSsInit Effect_Ss_Bomb2_InitVars; +extern EffectSsInit Effect_Ss_Blast_InitVars; +extern EffectSsInit Effect_Ss_G_Spk_InitVars; +extern EffectSsInit Effect_Ss_D_Fire_InitVars; +extern EffectSsInit Effect_Ss_Bubble_InitVars; +extern EffectSsInit Effect_Ss_G_Ripple_InitVars; +extern EffectSsInit Effect_Ss_G_Splash_InitVars; +extern EffectSsInit Effect_Ss_G_Fire_InitVars; +extern EffectSsInit Effect_Ss_Lightning_InitVars; +extern EffectSsInit Effect_Ss_Dt_Bubble_InitVars; +extern EffectSsInit Effect_Ss_Hahen_InitVars; +extern EffectSsInit Effect_Ss_Stick_InitVars; +extern EffectSsInit Effect_Ss_Sibuki_InitVars; +extern EffectSsInit Effect_Ss_Stone1_InitVars; +extern EffectSsInit Effect_Ss_Hitmark_InitVars; +extern EffectSsInit Effect_Ss_Fhg_Flash_InitVars; +extern EffectSsInit Effect_Ss_K_Fire_InitVars; +extern EffectSsInit Effect_Ss_Solder_Srch_Ball_InitVars; +extern EffectSsInit Effect_Ss_Kakera_InitVars; +extern EffectSsInit Effect_Ss_Ice_Piece_InitVars; +extern EffectSsInit Effect_Ss_En_Ice_InitVars; +extern EffectSsInit Effect_Ss_Fire_Tail_InitVars; +extern EffectSsInit Effect_Ss_En_Fire_InitVars; +extern EffectSsInit Effect_Ss_Extra_InitVars; +extern EffectSsInit Effect_Ss_Dead_Db_InitVars; +extern EffectSsInit Effect_Ss_Dead_Dd_InitVars; +extern EffectSsInit Effect_Ss_Dead_Ds_InitVars; +extern EffectSsInit Effect_Ss_Ice_Smoke_InitVars; +extern EffectSsInit Effect_En_Ice_Block_InitVars; +extern EffectSsInit Effect_Ss_Sbn_InitVars; + extern ActorInit Arms_Hook_InitVars; extern ActorInit Arrow_Fire_InitVars; extern ActorInit Arrow_Ice_InitVars; diff --git a/include/io/controller.h b/include/io/controller.h index cbd4963ae8..4321df0966 100644 --- a/include/io/controller.h +++ b/include/io/controller.h @@ -99,8 +99,8 @@ typedef struct { /* 0x00 */ u32 ramarray[15]; - /* 0x3C */ u32 pifstatus; -} OSPifRam; + /* 0x3C */ u32 status; +} OSPifRam; // size = 0x40 typedef struct { @@ -153,4 +153,11 @@ extern u8 __osMaxControllers; // extern OSMesgQueue D_8009CF38; // extern OSMesg D_8009CF50; +typedef struct { + /* 0x00 */ OSContPad cur; + /* 0x06 */ OSContPad prev; + /* 0x0C */ OSContPad press; // X/Y store delta from last frame + /* 0x12 */ OSContPad rel; // X/Y store adjusted +} Input; // size = 0x18 + #endif diff --git a/include/macros.h b/include/macros.h index 6dc1e5e4e4..c5fc2c4aeb 100644 --- a/include/macros.h +++ b/include/macros.h @@ -2,7 +2,7 @@ #define _MACROS_H_ #include "libc/stdint.h" -#include "convert.h" +#include "ultra64/convert.h" #include "z64.h" #define SCREEN_WIDTH 320 @@ -39,13 +39,13 @@ } \ (void)0 -#define GET_PLAYER(globalCtx) ((Player*)(globalCtx)->actorCtx.actorList[ACTORCAT_PLAYER].first) +#define GET_PLAYER(globalCtx) ((Player*)(globalCtx)->actorCtx.actorLists[ACTORCAT_PLAYER].first) -#define GET_FIRST_ENEMY(globalCtx) ((Actor*)(globalCtx)->actorCtx.actorList[ACTORCAT_ENEMY].first) +#define GET_FIRST_ENEMY(globalCtx) ((Actor*)(globalCtx)->actorCtx.actorLists[ACTORCAT_ENEMY].first) // linkAge still exists in MM, but is always set to 0 (always adult) // There are remnants of these macros from OOT, but they are essentially useless -//#define LINK_IS_CHILD (gSaveContext.linkAge != 0) +#define LINK_IS_CHILD (gSaveContext.linkAge == 1) #define LINK_IS_ADULT (gSaveContext.linkAge == 0) #define CURRENT_DAY (((void)0, gSaveContext.day) % 5) @@ -63,6 +63,7 @@ ((((void)0, gSaveContext.equips.equipment) & gEquipMasks[equip]) >> gEquipShifts[equip]) #define CUR_UPG_VALUE_VOID(upg) \ ((((void)0, gSaveContext.inventory.upgrades) & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) +#define INV_CONTENT_VOID(item) ((void)0, gSaveContext.inventory.items)[SLOT(item)] #define CUR_FORM ((gSaveContext.playerForm == PLAYER_FORM_HUMAN) ? 0 : gSaveContext.playerForm) @@ -85,6 +86,8 @@ #define CHECK_BTN_ALL(state, combo) (~((state) | ~(combo)) == 0) #define CHECK_BTN_ANY(state, combo) (((state) & (combo)) != 0) +#define CHECK_FLAG_ALL(flags, mask) (((flags) & (mask)) == (mask)) + extern GraphicsContext* __gfxCtx; #define WORK_DISP __gfxCtx->work.p @@ -101,6 +104,7 @@ extern GraphicsContext* __gfxCtx; s32 __dispPad #define CLOSE_DISPS(gfxCtx) \ + (void)0; \ } \ (void)0 @@ -145,6 +149,9 @@ extern GraphicsContext* __gfxCtx; (b) = _temp; \ } +#define OVERLAY_RELOCATION_OFFSET(overlayEntry) ((uintptr_t)((overlayEntry)->vramStart) - (uintptr_t)((overlayEntry)->loadedRamAddr)) +#define VRAM_PTR_SIZE(entry) ((uintptr_t)((entry)->vramEnd) - (uintptr_t)((entry)->vramStart)) + #ifdef __GNUC__ #define ALIGNED8 __attribute__ ((aligned (8))) #else diff --git a/include/os_malloc.h b/include/os_malloc.h new file mode 100644 index 0000000000..6b1cceab5a --- /dev/null +++ b/include/os_malloc.h @@ -0,0 +1,35 @@ +#ifndef OS_MALLOC +#define OS_MALLOC + +#include "PR/ultratypes.h" +#include "ultra64/message.h" +#include "libc/stddef.h" + +typedef struct ArenaNode { + /* 0x0 */ s16 magic; // Should always be 0x7373 + /* 0x2 */ s16 isFree; + /* 0x4 */ size_t size; + /* 0x8 */ struct ArenaNode* next; + /* 0xC */ struct ArenaNode* prev; +} ArenaNode; // size = 0x10 + +typedef struct { + /* 0x00 */ ArenaNode* head; + /* 0x04 */ void* start; + /* 0x08 */ OSMesgQueue lock; + /* 0x20 */ u8 unk20; + /* 0x21 */ u8 isInit; + /* 0x22 */ u8 flag; +} Arena; // size = 0x24 + +void __osMallocInit(Arena* arena, void* heap, size_t size); +void __osMallocCleanup(Arena* arena); +u8 __osMallocIsInitalized(Arena* arena); +void* __osMalloc(Arena* arena, size_t size); +void* __osMallocR(Arena* arena, size_t size); +void __osFree(Arena* arena, void* ptr); +void* __osRealloc(Arena* arena, void* ptr, size_t newSize); +void __osGetSizes(Arena* arena, size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated); +s32 __osCheckArena(Arena* arena); + +#endif diff --git a/include/segment_symbols.h b/include/segment_symbols.h index 0044936729..3f02baa5c0 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -73,7 +73,7 @@ DECLARE_OVERLAY_SEGMENT(opening) DECLARE_OVERLAY_SEGMENT(file_choose) DECLARE_OVERLAY_SEGMENT(daytelop) DECLARE_OVERLAY_SEGMENT(kaleido_scope) -DECLARE_OVERLAY_SEGMENT(Player_Actor) +DECLARE_OVERLAY_SEGMENT(player_actor) DECLARE_OVERLAY_SEGMENT(En_Test) DECLARE_OVERLAY_SEGMENT(En_GirlA) diff --git a/include/system_malloc.h b/include/system_malloc.h new file mode 100644 index 0000000000..e92eaf89fd --- /dev/null +++ b/include/system_malloc.h @@ -0,0 +1,20 @@ +#ifndef SYSTEM_MALLOC +#define SYSTEM_MALLOC + +#include "PR/ultratypes.h" +#include "os_malloc.h" + +void* SystemArena_Malloc(size_t size); +void* SystemArena_MallocR(size_t size); +void* SystemArena_Realloc(void* oldPtr, size_t newSize); +void SystemArena_Free(void* ptr); +void* SystemArena_Calloc(u32 elements, size_t size); +void SystemArena_GetSizes(size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated); +u32 SystemArena_CheckArena(void); +void SystemArena_InitArena(void* start, size_t size); +void SystemArena_Cleanup(void); +u8 SystemArena_IsInitialized(void); + +extern Arena gSystemArena; + +#endif diff --git a/include/convert.h b/include/ultra64/convert.h similarity index 94% rename from include/convert.h rename to include/ultra64/convert.h index c453e18e3a..59d8b801c3 100644 --- a/include/convert.h +++ b/include/ultra64/convert.h @@ -1,5 +1,5 @@ -#ifndef _ULTRA64_CONVERT_H_ -#define _ULTRA64_CONVERT_H_ +#ifndef ULTRA64_CONVERT_H +#define ULTRA64_CONVERT_H #include "libc/stdint.h" diff --git a/include/ultra64/hardware.h b/include/ultra64/hardware.h index ae6470d51d..57d560ab02 100644 --- a/include/ultra64/hardware.h +++ b/include/ultra64/hardware.h @@ -53,6 +53,8 @@ #define SP_DMEM_START 0x04000000 #define SP_DMEM_SIZE 0x1000 +#define TMEM_SIZE 0x1000 + #define SP_MEM_ADDR_REG 0x04040000 #define SP_DRAM_ADDR_REG 0x04040004 #define SP_RD_LEN_REG 0x04040008 diff --git a/include/variables.h b/include/variables.h index 35277bb802..cabe5d09e4 100644 --- a/include/variables.h +++ b/include/variables.h @@ -322,7 +322,6 @@ extern StackEntry sFaultThreadInfo; extern FaultThreadStruct gFaultStruct; extern FaultDrawer sFaultDrawerStruct; // extern UNK_TYPE4 D_8009CD10; -// extern Arena gSystemArena; extern u32 sRandFloat; // extern UNK_TYPE4 sArenaLockMsg; extern OSTask tmp_task; @@ -374,7 +373,6 @@ extern u8 D_801AE214[32]; // extern UNK_TYPE4 D_801AE240; // extern UNK_TYPE4 D_801AE250; extern UNK_PTR D_801AE260[3]; -// extern UNK_TYPE4 D_801AE26C; // extern UNK_TYPE4 D_801AE27C; // extern UNK_TYPE4 D_801AE28C; // extern UNK_TYPE4 D_801AE29C; @@ -382,9 +380,7 @@ extern UNK_PTR D_801AE260[3]; // extern UNK_TYPE4 D_801AE2BC; // extern UNK_TYPE4 D_801AE2CC; // extern UNK_TYPE4 D_801AE2DC; -extern F3DVertex sEffectShieldParticleVertices[4]; -extern EffInfo sEffInfoTable[5]; -extern EffectSsInfo EffectSS2Info; +// extern EffectSsInfo sEffectSsInfo; // extern UNK_TYPE1 D_801AE3B0; // extern UNK_TYPE1 D_801AE3B4; // extern UNK_TYPE4 D_801AE3B8; @@ -412,16 +408,13 @@ extern EffectSsInfo EffectSS2Info; // extern UNK_TYPE1 D_801AE48A; // extern UNK_TYPE1 D_801AE48C; // extern UNK_TYPE1 D_801AE490; -extern EffectSsOverlay particleOverlayTable[39]; +extern EffectSsOverlay gParticleOverlayTable[39]; // extern FlagSetEntry sFlagEntries[]; // extern s32 sEntryIndex; // extern u32 sCurrentBit; // extern s32 sTimer; -extern Color_RGBA8 D_801AEC80; -extern s801AEC84 D_801AEC84[13]; extern f32 actorMovementScale; -extern f32 D_801AECF0; -extern f32 D_801AECF4; +extern TargetRangeParams gTargetRanges[]; extern s16 D_801AED48[8]; // extern UNK_TYPE4 D_801AED58; extern Color_RGBA8 actorDefaultHitColor; @@ -870,8 +863,8 @@ extern ColChkVsFunc sOCVsFuncs[COLSHAPE_MAX][COLSHAPE_MAX]; extern CollisionCheckInfo defaultColChkInfo; extern ColChkApplyFunc sApplyDamageFuncs[COLSHAPE_MAX]; extern ColChkLineFunc sOCLineCheckFuncs[COLSHAPE_MAX]; -extern EffShieldParticleInit shieldParticleInitMetal; -extern EffShieldParticleInit shieldParticleInitWood; +extern EffectShieldParticleInit shieldParticleInitMetal; +extern EffectShieldParticleInit shieldParticleInitWood; // extern UNK_TYPE4 D_801BB090; // extern UNK_TYPE1 D_801BB094; // extern UNK_TYPE1 D_801BB0DC; @@ -1262,7 +1255,7 @@ extern UNK_PTR D_801C02F8; // extern UNK_TYPE1 D_801C07F0; // extern UNK_TYPE1 D_801C0820; // extern UNK_TYPE1 D_801C0838; -// extern UNK_TYPE1 D_801C0850; +extern Gfx D_801C0850[]; // extern UNK_TYPE1 D_801C0860; extern UNK_PTR D_801C0870; // extern UNK_TYPE1 D_801C0890; @@ -1552,10 +1545,9 @@ extern char D_801D0714[]; // extern UNK_TYPE1 D_801D08E8; // extern UNK_TYPE1 D_801D0900; extern ActorInit Player_InitVars; -// extern UNK_TYPE1 D_801D0B70; +extern KaleidoMgrOverlay gKaleidoMgrOverlayTable[2]; // extern UNK_TYPE1 D_801D0B8C; -// extern UNK_TYPE4 D_801D0BA8; -// extern UNK_TYPE4 D_801D0BAC; +extern KaleidoMgrOverlay* gKaleidoMgrCurOvl; // extern UNK_TYPE4 D_801D0BB0; // extern UNK_TYPE1 D_801D0C80; // extern UNK_TYPE1 D_801D0CB0; @@ -1631,10 +1623,10 @@ extern PadMgr* padmgrContext; // extern UNK_TYPE4 D_801D1538; extern UNK_PTR D_801D1540; // extern f32 sFactorialTbl[13]; -extern Vec3f D_801D15B0; -extern Vec3s D_801D15BC; -extern Mtx D_801D1DE0; -extern MtxF D_801D1E20; +extern Vec3f gZeroVec3f; +extern Vec3s gZeroVec3s; +extern Mtx gIdentityMtx; +extern MtxF gIdentityMtxF; // extern u64* initialgspUcodeText; // extern u64* initialgspUcodeData; // extern UNK_TYPE1 D_801D1E70; @@ -2841,7 +2833,7 @@ extern f32 D_801DE860; extern f32 D_801DE864; extern f32 D_801DE868; extern f32 D_801DE884; -// extern UNK_TYPE1 D_801DE890; +extern TexturePtr D_801DE890[]; extern f32 D_801DF090; extern f32 D_801DF094; extern f32 D_801DF0A0; @@ -3104,24 +3096,16 @@ extern u64 gJpegUCodeData[]; // extern UNK_TYPE1 D_801E3FA0; // bss -extern EffTables sEffTable; -// extern UNK_TYPE1 D_801E4514; -// extern UNK_TYPE1 D_801E4E08; -// extern UNK_TYPE1 D_801E531C; -// extern UNK_TYPE1 D_801E69E0; -// extern UNK_TYPE1 D_801E9AA0; -// extern UNK_TYPE1 D_801ED4C0; // extern UNK_TYPE1 D_801ED890; // extern UNK_TYPE1 D_801ED894; -// extern UNK_TYPE1 D_801ED8A0; -// extern UNK_TYPE1 D_801ED8B0; -// extern UNK_TYPE1 D_801ED8B4; +extern CollisionPoly* D_801ED8B0; +extern s32 D_801ED8B4; // extern UNK_TYPE1 D_801ED8B8; // extern UNK_TYPE1 D_801ED8BC; // extern UNK_TYPE1 D_801ED8C0; // extern UNK_TYPE1 D_801ED8C4; extern f32 D_801ED8C8; -extern f32 D_801ED8CC; +extern f32 sBgmEnemyDistSq; extern f32 D_801ED8D0; // extern UNK_TYPE1 D_801ED8D4; // extern UNK_TYPE1 D_801ED8D8; @@ -3197,12 +3181,12 @@ extern Vec3f D_801EE1E0; extern Vec3f D_801EE1F0; // extern UNK_TYPE1 D_801EE1F4; // extern UNK_TYPE1 D_801EE1F8; -extern EffSparkParams D_801EE200; +extern EffectSparkInit D_801EE200; extern TriNorm D_801EE6C8; extern TriNorm D_801EE700; -extern EffSparkParams D_801EE738; -extern EffSparkParams D_801EEC00; -extern EffSparkParams D_801EF0C8; +extern EffectSparkInit D_801EE738; +extern EffectSparkInit D_801EEC00; +extern EffectSparkInit D_801EF0C8; extern TriNorm D_801EF590; extern TriNorm D_801EF5C8; extern TriNorm D_801EF600; @@ -3227,7 +3211,7 @@ extern GameInfo* gGameInfo; // extern UNK_TYPE2 D_801F4DCC[8]; // extern UNK_TYPE1 D_801F4DDC; // extern UNK_TYPE1 D_801F4DE0; -// extern UNK_TYPE2 D_801F4DE2; +extern s16 D_801F4DE2; extern ActorCutscene* actorCutscenes; extern s16 actorCutsceneCount; extern u8 actorCutsceneWaiting[16]; @@ -3286,7 +3270,6 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F4F68; // extern UNK_TYPE1 D_801F4F6A; extern LightsBuffer sLightsBuffer; -extern Arena sZeldaArena; // extern UNK_TYPE1 D_801F5130; // extern UNK_TYPE1 D_801F5270; // extern UNK_TYPE1 D_801F528E; @@ -3342,9 +3325,9 @@ extern ShrinkWindowContext gShrinkWindowContext; extern ShrinkWindowContext* gShrinkWindowContextPtr; // extern UNK_TYPE4 D_801F6B50; // extern UNK_TYPE1 D_801F6B58; -// extern UNK_TYPE1 D_801F6BF0; -// extern UNK_TYPE1 D_801F6C00; -// extern UNK_TYPE1 D_801F6C04; +extern FaultAddrConvClient sKaleidoAreaFaultClient; +extern void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx); +extern void (*sKaleidoScopeDrawFunc)(GlobalContext* globalCtx); // extern UNK_TYPE1 D_801F6C10; extern Input D_801F6C18; // extern UNK_TYPE1 D_801F6C30; @@ -3784,7 +3767,7 @@ extern u16 gFramebuffer0[SCREEN_HEIGHT][SCREEN_WIDTH]; // keep objects extern Gfx D_040008D0[]; -extern UNK_TYPE D_040032B0; +extern Gfx D_040032B0[]; extern UNK_TYPE D_0400CF58; extern UNK_TYPE D_0400CF88; extern UNK_TYPE D_0400CF98; @@ -3877,16 +3860,9 @@ extern UNK_TYPE D_0400E3D8; extern UNK_TYPE D_0400E408; extern UNK_TYPE D_0400E410; extern UNK_TYPE D_0400E418; -extern CollisionHeader D_0400E710; // Pink Deku Flower collision -extern AnimationHeader D_0400EB7C; // Deku Flower intense flutter animation -extern Gfx D_0400ED80; // Pink Deku Flower display list -extern SkeletonHeader D_04011518; // Pink Deku Flower skeleton -extern AnimationHeader D_040117A8; // Deku Flower small flutter animation -extern CollisionHeader D_040118D8; // Gold Deku Flower collision -extern Gfx D_04011BD0; // Gold Deku Flower display list -extern SkeletonHeader D_040127E8; // Gold Deku Flower skeleton extern UNK_TYPE D_04012860; extern UNK_TYPE D_040128BC; +extern u64 D_04014570[]; extern UNK_TYPE D_04015FA0; extern UNK_TYPE D_04016360; extern UNK_TYPE D_0401A4D0; @@ -3905,24 +3881,16 @@ extern Gfx D_04023210[]; extern UNK_TYPE D_04023288; extern Gfx D_04023348[]; extern Gfx D_04023428[]; -extern UNK_TYPE D_04025850; extern UNK_TYPE D_04025DD0; extern UNK_TYPE D_040281DC; extern UNK_TYPE D_04028FEC; -extern UNK_TYPE D_04029140; +extern AnimationHeader D_04029140; extern Gfx D_04029CB0[]; extern Gfx D_04029CF0[]; extern UNK_TYPE D_04029D20; -extern AnimationHeader D_0402B494; -extern AnimatedMaterial D_0402C818; -extern AnimatedMaterial D_0402C890; -extern AnimatedMaterial D_0402C908; -extern AnimatedMaterial D_0402C980; -extern AnimatedMaterial D_0402C9F8; -extern FlexSkeletonHeader D_0402CA98; extern Gfx D_0402E510[]; -extern UNK_TYPE D_0402E65C; -extern UNK_TYPE D_0402F0EC; +extern AnimationHeader D_0402E65C; +extern AnimationHeader D_0402F0EC; extern Gfx D_04030100[]; // Floor shockwave ring extern Gfx D_040301B0[]; extern UNK_TYPE D_04032270; @@ -3944,12 +3912,13 @@ extern UNK_TYPE D_0403F230; extern UNK_TYPE D_04044300; extern Gfx D_04048DF0[]; extern UNK_TYPE D_04050D10; -extern UNK_TYPE D_04051180; -extern UNK_TYPE D_04051238; +extern Gfx D_04051180[]; +extern Gfx D_04051238[]; extern AnimationHeader D_0405140C; -extern UNK_TYPE D_040527F0; -extern UNK_TYPE D_040528B0; +extern Gfx D_040527F0[]; +extern Gfx D_040528B0[]; extern Gfx D_04054A90[]; +extern u64 D_04054F20[]; extern UNK_TYPE D_04055628; extern Gfx D_04057B10[]; extern Gfx D_04058BA0[]; @@ -3963,7 +3932,8 @@ extern TexturePtr D_0408EFE0[]; // gDust6Tex extern TexturePtr D_0408F3E0[]; // gDust7Tex extern TexturePtr D_0408F7E0[]; // gDust8Tex extern UNK_TYPE D_04050550; -extern UNK_TYPE D_04050648; +extern Gfx D_04050648[]; +extern Gfx D_040506E0[]; extern UNK_TYPE D_040510B0; extern UNK_TYPE D_04054940; extern Gfx D_0405AAB0[]; @@ -3985,21 +3955,18 @@ extern UNK_TYPE D_04062020; extern UNK_TYPE D_04062040; extern UNK_TYPE D_04062060; extern Gfx D_040622C0[]; -extern UNK_TYPE D_0406AB30; +extern Gfx D_0406AB30[]; extern UNK_TYPE D_0406B730; extern UNK_TYPE D_0406BB0C; extern UNK_TYPE D_0406F380; +extern Gfx D_040706E0[]; extern UNK_TYPE D_04073F00; extern UNK_TYPE D_04075400; -extern Gfx D_04075A40[]; -extern Gfx D_04075B30[]; extern Gfx D_04076BC0[]; -extern Gfx D_04077480[]; extern UNK_TYPE D_04079B10; extern Gfx D_0407AB10[]; // sun (sparkles when small) displaylist extern Gfx D_0407AB58[]; extern UNK_TYPE D_0407AFB0; -extern Gfx D_0407D590[]; extern UNK_TYPE D_0407D650; extern UNK_TYPE D_0407F218; extern UNK_TYPE D_040815D0; @@ -4007,16 +3974,20 @@ extern UNK_TYPE D_04081628; extern UNK_TYPE D_04083534; extern UNK_TYPE D_04091BE0; extern UNK_TYPE D_04091CE0; +extern TexturePtr D_04091DE0[]; +extern TexturePtr D_04091FE0[]; +extern TexturePtr D_040921E0[]; +extern TexturePtr D_040923E0[]; extern Gfx D_05000C40[]; extern UNK_TYPE D_05001D20; -extern UNK_TYPE D_050061E8; -extern UNK_TYPE D_05006420; -extern UNK_TYPE D_050066B0; +extern Gfx D_050061E8[]; +extern Gfx D_05006420[]; +extern Gfx D_050066B0[]; extern UNK_TYPE D_05007498; extern Gfx D_05007890[]; -extern UNK_TYPE D_050078A0; -extern UNK_TYPE D_05007938; +extern Gfx D_050078A0[]; +extern Gfx D_05007938[]; extern Gfx D_05007980[]; extern UNK_TYPE D_05007E00; extern UNK_TYPE D_05008018; @@ -4033,7 +4004,7 @@ extern UNK_TYPE D_0502324C; // other segments extern GfxMasterList D_0E000000; - +extern Mtx D_01000000; extern UNK_TYPE D_0F000000; diff --git a/include/z64.h b/include/z64.h index f094c7cfc4..1aba77e7af 100644 --- a/include/z64.h +++ b/include/z64.h @@ -334,26 +334,6 @@ typedef struct { /* 0x24 */ s16 unk_24; } SramContext; // size = 0x28 -typedef struct { - /* 0x00 */ UNK_TYPE4 unk0; - /* 0x04 */ UNK_TYPE4 unk4; - /* 0x08 */ UNK_TYPE4 unk8; - /* 0x0C */ f32 unkC; - /* 0x10 */ Color_RGBA8 unk10; -} TargetContextEntry; // size = 0x14 - -typedef struct { - /* 0x0 */ u32 texture; - /* 0x4 */ s16 unk4; - /* 0x6 */ s16 unk6; - /* 0x8 */ u8 unk8; - /* 0x9 */ u8 unk9; - /* 0xA */ u8 fadeOutDelay; - /* 0xB */ u8 fadeInDelay; - /* 0xC */ s16 alpha; - /* 0xE */ s16 color; -} TitleCardContext; // size = 0x10 - typedef struct { /* 0x0 */ s32 topY; /* 0x4 */ s32 bottomY; @@ -392,15 +372,27 @@ typedef struct { } s80185D40; // size = 0x2C typedef struct { - /* 0x0 */ u8 unk0; - /* 0x1 */ u8 unk1; - /* 0x2 */ u8 unk2; - /* 0x3 */ u8 unk3; - /* 0x4 */ u8 unk4; - /* 0x5 */ u8 unk5; - /* 0x6 */ u8 unk6; - /* 0x7 */ u8 unk7; -} s801AEC84; // size = 0x8 + /* 0x00 */ u32 unk0; + /* 0x04 */ u8 unk4; + /* 0x05 */ u8 unk5; + /* 0x06 */ u8 unk6; + /* 0x07 */ UNK_TYPE1 pad7[0x2]; + /* 0x09 */ u8 unk9; + /* 0x0A */ UNK_TYPE1 padA[0x2]; + /* 0x0C */ u32 unkC; + /* 0x10 */ u16 unk10; + /* 0x12 */ u16 unk12; + /* 0x14 */ u16 unk14; + /* 0x16 */ UNK_TYPE1 pad16[0x2]; + /* 0x18 */ u32 unk18; + /* 0x1C */ u32 unk1C; + /* 0x20 */ u32 unk20; + /* 0x24 */ u32 unk24; + /* 0x28 */ u32 unk28; + /* 0x2C */ u32 unk2C; + /* 0x30 */ u32 unk30; + /* 0x34 */ u32 unk34; +} s8018CFAC; // size = 0x38 typedef struct { /* 0x00 */ Vec3f unk0; @@ -475,18 +467,13 @@ typedef enum { } GfxPrintFlag; typedef struct { - /* 0x00 */ u16 countdown; - /* 0x04 */ Vec3f originPos; - /* 0x10 */ Vec3f relativePos; + /* 0x00 */ u8 countdown; + /* 0x01 */ u8 playSfxEachFrame; + /* 0x02 */ u16 sfxId; + /* 0x04 */ Vec3f worldPos; + /* 0x10 */ Vec3f projectedPos; } SoundSource; // size = 0x1C -typedef struct { - /* 0x00 */ OSContPad cur; - /* 0x06 */ OSContPad prev; - /* 0x0C */ OSContPad press; // X/Y store delta from last frame - /* 0x12 */ OSContPad rel; // X/Y store adjusted -} Input; // size = 0x18 - typedef struct { /* 0x000 */ u32 magic; /* 0x004 */ GraphicsContext* gfxCtx; @@ -702,6 +689,22 @@ typedef struct { /* 0x344 */ u32 unk_344; } InterfaceContext; // size = 0x348 +typedef struct { + /* 0x00 */ void* loadedRamAddr; + /* 0x04 */ uintptr_t vromStart; + /* 0x08 */ uintptr_t vromEnd; + /* 0x0C */ void* vramStart; + /* 0x10 */ void* vramEnd; + /* 0x14 */ uintptr_t offset; // loadedRamAddr - vramStart + /* 0x18 */ const char* name; +} KaleidoMgrOverlay; // size = 0x1C + +typedef enum { + /* 0x00 */ KALEIDO_OVL_KALEIDO_SCOPE, + /* 0x01 */ KALEIDO_OVL_PLAYER_ACTOR, + /* 0x02 */ KALEID_OVL_MAX +} KaleidoMgrOverlayType; + typedef struct { /* 0x00 */ u16 unk_0; /* 0x02 */ u16 unk_2; @@ -727,7 +730,7 @@ typedef struct { /* 0x22 */ u16 unk_22; /* 0x24 */ u16 unk_24; /* 0x26 */ u8 unk_26; - /* 0x28 */ LightInfo unk_28; // sun 1 + /* 0x28 */ LightInfo dirLight1; // sun 1 /* 0x36 */ LightInfo unk_36; // sun 2 /* 0x44 */ s8 unk_44; /* 0x48 */ DmaRequest unk_48; @@ -861,7 +864,9 @@ typedef struct { /* 0x1202A */ u16 unk1202A; /* 0x1202C */ UNK_TYPE1 pad1202C[0x2]; /* 0x1202E */ u16 unk1202E; - /* 0x12030 */ UNK_TYPE1 pad12030[0x14]; + /* 0x12030 */ s16 unk_12030; + /* 0x12032 */ UNK_TYPE1 unk_12032[0x2]; + /* 0x12034 */ UNK_TYPE1 pad12034[0x10]; /* 0x12044 */ s16 unk12044; /* 0x12046 */ UNK_TYPE1 pad12046[0x2]; /* 0x12048 */ u8 unk12048; // EnKakasi @@ -879,23 +884,6 @@ typedef struct { /* 0x120D8 */ UNK_TYPE1 pad120D8[0x8]; } MessageContext; // size = 0x120E0 -typedef struct ArenaNode { - /* 0x0 */ s16 magic; // Should always be 0x7373 - /* 0x2 */ s16 isFree; - /* 0x4 */ size_t size; - /* 0x8 */ struct ArenaNode* next; - /* 0xC */ struct ArenaNode* prev; -} ArenaNode; // size = 0x10 - -typedef struct { - /* 0x00 */ ArenaNode* head; - /* 0x04 */ void* start; - /* 0x08 */ OSMesgQueue lock; - /* 0x20 */ u8 unk20; - /* 0x21 */ u8 isInit; - /* 0x22 */ u8 flag; -} Arena; // size = 0x24 - typedef struct FaultAddrConvClient { /* 0x0 */ struct FaultAddrConvClient* next; /* 0x4 */ void* (*callback)(void*, void*); @@ -1181,24 +1169,12 @@ typedef enum { STACK_STATUS_OVERFLOW = 2 } StackStatus; -typedef struct TargetContext TargetContext; - -typedef struct ActorContext ActorContext; - -typedef struct s800B948C s800B948C; - struct FireObjLight { /* 0x00 */ LightNode* light; /* 0x04 */ LightInfoPositional lightInfo; /* 0x12 */ u8 unk12; }; // size = 0x13 -typedef struct ActorListEntry { - /* 0x0 */ s32 length; // number of actors loaded of this type - /* 0x4 */ Actor* first; // pointer to first actor of this type - /* 0x8 */ UNK_TYPE1 pad8[0x4]; -} ActorListEntry; // size = 0xC - #define OS_SC_RETRACE_MSG 1 #define OS_SC_DONE_MSG 2 #define OS_SC_NMI_MSG 3 // name is made up, 3 is OS_SC_RDP_DONE_MSG in the original sched.c @@ -1255,78 +1231,6 @@ struct FireObj { /* 0x78 */ FireObjLight light; }; // size = 0x8B -struct TargetContext { - /* 0x00 */ Vec3f unk0; - /* 0x0C */ Vec3f unkC; - /* 0x18 */ f32 unk18; - /* 0x1C */ f32 unk1C; - /* 0x20 */ f32 unk20; - /* 0x24 */ f32 unk24; - /* 0x28 */ f32 unk28; - /* 0x2C */ f32 unk2C; - /* 0x30 */ f32 unk30; - /* 0x34 */ f32 unk34; - /* 0x38 */ Actor* unk38; - /* 0x3C */ Actor* unk3C; - /* 0x40 */ f32 unk40; - /* 0x44 */ f32 unk44; - /* 0x48 */ s16 unk48; - /* 0x4A */ u8 unk4A; - /* 0x4B */ u8 unk4B; - /* 0x4C */ s8 unk4C; - /* 0x4D */ UNK_TYPE1 pad4D[0x3]; - /* 0x50 */ TargetContextEntry unk50[3]; - /* 0x8C */ Actor* unk8C; - /* 0x90 */ Actor* unk90; - /* 0x94 */ Actor* unk_94; -}; // size = 0x98 - -struct s800B948C { - /* 0x00 */ GlobalContext* globalCtx; - /* 0x04 */ Actor* actor; - /* 0x08 */ u32 updateActorIfSet; - /* 0x0C */ u32 unkC; - /* 0x10 */ Actor* unk10; - /* 0x14 */ Player* player; - /* 0x18 */ u32 runMainIfSet; // Bitmask of actor flags. The actor will only have main called if it has at least 1 flag set that matches this bitmask -}; // size = 0x1C - -struct ActorContext { - /* 0x000 */ UNK_TYPE1 pad0[0x2]; - /* 0x002 */ u8 unk2; - /* 0x003 */ u8 unk3; - /* 0x004 */ s8 unk4; - /* 0x005 */ u8 unk5; - /* 0x006 */ UNK_TYPE1 pad6[0x5]; - /* 0x00B */ s8 unkB; - /* 0x00C */ s16 unkC; - /* 0x00E */ u8 totalLoadedActors; - /* 0x00F */ u8 undrawnActorCount; - /* 0x010 */ ActorListEntry actorList[12]; - /* 0x0A0 */ Actor* undrawnActors[32]; // Records the first 32 actors drawn each frame - /* 0x120 */ TargetContext targetContext; - /* 0x1B8 */ u32 switchFlags[4]; // First 0x40 are permanent, second 0x40 are temporary - /* 0x1C8 */ u32 chestFlags; - /* 0x1CC */ u32 clearedRooms; - /* 0x1D0 */ u32 clearedRoomsTemp; - /* 0x1D4 */ u32 collectibleFlags[4]; // bitfield of 128 bits - /* 0x1E4 */ TitleCardContext titleCtxt; - /* 0x1F4 */ u8 unk1F4; - /* 0x1F5 */ u8 unk1F5; - /* 0x1F6 */ UNK_TYPE1 pad1F6[0x2]; - /* 0x1F8 */ f32 unk1F8; - /* 0x1FC */ Vec3f unk1FC; - /* 0x208 */ UNK_TYPE1 pad208[0x48]; - /* 0x250 */ void* unk250; // allocation of 0x20f0 bytes? - /* 0x254 */ u32 unk254[5]; - /* 0x268 */ u8 unk268; - /* 0x269 */ UNK_TYPE1 pad269[0x3]; - /* 0x26C */ UNK_TYPE1 pad26C[0xC]; - /* 0x278 */ u16 unk278; - /* 0x27A */ UNK_TYPE1 pad27A[0x2]; - /* 0x27C */ UNK_TYPE1 pad27C[0x8]; -}; // size = 0x284 - typedef struct { /* 0x00 */ u8 seqIndex; /* 0x01 */ u8 nightSeqIndex; @@ -1438,7 +1342,9 @@ struct GlobalContext { /* 0x18B4C */ PreRender pauseBgPreRender; /* 0x18B9C */ char unk_18B9C[0x2B8]; /* 0x18E54 */ SceneTableEntry* loadedScene; - /* 0x18E58 */ char unk_18E58[0x400]; + /* 0x18E58 */ char unk_18E58[0x10]; + /* 0x18E68 */ s32 unk_18E68; + /* 0x18E6C */ char unk_18E6C[0x3EC]; }; // size = 0x19258 typedef struct { @@ -1494,7 +1400,7 @@ typedef struct { typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, Vec3s*); -typedef s32 (*func_8013E640_arg6)(struct GlobalContext*, Actor*, Actor*, void*); +typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); struct struct_8013DF3C_arg1; typedef void (*struct_8013DF3C_arg1_unk_func1)(struct GlobalContext*, struct struct_8013DF3C_arg1*); @@ -1567,6 +1473,11 @@ typedef struct DebugDispObject { /* 0x2C */ s32 pad; //Padding not in the OOT version } DebugDispObject; // size = 0x30 +typedef struct { + /* 0x0 */ f32 rangeSq; + /* 0x4 */ f32 leashScale; +} TargetRangeParams; // size = 0x8 + typedef struct { /* 0x00 */ u8* value; /* 0x04 */ const char* name; diff --git a/include/z64actor.h b/include/z64actor.h index 2b35bec243..3ed9e2a335 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -1,5 +1,5 @@ -#ifndef _Z64ACTOR_H_ -#define _Z64ACTOR_H_ +#ifndef Z64ACTOR_H +#define Z64ACTOR_H #include "PR/ultratypes.h" #include "z64math.h" @@ -7,6 +7,8 @@ #include "z64collision_check.h" #include "unk.h" +// This value is hardcoded to be the size of ovl_Arrow_Fire which currently is the biggest actor that uses the AM_FIELD. +#define AM_FIELD_SIZE SEGMENT_SIZE(ovl_Arrow_Fire) #define MASS_IMMOVABLE 0xFF // Cannot be pushed by OC collisions #define MASS_HEAVY 0xFE // Can only be pushed by OC collisions with IMMOVABLE and HEAVY objects. @@ -15,6 +17,9 @@ struct GlobalContext; struct Lights; struct CollisionPoly; +struct EnBox; +struct EnDoor; + typedef void(*ActorFunc)(struct Actor* this, struct GlobalContext* globalCtx); typedef struct { @@ -116,6 +121,8 @@ typedef struct { /* 0x10 */ f32 shadowScale; // Changes the size of the shadow /* 0x14 */ u8 shadowAlpha; // Default is 255 /* 0x15 */ u8 feetFloorFlags; // Set if the actor's foot is clipped under the floor. & 1 is right foot, & 2 is left + /* 0x16 */ u8 unk_16; + /* 0x17 */ u8 unk_17; /* 0x18 */ Vec3f feetPos[2]; // Update by using `Actor_SetFeetPos` in PostLimbDrawOpa } ActorShape; // size = 0x30 @@ -131,15 +138,15 @@ typedef struct Actor { /* 0x020 */ s16 unk20; /* 0x024 */ PosRot world; // Position/rotation in the world /* 0x038 */ s8 cutscene; - /* 0x039 */ s8 unk39; + /* 0x039 */ u8 audioFlags; // Another set of flags? Seems related to sfx or bgm /* 0x03C */ PosRot focus; // Target reticle focuses on this position. For player this represents head pos and rot - /* 0x050 */ u16 sfx; // SFX ID to play. Sound plays when value is set, then is cleared the following update cycle + /* 0x050 */ u16 sfxId; // Id of sound effect to play. Plays when value is set, then is cleared the following update cycle /* 0x054 */ f32 targetArrowOffset; // Height offset of the target arrow relative to `focus` position /* 0x058 */ Vec3f scale; // Scale of the actor in each axis /* 0x064 */ Vec3f velocity; // Velocity of the actor in each axis /* 0x070 */ f32 speedXZ; // How fast the actor is traveling along the XZ plane /* 0x074 */ f32 gravity; // Acceleration due to gravity. Value is added to Y velocity every frame - /* 0x078 */ f32 minVelocityY; // Sets the lower bounds cap on velocity along the Y axis + /* 0x078 */ f32 terminalVelocity; // Sets the lower bounds cap on velocity along the Y axis /* 0x07C */ struct CollisionPoly* wallPoly; // Wall polygon the actor is touching /* 0x080 */ struct CollisionPoly* floorPoly; // Floor polygon directly below the actor /* 0x084 */ u8 wallBgId; // Bg ID of the wall polygon the actor is touching @@ -168,12 +175,12 @@ typedef struct Actor { /* 0x11C */ u8 colorFilterTimer; // A non-zero value enables the color filter. Decrements automatically /* 0x11D */ u8 isDrawn; // Set to true if the actor is currently being drawn. Always stays false for lens actors /* 0x11E */ u8 dropFlag; // Configures what item is dropped by the actor from `Item_DropCollectibleRandom` - /* 0x11F */ u8 hintId; // Sets what 0600 dialog to display when talking to navi. Default 0xFF + /* 0x11F */ u8 hintId; // Sets what 0600 dialog to display when talking to Tatl. Default 0xFF /* 0x120 */ struct Actor* parent; // Usage is actor specific. Set if actor is spawned via `Actor_SpawnAsChild` /* 0x124 */ struct Actor* child; // Usage is actor specific. Set if actor is spawned via `Actor_SpawnAsChild` /* 0x128 */ struct Actor* prev; // Previous actor of this category /* 0x12C */ struct Actor* next; // Next actor of this category - /* 0x130 */ ActorFunc init; // Initialization Routine. Called by `Actor_Init` or `Actor_UpdateAll` + /* 0x130 */ ActorFunc init; // Initialization Routine. Called by `Actor_InitContext` or `Actor_UpdateAll` /* 0x134 */ ActorFunc destroy; // Destruction Routine. Called by `Actor_Destroy` /* 0x138 */ ActorFunc update; // Update Routine. Called by `Actor_UpdateAll` /* 0x13C */ ActorFunc draw; // Draw Routine. Called by `Actor_Draw` @@ -287,7 +294,8 @@ typedef enum { /* 0x08 */ ACTORCAT_MISC, /* 0x09 */ ACTORCAT_BOSS, /* 0x0A */ ACTORCAT_DOOR, - /* 0x0B */ ACTORCAT_CHEST + /* 0x0B */ ACTORCAT_CHEST, + /* 0x0C */ ACTORCAT_MAX } ActorType; typedef struct { @@ -308,6 +316,96 @@ typedef struct { /* 0x0E */ s16 transitionRate; } ActorAnimationEntryS; // size = 0x10 +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ f32 unkC; + /* 0x10 */ Color_RGBA8 color; +} TargetContextEntry; // size = 0x14 + +typedef struct TargetContext { + /* 0x00 */ Vec3f unk0; + /* 0x0C */ Vec3f targetCenterPos; + /* 0x18 */ Color_RGBAf fairyInner; + /* 0x28 */ Color_RGBAf fairyOuter; + /* 0x38 */ Actor* arrowPointedActor; + /* 0x3C */ Actor* targetedActor; + /* 0x40 */ f32 unk40; + /* 0x44 */ f32 unk44; + /* 0x48 */ s16 unk48; // alpha + /* 0x4A */ u8 unk4A; + /* 0x4B */ u8 unk4B; + /* 0x4C */ s8 unk4C; + /* 0x4D */ UNK_TYPE1 pad4D[0x3]; + /* 0x50 */ TargetContextEntry unk50[3]; + /* 0x8C */ Actor* unk8C; + /* 0x90 */ Actor* bgmEnemy; + /* 0x94 */ Actor* unk_94; +} TargetContext; // size = 0x98 + +typedef struct { + /* 0x0 */ TexturePtr texture; + /* 0x4 */ s16 x; + /* 0x6 */ s16 y; + /* 0x8 */ u8 width; + /* 0x9 */ u8 height; + /* 0xA */ u8 durationTimer; // how long the title card appears for before fading + /* 0xB */ u8 delayTimer; // how long the title card waits to appear + /* 0xC */ s16 alpha; + /* 0xE */ s16 intensity; +} TitleCardContext; // size = 0x10 + +typedef struct ActorContext_unk_20C { + /* 0x0 */ s16 id; + /* 0x2 */ s8 isDynamicallyInitialised; + /* 0x4 */ void* ptr; +} ActorContext_unk_20C; // size = 0x8 + +typedef struct ActorContextFlags { + /* 0x00 */ u32 switches[4]; // First 0x40 are permanent, second 0x40 are temporary + /* 0x10 */ u32 chest; + /* 0x14 */ u32 clearedRoom; + /* 0x18 */ u32 clearedRoomTemp; + /* 0x1C */ u32 collectible[4]; // bitfield of 128 bits +} ActorContextFlags; // size = 0x2C + +typedef struct ActorListEntry { + /* 0x0 */ s32 length; // number of actors loaded of this type + /* 0x4 */ Actor* first; // pointer to first actor of this type + /* 0x8 */ s32 unk_08; +} ActorListEntry; // size = 0xC + +typedef struct ActorContext { + /* 0x000 */ u8 freezeFlashTimer; + /* 0x001 */ UNK_TYPE1 pad1; + /* 0x002 */ u8 unk2; + /* 0x003 */ u8 unk3; + /* 0x004 */ s8 unk4; + /* 0x005 */ u8 unk5; + /* 0x006 */ UNK_TYPE1 pad6[0x5]; + /* 0x00B */ s8 unkB; + /* 0x00C */ s16 unkC; + /* 0x00E */ u8 totalLoadedActors; + /* 0x00F */ u8 undrawnActorCount; + /* 0x010 */ ActorListEntry actorLists[ACTORCAT_MAX]; + /* 0x0A0 */ Actor* undrawnActors[32]; // Records the first 32 actors drawn each frame + /* 0x120 */ TargetContext targetContext; + /* 0x1B8 */ ActorContextFlags flags; + /* 0x1E4 */ TitleCardContext titleCtxt; + /* 0x1F4 */ u8 unk1F4; + /* 0x1F5 */ u8 unk1F5; + /* 0x1F6 */ UNK_TYPE1 pad1F6[0x2]; + /* 0x1F8 */ f32 unk1F8; + /* 0x1FC */ Vec3f unk1FC; + /* 0x208 */ UNK_TYPE1 unk_208[0x4]; + /* 0x20C */ ActorContext_unk_20C unk_20C[8]; + /* 0x24C */ UNK_TYPE1 unk_24C[0x4]; + /* 0x250 */ void* absoluteSpace; // Space used to allocate actor overlays of alloc type ALLOCTYPE_ABSOLUTE + /* 0x254 */ u32 unk254[5]; + /* 0x268 */ u8 unk268; + /* 0x269 */ UNK_TYPE1 pad269[0x3]; + /* 0x26C */ Input unk_26C; +} ActorContext; // size = 0x284 + typedef enum { /* 0x000 */ ACTOR_PLAYER, /* 0x001 */ ACTOR_EN_TEST, @@ -1002,6 +1100,76 @@ typedef enum { /* 0x2B2 */ ACTOR_ID_MAX // originally "ACTOR_DLF_MAX" } ActorID; +typedef enum { + /* 0 */ DOORLOCK_NORMAL, + /* 1 */ DOORLOCK_BOSS, + /* 2 */ DOORLOCK_2, // DOORLOCK_NORMAL_SPIRIT on OoT + /* 3 */ DOORLOCK_MAX +} DoorLockType; + +// Targetability / ACTOR_FLAG_TARGETABLE? +#define ACTOR_FLAG_1 (1 << 0) +// +#define ACTOR_FLAG_2 (1 << 1) +// +#define ACTOR_FLAG_4 (1 << 2) +// +#define ACTOR_FLAG_8 (1 << 3) +// +#define ACTOR_FLAG_10 (1 << 4) +// +#define ACTOR_FLAG_20 (1 << 5) +// +#define ACTOR_FLAG_40 (1 << 6) +// Invisible +#define ACTOR_FLAG_80 (1 << 7) +// Related to talk +#define ACTOR_FLAG_100 (1 << 8) +// +#define ACTOR_FLAG_200 (1 << 9) +// +#define ACTOR_FLAG_400 (1 << 10) +// +#define ACTOR_FLAG_800 (1 << 11) +// +#define ACTOR_FLAG_1000 (1 << 12) +// +#define ACTOR_FLAG_2000 (1 << 13) +// +#define ACTOR_FLAG_4000 (1 << 14) +// +#define ACTOR_FLAG_8000 (1 << 15) +// +#define ACTOR_FLAG_10000 (1 << 16) +// +#define ACTOR_FLAG_20000 (1 << 17) +// +#define ACTOR_FLAG_40000 (1 << 18) +// +#define ACTOR_FLAG_80000 (1 << 19) +// +#define ACTOR_FLAG_100000 (1 << 20) +// +#define ACTOR_FLAG_200000 (1 << 21) +// +#define ACTOR_FLAG_400000 (1 << 22) +// +#define ACTOR_FLAG_800000 (1 << 23) +// +#define ACTOR_FLAG_1000000 (1 << 24) +// +#define ACTOR_FLAG_2000000 (1 << 25) +// +#define ACTOR_FLAG_4000000 (1 << 26) +// +#define ACTOR_FLAG_8000000 (1 << 27) +// +#define ACTOR_FLAG_10000000 (1 << 28) +// +#define ACTOR_FLAG_20000000 (1 << 29) +// +#define ACTOR_FLAG_40000000 (1 << 30) + typedef enum { /* 0x00 */ CLEAR_TAG_SMALL_EXPLOSION, /* 0x01 */ CLEAR_TAG_LARGE_EXPLOSION, diff --git a/include/z64cutscene.h b/include/z64cutscene.h index 51e60799e0..0f2a6e6784 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -29,11 +29,11 @@ typedef struct { /* 0x00 */ u16 unk0; // action; // "dousa" /* 0x02 */ u16 startFrame; /* 0x04 */ u16 endFrame; - /* 0x06 */ UNK_TYPE1 pad6[0xA]; - /* 0x10 */ s32 unk10; - /* 0x14 */ UNK_TYPE1 pad14[0x8]; - /* 0x1C */ s32 unk1C; - /* 0x20 */ UNK_TYPE1 pad20[0x10]; + /* 0x06 */ u16 unk6; + /* 0x08 */ u16 unk8; + /* 0x0C */ Vec3i unk0C; + /* 0x18 */ Vec3i unk18; + /* 0x24 */ UNK_TYPE1 unk24[0xC]; } CsCmdActorAction; // size = 0x30 typedef struct { diff --git a/include/z64effect.h b/include/z64effect.h index adb6907324..d9211ef5e1 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -10,14 +10,6 @@ struct GraphicsContext; struct GlobalContext; -typedef void(*eff_destroy_func)(void* params); - -typedef void(*eff_draw_func)(void* params, struct GraphicsContext* gfxCtx); - -typedef void(*eff_init_func)(void* params, void* init); - -typedef s32(*eff_update_func)(void* params); - #define SPARK_COUNT 3 #define BLURE_COUNT 25 #define SHIELD_PARTICLE_COUNT 3 @@ -41,37 +33,45 @@ typedef s32(*eff_update_func)(void* params); #define rgObjBankIdx regs[11] typedef struct { - /* 0x0 */ u8 active; - /* 0x1 */ u8 unk1; - /* 0x2 */ u8 unk2; - /* 0x3 */ UNK_TYPE1 pad3[0x1]; -} EffCommon; // size = 0x4 + /* 0x00 */ u8 active; + /* 0x01 */ u8 unk1; + /* 0x02 */ u8 unk2; +} EffectStatus; // size = 0x03 typedef struct { /* 0x00 */ Vec3f velocity; /* 0x0C */ Vec3f position; - /* 0x18 */ Vec3s unk18; - /* 0x1E */ Vec3s unk1E; -} EffSparkParticle; // size = 0x24 + /* 0x18 */ Vec3s unkVelocity; + /* 0x1E */ Vec3s unkPosition; +} EffectSparkElement; // size = 0x24 typedef struct { /* 0x000 */ Vec3s position; - /* 0x008 */ s32 numParticles; // Will be calculated as particleFactor1 * particleFactor2 + 2 - /* 0x00C */ EffSparkParticle particles[32]; - /* 0x48C */ f32 velocity; + /* 0x008 */ s32 numElements; // "table_size"; calculated as uDiv * vDiv + 2 + /* 0x00C */ EffectSparkElement elements[32]; + /* 0x48C */ f32 speed; /* 0x490 */ f32 gravity; - /* 0x494 */ u32 particleFactor1; - /* 0x498 */ u32 particleFactor2; + /* 0x494 */ u32 uDiv; // "u_div" + /* 0x498 */ u32 vDiv; // "v_div" /* 0x49C */ Color_RGBA8 colorStart[4]; /* 0x4AC */ Color_RGBA8 colorEnd[4]; - /* 0x4BC */ s32 age; + /* 0x4BC */ s32 timer; /* 0x4C0 */ s32 duration; -} EffSparkParams; // size = 0x4C4 +} EffectSparkInit; // size = 0x4C4 typedef struct { - /* 0x000 */ EffCommon base; - /* 0x004 */ EffSparkParams params; -} EffSpark; // size = 0x4C8 + /* 0x000 */ Vec3s position; + /* 0x008 */ s32 numElements; // "table_size"; calculated as uDiv * vDiv + 2 + /* 0x00C */ EffectSparkElement elements[32]; + /* 0x48C */ f32 speed; + /* 0x490 */ f32 gravity; + /* 0x494 */ u32 uDiv; // "u_div" + /* 0x498 */ u32 vDiv; // "v_div" + /* 0x49C */ Color_RGBA8 colorStart[4]; + /* 0x4AC */ Color_RGBA8 colorEnd[4]; + /* 0x4BC */ s32 timer; + /* 0x4C0 */ s32 duration; +} EffectSpark; // size = 0x4C4 typedef struct { /* 0x00 */ s32 state; @@ -82,13 +82,15 @@ typedef struct { } EffectBlureElement; // size = 0x18 typedef struct { - /* 0x000 */ UNK_TYPE1 pad0[0x184]; - /* 0x184 */ Color_RGBA8 unk184; - /* 0x188 */ Color_RGBA8 unk188; - /* 0x18C */ Color_RGBA8 unk18C; - /* 0x190 */ Color_RGBA8 unk190; - /* 0x194 */ UNK_TYPE1 pad194[0xC]; -} EffBlureInit1; // size = 0x1A0 + /* 0x000 */ char unk_00[0x184]; + /* 0x184 */ u8 p1StartColor[4]; + /* 0x188 */ u8 p2StartColor[4]; + /* 0x18C */ u8 p1EndColor[4]; + /* 0x190 */ u8 p2EndColor[4]; + /* 0x194 */ s32 elemDuration; + /* 0x198 */ s32 unkFlag; + /* 0x19C */ s32 calcMode; +} EffectBlureInit1; // size = 0x1A0 typedef struct { /* 0x00 */ s32 calcMode; @@ -104,7 +106,7 @@ typedef struct { /* 0x1B */ u8 mode4Param; /* 0x1C */ Color_RGBA8 altPrimColor; // used with drawMode 1 /* 0x20 */ Color_RGBA8 altEnvColor; // used with drawMode 1 -} EffBlureInit2; // size = 0x24 +} EffectBlureInit2; // size = 0x24 typedef struct { /* 0x000 */ EffectBlureElement elements[16]; @@ -117,31 +119,26 @@ typedef struct { /* 0x192 */ Color_RGBA8 p2StartColor; /* 0x196 */ Color_RGBA8 p1EndColor; /* 0x19A */ Color_RGBA8 p2EndColor; - /* 0x19E */ u8 numElements; + /* 0x19E */ u8 numElements; // "now_edge_num" /* 0x19F */ u8 elemDuration; /* 0x1A0 */ u8 unkFlag; /* 0x1A1 */ u8 drawMode; // 0: simple; 1: simple with alt colors; 2+: smooth - /* 0x1A2 */ Color_RGBA8 altPrimColor; - /* 0x1A6 */ Color_RGBA8 altEnvColor; + /* 0x1A2 */ Color_RGBA8 altPrimColor; // used with drawMode 1 + /* 0x1A6 */ Color_RGBA8 altEnvColor; // used with drawMode 1 } EffectBlure; // size = 0x1AC typedef struct { - /* 0x000 */ EffCommon base; - /* 0x004 */ EffectBlure params; -} EffBlure; // size = 0x1B0 - -typedef struct { - /* 0x00 */ f32 startSpeed; + /* 0x00 */ f32 initialSpeed; /* 0x04 */ f32 endXChange; /* 0x08 */ f32 endX; /* 0x0C */ f32 startXChange; /* 0x10 */ f32 startX; - /* 0x14 */ s16 rotationY; - /* 0x16 */ s16 rotationZ; -} EffShieldParticleParticle; // size = 0x18 + /* 0x14 */ s16 yaw; + /* 0x16 */ s16 pitch; +} EffectShieldParticleElement; // size = 0x18 typedef struct { - /* 0x00 */ u8 numParticles; + /* 0x00 */ u8 numElements; /* 0x02 */ Vec3s position; /* 0x08 */ Color_RGBA8 primColorStart; /* 0x0C */ Color_RGBA8 envColorStart; @@ -149,18 +146,17 @@ typedef struct { /* 0x14 */ Color_RGBA8 envColorMid; /* 0x18 */ Color_RGBA8 primColorEnd; /* 0x1C */ Color_RGBA8 envColorEnd; - /* 0x20 */ f32 acceleration; + /* 0x20 */ f32 deceleration; /* 0x24 */ f32 maxInitialSpeed; /* 0x28 */ f32 lengthCutoff; /* 0x2C */ u8 duration; /* 0x2E */ LightPoint lightPoint; - /* 0x3C */ s32 hasLight; -} EffShieldParticleInit; // size = 0x40 + /* 0x3C */ s32 lightDecay; // halves light radius every frame when set to 1 +} EffectShieldParticleInit; // size = 0x40 typedef struct { - /* 0x000 */ EffShieldParticleParticle particles[16]; - /* 0x180 */ u8 numParticles; - /* 0x181 */ UNK_TYPE1 pad181[0x1]; + /* 0x000 */ EffectShieldParticleElement elements[16]; + /* 0x180 */ u8 numElements; /* 0x182 */ Vec3s position; /* 0x188 */ Color_RGBA8 primColorStart; /* 0x18C */ Color_RGBA8 envColorStart; @@ -168,66 +164,75 @@ typedef struct { /* 0x194 */ Color_RGBA8 envColorMid; /* 0x198 */ Color_RGBA8 primColorEnd; /* 0x19C */ Color_RGBA8 envColorEnd; - /* 0x1A0 */ f32 acceleration; - /* 0x1A4 */ UNK_TYPE1 pad1A4[0x4]; + /* 0x1A0 */ f32 deceleration; + /* 0x1A4 */ char unk_1A4[0x04]; /* 0x1A8 */ f32 maxInitialSpeed; /* 0x1AC */ f32 lengthCutoff; /* 0x1B0 */ u8 duration; - /* 0x1B1 */ u8 age; + /* 0x1B1 */ u8 timer; /* 0x1B2 */ LightInfo lightInfo; - /* 0x1C0 */ LightNode* light; - /* 0x1C4 */ s32 hasLight; -} EffShieldParticleParams; // size = 0x1C8 + /* 0x1C0 */ LightNode* lightNode; + /* 0x1C4 */ s32 lightDecay; // halves light radius every frame when set to 1 +} EffectShieldParticle; // size = 0x1C8 typedef struct { - /* 0x000 */ EffCommon base; - /* 0x004 */ EffShieldParticleParams params; -} EffShieldParticle; // size = 0x1CC - -typedef struct { - /* 0x00 */ UNK_TYPE2 active; - /* 0x02 */ Vec3s position1; - /* 0x08 */ Vec3s position2; + /* 0x00 */ u16 flags; + /* 0x02 */ Vec3s p1; + /* 0x08 */ Vec3s p2; /* 0x0E */ s16 life; /* 0x10 */ UNK_TYPE1 pad10[0x4]; - /* 0x14 */ UNK_TYPE4 unk14; -} EffTireMarkParticle; // size = 0x18 + /* 0x14 */ CollisionPoly* colPoly; +} EffectTireMarkElement; // size = 0x18 typedef struct { /* 0x0 */ s16 unk0; - /* 0x2 */ s16 maxLife; + /* 0x2 */ s16 elemDuration; /* 0x4 */ Color_RGBA8 color; -} EffTireMarkInit; // size = 0x8 +} EffectTireMarkInit; // size = 0x8 typedef struct { - /* 0x000 */ EffTireMarkParticle particles[64]; + /* 0x000 */ EffectTireMarkElement elements[64]; /* 0x600 */ s16 unk600; - /* 0x602 */ s16 numParticles; - /* 0x604 */ s16 maxLife; + /* 0x602 */ s16 numElements; + /* 0x604 */ s16 elemDuration; /* 0x606 */ Color_RGBA8 color; - /* 0x60A */ UNK_TYPE1 pad60A[0x2]; -} EffTireMarkParams; // size = 0x60C - -typedef struct { - /* 0x000 */ EffCommon base; - /* 0x004 */ EffTireMarkParams params; -} EffTireMark; // size = 0x610 - -typedef struct { - /* 0x00 */ u32 paramsSize; - /* 0x04 */ eff_init_func init; - /* 0x08 */ eff_destroy_func destroy; - /* 0x0C */ eff_update_func update; - /* 0x10 */ eff_draw_func draw; -} EffInfo; // size = 0x14 +} EffectTireMark; // size = 0x60C typedef struct { /* 0x0000 */ struct GlobalContext* globalCtx; - /* 0x0004 */ EffSpark sparks[SPARK_COUNT]; - /* 0x0E5C */ EffBlure blures[BLURE_COUNT]; - /* 0x388C */ EffShieldParticle shieldParticles[SHIELD_PARTICLE_COUNT]; - /* 0x3DF0 */ EffTireMark tireMarks[TIRE_MARK_COUNT]; -} EffTables; // size = 0x98E0 + struct { + EffectStatus status; + EffectSpark effect; + } /* 0x0004 */ sparks[SPARK_COUNT]; + struct { + EffectStatus status; + EffectBlure effect; + } /* 0x0E5C */ blures[BLURE_COUNT]; + struct { + EffectStatus status; + EffectShieldParticle effect; + } /* 0x388C */ shieldParticles[SHIELD_PARTICLE_COUNT]; + struct { + EffectStatus status; + EffectTireMark effect; + } /* 0x3DF0 */ tireMarks[TIRE_MARK_COUNT]; +} EffectContext; // size = 0x98E0 + +typedef struct { + /* 0x00 */ u32 size; + /* 0x04 */ void (*init)(void* effect, void* initParams); + /* 0x08 */ void (*destroy)(void* effect); + /* 0x0C */ s32 (*update)(void* effect); + /* 0x10 */ void (*draw)(void* effect, struct GraphicsContext* gfxCtx); +} EffectInfo; // size = 0x14 + +typedef enum { + /* 0x00 */ EFFECT_SPARK, + /* 0x01 */ EFFECT_BLURE1, + /* 0x02 */ EFFECT_BLURE2, + /* 0x03 */ EFFECT_SHIELD_PARTICLE, + /* 0x04 */ EFFECT_TIRE_MARK +} EffectType; /* Effect Soft Sprites */ @@ -249,7 +254,7 @@ typedef struct { /* 0x0C */ void* vramEnd; /* 0x10 */ void* loadedRamAddr; /* 0x14 */ EffectSsInit* initInfo; - /* 0x18 */ u32 unk18; // Always 0x01000000? + /* 0x18 */ u8 unk18; // Always 1? } EffectSsOverlay; // size = 0x1C typedef struct EffectSs { @@ -274,27 +279,6 @@ typedef struct { /* 0x8 */ s32 size; } EffectSsInfo; // size = 0xC -typedef struct { - /* 0x0 */ EffectSs* data_table; // Name from debug assert - /* 0x4 */ s32 searchIndex; - /* 0x8 */ s32 size; -} EffectTableInfo; // size = 0xC - -typedef struct { - /* 0x0 */ UNK_TYPE4 unk0; - /* 0x4 */ EffectSsInitFunc init; -} ParticleOverlayInfo; // size = 0x8 - -typedef struct { - /* 0x00 */ u32 vromStart; - /* 0x04 */ u32 vromEnd; - /* 0x08 */ void* vramStart; - /* 0x0C */ void* vramEnd; - /* 0x10 */ void* loadedRamAddr; - /* 0x14 */ ParticleOverlayInfo* overlayInfo; - /* 0x18 */ u32 unk18; // Always 0x01000000? -} ParticleOverlay; // size = 0x1C - typedef enum { /* 0x00 */ EFFECT_SS_DUST, /* 0x01 */ EFFECT_SS_KIRAKIRA, diff --git a/include/z64item.h b/include/z64item.h index 739f941027..8b436bbf10 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -275,7 +275,7 @@ typedef enum { /* 0x07 */ GI_RUPEE_HUGE, /* 0x08 */ GI_WALLET_ADULT, /* 0x09 */ GI_WALLET_GIANT, - /* 0x0A */ GI_0A, //Recovery Heart / Blue Rupee? + /* 0x0A */ GI_RECOVERY_HEART, /* 0x0C */ GI_HEART_PIECE = 0x0C, /* 0x0D */ GI_HEART_CONTAINER, /* 0x16 */ GI_BOMBS_10 = 0x16, @@ -299,6 +299,7 @@ typedef enum { /* 0x3C */ GI_KEY_SMALL = 0x3C, /* 0x3E */ GI_MAP = 0x3E, /* 0x3F */ GI_COMPASS, + /* 0x52 */ GI_SCALE_GOLD = 0x52, // Assumed, used in En_Fishing /* 0x59 */ GI_BOTTLE_POTION_RED = 0x59, /* 0x5A */ GI_5A, /* 0x5B */ GI_POTION_RED = 0x5B, @@ -343,6 +344,7 @@ typedef enum { /* 0x9F */ GI_SHIELD_HERO_2, // Code that treats this as hero's shield is unused, so take with a grain of salt /* 0xA1 */ GI_LETTER_TO_MAMA = 0xA1, /* 0xA9 */ GI_BOTTLE = 0xA9, + /* 0xAB */ GI_PENDANT_OF_MEMORIES = 0xAB, /* 0xBA */ GI_MAX = 0xBA } GetItemID; @@ -373,4 +375,12 @@ typedef enum { /* 0x68 */ GID_SWORD_GREAT_FAIRY } GetItemDrawID; +// TODO: fill +typedef enum { + /* -1 */ EXCH_ITEM_MINUS1 = -1, // Unknown usage or function + /* 0x00 */ EXCH_ITEM_NONE, + /* 0x1E */ EXCH_ITEM_1E = 0x1E, // BOTTLE_MUSHROOM + /* 0x2A */ EXCH_ITEM_2A = 0x2A // MOON_TEAR? +} ExchangeItemID; + #endif diff --git a/include/z64math.h b/include/z64math.h index 3caad91083..dff6699766 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -85,9 +85,10 @@ typedef struct { /* 0x06 */ s16 yaw; // azimuthal angle } VecSph; // size = 0x08 -#define F32_LERP(v0,v1,t) ((1.0f - (t)) * (v0) + (t) * (v1)) -#define F32_LERPIMP(v0, v1, t) (v0 + ((v1 - v0) * t)) -#define F32_LERPIMPINV(v0, v1, t) ((v0) + (((v1) - (v0)) / (t))) +#define LERPIMP(v0, v1, t) ((v0) + (((v1) - (v0)) * (t))) +#define F32_LERP(v0, v1, t) ((1.0f - (t)) * (f32)(v0) + (t) * (f32)(v1)) +#define F32_LERPIMP(v0, v1, t) ((f32)(v0) + (((f32)(v1) - (f32)(v0)) * (t))) +#define F32_LERPIMPINV(v0, v1, t) ((f32)(v0) + (((f32)(v1) - (f32)(v0)) / (t))) #define BINANG_LERPIMP(v0, v1, t) ((v0) + (s16)(BINANG_SUB((v1), (v0)) * (t))) #define BINANG_LERPIMPINV(v0, v1, t) ((v0) + BINANG_SUB((v1), (v0)) / (t)) diff --git a/include/z64player.h b/include/z64player.h index 6b156372eb..4066e2baf3 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -1,5 +1,5 @@ -#ifndef _Z64PLAYER_H_ -#define _Z64PLAYER_H_ +#ifndef Z64PLAYER_H +#define Z64PLAYER_H #include "z64actor.h" #include "os.h" @@ -252,7 +252,7 @@ typedef struct Player { /* 0x32A */ Vec3s morphTable[5]; /* 0x348 */ s16 eyeTexId; /* 0x34A */ s16 eyeAnimTimer; - /* 0x34C */ Actor* leftHandActor; + /* 0x34C */ Actor* heldActor; /* 0x350 */ PosRot leftHandWorld; /* 0x364 */ Actor* rightHandActor; /* 0x368 */ PosRot rightHandWorld; @@ -261,12 +261,12 @@ typedef struct Player { /* 0x37E */ s8 doorTimer; /* 0x37F */ s8 doorNext; // used with spiral staircase /* 0x380 */ Actor* doorActor; - /* 0x384 */ s16 unk_384; - /* 0x386 */ u16 unk_386; - /* 0x388 */ Actor* unk_388; - /* 0x38C */ s16 unk_38C; + /* 0x384 */ s16 getItemId; + /* 0x386 */ u16 getItemDirection; + /* 0x388 */ Actor* interactRangeActor; + /* 0x38C */ s8 mountSide; /* 0x390 */ Actor* rideActor; - /* 0x394 */ u8 unk_394; + /* 0x394 */ u8 csMode; /* 0x395 */ u8 unk_395; /* 0x396 */ u8 unk_396; /* 0x397 */ u8 unk_397; @@ -289,7 +289,8 @@ typedef struct Player { /* 0x664 */ ColliderQuad shieldQuad; /* 0x6E4 */ ColliderCylinder shieldCylinder; /* 0x730 */ Actor* unk_730; - /* 0x734 */ char unk_734[8]; + /* 0x734 */ char unk_734[4]; + /* 0x738 */ s32 unk_738; /* 0x73C */ s32 blureEffectIndex[3]; /* 0x748 */ char unk_748[0x320]; /* 0xA68 */ PlayerAgeProperties* ageProperties; // repurposed as "transformation properties"? @@ -301,7 +302,7 @@ typedef struct Player { /* 0xA80 */ Actor* tatlActor; /* 0xA84 */ s16 tatlTextId; /* 0xA86 */ s8 unk_A86; - /* 0xA87 */ s8 unk_A87; + /* 0xA87 */ s8 exchangeItemId; /* 0xA88 */ Actor* targetActor; /* 0xA8C */ f32 targetActorDistance; /* 0xA90 */ Actor* unk_A90; diff --git a/include/z64save.h b/include/z64save.h index a1ec72ab96..8e08a550a2 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -67,7 +67,7 @@ typedef struct { /* 0x0039 */ s8 magic; // "magic_now" /* 0x003A */ s16 rupees; // "lupy_count" /* 0x003C */ u16 swordHealth; // "long_sword_hp" - /* 0x003E */ u16 naviTimer; // "navi_timer" + /* 0x003E */ u16 tatlTimer; // "navi_timer" /* 0x0040 */ u8 magicAcquired; // "magic_mode" /* 0x0041 */ u8 doubleMagic; // "magic_ability" /* 0x0042 */ u8 doubleDefense; // "life_ability" @@ -174,7 +174,7 @@ typedef struct { /* 0x3F5C */ s32 unk_3F5C; // "bet_rupees" /* 0x3F60 */ u8 unk_3F60; // "framescale_flag" /* 0x3F64 */ f32 unk_3F64; // "framescale_scale" - /* 0x3F68 */ u32 unk_3F68[5][120]; + /* 0x3F68 */ u32 cycleSceneFlags[120][5]; /* 0x48C8 */ u16 unk_48C8; // "scene_id_mix" /* 0x48CA */ u8 maskMaskBit[3]; // masks given away on the Moon /* 0x48CD */ char unk_48CD[24]; diff --git a/include/z64scene.h b/include/z64scene.h index 3335699747..8d301d1d17 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -295,7 +295,7 @@ typedef struct { /* 0x04 */ s16 id; /* 0x06 */ Vec3s pos; /* 0x0C */ s16 rotY; - /* 0x0E */ s16 params; + /* 0x0E */ u16 params; } TransitionActorEntry; // size = 0x10 typedef struct { diff --git a/spec b/spec index 6c44f3b2d8..7260f38dc2 100644 --- a/spec +++ b/spec @@ -46,7 +46,6 @@ beginseg include "build/src/boot_O2/system_malloc.o" include "build/src/boot_O2/rand.o" include "build/src/boot_O2/__osMalloc.o" - include "build/data/boot/__osMalloc.bss.o" include "build/src/libultra/rmon/sprintf.o" include "build/src/boot_O2/printutils.o" include "build/src/boot_O2/sleep.o" @@ -120,8 +119,6 @@ beginseg include "build/src/libultra/io/devmgr.o" include "build/src/libultra/io/pirawdma.o" include "build/src/libultra/io/contpfs.o" - include "build/data/boot/contpfs.data.o" - include "build/data/boot/contpfs.bss.o" include "build/asm/boot/getcount.text.o" pad_text include "build/asm/boot/guMtxL2F.text.o" @@ -430,23 +427,19 @@ beginseg include "build/data/code/code_801E3FA0.bss.o" include "build/src/code/z_en_item00.o" include "build/src/code/z_eff_blure.o" - include "build/data/code/z_eff_blure.data.o" include "build/src/code/z_eff_shield_particle.o" - include "build/data/code/z_eff_shield_particle.data.o" include "build/src/code/z_eff_spark.o" include "build/src/code/z_eff_ss_dead.o" include "build/src/code/z_eff_tire_mark.o" include "build/src/code/z_effect.o" - include "build/data/code/z_effect.bss.o" include "build/src/code/z_effect_soft_sprite.o" - include "build/data/code/z_effect_soft_sprite.data.o" include "build/src/code/z_effect_soft_sprite_old_init.o" - include "build/data/code/z_effect_soft_sprite_old_init.data.o" + include "build/src/code/z_effect_soft_sprite_dlftbls.o" include "build/src/code/flg_set.o" + include "build/data/code/flg_set.bss.o" include "build/src/code/pad_801DC9C0.o" include "build/src/code/z_DLF.o" include "build/src/code/z_actor.o" - include "build/data/code/z_actor.data.o" include "build/data/code/z_actor.bss.o" include "build/src/code/z_actor_dlftbls.o" include "build/src/code/z_bgcheck.o" @@ -471,7 +464,7 @@ beginseg 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/code_800F0390.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_face_reaction.o" @@ -497,7 +490,6 @@ beginseg include "build/src/code/z_lights.o" include "build/data/code/z_lights.bss.o" include "build/src/code/z_malloc.o" - include "build/data/code/z_malloc.bss.o" include "build/src/code/z_map_disp.o" include "build/data/code/z_map_disp.data.o" include "build/data/code/z_map_disp.bss.o" @@ -567,10 +559,7 @@ beginseg 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/data/code/z_kaleido_manager.data.o" - include "build/data/code/z_kaleido_manager.bss.o" include "build/src/code/z_kaleido_scope_call.o" - include "build/data/code/z_kaleido_scope_call.bss.o" include "build/src/code/z_fbdemo_dlftbls.o" include "build/data/code/code_801D0BB0.data.o" include "build/src/code/z_fbdemo.o" @@ -641,7 +630,7 @@ beginseg 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/code_80194710.o" + include "build/src/code/audio/audio_dcache.o" include "build/src/code/audio/code_80194790.o" include "build/data/code/code_80194790.data.o" include "build/src/code/audio/audio_playback.o" @@ -741,12 +730,12 @@ beginseg endseg beginseg - name "ovl_Player_Actor" + name "ovl_player_actor" compress - include "build/src/overlays/actors/ovl_Player_Actor/z_player.o" - include "build/data/ovl_Player_Actor/ovl_Player_Actor.data.o" - include "build/data/ovl_Player_Actor/ovl_Player_Actor.bss.o" - include "build/data/ovl_Player_Actor/ovl_Player_Actor.reloc.o" + include "build/src/overlays/actors/ovl_player_actor/z_player.o" + include "build/data/ovl_player_actor/ovl_player_actor.data.o" + include "build/data/ovl_player_actor/ovl_player_actor.bss.o" + include "build/data/ovl_player_actor/ovl_player_actor.reloc.o" endseg beginseg @@ -862,8 +851,7 @@ beginseg name "ovl_En_Elf" compress include "build/src/overlays/actors/ovl_En_Elf/z_en_elf.o" - include "build/data/ovl_En_Elf/ovl_En_Elf.data.o" - include "build/data/ovl_En_Elf/ovl_En_Elf.reloc.o" + include "build/src/overlays/actors/ovl_En_Elf/ovl_En_Elf_reloc.o" endseg beginseg @@ -884,8 +872,7 @@ beginseg name "ovl_En_Peehat" compress include "build/src/overlays/actors/ovl_En_Peehat/z_en_peehat.o" - include "build/data/ovl_En_Peehat/ovl_En_Peehat.data.o" - include "build/data/ovl_En_Peehat/ovl_En_Peehat.reloc.o" + include "build/src/overlays/actors/ovl_En_Peehat/ovl_En_Peehat_reloc.o" endseg beginseg @@ -968,8 +955,7 @@ beginseg name "ovl_En_St" compress include "build/src/overlays/actors/ovl_En_St/z_en_st.o" - include "build/data/ovl_En_St/ovl_En_St.data.o" - include "build/data/ovl_En_St/ovl_En_St.reloc.o" + include "build/src/overlays/actors/ovl_En_St/ovl_En_St_reloc.o" endseg beginseg @@ -1054,9 +1040,11 @@ beginseg name "ovl_Door_Warp1" compress include "build/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.o" - include "build/data/ovl_Door_Warp1/ovl_Door_Warp1.data.o" - include "build/data/ovl_Door_Warp1/ovl_Door_Warp1.bss.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Door_Warp1/ovl_Door_Warp1_reloc.o" +#else include "build/data/ovl_Door_Warp1/ovl_Door_Warp1.reloc.o" +#endif endseg beginseg @@ -1203,9 +1191,11 @@ beginseg name "ovl_Object_Kankyo" compress include "build/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.o" - include "build/data/ovl_Object_Kankyo/ovl_Object_Kankyo.data.o" - include "build/data/ovl_Object_Kankyo/ovl_Object_Kankyo.bss.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Object_Kankyo/ovl_Object_Kankyo_reloc.o" +#else include "build/data/ovl_Object_Kankyo/ovl_Object_Kankyo.reloc.o" +#endif endseg beginseg @@ -1279,8 +1269,7 @@ beginseg name "ovl_En_Bigslime" compress include "build/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.o" - include "build/data/ovl_En_Bigslime/ovl_En_Bigslime.data.o" - include "build/data/ovl_En_Bigslime/ovl_En_Bigslime.reloc.o" + include "build/src/overlays/actors/ovl_En_Bigslime/ovl_En_Bigslime_reloc.o" endseg beginseg @@ -1332,9 +1321,11 @@ beginseg name "ovl_En_Fishing" compress include "build/src/overlays/actors/ovl_En_Fishing/z_en_fishing.o" - include "build/data/ovl_En_Fishing/ovl_En_Fishing.data.o" - include "build/data/ovl_En_Fishing/ovl_En_Fishing.bss.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_En_Fishing/ovl_En_Fishing_reloc.o" +#else include "build/data/ovl_En_Fishing/ovl_En_Fishing.reloc.o" +#endif endseg beginseg @@ -1380,8 +1371,7 @@ beginseg name "ovl_En_Fish" compress include "build/src/overlays/actors/ovl_En_Fish/z_en_fish.o" - include "build/data/ovl_En_Fish/ovl_En_Fish.data.o" - include "build/data/ovl_En_Fish/ovl_En_Fish.reloc.o" + include "build/src/overlays/actors/ovl_En_Fish/ovl_En_Fish_reloc.o" endseg beginseg @@ -1489,8 +1479,7 @@ beginseg name "ovl_En_Fz" compress include "build/src/overlays/actors/ovl_En_Fz/z_en_fz.o" - include "build/data/ovl_En_Fz/ovl_En_Fz.data.o" - include "build/data/ovl_En_Fz/ovl_En_Fz.reloc.o" + include "build/src/overlays/actors/ovl_En_Fz/ovl_En_Fz_reloc.o" endseg beginseg @@ -1650,8 +1639,11 @@ beginseg name "ovl_En_Kanban" compress include "build/src/overlays/actors/ovl_En_Kanban/z_en_kanban.o" - include "build/data/ovl_En_Kanban/ovl_En_Kanban.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_En_Kanban/ovl_En_Kanban_reloc.o" +#else include "build/data/ovl_En_Kanban/ovl_En_Kanban.reloc.o" +#endif endseg beginseg @@ -1681,8 +1673,7 @@ beginseg name "ovl_En_Ishi" compress include "build/src/overlays/actors/ovl_En_Ishi/z_en_ishi.o" - include "build/data/ovl_En_Ishi/ovl_En_Ishi.data.o" - include "build/data/ovl_En_Ishi/ovl_En_Ishi.reloc.o" + include "build/src/overlays/actors/ovl_En_Ishi/ovl_En_Ishi_reloc.o" endseg beginseg @@ -1824,16 +1815,14 @@ beginseg name "ovl_Obj_Roomtimer" compress include "build/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.o" - include "build/data/ovl_Obj_Roomtimer/ovl_Obj_Roomtimer.data.o" - include "build/data/ovl_Obj_Roomtimer/ovl_Obj_Roomtimer.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Roomtimer/ovl_Obj_Roomtimer_reloc.o" endseg beginseg name "ovl_En_Ssh" compress include "build/src/overlays/actors/ovl_En_Ssh/z_en_ssh.o" - include "build/data/ovl_En_Ssh/ovl_En_Ssh.data.o" - include "build/data/ovl_En_Ssh/ovl_En_Ssh.reloc.o" + include "build/src/overlays/actors/ovl_En_Ssh/ovl_En_Ssh_reloc.o" endseg beginseg @@ -1953,8 +1942,7 @@ beginseg name "ovl_Effect_Ss_Stick" compress include "build/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.o" - include "build/data/ovl_Effect_Ss_Stick/ovl_Effect_Ss_Stick.data.o" - include "build/data/ovl_Effect_Ss_Stick/ovl_Effect_Ss_Stick.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Stick/ovl_Effect_Ss_Stick_reloc.o" endseg beginseg @@ -2282,8 +2270,7 @@ beginseg name "ovl_En_Mm2" compress include "build/src/overlays/actors/ovl_En_Mm2/z_en_mm2.o" - include "build/data/ovl_En_Mm2/ovl_En_Mm2.data.o" - include "build/data/ovl_En_Mm2/ovl_En_Mm2.reloc.o" + include "build/src/overlays/actors/ovl_En_Mm2/ovl_En_Mm2_reloc.o" endseg beginseg @@ -2417,8 +2404,7 @@ beginseg name "ovl_En_Aob_01" compress include "build/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.o" - include "build/data/ovl_En_Aob_01/ovl_En_Aob_01.data.o" - include "build/data/ovl_En_Aob_01/ovl_En_Aob_01.reloc.o" + include "build/src/overlays/actors/ovl_En_Aob_01/ovl_En_Aob_01_reloc.o" endseg beginseg @@ -2559,9 +2545,7 @@ beginseg name "ovl_Boss_04" compress include "build/src/overlays/actors/ovl_Boss_04/z_boss_04.o" - include "build/data/ovl_Boss_04/ovl_Boss_04.data.o" - include "build/data/ovl_Boss_04/ovl_Boss_04.bss.o" - include "build/data/ovl_Boss_04/ovl_Boss_04.reloc.o" + include "build/src/overlays/actors/ovl_Boss_04/ovl_Boss_04_reloc.o" endseg beginseg @@ -2617,8 +2601,11 @@ beginseg name "ovl_En_Go" compress include "build/src/overlays/actors/ovl_En_Go/z_en_go.o" - include "build/data/ovl_En_Go/ovl_En_Go.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_En_Go/ovl_En_Go_reloc.o" +#else include "build/data/ovl_En_Go/ovl_En_Go.reloc.o" +#endif endseg beginseg @@ -2655,9 +2642,7 @@ beginseg name "ovl_Obj_Flowerpot" compress include "build/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.o" - include "build/data/ovl_Obj_Flowerpot/ovl_Obj_Flowerpot.data.o" - include "build/data/ovl_Obj_Flowerpot/ovl_Obj_Flowerpot.bss.o" - include "build/data/ovl_Obj_Flowerpot/ovl_Obj_Flowerpot.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Flowerpot/ovl_Obj_Flowerpot_reloc.o" endseg beginseg @@ -2704,8 +2689,11 @@ beginseg name "ovl_Obj_Iceblock" compress include "build/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.o" - include "build/data/ovl_Obj_Iceblock/ovl_Obj_Iceblock.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Iceblock/ovl_Obj_Iceblock_reloc.o" +#else include "build/data/ovl_Obj_Iceblock/ovl_Obj_Iceblock.reloc.o" +#endif endseg beginseg @@ -2934,8 +2922,7 @@ beginseg name "ovl_En_Wiz_Fire" compress include "build/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.o" - include "build/data/ovl_En_Wiz_Fire/ovl_En_Wiz_Fire.data.o" - include "build/data/ovl_En_Wiz_Fire/ovl_En_Wiz_Fire.reloc.o" + include "build/src/overlays/actors/ovl_En_Wiz_Fire/ovl_En_Wiz_Fire_reloc.o" endseg beginseg @@ -3025,8 +3012,7 @@ beginseg name "ovl_Obj_Hugebombiwa" compress include "build/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.o" - include "build/data/ovl_Obj_Hugebombiwa/ovl_Obj_Hugebombiwa.data.o" - include "build/data/ovl_Obj_Hugebombiwa/ovl_Obj_Hugebombiwa.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hugebombiwa/ovl_Obj_Hugebombiwa_reloc.o" endseg beginseg @@ -3048,17 +3034,14 @@ beginseg name "ovl_En_Water_Effect" compress include "build/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.o" - include "build/data/ovl_En_Water_Effect/ovl_En_Water_Effect.data.o" - include "build/data/ovl_En_Water_Effect/ovl_En_Water_Effect.reloc.o" + include "build/src/overlays/actors/ovl_En_Water_Effect/ovl_En_Water_Effect_reloc.o" endseg beginseg name "ovl_En_Kusa2" compress include "build/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.o" - include "build/data/ovl_En_Kusa2/ovl_En_Kusa2.data.o" - include "build/data/ovl_En_Kusa2/ovl_En_Kusa2.bss.o" - include "build/data/ovl_En_Kusa2/ovl_En_Kusa2.reloc.o" + include "build/src/overlays/actors/ovl_En_Kusa2/ovl_En_Kusa2_reloc.o" endseg beginseg @@ -3125,9 +3108,7 @@ beginseg name "ovl_En_Fall" compress include "build/src/overlays/actors/ovl_En_Fall/z_en_fall.o" - include "build/data/ovl_En_Fall/ovl_En_Fall.data.o" - include "build/data/ovl_En_Fall/ovl_En_Fall.bss.o" - include "build/data/ovl_En_Fall/ovl_En_Fall.reloc.o" + include "build/src/overlays/actors/ovl_En_Fall/ovl_En_Fall_reloc.o" endseg beginseg @@ -3367,8 +3348,7 @@ beginseg name "ovl_Obj_Tokeidai" compress include "build/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.o" - include "build/data/ovl_Obj_Tokeidai/ovl_Obj_Tokeidai.data.o" - include "build/data/ovl_Obj_Tokeidai/ovl_Obj_Tokeidai.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Tokeidai/ovl_Obj_Tokeidai_reloc.o" endseg beginseg @@ -3632,8 +3612,7 @@ beginseg name "ovl_En_Kame" compress include "build/src/overlays/actors/ovl_En_Kame/z_en_kame.o" - include "build/data/ovl_En_Kame/ovl_En_Kame.data.o" - include "build/data/ovl_En_Kame/ovl_En_Kame.reloc.o" + include "build/src/overlays/actors/ovl_En_Kame/ovl_En_Kame_reloc.o" endseg beginseg @@ -3851,16 +3830,14 @@ beginseg name "ovl_En_Col_Man" compress include "build/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.o" - include "build/data/ovl_En_Col_Man/ovl_En_Col_Man.data.o" - include "build/data/ovl_En_Col_Man/ovl_En_Col_Man.reloc.o" + include "build/src/overlays/actors/ovl_En_Col_Man/ovl_En_Col_Man_reloc.o" endseg beginseg name "ovl_En_Talk_Gibud" compress include "build/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.o" - include "build/data/ovl_En_Talk_Gibud/ovl_En_Talk_Gibud.data.o" - include "build/data/ovl_En_Talk_Gibud/ovl_En_Talk_Gibud.reloc.o" + include "build/src/overlays/actors/ovl_En_Talk_Gibud/ovl_En_Talk_Gibud_reloc.o" endseg beginseg @@ -3874,8 +3851,11 @@ beginseg name "ovl_Obj_Snowball" compress include "build/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.o" - include "build/data/ovl_Obj_Snowball/ovl_Obj_Snowball.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Snowball/ovl_obj_Snowball_reloc.o" +#else include "build/data/ovl_Obj_Snowball/ovl_Obj_Snowball.reloc.o" +#endif endseg beginseg @@ -3890,8 +3870,7 @@ beginseg name "ovl_En_Gb2" compress include "build/src/overlays/actors/ovl_En_Gb2/z_en_gb2.o" - include "build/data/ovl_En_Gb2/ovl_En_Gb2.data.o" - include "build/data/ovl_En_Gb2/ovl_En_Gb2.reloc.o" + include "build/src/overlays/actors/ovl_En_Gb2/ovl_En_Gb2_reloc.o" endseg beginseg @@ -3990,8 +3969,7 @@ beginseg name "ovl_Obj_Dowsing" compress include "build/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.o" - include "build/data/ovl_Obj_Dowsing/ovl_Obj_Dowsing.data.o" - include "build/data/ovl_Obj_Dowsing/ovl_Obj_Dowsing.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Dowsing/ovl_Obj_Dowsing_reloc.o" endseg beginseg @@ -4274,8 +4252,7 @@ beginseg name "ovl_En_Rail_Skb" compress include "build/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.o" - include "build/data/ovl_En_Rail_Skb/ovl_En_Rail_Skb.data.o" - include "build/data/ovl_En_Rail_Skb/ovl_En_Rail_Skb.reloc.o" + include "build/src/overlays/actors/ovl_En_Rail_Skb/ovl_En_Rail_Skb_reloc.o" endseg beginseg @@ -4415,9 +4392,7 @@ beginseg name "ovl_En_Zog" compress include "build/src/overlays/actors/ovl_En_Zog/z_en_zog.o" - include "build/data/ovl_En_Zog/ovl_En_Zog.data.o" - include "build/data/ovl_En_Zog/ovl_En_Zog.bss.o" - include "build/data/ovl_En_Zog/ovl_En_Zog.reloc.o" + include "build/src/overlays/actors/ovl_En_Zog/ovl_En_Zog_reloc.o" endseg beginseg @@ -4432,16 +4407,14 @@ beginseg name "ovl_Obj_Jg_Gakki" compress include "build/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.o" - include "build/data/ovl_Obj_Jg_Gakki/ovl_Obj_Jg_Gakki.data.o" - include "build/data/ovl_Obj_Jg_Gakki/ovl_Obj_Jg_Gakki.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Jg_Gakki/ovl_Obj_Jg_Gakki_reloc.o" endseg beginseg name "ovl_Bg_Inibs_Movebg" compress include "build/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.o" - include "build/data/ovl_Bg_Inibs_Movebg/ovl_Bg_Inibs_Movebg.data.o" - include "build/data/ovl_Bg_Inibs_Movebg/ovl_Bg_Inibs_Movebg.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Inibs_Movebg/ovl_Bg_Inibs_Movebg_reloc.o" endseg beginseg @@ -4588,8 +4561,7 @@ beginseg name "ovl_En_Geg" compress include "build/src/overlays/actors/ovl_En_Geg/z_en_geg.o" - include "build/data/ovl_En_Geg/ovl_En_Geg.data.o" - include "build/data/ovl_En_Geg/ovl_En_Geg.reloc.o" + include "build/src/overlays/actors/ovl_En_Geg/ovl_En_Geg_reloc.o" endseg beginseg @@ -4896,8 +4868,7 @@ beginseg name "ovl_En_Talk" compress include "build/src/overlays/actors/ovl_En_Talk/z_en_talk.o" - include "build/data/ovl_En_Talk/ovl_En_Talk.data.o" - include "build/data/ovl_En_Talk/ovl_En_Talk.reloc.o" + include "build/src/overlays/actors/ovl_En_Talk/ovl_En_Talk_reloc.o" endseg beginseg @@ -4935,8 +4906,7 @@ beginseg name "ovl_En_Ruppecrow" compress include "build/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.o" - include "build/data/ovl_En_Ruppecrow/ovl_En_Ruppecrow.data.o" - include "build/data/ovl_En_Ruppecrow/ovl_En_Ruppecrow.reloc.o" + include "build/src/overlays/actors/ovl_En_Ruppecrow/ovl_En_Ruppecrow_reloc.o" endseg beginseg @@ -5042,8 +5012,7 @@ beginseg name "ovl_En_Akindonuts" compress include "build/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.o" - include "build/data/ovl_En_Akindonuts/ovl_En_Akindonuts.data.o" - include "build/data/ovl_En_Akindonuts/ovl_En_Akindonuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Akindonuts/ovl_En_Akindonuts_reloc.o" endseg beginseg @@ -5122,7 +5091,6 @@ beginseg name "ovl_En_Bomjima" compress include "build/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.o" - include "build/data/ovl_En_Bomjima/ovl_En_Bomjima.data.o" include "build/data/ovl_En_Bomjima/ovl_En_Bomjima.reloc.o" endseg @@ -5130,8 +5098,7 @@ beginseg name "ovl_En_Bomjimb" compress include "build/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.o" - include "build/data/ovl_En_Bomjimb/ovl_En_Bomjimb.data.o" - include "build/data/ovl_En_Bomjimb/ovl_En_Bomjimb.reloc.o" + include "build/src/overlays/actors/ovl_En_Bomjimb/ovl_En_Bomjimb_reloc.o" endseg beginseg diff --git a/src/boot_O2/__osMalloc.c b/src/boot_O2/__osMalloc.c index 503c7c25ac..24fa6d39ec 100644 --- a/src/boot_O2/__osMalloc.c +++ b/src/boot_O2/__osMalloc.c @@ -1,4 +1,8 @@ -#include "global.h" +#include "os_malloc.h" +#include "libc/stdbool.h" +#include "libc/stdint.h" +#include "macros.h" +#include "functions.h" #define FILL_ALLOCBLOCK (1 << 0) #define FILL_FREEBLOCK (1 << 1) @@ -13,9 +17,9 @@ #define BLOCK_FREE_MAGIC (0xEF) #define BLOCK_FREE_MAGIC_32 (0xEFEFEFEF) -extern OSMesg sArenaLockMsg[1]; +OSMesg sArenaLockMsg[1]; -#pragma GLOBAL_ASM("asm/non_matchings/boot/__osMalloc/D_80099110.s") +void __osMallocAddHeap(Arena* arena, void* heap, size_t size); void ArenaImpl_LockInit(Arena* arena) { osCreateMesgQueue(&arena->lock, sArenaLockMsg, ARRAY_COUNT(sArenaLockMsg)); @@ -45,111 +49,184 @@ ArenaNode* ArenaImpl_GetLastBlock(Arena* arena) { return last; } -void __osMallocInit(Arena* arena, void* start, size_t size) { - bzero(arena, sizeof(*arena)); +/** + * Initializes \p arena to manage the memory region \p heap. + * + * @param arena The Arena to initialize. + * @param heap The memory region to use as heap space. + * @param size The size of the heap. + */ +void __osMallocInit(Arena* arena, void* heap, size_t size) { + bzero(arena, sizeof(Arena)); + ArenaImpl_LockInit(arena); - __osMallocAddBlock(arena, start, size); - arena->isInit = 1; + + __osMallocAddHeap(arena, heap, size); + arena->isInit = true; } -void __osMallocAddBlock(Arena* arena, void* start, s32 size) { - s32 diff; - s32 size2; +// Original name: __osMallocAddBlock +void __osMallocAddHeap(Arena* arena, void* heap, size_t size) { + ptrdiff_t diff; + s32 alignedSize; ArenaNode* firstNode; ArenaNode* lastNode; - if (start != NULL) { - firstNode = (ArenaNode*)ALIGN16((u32)start); - diff = (s32)firstNode - (s32)start; - size2 = (size - diff) & ~0xF; + if (heap == NULL) { + return; + } - if (size2 > (s32)sizeof(ArenaNode)) { - firstNode->next = NULL; - firstNode->prev = NULL; - firstNode->size = size2 - sizeof(ArenaNode); - firstNode->isFree = 1; - firstNode->magic = NODE_MAGIC; - ArenaImpl_Lock(arena); - lastNode = ArenaImpl_GetLastBlock(arena); - if (lastNode == NULL) { - arena->head = firstNode; - arena->start = start; - } else { - firstNode->prev = lastNode; - lastNode->next = firstNode; - } - ArenaImpl_Unlock(arena); + firstNode = (ArenaNode*)ALIGN16((uintptr_t)heap); + diff = (uintptr_t)firstNode - (uintptr_t)heap; + alignedSize = ((s32)size - diff) & ~0xF; + + // If the size of the heap is smaller than sizeof(ArenaNode), then the initialization will silently fail + if (alignedSize > (s32)sizeof(ArenaNode)) { + firstNode->next = NULL; + firstNode->prev = NULL; + firstNode->size = alignedSize - sizeof(ArenaNode); + firstNode->isFree = true; + firstNode->magic = NODE_MAGIC; + + ArenaImpl_Lock(arena); + + lastNode = ArenaImpl_GetLastBlock(arena); + + // Checks if there's already a block + if (lastNode == NULL) { + arena->head = firstNode; + arena->start = heap; + } else { + // Chain the existing block with the new one + firstNode->prev = lastNode; + lastNode->next = firstNode; } + + ArenaImpl_Unlock(arena); } } +/** + * Clears the whole \p arena, invalidating every allocated pointer to it. + * + * @param arena The Arena to clear. + */ void __osMallocCleanup(Arena* arena) { - bzero(arena, sizeof(*arena)); + bzero(arena, sizeof(Arena)); } +/** + * Returns whether or not the \p arena has been initialized. + * + * @param arena The Arena to check. + * @return u8 `true` if the \p arena has been initialized. `false` otherwise. + */ u8 __osMallocIsInitalized(Arena* arena) { return arena->isInit; } +/** + * Allocates at least \p size bytes of memory using the given \p arena. + * The block of memory will be allocated at the start of the first sufficiently large free block. + * + * - If there's not enough space in the given \p arena, this function will fail, returning `NULL`. + * - If \p size is zero, then an empty region of memory is returned. + * + * To avoid memory leaks, the returned pointer should be eventually deallocated using either `__osFree` or + * `__osRealloc`. + * + * @param[in, out] arena The specific Arena to be used for the allocation. + * @param[in] size The size in bytes that will be allocated. + * @return void* On success, the allocated area of the \p arena memory. Otherwise, `NULL`. + */ void* __osMalloc(Arena* arena, size_t size) { ArenaNode* iter; ArenaNode* newNode; - void* alloc; - u32 blockSize; - alloc = NULL; + void* alloc = NULL; size = ALIGN16(size); + ArenaImpl_Lock(arena); + + // Start iterating from the head of the arena. iter = arena->head; + // Iterate over the arena looking for a big enough space of memory. while (iter != NULL) { if (iter->isFree && iter->size >= size) { - ArenaNode* next; - blockSize = ALIGN16(size) + sizeof(ArenaNode); + size_t blockSize = ALIGN16(size) + sizeof(ArenaNode); + + // If the block is larger than the requested size, then split it and just use the required size of the + // current block. if (blockSize < iter->size) { - newNode = (ArenaNode*)((u32)iter + blockSize); + ArenaNode* next; + + newNode = (ArenaNode*)((uintptr_t)iter + blockSize); newNode->next = iter->next; newNode->prev = iter; newNode->size = iter->size - blockSize; - newNode->isFree = 1; + newNode->isFree = true; newNode->magic = NODE_MAGIC; iter->next = newNode; iter->size = size; + next = newNode->next; - if (next) { + if (next != NULL) { next->prev = newNode; } } - iter->isFree = 0; - alloc = (void*)((u32)iter + sizeof(ArenaNode)); + iter->isFree = false; + alloc = (void*)((uintptr_t)iter + sizeof(ArenaNode)); break; } iter = iter->next; } + ArenaImpl_Unlock(arena); return alloc; } +/** + * Allocates at least \p size bytes of memory using the given \p arena. + * Unlike __osMalloc, the block of memory will be allocated from the end of the \p arena. + * + * - If there's not enough space in the given \p arena, this function will fail, returning `NULL`. + * - If \p size is zero, then an empty region of memory is returned. + * + * To avoid memory leaks, the returned pointer should be eventually deallocated using `__osFree` or `__osRealloc`. + * + * @param[in, out] arena The specific Arena to be used for the allocation. + * @param[in] size The size in bytes that will be allocated. + * @return void* On success, the allocated area of the \p arena memory. Otherwise, `NULL`. + */ void* __osMallocR(Arena* arena, size_t size) { ArenaNode* iter; ArenaNode* newNode; - u32 blockSize; + size_t blockSize; void* alloc = NULL; size = ALIGN16(size); + ArenaImpl_Lock(arena); + + // Start iterating from the last block of the arena. iter = ArenaImpl_GetLastBlock(arena); + // Iterate in reverse the arena looking for a big enough space of memory. while (iter != NULL) { if (iter->isFree && iter->size >= size) { - ArenaNode* next; blockSize = ALIGN16(size) + sizeof(ArenaNode); + + // If the block is larger than the requested size, then split it and just use the required size of the + // current block. if (blockSize < iter->size) { - newNode = (ArenaNode*)((u32)iter + (iter->size - size)); + ArenaNode* next; + + newNode = (ArenaNode*)((uintptr_t)iter + (iter->size - size)); newNode->next = iter->next; newNode->prev = iter; newNode->size = size; @@ -157,69 +234,171 @@ void* __osMallocR(Arena* arena, size_t size) { iter->next = newNode; iter->size -= blockSize; + next = newNode->next; - if (next) { + if (next != NULL) { next->prev = newNode; } iter = newNode; } - iter->isFree = 0; - alloc = (void*)((u32)iter + sizeof(ArenaNode)); + iter->isFree = false; + alloc = (void*)((uintptr_t)iter + sizeof(ArenaNode)); break; } iter = iter->prev; } + ArenaImpl_Unlock(arena); return alloc; } +/** + * Deallocates the pointer \p ptr previously allocated by `__osMalloc`, `__osMallocR` or `__osRealloc`. + * If \p ptr is `NULL` or it has been already been freed, then this function does nothing. + * + * - The behaviour is undefined if \p ptr is not a memory region returned by one of the cited allocating + * functions. + * - The behaviour is undefined if \p ptr doesn't correspond to the given \p arena. + * - Any access to the freed pointer is undefined behaviour. + * + * @param[in, out] arena The specific Arena to be used for the allocation. + * @param[in, out] ptr The allocated memory block to deallocate. + */ void __osFree(Arena* arena, void* ptr) { ArenaNode* node; ArenaNode* next; ArenaNode* prev; - ArenaNode* newNext; ArenaImpl_Lock(arena); - node = (ArenaNode*)((u32)ptr - sizeof(ArenaNode)); - if (ptr == NULL || (node->magic != NODE_MAGIC) || node->isFree) { - goto end; - } + node = (ArenaNode*)((uintptr_t)ptr - sizeof(ArenaNode)); - next = node->next; - prev = node->prev; - node->isFree = 1; + if (ptr != NULL && node->magic == NODE_MAGIC && !node->isFree) { + next = node->next; + prev = node->prev; + node->isFree = true; - newNext = next; - if ((u32)next == (u32)node + sizeof(ArenaNode) + node->size && next->isFree) { - newNext = next->next; - if (newNext != NULL) { - newNext->prev = node; + // Checks if the next node is contiguous to the current node and if it isn't currently allocated. Then merge the + // two nodes into one. + if ((uintptr_t)next == (uintptr_t)node + sizeof(ArenaNode) + node->size && next->isFree) { + ArenaNode* newNext = next->next; + + if (newNext != NULL) { + newNext->prev = node; + } + + node->size += next->size + sizeof(ArenaNode); + + node->next = newNext; + next = newNext; } - node->size += next->size + sizeof(ArenaNode); + // Checks if the previous node is contiguous to the current node and if it isn't currently allocated. Then merge + // the two nodes into one. + if (prev != NULL && prev->isFree && (uintptr_t)node == (uintptr_t)prev + sizeof(ArenaNode) + prev->size) { + if (next != NULL) { + next->prev = prev; + } - node->next = newNext; - next = newNext; - } - - if (prev != NULL && prev->isFree && (u32)node == (u32)prev + sizeof(ArenaNode) + prev->size) { - if (next) { - next->prev = prev; + prev->next = next; + prev->size += node->size + sizeof(ArenaNode); } - prev->next = next; - prev->size += node->size + sizeof(ArenaNode); } -end: ArenaImpl_Unlock(arena); } -#pragma GLOBAL_ASM("asm/non_matchings/boot/__osMalloc/__osRealloc.s") +/** + * Reallocates the pointer \p ptr. + * \p ptr must be either a pointer previously allocated by `__osMalloc`, `__osMallocR` or `__osRealloc` and + * not freed yet, or a `NULL` pointer. + * + * - If \p ptr is `NULL` a new pointer is allocated. See `__osMalloc` for more details. + * - If \p newSize is 0, then the given pointer is freed and `NULL` is returned. See `__osFree` for more details. + * - If \p newSize is bigger than the currently allocated allocated pointer, then the area of memory is expanded to a + * size big enough to fit the requested size. + * + * - The behaviour is undefined if \p ptr is not a memory region returned by one of the cited allocating + * functions. + * - The behaviour is undefined if \p ptr doesn't correspond to the given \p arena. + * - If the pointer is freed, then any access to the original freed pointer is undefined behaviour. + * + * @param[in, out] arena The specific Arena to be used for the allocation. + * @param[in, out] ptr The allocated memory block to deallocate. + * @param[in] newSize The new requested size. + * @return void* On success, the pointer to the reallocated area of memory. On failure, `NULL` is returned, + * and the original parameter \p ptr remains valid. + */ +void* __osRealloc(Arena* arena, void* ptr, size_t newSize) { + ArenaImpl_Lock(arena); -void __osAnalyzeArena(Arena* arena, size_t* outMaxFree, size_t* outFree, size_t* outAlloc) { + (void)"__osRealloc(%08x, %d)\n"; + + if (ptr == NULL) { + // if the `ptr` is NULL, then allocate a new pointer with the specified size + // if newSize is 0, then __osMalloc would return a NULL pointer + ptr = __osMalloc(arena, newSize); + } else if (newSize == 0) { + // if the requested size is zero, then free the pointer + __osFree(arena, ptr); + ptr = NULL; + } else { + size_t diff; + void* newPtr; + // Gets the start of the ArenaNode pointer embedded + ArenaNode* node = (void*)((uintptr_t)ptr - sizeof(ArenaNode)); + + newSize = ALIGN16(newSize); + + // Only reallocate the memory if the new size isn't smaller than the actual node size + if ((newSize != node->size) && (node->size < newSize)) { + ArenaNode* next = node->next; + + diff = newSize - node->size; + // Checks if the next node is contiguous to the current allocated node and it has enough space to fit the + // new requested size + if (((uintptr_t)next == (uintptr_t)node + node->size + sizeof(ArenaNode)) && (next->isFree) && + (next->size >= diff)) { + ArenaNode* next2 = next->next; + + next->size = (next->size - diff); + if (next2 != NULL) { + // Update the previous element of the linked list + next2->prev = (void*)((uintptr_t)next + diff); + } + + next2 = (void*)((uintptr_t)next + diff); + node->next = next2; + node->size = newSize; + __osMemcpy(next2, next, sizeof(ArenaNode)); + } else { + // Create a new pointer and manually copy the data from the old pointer to the new one + newPtr = __osMalloc(arena, newSize); + if (newPtr != NULL) { + bcopy(newPtr, ptr, node->size); + __osFree(arena, ptr); + } + ptr = newPtr; + } + } + } + + ArenaImpl_Unlock(arena); + + return ptr; +} + +/** + * Gets the size of the largest free block, the total free space and the total allocated space. + * + * @param[in, out] arena The Arena which will be used to get the values from. + * @param[out] outMaxFree The size of the largest free block. + * @param[out] outFree The total free space. + * @param[out] outAlloc The total allocated space. + */ +void __osGetSizes(Arena* arena, size_t* outMaxFree, size_t* outFree, size_t* outAlloc) { ArenaNode* iter; ArenaImpl_Lock(arena); @@ -245,4 +424,35 @@ void __osAnalyzeArena(Arena* arena, size_t* outMaxFree, size_t* outFree, size_t* ArenaImpl_Unlock(arena); } -#pragma GLOBAL_ASM("asm/non_matchings/boot/__osMalloc/__osCheckArena.s") +/** + * Checks the validity of every node of the \p arena. + * + * @param arena The Arena to check. + * @return s32 0 if every pointer is valid. 1 otherwise. + */ +s32 __osCheckArena(Arena* arena) { + ArenaNode* iter; + s32 err = 0; + + ArenaImpl_Lock(arena); + + // "Checking the contents of the arena..." + (void)"アリーナの内容をチェックしています... (%08x)\n"; + + for (iter = arena->head; iter != NULL; iter = iter->next) { + if (iter->magic != NODE_MAGIC) { + // "Oops!!" + (void)"おおっと!! (%08x %08x)\n"; + + err = 1; + break; + } + } + + // "The arena still looks good" + (void)"アリーナはまだ、いけそうです\n"; + + ArenaImpl_Unlock(arena); + + return err; +} diff --git a/src/boot_O2/boot_800862E0.c b/src/boot_O2/boot_800862E0.c index ecba8c5f54..1055dfe1b8 100644 --- a/src/boot_O2/boot_800862E0.c +++ b/src/boot_O2/boot_800862E0.c @@ -1,4 +1,5 @@ #include "global.h" +#include "os_malloc.h" #pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_MallocMin1.s") diff --git a/src/boot_O2/boot_80086760.c b/src/boot_O2/boot_80086760.c index 1a9b374538..3c75bcd3f7 100644 --- a/src/boot_O2/boot_80086760.c +++ b/src/boot_O2/boot_80086760.c @@ -24,30 +24,30 @@ f32 func_80086760(f32 x) { // Unused // Math_FFloorF f32 func_80086794(f32 x) { - func_80086C70(x); + return func_80086C70(x); } // Unused // Math_FCeilF f32 func_800867B4(f32 x) { - func_80086CA8(x); + return func_80086CA8(x); } // Unused // Math_FRoundF f32 func_800867D4(f32 x) { - func_80086D50(x); + return func_80086D50(x); } // Unused // Math_FTruncF f32 func_800867F4(f32 x) { - func_80086CE0(x); + return func_80086CE0(x); } // Math_FNearbyIntF f32 func_80086814(f32 x) { - func_80086D18(x); + return func_80086D18(x); } /** diff --git a/src/boot_O2/loadfragment.c b/src/boot_O2/loadfragment.c index 4589cd3590..968fb464ab 100644 --- a/src/boot_O2/loadfragment.c +++ b/src/boot_O2/loadfragment.c @@ -1,4 +1,5 @@ #include "global.h" +#include "system_malloc.h" #pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment/Load_Relocate.s") diff --git a/src/boot_O2/loadfragment2.c b/src/boot_O2/loadfragment2.c index 5c884be962..c324b80d5c 100644 --- a/src/boot_O2/loadfragment2.c +++ b/src/boot_O2/loadfragment2.c @@ -1,4 +1,5 @@ #include "global.h" +#include "system_malloc.h" UNK_TYPE4 D_80096C30 = 2; diff --git a/src/boot_O2/system_malloc.c b/src/boot_O2/system_malloc.c index ad2bb63458..56608166cb 100644 --- a/src/boot_O2/system_malloc.c +++ b/src/boot_O2/system_malloc.c @@ -1,4 +1,5 @@ #include "global.h" +#include "os_malloc.h" Arena gSystemArena; @@ -29,8 +30,8 @@ void* SystemArena_Calloc(u32 elements, size_t size) { return ptr; } -void SystemArena_AnalyzeArena(size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated) { - __osAnalyzeArena(&gSystemArena, maxFreeBlock, bytesFree, bytesAllocated); +void SystemArena_GetSizes(size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated) { + __osGetSizes(&gSystemArena, maxFreeBlock, bytesFree, bytesAllocated); } u32 SystemArena_CheckArena(void) { diff --git a/src/boot_O2_g3/yaz0.c b/src/boot_O2_g3/yaz0.c index 094c0bb381..5fb32b8eaa 100644 --- a/src/boot_O2_g3/yaz0.c +++ b/src/boot_O2_g3/yaz0.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u8 sYaz0DataBuffer[0x400]; diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index ebf3909249..190536b21e 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u32 sDmaMgrDmaBuffSize = 0x2000; diff --git a/src/buffers/gfxyield.c b/src/buffers/gfxyield.c index 73810d4acd..94a5f55c97 100644 --- a/src/buffers/gfxyield.c +++ b/src/buffers/gfxyield.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; diff --git a/src/code/audio/audio_dcache.c b/src/code/audio/audio_dcache.c new file mode 100644 index 0000000000..27f019fef9 --- /dev/null +++ b/src/code/audio/audio_dcache.c @@ -0,0 +1,15 @@ +#include "global.h" + +void Audio_InvalDCache(void* buf, size_t size) { + OSIntMask prevMask = osSetIntMask(1); + + osInvalDCache(buf, size); + osSetIntMask(prevMask); +} + +void Audio_WritebackDCache(void* buf, size_t size) { + OSIntMask prevMask = osSetIntMask(1); + + osWritebackDCache(buf, size); + osSetIntMask(prevMask); +} diff --git a/src/code/audio/code_80194710.c b/src/code/audio/code_80194710.c deleted file mode 100644 index 090c5735b1..0000000000 --- a/src/code/audio/code_80194710.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194710.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194750.s") diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index 9354af1887..5d0a166a28 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -134,7 +134,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019F170.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019F1C0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_PlaySfxAtPos.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019F208.s") diff --git a/src/code/audio/code_801A5BD0.c b/src/code/audio/code_801A5BD0.c index 32889dcb83..7d796aa9fc 100644 --- a/src/code/audio/code_801A5BD0.c +++ b/src/code/audio/code_801A5BD0.c @@ -6,7 +6,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5C8C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5CFC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/Audio_PlaySfxGeneral.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5DDC.s") @@ -24,7 +24,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A7284.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A72CC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/Audio_StopSfxByPos.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A7328.s") diff --git a/src/code/code_800F0390.c b/src/code/code_800F0390.c deleted file mode 100644 index f495cfe5ea..0000000000 --- a/src/code/code_800F0390.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F0390/func_800F0390.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F0390/func_800F03C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F0390/func_800F048C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F0390/Audio_PlaySoundAtPosition.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F0390/func_800F0590.s") diff --git a/src/code/game.c b/src/code/game.c index e431fafdaf..2713be2990 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -1,4 +1,5 @@ #include "global.h" +#include "system_malloc.h" s32 gFramerateDivisor = 1; f32 gFramerateDivisorF = 1.0f; @@ -174,7 +175,7 @@ void GameState_Realloc(GameState* gameState, size_t size) { alloc = &gameState->alloc; THA_Dt(&gameState->heap); GameAlloc_Free(alloc, heapStart); - SystemArena_AnalyzeArena(&systemMaxFree, &bytesFree, &bytesAllocated); + SystemArena_GetSizes(&systemMaxFree, &bytesFree, &bytesAllocated); size = ((systemMaxFree - (sizeof(ArenaNode))) < size) ? (0) : (size); if (size == 0) { size = systemMaxFree - (sizeof(ArenaNode)); diff --git a/src/code/gamealloc.c b/src/code/gamealloc.c index 541f9125b0..6067ad91c4 100644 --- a/src/code/gamealloc.c +++ b/src/code/gamealloc.c @@ -1,4 +1,5 @@ #include "global.h" +#include "system_malloc.h" void GameAlloc_Log(GameAlloc* this) { GameAllocEntry* iter; diff --git a/src/code/graph.c b/src/code/graph.c index 7ef1715fd9..8059d1f63a 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -1,5 +1,6 @@ #include "prevent_bss_reordering.h" #include "global.h" +#include "system_malloc.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" #include "overlays/gamestates/ovl_file_choose/z_file_choose.h" #include "overlays/gamestates/ovl_opening/z_opening.h" @@ -88,33 +89,27 @@ GameStateOverlay* Graph_GetNextGameState(GameState* gameState) { return NULL; } -#ifdef NON_MATCHING -// Regalloc differences void* Graph_FaultAddrConvFunc(void* address, void* param) { - u32 addr = address; - GameStateOverlay* gamestateOvl; - u32 ramConv; - u32 ramStart; - u32 diff; + uintptr_t addr = address; + GameStateOverlay* gamestateOvl = &gGameStateOverlayTable[0]; + uintptr_t ramConv; + void* ramStart; + uintptr_t diff; s32 i; - for (i = 0; i < graphNumGameStates; i++) { - gamestateOvl = &gGameStateOverlayTable[i]; + for (i = 0; i < graphNumGameStates; i++, gamestateOvl++) { + diff = VRAM_PTR_SIZE(gamestateOvl); ramStart = gamestateOvl->loadedRamAddr; - diff = (u32)gamestateOvl->vramEnd - (u32)gamestateOvl->vramStart; - ramConv = (u32)gamestateOvl->vramStart - ramStart; + ramConv = (uintptr_t)gamestateOvl->vramStart - (uintptr_t)ramStart; - if (gamestateOvl->loadedRamAddr != NULL) { - if (addr >= ramStart && addr < ramStart + diff) { + if (ramStart != NULL) { + if (addr >= (uintptr_t)ramStart && addr < (uintptr_t)ramStart + diff) { return addr + ramConv; } } } return NULL; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_FaultAddrConvFunc.s") -#endif void Graph_Init(GraphicsContext* gfxCtx) { bzero(gfxCtx, sizeof(GraphicsContext)); diff --git a/src/code/listalloc.c b/src/code/listalloc.c index da294a1091..33f9989ba1 100644 --- a/src/code/listalloc.c +++ b/src/code/listalloc.c @@ -1,4 +1,5 @@ #include "global.h" +#include "system_malloc.h" ListAlloc* ListAlloc_Init(ListAlloc* this) { this->prev = NULL; diff --git a/src/code/sched.c b/src/code/sched.c index 927a48f66b..5f9cdf236a 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #define RSP_DONE_MSG 667 diff --git a/src/code/speed_meter.c b/src/code/speed_meter.c index b8b0299eba..9f04de110c 100644 --- a/src/code/speed_meter.c +++ b/src/code/speed_meter.c @@ -1,4 +1,5 @@ #include "global.h" +#include "system_malloc.h" #pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/func_80177390.s") diff --git a/src/code/sys_cmpdma.c b/src/code/sys_cmpdma.c index c670645fc2..2533c44f5e 100644 --- a/src/code/sys_cmpdma.c +++ b/src/code/sys_cmpdma.c @@ -1,4 +1,5 @@ #include "global.h" +#include "system_malloc.h" #pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178750.s") diff --git a/src/code/sys_flashrom.c b/src/code/sys_flashrom.c index 1431e7a666..8b6c2fa5cc 100644 --- a/src/code/sys_flashrom.c +++ b/src/code/sys_flashrom.c @@ -1,4 +1,5 @@ #include "global.h" +#include "system_malloc.h" #pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_801857C0.s") diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index 50fd1211ec..d676a437cf 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -138,7 +138,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_IsPointInSphere.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D668.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_PointDistToLine2D.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D7C0.s") diff --git a/src/code/z_DLF.c b/src/code/z_DLF.c index 688a5af159..4c57aca014 100644 --- a/src/code/z_DLF.c +++ b/src/code/z_DLF.c @@ -1,4 +1,5 @@ #include "global.h" +#include "system_malloc.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/Overlay_LoadGameState.s") diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 42f67987a1..80e4ed697e 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1,7 +1,44 @@ +/* + * File: z_actor.c + * Description: + */ + #include "global.h" +#include "overlays/actors/ovl_En_Horse/z_en_horse.h" +#include "overlays/actors/ovl_En_Part/z_en_part.h" +#include "overlays/actors/ovl_En_Box/z_en_box.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "objects/object_bdoor/object_bdoor.h" + +// bss +extern FaultClient sActorFaultClient; // 2 funcs +extern CollisionPoly* D_801ED8B0; // 1 func +extern s32 D_801ED8B4; // 2 funcs +extern Actor* D_801ED8B8; // 2 funcs +extern Actor* D_801ED8BC; // 2 funcs +extern Actor* D_801ED8C0; // 2 funcs +extern Actor* D_801ED8C4; // 2 funcs +extern f32 D_801ED8C8; // 2 funcs +extern f32 sBgmEnemyDistSq; // 2 funcs +extern f32 D_801ED8D0; // 2 funcs +extern s32 D_801ED8D4; // 2 funcs +extern s32 D_801ED8D8; // 2 funcs +extern s16 D_801ED8DC; // 2 funcs +extern Mtx D_801ED8E0; // 1 func +extern Actor* D_801ED920; // 2 funcs. 1 out of z_actor + +// Internal forward declarations +void func_800BA8B8(GlobalContext* globalCtx, ActorContext* actorCtx); +Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, GlobalContext* globalCtx); +Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalCtx); +void func_800BB8EC(GameState* gameState, ActorContext* actorCtx, Actor** arg2, Actor** arg3, Player* player); +s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* projectedPos, f32 projectedW); +void Actor_AddToCategory(ActorContext* actorCtx, Actor* actor, u8 actorCategory); +Actor* Actor_RemoveFromCategory(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actorToRemove); void Actor_PrintLists(ActorContext* actorCtx) { - ActorListEntry* actorList = &actorCtx->actorList[0]; + ActorListEntry* actorList = &actorCtx->actorLists[0]; Actor* actor; s32 i; @@ -9,7 +46,7 @@ void Actor_PrintLists(ActorContext* actorCtx) { FaultDrawer_Printf("actor\n", gMaxActorId); FaultDrawer_Printf("No. Actor Name Part SegName\n"); - for (i = 0; i < ARRAY_COUNT(actorCtx->actorList); i++) { + for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { actor = actorList[i].first; while (actor != NULL) { @@ -26,7 +63,6 @@ void ActorShape_Init(ActorShape* actorShape, f32 yOffset, ActorShadowFunc shadow actorShape->shadowAlpha = 255; } -#ifdef NON_MATCHING void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gfx* dlist, Color_RGBA8* color) { if (actor->floorPoly != NULL) { f32 dy = actor->world.pos.y - actor->floorHeight; @@ -43,7 +79,10 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf COMBINED); dy = CLAMP(dy, 0.0f, 150.0f); - shadowScale = 1.0f - (dy * 0.0028571428f); + shadowScale = 1.0f - (dy * (1.0f / 350.0f)); + if ((dy * (1.0f / 350.0f)) > 1.0f) { + shadowScale = 0.0f; + } if (color != NULL) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, color->r, color->g, color->b, @@ -55,13 +94,12 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf func_800C0094(actor->floorPoly, actor->world.pos.x, actor->floorHeight, actor->world.pos.z, &mtx); Matrix_SetCurrentState(&mtx); - if (dlist != D_04076BC0) { - Matrix_RotateY((f32)actor->shape.rot.y * (M_PI / 32768), MTXMODE_APPLY); + if ((dlist != gCircleShadowDL) || (actor->scale.x != actor->scale.z)) { + Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); } - shadowScale = 1.0f - (dy * 0.0028571428f); shadowScale *= actor->shape.shadowScale; - Matrix_Scale(shadowScale * actor->scale.x, 1.0f, shadowScale * actor->scale.z, MTXMODE_APPLY); + Matrix_Scale(actor->scale.x * shadowScale, 1.0f, actor->scale.z * shadowScale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, dlist); @@ -70,244 +108,949 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/ActorShadow_Draw.s") -#endif -/* ActorShadow_DrawCircle */ -void func_800B3FC0(Actor* actor, Lights* lights, GlobalContext* globalCtx) { +void ActorShadow_DrawCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx) { if (actor->bgCheckFlags & 0x400) { func_800B4AEC(globalCtx, actor, 50.0f); } - ActorShadow_Draw(actor, lights, globalCtx, D_04076BC0, NULL); + ActorShadow_Draw(actor, lights, globalCtx, gCircleShadowDL, NULL); } -/* ActorShadow_DrawSquare */ -void func_800B4024(Actor* actor, Lights* lights, GlobalContext* globalCtx) { +void ActorShadow_DrawSquare(Actor* actor, Lights* lights, GlobalContext* globalCtx) { if (actor->bgCheckFlags & 0x400) { func_800B4AEC(globalCtx, actor, 50.0f); } - ActorShadow_Draw(actor, lights, globalCtx, D_04075A40, NULL); + ActorShadow_Draw(actor, lights, globalCtx, gSquareShadowDL, NULL); } -/* ActorShadow_DrawWhiteCircle */ -void func_800B4088(Actor* actor, Lights* lights, GlobalContext* globalCtx) { - ActorShadow_Draw(actor, lights, globalCtx, D_04076BC0, &D_801AEC80); +void ActorShadow_DrawWhiteCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx) { + static Color_RGBA8 color = { 255, 255, 255, 255 }; + + ActorShadow_Draw(actor, lights, globalCtx, gCircleShadowDL, &color); } -/* ActorShadow_DrawHorse */ -void func_800B40B8(Actor* actor, Lights* lights, GlobalContext* globalCtx) { - ActorShadow_Draw(actor, lights, globalCtx, D_04077480, NULL); +void ActorShadow_DrawHorse(Actor* actor, Lights* lights, GlobalContext* globalCtx) { + ActorShadow_Draw(actor, lights, globalCtx, gHorseShadowDL, NULL); } -/* ActorShadow_DrawFoot */ -#ifdef NON_MATCHING -void func_800B40E0(GlobalContext* globalCtx, Light* light, MtxF* arg2, s32 arg3, f32 arg4, f32 arg5, f32 arg6) { - s32 pad1; +void ActorShadow_DrawFoot(GlobalContext* globalCtx, Light* light, MtxF* arg2, s32 lightNum, f32 shadowAlpha, + f32 shadowScaleX, f32 shadowScaleZ) { + s32 pad; s16 sp58; - s32 pad2[2]; + f32 dir2; + f32 dir0; OPEN_DISPS(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, - (u32)(((arg3 * 1.3e-05f) > 1.0f ? 1.0f : (arg3 * 1.3e-05f)) * arg4) & 0xFF); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u8)(CLAMP_MAX(lightNum * 1.3e-05f, 1.0f) * shadowAlpha)); - sp58 = Math_FAtan2F(light->l.dir[0], light->l.dir[2]); - arg6 *= (4.5f - (light->l.dir[1] * 0.035f)); - arg6 = (arg6 < 1.0f) ? 1.0f : arg6; + dir0 = light->l.dir[0]; + dir2 = light->l.dir[2]; + sp58 = Math_FAtan2F(dir2, dir0); + shadowScaleZ *= (4.5f - (light->l.dir[1] * 0.035f)); + shadowScaleZ = CLAMP_MIN(shadowScaleZ, 1.0f); Matrix_SetCurrentState(arg2); Matrix_RotateY(sp58, MTXMODE_APPLY); - Matrix_Scale(arg5, 1.0f, arg5 * arg6, MTXMODE_APPLY); + Matrix_Scale(shadowScaleX, 1.0f, shadowScaleX * shadowScaleZ, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); - gSPDisplayList(POLY_OPA_DISP++, D_04075B30); + gSPDisplayList(POLY_OPA_DISP++, gFootShadowDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B40E0.s") -#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B42F8.s") +void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx) { + f32 distToFloor = actor->world.pos.y - actor->floorHeight; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B4A98.s") + if (distToFloor > 0.0f) { + f32 shadowScale = actor->shape.shadowScale; + u8 shadowAlpha = actor->shape.shadowAlpha; + f32 alphaRatio; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B4AEC.s") + if ((actor->id == ACTOR_PLAYER) && (((Player*)actor)->stateFlags3 & 0x8000)) { + f32 tmpScaleZ = actor->scale.z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B4B50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B4EDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B4F40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B4F78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B5040.s") - -void Actor_TargetContextInit(TargetContext* targetCtx, Actor* actor, GlobalContext* globalCtx) { - targetCtx->unk90 = NULL; - targetCtx->unk8C = NULL; - targetCtx->unk3C = NULL; - targetCtx->unk38 = NULL; - targetCtx->unk4B = 0; - targetCtx->unk4C = 0; - targetCtx->unk40 = 0; - func_800B5040(targetCtx, actor, actor->category, globalCtx); - func_800B4F78(targetCtx, actor->category, globalCtx); -} - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B5208.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B5814.s") - -u32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag) { - if (flag >= 0 && flag < 0x80) { - return globalCtx->actorCtx.switchFlags[(flag & -0x20) >> 5] & (1 << (flag & 0x1F)); - } - return 0; -} - -void Actor_SetSwitchFlag(GlobalContext* globalCtx, s32 flag) { - if (flag >= 0 && flag < 0x80) { - globalCtx->actorCtx.switchFlags[(flag & -0x20) >> 5] |= 1 << (flag & 0x1F); - } -} - -void Actor_UnsetSwitchFlag(GlobalContext* globalCtx, s32 flag) { - if (flag >= 0 && flag < 0x80) { - globalCtx->actorCtx.switchFlags[(flag & -0x20) >> 5] &= ~(1 << (flag & 0x1F)); - } -} - -u32 Actor_GetChestFlag(GlobalContext* globalCtx, u32 flag) { - return globalCtx->actorCtx.chestFlags & (1 << flag); -} - -void Actor_SetChestFlag(GlobalContext* globalCtx, u32 flag) { - globalCtx->actorCtx.chestFlags |= (1 << flag); -} - -void Actor_SetAllChestFlag(GlobalContext* globalCtx, u32 flag) { - globalCtx->actorCtx.chestFlags = flag; -} - -u32 Actor_GetAllChestFlag(GlobalContext* globalCtx) { - return globalCtx->actorCtx.chestFlags; -} - -u32 Actor_GetRoomCleared(GlobalContext* globalCtx, u32 roomNumber) { - return globalCtx->actorCtx.clearedRooms & (1 << roomNumber); -} - -void Actor_SetRoomCleared(GlobalContext* globalCtx, u32 roomNumber) { - globalCtx->actorCtx.clearedRooms |= (1 << roomNumber); -} - -void Actor_UnsetRoomCleared(GlobalContext* globalCtx, u32 roomNumber) { - globalCtx->actorCtx.clearedRooms &= ~(1 << roomNumber); -} - -u32 Actor_GetRoomClearedTemp(GlobalContext* globalCtx, u32 roomNumber) { - return globalCtx->actorCtx.clearedRoomsTemp & (1 << roomNumber); -} - -void Actor_SetRoomClearedTemp(GlobalContext* globalCtx, u32 roomNumber) { - globalCtx->actorCtx.clearedRoomsTemp |= (1 << roomNumber); -} - -void Actor_UnsetRoomClearedTemp(GlobalContext* globalCtx, u32 roomNumber) { - globalCtx->actorCtx.clearedRoomsTemp &= ~(1 << roomNumber); -} - -u32 Actor_GetCollectibleFlag(GlobalContext* globalCtx, s32 index) { - if (index > 0 && index < 0x80) { - return globalCtx->actorCtx.collectibleFlags[(index & -0x20) >> 5] & (1 << (index & 0x1F)); - } - return 0; -} - -void Actor_SetCollectibleFlag(GlobalContext* globalCtx, s32 index) { - if (index > 0 && index < 0x80) { - globalCtx->actorCtx.collectibleFlags[(index & -0x20) >> 5] |= 1 << (index & 0x1F); - } -} - -void Actor_TitleCardContextInit(GlobalContext* globalCtx, TitleCardContext* titleCardCtx) { - titleCardCtx->fadeOutDelay = 0; - titleCardCtx->fadeInDelay = 0; - titleCardCtx->color = 0; - titleCardCtx->alpha = 0; -} - -void Actor_TitleCardCreate(GlobalContext* globalCtx, TitleCardContext* titleCardCtx, u32 texture, s16 param_4, - s16 param_5, u8 param_6, u8 param_7) { - titleCardCtx->texture = texture; - titleCardCtx->unk4 = param_4; - titleCardCtx->unk6 = param_5; - titleCardCtx->unk8 = param_6; - titleCardCtx->unk9 = param_7; - titleCardCtx->fadeOutDelay = 80; - titleCardCtx->fadeInDelay = 0; -} - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_Nop800B5E50.s") - -void Actor_TitleCardUpdate(GlobalContext* globalCtx, TitleCardContext* titleCardCtx) { - if (DECR(titleCardCtx->fadeInDelay) == 0) { - if (DECR(titleCardCtx->fadeOutDelay) == 0) { - Math_StepToS(&titleCardCtx->alpha, 0, 30); - Math_StepToS(&titleCardCtx->color, 0, 70); + actor->scale.z += 0.03f * fabsf(Math_CosS(((Player*)actor)->unk_AAA)); + actor->shape.shadowScale *= 0.2f; + alphaRatio = distToFloor * 0.03f; + actor->shape.shadowAlpha = actor->shape.shadowAlpha * CLAMP_MAX(alphaRatio, 1.0f); + ActorShadow_Draw(actor, mapper, globalCtx, gCircleShadowDL, NULL); + actor->scale.z = tmpScaleZ; } else { - Math_StepToS(&titleCardCtx->alpha, 255, 10); - Math_StepToS(&titleCardCtx->color, 255, 20); + actor->shape.shadowScale *= 0.3f; + alphaRatio = (distToFloor - 20.0f) * 0.02f; + actor->shape.shadowAlpha = actor->shape.shadowAlpha * CLAMP_MAX(alphaRatio, 1.0f); + ActorShadow_DrawCircle(actor, mapper, globalCtx); + } + + actor->shape.shadowScale = shadowScale; + actor->shape.shadowAlpha = shadowAlpha; + } + + if (distToFloor < 200.0f) { + MtxF sp13C; + MtxF spFC; + CollisionPoly* spF8; + s32 bgId; + f32 floorHeight[2]; + f32 pad; + f32 shadowAlpha; + f32 shadowScaleX; + f32 shadowScaleZ; + Light* lightPtr; + s32 lightNumMax; + s32 i; + s32 j; + s32 lightNum; + Vec3f* feetPosPtr; + s32 numLights; + f32* floorHeightPtr; + s32 spB8; + + numLights = mapper->numLights - 2; + feetPosPtr = actor->shape.feetPos; + floorHeightPtr = floorHeight; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); + actor->shape.feetFloorFlags = 0; + spB8 = 2; + + for (i = 0; i < ARRAY_COUNT(floorHeight); i++, spB8 >>= 1) { + feetPosPtr->y += 50.0f; + *floorHeightPtr = func_80169100(globalCtx, &sp13C, &spF8, &bgId, feetPosPtr); + feetPosPtr->y -= 50.0f; + + distToFloor = feetPosPtr->y - *floorHeightPtr; + if ((distToFloor >= -1.0f) && (distToFloor < 500.0f)) { + lightNumMax = 0; + + if (distToFloor <= 10.0f) { + actor->shape.feetFloorFlags |= spB8; + + if ((actor->depthInWater < 0.0f) && (bgId == 0x32) && ((actor->shape.unk_17 & spB8) != 0)) { + if (func_800C9C24(&globalCtx->colCtx, spF8, bgId, 1) != 0) { + SkinMatrix_MtxFCopy(&sp13C, &spFC); + SkinMatrix_MulYRotation(&spFC, actor->shape.rot.y); + EffFootmark_Add(globalCtx, &spFC, actor, i, feetPosPtr, (actor->shape.shadowScale * 0.3f), + IREG(88) + 80, IREG(89) + 60, IREG(90) + 40, 30000, 200, 60); + } + actor->shape.unk_17 &= ~spB8; + + if (!mapper->l.l) {} // POSSIBLE FAKE MATCH + } + } + + if (distToFloor > 30.0f) { + distToFloor = 30.0f; + } + + shadowAlpha = actor->shape.shadowAlpha * (1.0f - (distToFloor * (1 / 30.0f))); + shadowScaleZ = 1.0f - (distToFloor * (1.0f / 70.0f)); + shadowScaleX = actor->shape.shadowScale * shadowScaleZ * actor->scale.x; + + for (lightPtr = mapper->l.l, j = 0; j < numLights; lightPtr++, j++) { + if (lightPtr->l.dir[1] > 0) { + lightNum = (lightPtr->l.col[0] + lightPtr->l.col[1] + lightPtr->l.col[2]) * + ABS_ALT(lightPtr->l.dir[1]); + + if (lightNum > 0) { + lightNumMax += lightNum; + ActorShadow_DrawFoot(globalCtx, lightPtr, &sp13C, lightNum, shadowAlpha, shadowScaleX, + shadowScaleZ); + } + } + } + + for (j = 0; j < 2; lightPtr++, j++) { + if (lightPtr->l.dir[1] > 0) { + lightNum = ((lightPtr->l.col[0] + lightPtr->l.col[1] + lightPtr->l.col[2]) * + ABS_ALT(lightPtr->l.dir[1])) - + (lightNumMax * 8); + if (lightNum > 0) { + ActorShadow_DrawFoot(globalCtx, lightPtr, &sp13C, lightNum, shadowAlpha, shadowScaleX, + shadowScaleZ); + } + } + } + } + feetPosPtr++; + floorHeightPtr++; + } + + if (!(actor->bgCheckFlags & 1)) { + actor->shape.feetFloorFlags = 0; + } else if (actor->shape.feetFloorFlags == 3) { + f32 footDistY = actor->shape.feetPos[FOOT_LEFT].y - actor->shape.feetPos[FOOT_RIGHT].y; + + if ((floorHeight[0] + footDistY) < (floorHeight[1] - footDistY)) { + actor->shape.feetFloorFlags = 2; + } else { + actor->shape.feetFloorFlags = 1; + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* leftFootPos, s32 rightFootIndex, + Vec3f* rightFootPos) { + if (limbIndex == leftFootIndex) { + Matrix_MultiplyVector3fByState(leftFootPos, &actor->shape.feetPos[FOOT_LEFT]); + } else if (limbIndex == rightFootIndex) { + Matrix_MultiplyVector3fByState(rightFootPos, &actor->shape.feetPos[FOOT_RIGHT]); + } +} + +void func_800B4AEC(GlobalContext* globalCtx, Actor* actor, f32 y) { + s32 floorBgId; + f32 yPos = actor->world.pos.y; + + actor->world.pos.y += y; + actor->floorHeight = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &floorBgId, + actor, &actor->world.pos); + actor->floorBgId = floorBgId; + actor->world.pos.y = yPos; +} + +void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx) { + f32 spEC; + f32 temp_f12; + f32 temp_f20; + f32 shadowScaleZ; + f32 temp_f22; + f32 temp_f24; + f32 temp_f8; + MtxF sp94; + s32 lightNum; + s32 numLights; + s8 phi_v1; + u8 temp_v0; + Light* phi_s0; + s32 lightNumMax; + + if (actor->bgCheckFlags & 0x400) { + func_800B4AEC(globalCtx, actor, 50.0f); + } + + if (actor->floorPoly != NULL) { + s32 j; + + spEC = actor->world.pos.y - actor->floorHeight; + if (spEC > 20.0f) { + temp_f20 = actor->shape.shadowScale; + temp_v0 = actor->shape.shadowAlpha; + actor->shape.shadowScale *= 0.3f; + temp_f12 = (spEC - 20.0f) * 0.02f; + actor->shape.shadowAlpha = CLAMP_MAX(temp_f12, 1.0f) * actor->shape.shadowAlpha; + ActorShadow_DrawCircle(actor, mapper, globalCtx); + actor->shape.shadowScale = temp_f20; + actor->shape.shadowAlpha = temp_v0; + dummy_label_111649:; + } else if (spEC >= -1.0f) { + numLights = mapper->numLights - 2; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); + + func_800C0094(actor->floorPoly, actor->world.pos.x, actor->floorHeight, actor->world.pos.z, &sp94); + temp_f22 = (f32)actor->shape.shadowAlpha * (1.0f - (spEC * (1.0f / 30.0f))); + phi_s0 = mapper->l.l; + shadowScaleZ = 1.0f - (spEC * (1.0f / 70.0f)); + temp_f24 = actor->shape.shadowScale * shadowScaleZ * actor->scale.x; + + lightNumMax = 0; + for (j = 0; j < numLights; j++, phi_s0++) { + if (phi_s0->l.dir[1] > 0) { + lightNum = (phi_s0->l.col[0] + phi_s0->l.col[1] + phi_s0->l.col[2]) * ABS_ALT(phi_s0->l.dir[1]); + if (lightNum > 0) { + lightNumMax += lightNum; + ActorShadow_DrawFoot(globalCtx, phi_s0, &sp94, lightNum, temp_f22, temp_f24, shadowScaleZ); + } + } + } + + for (j = 0; j < 2; j++, phi_s0++) { + if (phi_s0->l.dir[1] > 0) { + lightNum = (ABS_ALT(phi_s0->l.dir[1]) * (phi_s0->l.col[0] + phi_s0->l.col[1] + phi_s0->l.col[2])) - + (lightNumMax * ((void)0, 8)); + if (lightNum > 0) { + ActorShadow_DrawFoot(globalCtx, phi_s0, &sp94, lightNum, temp_f22, temp_f24, shadowScaleZ); + } + } + } + CLOSE_DISPS(globalCtx->state.gfxCtx); } } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_TitleCardDraw.s") +void Actor_GetProjectedPos(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, arg2, arg3); + if (*arg3 < 1.0f) { + *arg3 = 1.0f; + } else { + *arg3 = 1.0f / *arg3; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6434.s") +void Target_SetPos(TargetContext* targetCtx, s32 index, f32 x, f32 y, f32 z) { + targetCtx->unk50[index].pos.x = x; + targetCtx->unk50[index].pos.y = y; + targetCtx->unk50[index].pos.z = z; + targetCtx->unk50[index].unkC = targetCtx->unk44; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6468.s") +typedef struct { + /* 0x0 */ Color_RGBA8 inner; + /* 0x4 */ Color_RGBA8 outer; +} TatlColor; // size = 0x8 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6474.s") +TatlColor sTatlColorList[] = { + { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, + { { 255, 255, 230, 255 }, { 220, 160, 80, 0 } }, { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, + { { 150, 150, 255, 255 }, { 150, 150, 255, 0 } }, { { 255, 255, 0, 255 }, { 200, 155, 0, 0 } }, + { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, + { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, { { 255, 255, 0, 255 }, { 200, 155, 0, 0 } }, + { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, + { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } } +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B648C.s") +void func_800B4F78(TargetContext* targetCtx, s32 type, GlobalContext* globalCtx) { + TatlColor* tatlColorEntry; + s32 i; + TargetContextEntry* targetEntry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B64FC.s") + Math_Vec3f_Copy(&targetCtx->targetCenterPos, &globalCtx->view.eye); + targetCtx->unk48 = 0x100; + tatlColorEntry = &sTatlColorList[type]; + targetCtx->unk44 = 500.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6584.s") + targetEntry = targetCtx->unk50; + for (i = 0; i < ARRAY_COUNT(targetCtx->unk50); i++, targetEntry++) { + Target_SetPos(targetCtx, i, 0.0f, 0.0f, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6608.s") + targetEntry->color.r = tatlColorEntry->inner.r; + targetEntry->color.g = tatlColorEntry->inner.g; + targetEntry->color.b = tatlColorEntry->inner.b; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6680.s") +void Target_SetColors(TargetContext* targetCtx, Actor* actor, s32 type, GlobalContext* globalCtx) { + targetCtx->unk0.x = actor->focus.pos.x; + targetCtx->unk0.y = actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y); + targetCtx->unk0.z = actor->focus.pos.z; + + targetCtx->fairyInner.r = sTatlColorList[type].inner.r; + targetCtx->fairyInner.g = sTatlColorList[type].inner.g; + targetCtx->fairyInner.b = sTatlColorList[type].inner.b; + targetCtx->fairyInner.a = sTatlColorList[type].inner.a; + targetCtx->fairyOuter.r = sTatlColorList[type].outer.r; + targetCtx->fairyOuter.g = sTatlColorList[type].outer.g; + targetCtx->fairyOuter.b = sTatlColorList[type].outer.b; + targetCtx->fairyOuter.a = sTatlColorList[type].outer.a; +} + +void Actor_TargetContextInit(TargetContext* targetCtx, Actor* actor, GlobalContext* globalCtx) { + targetCtx->bgmEnemy = NULL; + targetCtx->unk8C = NULL; + targetCtx->targetedActor = NULL; + targetCtx->arrowPointedActor = NULL; + targetCtx->unk4B = 0; + targetCtx->unk4C = 0; + targetCtx->unk40 = 0.0f; + Target_SetColors(targetCtx, actor, actor->category, globalCtx); + func_800B4F78(targetCtx, actor->category, globalCtx); +} + +void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!(player->stateFlags1 & 0x300006C2)) { + Actor* actor = targetCtx->targetedActor; + + OPEN_DISPS(globalCtx->state.gfxCtx); + if (targetCtx->unk48 != 0) { + TargetContextEntry* entry; + s16 alpha = 255; + f32 var1 = 1.0f; + Vec3f spBC; + s32 spB8; + f32 spB4; + s32 spB0; + s32 spAC; + f32 var2; + s32 i; + + if (targetCtx->unk4B != 0) { + spB8 = 1; + } else { + spB8 = 3; + } + + if (actor != NULL) { + Math_Vec3f_Copy(&targetCtx->targetCenterPos, &actor->focus.pos); + var1 = (500.0f - targetCtx->unk44) / 420.0f; + } else { + targetCtx->unk48 -= 120; + if (targetCtx->unk48 < 0) { + targetCtx->unk48 = 0; + } + alpha = targetCtx->unk48; + } + + Actor_GetProjectedPos(globalCtx, &targetCtx->targetCenterPos, &spBC, &spB4); + + spBC.x = (160 * (spBC.x * spB4)) * var1; + spBC.x = CLAMP(spBC.x, -320.0f, 320.0f); + + spBC.y = (120 * (spBC.y * spB4)) * var1; + spBC.y = CLAMP(spBC.y, -240.0f, 240.0f); + + spBC.z = spBC.z * var1; + + targetCtx->unk4C--; + if (targetCtx->unk4C < 0) { + targetCtx->unk4C = 2; + } + + Target_SetPos(targetCtx, targetCtx->unk4C, spBC.x, spBC.y, spBC.z); + + if ((!(player->stateFlags1 & 0x40)) || (actor != player->unk_730)) { + OVERLAY_DISP = Gfx_CallSetupDL(OVERLAY_DISP, 0x39); + + for (spB0 = 0, spAC = targetCtx->unk4C; spB0 < spB8; spB0++, spAC = (spAC + 1) % 3) { + entry = &targetCtx->unk50[spAC]; + + if (entry->unkC < 500.0f) { + if (entry->unkC <= 120.0f) { + var2 = 0.15f; + } else { + var2 = ((entry->unkC - 120.0f) * 0.001f) + 0.15f; + } + + Matrix_InsertTranslation(entry->pos.x, entry->pos.y, 0.0f, MTXMODE_NEW); + Matrix_Scale(var2, 0.15f, 1.0f, MTXMODE_APPLY); + + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, entry->color.r, entry->color.g, entry->color.b, + (u8)alpha); + + Matrix_InsertZRotation_s((targetCtx->unk4B * 512), MTXMODE_APPLY); + + for (i = 0; i < 4; i++) { + Matrix_InsertZRotation_s(0x4000, MTXMODE_APPLY); + Matrix_StatePush(); + Matrix_InsertTranslation(entry->unkC, entry->unkC, 0.0f, MTXMODE_APPLY); + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(OVERLAY_DISP++, gZTargetLockOnTriangleDL); + Matrix_StatePop(); + } + } + + alpha -= 255 / 3; + if (alpha < 0) { + alpha = 0; + } + } + } + } + + actor = targetCtx->unk_94; + if ((actor != NULL) && !(actor->flags & ACTOR_FLAG_8000000)) { + TatlColor* color = &sTatlColorList[actor->category]; + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x07); + + Matrix_InsertTranslation(actor->focus.pos.x, + actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y) + 17.0f, + actor->focus.pos.z, MTXMODE_NEW); + Matrix_RotateY((globalCtx->gameplayFrames * 3000), MTXMODE_APPLY); + Matrix_Scale((iREG(27) + 35) / 1000.0f, (iREG(28) + 60) / 1000.0f, (iREG(29) + 50) / 1000.0f, + MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, color->inner.r, color->inner.g, color->inner.b, 255); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(POLY_XLU_DISP++, gZTargetArrowDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +// OoT: func_8002C7BC +void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + Actor* sp68 = NULL; + s32 category; + Vec3f sp58; + f32 sp54; + + if ((player->unk_730 != 0) && (player->unk_AE3[player->unk_ADE] == 2)) { + targetCtx->unk_94 = NULL; + } else { + func_800BB8EC(gameState, &globalCtx->actorCtx, &sp68, &D_801ED920, player); + targetCtx->unk_94 = sp68; + } + + if (targetCtx->unk8C != 0) { + sp68 = targetCtx->unk8C; + targetCtx->unk8C = NULL; + } else if (actor != 0) { + sp68 = actor; + } + + if (sp68 != NULL) { + category = sp68->category; + } else { + category = player->actor.category; + } + + if ((sp68 != targetCtx->arrowPointedActor) || (category != targetCtx->unk4A)) { + targetCtx->arrowPointedActor = sp68; + targetCtx->unk4A = category; + targetCtx->unk40 = 1.0f; + } + + if (sp68 == NULL) { + sp68 = &player->actor; + } + + if (!Math_StepToF(&targetCtx->unk40, 0.0f, 0.25f)) { + f32 temp_f0; + f32 x; + f32 y; + f32 z; + + temp_f0 = 0.25f / targetCtx->unk40; + + x = sp68->focus.pos.x - targetCtx->unk0.x; + y = (sp68->focus.pos.y + (sp68->targetArrowOffset * sp68->scale.y)) - targetCtx->unk0.y; + z = sp68->focus.pos.z - targetCtx->unk0.z; + + targetCtx->unk0.x += x * temp_f0; + targetCtx->unk0.y += y * temp_f0; + targetCtx->unk0.z += z * temp_f0; + } else { + Target_SetColors(targetCtx, sp68, category, globalCtx); + } + + if (actor != NULL && targetCtx->unk4B == 0) { + Actor_GetProjectedPos(globalCtx, &actor->focus.pos, &sp58, &sp54); + if ((sp58.z <= 0.0f) || (fabsf(sp58.x * sp54) >= 1.0f) || (fabsf(sp58.y * sp54) >= 1.0f)) { + actor = NULL; + } + } + + if (actor != NULL) { + if (actor != targetCtx->targetedActor) { + s32 sfxId; + + func_800B4F78(targetCtx, actor->category, globalCtx); + + targetCtx->targetedActor = actor; + + if (actor->id == ACTOR_EN_BOOM) { + targetCtx->unk48 = 0; + } + + sfxId = + CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_4 | ACTOR_FLAG_1) ? NA_SE_SY_LOCK_ON : NA_SE_SY_LOCK_ON_HUMAN; + play_sound(sfxId); + } + + targetCtx->targetCenterPos.x = actor->world.pos.x; + targetCtx->targetCenterPos.y = actor->world.pos.y - (actor->shape.yOffset * actor->scale.y); + targetCtx->targetCenterPos.z = actor->world.pos.z; + + if (targetCtx->unk4B == 0) { + f32 temp_f0_2; + f32 clampedFloat; + + temp_f0_2 = (500.0f - targetCtx->unk44) * 3.0f; + clampedFloat = CLAMP(temp_f0_2, 30.0f, 100.0f); + + if (Math_StepToF(&targetCtx->unk44, 80.0f, clampedFloat)) { + targetCtx->unk4B++; + } + } else { + targetCtx->unk4B = (targetCtx->unk4B + 3) | 0x80; + targetCtx->unk44 = 120.0f; + } + } else { + targetCtx->targetedActor = NULL; + Math_StepToF(&targetCtx->unk44, 500.0f, 80.0f); + } +} + +/* Start of Flags section */ + +/** + * Tests if current scene switch flag is set. + */ +s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag) { + if (flag >= 0 && flag < 0x80) { + return globalCtx->actorCtx.flags.switches[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F)); + } + return 0; +} + +/** + * Sets current scene switch flag. + */ +void Flags_SetSwitch(GlobalContext* globalCtx, s32 flag) { + if (flag >= 0 && flag < 0x80) { + globalCtx->actorCtx.flags.switches[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F); + } +} + +/** + * Unsets current scene switch flag. + */ +void Flags_UnsetSwitch(GlobalContext* globalCtx, s32 flag) { + if (flag >= 0 && flag < 0x80) { + globalCtx->actorCtx.flags.switches[(flag & ~0x1F) >> 5] &= ~(1 << (flag & 0x1F)); + } +} + +/** + * Tests if current scene chest flag is set. + */ +s32 Flags_GetTreasure(GlobalContext* globalCtx, s32 flag) { + return globalCtx->actorCtx.flags.chest & (1 << flag); +} + +/** + * Sets current scene chest flag. + */ +void Flags_SetTreasure(GlobalContext* globalCtx, s32 flag) { + globalCtx->actorCtx.flags.chest |= (1 << flag); +} + +/** + * Overrides the all the chest flags. + */ +void Flags_SetAllTreasure(GlobalContext* globalCtx, s32 flag) { + globalCtx->actorCtx.flags.chest = flag; +} + +/** + * Returns all the chest flags. + */ +s32 Flags_GetAllTreasure(GlobalContext* globalCtx) { + return globalCtx->actorCtx.flags.chest; +} + +/** + * Tests if current scene clear flag is set. + */ +s32 Flags_GetClear(GlobalContext* globalCtx, s32 roomNumber) { + return globalCtx->actorCtx.flags.clearedRoom & (1 << roomNumber); +} + +/** + * Sets current scene clear flag. + */ +void Flags_SetClear(GlobalContext* globalCtx, s32 roomNumber) { + globalCtx->actorCtx.flags.clearedRoom |= (1 << roomNumber); +} + +/** + * Unsets current scene clear flag. + */ +void Flags_UnsetClear(GlobalContext* globalCtx, s32 roomNumber) { + globalCtx->actorCtx.flags.clearedRoom &= ~(1 << roomNumber); +} + +/** + * Tests if current scene temp clear flag is set. + */ +s32 Flags_GetClearTemp(GlobalContext* globalCtx, s32 roomNumber) { + return globalCtx->actorCtx.flags.clearedRoomTemp & (1 << roomNumber); +} + +/** + * Sets current scene temp clear flag. + */ +void Flags_SetClearTemp(GlobalContext* globalCtx, s32 roomNumber) { + globalCtx->actorCtx.flags.clearedRoomTemp |= (1 << roomNumber); +} + +/** + * Unsets current scene temp clear flag. + */ +void Flags_UnsetClearTemp(GlobalContext* globalCtx, s32 roomNumber) { + globalCtx->actorCtx.flags.clearedRoomTemp &= ~(1 << roomNumber); +} + +/** + * Tests if current scene collectible flag is set. + */ +s32 Flags_GetCollectible(GlobalContext* globalCtx, s32 flag) { + if (flag > 0 && flag < 0x80) { + return globalCtx->actorCtx.flags.collectible[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F)); + } + return 0; +} + +/** + * Sets current scene collectible flag. + */ +void Flags_SetCollectible(GlobalContext* globalCtx, s32 flag) { + if (flag > 0 && flag < 0x80) { + globalCtx->actorCtx.flags.collectible[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F); + } +} + +/* End of Flags section */ + +/* Start of TitleCard section */ + +void TitleCard_ContextInit(GameState* gameState, TitleCardContext* titleCtx) { + titleCtx->durationTimer = 0; + titleCtx->delayTimer = 0; + titleCtx->intensity = 0; + titleCtx->alpha = 0; +} + +void TitleCard_InitBossName(GameState* gameState, TitleCardContext* titleCtx, TexturePtr texture, s16 x, s16 y, + u8 width, u8 height) { + titleCtx->texture = texture; + titleCtx->x = x; + titleCtx->y = y; + titleCtx->width = width; + titleCtx->height = height; + titleCtx->durationTimer = 80; + titleCtx->delayTimer = 0; +} + +void TitleCard_InitPlaceName(GameState* gameState, TitleCardContext* titleCtx, TexturePtr texture, s32 x, s32 y, + s32 width, s32 height, s32 delay) { +} + +void TitleCard_Update(GameState* gameState, TitleCardContext* titleCtx) { + if (DECR(titleCtx->delayTimer) == 0) { + if (DECR(titleCtx->durationTimer) == 0) { + Math_StepToS(&titleCtx->alpha, 0, 30); + Math_StepToS(&titleCtx->intensity, 0, 70); + } else { + Math_StepToS(&titleCtx->alpha, 255, 10); + Math_StepToS(&titleCtx->intensity, 255, 20); + } + } +} + +void TitleCard_Draw(GameState* gameState, TitleCardContext* titleCtx) { + if (titleCtx->alpha != 0) { + s32 width = titleCtx->width; + s32 height = titleCtx->height; + s32 unk1; + s32 spC0; + s32 sp38; + s32 spB8; + s32 spB4; + s32 temp; + + temp = width * 2; + spC0 = (titleCtx->x * 4) - temp; + spB8 = (titleCtx->y * 4) - (height * 2); + sp38 = width * 2; + + OPEN_DISPS(gameState->gfxCtx); + + height = (width * height > TMEM_SIZE) ? TMEM_SIZE / width : height; + spB4 = spB8 + (height * 4); + + if (1) {} + + OVERLAY_DISP = func_8012C014(OVERLAY_DISP); + + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, (u8)titleCtx->intensity, (u8)titleCtx->intensity, (u8)titleCtx->intensity, + (u8)titleCtx->alpha); + + gDPLoadTextureBlock(OVERLAY_DISP++, (s32*)titleCtx->texture, G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSPTextureRectangle(OVERLAY_DISP++, spC0, spB8, ((sp38 * 2) + spC0) - 4, spB8 + (height * 4) - 1, + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + + height = titleCtx->height - height; + + if (height > 0) { + gDPLoadTextureBlock(OVERLAY_DISP++, (s32)titleCtx->texture + 0x1000, G_IM_FMT_IA, G_IM_SIZ_8b, width, + height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, + G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSPTextureRectangle(OVERLAY_DISP++, spC0, spB4, ((sp38 * 2) + spC0) - 4, spB4 + (height * 4) - 1, + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + } + + CLOSE_DISPS(gameState->gfxCtx); + } +} + +/* End of TitleCard section */ + +// unused +s32 func_800B6434(GlobalContext* globalCtx, TitleCardContext* titleCtx) { + if ((globalCtx->actorCtx.titleCtxt.delayTimer != 0) || (globalCtx->actorCtx.titleCtxt.alpha != 0)) { + titleCtx->durationTimer = 0; + titleCtx->delayTimer = 0; + return false; + } + return true; +} + +void func_800B6468(GlobalContext* globalCtx) { + globalCtx->actorCtx.unk1F5 = 0; +} + +void func_800B6474(GlobalContext* globalCtx) { + if (globalCtx->actorCtx.unk1F5 != 0) { + globalCtx->actorCtx.unk1F5--; + } +} + +s32 func_800B648C(GlobalContext* globalCtx, s32 arg1, s32 arg2, f32 arg3, Vec3f* arg4) { + if ((globalCtx->actorCtx.unk1F5 != 0) && (arg3 < globalCtx->actorCtx.unk1F8)) { + return false; + } + + globalCtx->actorCtx.unk1F4 = arg1; + globalCtx->actorCtx.unk1F5 = arg2; + globalCtx->actorCtx.unk1F8 = arg3; + Math_Vec3f_Copy(&globalCtx->actorCtx.unk1FC, arg4); + + return true; +} + +f32 func_800B64FC(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2, u32* arg3) { + f32 temp_f8; + + if ((globalCtx->actorCtx.unk1F5 == 0) || (arg1 == 0.0f)) { + return -1.0f; + } + + temp_f8 = Math_Vec3f_DistXYZ(&globalCtx->actorCtx.unk1FC, arg2) / arg1; + *arg3 = globalCtx->actorCtx.unk1F4; + return globalCtx->actorCtx.unk1F8 - temp_f8; +} + +/** + * Initializes an element of the `globalCtx->actorCtx.unk_20C` array to the `arg2` pointer, or allocates one using the + * `size` argument in case `arg2` is NULL. This element is associated to an `id` + * + * In success returns the allocated pointer if `arg2` was NULL or the `arg2` pointer otherwise + * In failure (There's no space left in `globalCtx->actorCtx.unk_20C` or an allocation error happened) returns NULL + * + * Note there are no duplicated id checks. + * + * Used only by EnLiftNuts. + */ +void* func_800B6584(GlobalContext* globalCtx, s16 id, void* arg2, size_t size) { + ActorContext_unk_20C* entry = globalCtx->actorCtx.unk_20C; + s32 i; + + for (i = 0; i < ARRAY_COUNT(globalCtx->actorCtx.unk_20C); i++) { + if (entry->id == 0) { + if (arg2 == NULL) { + arg2 = ZeldaArena_Malloc(size); + if (arg2 == NULL) { + return NULL; + } + entry->isDynamicallyInitialised = true; + } + + entry->id = id; + entry->ptr = arg2; + return arg2; + } + + entry++; + } + + return NULL; +} + +/** + * Frees the first element of `globalCtx->actorCtx.unk_20C` with id `id`. + * + * If success, the free'd pointer is returned. + * If failure, NULL is returned. + * + * Used only by EnLiftNuts. + */ +void* func_800B6608(GlobalContext* globalCtx, s16 id) { + ActorContext_unk_20C* entry = globalCtx->actorCtx.unk_20C; + s32 i; + + for (i = 0; i < ARRAY_COUNT(globalCtx->actorCtx.unk_20C); i++) { + if (id == entry->id) { + entry->id = 0; + if (entry->isDynamicallyInitialised) { + ZeldaArena_Free(entry->ptr); + entry->isDynamicallyInitialised = false; + } + return entry->ptr; + } + + entry++; + } + + return NULL; +} + +/** + * Retrieves the first pointer stored with the id `id`. + * If there's no pointer stored with that id, NULL is returned. + * + * Used only by EnLiftNuts. + */ +void* func_800B6680(GlobalContext* globalCtx, s16 id) { + ActorContext_unk_20C* entry = globalCtx->actorCtx.unk_20C; + s32 i; + + for (i = 0; i < ARRAY_COUNT(globalCtx->actorCtx.unk_20C); i++) { + if (id == entry->id) { + return entry->ptr; + } + + entry++; + } + + return NULL; +} void Actor_MarkForDeath(Actor* actor) { actor->draw = NULL; actor->update = NULL; - actor->flags &= ~0x1; + actor->flags &= ~ACTOR_FLAG_1; } -void Actor_InitCurrPosition(Actor* actor) { +void Actor_SetWorldToHome(Actor* actor) { actor->world = actor->home; } -void Actor_SetHeight(Actor* actor, f32 height) { +void Actor_SetFocus(Actor* actor, f32 height) { actor->focus.pos.x = actor->world.pos.x; actor->focus.pos.y = actor->world.pos.y + height; actor->focus.pos.z = actor->world.pos.z; + actor->focus.rot.x = actor->world.rot.x; actor->focus.rot.y = actor->world.rot.y; actor->focus.rot.z = actor->world.rot.z; } -void Actor_SetRotationFromDrawRotation(Actor* actor) { +void Actor_SetWorldRotToShape(Actor* actor) { actor->world.rot = actor->shape.rot; } -void Actor_InitDrawRotation(Actor* actor) { +void Actor_SetShapeRotToWorld(Actor* actor) { actor->shape.rot = actor->world.rot; } @@ -317,43 +1060,38 @@ void Actor_SetScale(Actor* actor, f32 scale) { actor->scale.x = scale; } -void Actor_SetObjectSegment(GlobalContext* globalCtx, Actor* actor) { - // TODO: Segment number enum +void Actor_SetObjectDependency(GlobalContext* globalCtx, Actor* actor) { gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[actor->objBankIndex].segment); } -#if 0 -void Actor_InitToDefaultValues(Actor* actor, GlobalContext* globalCtx) { - Actor_InitCurrPosition(actor); - Actor_InitDrawRotation(actor); - Actor_SetHeight(actor, 0); +void Actor_Init(Actor* actor, GlobalContext* globalCtx) { + Actor_SetWorldToHome(actor); + Actor_SetShapeRotToWorld(actor); + Actor_SetFocus(actor, 0.0f); Math_Vec3f_Copy(&actor->prevPos, &actor->world.pos); - Actor_SetScale(actor, 0.01); + Actor_SetScale(actor, 0.01f); actor->targetMode = 3; - actor->minYVelocity = -20.0f; + actor->terminalVelocity = -20.0f; - actor->meshAttachedTo = 0x32; - - actor->sqrdDistToLink = D_801DCA54; - CollisionCheck_InitInfo(&actor->colChkInfo); + actor->xyzDistToPlayerSq = FLT_MAX; actor->uncullZoneForward = 1000.0f; actor->uncullZoneScale = 350.0f; actor->uncullZoneDownward = 700.0f; - actor->naviMsgId = 255; + actor->hintId = 255; - Actor_Setshape(&actor->shape, 0, 0, 0); - if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex) != 0) { - Actor_SetObjectSegment(globalCtx, actor); + CollisionCheck_InitInfo(&actor->colChkInfo); + actor->floorBgId = BGCHECK_SCENE; + + ActorShape_Init(&actor->shape, 0.0f, NULL, 0.0f); + if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { + Actor_SetObjectDependency(globalCtx, actor); actor->init(actor, globalCtx); actor->init = NULL; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_InitToDefaultValues.s") -#endif -void Actor_FiniActor(Actor* actor, GlobalContext* globalCtx) { +void Actor_Destroy(Actor* actor, GlobalContext* globalCtx) { if (actor->init == NULL) { if (actor->destroy != NULL) { actor->destroy(actor, globalCtx); @@ -362,60 +1100,111 @@ void Actor_FiniActor(Actor* actor, GlobalContext* globalCtx) { } } +f32 actorMovementScale = 1.0f; + void Actor_SetMovementScale(s32 scale) { actorMovementScale = scale * 0.5f; } -void Actor_ApplyMovement(Actor* actor) { +/** + * Update actor position using velocity and any push from z_collision_check. + */ +void Actor_UpdatePos(Actor* actor) { f32 speedRate = actorMovementScale; - actor->world.pos.x += ((actor->velocity.x * speedRate) + actor->colChkInfo.displacement.x); - actor->world.pos.y += ((actor->velocity.y * speedRate) + actor->colChkInfo.displacement.y); - actor->world.pos.z += ((actor->velocity.z * speedRate) + actor->colChkInfo.displacement.z); + actor->world.pos.x += (actor->velocity.x * speedRate) + actor->colChkInfo.displacement.x; + actor->world.pos.y += (actor->velocity.y * speedRate) + actor->colChkInfo.displacement.y; + actor->world.pos.z += (actor->velocity.z * speedRate) + actor->colChkInfo.displacement.z; } -void Actor_SetVelocityYRotationAndGravity(Actor* actor) { +/** + * Updates actor's velocity accounting for gravity (without exceeding terminal velocity) + * The operation is performed in cylindrical coordinates + * + * It is recommended to not call this function directly and use `Actor_MoveWithGravity` instead + */ +void Actor_UpdateVelocityWithGravity(Actor* actor) { actor->velocity.x = actor->speedXZ * Math_SinS(actor->world.rot.y); actor->velocity.z = actor->speedXZ * Math_CosS(actor->world.rot.y); - actor->velocity.y += actor->gravity; - if (actor->velocity.y < actor->minVelocityY) { - actor->velocity.y = actor->minVelocityY; + actor->velocity.y += actor->gravity; + if (actor->velocity.y < actor->terminalVelocity) { + actor->velocity.y = actor->terminalVelocity; } } -void Actor_SetVelocityAndMoveYRotationAndGravity(Actor* actor) { - Actor_SetVelocityYRotationAndGravity(actor); - Actor_ApplyMovement(actor); +/** + * Moves actor accounting for its current velocity and applying gravity + * The operation is performed in cylindrical coordinates + */ +void Actor_MoveWithGravity(Actor* actor) { + Actor_UpdateVelocityWithGravity(actor); + Actor_UpdatePos(actor); } -void Actor_SetVelocityXYRotation(Actor* actor) { - f32 velX = Math_CosS(actor->world.rot.x) * actor->speedXZ; - actor->velocity.x = Math_SinS(actor->world.rot.y) * velX; +/** + * Updates actor's velocity, ignoring gravity + * The operation is performed in spherical coordinates + * + * It is recommended to not call this function directly and use `Actor_MoveWithoutGravity` instead + */ +void Actor_UpdateVelocityWithoutGravity(Actor* actor) { + f32 horizontalSpeed = Math_CosS(actor->world.rot.x) * actor->speedXZ; + + actor->velocity.x = Math_SinS(actor->world.rot.y) * horizontalSpeed; actor->velocity.y = Math_SinS(actor->world.rot.x) * actor->speedXZ; - actor->velocity.z = Math_CosS(actor->world.rot.y) * velX; + actor->velocity.z = Math_CosS(actor->world.rot.y) * horizontalSpeed; } -void Actor_SetVelocityAndMoveXYRotation(Actor* actor) { - Actor_SetVelocityXYRotation(actor); - Actor_ApplyMovement(actor); +/** + * Moves actor accounting for its current velocity, without applying gravity + * The operation is performed in spherical coordinates + * + * Useful for flying or swimming actors + */ +void Actor_MoveWithoutGravity(Actor* actor) { + Actor_UpdateVelocityWithoutGravity(actor); + Actor_UpdatePos(actor); } -void Actor_SetVelocityXYRotationReverse(Actor* actor) { - f32 velX = Math_CosS(-actor->world.rot.x) * actor->speedXZ; - actor->velocity.x = Math_SinS(actor->world.rot.y) * velX; +/** + * Like `Actor_UpdateVelocityWithoutGravity`, but the actor is moved backwards instead of forwards + * + * It is recommended to not call this function directly and use `Actor_MoveWithoutGravityReverse` instead + */ +void Actor_UpdateVelocityWithoutGravityReverse(Actor* actor) { + f32 horizontalSpeed = Math_CosS(-actor->world.rot.x) * actor->speedXZ; + + actor->velocity.x = Math_SinS(actor->world.rot.y) * horizontalSpeed; actor->velocity.y = Math_SinS(-actor->world.rot.x) * actor->speedXZ; - actor->velocity.z = Math_CosS(actor->world.rot.y) * velX; + actor->velocity.z = Math_CosS(actor->world.rot.y) * horizontalSpeed; } -void Actor_SetVelocityAndMoveXYRotationReverse(Actor* actor) { - Actor_SetVelocityXYRotationReverse(actor); - Actor_ApplyMovement(actor); +/** + * Like `Actor_MoveWithoutGravity`, but the actor is moved backwards instead of forwards + */ +void Actor_MoveWithoutGravityReverse(Actor* actor) { + Actor_UpdateVelocityWithoutGravityReverse(actor); + Actor_UpdatePos(actor); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6C04.s") +/** + * Sets horizontal speed and Y velocity using the `speed` argument and current pitch + */ +void Actor_SetSpeeds(Actor* actor, f32 speed) { + actor->speedXZ = Math_CosS(actor->world.rot.x) * speed; + actor->velocity.y = -Math_SinS(actor->world.rot.x) * speed; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6C58.s") +// unused +void Actor_UpdatePosFromSkelAnime(Actor* actor, SkelAnime* skelAnime) { + Vec3f pos; + + SkelAnime_UpdateTranslation(skelAnime, &pos, actor->shape.rot.y); + actor->world.pos.x += pos.x * actor->scale.x; + actor->world.pos.y += pos.y * actor->scale.y; + actor->world.pos.z += pos.z * actor->scale.z; +} s16 Actor_YawBetweenActors(Actor* from, Actor* to) { return Math_Vec3f_Yaw(&from->world.pos, &to->world.pos); @@ -457,171 +1246,744 @@ f32 Actor_XZDistanceToPoint(Actor* actor, Vec3f* point) { return Math_Vec3f_DistXZ(&actor->world.pos, point); } -/** Performs the affine (linear) transformation from world coordinates to actor coordinates +/** + * Find the offset of a point from an actor in that actor's own coordinates (origin at the actor's + * world.pos, z-axis is facing angle, i.e. shape.rot.y) * * @param[in] actor The actor whose coordinate system to transform to. * @param[out] offset The transformed coordinates. * @param[in] point The point to transform to actor coordinates. */ -void Actor_CalcOffsetOrientedToDrawRotation(Actor* actor, Vec3f* offset, Vec3f* point) { - f32 cos_rot_y; - f32 sin_rot_y; - f32 imm_x; - f32 imm_z; +void Actor_OffsetOfPointInActorCoords(Actor* actor, Vec3f* offset, Vec3f* point) { + f32 cos = Math_CosS(actor->shape.rot.y); + f32 sin = Math_SinS(actor->shape.rot.y); + f32 diffX; + f32 diffZ; - cos_rot_y = Math_CosS(actor->shape.rot.y); - sin_rot_y = Math_SinS(actor->shape.rot.y); - imm_x = point->x - actor->world.pos.x; - imm_z = point->z - actor->world.pos.z; - offset->x = ((imm_x * cos_rot_y) - (imm_z * sin_rot_y)); - offset->z = ((imm_z * cos_rot_y) + (imm_x * sin_rot_y)); + // Shift X,Z to actor coordinates origin + diffX = point->x - actor->world.pos.x; + diffZ = point->z - actor->world.pos.z; + + // Rotate X and Z offsets to align Z to actor's shape.rot.y + offset->x = ((diffX * cos) - (diffZ * sin)); + offset->z = ((diffZ * cos) + (diffX * sin)); + + // Shift Y to origin offset->y = point->y - actor->world.pos.y; } -f32 Actor_YDistance(Actor* actor1, Actor* actor2) { +f32 Actor_HeightDiff(Actor* actor1, Actor* actor2) { return actor2->world.pos.y - actor1->world.pos.y; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6F20.s") +/** + * Sets the current and new inputs. + */ +void func_800B6F20(GlobalContext* globalCtx, Input* input, f32 magnitude, s16 baseYaw) { + s16 relativeYaw = baseYaw - func_800DFC68(GET_ACTIVE_CAM(globalCtx)); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6FC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7090.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7118.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7128.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B715C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7170.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B71DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7200.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B722C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B724C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7298.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B72E0.s") - -void func_800B72F8(DynaPolyActor* dpactor, f32 a1, s16 a2) { - dpactor->yRotation = a2; - dpactor->pushForce += a1; + input->cur.stick_x = -Math_SinS(relativeYaw) * magnitude; + input->rel.stick_x = input->cur.stick_x; + input->cur.stick_y = Math_CosS(relativeYaw) * magnitude; + input->rel.stick_y = input->cur.stick_y; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_IsLinkFacingActor.s") +f32 Player_GetHeight(Player* player) { + f32 extraHeight; -s32 Actor_IsActorFacedByActor(Actor* actor, Actor* other, s16 tolerance) { - s16 angle; - s16 dist; - - angle = BINANG_ROT180(Actor_YawBetweenActors(actor, other)); - dist = angle - other->shape.rot.y; - if (ABS_ALT(dist) < tolerance) { - return 1; + if (player->stateFlags1 & 0x800000) { + extraHeight = 32.0f; + } else { + extraHeight = 0.0f; } - return 0; -} -s32 Actor_IsActorFacingLink(Actor* actor, s16 angle) { - s16 dist; - - dist = actor->yawTowardsPlayer - actor->shape.rot.y; - if (ABS_ALT(dist) < angle) { - return 1; + switch (player->transformation) { + default: + case PLAYER_FORM_FIERCE_DEITY: + return extraHeight + 124.0f; + case PLAYER_FORM_GORON: + // (player->stateFlags3 & 0x1000): being curled? + return extraHeight + ((player->stateFlags3 & 0x1000) ? 34.0f : 80.0f); + case PLAYER_FORM_ZORA: + return extraHeight + 68.0f; + case PLAYER_FORM_DEKU: + return extraHeight + 36.0f; + case PLAYER_FORM_HUMAN: + return extraHeight + 44.0f; } - return 0; } -s32 Actor_IsActorFacingActor(Actor* actor, Actor* other, s16 tolerance) { - s16 dist; - - dist = Actor_YawBetweenActors(actor, other) - actor->shape.rot.y; - if (ABS_ALT(dist) < tolerance) { - return 1; +f32 Player_GetRunSpeedLimit(Player* player) { + if (player->stateFlags1 & 0x800000) { + return 15.0f; + } else if (player->stateFlags1 & 0x8000000) { + return (R_RUN_SPEED_LIMIT / 100.0f) * 0.6f; + } else { + return R_RUN_SPEED_LIMIT / 100.0f; } - return 0; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_IsActorFacingLinkAndWithinRange.s") +s32 func_800B7118(Player* player) { + return player->stateFlags1 & 0x8; +} -s32 Actor_IsActorFacingActorAndWithinRange(Actor* actor, Actor* other, f32 range, s16 tolerance) { - s16 dist; +s32 func_800B7128(Player* player) { + return func_800B7118(player) && player->unk_ACC; +} - if (Actor_DistanceBetweenActors(actor, other) < range) { - dist = Actor_YawBetweenActors(actor, other) - actor->shape.rot.y; - if (ABS_ALT(dist) < tolerance) { - return 1; +s32 func_800B715C(GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + return player->stateFlags2 & 0x8; +} + +void Actor_SetCameraHorseSetting(GlobalContext* globalCtx, Player* player) { + if ((globalCtx->roomCtx.currRoom.unk3 != 4) && (player->actor.id == ACTOR_PLAYER)) { + EnHorse* rideActor = (EnHorse*)player->rideActor; + + if ((rideActor != NULL) && !(rideActor->unk_1EC & 0x10)) { + func_800DFAC8(Play_GetCamera(globalCtx, MAIN_CAM), 4); } } - return 0; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B75A0.s") +void Actor_MountHorse(GlobalContext* globalCtx, Player* player, Actor* horse) { + player->rideActor = horse; + player->stateFlags1 |= 0x800000; + horse->child = &player->actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B761C.s") +s32 func_800B7200(Player* player) { + return (player->stateFlags1 & 0x20000080) || (player->csMode != 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7678.s") +void func_800B722C(GameState* gameState, Player* player) { + func_800F40A0(gameState, player); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_UpdateBgCheckInfo.s") +s32 func_800B724C(GlobalContext* globalCtx, Actor* actor, u8 csMode) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7E04.s") + if ((player->csMode == 5) || ((csMode == 6) && (player->csMode == 0))) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7FE0.s") + player->csMode = csMode; + player->unk_398 = actor; + player->unk_3BA = 0; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8018.s") +u32 func_800B7298(GlobalContext* globalCtx, Actor* actor, u8 csMode) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8050.s") + if (func_800B724C(globalCtx, actor, csMode)) { + player->unk_3BA = 1; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8118.s") +// Unused +void func_800B72E0(DynaPolyActor* dyna) { + dyna->unk14C = 0.0f; + dyna->pushForce = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B81E0.s") +void func_800B72F8(DynaPolyActor* dyna, f32 extraPushForce, s16 yRotation) { + dyna->yRotation = yRotation; + dyna->pushForce += extraPushForce; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8214.s") +/** + * Check if the player is facing the specified actor. + * The maximum angle difference that qualifies as "facing" is specified by `maxAngleDiff`. + */ +s32 Player_IsFacingActor(Actor* actor, s16 maxAngleDiff, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 yawDiff = BINANG_ADD(actor->yawTowardsPlayer, 0x8000) - player->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8248.s") + if (ABS_ALT(yawDiff) < maxAngleDiff) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B82EC.s") +/** + * Check if `actorB` is facing `actorA`. + * The maximum angle difference that qualifies as "facing" is specified by `maxAngle`. + * + * This function is unused in the original game. + */ +s32 Actor_ActorBIsFacingActorA(Actor* actorA, Actor* actorB, s16 maxAngleDiff) { + s16 angle = BINANG_ROT180(Actor_YawBetweenActors(actorA, actorB)); + s16 dist = angle - actorB->shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B83BC.s") + if (ABS_ALT(dist) < maxAngleDiff) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B83F8.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B84D0.s") +/** + * Check if the specified actor is facing the player. + * The maximum angle difference that qualifies as "facing" is specified by `maxAngleDiff`. + */ +s32 Actor_IsFacingPlayer(Actor* actor, s16 angle) { + s16 dist = actor->yawTowardsPlayer - actor->shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8500.s") + if (ABS_ALT(dist) < angle) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B85E0.s") +/** + * Check if `actorA` is facing `actorB`. + * The maximum angle difference that qualifies as "facing" is specified by `maxAngleDiff`. + */ +s32 Actor_ActorAIsFacingActorB(Actor* actorA, Actor* actorB, s16 maxAngleDiff) { + s16 dist = Actor_YawBetweenActors(actorA, actorB) - actorA->shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8614.s") + if (ABS_ALT(dist) < maxAngleDiff) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B863C.s") +/** + * Check if the specified actor is facing the player and is nearby. + * The maximum angle difference that qualifies as "facing" is specified by `maxAngleDiff`. + * The maximum distance that qualifies as "nearby" is specified by `range`. + */ +s32 Actor_IsFacingAndNearPlayer(Actor* actor, f32 range, s16 maxAngleDiff) { + s16 yaw = actor->yawTowardsPlayer - actor->shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B867C.s") + if (ABS_ALT(yaw) < maxAngleDiff) { + s16 pad; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B86C8.s") + if (sqrtf(SQ(actor->xzDistToPlayer) + SQ(actor->playerHeightRel)) < range) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8708.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8718.s") +/** + * Check if `actorA` is facing `actorB` and is nearby. + * The maximum angle difference that qualifies as "facing" is specified by `maxAngleDiff`. + * The maximum distance that qualifies as "nearby" is specified by `range`. + */ +s32 Actor_ActorAIsFacingAndNearActorB(Actor* actorA, Actor* actorB, f32 range, s16 maxAngleDiff) { + if (Actor_DistanceBetweenActors(actorA, actorB) < range) { + s16 dist = Actor_YawBetweenActors(actorA, actorB) - actorA->shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B874C.s") + if (ABS_ALT(dist) < maxAngleDiff) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8804.s") +/* Start of BgCheck related section */ -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B882C.s") +void func_800B75A0(CollisionPoly* poly, Vec3f* normal, s16* azimuth) { + normal->x = COLPOLY_GET_NORMAL(poly->normal.x); + normal->y = COLPOLY_GET_NORMAL(poly->normal.y); + normal->z = COLPOLY_GET_NORMAL(poly->normal.z); + *azimuth = Math_FAtan2F(normal->z, normal->x); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B886C.s") +s32 func_800B761C(Actor* actor, f32 arg1, s32 arg2) { + if (actor->bgCheckFlags & 1) { + actor->bgCheckFlags &= ~1; + actor->bgCheckFlags |= 4; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8898.s") + if ((actor->velocity.y < 0.0f) && (arg2 & 0x10)) { + actor->velocity.y = 0.0f; + } + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8934.s") + return true; +} -u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { +s32 func_800B7678(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s32 flags) { + f32 distToFloor; + s32 bgId; + + pos->y += (flags & 0x800) ? 10.0f : 50.0f; + + actor->floorHeight = + BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &bgId, actor, pos); + actor->bgCheckFlags &= ~(0x80 | 0x04 | 0x02); + if (actor->floorHeight <= BGCHECK_Y_MIN) { + return func_800B761C(actor, BGCHECK_Y_MIN, flags); + } + + distToFloor = actor->floorHeight - actor->world.pos.y; + actor->floorBgId = bgId; + if ((distToFloor >= 0.0f) || (((actor->bgCheckFlags & 1)) && !(actor->bgCheckFlags & 0x800) && + (distToFloor >= -11.0f) && (actor->velocity.y < 0.0f))) { + actor->bgCheckFlags |= 0x80; + + if (actor->bgCheckFlags & 0x10) { + if (bgId != D_801ED8B4) { + if (distToFloor > 15.0f) { + actor->bgCheckFlags |= 0x100; + } + } else { + actor->world.pos.x = actor->prevPos.x; + actor->world.pos.z = actor->prevPos.z; + } + } + + actor->world.pos.y = actor->floorHeight; + + if (actor->velocity.y <= 0.0f) { + if (!(actor->bgCheckFlags & 1)) { + actor->bgCheckFlags |= 2; + } else if ((flags & 8) && (actor->gravity < 0.0f)) { + actor->velocity.y = -4.0f; + } else if (!(flags & 0x100)) { + actor->velocity.y = 0.0f; + } + + actor->bgCheckFlags |= 1; + BgCheck2_AttachToMesh(&globalCtx->colCtx, actor, (s32)actor->floorBgId); + } + } else { + return func_800B761C(actor, distToFloor, flags); + } + + return true; +} + +void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallCheckHeight, f32 wallCheckRadius, + f32 ceilingCheckHeight, u32 flags) { + f32 sp94 = actor->world.pos.y - actor->prevPos.y; + s32 pad; + Vec3f pos; + + if ((actor->floorBgId != BGCHECK_SCENE) && (actor->bgCheckFlags & 1)) { + BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, actor->floorBgId, actor); + } + + if (flags & 1) { + s32 bgId; + + actor->bgCheckFlags &= ~0x1000; + if ((!(flags & 0x80) && + (BgCheck_EntitySphVsWall3(&globalCtx->colCtx, &pos, &actor->world.pos, &actor->prevPos, wallCheckRadius, + &actor->wallPoly, &bgId, actor, wallCheckHeight))) || + ((flags & 0x80) && + (BgCheck_EntitySphVsWall4(&globalCtx->colCtx, &pos, &actor->world.pos, &actor->prevPos, wallCheckRadius, + &actor->wallPoly, &bgId, actor, wallCheckHeight)))) { + CollisionPoly* sp7C = actor->wallPoly; + + actor->bgCheckFlags |= 8; + if ((flags & 0x200) && (actor->bgCheckFlags & 0x1000) && ((s32)sp7C->normal.y > 0) && + (sqrtf(SQXYZ(actor->colChkInfo.displacement)) < 10.0f)) { + actor->bgCheckFlags &= ~8; + } else if (actor->bgCheckFlags & 8) { + Math_Vec3f_Copy(&actor->world.pos, &pos); + } + + actor->wallYaw = Math_FAtan2F(sp7C->normal.z, sp7C->normal.x); + actor->wallBgId = bgId; + } else { + actor->bgCheckFlags &= ~8; + } + } + + pos.x = actor->world.pos.x; + pos.z = actor->world.pos.z; + if (flags & 2) { + f32 y; + + pos.y = actor->prevPos.y + 4.0f; + if (BgCheck_EntityCheckCeiling(&globalCtx->colCtx, &y, &pos, (ceilingCheckHeight + sp94) - 4.0f, &D_801ED8B0, + &D_801ED8B4, actor)) { + actor->bgCheckFlags |= 0x10; + actor->world.pos.y = (y + sp94) - 4.0f; + } else { + actor->bgCheckFlags &= ~0x10; + } + } + if (flags & 4) { + WaterBox* waterbox; + f32 y; + + pos.y = actor->prevPos.y; + func_800B7678(globalCtx, actor, &pos, flags); + y = actor->world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, actor->world.pos.x, actor->world.pos.z, &y, + &waterbox)) { + actor->depthInWater = y - actor->world.pos.y; + if (actor->depthInWater <= 0.0f) { + actor->bgCheckFlags &= ~(0x40 | 0x20); + } else if (!(actor->bgCheckFlags & 0x20)) { + actor->bgCheckFlags |= (0x40 | 0x20); + if (!(flags & 0x40)) { + Vec3f sp64; + + sp64.x = actor->world.pos.x; + sp64.y = y; + sp64.z = actor->world.pos.z; + + EffectSsGRipple_Spawn(globalCtx, &sp64, 100, 500, 0); + EffectSsGRipple_Spawn(globalCtx, &sp64, 100, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &sp64, 100, 500, 8); + } + } else { + actor->bgCheckFlags &= ~0x40; + } + } else { + actor->bgCheckFlags &= ~(0x40 | 0x20); + actor->depthInWater = BGCHECK_Y_MIN; + } + } + + if (flags & 0x400) { + WaterBox* waterbox; + f32 y = actor->world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, actor->world.pos.x, actor->world.pos.z, &y, + &waterbox)) { + actor->depthInWater = y - actor->world.pos.y; + + if (actor->depthInWater < 0.0f) { + actor->bgCheckFlags &= ~(0x40 | 0x20); + } else if (!(actor->bgCheckFlags & 0x20)) { + actor->bgCheckFlags |= (0x40 | 0x20); + if (!(flags & 0x40)) { + Vec3f sp50; + + sp50.x = actor->world.pos.x; + sp50.y = y; + sp50.z = actor->world.pos.z; + + EffectSsGRipple_Spawn(globalCtx, &sp50, 100, 500, 0); + EffectSsGRipple_Spawn(globalCtx, &sp50, 100, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &sp50, 100, 500, 8); + } + } else { + actor->bgCheckFlags &= ~0x40; + } + } else { + actor->bgCheckFlags &= ~(0x40 | 0x20); + actor->depthInWater = BGCHECK_Y_MIN; + } + } +} + +Gfx* Hilite_Draw(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx, Gfx* dl, Hilite** hilite) { + LookAt* lookAt = GRAPH_ALLOC(gfxCtx, sizeof(LookAt)); + f32 correctedEyeX = (eye->x == object->x) && (eye->z == object->z) ? eye->x + 0.001f : eye->x; + + *hilite = GRAPH_ALLOC(gfxCtx, sizeof(Hilite)); + + guLookAtHilite(&D_801ED8E0, lookAt, *hilite, correctedEyeX, eye->y, eye->z, object->x, object->y, object->z, 0.0f, + 1.0f, 0.0f, lightDir->x, lightDir->y, lightDir->z, lightDir->x, lightDir->y, lightDir->z, 0x10, + 0x10); + + gSPLookAt(dl++, lookAt); + gDPSetHilite1Tile(dl++, 1, *hilite, 0x10, 0x10); + + return dl; +} + +Hilite* Hilite_DrawOpa(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx) { + Hilite* hilite; + + OPEN_DISPS(gfxCtx); + + POLY_OPA_DISP = Hilite_Draw(object, eye, lightDir, gfxCtx, POLY_OPA_DISP, &hilite); + + CLOSE_DISPS(gfxCtx); + + return hilite; +} + +Hilite* Hilite_DrawXlu(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx) { + Hilite* hilite; + + OPEN_DISPS(gfxCtx); + + POLY_XLU_DISP = Hilite_Draw(object, eye, lightDir, gfxCtx, POLY_XLU_DISP, &hilite); + + CLOSE_DISPS(gfxCtx); + + return hilite; +} + +void func_800B8050(Actor* actor, GlobalContext* globalCtx, s32 flag) { + Hilite* hilite = func_800BCBF4(&actor->world.pos, globalCtx); + + if (flag != 0) { + Gfx* displayListHead; + Gfx* displayList = GRAPH_ALLOC(globalCtx->state.gfxCtx, 2 * sizeof(Gfx)); + + displayListHead = displayList; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10); + gSPEndDisplayList(displayListHead); + gSPSegment(POLY_OPA_DISP++, 0x07, displayList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_800B8118(Actor* actor, GlobalContext* globalCtx, s32 flag) { + Hilite* hilite = func_800BCC68(&actor->world.pos, globalCtx); + + if (flag != 0) { + Gfx* displayListHead; + Gfx* displayList = GRAPH_ALLOC(globalCtx->state.gfxCtx, 2 * sizeof(Gfx)); + + displayListHead = displayList; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10); + gSPEndDisplayList(displayListHead); + gSPSegment(POLY_XLU_DISP++, 0x07, displayList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +PosRot* Actor_GetFocus(PosRot* dest, Actor* actor) { + *dest = actor->focus; + + return dest; +} + +PosRot* Actor_GetWorld(PosRot* dest, Actor* actor) { + *dest = actor->world; + + return dest; +} + +PosRot* Actor_GetWorldPosShapeRot(PosRot* dest, Actor* actor) { + PosRot sp1C; + + Math_Vec3f_Copy(&sp1C.pos, &actor->world.pos); + if (actor->id == ACTOR_PLAYER) { + Player* player = (Player*)actor; + + sp1C.pos.y += player->unk_AC0 * actor->scale.y; + } + sp1C.rot = actor->shape.rot; + *dest = sp1C; + + return dest; +} + +f32 func_800B82EC(Actor* actor, Player* player, s16 angle) { + f32 temp_f12; + s16 temp_v0 = BINANG_SUB(BINANG_SUB(actor->yawTowardsPlayer, 0x8000), angle); + s16 yaw = ABS_ALT(temp_v0); + + if (player->unk_730 != NULL) { + if ((yaw > 0x4000) || ((actor->flags & ACTOR_FLAG_8000000))) { + return FLT_MAX; + } + + temp_f12 = actor->xyzDistToPlayerSq - ((actor->xyzDistToPlayerSq * 0.8f) * ((0x4000 - yaw) * (1.0f / 0x8000))); + return temp_f12; + } + + if (yaw >= 0x2AAB) { + return FLT_MAX; + } + return actor->xyzDistToPlayerSq; +} + +#define TARGET_RANGE(range, leash) \ + { SQ(range), (f32)range / leash } + +TargetRangeParams gTargetRanges[] = { + TARGET_RANGE(70, 140), TARGET_RANGE(170, 255), TARGET_RANGE(280, 5600), TARGET_RANGE(350, 525), + TARGET_RANGE(700, 1050), TARGET_RANGE(1000, 1500), TARGET_RANGE(100, 105.36842), TARGET_RANGE(140, 163.33333), + TARGET_RANGE(240, 576), TARGET_RANGE(280, 280000), TARGET_RANGE(2500, 3750), +}; + +s32 func_800B83BC(Actor* actor, f32 arg1) { + return arg1 < gTargetRanges[actor->targetMode].rangeSq; +} + +s32 func_800B83F8(Actor* actor, Player* player, s32 flag) { + if ((actor->update == NULL) || !(actor->flags & ACTOR_FLAG_1) || (actor->flags & ACTOR_FLAG_8000000)) { + return true; + } + + if (!flag) { + s16 yaw = BINANG_SUB(actor->yawTowardsPlayer, 0x8000) - player->actor.shape.rot.y; + s16 phi_v1 = ABS_ALT(yaw); + f32 dist; + + if ((player->unk_730 == NULL) && (phi_v1 >= 0x2AAB)) { + dist = FLT_MAX; + } else { + dist = actor->xyzDistToPlayerSq; + } + + return !func_800B83BC(actor, gTargetRanges[actor->targetMode].leashScale * dist); + } + + return false; +} + +s16 D_801AED48[] = { + 0x101, 0x141, 0x111, 0x151, 0x105, 0x145, 0x115, 0x155, +}; + +s32 Actor_ProcessTalkRequest(Actor* actor, GameState* gameState) { + if (actor->flags & ACTOR_FLAG_100) { + actor->flags &= ~ACTOR_FLAG_100; + return true; + } + + return false; +} + +// Actor_PickUpExchange? Seems to be called with exchangeItemId -1 if the same actor used Actor_PickUp +// This function is also used to toggle the "Speak" action on the A button +s32 func_800B8500(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->actor.flags & ACTOR_FLAG_100) || + ((exchangeItemId > EXCH_ITEM_NONE) && Player_InCsMode(&globalCtx->state)) || + (!actor->isTargeted && + ((fabsf(actor->playerHeightRel) > fabsf(yRange)) || ((actor->xzDistToPlayer > player->targetActorDistance)) || + (xzRange < actor->xzDistToPlayer)))) { + return false; + } + + player->targetActor = actor; + player->targetActorDistance = actor->xzDistToPlayer; + player->exchangeItemId = exchangeItemId; + + ActorCutscene_SetIntentToPlay(0x7C); + return true; +} + +s32 func_800B85E0(Actor* actor, GlobalContext* globalCtx, f32 radius, s32 exchangeItemId) { + return func_800B8500(actor, globalCtx, radius, radius, exchangeItemId); +} + +s32 func_800B8614(Actor* actor, GlobalContext* globalCtx, f32 radius) { + return func_800B85E0(actor, globalCtx, radius, EXCH_ITEM_NONE); +} + +s32 func_800B863C(Actor* actor, GlobalContext* globalCtx) { + f32 cylRadius = actor->colChkInfo.cylRadius + 50.0f; + + return func_800B8614(actor, globalCtx, cylRadius); +} + +s32 Actor_TextboxIsClosing(Actor* actor, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 2) { + actor->flags &= ~ACTOR_FLAG_100; + return true; + } + + return false; +} + +/** + * Changes the actor the Player is focussing on + * Fails if Player is not already focussing on an actor or in a talking state + */ +s32 Actor_ChangeFocus(Actor* actor1, GlobalContext* globalCtx, Actor* actor2) { + Actor* targetActor; + Player* player = GET_PLAYER(globalCtx); + + targetActor = player->targetActor; + + if ((player->actor.flags & ACTOR_FLAG_100) && (targetActor != NULL)) { + player->targetActor = actor2; + player->unk_730 = actor2; + return true; + } + + return false; +} + +s32 Player_GetExchangeItemId(GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + return player->exchangeItemId; +} + +s32 func_800B8718(Actor* actor, GameState* gameState) { + if (actor->flags & ACTOR_FLAG_20000000) { + actor->flags &= ~ACTOR_FLAG_20000000; + return true; + } + + return false; +} + +// Similar to func_800B8500 +s32 func_800B874C(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->actor.flags & ACTOR_FLAG_20000000) || Player_InCsMode(&globalCtx->state) || + (yRange < fabsf(actor->playerHeightRel)) || ((player->unk_A94 < actor->xzDistToPlayer)) || + (xzRange < actor->xzDistToPlayer)) { + return false; + } + + player->unk_A90 = actor; + player->unk_A94 = actor->xzDistToPlayer; + return true; +} + +s32 func_800B8804(Actor* actor, GlobalContext* globalCtx, f32 xzRange) { + return func_800B874C(actor, globalCtx, xzRange, 20.0f); +} + +s32 func_800B882C(Actor* actor, GlobalContext* globalCtx) { + f32 cylRadius = actor->colChkInfo.cylRadius + 50.0f; + + return func_800B8804(actor, globalCtx, cylRadius); +} + +s32 func_800B886C(Actor* actor, GlobalContext* globalCtx) { + if (!(GET_PLAYER(globalCtx)->actor.flags & ACTOR_FLAG_20000000)) { + return true; + } + + return false; +} + +void Actor_GetScreenPos(GlobalContext* globalCtx, Actor* actor, s16* x, s16* y) { + Vec3f projectedPos; + f32 w; + + Actor_GetProjectedPos(globalCtx, &actor->focus.pos, &projectedPos, &w); + *x = (projectedPos.x * w * (SCREEN_WIDTH / 2)) + (SCREEN_WIDTH / 2); + *y = (projectedPos.y * w * -(SCREEN_HEIGHT / 2)) + (SCREEN_HEIGHT / 2); +} + +s32 func_800B8934(GlobalContext* globalCtx, Actor* actor) { + Vec3f sp2C; + f32 sp28; + s32 pad[2]; + + Actor_GetProjectedPos(globalCtx, &actor->focus.pos, &sp2C, &sp28); + + return (sp2C.x * sp28 >= -1.0f) && (sp2C.x * sp28 <= 1.0f) && (sp2C.y * sp28 >= -1.0f) && (sp2C.y * sp28 <= 1.0f); +} + +s32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { if (actor->parent != NULL) { return true; } else { @@ -629,119 +1991,1126 @@ u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8A1C.s") +/** + * Allows to pick up an item (GetItem or GI), lift an actor or catch various actors in bottles + * within the specified range. + * + * GI_NONE is usually used as a special case to lift an actor + * GI_MAX is usually used to catch an actor in a bottle + */ +s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRange, f32 yRange) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8B84.s") + if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { + if ((actor->xzDistToPlayer <= xzRange) && (fabsf(actor->playerHeightRel) <= fabsf(yRange))) { + if (((getItemId == GI_MASK_CIRCUS_LEADER) || (getItemId == GI_PENDANT_OF_MEMORIES) || + (getItemId == GI_DEED_LAND) || + (((player->heldActor != NULL) || (actor == player->targetActor)) && + (getItemId > GI_NONE && getItemId < GI_MAX))) || + (!(player->stateFlags1 & 0x20000800))) { + s16 yawDiff = actor->yawTowardsPlayer - player->actor.shape.rot.y; + s32 absYawDiff = ABS_ALT(yawDiff); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8BB0.s") + if ((getItemId != GI_NONE) || (player->getItemDirection < absYawDiff)) { + player->getItemId = getItemId; + player->interactRangeActor = actor; + player->getItemDirection = absYawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8BD0.s") + if ((getItemId > GI_NONE) && (getItemId < GI_MAX)) { + ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[1]); + } + + return true; + } + } + } + } + + return false; +} + +s32 Actor_PickUpNearby(Actor* actor, GlobalContext* globalCtx, s32 getItemId) { + return Actor_PickUp(actor, globalCtx, getItemId, 50.0f, 10.0f); +} + +s32 Actor_LiftActor(Actor* actor, GlobalContext* globalCtx) { + return Actor_PickUpNearby(actor, globalCtx, GI_NONE); +} + +s32 Actor_PickUpFar(Actor* actor, GlobalContext* globalCtx, s32 getItemId) { + return Actor_PickUp(actor, globalCtx, getItemId, 9999.9f, 9999.9f); +} s32 Actor_HasNoParent(Actor* actor, GlobalContext* globalCtx) { - if (!actor->parent) { + if (actor->parent == NULL) { return true; - } else { - return false; + } + + return false; +} + +void func_800B8C20(Actor* actorA, Actor* actorB, GlobalContext* globalCtx) { + Actor* parent = actorA->parent; + + if (parent->id == ACTOR_PLAYER) { + Player* player = (Player*)parent; + + player->heldActor = actorB; + player->interactRangeActor = actorB; + } + + parent->child = actorB; + actorB->parent = parent; + actorA->parent = NULL; +} + +void func_800B8C50(Actor* actor, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (actor->xyzDistToPlayerSq < player->unk_AA0) { + player->unk_AA0 = actor->xyzDistToPlayerSq; } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8C20.s") +s32 Actor_HasRider(GlobalContext* globalCtx, Actor* horse) { + if (horse->child != NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8C50.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8C78.s") +s32 Actor_SetRideActor(GlobalContext* globalCtx, Actor* horse, s32 mountSide) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8C9C.s") + if (!(player->stateFlags1 & 0x003C7880)) { + player->rideActor = horse; + player->mountSide = mountSide; + ActorCutscene_SetIntentToPlay(0x7C); + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8CEC.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8D10.s") +s32 Actor_HasNoRider(GlobalContext* globalCtx, Actor* horse) { + if (horse->child == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8D50.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8D98.s") +void func_800B8D10(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5, u32 arg6) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8DD4.s") + player->unk_B74 = arg6; + player->unk_B75 = arg5; + player->unk_B78 = arg2; + player->unk_B76 = arg3; + player->unk_B7C = arg4; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8E1C.s") +void func_800B8D50(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 yaw, f32 arg4, u32 arg5) { + func_800B8D10(globalCtx, actor, arg2, yaw, arg4, 3, arg5); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8E58.s") +void func_800B8D98(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4) { + func_800B8D50(globalCtx, actor, arg2, arg3, arg4, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Audio_PlayActorSound2.s") +void func_800B8DD4(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5) { + func_800B8D10(globalCtx, actor, arg2, arg3, arg4, 2, arg5); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8EF4.s") +void func_800B8E1C(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4) { + func_800B8DD4(globalCtx, actor, arg2, arg3, arg4, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8F98.s") +void func_800B8E58(Player* player, u16 sfxId) { + if (player->currentMask == PLAYER_MASK_GIANT) { + func_8019F170(&player->actor.projectedPos, sfxId); + } else { + Audio_PlaySfxGeneral(sfxId, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8FC0.s") +/** + * Plays the sound effect at the actor's position + */ +void Actor_PlaySfxAtPos(Actor* actor, u16 sfxId) { + Audio_PlaySfxAtPos(&actor->projectedPos, sfxId); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8FE8.s") +void func_800B8EF4(GlobalContext* globalCtx, Actor* actor) { + u32 sfxId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9010.s") + if (actor->bgCheckFlags & 0x20) { + if (actor->depthInWater < 20.0f) { + sfxId = NA_SE_PL_WALK_WATER0 - SFX_FLAG; + } else { + sfxId = NA_SE_PL_WALK_WATER1 - SFX_FLAG; + } + } else { + sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, actor->floorPoly, actor->floorBgId); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9038.s") + Audio_PlaySfxAtPos(&actor->projectedPos, NA_SE_EV_BOMB_BOUND); + Audio_PlaySfxAtPos(&actor->projectedPos, sfxId + SFX_FLAG); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9084.s") +void func_800B8F98(Actor* actor, u16 sfxId) { + actor->sfxId = sfxId; + actor->audioFlags &= ~(0x10 | 0x08 | 0x04 | 0x02 | 0x01); + actor->audioFlags |= 0x02; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9098.s") +void func_800B8FC0(Actor* actor, u16 sfxId) { + actor->sfxId = sfxId; + actor->audioFlags &= ~(0x10 | 0x08 | 0x04 | 0x02 | 0x01); + actor->audioFlags |= 4; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B90AC.s") +void func_800B8FE8(Actor* actor, u16 sfxId) { + actor->sfxId = sfxId; + actor->audioFlags &= ~(0x10 | 0x08 | 0x04 | 0x02 | 0x01); + actor->audioFlags |= 0x08; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B90F4.s") +void func_800B9010(Actor* actor, u16 sfxId) { + actor->sfxId = sfxId; + actor->audioFlags &= ~(0x10 | 0x08 | 0x04 | 0x02 | 0x01); + actor->audioFlags |= 0x01; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9120.s") +void func_800B9038(Actor* actor, s32 timer) { + actor->audioFlags &= ~(0x10 | 0x08 | 0x04 | 0x02 | 0x01); + actor->audioFlags |= 0x10; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_Init.s") + // The sfxId here are not actually sound effects, but instead this is data that gets sent into + // the io ports of the music macro language (func_801A0810 / Audio_PlaySfxAtPosWithSoundScriptIO is + // the function that it's used for) + if (timer < 40) { + actor->sfxId = 3; + } else if (timer < 100) { + actor->sfxId = 2; + } else { + actor->sfxId = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9334.s") +void func_800B9084(Actor* actor) { + actor->audioFlags |= 0x20; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_UpdateActor.s") +void func_800B9098(Actor* actor) { + actor->audioFlags |= 0x40; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_UpdateAll.s") +s32 func_800B90AC(GlobalContext* globalCtx, Actor* actor, CollisionPoly* polygon, s32 index, s32 arg4) { + if (func_800C99D4(&globalCtx->colCtx, polygon, index) == 8) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_DrawActor.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9D1C.s") +void func_800B90F4(GlobalContext* globalCtx) { + if (globalCtx->actorCtx.unk3 != 0) { + globalCtx->actorCtx.unk3 = 0; + func_80115D5C(&globalCtx->state); + } +} + +void func_800B9120(ActorContext* actorCtx) { + s32 phi_v0 = CURRENT_DAY * 2; + + if (gSaveContext.time < CLOCK_TIME(6, 0) || gSaveContext.time > CLOCK_TIME(18, 0)) { + phi_v0++; + } + + actorCtx->unkC = 0x200 >> phi_v0; +} + +void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry* actorEntry) { + ActorOverlay* overlayEntry; + u32* cycleFlags; + s32 i; + + gSaveContext.weekEventReg[92] |= 0x80; + cycleFlags = gSaveContext.cycleSceneFlags[convert_scene_number_among_shared_scenes(globalCtx->sceneNum)]; + + bzero(actorCtx, sizeof(ActorContext)); + ActorOverlayTable_Init(); + Matrix_MtxFCopy(&globalCtx->billboardMtxF, &gIdentityMtxF); + Matrix_MtxFCopy(&globalCtx->viewProjectionMtxF, &gIdentityMtxF); + + overlayEntry = gActorOverlayTable; + for (i = 0; i < ARRAY_COUNT(gActorOverlayTable); i++) { + overlayEntry->loadedRamAddr = NULL; + overlayEntry->numLoaded = 0; + overlayEntry++; + } + + actorCtx->flags.chest = cycleFlags[0]; + actorCtx->flags.switches[0] = cycleFlags[1]; + actorCtx->flags.switches[1] = cycleFlags[2]; + if (globalCtx->sceneNum == SCENE_INISIE_R) { + cycleFlags = gSaveContext.cycleSceneFlags[globalCtx->sceneNum]; + } + actorCtx->flags.collectible[0] = cycleFlags[4]; + actorCtx->flags.clearedRoom = cycleFlags[3]; + + TitleCard_ContextInit(&globalCtx->state, &actorCtx->titleCtxt); + func_800B6468(globalCtx); + + actorCtx->absoluteSpace = NULL; + + Actor_SpawnEntry(actorCtx, actorEntry, globalCtx); + Actor_TargetContextInit(&actorCtx->targetContext, actorCtx->actorLists[ACTORCAT_PLAYER].first, globalCtx); + func_800B9120(actorCtx); + Fault_AddClient(&sActorFaultClient, (void*)Actor_PrintLists, actorCtx, NULL); + func_800B722C(&globalCtx->state, (Player*)actorCtx->actorLists[ACTORCAT_PLAYER].first); +} + +/** + * Spawns the actors in the current setup (of the current scene/setup/room triple) + * Only spawns actors based on the time flags embedded in their rotation parameters + */ +void Actor_SpawnSetupActors(GlobalContext* globalCtx, ActorContext* actorCtx) { + if (globalCtx->numSetupActors > 0) { + ActorEntry* actorEntry = globalCtx->setupActorList; + s32 temp_fp = actorCtx->unkC; + s32 temp_s1; + s32 phi_v0; + s32 i; + + func_800B9120(actorCtx); + func_800BA8B8(globalCtx, &globalCtx->actorCtx); + + temp_s1 = (actorCtx->unkC * 2) & 0x2FF; + + for (i = 0; i < globalCtx->numSetupActors; i++) { + phi_v0 = ((actorEntry->rot.x & 7) << 7) | (actorEntry->rot.z & 0x7F); + if (phi_v0 == 0) { + phi_v0 = 0x3FF; + } + + if (!(phi_v0 & temp_fp) && (phi_v0 & actorCtx->unkC) && + (!(gSaveContext.eventInf[1] & 0x80) || !(phi_v0 & temp_s1) || !(actorEntry->id & 0x800))) { + Actor_SpawnEntry(&globalCtx->actorCtx, actorEntry, globalCtx); + } + actorEntry++; + } + + // Prevents re-spawning the setup actors + globalCtx->numSetupActors = -globalCtx->numSetupActors; + } +} + +typedef struct { + /* 0x00 */ GlobalContext* globalCtx; + /* 0x04 */ Actor* actor; + /* 0x08 */ u32 unk_08; + /* 0x0C */ u32 unkC; + /* 0x10 */ Actor* unk10; + /* 0x14 */ Player* player; + /* 0x18 */ u32 unk_18; // Bitmask of actor flags. The actor will only have main called if it has at least 1 + // flag set that matches this bitmask +} UpdateActor_Params; // size = 0x1C + +Actor* Actor_UpdateActor(UpdateActor_Params* params) { + GlobalContext* globalCtx = params->globalCtx; + Actor* actor = params->actor; + Actor* nextActor; + + if (actor->world.pos.y < -25000.0f) { + actor->world.pos.y = -25000.0f; + } + + actor->sfxId = 0; + actor->audioFlags &= ~0x7F; + + if (actor->init != NULL) { + if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { + Actor_SetObjectDependency(globalCtx, actor); + actor->init(actor, globalCtx); + actor->init = NULL; + } + nextActor = actor->next; + } else if (actor->update == NULL) { + if (!actor->isDrawn) { + nextActor = Actor_Delete(&globalCtx->actorCtx, actor, globalCtx); + } else { + Actor_Destroy(actor, globalCtx); + nextActor = actor->next; + } + } else { + if (!Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { + Actor_MarkForDeath(actor); + } else { + s32 tmp = (params->unk_08 == 0); + + if (((params->unk_08) && !(actor->flags & params->unk_08)) || + ((tmp = (params->unk_08 == 0)) && + (!(actor->flags & ACTOR_FLAG_100000) || + ((actor->category == ACTORCAT_EXPLOSIVES) && (params->player->stateFlags1 & 0x200))) && + (params->unkC != 0) && (actor != params->unk10) && ((actor != params->player->heldActor)) && + (actor->parent != ¶ms->player->actor))) { + CollisionCheck_ResetDamage(&actor->colChkInfo); + } else { + Math_Vec3f_Copy(&actor->prevPos, &actor->world.pos); + actor->xzDistToPlayer = Actor_XZDistanceBetweenActors(actor, ¶ms->player->actor); + actor->playerHeightRel = Actor_HeightDiff(actor, ¶ms->player->actor); + actor->xyzDistToPlayerSq = SQ(actor->xzDistToPlayer) + SQ(actor->playerHeightRel); + + actor->yawTowardsPlayer = Actor_YawBetweenActors(actor, ¶ms->player->actor); + actor->flags &= ~ACTOR_FLAG_1000000; + + if ((DECR(actor->freezeTimer) == 0) && (actor->flags & params->unk_18)) { + if (actor == params->player->unk_730) { + actor->isTargeted = true; + } else { + actor->isTargeted = false; + } + + if ((actor->targetPriority != 0) && (params->player->unk_730 == 0)) { + actor->targetPriority = 0; + } + + Actor_SetObjectDependency(globalCtx, actor); + + if (actor->colorFilterTimer != 0) { + actor->colorFilterTimer--; + } + + actor->update(actor, globalCtx); + BgCheck_ResetFlagsIfLoadedActor(globalCtx, &globalCtx->colCtx.dyna, actor); + } + + CollisionCheck_ResetDamage(&actor->colChkInfo); + } + } + nextActor = actor->next; + } + return nextActor; +} + +u32 D_801AED58[] = { + 0x100002C2, 0x100002C2, 0x00000200, 0x100006C2, 0x00000282, 0x300002C2, + 0x10000282, 0x00000002, 0x300002C2, 0x100006C2, 0x00000002, 0x100002C2, +}; + +void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { + s32 i; + Actor* actor; + Player* player = GET_PLAYER(globalCtx); + u32* tmp; + s32 cat; + Actor* next; + ActorListEntry* entry; + UpdateActor_Params params; + + params.player = player; + params.globalCtx = globalCtx; + + if (globalCtx->unk_18844 != 0) { + params.unk_18 = ACTOR_FLAG_200000; + } else { + params.unk_18 = ACTOR_FLAG_200000 | ACTOR_FLAG_40 | ACTOR_FLAG_10; + } + + Actor_SpawnSetupActors(globalCtx, actorCtx); + + if (actorCtx->unk2 != 0) { + actorCtx->unk2--; + } + + tmp = D_801AED58; + + if (player->stateFlags2 & 0x8000000) { + params.unk_08 = 0x2000000; + } else { + params.unk_08 = 0; + } + + if ((player->stateFlags1 & 0x40) && ((player->actor.textId & 0xFF00) != 0x1900)) { + params.unk10 = player->targetActor; + } else { + params.unk10 = NULL; + } + + for (i = 0, entry = actorCtx->actorLists; i < ARRAY_COUNT(actorCtx->actorLists); entry++, tmp++, i++) { + params.unkC = *tmp & player->stateFlags1; + params.actor = entry->first; + + while (params.actor != NULL) { + params.actor = Actor_UpdateActor(¶ms); + } + + if (i == ACTORCAT_BG) { + DynaPoly_Setup(globalCtx, &globalCtx->colCtx.dyna); + } + } + + for (i = 0, entry = actorCtx->actorLists; i < ARRAY_COUNT(actorCtx->actorLists); entry++, i++) { + if (entry->unk_08 != 0) { + actor = entry->first; + + while (actor != NULL) { + if (i == actor->category) { + actor = actor->next; + } else { + next = actor->next; + cat = actor->category; + actor->category = i; + Actor_RemoveFromCategory(globalCtx, actorCtx, actor); + Actor_AddToCategory(actorCtx, actor, cat); + actor = next; + } + } + entry->unk_08 = 0; + } + } + + actor = player->unk_730; + if ((actor != NULL) && (actor->update == NULL)) { + actor = NULL; + func_80123DA4(player); + } + + if ((actor == NULL) || (player->unk_738 < 5)) { + actor = NULL; + if (actorCtx->targetContext.unk4B != 0) { + actorCtx->targetContext.unk4B = 0; + play_sound(NA_SE_SY_LOCK_OFF); + } + } + + if (!(player->stateFlags1 & 2)) { + func_800B5814(&actorCtx->targetContext, player, actor, &globalCtx->state); + } + + TitleCard_Update(&globalCtx->state, &actorCtx->titleCtxt); + func_800B6474(globalCtx); + DynaPoly_UpdateBgActorTransforms(globalCtx, &globalCtx->colCtx.dyna); +} + +void Actor_Draw(GlobalContext* globalCtx, Actor* actor) { + Lights* light; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + light = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx); + if ((actor->flags & ACTOR_FLAG_10000000) && (globalCtx->roomCtx.currRoom.enablePosLights || (MREG(93) != 0))) { + light->enablePosLights = true; + } + + Lights_BindAll(light, globalCtx->lightCtx.listHead, + (actor->flags & (ACTOR_FLAG_10000000 | ACTOR_FLAG_400000)) ? NULL : &actor->world.pos, globalCtx); + Lights_Draw(light, globalCtx->state.gfxCtx); + + if (actor->flags & ACTOR_FLAG_1000) { + Matrix_SetStateRotationAndTranslation( + actor->world.pos.x + globalCtx->mainCamera.skyboxOffset.x, + actor->world.pos.y + ((actor->shape.yOffset * actor->scale.y) + globalCtx->mainCamera.skyboxOffset.y), + actor->world.pos.z + globalCtx->mainCamera.skyboxOffset.z, &actor->shape.rot); + } else { + Matrix_SetStateRotationAndTranslation(actor->world.pos.x, + actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), + actor->world.pos.z, &actor->shape.rot); + } + + Matrix_Scale(actor->scale.x, actor->scale.y, actor->scale.z, MTXMODE_APPLY); + Actor_SetObjectDependency(globalCtx, actor); + + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[actor->objBankIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[actor->objBankIndex].segment); + + if (actor->colorFilterTimer != 0) { + s32 temp_v0_2 = actor->colorFilterParams & 0xC000; + Color_RGBA8 actorDefaultHitColor = { 0, 0, 0, 255 }; + + if (temp_v0_2 == 0x8000) { + actorDefaultHitColor.r = actorDefaultHitColor.g = actorDefaultHitColor.b = + ((actor->colorFilterParams & 0x1F00) >> 5) | 7; + } else if (temp_v0_2 == 0x4000) { + actorDefaultHitColor.r = ((actor->colorFilterParams & 0x1F00) >> 5) | 7; + } else if (temp_v0_2 == 0xC000) { + actorDefaultHitColor.b = actorDefaultHitColor.g = actorDefaultHitColor.r = 0; + } else { + actorDefaultHitColor.b = ((actor->colorFilterParams & 0x1F00) >> 5) | 7; + } + + if (actor->colorFilterParams & 0x2000) { + func_800AE778(globalCtx, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); + } else { + func_800AE434(globalCtx, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); + } + } + + actor->draw(actor, globalCtx); + + if (actor->colorFilterTimer != 0) { + if (actor->colorFilterParams & 0x2000) { + func_800AE8EC(globalCtx); + } else { + func_800AE5A0(globalCtx); + } + } + + if (actor->shape.shadowDraw != NULL) { + actor->shape.shadowDraw(actor, light, globalCtx); + } + actor->isDrawn = true; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_800B9D1C(Actor* actor) { + s32 sfxId = actor->sfxId; + + if (sfxId != 0) { + if (actor->audioFlags & 2) { + Audio_PlaySfxGeneral(sfxId, &actor->projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); + } else if (actor->audioFlags & 4) { + play_sound(sfxId); + } else if (actor->audioFlags & 8) { + func_8019F128(sfxId); + } else if (actor->audioFlags & 0x10) { + func_801A0810(&D_801DB4A4, NA_SE_SY_TIMER - SFX_FLAG, (sfxId - 1)); + } else if (actor->audioFlags & 1) { + Audio_PlaySfxAtPos(&actor->projectedPos, sfxId); + } + } + + if (sfxId) {} + + if (actor->audioFlags & 0x40) { + func_801A1FB4(3, &actor->projectedPos, NA_BGM_MUSIC_BOX_HOUSE, 1500.0f); + } + + if (actor->audioFlags & 0x20) { + func_801A1FB4(0, &actor->projectedPos, NA_BGM_KAMARO_DANCE, 900.0f); + } +} void Actor_DrawAllSetup(GlobalContext* globalCtx) { globalCtx->actorCtx.undrawnActorCount = 0; globalCtx->actorCtx.unkB = 0; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_RecordUndrawnActor.s") +s32 Actor_RecordUndrawnActor(GlobalContext* globalCtx, Actor* actor) { + if (globalCtx->actorCtx.undrawnActorCount >= 32) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9E84.s") + globalCtx->actorCtx.undrawnActors[globalCtx->actorCtx.undrawnActorCount] = actor; + globalCtx->actorCtx.undrawnActorCount++; + return true; +} +void func_800B9E84(Gfx** arg0, s32 arg1) { + func_80164C14(arg0, D_801DE890, 4, 0, 6, 6, ((100 - arg1) * 0.003f) + 1.0f); +} + +#ifdef NON_EQUIVALENT +// Related to draw actors with lens +void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) { + s32 spB4; + Gfx* spAC; + void* spA8; // pad + s32 spA4; + // void* sp34; + // Gfx* temp_s1_11; + // Gfx** temp_a0_2; + // Gfx** temp_a1; + // GraphicsContext* temp_s2; + // void* temp_s1_10; + // void* temp_s1_7; + // void* temp_s1_8; + // void* temp_s1_9; + // Gfx* phi_s1; + Gfx* phi_s1_2; + // void* phi_s1_4; + + OPEN_DISPS(globalCtx->state.gfxCtx); + // temp_s2 = globalCtx->state.gfxCtx; + + if (numActors > 0) { + spAC = POLY_XLU_DISP; + // sp34 = globalCtx + 0x18000; + spA4 = globalCtx->unk_18E68; + + PreRender_SetValues(&globalCtx->pauseBgPreRender, D_801FBBCC, D_801FBBCE, __gfxCtx->curFrameBuffer, + __gfxCtx->zbuffer); + + func_80170200(&globalCtx->pauseBgPreRender, &spAC, __gfxCtx->zbuffer, (void*)spA4); + + // spAC->words.w0 = 0xE7000000; + // spAC->words.w1 = 0; + // temp_s1_2 = spAC + 8; + gDPPipeSync(spAC++); + + // temp_s1_2->words.w0 = 0xEE000000; + // temp_s1_2->words.w1 = 0; + // temp_s1_3 = temp_s1_2 + 8; + gDPSetPrimDepth(spAC++, 0, 0); + + // temp_s1_3->words.w0 = 0xEF002C30; + // temp_s1_3->words.w1 = 0xAF504365; + // temp_s1_4 = temp_s1_3 + 8; + gDPSetOtherMode(spAC++, + G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_THRESHOLD | G_ZS_PRIM | Z_UPD | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | + GBL_c1(G_BL_CLR_BL, G_BL_0, G_BL_CLR_MEM, G_BL_1MA) | + GBL_c2(G_BL_CLR_BL, G_BL_0, G_BL_CLR_MEM, G_BL_1MA)); + + // temp_s1_4->words.w1 = 0xFF; + // temp_s1_4->words.w0 = 0xFA000000; + // temp_s1_5 = temp_s1_4 + 8; + gDPSetPrimColor(spAC++, 0, 0, 0, 0, 0, 255); + // temp_s1_5 = spAC; + + if (globalCtx->roomCtx.currRoom.unk5 == 0) { + // temp_s1_5->words.w0 = 0xFC61E6C3; + // temp_s1_5->words.w1 = 0x11CF9FCF; + // phi_s1 = temp_s1_5 + 8; + gDPSetCombineLERP(spAC++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, + TEXEL0, PRIMITIVE, 0); + } else { + // temp_s1_5->words.w0 = 0xFC119623; + // temp_s1_5->words.w1 = 0xFF2FFFFF; + // phi_s1 = temp_s1_5 + 8; + gDPSetCombineMode(spAC++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + } + + // spAC = phi_s1; + func_800B9E84(&spAC, globalCtx->actorCtx.unk4); + phi_s1_2 = func_801660B8(globalCtx, spAC); + + for (spB4 = 0; spB4 < numActors; spB4++, actors++) { + Actor_Draw(globalCtx, *actors); + } + + // temp_s0_2 = &globalCtx->pauseBgPreRender; + + // phi_s1_2->words.w0 = 0xE7000000; + // phi_s1_2->words.w1 = 0; + // temp_s1_7 = phi_s1_2 + 8; + gDPPipeSync(phi_s1_2++); + + // temp_s1_7->unk_0 = 0xEF002CF0; + // temp_s1_7->unk_4 = 0xF5A714D; + // temp_s1_8 = temp_s1_7 + 8; + gDPSetOtherMode(phi_s1_2++, + G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_THRESHOLD | G_ZS_PRIM | AA_EN | IM_RD | CVG_DST_WRAP | ZMODE_OPA | CVG_X_ALPHA | + ALPHA_CVG_SEL | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_1) | + GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_1)); + + // temp_s1_8->unk_4 = -0x100; + // temp_s1_8->unk_0 = 0xF9000000; + // temp_s1_9 = temp_s1_8 + 8; + gDPSetBlendColor(phi_s1_2++, 255, 255, 255, 0); + + // temp_s1_9->unk_4 = 0x20; + // temp_s1_9->unk_0 = 0xFA0000FF; + // temp_s1_10 = temp_s1_9 + 8; + gDPSetPrimColor(phi_s1_2++, 0, 0xFF, 0, 0, 0, 32); + + // temp_a0_2 = &spAC; + // if (sp34->unk_6E5 == 0) { + if (globalCtx->roomCtx.currRoom.unk5 == 0) { + // temp_s1_10->unk_0 = 0xFC119623; + // temp_s1_10->unk_4 = 0xFF2FFFFF; + // phi_s1_4 = temp_s1_10 + 8; + gDPSetCombineMode(phi_s1_2++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + //} else { + } else { + // temp_s1_10->unk_4 = 0x11CF9FCF; + // temp_s1_10->unk_0 = 0xFC61E6C3; + // phi_s1_4 = temp_s1_10 + 8; + gDPSetCombineLERP(phi_s1_2++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, + TEXEL0, PRIMITIVE, 0); + + //} + } + // phi_s1_4->unk_0 = (s32) (((sp34->unk_B4C - 1) & 0xFFF) | 0xFF100000); + // temp_s1_11 = phi_s1_4 + 8; + // phi_s1_4->unk_4 = spA4; + gDPSetColorImage(phi_s1_2++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((globalCtx->pauseBgPreRender.width - 1) & 0xFFF), + spA4); + // temp_s1_11 = phi_s1_2; + + spAC = phi_s1_2; + + // spAC = temp_s1_11; + func_800B9E84(&spAC, (s32)globalCtx->actorCtx.unk4); + // temp_s1_11->words.w0 = 0xE7000000; + // temp_s1_11->words.w1 = 0; + // temp_s1_12 = temp_s1_11 + 8; + gDPPipeSync(spAC++); + + // temp_s1_12->words.w1 = -0xF8; + // temp_s1_12->words.w0 = 0xF9000000; + // temp_s1_13 = temp_s1_12 + 8; + gDPSetBlendColor(spAC++, 255, 255, 255, 8); + + // temp_s1_14 = temp_s1_13 + 8; + // temp_s1_13->words.w0 = ((sp34->unk_B4C - 1) & 0xFFF) | 0xFF100000; + // temp_s1_13->words.w1 = sp34->unk_B5C; + gDPSetColorImage(spAC++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((globalCtx->pauseBgPreRender.width - 1) & 0xFFF), + globalCtx->pauseBgPreRender.fbuf); + + // temp_a1 = &spAC; + // spAC = temp_s1_14; + // func_8016FDB8(&globalCtx->pauseBgPreRender, temp_a1, (void* ) spA4, spA8, 1U); + func_8016FDB8(&globalCtx->pauseBgPreRender, &spAC, (void*)spA4, __gfxCtx->zbuffer, 1U); + // + // POLY_OPA_DISP = temp_s1_14; + POLY_OPA_DISP = spAC; + } + + // temp_s1_15 = OVERLAY_DISP; + // temp_s1_15->words.w0 = 0xE7000000; + // temp_s1_15->words.w1 = 0; + // temp_s1_16 = temp_s1_15 + 8; + spAC = OVERLAY_DISP; + gDPPipeSync(spAC++); + + // temp_s1_16->words.w0 = 0xEF002C30; + // temp_s1_16->words.w1 = 0x00504345; + // temp_s1_17 = temp_s1_16 + 8; + gDPSetOtherMode(spAC++, + G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_THRESHOLD | G_ZS_PRIM | G_RM_CLD_SURF | G_RM_CLD_SURF2); + + // temp_s1_17->words.w0 = 0xFC61E6C3; + // temp_s1_17->words.w1 = 0x11CF9FCF; + // temp_s1_18 = temp_s1_17 + 8; + gDPSetCombineLERP(spAC++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, + PRIMITIVE, 0); + + // temp_s1_18->words.w0 = 0xFA000000; + // temp_s1_18->words.w1 = 0x4A00004A; + // spAC = temp_s1_18 + 8; + gDPSetPrimColor(spAC++, 0, 0, 74, 0, 0, 74); + + func_800B9E84(&spAC, (s32)globalCtx->actorCtx.unk4); + + OVERLAY_DISP = spAC; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} +#else +void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors); #pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9EF4.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BA2D8.s") +s32 func_800BA2D8(GlobalContext* globalCtx, Actor* actor) { + return func_800BA2FC(globalCtx, actor, &actor->projectedPos, actor->projectedW); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BA2FC.s") +s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* projectedPos, f32 projectedW) { + if ((-actor->uncullZoneScale < projectedPos->z) && + (projectedPos->z < (actor->uncullZoneForward + actor->uncullZoneScale))) { + f32 phi_f12; + f32 phi_f2 = CLAMP_MIN(projectedW, 1.0f); + f32 phi_f14; + f32 phi_f16; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_DrawAll.s") + if (globalCtx->view.fovy != 60.0f) { + phi_f12 = actor->uncullZoneScale * globalCtx->unk_187F0.x * 0.76980036f; // sqrt(16/27) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BA6FC.s") + phi_f14 = globalCtx->unk_187F0.y * 0.57735026f; // 1 / sqrt(3) + phi_f16 = actor->uncullZoneScale * phi_f14; + phi_f14 *= actor->uncullZoneDownward; + } else { + phi_f16 = phi_f12 = actor->uncullZoneScale; + phi_f14 = actor->uncullZoneDownward; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BA798.s") + if (((fabsf(projectedPos->x) - phi_f12) < phi_f2) && ((-phi_f2 < (projectedPos->y + phi_f14))) && + ((projectedPos->y - phi_f16) < phi_f2)) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BA8B8.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BA9B4.s") +void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx) { + s32 pad[2]; + Gfx* ref2; + Gfx* tmp2; + s32 pad2; + Gfx* sp58; + ActorListEntry* actorEntry; + Actor* actor; + s32 actorFlags; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_InsertIntoTypeList.s") + if (globalCtx->unk_18844 != 0) { + actorFlags = ACTOR_FLAG_200000; + } else { + actorFlags = ACTOR_FLAG_200000 | ACTOR_FLAG_40 | ACTOR_FLAG_20; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_RemoveFromTypeList.s") + OPEN_DISPS(globalCtx->state.gfxCtx); + + Actor_DrawAllSetup(globalCtx); + + sp58 = POLY_XLU_DISP; + POLY_XLU_DISP = &sp58[1]; + + for (i = 0, actorEntry = actorCtx->actorLists; i < ARRAY_COUNT(actorCtx->actorLists); i++, actorEntry++) { + actor = actorEntry->first; + + while (actor != NULL) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &actor->world.pos, &actor->projectedPos, + &actor->projectedW); + + if (actor->audioFlags & 0x7F) { + func_800B9D1C(actor); + } + + if (func_800BA2D8(globalCtx, actor)) { + actor->flags |= ACTOR_FLAG_40; + } else { + actor->flags &= ~ACTOR_FLAG_40; + } + + actor->isDrawn = false; + if ((actor->init == NULL) && (actor->draw != NULL) && (actor->flags & actorFlags)) { + if ((actor->flags & ACTOR_FLAG_80) && + ((globalCtx->roomCtx.currRoom.unk5 == 0) || (globalCtx->actorCtx.unk4 == 0x64) || + (actor->room != globalCtx->roomCtx.currRoom.num))) { + if (Actor_RecordUndrawnActor(globalCtx, actor)) {} + } else { + Actor_Draw(globalCtx, actor); + } + } + + actor = actor->next; + } + } + + Effect_DrawAll(globalCtx->state.gfxCtx); + EffectSS_DrawAllParticles(globalCtx); + EffFootmark_Draw(globalCtx); + + ref2 = POLY_XLU_DISP; + gSPDisplayList(sp58, &ref2[1]); + POLY_XLU_DISP = &ref2[1]; + + if (globalCtx->actorCtx.unk3 != 0) { + Math_StepToC(&globalCtx->actorCtx.unk4, 100, 20); + if (GET_PLAYER(globalCtx)->stateFlags2 & 0x8000000) { + func_800B90F4(globalCtx); + } + } else { + Math_StepToC(&globalCtx->actorCtx.unk4, 0, 10); + } + if (globalCtx->actorCtx.unk4 != 0) { + globalCtx->actorCtx.unkB = 1; + func_800B9EF4(globalCtx, globalCtx->actorCtx.undrawnActorCount, globalCtx->actorCtx.undrawnActors); + } + + tmp2 = POLY_XLU_DISP; + gSPEndDisplayList(&tmp2[0]); + gSPBranchList(ref2, &tmp2[1]); + POLY_XLU_DISP = &tmp2[1]; + + if (globalCtx->unk_18844 == 0) { + Lights_DrawGlow(globalCtx); + } + + TitleCard_Draw(&globalCtx->state, &actorCtx->titleCtxt); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +/** + * Kills every actor which its object is not loaded + */ +void func_800BA6FC(GlobalContext* globalCtx, ActorContext* actorCtx) { + Actor* actor; + s32 i; + + for (i = 0; i != ARRAY_COUNT(actorCtx->actorLists); i++) { + actor = actorCtx->actorLists[i].first; + + while (actor != NULL) { + if (!Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { + Actor_MarkForDeath(actor); + } + + actor = actor->next; + } + } +} + +/** + * Kill actors on room change and update flags accordingly + */ +void func_800BA798(GlobalContext* globalCtx, ActorContext* actorCtx) { + Actor* actor; + s32 i; + + for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { + actor = actorCtx->actorLists[i].first; + + while (actor != NULL) { + if ((actor->room >= 0) && (actor->room != globalCtx->roomCtx.currRoom.num) && + (actor->room != globalCtx->roomCtx.prevRoom.num)) { + if (!actor->isDrawn) { + actor = Actor_Delete(actorCtx, actor, globalCtx); + } else { + Actor_MarkForDeath(actor); + Actor_Destroy(actor, globalCtx); + actor = actor->next; + } + } else { + actor = actor->next; + } + } + } + + CollisionCheck_ClearContext(globalCtx, &globalCtx->colChkCtx); + actorCtx->flags.clearedRoomTemp = 0; + actorCtx->flags.switches[3] = 0; + actorCtx->flags.collectible[3] = 0; + globalCtx->msgCtx.unk_12030 = 0; +} + +void func_800BA8B8(GlobalContext* globalCtx, ActorContext* actorCtx) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { + Actor* actor = actorCtx->actorLists[i].first; + + while (actor != NULL) { + if (!(actor->unk20 & actorCtx->unkC)) { + func_80123590(globalCtx, actor); + if (!actor->isDrawn) { + actor = Actor_Delete(actorCtx, actor, globalCtx); + } else { + Actor_MarkForDeath(actor); + Actor_Destroy(actor, globalCtx); + actor = actor->next; + } + } else { + actor = actor->next; + } + } + } + + CollisionCheck_ClearContext(globalCtx, &globalCtx->colChkCtx); + globalCtx->msgCtx.unk_12030 = 0; +} + +void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx) { + s32 i; + + Fault_RemoveClient(&sActorFaultClient); + + for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { + if (i != ACTORCAT_PLAYER) { + Actor* actor = actorCtx->actorLists[i].first; + + while (actor != NULL) { + Actor_Delete(actorCtx, actor, globalCtx); + actor = actorCtx->actorLists[i].first; + } + } + } + + while (actorCtx->actorLists[ACTORCAT_PLAYER].first != NULL) { + Actor_Delete(actorCtx, actorCtx->actorLists[ACTORCAT_PLAYER].first, globalCtx); + } + + if (actorCtx->absoluteSpace != NULL) { + ZeldaArena_Free(actorCtx->absoluteSpace); + actorCtx->absoluteSpace = NULL; + } + + func_80169D40(globalCtx); + ActorOverlayTable_Cleanup(); +} + +/** + * Adds a given actor instance at the front of the actor list of the specified category. + * Also sets the actor instance as being of that category. + */ +void Actor_AddToCategory(ActorContext* actorCtx, Actor* actor, u8 actorCategory) { + Actor* actorAux; + Actor* lastActor; + + actor->category = actorCategory; + + actorCtx->totalLoadedActors++; + actorCtx->actorLists[actorCategory].length++; + lastActor = actorCtx->actorLists[actorCategory].first; + + if (lastActor == NULL) { + actorCtx->actorLists[actorCategory].first = actor; + return; + } + + actorAux = lastActor->next; + while (actorAux != NULL) { + lastActor = actorAux; + actorAux = actorAux->next; + } + + lastActor->next = actor; + actor->prev = lastActor; +} + +/** + * Removes a given actor instance from its actor list. + * Also sets the temp clear flag of the current room if the actor removed was the last enemy loaded. + */ +Actor* Actor_RemoveFromCategory(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actorToRemove) { + Actor* newHead; + + actorCtx->totalLoadedActors--; + actorCtx->actorLists[actorToRemove->category].length--; + + if (actorToRemove->prev != NULL) { + actorToRemove->prev->next = actorToRemove->next; + } else { + actorCtx->actorLists[actorToRemove->category].first = actorToRemove->next; + } + + newHead = actorToRemove->next; + + if (newHead != NULL) { + newHead->prev = actorToRemove->prev; + } + + actorToRemove->next = NULL; + actorToRemove->prev = NULL; + + if ((actorToRemove->room == globalCtx->roomCtx.currRoom.num) && (actorToRemove->category == ACTORCAT_ENEMY) && + (actorCtx->actorLists[ACTORCAT_ENEMY].length == 0)) { + Flags_SetClearTemp(globalCtx, globalCtx->roomCtx.currRoom.num); + } + + return newHead; +} void Actor_FreeOverlay(ActorOverlay* entry) { - void* ramAddr; - if (entry->numLoaded == 0) { - ramAddr = entry->loadedRamAddr; + void* ramAddr = entry->loadedRamAddr; + if (ramAddr != NULL) { - // Bit 1 - always loaded - if ((entry->allocType & 2) == 0) { - // Bit 0 - don't alloc memory - if ((entry->allocType & 1) != 0) { + if (!(entry->allocType & ALLOCTYPE_PERMANENT)) { + if (entry->allocType & ALLOCTYPE_ABSOLUTE) { entry->loadedRamAddr = NULL; } else { ZeldaArena_Free(ramAddr); @@ -752,115 +3121,1183 @@ void Actor_FreeOverlay(ActorOverlay* entry) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_Spawn.s") +Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ, + s16 rotX, s16 rotY, s16 rotZ, s32 params) { + return Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1, + 0x3FF, NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_LoadOverlay.s") +ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index) { + size_t overlaySize; + ActorOverlay* overlayEntry = &gActorOverlayTable[index]; + ActorInit* actorInit; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_SpawnAsChildAndCutscene.s") + overlaySize = VRAM_PTR_SIZE(overlayEntry); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_SpawnAsChild.s") + if (overlayEntry->vramStart == NULL) { + actorInit = overlayEntry->initInfo; + } else { + if (overlayEntry->loadedRamAddr == NULL) { + if (overlayEntry->allocType & ALLOCTYPE_ABSOLUTE) { + if (actorCtx->absoluteSpace == NULL) { + actorCtx->absoluteSpace = ZeldaArena_MallocR(AM_FIELD_SIZE); + } + gActorOverlayTable[index].loadedRamAddr = actorCtx->absoluteSpace; + } else if (overlayEntry->allocType & ALLOCTYPE_PERMANENT) { + gActorOverlayTable[index].loadedRamAddr = ZeldaArena_MallocR(overlaySize); + } else { + gActorOverlayTable[index].loadedRamAddr = ZeldaArena_Malloc(overlaySize); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_SpawnTransitionActors.s") + if (overlayEntry->loadedRamAddr == NULL) { + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BB2D0.s") + Load2_LoadOverlay(overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart, + overlayEntry->vramEnd, overlayEntry->loadedRamAddr); + overlayEntry->numLoaded = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BB498.s") + actorInit = + (uintptr_t)((overlayEntry->initInfo != NULL) + ? (void*)(-OVERLAY_RELOCATION_OFFSET(overlayEntry) + (uintptr_t)overlayEntry->initInfo) + : NULL); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BB59C.s") + return actorInit; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BB604.s") +Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, + s16 rotX, s16 rotY, s16 rotZ, s32 params, u32 cutscene, s32 arg11, Actor* parent) { + s32 pad; + Actor* actor; + ActorInit* actorInit; + s32 objBankIndex; + ActorOverlay* overlayEntry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BB8EC.s") + if (actorCtx->totalLoadedActors >= 0xFF) { + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Enemy_StartFinishingBlow.s") + actorInit = Actor_LoadOverlay(actorCtx, index); + if (actorInit == NULL) { + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BBAC0.s") + objBankIndex = Object_GetIndex(&globalCtx->objectCtx, actorInit->objectId); + if ((objBankIndex < 0) || + ((actorInit->type == ACTORCAT_ENEMY) && Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num) && + (actorInit->id != ACTOR_BOSS_05))) { + Actor_FreeOverlay(&gActorOverlayTable[index]); + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BBB74.s") + actor = ZeldaArena_Malloc(actorInit->instanceSize); + if (actor == NULL) { + Actor_FreeOverlay(&gActorOverlayTable[index]); + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BBC20.s") + overlayEntry = &gActorOverlayTable[index]; + if (overlayEntry->vramStart != 0) { + overlayEntry->numLoaded++; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BBCEC.s") + bzero(actor, actorInit->instanceSize); + actor->overlayEntry = overlayEntry; + actor->id = actorInit->id; + actor->flags = actorInit->flags; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BBDAC.s") + if (actorInit->id == ACTOR_EN_PART) { + actor->objBankIndex = rotZ; + rotZ = 0; + } else { + actor->objBankIndex = objBankIndex; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BBFB0.s") + actor->init = actorInit->init; + actor->destroy = actorInit->destroy; + actor->update = actorInit->update; + actor->draw = actorInit->draw; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC154.s") + if (parent != NULL) { + actor->room = parent->room; + actor->parent = parent; + parent->child = actor; + } else { + actor->room = globalCtx->roomCtx.currRoom.num; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC188.s") + actor->home.pos.x = x; + actor->home.pos.y = y; + actor->home.pos.z = z; + actor->home.rot.x = rotX; + actor->home.rot.y = rotY; + actor->home.rot.z = rotZ; + actor->params = params & 0xFFFF; + actor->cutscene = (cutscene & 0x7F); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC1B4.s") + if (actor->cutscene == 0x7F) { + actor->cutscene = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC270.s") + if (arg11 != 0) { + actor->unk20 = arg11; + } else { + actor->unk20 = 0x3FF; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC444.s") + Actor_AddToCategory(actorCtx, actor, actorInit->type); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC4EC.s") + { + u32 sp20 = gSegments[6]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC5B8.s") + Actor_Init(actor, globalCtx); + gSegments[6] = sp20; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC5EC.s") + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC620.s") +Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, GlobalContext* globalCtx, s16 actorId, f32 posX, + f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params) { + return Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1, + parent->unk20, parent); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC770.s") +void Actor_SpawnTransitionActors(GlobalContext* globalCtx, ActorContext* actorCtx) { + TransitionActorEntry* transitionActorList = globalCtx->doorCtx.transitionActorList; + s32 i; + s16 numTransitionActors = globalCtx->doorCtx.numTransitionActors; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC7D8.s") + for (i = 0; i < numTransitionActors; transitionActorList++, i++) { + if (transitionActorList->id >= 0) { + if ((transitionActorList->sides[0].room >= 0 && + (globalCtx->roomCtx.currRoom.num == transitionActorList->sides[0].room || + globalCtx->roomCtx.prevRoom.num == transitionActorList->sides[0].room)) || + (transitionActorList->sides[1].room >= 0 && + (globalCtx->roomCtx.currRoom.num == transitionActorList->sides[1].room || + globalCtx->roomCtx.prevRoom.num == transitionActorList->sides[1].room))) { + s16 rotY = ((transitionActorList->rotY >> 7) & 0x1FF) * (0x10000 / 360.0f); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC848.s") + if (Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, transitionActorList->id & 0x1FFF, + transitionActorList->pos.x, transitionActorList->pos.y, + transitionActorList->pos.z, 0, rotY, 0, + (i << 0xA) + (transitionActorList->params & 0x3FF), + transitionActorList->rotY & 0x7F, 0x3FF, 0) != NULL) { + transitionActorList->id = -transitionActorList->id; + } + numTransitionActors = globalCtx->doorCtx.numTransitionActors; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC8B8.s") +Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, GlobalContext* globalCtx) { + s16 rotX = (actorEntry->rot.x >> 7) & 0x1FF; + s16 rotY = (actorEntry->rot.y >> 7) & 0x1FF; + s16 rotZ = (actorEntry->rot.z >> 7) & 0x1FF; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BCB50.s") + if (!(actorEntry->id & 0x8000)) { + rotY *= 0x10000 / 360.0f; + } else if (rotY > 180) { + rotY -= 360; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BCB70.s") + if (!(actorEntry->id & 0x4000)) { + rotX *= 0x10000 / 360.0f; + } else if (rotX > 180) { + rotX -= 360; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BCBF4.s") + if (!(actorEntry->id & 0x2000)) { + rotZ *= 0x10000 / 360.0f; + } else if (rotZ > 180) { + rotZ -= 360; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BCC68.s") + return Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, actorEntry->id & 0x1FFF, actorEntry->pos.x, + actorEntry->pos.y, actorEntry->pos.z, rotX, rotY, rotZ, + actorEntry->params & 0xFFFF, actorEntry->rot.y & 0x7F, + ((actorEntry->rot.x & 7) << 7) | (actorEntry->rot.z & 0x7F), NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BCCDC.s") +Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Actor* newHead; + ActorOverlay* overlayEntry = actor->overlayEntry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BD2B4.s") + if ((player != NULL) && (actor == player->unk_730)) { + func_80123DA4(player); + Camera_ChangeMode(Play_GetCamera(globalCtx, Play_GetActiveCameraIndex(globalCtx)), 0); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BD384.s") + if (actor == actorCtx->targetContext.arrowPointedActor) { + actorCtx->targetContext.arrowPointedActor = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BD6B8.s") + if (actor == actorCtx->targetContext.unk8C) { + actorCtx->targetContext.unk8C = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BD6E4.s") + if (actor == actorCtx->targetContext.bgmEnemy) { + actorCtx->targetContext.bgmEnemy = NULL; + } + + Audio_StopSfxByPos(&actor->projectedPos); + Actor_Destroy(actor, globalCtx); + + newHead = Actor_RemoveFromCategory(globalCtx, actorCtx, actor); + ZeldaArena_Free(actor); + + if (overlayEntry->vramStart != NULL) { + overlayEntry->numLoaded--; + Actor_FreeOverlay(overlayEntry); + } + + return newHead; +} + +s32 func_800BB59C(GlobalContext* globalCtx, Actor* actor) { + s16 x; + s16 y; + + Actor_GetScreenPos(globalCtx, actor, &x, &y); + + return (x > -20) && (x < gScreenWidth + 20) && (y > -160) && (y < gScreenHeight + 160); +} + +void func_800BB604(GameState* gameState, ActorContext* actorCtx, Player* player, s32 actorCategory) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + f32 temp_f0_2; + Actor* sp8C; + Actor* actor; + s32 phi_s2; + CollisionPoly* sp80; + s32 sp7C; + Vec3f sp70; + s32 phi_s2_2; + + actor = actorCtx->actorLists[actorCategory].first; + sp8C = player->unk_730; + while (actor != NULL) { + if ((actor->update != NULL) && ((Player*)actor != player)) { + if (actor->flags & (ACTOR_FLAG_40000000 | ACTOR_FLAG_1)) { + if ((actorCategory == ACTORCAT_ENEMY) && CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_4 | ACTOR_FLAG_1)) { + if ((actor->xyzDistToPlayerSq < SQ(500.0f)) && (actor->xyzDistToPlayerSq < sBgmEnemyDistSq)) { + actorCtx->targetContext.bgmEnemy = actor; + sBgmEnemyDistSq = actor->xyzDistToPlayerSq; + } + } + + if ((actor != sp8C) || (actor->flags & ACTOR_FLAG_80000)) { + temp_f0_2 = func_800B82EC(actor, player, D_801ED8DC); + phi_s2_2 = (actor->flags & 1) != 0; + if (phi_s2_2) { + phi_s2_2 = temp_f0_2 < D_801ED8C8; + } + phi_s2 = phi_s2_2; + phi_s2_2 = (actor->flags & ACTOR_FLAG_40000000) != 0; + if (phi_s2_2) { + phi_s2_2 = temp_f0_2 < D_801ED8D0; + } + + if (((phi_s2) || (phi_s2_2)) && (func_800B83BC(actor, temp_f0_2))) { + if (func_800BB59C(globalCtx, actor)) { + if (((!BgCheck_CameraLineTest1(&globalCtx->colCtx, &player->actor.focus.pos, + &actor->focus.pos, &sp70, &sp80, 1, 1, 1, 1, &sp7C)) || + (SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, sp80, sp7C)))) { + if (actor->targetPriority != 0) { + if ((phi_s2 != 0) && (actor->targetPriority < D_801ED8D4)) { + D_801ED8BC = actor; + D_801ED8D4 = actor->targetPriority; + } + if ((phi_s2_2 != 0) && (actor->targetPriority < D_801ED8D8)) { + D_801ED8C4 = actor; + D_801ED8D8 = actor->targetPriority; + } + } else { + if (phi_s2 != 0) { + D_801ED8B8 = actor; + D_801ED8C8 = temp_f0_2; + } + if (phi_s2_2 != 0) { + D_801ED8C0 = actor; + D_801ED8D0 = temp_f0_2; + } + } + } + } + } + } + } + } + + actor = actor->next; + } +} + +u8 D_801AED8C[] = { + ACTORCAT_BOSS, ACTORCAT_ENEMY, ACTORCAT_BG, ACTORCAT_EXPLOSIVES, ACTORCAT_NPC, ACTORCAT_ITEMACTION, + ACTORCAT_CHEST, ACTORCAT_SWITCH, ACTORCAT_PROP, ACTORCAT_MISC, ACTORCAT_DOOR, ACTORCAT_SWITCH, +}; + +void func_800BB8EC(GameState* gameState, ActorContext* actorCtx, Actor** arg2, Actor** arg3, Player* player) { + u8* actorCategories; + s32 i; + + D_801ED8B8 = D_801ED8BC = D_801ED8C0 = D_801ED8C4 = NULL; + D_801ED8C8 = D_801ED8D0 = sBgmEnemyDistSq = FLT_MAX; + D_801ED8D4 = D_801ED8D8 = INT32_MAX; + + actorCtx->targetContext.bgmEnemy = NULL; + D_801ED8DC = player->actor.shape.rot.y; + + actorCategories = D_801AED8C; + + for (i = 0; i < 3; i++) { + func_800BB604(gameState, actorCtx, player, *actorCategories); + actorCategories++; + } + + if (D_801ED8B8 == NULL) { + for (; i < ARRAY_COUNT(D_801AED8C); i++) { + func_800BB604(gameState, actorCtx, player, *actorCategories); + actorCategories++; + } + } + + if (D_801ED8B8 == NULL) { + *arg2 = D_801ED8BC; + } else { + *arg2 = D_801ED8B8; + } + + if (D_801ED8C0 == NULL) { + *arg3 = D_801ED8C4; + } else { + *arg3 = D_801ED8C0; + } +} + +/** + * Play the death sound effect and flash the screen white for 4 frames. + * While the screen flashes, the game freezes. + */ +void Enemy_StartFinishingBlow(GlobalContext* globalCtx, Actor* actor) { + globalCtx->actorCtx.freezeFlashTimer = 5; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &actor->world.pos, 20, NA_SE_EN_LAST_DAMAGE); +} + +// blinking routine +s16 func_800BBAC0(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3) { + if (DECR(arg0[1]) == 0) { + arg0[1] = Rand_S16Offset(arg1, arg2); + } + + if (arg0[1] - arg3 > 0) { + arg0[0] = 0; + } else if ((arg0[1] - arg3 >= -1) || (arg0[1] < 2)) { + arg0[0] = 1; + } else { + arg0[0] = 2; + } + + return arg0[0]; +} + +// blinking routine +s16 func_800BBB74(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3) { + if (DECR(arg0[1]) == 0) { + arg0[1] = Rand_S16Offset(arg1, arg2); + } + + if (arg0[1] - arg3 > 0) { + arg0[0] = 0; + } else if (arg0[1] - arg3 == 0) { + arg0[0] = 1; + } else { + arg0[0] = 2; + } + + return arg0[0]; +} + +// unused blinking routine +s16 func_800BBC20(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3) { + if (DECR(arg0[1]) == 0) { + arg0[1] = Rand_S16Offset(arg1, arg2); + arg0[0]++; + if ((arg0[0] % 3) == 0) { + arg0[0] = (s32)(Rand_ZeroOne() * arg3) * 3; + } + } + return arg0[0]; +} + +void Actor_SpawnBodyParts(Actor* actor, GlobalContext* globalCtx, s32 arg2, Gfx** dList) { + EnPart* part; + Actor* spawnedPart; + MtxF* currentMatrix; + + if (*dList != NULL) { + currentMatrix = Matrix_GetCurrentState(); + spawnedPart = + Actor_SpawnAsChild(&globalCtx->actorCtx, actor, globalCtx, ACTOR_EN_PART, currentMatrix->mf[3][0], + currentMatrix->mf[3][1], currentMatrix->mf[3][2], 0, 0, actor->objBankIndex, arg2); + if (spawnedPart != NULL) { + part = (EnPart*)spawnedPart; + + func_8018219C(currentMatrix, &part->actor.shape.rot, 0); + part->unk_150 = *dList; + Math_Vec3f_Copy(&part->actor.scale, &actor->scale); + } + } +} + +void Actor_SpawnFloorDustRing(GlobalContext* globalCtx, Actor* actor, Vec3f* posXZ, f32 radius, s32 countMinusOne, + f32 randAccelWeight, s16 scale, s16 scaleStep, u8 useLighting) { + Vec3f pos; + Vec3f accel = { 0.0f, 0.3f, 0.0f }; + s32 pad[2]; + f32 angle; + s32 i; + + angle = (Rand_ZeroOne() - 0.5f) * (2.0f * 3.14f); + pos.y = actor->floorHeight; + accel.y += (Rand_ZeroOne() - 0.5f) * 0.2f; + + for (i = countMinusOne; i >= 0; i--) { + pos.x = (sin_rad(angle) * radius) + posXZ->x; + pos.z = (cos_rad(angle) * radius) + posXZ->z; + accel.x = (Rand_ZeroOne() - 0.5f) * randAccelWeight; + accel.z = (Rand_ZeroOne() - 0.5f) * randAccelWeight; + + if (scale == 0) { + func_800B10C0(globalCtx, &pos, &gZeroVec3f, &accel); + } else if (useLighting) { + func_800B1210(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep); + } else { + func_800B11A0(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep); + } + angle += (2.0f * 3.14f) / (countMinusOne + 1.0f); + } +} + +void func_800BBFB0(GlobalContext* globalCtx, Vec3f* position, f32 arg2, s32 arg3, s16 arg4, s16 scaleStep, u8 arg6) { + Vec3f pos; + Vec3f accel = { 0.0f, 0.3f, 0.0f }; + s32 i; + + for (i = arg3; i >= 0; i--) { + s16 scale; + + pos.x = ((Rand_ZeroOne() - 0.5f) * arg2) + position->x; + pos.y = ((Rand_ZeroOne() - 0.5f) * arg2) + position->y; + pos.z = ((Rand_ZeroOne() - 0.5f) * arg2) + position->z; + + scale = (s32)(Rand_ZeroOne() * arg4 * 0.2f); + scale += arg4; + + if (arg6) { + func_800B1210(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep); + } else { + func_800B11A0(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep); + } + } +} + +void func_800BC154(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actor, u8 actorCategory) { + actorCtx->actorLists[actor->category].unk_08 = 1; + actor->category = actorCategory; +} + +// Damage flags for EnArrow +s32 D_801AEDB0[] = { + 0x800, 0x20, 0x20, 0x800, 0x1000, 0x2000, 0x1, 0x10000, 0x1, +}; + +s32 func_800BC188(s32 index) { + if ((index < 0) || (index >= ARRAY_COUNT(D_801AEDB0))) { + return 0; + } + + return D_801AEDB0[index]; +} + +s32 func_800BC1B4(Actor* actor, Actor* arg1, f32 arg2, f32 arg3) { + if ((arg3 > 0.0f) && (Actor_DistanceBetweenActors(arg1, actor) < ((arg3 * 2.5f) + arg2))) { + s16 temp_v1 = BINANG_SUB(Actor_YawBetweenActors(arg1, actor), arg1->world.rot.y); + + if (ABS_ALT(temp_v1) < 0x1400) { + return true; + } + } + + return false; +} + +Actor* func_800BC270(GlobalContext* globalCtx, Actor* actor, f32 arg2, s32 arg3) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + + while (itemAction != NULL) { + if (((itemAction->id == ACTOR_ARMS_HOOK) && (arg3 & 0x80)) || + ((itemAction->id == ACTOR_EN_BOOM) && (arg3 & 0x10)) || + ((itemAction->id == ACTOR_EN_ARROW) && (func_800BC188(itemAction->params) & arg3))) { + f32 speedXZ; + + if ((itemAction->speedXZ <= 0.0f) && (GET_PLAYER(globalCtx)->unk_D57 != 0)) { + if (itemAction->id == ACTOR_ARMS_HOOK) { + speedXZ = 20.0f; + } else if (itemAction->id == ACTOR_EN_BOOM) { + speedXZ = 12.0f; + } else { + s32 temp_v0_3 = func_800BC188(itemAction->params); + + if (temp_v0_3 == 1) { + speedXZ = 80.0f; + } else if (temp_v0_3 == 0x10000) { + speedXZ = 60.0f; + } else { + speedXZ = 150.0f; + } + } + } else { + speedXZ = itemAction->speedXZ; + } + + if (func_800BC1B4(actor, itemAction, arg2, speedXZ)) { + break; + } + } + + itemAction = itemAction->next; + } + + return itemAction; +} + +Actor* func_800BC444(GlobalContext* globalCtx, Actor* actor, f32 arg2) { + Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + + while (explosive != NULL) { + if (((explosive->id == ACTOR_EN_BOM) || (explosive->id == ACTOR_EN_BOM_CHU) || + (explosive->id == ACTOR_EN_BOMBF))) { + if (func_800BC1B4(actor, explosive, arg2, explosive->speedXZ)) { + break; + } + } + explosive = explosive->next; + } + + return explosive; +} + +/** + * Checks if a given actor will be standing on the ground after being translated + * by the provided distance and angle. + * + * Returns true if the actor will be standing on ground. + */ +s16 Actor_TestFloorInDirection(Actor* actor, GlobalContext* globalCtx, f32 distance, s16 angle) { + s16 ret; + u16 bgCheckFlags; + f32 dx; + f32 dz; + Vec3f actorPos; + + Math_Vec3f_Copy(&actorPos, &actor->world.pos); + + bgCheckFlags = actor->bgCheckFlags; + + dx = Math_SinS(angle) * distance; + dz = Math_CosS(angle) * distance; + + actor->world.pos.x += dx; + actor->world.pos.z += dz; + + Actor_UpdateBgCheckInfo(globalCtx, actor, 0.0f, 0.0f, 0.0f, 4); + Math_Vec3f_Copy(&actor->world.pos, &actorPos); + + ret = actor->bgCheckFlags & 1; + + actor->bgCheckFlags = bgCheckFlags; + + return ret; +} + +/** + * Returns true if the player is targeting the provided actor + */ +s32 Actor_IsTargeted(GlobalContext* globalCtx, Actor* actor) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags3 & 0x80000000) && actor->isTargeted) { + return true; + } + + return false; +} + +/** + * Returns true if the player is targeting an actor other than the provided actor + */ +s32 Actor_OtherIsTargeted(GlobalContext* globalCtx, Actor* actor) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags3 & 0x80000000) && !actor->isTargeted) { + return true; + } + + return false; +} + +void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx) { + MtxF sp58; + f32 sp54; + Vec3f sp48; + CollisionPoly* sp44; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, alpha); + + sp48.x = arg0->x; + sp48.y = arg0->y + 1.0f; + sp48.z = arg0->z; + + sp54 = BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &sp44, &sp48); + if (sp44 != NULL) { + func_800C0094(sp44, arg0->x, sp54, arg0->z, &sp58); + Matrix_SetCurrentState(&sp58); + } else { + Matrix_InsertTranslation(arg0->x, arg0->y, arg0->z, MTXMODE_NEW); + } + Matrix_Scale(arg1->x, 1.0f, arg1->z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gCircleShadowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_800BC770(GlobalContext* globalCtx, s16 y, s16 countdown) { + s16 idx = Quake_Add(&globalCtx->mainCamera, 3); + + Quake_SetSpeed(idx, 20000); + Quake_SetQuakeValues(idx, y, 0, 0, 0); + Quake_SetCountdown(idx, countdown); +} + +void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed) { + s16 idx = Quake_Add(&globalCtx->mainCamera, 3); + + Quake_SetSpeed(idx, speed); + Quake_SetQuakeValues(idx, y, 0, 0, 0); + Quake_SetCountdown(idx, countdown); +} + +void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 arg2, s16 arg3) { + if (arg2 >= 5) { + func_8013ECE0(actor->xyzDistToPlayerSq, 255, 20, 150); + } else { + func_8013ECE0(actor->xyzDistToPlayerSq, 180, 20, 100); + } + func_800BC770(globalCtx, arg2, arg3); +} + +typedef struct { + /* 0x00 */ f32 chainAngle; + /* 0x04 */ f32 chainLength; + /* 0x08 */ f32 yShift; + /* 0x0C */ f32 chainsScale; + /* 0x10 */ f32 chainsRotZInit; + /* 0x14 */ Gfx* chainDL; + /* 0x18 */ Gfx* lockDL; +} DoorLockInfo; // size = 0x1C + +DoorLockInfo sDoorLocksInfo[DOORLOCK_MAX] = { + /* DOORLOCK_NORMAL */ { 0.54f, 6000.0f, 5000.0, 1.0f, 0.0f, gDoorChainsDL, gDoorLockDL }, + /* DOORLOCK_BOSS */ { 0.644f, 12000.0f, 8000.0f, 1.0f, 0.0f, object_bdoor_DL_000530, object_bdoor_DL_000400 }, + /* DOORLOCK_2 */ { 0.6400000453f, 8500.0f, 8000.0f, 1.75f, 0.1f, gDoorChainsDL, gDoorLockDL }, +}; + +/** + * Draws chains and lock of a locked door, of the specified `type` (see `DoorLockType`). + * `frame` can be 0 to 10, where 0 is "open" and 10 is "closed", the chains slide accordingly. + */ +void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { + s32 pad[2]; + MtxF baseMtxF; + s32 i; + f32 chainsTranslateX; + f32 chainsTranslateY; + DoorLockInfo* entry = &sDoorLocksInfo[type]; + f32 chainRotZ = entry->chainsRotZInit; + f32 rotZStep; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY); + Matrix_CopyCurrentState(&baseMtxF); + + chainsTranslateX = __sinf(entry->chainAngle - chainRotZ) * -(10 - frame) * 0.1f * entry->chainLength; + chainsTranslateY = __cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength; + + for (i = 0; i < 4; i++) { + Matrix_SetCurrentState(&baseMtxF); + Matrix_InsertZRotation_f(chainRotZ, MTXMODE_APPLY); + Matrix_InsertTranslation(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY); + if (entry->chainsScale != 1.0f) { + Matrix_Scale(entry->chainsScale, entry->chainsScale, entry->chainsScale, MTXMODE_APPLY); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, entry->chainDL); + + if ((i % 2) != 0) { + rotZStep = 2.0f * entry->chainAngle; + } else { + rotZStep = M_PI - (2.0f * entry->chainAngle); + } + + chainRotZ += rotZStep; + } + + Matrix_SetCurrentState(&baseMtxF); + Matrix_Scale(frame * 0.1f, frame * 0.1f, frame * 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, entry->lockDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void Actor_SpawnShieldParticlesMetal(GlobalContext* globalCtx, Vec3f* pos) { + CollisionCheck_SpawnShieldParticlesMetal(globalCtx, pos); +} + +void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 xluFlag, u16 duration) { + if ((colorFlag == 0x8000) && !(colorIntensityMax & 0x8000)) { + Actor_PlaySfxAtPos(actor, NA_SE_EN_LIGHT_ARROW_HIT); + } + + actor->colorFilterParams = colorFlag | xluFlag | ((colorIntensityMax & 0xF8) << 5) | duration; + actor->colorFilterTimer = duration; +} + +Hilite* func_800BCBF4(Vec3f* arg0, GlobalContext* globalCtx) { + Vec3f lightDir; + + lightDir.x = globalCtx->envCtx.dirLight1.params.dir.x; + lightDir.y = globalCtx->envCtx.dirLight1.params.dir.y; + lightDir.z = globalCtx->envCtx.dirLight1.params.dir.z; + + return Hilite_DrawOpa(arg0, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); +} + +Hilite* func_800BCC68(Vec3f* arg0, GlobalContext* globalCtx) { + Vec3f lightDir; + + lightDir.x = globalCtx->envCtx.dirLight1.params.dir.x; + lightDir.y = globalCtx->envCtx.dirLight1.params.dir.y; + lightDir.z = globalCtx->envCtx.dirLight1.params.dir.z; + + return Hilite_DrawXlu(arg0, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); +} + +void func_800BCCDC(Vec3s* points, s32 pathCount, Vec3f* pos1, Vec3f* pos2, s32 arg4) { + s32 spB4; + s32 spB0; + s32 spA8[2] = { 0, 0 }; + s32 spA0[2] = { 0, 0 }; + Vec3f sp94; + Vec3f sp7C[2]; + Vec3f sp70; + Vec3f sp64; + f32 sp60; + f32 sp5C; + f32 sp54[2]; + + spB0 = 0; + sp5C = SQ(40000.0f); + + for (spB4 = 0; spB4 < pathCount; spB4++) { + sp60 = Math3D_XZDistanceSquared(pos1->x, pos1->z, points[spB4].x, points[spB4].z); + if (sp60 < sp5C) { + sp5C = sp60; + spB0 = spB4; + } + } + + sp94.x = (points + spB0)->x; + sp94.z = (points + spB0)->z; + pos2->y = (points + spB0)->y; + if (spB0 != 0) { + sp64.x = (points + spB0 - 1)->x; + sp64.z = (points + spB0 - 1)->z; + } else if (arg4) { + sp64.x = (points + pathCount - 1)->x; + sp64.z = (points + pathCount - 1)->z; + } + + if ((spB0 != 0) || arg4) { + spA8[0] = + Math3D_PointDistToLine2D(pos1->x, pos1->z, sp64.x, sp64.z, sp94.x, sp94.z, &sp7C[0].x, &sp7C[0].z, &sp60); + } + + if (spB0 + 1 != pathCount) { + sp70.x = (points + spB0 + 1)->x; + sp70.z = (points + spB0 + 1)->z; + } else if (arg4) { + sp70.x = points->x; + sp70.z = points->z; + } + + if ((spB0 + 1 != pathCount) || arg4) { + spA8[1] = + Math3D_PointDistToLine2D(pos1->x, pos1->z, sp94.x, sp94.z, sp70.x, sp70.z, &sp7C[1].x, &sp7C[1].z, &sp60); + } + + if (arg4) { + s32 phi_s0_2; + + spA0[0] = ((sp64.x - pos1->x) * (sp94.z - pos1->z)) < ((sp64.z - pos1->z) * (sp94.x - pos1->x)); + spA0[1] = ((sp70.z - pos1->z) * (sp94.x - pos1->x)) < ((sp94.z - pos1->z) * (sp70.x - pos1->x)); + + for (phi_s0_2 = 0; phi_s0_2 < ARRAY_COUNT(sp54); phi_s0_2++) { + if (spA8[phi_s0_2] != 0) { + sp54[phi_s0_2] = Math3D_XZDistanceSquared(pos1->x, pos1->z, sp7C[phi_s0_2].x, sp7C[phi_s0_2].z); + } else { + sp54[phi_s0_2] = SQ(40000.0f); + } + } + } + + if (arg4 && (((spA0[0] != 0) && (spA0[1] != 0)) || ((spA0[0] != 0) && (spA8[0] != 0) && (sp54[0] < sp54[1])) || + ((spA0[1] != 0) && (spA8[1] != 0) && (sp54[1] < sp54[0])))) { + pos2->x = pos1->x; + pos2->z = pos1->z; + } else if ((spA8[0] != 0) && (spA8[1] != 0)) { + if ((spA0[0] == 0) && (spA0[1] == 0)) { + if (Math3D_PointDistToLine2D(pos1->x, pos1->z, sp7C[0].x, sp7C[0].z, sp7C[1].x, sp7C[1].z, &pos2->x, + &pos2->z, &sp60) == 0) { + pos2->x = (sp7C[1].x + sp7C[0].x) * 0.5f; + pos2->z = (sp7C[1].z + sp7C[0].z) * 0.5f; + } + } else if (sp54[1] < sp54[0]) { + pos2->x = sp7C[1].x; + pos2->z = sp7C[1].z; + } else { + pos2->x = sp7C[0].x; + pos2->z = sp7C[0].z; + } + } else if (spA8[0] != 0) { + pos2->x = sp7C[0].x; + pos2->z = sp7C[0].z; + } else if (spA8[1] != 0) { + pos2->x = sp7C[1].x; + pos2->z = sp7C[1].z; + } else if (arg4 && ((((sp64.x - pos1->x) * (sp70.z - pos1->z)) < ((sp64.z - pos1->z) * (sp70.x - pos1->x))))) { + pos2->x = pos1->x; + pos2->z = pos1->z; + } else { + pos2->x = sp94.x; + pos2->z = sp94.z; + } +} + +// unused +s32 func_800BD2B4(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 arg3, + u16 (*textIdCallback)(GlobalContext*, Actor*), s16 (*arg5)(GlobalContext*, Actor*)) { + if (Actor_ProcessTalkRequest(actor, &globalCtx->state)) { + *arg2 = true; + return true; + } else if (*arg2) { + *arg2 = arg5(globalCtx, actor); + return false; + } else if (!func_800B8934(globalCtx, actor)) { + return false; + } else if (!func_800B8614(actor, globalCtx, arg3)) { + return false; + } else { + actor->textId = textIdCallback(globalCtx, actor); + return false; + } +} + +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ s16 unk_04; + /* 0x06 */ s16 unk_06; + /* 0x08 */ s16 unk_08; + /* 0x0A */ s16 unk_0A; + /* 0x0C */ u8 unk_0C; +} struct_801AEE38_0; // size = 0x10 + +typedef struct { + /* 0x00 */ struct_801AEE38_0 sub_00; + /* 0x10 */ f32 unk_10; + /* 0x14 */ s16 unk_14; +} struct_801AEE38; // size = 0x18 + +struct_801AEE38 D_801AEE38[] = { + { { 0x1C20, 0xE390, 0x1C70, 0x1554, 0x0000, 0x0000, 0x0000 }, 170.0f, 0x3FFC }, + { { 0x2AA8, 0xEAAC, 0x1554, 0x1554, 0xF8E4, 0x0E38, 0x0001 }, 170.0f, 0x3FFC }, + { { 0x31C4, 0xE390, 0x0E38, 0x0E38, 0xF1C8, 0x071C, 0x0001 }, 170.0f, 0x3FFC }, + { { 0x1554, 0xF1C8, 0x0000, 0x071C, 0xF8E4, 0x0000, 0x0001 }, 170.0f, 0x3FFC }, + { { 0x2AA8, 0xF8E4, 0x071C, 0x0E38, 0xD558, 0x2AA8, 0x0001 }, 170.0f, 0x3FFC }, + { { 0x0000, 0xE390, 0x2AA8, 0x3FFC, 0xF1C8, 0x0E38, 0x0001 }, 170.0f, 0x3FFC }, + { { 0x2AA8, 0xF1C8, 0x0E38, 0x0E38, 0x0000, 0x0000, 0x0001 }, 0.0f, 0x0000 }, + { { 0x2AA8, 0xF1C8, 0x0000, 0x0E38, 0x0000, 0x1C70, 0x0001 }, 0.0f, 0x0000 }, + { { 0x2AA8, 0xF1C8, 0xF1C8, 0x0000, 0x0000, 0x0000, 0x0001 }, 0.0f, 0x0000 }, + { { 0x071C, 0xF1C8, 0x0E38, 0x1C70, 0x0000, 0x0000, 0x0001 }, 0.0f, 0x0000 }, + { { 0x0E38, 0xF1C8, 0x0000, 0x1C70, 0x0000, 0x0E38, 0x0001 }, 0.0f, 0x0000 }, + { { 0x2AA8, 0xE390, 0x1C70, 0x0E38, 0xF1C8, 0x0E38, 0x0001 }, 0.0f, 0x0000 }, + { { 0x18E2, 0xF1C8, 0x0E38, 0x0E38, 0x0000, 0x0000, 0x0001 }, 0.0f, 0x0000 }, + { { 0x2A6C, 0xE390, 0x1C70, 0x1554, 0x0000, 0x0000, 0x0000 }, 170.0f, 0x3FFC }, +}; + +void func_800BD384(Actor* actor, struct_800BD888_arg1* arg1, s16 arg2, s16 arg3, s16 arg4, s16 arg5, s16 arg6, s16 arg7, + u8 arg8) { + s16 sp46; + s16 sp44; + s16 temp2; + s16 sp40; + s16 temp1; + Vec3f sp30; + + sp30.x = actor->world.pos.x; + sp30.y = actor->world.pos.y + arg1->unk_14; + sp30.z = actor->world.pos.z; + + sp46 = Math_Vec3f_Pitch(&sp30, &arg1->unk_18); + sp44 = Math_Vec3f_Yaw(&sp30, &arg1->unk_18); + sp40 = Math_Vec3f_Yaw(&actor->world.pos, &arg1->unk_18) - actor->shape.rot.y; + + temp1 = CLAMP(sp40, -arg2, arg2); + Math_SmoothStepToS(&arg1->unk_08.y, temp1, 6, 2000, 1); + + temp1 = (ABS_ALT(sp40) >= 0x8000) ? 0 : ABS_ALT(sp40); + arg1->unk_08.y = CLAMP(arg1->unk_08.y, -temp1, temp1); + + sp40 -= arg1->unk_08.y; + + temp1 = CLAMP(sp40, -arg5, arg5); + Math_SmoothStepToS(&arg1->unk_0E.y, temp1, 6, 2000, 1); + + temp1 = (ABS_ALT(sp40) >= 0x8000) ? 0 : ABS_ALT(sp40); + arg1->unk_0E.y = CLAMP(arg1->unk_0E.y, -temp1, temp1); + + if (arg8) { + Math_SmoothStepToS(&actor->shape.rot.y, sp44, 6, 2000, 1); + } + + temp1 = CLAMP(sp46, arg4, (s16)(u16)arg3); + Math_SmoothStepToS(&arg1->unk_08.x, temp1, 6, 2000, 1); + + temp2 = sp46 - arg1->unk_08.x; + + temp1 = CLAMP(temp2, arg7, arg6); + Math_SmoothStepToS(&arg1->unk_0E.x, temp1, 6, 2000, 1); +} + +// unused +s16 func_800BD6B8(s16 arg0) { + return D_801AEE38[arg0].unk_14; +} + +s16 func_800BD6E4(Actor* actor, struct_800BD888_arg1* arg1, f32 arg2, s16 arg3, s16 flag) { + s32 pad; + + if (flag) { + return flag; + } else if (arg1->unk_00 != 0) { + return 4; + } else if (arg2 < Math_Vec3f_DistXYZ(&actor->world.pos, &arg1->unk_18)) { + arg1->unk_04 = 0; + arg1->unk_06 = 0; + return 1; + } else { + s16 yaw = Math_Vec3f_Yaw(&actor->world.pos, &arg1->unk_18); + s16 phi_a0 = ABS_ALT(BINANG_SUB(yaw, actor->shape.rot.y)); + + if (arg3 >= phi_a0) { + arg1->unk_04 = 0; + arg1->unk_06 = 0; + return 2; + } else if (DECR(arg1->unk_04) != 0) { + return arg1->unk_02; + } else { + switch (arg1->unk_06) { + case 0: + case 2: + arg1->unk_04 = Rand_S16Offset(30, 30); + arg1->unk_06++; + return 1; + + case 1: + arg1->unk_04 = Rand_S16Offset(10, 10); + arg1->unk_06++; + return 3; + + default: + return 4; + } + } + } +} // This function is very similar to OoT's func_80034A14 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BD888.s") +void func_800BD888(Actor* actor, struct_800BD888_arg1* arg1, s16 arg2, s16 arg3) { + struct_801AEE38_0 sp38; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BD9A0.s") + arg1->unk_02 = func_800BD6E4(actor, arg1, D_801AEE38[arg2].unk_10, D_801AEE38[arg2].unk_14, arg3); + sp38 = D_801AEE38[arg2].sub_00; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BD9E0.s") + switch (arg1->unk_02) { + case 1: + sp38.unk_00 = 0; + sp38.unk_04 = 0; + sp38.unk_02 = 0; + case 3: + sp38.unk_06 = 0; + sp38.unk_0A = 0; + sp38.unk_08 = 0; + case 2: + sp38.unk_0C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BDAA0.s") + func_800BD384(actor, arg1, sp38.unk_00, sp38.unk_04, sp38.unk_02, sp38.unk_06, sp38.unk_0A, sp38.unk_08, + sp38.unk_0C); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BDB6C.s") +Gfx D_801AEF88[] = { + gsDPSetRenderMode(AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + G_RM_FOG_SHADE_A, + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)), + gsDPSetAlphaCompare(G_AC_THRESHOLD), + gsSPEndDisplayList(), +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BDC5C.s") +Gfx D_801AEFA0[] = { + gsSPEndDisplayList(), +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BDCF4.s") +void* func_800BD9A0(GraphicsContext* gfxCtx) { + Gfx* displayListHead; + Gfx* displayList; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_Noop.s") + displayListHead = displayList = GRAPH_ALLOC(gfxCtx, 0x10); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BDFC0.s") + gDPSetRenderMode(displayListHead++, + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + G_RM_FOG_SHADE_A, + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); + gSPEndDisplayList(displayListHead++); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE03C.s") + return displayList; +} -Actor* func_800BE0B8(GlobalContext* globalCtx, Actor* inActor, s16 arg2, u8 arg3, f32 arg4) { - Actor* actor = globalCtx->actorCtx.actorList[arg3].first; +// unused +void func_800BD9E0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, + PostLimbDraw postLimbDraw, Actor* actor, s16 alpha) { + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, alpha); + gSPSegment(POLY_OPA_DISP++, 0x0C, gEmptyDL); + + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + overrideLimbDraw, postLimbDraw, actor, POLY_OPA_DISP); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_800BDAA0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, + PostLimbDraw postLimbDraw, Actor* actor, s16 alpha) { + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, alpha); + gSPSegment(POLY_XLU_DISP++, 0x0C, func_800BD9A0(globalCtx->state.gfxCtx)); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + overrideLimbDraw, postLimbDraw, actor, POLY_XLU_DISP); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +// Unused +s16 func_800BDB6C(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3) { + Player* player = GET_PLAYER(globalCtx); + f32 phi_f2; + + if ((globalCtx->csCtx.state != 0) || (D_801D0D50 != 0)) { + phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &globalCtx->view.eye) * 0.25f; + } else { + phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &player->actor.world.pos); + } + + if (arg3 < phi_f2) { + actor->flags &= ~ACTOR_FLAG_1; + Math_SmoothStepToS(&arg2, 0, 6, 0x14, 1); + } else { + actor->flags |= ACTOR_FLAG_1; + Math_SmoothStepToS(&arg2, 0xFF, 6, 0x14, 1); + } + + return arg2; +} + +void Actor_ChangeAnimation(SkelAnime* skelAnime, ActorAnimationEntry* animation, s32 index) { + f32 frameCount; + + animation += index; + if (animation->frameCount > 0.0f) { + frameCount = animation->frameCount; + } else { + frameCount = Animation_GetLastFrame(&animation->animation->common); + } + + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, frameCount, + animation->mode, animation->morphFrames); +} + +// Unused +void func_800BDCF4(GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 size) { + s32 frames = globalCtx->gameplayFrames; + s32 i; + + for (i = 0; i < size; i++) { + arg1[i] = (0x814 + 50 * i) * frames; + arg2[i] = (0x940 + 50 * i) * frames; + } +} + +void Actor_Noop(Actor* actor, GlobalContext* globalCtx) { +} + +#include "z_cheap_proc.c" + +/** + * Finds the first actor instance of a specified Id and category within a given range from + * an actor if there is one. If the Id provided is -1, this will look for any actor of the + * specified category rather than a specific Id. + */ +Actor* Actor_FindNearby(GlobalContext* globalCtx, Actor* inActor, s16 actorId, u8 actorCategory, f32 distance) { + Actor* actor = globalCtx->actorCtx.actorLists[actorCategory].first; while (actor != NULL) { - if (actor == inActor || ((arg2 != -1) && (arg2 != actor->id))) { + if (actor == inActor || ((actorId != -1) && (actorId != actor->id))) { actor = actor->next; continue; } - if (Actor_DistanceBetweenActors(inActor, actor) <= arg4) { + if (Actor_DistanceBetweenActors(inActor, actor) <= distance) { return actor; } @@ -870,26 +4307,434 @@ Actor* func_800BE0B8(GlobalContext* globalCtx, Actor* inActor, s16 arg2, u8 arg3 return NULL; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE184.s") +s32 func_800BE184(GlobalContext* globalCtx, Actor* actor, f32 xzDist, s16 arg3, s16 arg4, s16 arg5) { + Player* player = GET_PLAYER(globalCtx); + s16 phi_v0 = BINANG_SUB(BINANG_ROT180(actor->yawTowardsPlayer), player->actor.shape.rot.y); + s16 temp_t0 = actor->yawTowardsPlayer - arg5; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_ApplyDamage.s") + if ((actor->xzDistToPlayer <= xzDist) && (player->swordState != 0)) { + if ((arg4 >= ABS_ALT(phi_v0)) && (arg3 >= ABS_ALT(temp_t0))) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE258.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE2B8.s") +u8 Actor_ApplyDamage(Actor* actor) { + if (actor->colChkInfo.damage >= actor->colChkInfo.health) { + actor->colChkInfo.health = 0; + } else { + actor->colChkInfo.health -= actor->colChkInfo.damage; + } + return actor->colChkInfo.health; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE33C.s") +void Actor_SetDropFlag(Actor* actor, ColliderInfo* colInfo) { + ColliderInfo* acHitInfo = colInfo->acHitInfo; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE3D0.s") + if (acHitInfo == NULL) { + actor->dropFlag = 0; + } else if (acHitInfo->toucher.dmgFlags & 0x800) { // DMG_FIRE_ARROW + actor->dropFlag = 1; + } else if (acHitInfo->toucher.dmgFlags & 0x1000) { // DMG_ICE_ARROW + actor->dropFlag = 2; + } else if (acHitInfo->toucher.dmgFlags & 0x2000) { // DMG_LIGHT_ARROW + actor->dropFlag = 0x20; + } else { + actor->dropFlag = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE504.s") +void Actor_SetDropFlagJntSph(Actor* actor, ColliderJntSph* jntSphere) { + s32 i; + ColliderJntSphElement* jntElement; + ColliderInfo* acHitInfo; + s32 flag; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE568.s") + actor->dropFlag = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE5CC.s") + for (i = jntSphere->count - 1; i >= 0; i--) { + jntElement = &jntSphere->elements[i]; + acHitInfo = jntElement->info.acHitInfo; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE63C.s") + if (acHitInfo == NULL) { + flag = 0; + } else { + s32 dmgFlags = acHitInfo->toucher.dmgFlags; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE680.s") + if (dmgFlags & 0x800) { + flag = 1; + } else if (dmgFlags & 0x1000) { + flag = 2; + } else { + flag = (dmgFlags & 0x2000) ? 0x20 : 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BF7CC.s") + actor->dropFlag |= flag; + } +} + +void func_800BE33C(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3) { + f32 xDiff = arg1->x - arg0->x; + f32 zDiff = arg1->z - arg0->z; + f32 yDiff = arg3 ? (arg1->y - arg0->y) : (arg0->y - arg1->y); + + arg2->y = Math_FAtan2F(zDiff, xDiff); + arg2->x = Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), yDiff); +} + +void func_800BE3D0(Actor* actor, s16 angle, Vec3s* arg2) { + f32 sp44; + f32 sp40; + f32 sp3C; + f32 sp38; + f32 sp34; + f32 sp30; + f32 sp2C; + s32 pad[3]; + + if (actor->floorPoly != NULL) { + CollisionPoly* floorPoly = actor->floorPoly; + + sp44 = COLPOLY_GET_NORMAL(floorPoly->normal.x); + sp40 = COLPOLY_GET_NORMAL(floorPoly->normal.y); + sp3C = COLPOLY_GET_NORMAL(floorPoly->normal.z); + + sp38 = Math_SinS(angle); + sp34 = Math_CosS(angle); + arg2->x = (s16)-Math_Atan2S((-(sp44 * sp38) - (sp3C * sp34)) * sp40, 1.0f); + + sp2C = Math_SinS(angle - 0x3FF7); + sp30 = Math_CosS(angle - 0x3FF7); + arg2->z = (s16)-Math_Atan2S((-(sp44 * sp2C) - (sp3C * sp30)) * sp40, 1.0f); + } +} + +void func_800BE504(Actor* actor, ColliderCylinder* collider) { + // Checks if was hit by either DMG_NORMAL_ARROW, DMG_FIRE_ARROW, DMG_ICE_ARROW, DMG_LIGHT_ARROW or DMG_DEKU_BUBBLE + if ((collider->info.acHitInfo->toucher.dmgFlags & (0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20))) { + actor->world.rot.y = collider->base.ac->shape.rot.y; + } else { + actor->world.rot.y = Actor_YawBetweenActors(collider->base.ac, actor); + } +} + +void func_800BE568(Actor* actor, ColliderSphere* collider) { + if (collider->info.acHitInfo->toucher.dmgFlags & (0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20)) { + actor->world.rot.y = collider->base.ac->shape.rot.y; + } else { + actor->world.rot.y = Actor_YawBetweenActors(collider->base.ac, actor); + } +} + +void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 colliderIndex) { + if (collider->elements[colliderIndex].info.acHitInfo->toucher.dmgFlags & + (0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20)) { + actor->world.rot.y = collider->base.ac->shape.rot.y; + } else { + actor->world.rot.y = Actor_YawBetweenActors(collider->base.ac, actor); + } +} + +s32 func_800BE63C(struct EnBox* chest) { + if (chest->type == 5 || chest->type == 6 || chest->type == 7 || chest->type == 8 || + chest->type == 0xC) { + return true; + } + return false; +} + +TexturePtr D_801AEFA8[] = { + gameplay_keep_Tex_091DE0, + gameplay_keep_Tex_091FE0, + gameplay_keep_Tex_0921E0, + gameplay_keep_Tex_0923E0, +}; + +// Draw common damageEffects +void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 arg3, f32 effectScale, f32 steamScale, + f32 effectAlpha, u8 mode) { + if (effectAlpha > 0.001f) { + s32 temp_v1_3; + s16 i; + MtxF* temp_s3; + f32 alpha; + f32 sp124; + f32 sp120; + f32 sp11C; + f32 sp118; + Vec3f* limbAux = limbPos; + u32 sp110 = globalCtx->gameplayFrames; + f32 sp74; + + temp_s3 = Matrix_GetCurrentState(); + + if ((actor != NULL) && (effectAlpha > 0.05f) && (globalCtx->gameOverCtx.state == 0)) { + if (mode == 0) { + Actor_PlaySfxAtPos(actor, NA_SE_EV_BURN_OUT - SFX_FLAG); + } else if (mode == 1) { + Actor_PlaySfxAtPos(actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } else if (mode == 0xB) { + Actor_PlaySfxAtPos(actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } else if ((mode == 0x14) || (mode == 0x15)) { + Actor_PlaySfxAtPos(actor, NA_SE_EN_COMMON_DEADLIGHT - SFX_FLAG); + } + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + switch (mode) { + case 0xA: + case 0xB: + sp124 = ((KREG(19) * 0.01f) + 2.3f) * effectScale; + sp118 = ((KREG(28) * 0.0001f) + 0.035f) * steamScale; + func_800BCC68(limbPos, globalCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp110 & 0xFF, 0x20, 0x10, 1, 0, + (sp110 * 2) & 0xFF, 0x40, 0x20)); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, 255); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_050648); + + sp74 = effectAlpha * 255.0f; + for (i = 0; i < arg3; i++) { + alpha = i & 3; + alpha = sp74 - (30.0f * alpha); + if (sp74 < (30.0f * (i & 3))) { + alpha = 0.0f; + } + if (alpha > 255.0f) { + alpha = 255.0f; + } + + gDPSetEnvColor(POLY_XLU_DISP++, KREG(20) + 0xC8, KREG(21) + 0xC8, KREG(22) + 0xFF, (u8)alpha); + + Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); + Matrix_Scale(sp124, sp124, sp124, MTXMODE_APPLY); + if (i & 1) { + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + } + if (i & 2) { + Matrix_InsertZRotation_f(M_PI, MTXMODE_APPLY); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0506E0); + + limbPos++; + } + + limbPos = limbAux; + + gDPSetColorDither(POLY_XLU_DISP++, G_CD_BAYER); + + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_PATTERN); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051180); + + alpha = effectAlpha * 100.0f; + if (alpha > 100.0f) { + alpha = 100.0f; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (u8)alpha); + + for (i = 0; i < arg3; i++) { + temp_v1_3 = ((i * 3) + sp110); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, temp_v1_3 * 3, temp_v1_3 * -0xC, 0x20, 0x40, + 1, 0, 0, 0x20, 0x20)); + + Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(sp118, sp118, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051238); + + limbPos++; + } + break; + + case 0x0: + case 0x1: + if (mode == 0) { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 0); + mode = 0xFF; + } + + Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f, 1); + + sp74 = effectAlpha * 255.0f; + + for (i = 0; i < arg3; i++) { + alpha = i & 3; + alpha = sp74 - 30.0f * alpha; + if (sp74 < 30.0f * (i & 3)) { + alpha = 0.0f; + } + if (alpha > 255.0f) { + alpha = 255.0f; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, mode, (u8)alpha); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, + ((i * 10 + sp110) * -0x14) & 0x1FF, 0x20, 0x80)); + + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + temp_s3->mf[3][0] = limbPos->x; + temp_s3->mf[3][1] = limbPos->y; + temp_s3->mf[3][2] = limbPos->z; + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + + limbPos++; + } + break; + + case 0x14: + case 0x15: + sp120 = ((KREG(19) * 0.01f) + 4.0f) * effectScale; + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023348); + + alpha = effectAlpha * 255.0f; + if (alpha > 255.0f) { + alpha = 255.0f; + } + + if (mode == 0x15) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 0xFF), (u8)(sREG(17) + 0xFF), + (u8)(sREG(18) + 0xFF), (u8)alpha); + + gDPSetEnvColor(POLY_XLU_DISP++, (u8)sREG(19), (u8)(sREG(20) + 0xFF), (u8)(sREG(21) + 0xFF), 0x80); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)alpha); + + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 128); + } + Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Scale(sp120, sp120, 1.0f, MTXMODE_APPLY); + + for (i = 0; i < arg3; i++) { + Matrix_InsertZRotation_f(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY); + temp_s3->mf[3][0] = limbPos->x; + temp_s3->mf[3][1] = limbPos->y; + temp_s3->mf[3][2] = limbPos->z; + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); + + limbPos++; + } + break; + + case 0x1E: + case 0x1F: + case 0x20: + if (mode == 0x1E) { + sp11C = (KREG(19) * 0.01f + 1.0f) * effectScale; + } else if (mode == 0x1F) { + sp11C = (KREG(19) * 0.01f + 1.5f) * effectScale; + } else { + sp11C = (KREG(19) * 0.01f + 2.0f) * effectScale; + } + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_801AEFA8[globalCtx->gameplayFrames & 3])); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023480); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 0xFF), (u8)(sREG(17) + 0xFF), + (u8)(sREG(18) + 0x96), (u8)(sREG(19) + 0xFF)); + + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 0xFF), (u8)(sREG(21) + 0xFF), (u8)sREG(22), + (u8)sREG(23)); + + Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Scale(sp11C, sp11C, sp11C, MTXMODE_APPLY); + + for (i = 0; i < arg3; i++) { + Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); + Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), 1); + temp_s3->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; + temp_s3->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; + temp_s3->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0234F0); + + Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); + Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), 1); + temp_s3->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; + temp_s3->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; + temp_s3->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0234F0); + + limbPos++; + } + break; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s32 limbPosCount, + s32 effectsPerLimb, f32 scale, f32 scaleRange) { + static Color_RGBA8 primColor = { 170, 255, 255, 255 }; + static Color_RGBA8 envColor = { 200, 200, 255, 255 }; + static Vec3f accel = { 0.0f, -1.0f, 0.0f }; + s32 i; + s32 pad; + Vec3f velocity; + s16 randomYaw; + s16 yaw; + s32 j; + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &actor->world.pos, 30, NA_SE_EV_ICE_BROKEN); + + for (i = 0; i < limbPosCount; i++) { + yaw = Actor_YawToPoint(actor, limbPos); + + for (j = 0; j < effectsPerLimb; j++) { + randomYaw = (Rand_Next() >> 0x13) + yaw; + + velocity.z = Rand_ZeroFloat(5.0f); + + velocity.x = Math_SinS(randomYaw) * velocity.z; + velocity.y = Rand_ZeroFloat(4.0f) + 8.0f; + velocity.z *= Math_CosS(randomYaw); + + EffectSsEnIce_Spawn(globalCtx, limbPos, Rand_ZeroFloat(scaleRange) + scale, &velocity, &accel, &primColor, + &envColor, 30); + } + + limbPos++; + } +} diff --git a/src/code/z_actor_dlftbls.c b/src/code/z_actor_dlftbls.c index f33fcd5388..77b6546ffd 100644 --- a/src/code/z_actor_dlftbls.c +++ b/src/code/z_actor_dlftbls.c @@ -722,7 +722,7 @@ void ActorOverlayTable_FaultPrint(void* arg0, void* arg1) { FaultDrawer_Printf("No. RamStart- RamEnd cn Name\n"); for (i = 0, overlayEntry = &gActorOverlayTable[0]; i < gMaxActorId; i++, overlayEntry++) { - overlaySize = (u32)overlayEntry->vramEnd - (u32)overlayEntry->vramStart; + overlaySize = VRAM_PTR_SIZE(overlayEntry); if (overlayEntry->loadedRamAddr != NULL) { FaultDrawer_Printf("%3d %08x-%08x %3d %s\n", i, overlayEntry->loadedRamAddr, (u32)overlayEntry->loadedRamAddr + overlaySize, overlayEntry->numLoaded, ""); @@ -740,7 +740,7 @@ void* ActorOverlayTable_FaultAddrConv(void* arg0, void* arg1) { u32 offset; for (i = 0; i < gMaxActorId; i++, overlayEntry++) { - size = (u8*)overlayEntry->vramEnd - (u8*)overlayEntry->vramStart; + size = VRAM_PTR_SIZE(overlayEntry); ramStart = overlayEntry->loadedRamAddr; ramEnd = ramStart + size; offset = (u8*)overlayEntry->vramStart - ramStart; diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index e5cb1ddb16..850d5234b7 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -68,10 +68,12 @@ BgSpecialSceneMaxObjects sCustomDynapolyMem[] = { { SCENE_21MITURINMAE, 1000, 600, 512 }, }; +// TODO: All these bss variables are localized to one function and can +// likely be made into in-function static bss variables in the future char D_801ED950[80]; char D_801ED9A0[80]; Vec3f D_801ED9F0[3]; // polyVerts -Vec3f D_801EDA18[3]; // polyVerts //not ok, needs to be inlined to match +Vec3f D_801EDA18[3]; // polyVerts MtxF D_801EDA40; Vec3f D_801EDA80[3]; // polyVerts char D_801EDAA8[80]; @@ -79,8 +81,6 @@ char D_801EDAF8[80]; Vec3f D_801EDB48[3]; // polyVerts Vec3f D_801EDB70[3]; Plane D_801EDB98; -Sphere16 D_801EDBA8; -TriNorm D_801EDBB0; void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector); f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast); @@ -322,40 +322,34 @@ s32 CollisionPoly_CheckYIntersectApprox1(CollisionPoly* poly, Vec3s* vtxList, f3 * Checks if point (`x`,`z`) is within `checkDist` of `poly`, computing `yIntersect` if true * Determinant max 0.0f (checks if on or within poly) */ -#ifdef NON_MATCHING s32 CollisionPoly_CheckYIntersect(CollisionPoly* poly, Vec3s* vtxList, f32 x, f32 z, f32* yIntersect, f32 checkDist) { - static Vec3f polyVerts[3]; // D_801EDA18 Vec3s* sVerts; f32 nx; f32 ny; f32 nz; sVerts = &vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)]; - polyVerts[0].x = sVerts->x; - polyVerts[0].y = sVerts->y; - polyVerts[0].z = sVerts->z; + D_801EDA18[0].x = sVerts->x; + D_801EDA18[0].y = sVerts->y; + D_801EDA18[0].z = sVerts->z; sVerts = &vtxList[COLPOLY_VTX_INDEX(poly->flags_vIB)]; - polyVerts[1].x = sVerts->x; - polyVerts[1].y = sVerts->y; - polyVerts[1].z = sVerts->z; - sVerts = &vtxList[poly->vIC]; - polyVerts[2].x = sVerts->x; - polyVerts[2].y = sVerts->y; - polyVerts[2].z = sVerts->z; + D_801EDA18[1].x = sVerts->x; + D_801EDA18[1].y = sVerts->y; + D_801EDA18[1].z = sVerts->z; + sVerts = &vtxList[(s32)poly->vIC]; + D_801EDA18[2].x = sVerts->x; + D_801EDA18[2].y = sVerts->y; + D_801EDA18[2].z = sVerts->z; - if (!func_8017A304(&polyVerts[0], &polyVerts[1], &polyVerts[2], z, x, checkDist)) { + if (!func_8017A304(&D_801EDA18[0], &D_801EDA18[1], &D_801EDA18[2], z, x, checkDist)) { return 0; } nx = COLPOLY_GET_NORMAL(poly->normal.x); ny = COLPOLY_GET_NORMAL(poly->normal.y); nz = COLPOLY_GET_NORMAL(poly->normal.z); - return Math3D_TriChkPointParaYIntersectInsideTri2(&polyVerts[0], &polyVerts[1], &polyVerts[2], nx, ny, nz, + return Math3D_TriChkPointParaYIntersectInsideTri2(&D_801EDA18[0], &D_801EDA18[1], &D_801EDA18[2], nx, ny, nz, poly->dist, z, x, yIntersect, checkDist); } -#else -s32 CollisionPoly_CheckYIntersect(CollisionPoly* poly, Vec3s* vtxList, f32 x, f32 z, f32* yIntersect, f32 checkDist); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/CollisionPoly_CheckYIntersect.s") -#endif s32 CollisionPoly_CheckYIntersectApprox2(CollisionPoly* poly, Vec3s* vtxList, f32 x, f32 z, f32* yIntersect) { return CollisionPoly_CheckYIntersectApprox1(poly, vtxList, x, z, yIntersect, 1.0f); @@ -427,8 +421,6 @@ s32 CollisionPoly_LineVsPoly(BgLineVsPolyTest* a0); #pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/CollisionPoly_LineVsPoly.s") #endif -#ifdef NON_MATCHING -// OK but .bss order issues s32 CollisionPoly_SphVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* center, f32 radius) { static Sphere16 sphere; // D_801EDBA8 static TriNorm tri; // D_801EDBB0 @@ -443,12 +435,7 @@ s32 CollisionPoly_SphVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* center, sphere.radius = radius; return Math3D_ColSphereTri(&sphere, &tri, &intersect); } -#else -s32 CollisionPoly_SphVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* center, f32 radius); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/CollisionPoly_SphVsPoly.s") -#endif -#ifdef NON_MATCHING /** * Add poly to StaticLookup table * Table is sorted by poly's smallest y vertex component @@ -486,6 +473,8 @@ void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, Coll while (true) { // if at the end of the list if (curNode->next == SS_NULL) { + s32 pad; + newNodeId = SSNodeList_GetNextNodeIdx(&colCtx->polyNodes); SSNode_SetValue(&colCtx->polyNodes.tbl[newNodeId], &polyId, SS_NULL); curNode->next = newNodeId; @@ -507,9 +496,6 @@ void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, Coll curNode = nextNode; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/StaticLookup_AddPolyToSSList.s") -#endif /** * Add CollisionPoly to StaticLookup list @@ -871,28 +857,29 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 * `outPoly` returns the poly collided with * `outY` returns the y coordinate needed to not collide with `outPoly` */ -#ifdef NON_MATCHING s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight, CollisionPoly** outPoly, Actor* actor) { s32 result = false; - // u16 nextId; CollisionPoly* curPoly; CollisionPoly* polyList; - f32 ceilingY; - Vec3s* vtxList; - SSNode* curNode; s32 curPolyId; + f32 ceilingY; + SSNode* curNode; + Vec3s* vtxList; if (lookup->ceiling.head == SS_NULL) { return result; } - curNode = &colCtx->polyNodes.tbl[lookup->ceiling.head]; polyList = colCtx->colHeader->polyList; vtxList = colCtx->colHeader->vtxList; + curNode = &colCtx->polyNodes.tbl[lookup->ceiling.head]; *outY = pos->y; while (true) { + f32 intersectDist; + f32 ny; + curPolyId = curNode->polyId; curPoly = &polyList[curPolyId]; if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags) || @@ -908,8 +895,8 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte } if (CollisionPoly_CheckYIntersectApprox2(curPoly, vtxList, pos->x, pos->z, &ceilingY)) { - f32 intersectDist = ceilingY - *outY; - f32 ny = COLPOLY_GET_NORMAL(curPoly->normal.y); + intersectDist = ceilingY - *outY; + ny = COLPOLY_GET_NORMAL(curPoly->normal.y); if (intersectDist > 0 && intersectDist < checkHeight && intersectDist * ny <= 0) { *outY = ceilingY - checkHeight; @@ -926,11 +913,6 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte } return result; } -#else -s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionContext* colCtx, f32* outY, Vec3f* pos, - f32 checkHeight, CollisionPoly** outPoly, Actor* actor); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_CheckStaticCeiling.s") -#endif /** * Tests if line `posA` to `posB` intersects with a static poly in list `ssList`. Uses polyCheckTbl @@ -1049,7 +1031,6 @@ s32 BgCheck_CheckLineInSubdivision(StaticLineTest* arg0) { * returns true if any poly intersects the sphere, else returns false * `outPoly` returns the pointer of the first poly found that intersects */ -#ifdef NON_MATCHING s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext* colCtx, Vec3f* center, f32 radius, CollisionPoly** outPoly, Actor* actor) { Vec3s* vtxList; @@ -1057,7 +1038,6 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext CollisionPoly* curPoly; u16 nextId; s16 curPolyId; - s32 pad; polyList = colCtx->colHeader->polyList; vtxList = colCtx->colHeader->vtxList; @@ -1088,17 +1068,14 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext } if (node->next != SS_NULL) { node = &colCtx->polyNodes.tbl[node->next]; + { s32 pad; } + continue; } break; } return false; } -#else -s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext* colCtx, Vec3f* center, f32 radius, - CollisionPoly** outPoly, Actor* actor); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_SphVsFirstStaticPolyList.s") -#endif /** * Get first static poly intersecting sphere `center` `radius` within `lookup` @@ -1539,16 +1516,12 @@ s32 BgCheck_GetSpecialSceneMaxObjects(GlobalContext* globalCtx, s32* maxNodes, s /** * Allocate CollisionContext */ -#ifdef NON_MATCHING void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, CollisionHeader* colHeader) { u32 tblMax; u32 memSize; u32 lookupTblMemSize; SSNodeList* nodeList; - s32 useCustomSubdivisions; - u32 customMemSize; s32 customNodeListMax; - s32 i; customNodeListMax = -1; colCtx->colHeader = colHeader; @@ -1563,6 +1536,10 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis colCtx->subdivAmount.y = 4; colCtx->subdivAmount.z = 16; } else { + u32 customMemSize; + s32 useCustomSubdivisions; + s32 i; + if (BgCheck_TryGetCustomMemsize(globalCtx->sceneNum, &customMemSize)) { colCtx->memSize = customMemSize; } else { @@ -1631,10 +1608,6 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis DynaPoly_Init(globalCtx, &colCtx->dyna); DynaPoly_Alloc(globalCtx, &colCtx->dyna); } -#else -void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, CollisionHeader* colHeader); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_Allocate.s") -#endif /** * Enables CollisionContext wide flags @@ -2182,7 +2155,6 @@ s32 BgCheck_EntityCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, return BgCheck_CheckCeilingImpl(colCtx, COLPOLY_IGNORE_ENTITY, outY, pos, checkHeight, outPoly, outBgId, actor); } -#ifdef NON_MATCHING /** * Tests if a line from `posA` to `posB` intersects with a poly * returns true if it does, else false @@ -2202,12 +2174,9 @@ s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, StaticLineTest checkLine; Vec3f sectorMin; Vec3f sectorMax; - s32 k; + s32 temp_lo; StaticLookup* lookup; s32 j; - StaticLookup* jLookup; - s32 temp_lo; - s32 pad[2]; lookupTbl = colCtx->lookupTbl; posBTemp = *posB; @@ -2247,11 +2216,15 @@ s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, sectorMax.z = colCtx->subdivLength.z + sectorMin.z; for (i = subdivMin[2]; i < subdivMax[2] + 1; i++) { - jLookup = iLookup + subdivMin[1] * colCtx->subdivAmount.x; + StaticLookup* jLookup = iLookup + subdivMin[1] * colCtx->subdivAmount.x; + s32 pad; + sectorMin.y = subdivMin[1] * colCtx->subdivLength.y + colCtx->minBounds.y; sectorMax.y = colCtx->subdivLength.y + sectorMin.y; for (j = subdivMin[1]; j < subdivMax[1] + 1; j++) { + s32 k; + lookup = jLookup + subdivMin[0]; sectorMin.x = subdivMin[0] * colCtx->subdivLength.x + colCtx->minBounds.x; sectorMax.x = colCtx->subdivLength.x + sectorMin.x; @@ -2292,9 +2265,6 @@ s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, } return result; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_CheckLineImpl.s") -#endif /** * Get bccFlags @@ -3373,8 +3343,6 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_RaycastFloorDyna.s") #endif -#ifdef NON_MATCHING -// regalloc, minor instruction ordering /** * Performs collision detection on a BgActor's wall polys on sphere `pos`, `radius` * returns true if a collision was detected @@ -3401,8 +3369,6 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo f32 invNormalXZ; f32 planeDist; f32 temp_f18; - f32 zIntersectDist; - f32 xIntersectDist; f32 zMin; f32 zMax; f32 xMin; @@ -3472,6 +3438,8 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo } } if (CollisionPoly_CheckZIntersectApprox(poly, dyna->vtxList, resultPos.x, pos->y, &intersect)) { + s32 pad; + if (fabsf(intersect - resultPos.z) <= radius / temp_f18) { if ((intersect - resultPos.z) * nz <= 4.0f) { if (BgCheck_ComputeWallDisplacement(colCtx, poly, &resultPos.x, &resultPos.z, nx, ny, nz, @@ -3547,7 +3515,8 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo } if (CollisionPoly_CheckXIntersectApprox(poly, dyna->vtxList, pos->y, resultPos.z, &intersect)) { - xIntersectDist = intersect - resultPos.x; + f32 xIntersectDist = intersect - resultPos.x; + if (fabsf(xIntersectDist) <= radius / temp_f18) { if (xIntersectDist * nx <= 4.0f) { if (BgCheck_ComputeWallDisplacement(colCtx, poly, &resultPos.x, &resultPos.z, nx, ny, nz, @@ -3567,12 +3536,6 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo *outZ = resultPos.z; return result; } -#else -s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCollisionContext* dyna, SSList* ssList, - f32* outX, f32* outZ, CollisionPoly** outPoly, s32* outBgId, Vec3f* pos, f32 radius, - s32 bgId, Actor* actor); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_SphVsDynaWallInBgActor.s") -#endif /** * Performs collision detection on all dyna poly walls using sphere `pos`, `radius` @@ -4028,7 +3991,7 @@ void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, GlobalContext* globa for (i = 0; i < BG_ACTOR_MAX; i++) { flag = dyna->bgActorFlags[i]; if ((flag & 1) && !(flag & 2)) { - Actor_SetObjectSegment(globalCtx, dyna->bgActors[i].actor); + Actor_SetObjectDependency(globalCtx, dyna->bgActors[i].actor); CollisionHeader_SegmentedToVirtual(dyna->bgActors[i].colHeader); } } diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 4c25024706..1e983c9541 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -312,7 +312,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetMode.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DF840.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeMode.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DF86C.s") diff --git a/src/code/z_cheap_proc.c b/src/code/z_cheap_proc.c new file mode 100644 index 0000000000..d0709fde96 --- /dev/null +++ b/src/code/z_cheap_proc.c @@ -0,0 +1,39 @@ +#include "global.h" + +/** + * Draws a display list to the opaque display buffer + */ +void Gfx_DrawDListOpa(GlobalContext* globalCtx, Gfx* dlist) { + Gfx* dl; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + dl = POLY_OPA_DISP; + + gSPDisplayList(&dl[0], &sSetupDL[6 * 0x19]); + gSPMatrix(&dl[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&dl[2], dlist); + + POLY_OPA_DISP = &dl[3]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +/** + * Draws a display list to the translucent display buffer + */ +void Gfx_DrawDListXlu(GlobalContext* globalCtx, Gfx* dlist) { + Gfx* dl; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + dl = POLY_XLU_DISP; + + gSPDisplayList(&dl[0], &sSetupDL[6 * 0x19]); + gSPMatrix(&dl[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&dl[2], dlist); + + POLY_XLU_DISP = &dl[3]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index e11e6cbd74..ddf21fe172 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -27,12 +27,12 @@ Vec3f D_801EE1C0; Vec3f D_801EE1D0; Vec3f D_801EE1E0; Vec3f D_801EE1F0; -EffSparkParams D_801EE200; +EffectSparkInit D_801EE200; TriNorm D_801EE6C8; TriNorm D_801EE700; -EffSparkParams D_801EE738; -EffSparkParams D_801EEC00; -EffSparkParams D_801EF0C8; +EffectSparkInit D_801EE738; +EffectSparkInit D_801EEC00; +EffectSparkInit D_801EF0C8; TriNorm D_801EF590; TriNorm D_801EF5C8; TriNorm D_801EF600; @@ -1382,14 +1382,14 @@ void CollisionCheck_NoBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* #ifdef NON_MATCHING // needs in-function static bss void CollisionCheck_BlueBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v) { - static EffSparkParams D_801EEC00; + static EffectSparkInit D_801EEC00; s32 effectIndex; D_801EEC00.position.x = v->x; D_801EEC00.position.x = v->y; D_801EEC00.position.x = v->z; - D_801EEC00.particleFactor1 = 5; - D_801EEC00.particleFactor2 = 5; + D_801EEC00.uDiv = 5; + D_801EEC00.vDiv = 5; D_801EEC00.colorStart[0].r = 10; D_801EEC00.colorStart[0].g = 10; D_801EEC00.colorStart[0].b = 200; @@ -1422,12 +1422,12 @@ void CollisionCheck_BlueBlood(GlobalContext* globalCtx, Collider* collider, Vec3 D_801EEC00.colorEnd[3].g = 0; D_801EEC00.colorEnd[3].b = 64; D_801EEC00.colorEnd[3].a = 0; - D_801EEC00.age = 0; + D_801EEC00.timer = 0; D_801EEC00.duration = 16; - D_801EEC00.velocity = 8.0f; + D_801EEC00.speed = 8.0f; D_801EEC00.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, 0, 0, 1, &D_801EEC00); + Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EEC00); } #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_BlueBlood.s") @@ -1440,14 +1440,14 @@ void CollisionCheck_BlueBlood(GlobalContext* globalCtx, Collider* collider, Vec3 #ifdef NON_MATCHING // needs in-function static bss void CollisionCheck_GreenBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v) { - static EffSparkParams D_801EF0C8; + static EffectSparkInit D_801EF0C8; s32 effectIndex; D_801EF0C8.position.x = v->x; D_801EF0C8.position.x = v->y; D_801EF0C8.position.x = v->z; - D_801EF0C8.particleFactor1 = 5; - D_801EF0C8.particleFactor2 = 5; + D_801EF0C8.uDiv = 5; + D_801EF0C8.vDiv = 5; D_801EF0C8.colorStart[0].r = 10; D_801EF0C8.colorStart[0].g = 200; D_801EF0C8.colorStart[0].b = 10; @@ -1480,11 +1480,11 @@ void CollisionCheck_GreenBlood(GlobalContext* globalCtx, Collider* collider, Vec D_801EF0C8.colorEnd[3].g = 64; D_801EF0C8.colorEnd[3].b = 0; D_801EF0C8.colorEnd[3].a = 0; - D_801EF0C8.age = 0; + D_801EF0C8.timer = 0; D_801EF0C8.duration = 16; - D_801EF0C8.velocity = 8.0f; + D_801EF0C8.speed = 8.0f; D_801EF0C8.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, 0, 0, 1, &D_801EF0C8); + Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EF0C8); } #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_GreenBlood.s") @@ -1525,7 +1525,7 @@ void CollisionCheck_HitSolid(GlobalContext* globalCtx, ColliderInfo* info, Colli if (collider->actor == NULL) { play_sound(NA_SE_IT_SHIELD_BOUND); } else { - func_8019F1C0(&collider->actor->projectedPos, NA_SE_IT_SHIELD_BOUND); + Audio_PlaySfxAtPos(&collider->actor->projectedPos, NA_SE_IT_SHIELD_BOUND); } } else if (flags == TOUCH_SFX_NORMAL) { EffectSsHitMark_SpawnFixedScale(globalCtx, 3, hitPos); @@ -1539,14 +1539,14 @@ void CollisionCheck_HitSolid(GlobalContext* globalCtx, ColliderInfo* info, Colli if (collider->actor == NULL) { play_sound(NA_SE_IT_SHIELD_BOUND); } else { - func_8019F1C0(&collider->actor->projectedPos, NA_SE_IT_SHIELD_BOUND); + Audio_PlaySfxAtPos(&collider->actor->projectedPos, NA_SE_IT_SHIELD_BOUND); } } else if (flags == TOUCH_SFX_WOOD) { EffectSsHitMark_SpawnFixedScale(globalCtx, 1, hitPos); if (collider->actor == NULL) { play_sound(NA_SE_IT_REFLECTION_WOOD); } else { - func_8019F1C0(&collider->actor->projectedPos, NA_SE_IT_REFLECTION_WOOD); + Audio_PlaySfxAtPos(&collider->actor->projectedPos, NA_SE_IT_REFLECTION_WOOD); } } } @@ -1557,13 +1557,13 @@ void CollisionCheck_HitSolid(GlobalContext* globalCtx, ColliderInfo* info, Colli s32 CollisionCheck_SwordHitAudio(Collider* at, ColliderInfo* acInfo) { if (at->actor != NULL && at->actor->category == ACTORCAT_PLAYER) { if (acInfo->elemType == ELEMTYPE_UNK0) { - func_8019F1C0(&at->actor->projectedPos, NA_SE_IT_SWORD_STRIKE); + Audio_PlaySfxAtPos(&at->actor->projectedPos, NA_SE_IT_SWORD_STRIKE); } else if (acInfo->elemType == ELEMTYPE_UNK1) { - func_8019F1C0(&at->actor->projectedPos, NA_SE_IT_SWORD_STRIKE_HARD); + Audio_PlaySfxAtPos(&at->actor->projectedPos, NA_SE_IT_SWORD_STRIKE_HARD); } else if (acInfo->elemType == ELEMTYPE_UNK2) { - func_8019F1C0(&at->actor->projectedPos, 0); + Audio_PlaySfxAtPos(&at->actor->projectedPos, 0); } else if (acInfo->elemType == ELEMTYPE_UNK3) { - func_8019F1C0(&at->actor->projectedPos, 0); + Audio_PlaySfxAtPos(&at->actor->projectedPos, 0); } } return 1; @@ -1618,7 +1618,7 @@ void CollisionCheck_HitEffects(GlobalContext* globalCtx, Collider* at, ColliderI if (ac->actor == NULL) { play_sound(NA_SE_IT_SHIELD_BOUND); } else { - func_8019F1C0(&ac->actor->projectedPos, NA_SE_IT_SHIELD_BOUND); + Audio_PlaySfxAtPos(&ac->actor->projectedPos, NA_SE_IT_SHIELD_BOUND); } } } @@ -3751,14 +3751,14 @@ void Collider_UpdateSphere(s32 limb, ColliderSphere* collider) { #ifdef NON_MATCHING // needs in-function static bss void CollisionCheck_SpawnRedBlood(GlobalContext* globalCtx, Vec3f* v) { - static EffSparkParams D_801EE200; + static EffectSparkInit D_801EE200; s32 effectIndex; D_801EE200.position.x = v->x; D_801EE200.position.x = v->y; D_801EE200.position.x = v->z; - D_801EE200.particleFactor1 = 5; - D_801EE200.particleFactor2 = 5; + D_801EE200.uDiv = 5; + D_801EE200.vDiv = 5; D_801EE200.colorStart[0].r = 128; D_801EE200.colorStart[0].g = 0; D_801EE200.colorStart[0].b = 64; @@ -3791,12 +3791,12 @@ void CollisionCheck_SpawnRedBlood(GlobalContext* globalCtx, Vec3f* v) { D_801EE200.colorEnd[3].g = 0; D_801EE200.colorEnd[3].b = 64; D_801EE200.colorEnd[3].a = 0; - D_801EE200.age = 0; + D_801EE200.timer = 0; D_801EE200.duration = 16; - D_801EE200.velocity = 8.0f; + D_801EE200.speed = 8.0f; D_801EE200.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, 0, 0, 1, &D_801EE200); + Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EE200); } #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnRedBlood.s") @@ -3809,14 +3809,14 @@ void CollisionCheck_SpawnRedBlood(GlobalContext* globalCtx, Vec3f* v) { #ifdef NON_MATCHING // needs in-function static bss void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) { - static EffSparkParams D_801EE738; + static EffectSparkInit D_801EE738; s32 effectIndex; D_801EE738.position.x = v->x; D_801EE738.position.x = v->y; D_801EE738.position.x = v->z; - D_801EE738.particleFactor1 = 5; - D_801EE738.particleFactor2 = 5; + D_801EE738.uDiv = 5; + D_801EE738.vDiv = 5; D_801EE738.colorStart[0].r = 255; D_801EE738.colorStart[0].g = 255; D_801EE738.colorStart[0].b = 255; @@ -3849,12 +3849,12 @@ void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) { D_801EE738.colorEnd[3].g = 0; D_801EE738.colorEnd[3].b = 0; D_801EE738.colorEnd[3].a = 0; - D_801EE738.age = 0; + D_801EE738.timer = 0; D_801EE738.duration = 16; - D_801EE738.velocity = 8.0f; + D_801EE738.speed = 8.0f; D_801EE738.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, 0, 0, 1, &D_801EE738); + Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EE738); } #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnWaterDroplets.s") @@ -3864,7 +3864,7 @@ void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) { * Spawns streaks of light from hits against solid objects */ void CollisionCheck_SpawnShieldParticles(GlobalContext* globalCtx, Vec3f* v) { - static EffShieldParticleInit shieldParticleInitMetal = { + static EffectShieldParticleInit shieldParticleInitMetal = { 16, { 0, 0, 0 }, { 0, 200, 255, 255 }, @@ -3889,7 +3889,7 @@ void CollisionCheck_SpawnShieldParticles(GlobalContext* globalCtx, Vec3f* v) { shieldParticleInitMetal.lightPoint.y = shieldParticleInitMetal.position.y; shieldParticleInitMetal.lightPoint.z = shieldParticleInitMetal.position.z; - Effect_Add(globalCtx, &effectIndex, 3, 0, 1, &shieldParticleInitMetal); + Effect_Add(globalCtx, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &shieldParticleInitMetal); } /** @@ -3905,7 +3905,7 @@ void CollisionCheck_SpawnShieldParticlesMetal(GlobalContext* globalCtx, Vec3f* v */ void CollisionCheck_SpawnShieldParticlesMetalSound(GlobalContext* globalCtx, Vec3f* v, Vec3f* pos) { CollisionCheck_SpawnShieldParticles(globalCtx, v); - func_8019F1C0(pos, NA_SE_IT_SHIELD_REFLECT_SW); + Audio_PlaySfxAtPos(pos, NA_SE_IT_SHIELD_REFLECT_SW); } /** @@ -3919,7 +3919,7 @@ void CollisionCheck_SpawnShieldParticlesMetal2(GlobalContext* globalCtx, Vec3f* * Spawns streaks of light and makes a wooden sound */ void CollisionCheck_SpawnShieldParticlesWood(GlobalContext* globalCtx, Vec3f* v, Vec3f* pos) { - static EffShieldParticleInit shieldParticleInitWood = { + static EffectShieldParticleInit shieldParticleInitWood = { 16, { 0, 0, 0 }, { 0, 200, 255, 255 }, @@ -3944,8 +3944,8 @@ void CollisionCheck_SpawnShieldParticlesWood(GlobalContext* globalCtx, Vec3f* v, shieldParticleInitWood.lightPoint.y = shieldParticleInitWood.position.y; shieldParticleInitWood.lightPoint.z = shieldParticleInitWood.position.z; - Effect_Add(globalCtx, &effectIndex, 3, 0, 1, &shieldParticleInitWood); - func_8019F1C0(pos, NA_SE_IT_REFLECTION_WOOD); + Effect_Add(globalCtx, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &shieldParticleInitWood); + Audio_PlaySfxAtPos(pos, NA_SE_IT_REFLECTION_WOOD); } /** diff --git a/src/code/z_debug.c b/src/code/z_debug.c index 924a2ad305..46649a4ce1 100644 --- a/src/code/z_debug.c +++ b/src/code/z_debug.c @@ -1,11 +1,12 @@ #include "global.h" +#include "system_malloc.h" GameInfo* gGameInfo; void GameInfo_Init(void) { s32 i; - gGameInfo = (GameInfo*)SystemArena_Malloc(sizeof(GameInfo)); + gGameInfo = SystemArena_Malloc(sizeof(GameInfo)); if (1) {} gGameInfo->unk_00 = 0; gGameInfo->unk_01 = 0; diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.c index a62d4ddb9e..ab3478fa1c 100644 --- a/src/code/z_debug_display.c +++ b/src/code/z_debug_display.c @@ -116,7 +116,7 @@ void func_800E992C(GlobalContext* globalCtx, s32 arg1) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C560(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, &D_801D1DE0, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, func_800E99B0(globalCtx->state.gfxCtx, arg1)); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c index 17685de15d..8875343662 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -1,27 +1,18 @@ #include "global.h" -#ifdef NON_MATCHING -void func_800A81F0(EffectBlure* this, Vec3f* p1, Vec3f* p2) { +void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) { EffectBlureElement* elem; s32 numElements; - Vec3f sp16C; - Vec3f sp160; - Vec3f sp154; - f32 scale; - MtxF sp110; - MtxF spD0; - MtxF sp90; - MtxF sp50; - Vec3f sp44; - Vec3f sp38; + + if (this) {} + if (this) {} if (this != NULL) { - numElements = this->numElements; - if (numElements >= 16) { + if (this->numElements >= ARRAY_COUNT(this->elements)) { return; } - elem = &this->elements[numElements]; + elem = &this->elements[this->numElements]; elem->state = 1; if (!(this->flags & 2)) { @@ -32,6 +23,17 @@ void func_800A81F0(EffectBlure* this, Vec3f* p1, Vec3f* p2) { elem->p2.y = p2->y; elem->p2.z = p2->z; } else { + Vec3f sp16C; + Vec3f sp160; + Vec3f sp154; + f32 scale; + MtxF sp110; + MtxF spD0; + MtxF sp90; + MtxF sp50; + Vec3f sp44; + Vec3f sp38; + sp16C.x = ((f32)(elem - 1)->p2.x + (f32)(elem - 1)->p1.x) * 0.5f; sp16C.y = ((f32)(elem - 1)->p2.y + (f32)(elem - 1)->p1.y) * 0.5f; sp16C.z = ((f32)(elem - 1)->p2.z + (f32)(elem - 1)->p1.z) * 0.5f; @@ -41,7 +43,7 @@ void func_800A81F0(EffectBlure* this, Vec3f* p1, Vec3f* p2) { Math_Vec3f_Diff(&sp160, &sp16C, &sp154); scale = Math3D_Vec3fMagnitude(&sp154); - if (!(fabsf(scale) < D_801DC080)) { + if (!(fabsf(scale) < 0.008f)) { scale = 1.0f / scale; Math_Vec3f_Scale(&sp154, scale); @@ -66,40 +68,977 @@ void func_800A81F0(EffectBlure* this, Vec3f* p1, Vec3f* p2) { this->numElements++; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/func_800A81F0.s") -#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/func_800A8514.s") +void EffectBlure_AddSpace(EffectBlure* this) { + EffectBlureElement* elem; + s32 numElements; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/EffectBlure_Initcommon.s") + if (this != NULL) { + numElements = this->numElements; + if (numElements >= ARRAY_COUNT(this->elements)) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/EffectBlure_Init1.s") + elem = &this->elements[numElements]; + elem->state = 0; + elem->timer = 1; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/EffectBlure_Init2.s") + this->numElements++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/EffectBlure_Destroy.s") +void EffectBlure_InitElements(EffectBlure* this) { + EffectBlureElement* elem; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/EffectBlure_Update.s") + this->numElements = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/func_800A8C78.s") + for (i = 0; i < ARRAY_COUNT(this->elements); i++) { + elem = &this->elements[i]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/func_800A8DE8.s") + elem->state = 2; + elem->p1.x = 0; + elem->p1.y = 0; + elem->p1.z = 0; + elem->p2.x = 0; + elem->p2.y = 0; + elem->p2.z = 0; + elem->timer = 0; + elem->flags = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/func_800A92FC.s") +void EffectBlure_Init1(void* thisx, void* initParamsx) { + EffectBlure* this = (EffectBlure*)thisx; + EffectBlureInit1* initParams = (EffectBlureInit1*)initParamsx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/func_800A9330.s") + if ((this != NULL) && (initParams != NULL)) { + EffectBlure_InitElements(this); + this->p1StartColor.r = initParams->p1StartColor[0]; + this->p2StartColor.r = initParams->p2StartColor[0]; + this->p1EndColor.r = initParams->p1EndColor[0]; + this->p2EndColor.r = initParams->p2EndColor[0]; + this->p1StartColor.g = initParams->p1StartColor[1]; + this->p2StartColor.g = initParams->p2StartColor[1]; + this->p1EndColor.g = initParams->p1EndColor[1]; + this->p2EndColor.g = initParams->p2EndColor[1]; + this->p1StartColor.b = initParams->p1StartColor[2]; + this->p2StartColor.b = initParams->p2StartColor[2]; + this->p1EndColor.b = initParams->p1EndColor[2]; + this->p2EndColor.b = initParams->p2EndColor[2]; + this->p1StartColor.a = initParams->p1StartColor[3]; + this->p2StartColor.a = initParams->p2StartColor[3]; + this->p1EndColor.a = initParams->p1EndColor[3]; + this->p2EndColor.a = initParams->p2EndColor[3]; + this->elemDuration = initParams->elemDuration; + this->unkFlag = initParams->unkFlag; + this->calcMode = initParams->calcMode; + this->flags = 0; + this->addAngleChange = 0; + this->addAngle = 0; + this->drawMode = 0; + this->altPrimColor.r = 0; + this->altPrimColor.g = 0; + this->altPrimColor.b = 0; + this->altPrimColor.a = 0; + this->altEnvColor.r = 0; + this->altEnvColor.g = 0; + this->altEnvColor.b = 0; + this->altEnvColor.a = 0; + this->mode4Param = 1.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/func_800A9804.s") +void EffectBlure_Init2(void* thisx, void* initParamsx) { + EffectBlure* this = (EffectBlure*)thisx; + EffectBlureInit2* initParams = (EffectBlureInit2*)initParamsx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/func_800AA190.s") + if ((this != NULL) && (initParams != NULL)) { + EffectBlure_InitElements(this); + this->p1StartColor.r = initParams->p1StartColor[0]; + this->p2StartColor.r = initParams->p2StartColor[0]; + this->p1EndColor.r = initParams->p1EndColor[0]; + this->p2EndColor.r = initParams->p2EndColor[0]; + this->p1StartColor.g = initParams->p1StartColor[1]; + this->p2StartColor.g = initParams->p2StartColor[1]; + this->p1EndColor.g = initParams->p1EndColor[1]; + this->p2EndColor.g = initParams->p2EndColor[1]; + this->p1StartColor.b = initParams->p1StartColor[2]; + this->p2StartColor.b = initParams->p2StartColor[2]; + this->p1EndColor.b = initParams->p1EndColor[2]; + this->p2EndColor.b = initParams->p2EndColor[2]; + this->p1StartColor.a = initParams->p1StartColor[3]; + this->p2StartColor.a = initParams->p2StartColor[3]; + this->p1EndColor.a = initParams->p1EndColor[3]; + this->p2EndColor.a = initParams->p2EndColor[3]; + this->elemDuration = initParams->elemDuration; + this->unkFlag = initParams->unkFlag; + this->calcMode = initParams->calcMode; + this->flags = initParams->flags; + this->drawMode = initParams->drawMode; + this->addAngleChange = initParams->addAngleChange; + this->addAngle = 0; + this->mode4Param = initParams->mode4Param; + this->altPrimColor = initParams->altPrimColor; + this->altEnvColor = initParams->altEnvColor; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/func_800AA460.s") +void EffectBlure_Destroy(void* thisx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/func_800AA498.s") +s32 EffectBlure_Update(void* thisx) { + EffectBlure* this = (EffectBlure*)thisx; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/func_800AA700.s") + if (this == NULL) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/func_800AABE0.s") + if (this->numElements == 0) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_blure/EffectBlure_Draw.s") + while (true) { + if (this->elements[0].state == 0) { + for (i = 0; i < ARRAY_COUNT(this->elements) - 1; i++) { + this->elements[i] = this->elements[i + 1]; + } + + this->elements[i].state = 2; + this->elements[i].p1.x = 0; + this->elements[i].p1.y = 0; + this->elements[i].p1.z = 0; + this->elements[i].p2.x = 0; + this->elements[i].p2.y = 0; + this->elements[i].p2.z = 0; + this->elements[i].flags = 0; + this->elements[i].timer = 0; + + this->numElements--; + if (this->numElements <= 0) { + this->numElements = 0; + return 0; + } + } else { + break; + } + } + + if (this->elements[0].state == 2) { + return 0; + } + + for (i = 0; i < this->numElements; i++) { + this->elements[i].timer++; + } + + if (this->elemDuration < this->elements[0].timer) { + for (i = 0; i < ARRAY_COUNT(this->elements) - 1; i++) { + this->elements[i] = this->elements[i + 1]; + if (this->elements[i].timer >= this->elemDuration) { + this->elements[i].timer = this->elemDuration; + } + } + + this->elements[i].state = 2; + this->elements[i].p1.x = 0; + this->elements[i].p1.y = 0; + this->elements[i].p1.z = 0; + this->elements[i].p2.x = 0; + this->elements[i].p2.y = 0; + this->elements[i].p2.z = 0; + this->elements[i].flags = 0; + this->elements[i].timer = 0; + + this->numElements--; + if (this->numElements <= 0) { + this->numElements = 0; + return 0; + } + return 0; + } + + for (i = 0; i < this->numElements; i++) { + if (this->elements[i].timer >= this->elemDuration) { + this->elements[i].timer = this->elemDuration; + } + } + + this->addAngle += this->addAngleChange; + return 0; +} + +void EffectBlure_UpdateFlags(EffectBlureElement* elem) { + Vec3f sp64; + Vec3f sp58; + Vec3f sp4C; + Vec3f sp40; + EffectBlureElement* prev = elem - 1; + EffectBlureElement* next = elem + 1; + f32 sp34; + f32 sp30; + f32 sp2C; + + if (((elem - 1)->state == 0) || ((elem + 1)->state == 0)) { + elem->flags &= ~3; + elem->flags |= 2; + } else { + Math_Vec3s_DiffToVec3f(&sp64, &elem->p1, &prev->p1); + Math_Vec3s_DiffToVec3f(&sp58, &elem->p2, &prev->p2); + Math_Vec3s_DiffToVec3f(&sp4C, &next->p1, &elem->p1); + Math_Vec3s_DiffToVec3f(&sp40, &next->p2, &elem->p2); + + if (Math3D_AngleBetweenVectors(&sp64, &sp4C, &sp34) || Math3D_AngleBetweenVectors(&sp58, &sp40, &sp30) || + Math3D_AngleBetweenVectors(&sp4C, &sp40, &sp2C)) { + elem->flags &= ~3; + elem->flags |= 0; + } else if ((sp34 <= -0.5f) || (sp30 <= -0.5f) || (sp2C <= 0.7071f)) { + elem->flags &= ~3; + elem->flags |= 0; + } else { + elem->flags &= ~3; + elem->flags |= 1; + } + } +} + +void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3s* vec1, Vec3s* vec2, + Color_RGBA8* color1, Color_RGBA8* color2) { + Vec3s sp30; + f32 mode4Param; + EffectBlureElement* elem = &this->elements[index]; + + switch (this->calcMode) { + case 1: + vec1->x = func_800B09D0(elem->p1.x, elem->p2.x, ratio); + vec1->y = func_800B09D0(elem->p1.y, elem->p2.y, ratio); + vec1->z = func_800B09D0(elem->p1.z, elem->p2.z, ratio); + vec2->x = elem->p2.x; + vec2->y = elem->p2.y; + vec2->z = elem->p2.z; + break; + + case 2: + vec1->x = elem->p1.x; + vec1->y = elem->p1.y; + vec1->z = elem->p1.z; + vec2->x = func_800B09D0(elem->p2.x, elem->p1.x, ratio); + vec2->y = func_800B09D0(elem->p2.y, elem->p1.y, ratio); + vec2->z = func_800B09D0(elem->p2.z, elem->p1.z, ratio); + break; + + case 3: + ratio *= 0.5f; + vec1->x = func_800B09D0(elem->p1.x, elem->p2.x, ratio); + vec1->y = func_800B09D0(elem->p1.y, elem->p2.y, ratio); + vec1->z = func_800B09D0(elem->p1.z, elem->p2.z, ratio); + vec2->x = func_800B09D0(elem->p2.x, elem->p1.x, ratio); + vec2->y = func_800B09D0(elem->p2.y, elem->p1.y, ratio); + vec2->z = func_800B09D0(elem->p2.z, elem->p1.z, ratio); + ratio *= 2.0f; + break; + + case 4: + sp30.x = elem->p1.x - elem->p2.x; + sp30.y = elem->p1.y - elem->p2.y; + sp30.z = elem->p1.z - elem->p2.z; + mode4Param = this->mode4Param - 1.0f; + + vec1->x = (sp30.x * 0.5f * mode4Param * ratio) + elem->p1.x; + vec1->y = (sp30.y * 0.5f * mode4Param * ratio) + elem->p1.y; + if (1) {} // Necessary to match + vec1->z = (sp30.z * 0.5f * mode4Param * ratio) + elem->p1.z; + + vec2->x = -(sp30.x * 0.5f * mode4Param * ratio) + elem->p2.x; + vec2->y = -(sp30.y * 0.5f * mode4Param * ratio) + elem->p2.y; + vec2->z = -(sp30.z * 0.5f * mode4Param * ratio) + elem->p2.z; + break; + + case 0: + default: + vec1->x = elem->p1.x; + vec1->y = elem->p1.y; + vec1->z = elem->p1.z; + vec2->x = elem->p2.x; + vec2->y = elem->p2.y; + vec2->z = elem->p2.z; + break; + } + + sp30 = sp30; // Optimized out but seems necessary to match stack usage + + if (this->flags & 0x10) { + color1->r = color1->g = color1->b = color1->a = 255; + color2->r = color2->g = color2->b = color2->a = 255; + } else { + color1->r = func_800B0A24(this->p1StartColor.r, this->p1EndColor.r, ratio); + color1->g = func_800B0A24(this->p1StartColor.g, this->p1EndColor.g, ratio); + color1->b = func_800B0A24(this->p1StartColor.b, this->p1EndColor.b, ratio); + color1->a = func_800B0A24(this->p1StartColor.a, this->p1EndColor.a, ratio); + color2->r = func_800B0A24(this->p2StartColor.r, this->p2EndColor.r, ratio); + color2->g = func_800B0A24(this->p2StartColor.g, this->p2EndColor.g, ratio); + color2->b = func_800B0A24(this->p2StartColor.b, this->p2EndColor.b, ratio); + color2->a = func_800B0A24(this->p2StartColor.a, this->p2EndColor.a, ratio); + } +} + +void EffectBlure_SetupSmooth(EffectBlure* this, GraphicsContext* gfxCtx) { + OPEN_DISPS(gfxCtx); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x26); + + CLOSE_DISPS(gfxCtx); +} + +void EffectBlure_DrawElemNoInterpolation(EffectBlure* this, EffectBlureElement* elem, s32 index, + GraphicsContext* gfxCtx) { + static Vtx_t baseVtx = VTX_T(0, 0, 0, 0, 0, 255, 255, 255, 255); + Vtx* vtx; + Vec3s sp8C; + Vec3s sp84; + f32 ratio; + Color_RGBA8 sp7C; + Color_RGBA8 sp78; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + + OPEN_DISPS(gfxCtx); + + Math_Vec3s_ToVec3f(&sp6C, &this->elements[0].p2); + + vtx = GRAPH_ALLOC(gfxCtx, sizeof(Vtx[4])); + if (vtx == NULL) { + } else { + vtx[0].v = baseVtx; + vtx[1].v = baseVtx; + vtx[2].v = baseVtx; + vtx[3].v = baseVtx; + + ratio = (f32)elem->timer / (f32)this->elemDuration; + EffectBlure_GetComputedValues(this, index, ratio, &sp8C, &sp84, &sp7C, &sp78); + + sp60.x = sp84.x; + sp60.y = sp84.y; + sp60.z = sp84.z; + Math_Vec3f_Diff(&sp60, &sp6C, &sp54); + Math_Vec3f_Scale(&sp54, 10.0f); + vtx[0].v.ob[0] = sp54.x; + vtx[0].v.ob[1] = sp54.y; + vtx[0].v.ob[2] = sp54.z; + vtx[0].v.cn[0] = sp78.r; + vtx[0].v.cn[1] = sp78.g; + vtx[0].v.cn[2] = sp78.b; + vtx[0].v.cn[3] = sp78.a; + + sp60.x = sp8C.x; + sp60.y = sp8C.y; + sp60.z = sp8C.z; + Math_Vec3f_Diff(&sp60, &sp6C, &sp54); + Math_Vec3f_Scale(&sp54, 10.0f); + vtx[1].v.ob[0] = sp54.x; + vtx[1].v.ob[1] = sp54.y; + vtx[1].v.ob[2] = sp54.z; + vtx[1].v.cn[0] = sp7C.r; + vtx[1].v.cn[1] = sp7C.g; + vtx[1].v.cn[2] = sp7C.b; + vtx[1].v.cn[3] = sp7C.a; + + ratio = (f32)(elem + 1)->timer / (f32)this->elemDuration; + EffectBlure_GetComputedValues(this, index + 1, ratio, &sp8C, &sp84, &sp7C, &sp78); + + sp60.x = sp8C.x; + sp60.y = sp8C.y; + sp60.z = sp8C.z; + Math_Vec3f_Diff(&sp60, &sp6C, &sp54); + Math_Vec3f_Scale(&sp54, 10.0f); + vtx[2].v.ob[0] = sp54.x; + vtx[2].v.ob[1] = sp54.y; + vtx[2].v.ob[2] = sp54.z; + vtx[2].v.cn[0] = sp7C.r; + vtx[2].v.cn[1] = sp7C.g; + vtx[2].v.cn[2] = sp7C.b; + vtx[2].v.cn[3] = sp7C.a; + + sp60.x = sp84.x; + sp60.y = sp84.y; + sp60.z = sp84.z; + Math_Vec3f_Diff(&sp60, &sp6C, &sp54); + Math_Vec3f_Scale(&sp54, 10.0f); + vtx[3].v.ob[0] = sp54.x; + vtx[3].v.ob[1] = sp54.y; + vtx[3].v.ob[2] = sp54.z; + vtx[3].v.cn[0] = sp78.r; + vtx[3].v.cn[1] = sp78.g; + vtx[3].v.cn[2] = sp78.b; + vtx[3].v.cn[3] = sp78.a; + + gSPVertex(POLY_XLU_DISP++, vtx, 4, 0); + gSP2Triangles(POLY_XLU_DISP++, 0, 1, 2, 0, 0, 2, 3, 0); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElement* elem, s32 index, + GraphicsContext* gfxCtx) { + static Vtx_t baseVtx = VTX_T(0, 0, 0, 0, 0, 255, 255, 255, 255); + Vtx* vtx; + Vec3s sp1EC; + Vec3s sp1E4; + f32 ratio; + Color_RGBA8 sp1DC; + Color_RGBA8 sp1D8; + Vec3f sp1CC; + Vec3f sp1C0; + Vec3f sp1B4; + Vec3f sp1A8; + Color_RGBA8 sp1A4; + Color_RGBA8 sp1A0; + Color_RGBA8 sp19C; + Color_RGBA8 sp198; + Vec3f sp18C; + Vec3f sp180; + Vec3f sp174; + Vec3f sp168; + s32 i; + Vec3f sp158; + Vec3f sp14C; + Color_RGBA8 sp148; + Color_RGBA8 sp144; + Vec3f sp138; + + OPEN_DISPS(gfxCtx); + + Math_Vec3s_ToVec3f(&sp138, &this->elements[0].p2); + + ratio = (f32)elem->timer / (f32)this->elemDuration; + EffectBlure_GetComputedValues(this, index, ratio, &sp1EC, &sp1E4, &sp1A4, &sp1A0); + Math_Vec3s_ToVec3f(&sp1CC, &sp1EC); + Math_Vec3s_ToVec3f(&sp1C0, &sp1E4); + + ratio = (f32)(elem + 1)->timer / (f32)this->elemDuration; + EffectBlure_GetComputedValues(this, index + 1, ratio, &sp1EC, &sp1E4, &sp19C, &sp198); + Math_Vec3s_ToVec3f(&sp18C, &sp1EC); + Math_Vec3s_ToVec3f(&sp180, &sp1E4); + + if ((elem->flags & 3) == 2) { + Math_Vec3f_Diff(&sp18C, &sp1CC, &sp1B4); + Math_Vec3f_Diff(&sp180, &sp1C0, &sp1A8); + } else { + Vec3f sp118; + Vec3f sp10C; + + ratio = (f32)(elem - 1)->timer / (f32)this->elemDuration; + EffectBlure_GetComputedValues(this, index - 1, ratio, &sp1EC, &sp1E4, &sp1DC, &sp1D8); + Math_Vec3s_ToVec3f(&sp118, &sp1EC); + Math_Vec3s_ToVec3f(&sp10C, &sp1E4); + Math_Vec3f_Diff(&sp18C, &sp118, &sp1B4); + Math_Vec3f_Diff(&sp180, &sp10C, &sp1A8); + } + + Math_Vec3f_Scale(&sp1B4, 0.5f); + Math_Vec3f_Scale(&sp1A8, 0.5f); + + if (((elem + 1)->flags & 3) == 2) { + Math_Vec3f_Diff(&sp18C, &sp1CC, &sp174); + Math_Vec3f_Diff(&sp180, &sp1C0, &sp168); + } else { + Vec3f sp100; + Vec3f spF4; + + ratio = (f32)(elem + 2)->timer / (f32)this->elemDuration; + EffectBlure_GetComputedValues(this, index + 2, ratio, &sp1EC, &sp1E4, &sp1DC, &sp1D8); + Math_Vec3s_ToVec3f(&sp100, &sp1EC); + Math_Vec3s_ToVec3f(&spF4, &sp1E4); + Math_Vec3f_Diff(&sp100, &sp1CC, &sp174); + Math_Vec3f_Diff(&spF4, &sp1C0, &sp168); + } + + Math_Vec3f_Scale(&sp174, 0.5f); + Math_Vec3f_Scale(&sp168, 0.5f); + + vtx = GRAPH_ALLOC(gfxCtx, sizeof(Vtx[16])); + if (vtx == NULL) { + } else { + Math_Vec3f_Diff(&sp1CC, &sp138, &sp158); + Math_Vec3f_Scale(&sp158, 10.0f); + Math_Vec3f_Diff(&sp1C0, &sp138, &sp14C); + Math_Vec3f_Scale(&sp14C, 10.0f); + + Color_RGBA8_Copy(&sp148, &sp1A4); + Color_RGBA8_Copy(&sp144, &sp1A0); + + vtx[0].v = baseVtx; + vtx[1].v = baseVtx; + + vtx[0].v.ob[0] = func_80086814(sp158.x); + vtx[0].v.ob[1] = func_80086814(sp158.y); + vtx[0].v.ob[2] = func_80086814(sp158.z); + vtx[0].v.cn[0] = sp148.r; + vtx[0].v.cn[1] = sp148.g; + vtx[0].v.cn[2] = sp148.b; + vtx[0].v.cn[3] = sp148.a; + vtx[1].v.ob[0] = func_80086814(sp14C.x); + vtx[1].v.ob[1] = func_80086814(sp14C.y); + vtx[1].v.ob[2] = func_80086814(sp14C.z); + vtx[1].v.cn[0] = sp144.r; + vtx[1].v.cn[1] = sp144.g; + vtx[1].v.cn[2] = sp144.b; + vtx[1].v.cn[3] = sp144.a; + + for (i = 1; i < 8; i++) { + s32 j1 = 2 * i; + s32 j2 = 2 * i + 1; + Vec3f spE0; + f32 temp_f28 = i / 7.0f; // t + f32 temp_f0 = SQ(temp_f28); // t^2 + f32 temp_f2 = temp_f0 * temp_f28; // t^3 + f32 temp_f20 = temp_f2 - temp_f0; // t^3 - t^2 + f32 temp_f22 = temp_f2 - 2.0f * temp_f0 + temp_f28; // t^3 - 2t^2 + t + f32 temp_f24 = 2.0f * temp_f2 - temp_f0 * 3.0f + 1.0f; // 2t^3 - 3t^2 + 1 + f32 temp_f26 = temp_f0 * 3.0f - 2.0f * temp_f2; // 3t^2 - 2t^3 + s32 pad1; + s32 pad2; + + // p = (2t^3 - 3t^2 + 1)p0 + (3t^2 - 2t^3)p1 + (t^3 - 2t^2 + t)m0 + (t^3 - t^2)m1 + spE0.x = (temp_f24 * sp1CC.x) + (temp_f26 * sp18C.x) + (temp_f22 * sp1B4.x) + (temp_f20 * sp174.x); + spE0.y = (temp_f24 * sp1CC.y) + (temp_f26 * sp18C.y) + (temp_f22 * sp1B4.y) + (temp_f20 * sp174.y); + spE0.z = (temp_f24 * sp1CC.z) + (temp_f26 * sp18C.z) + (temp_f22 * sp1B4.z) + (temp_f20 * sp174.z); + Math_Vec3f_Diff(&spE0, &sp138, &sp158); + Math_Vec3f_Scale(&sp158, 10.0f); + + spE0.x = (temp_f24 * sp1C0.x) + (temp_f26 * sp180.x) + (temp_f22 * sp1A8.x) + (temp_f20 * sp168.x); + spE0.y = (temp_f24 * sp1C0.y) + (temp_f26 * sp180.y) + (temp_f22 * sp1A8.y) + (temp_f20 * sp168.y); + spE0.z = (temp_f24 * sp1C0.z) + (temp_f26 * sp180.z) + (temp_f22 * sp1A8.z) + (temp_f20 * sp168.z); + Math_Vec3f_Diff(&spE0, &sp138, &sp14C); + Math_Vec3f_Scale(&sp14C, 10.0f); + + vtx[j1].v = baseVtx; + vtx[j2].v = baseVtx; + + vtx[j1].v.ob[0] = func_80086814(sp158.x); + vtx[j1].v.ob[1] = func_80086814(sp158.y); + vtx[j1].v.ob[2] = func_80086814(sp158.z); + vtx[j1].v.cn[0] = func_800B0A24(sp1A4.r, sp19C.r, temp_f28); + vtx[j1].v.cn[1] = func_800B0A24(sp1A4.g, sp19C.g, temp_f28); + vtx[j1].v.cn[2] = func_800B0A24(sp1A4.b, sp19C.b, temp_f28); + vtx[j1].v.cn[3] = func_800B0A24(sp1A4.a, sp19C.a, temp_f28); + + vtx[j2].v.ob[0] = func_80086814(sp14C.x); + vtx[j2].v.ob[1] = func_80086814(sp14C.y); + vtx[j2].v.ob[2] = func_80086814(sp14C.z); + vtx[j2].v.cn[0] = func_800B0A24(sp1A0.r, sp198.r, temp_f28); + vtx[j2].v.cn[1] = func_800B0A24(sp1A0.g, sp198.g, temp_f28); + vtx[j2].v.cn[2] = func_800B0A24(sp1A0.b, sp198.b, temp_f28); + vtx[j2].v.cn[3] = func_800B0A24(sp1A0.a, sp198.a, temp_f28); + } + + gSPVertex(POLY_XLU_DISP++, vtx, 16, 0); + gSP2Triangles(POLY_XLU_DISP++, 0, 1, 3, 0, 0, 3, 2, 0); + gSP2Triangles(POLY_XLU_DISP++, 2, 3, 5, 0, 2, 5, 4, 0); + gSP2Triangles(POLY_XLU_DISP++, 4, 5, 7, 0, 4, 7, 6, 0); + gSP2Triangles(POLY_XLU_DISP++, 6, 7, 9, 0, 6, 9, 8, 0); + gSP2Triangles(POLY_XLU_DISP++, 8, 9, 11, 0, 8, 11, 10, 0); + gSP2Triangles(POLY_XLU_DISP++, 10, 11, 13, 0, 10, 13, 12, 0); + gSP2Triangles(POLY_XLU_DISP++, 12, 13, 15, 0, 12, 15, 14, 0); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectBlure_DrawSmooth(EffectBlure* this2, GraphicsContext* gfxCtx) { + EffectBlure* this = this2; + EffectBlureElement* elem; + s32 i; + MtxF spDC; + MtxF sp9C; + MtxF sp5C; + Mtx* mtx; + + OPEN_DISPS(gfxCtx); + + if (this->numElements < 2) { + return; + } + + this->elements[0].flags &= ~3; + this->elements[0].flags |= 2; + + for (elem = &this->elements[1]; elem < this->elements + this->numElements - 1; elem++) { + EffectBlure_UpdateFlags(elem); + } + + this->elements[this->numElements - 1].flags &= ~3; + this->elements[this->numElements - 1].flags |= 2; + + EffectBlure_SetupSmooth(this, gfxCtx); + SkinMatrix_SetTranslate(&spDC, this->elements[0].p2.x, this->elements[0].p2.y, this->elements[0].p2.z); + SkinMatrix_SetScale(&sp9C, 0.1f, 0.1f, 0.1f); + SkinMatrix_MtxFMtxFMult(&spDC, &sp9C, &sp5C); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &sp5C); + if (mtx == NULL) { + return; + } + + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + for (i = 0, elem = &this->elements[0]; elem < this->elements + this->numElements - 1; i++, elem++) { + if ((elem->state == 0) || ((elem + 1)->state == 0)) { + continue; + } + if ((((elem->flags & 3) == 0) && (((elem + 1)->flags & 3) == 0)) || + (((elem->flags & 3) == 2) && (((elem + 1)->flags & 3) == 0)) || + (((elem->flags & 3) == 0) && (((elem + 1)->flags & 3) == 2)) || + (((elem->flags & 3) == 2) && (((elem + 1)->flags & 3) == 2))) { + EffectBlure_DrawElemNoInterpolation(this, elem, i, gfxCtx); + } else { + EffectBlure_DrawElemHermiteInterpolation(this, elem, i, gfxCtx); + } + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectBlure_SetupSimple(GraphicsContext* gfxCtx, EffectBlure* this, Vtx* vtx) { + OPEN_DISPS(gfxCtx); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x26); + + CLOSE_DISPS(gfxCtx); +} + +void EffectBlure_SetupSimpleAlt(GraphicsContext* gfxCtx, EffectBlure* this, Vtx* vtx) { + OPEN_DISPS(gfxCtx); + + gDPPipeSync(POLY_XLU_DISP++); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x26); + + gDPSetCycleType(POLY_XLU_DISP++, G_CYC_2CYCLE); + gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE); + gSPTexture(POLY_XLU_DISP++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); + + gDPLoadTextureBlock(POLY_XLU_DISP++, D_04014570, G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, + G_TX_NOMIRROR | G_TX_WRAP, 6, 5, G_TX_NOLOD, G_TX_NOLOD); + + gDPSetCombineLERP(POLY_XLU_DISP++, TEXEL0, PRIMITIVE, PRIM_LOD_FRAC, TEXEL0, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, + ENVIRONMENT, COMBINED, ENVIRONMENT, 0, 0, 0, COMBINED); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR); + gSPSetGeometryMode(POLY_XLU_DISP++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH); + gDPPipeSync(POLY_XLU_DISP++); + + gDPSetEnvColor(POLY_XLU_DISP++, this->altEnvColor.r, this->altEnvColor.g, this->altEnvColor.b, this->altEnvColor.a); + + CLOSE_DISPS(gfxCtx); +} + +void (*sSetupHandlers[])(GraphicsContext* gfxCtx, EffectBlure* this, Vtx* vtx) = { + EffectBlure_SetupSimple, + EffectBlure_SetupSimpleAlt, +}; + +s32 D_801AE268 = 0; // unused + +void EffectBlure_DrawSimpleVertices(GraphicsContext* gfxCtx, EffectBlure* this, Vtx* vtx) { + Mtx* mtx; + + OPEN_DISPS(gfxCtx); + + sSetupHandlers[this->drawMode](gfxCtx, this, vtx); + gDPPipeSync(POLY_XLU_DISP++); + + { + Vec3f sp1B0; + Vec3f sp1A4; + Vec3f sp198; + f32 alphaRatio; + MtxF sp154; + MtxF sp114; + MtxF spD4; + MtxF sp94; + f32 scale; + s32 i; + s32 j; + + j = 0; + + for (i = 0; i < this->numElements - 1; i++) { + if (this->drawMode == 1) { + alphaRatio = (f32)this->elements[i].timer / (f32)this->elemDuration; + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, this->altPrimColor.r, this->altPrimColor.g, + this->altPrimColor.b, this->altPrimColor.a * (1.0f - alphaRatio)); + gDPPipeSync(POLY_XLU_DISP++); + } + + if (1) {} // Necessary to match + + gSPVertex(POLY_XLU_DISP++, &vtx[j], 4, 0); + gSP2Triangles(POLY_XLU_DISP++, 0, 1, 3, 0, 0, 3, 2, 0); + + if (this->flags & 4) { + sp1B0.x = ((f32)vtx[4 * i + 0].v.ob[0] + (f32)vtx[4 * i + 1].v.ob[0]) * 0.5f; + sp1B0.y = ((f32)vtx[4 * i + 0].v.ob[1] + (f32)vtx[4 * i + 1].v.ob[1]) * 0.5f; + sp1B0.z = ((f32)vtx[4 * i + 0].v.ob[2] + (f32)vtx[4 * i + 1].v.ob[2]) * 0.5f; + sp1A4.x = ((f32)vtx[4 * i + 2].v.ob[0] + (f32)vtx[4 * i + 3].v.ob[0]) * 0.5f; + sp1A4.y = ((f32)vtx[4 * i + 2].v.ob[1] + (f32)vtx[4 * i + 3].v.ob[1]) * 0.5f; + sp1A4.z = ((f32)vtx[4 * i + 2].v.ob[2] + (f32)vtx[4 * i + 3].v.ob[2]) * 0.5f; + + Math_Vec3f_Diff(&sp1A4, &sp1B0, &sp198); + scale = sqrtf(SQXYZ(sp198)); + + if (fabsf(scale) > 0.0005f) { + scale = 1.0f / scale; + Math_Vec3f_Scale(&sp198, scale); + + SkinMatrix_SetTranslate(&sp154, sp1B0.x, sp1B0.y, sp1B0.z); + SkinMatrix_SetRotateAroundVec(&sp114, 0x3FFF, sp198.x, sp198.y, sp198.z); + SkinMatrix_MtxFMtxFMult(&sp154, &sp114, &spD4); + SkinMatrix_SetTranslate(&sp154, -sp1B0.x, -sp1B0.y, -sp1B0.z); + SkinMatrix_MtxFMtxFMult(&spD4, &sp154, &sp94); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &sp94); + if (mtx == NULL) { + break; + } + + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPVertex(POLY_XLU_DISP++, &vtx[j], 4, 0); + gSP2Triangles(POLY_XLU_DISP++, 0, 1, 3, 0, 0, 3, 2, 0); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + } + + j += 4; + } + } + + CLOSE_DISPS(gfxCtx); +} + +Vtx_t D_801AE26C[] = { + VTX_T(0, 0, 0, 0, 1024, 255, 255, 255, 255), + VTX_T(0, 0, 0, 0, 0, 255, 255, 255, 255), + VTX_T(0, 0, 0, 2048, 1024, 255, 255, 255, 255), + VTX_T(0, 0, 0, 2048, 0, 255, 255, 255, 255), +}; + +Vtx_t D_801AE2AC[] = { + VTX_T(0, 0, 0, 2048, 1024, 255, 255, 255, 255), + VTX_T(0, 0, 0, 2048, 0, 255, 255, 255, 255), + VTX_T(0, 0, 0, 2048, 1024, 255, 255, 255, 255), + VTX_T(0, 0, 0, 2048, 0, 255, 255, 255, 255), +}; + +void EffectBlure_DrawSimple(EffectBlure* this2, GraphicsContext* gfxCtx) { + EffectBlure* this = this2; + Vtx* vtx; + Vtx* vtxIter; + EffectBlureElement* elem; + s32 vtxCount; + s32 i; + s32 j; + Vec3s sp74; + Vec3s sp6C; + f32 ratio; + Color_RGBA8 sp64; + Color_RGBA8 sp60; + + if (this->numElements >= 2) { + vtxCount = this->numElements * 4; + + vtx = GRAPH_ALLOC(gfxCtx, ALIGN16(vtxCount * sizeof(Vtx))); + if (vtx == NULL) { + return; + } + + vtxIter = vtx; + for (i = 0; i < 4; i++) { + vtxIter->v = D_801AE26C[i]; + vtxIter++; + } + + if (this->numElements >= 2) { + for (elem = this->elements; elem < this->elements + this->numElements - 2; elem++) { + for (i = 0; i < 4; i++) { + vtxIter->v = D_801AE2AC[i]; + vtxIter++; + } + } + } + + for (i = 0; i < this->numElements; i++) { + elem = &this->elements[i]; + + ratio = (f32)elem->timer / (f32)this->elemDuration; + EffectBlure_GetComputedValues(this, i, ratio, &sp74, &sp6C, &sp64, &sp60); + + j = i * 4 - 2; + if (j >= 0) { + vtx[j].v.ob[0] = sp74.x; + vtx[j].v.ob[1] = sp74.y; + vtx[j].v.ob[2] = sp74.z; + vtx[j].v.cn[0] = sp64.r; + vtx[j].v.cn[1] = sp64.g; + vtx[j].v.cn[2] = sp64.b; + vtx[j].v.cn[3] = sp64.a; + } + + j++; + if (j >= 0) { + vtx[j].v.ob[0] = sp6C.x; + vtx[j].v.ob[1] = sp6C.y; + vtx[j].v.ob[2] = sp6C.z; + vtx[j].v.cn[0] = sp60.r; + vtx[j].v.cn[1] = sp60.g; + vtx[j].v.cn[2] = sp60.b; + vtx[j].v.cn[3] = sp60.a; + } + + j++; + if (vtxCount >= j) { + vtx[j].v.ob[0] = sp74.x; + vtx[j].v.ob[1] = sp74.y; + vtx[j].v.ob[2] = sp74.z; + vtx[j].v.cn[0] = sp64.r; + vtx[j].v.cn[1] = sp64.g; + vtx[j].v.cn[2] = sp64.b; + vtx[j].v.cn[3] = sp64.a; + } + + j++; + if (vtxCount >= j) { + vtx[j].v.ob[0] = sp6C.x; + vtx[j].v.ob[1] = sp6C.y; + vtx[j].v.ob[2] = sp6C.z; + vtx[j].v.cn[0] = sp60.r; + vtx[j].v.cn[1] = sp60.g; + vtx[j].v.cn[2] = sp60.b; + vtx[j].v.cn[3] = sp60.a; + } + } + + EffectBlure_DrawSimpleVertices(gfxCtx, this, vtx); + } +} + +void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { + EffectBlure* this = (EffectBlure*)thisx; + Vtx* vtx; + EffectBlureElement* elem; + s32 i; + s32 j; + s32 phi_t2; + + OPEN_DISPS(gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->numElements != 0) { + if (this->flags == 0) { + func_8012C560(gfxCtx); + gDPPipeSync(POLY_XLU_DISP++); + + vtx = GRAPH_ALLOC(gfxCtx, sizeof(Vtx[32])); + if (vtx == NULL) { + } else { + j = 0; + for (i = 0; i < this->numElements; i++) { + elem = &this->elements[i]; + + if (elem->state == 1) { + f32 ratio = (f32)elem->timer / (f32)this->elemDuration; + + switch (this->calcMode) { + case 1: + vtx[j].v.ob[0] = func_800B09D0(elem->p1.x, elem->p2.x, ratio); + vtx[j].v.ob[1] = func_800B09D0(elem->p1.y, elem->p2.y, ratio); + vtx[j].v.ob[2] = func_800B09D0(elem->p1.z, elem->p2.z, ratio); + vtx[j + 1].v.ob[0] = elem->p2.x; + vtx[j + 1].v.ob[1] = elem->p2.y; + vtx[j + 1].v.ob[2] = elem->p2.z; + break; + case 2: + vtx[j].v.ob[0] = elem->p1.x; + vtx[j].v.ob[1] = elem->p1.y; + vtx[j].v.ob[2] = elem->p1.z; + vtx[j + 1].v.ob[0] = func_800B09D0(elem->p2.x, elem->p1.x, ratio); + vtx[j + 1].v.ob[1] = func_800B09D0(elem->p2.y, elem->p1.y, ratio); + vtx[j + 1].v.ob[2] = func_800B09D0(elem->p2.z, elem->p1.z, ratio); + break; + case 3: + ratio *= 0.5f; + vtx[j].v.ob[0] = func_800B09D0(elem->p1.x, elem->p2.x, ratio); + vtx[j].v.ob[1] = func_800B09D0(elem->p1.y, elem->p2.y, ratio); + vtx[j].v.ob[2] = func_800B09D0(elem->p1.z, elem->p2.z, ratio); + vtx[j + 1].v.ob[0] = func_800B09D0(elem->p2.x, elem->p1.x, ratio); + vtx[j + 1].v.ob[1] = func_800B09D0(elem->p2.y, elem->p1.y, ratio); + vtx[j + 1].v.ob[2] = func_800B09D0(elem->p2.z, elem->p1.z, ratio); + ratio *= 2.0f; + break; + case 0: + default: + vtx[j].v.ob[0] = elem->p1.x; + vtx[j].v.ob[1] = elem->p1.y; + vtx[j].v.ob[2] = elem->p1.z; + vtx[j + 1].v.ob[0] = elem->p2.x; + vtx[j + 1].v.ob[1] = elem->p2.y; + vtx[j + 1].v.ob[2] = elem->p2.z; + break; + } + + vtx[j].v.flag = 0; + vtx[j].v.tc[0] = 0; + vtx[j].v.tc[1] = 0; + vtx[j].v.cn[0] = func_800B0A24(this->p1StartColor.r, this->p1EndColor.r, ratio); + vtx[j].v.cn[1] = func_800B0A24(this->p1StartColor.g, this->p1EndColor.g, ratio); + vtx[j].v.cn[2] = func_800B0A24(this->p1StartColor.b, this->p1EndColor.b, ratio); + vtx[j].v.cn[3] = func_800B0A24(this->p1StartColor.a, this->p1EndColor.a, ratio); + j++; + + vtx[j].v.flag = 0; + vtx[j].v.tc[0] = 0; + vtx[j].v.tc[1] = 0; + vtx[j].v.cn[0] = func_800B0A24(this->p2StartColor.r, this->p2EndColor.r, ratio); + vtx[j].v.cn[1] = func_800B0A24(this->p2StartColor.g, this->p2EndColor.g, ratio); + vtx[j].v.cn[2] = func_800B0A24(this->p2StartColor.b, this->p2EndColor.b, ratio); + vtx[j].v.cn[3] = func_800B0A24(this->p2StartColor.a, this->p2EndColor.a, ratio); + j++; + } + } + + phi_t2 = 0; + j = 0; + + gSPVertex(POLY_XLU_DISP++, vtx, 32, 0); + + for (i = 0; i < this->numElements; i++) { + elem = &this->elements[i]; + + if (elem->state == 0) { + phi_t2 = 0; + } else { + if (phi_t2 == 0) { + phi_t2 = 1; + } else { + gSP1Quadrangle(POLY_XLU_DISP++, j - 2, j - 1, j + 1, j, 0); + + if (this->unkFlag == 1) { + phi_t2 = 0; + } + } + j += 2; + } + } + } + } else if (this->drawMode < 2) { + EffectBlure_DrawSimple(this, gfxCtx); + } else { + EffectBlure_DrawSmooth(this, gfxCtx); + } + } + + CLOSE_DISPS(gfxCtx); +} diff --git a/src/code/z_eff_shield_particle.c b/src/code/z_eff_shield_particle.c index 29d93a7159..05669d63ad 100644 --- a/src/code/z_eff_shield_particle.c +++ b/src/code/z_eff_shield_particle.c @@ -1,11 +1,207 @@ #include "global.h" +#include "vt.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_shield_particle/EffectShieldParticle_Init.s") +#include "assets/code/eff_shield_particle/eff_shield_particle.c" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_shield_particle/EffectShieldParticle_Destroy.s") +void EffectShieldParticle_Init(void* thisx, void* initParamsx) { + EffectShieldParticle* this = (EffectShieldParticle*)thisx; + EffectShieldParticleInit* initParams = (EffectShieldParticleInit*)initParamsx; + EffectShieldParticleElement* elem; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_shield_particle/EffectShieldParticle_Update.s") + if ((this != NULL) && (initParams != NULL)) { + this->numElements = initParams->numElements; + if (this->numElements > ARRAY_COUNT(this->elements)) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_shield_particle/EffectShieldParticle_CalculateColors.s") + this->position = initParams->position; + this->primColorStart = initParams->primColorStart; + this->envColorStart = initParams->envColorStart; + this->primColorMid = initParams->primColorMid; + this->envColorMid = initParams->envColorMid; + this->primColorEnd = initParams->primColorEnd; + this->envColorEnd = initParams->envColorEnd; + this->deceleration = initParams->deceleration; + this->maxInitialSpeed = initParams->maxInitialSpeed; + this->lengthCutoff = initParams->lengthCutoff; + this->duration = initParams->duration; + this->timer = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_shield_particle/EffectShieldParticle_Draw.s") + for (elem = &this->elements[0]; elem < &this->elements[this->numElements]; elem++) { + elem->initialSpeed = (Rand_ZeroOne() * (this->maxInitialSpeed * 0.5f)) + (this->maxInitialSpeed * 0.5f); + elem->endX = 0.0f; + elem->startXChange = 0.0f; + elem->startX = 0.0f; + elem->endXChange = elem->initialSpeed; + elem->yaw = Rand_ZeroOne() * 65534.0f; + elem->pitch = Rand_ZeroOne() * 65534.0f; + } + + this->lightDecay = initParams->lightDecay; + if (this->lightDecay == true) { + this->lightInfo.type = LIGHT_POINT_NOGLOW; + this->lightInfo.params.point = initParams->lightPoint; + this->lightNode = + LightContext_InsertLight(Effect_GetGlobalCtx(), &Effect_GetGlobalCtx()->lightCtx, &this->lightInfo); + } else { + this->lightNode = NULL; + } + } +} + +void EffectShieldParticle_Destroy(void* thisx) { + EffectShieldParticle* this = (EffectShieldParticle*)thisx; + + if ((this != NULL) && (this->lightDecay == true)) { + if (this->lightNode == Effect_GetGlobalCtx()->lightCtx.listHead) { + Effect_GetGlobalCtx()->lightCtx.listHead = this->lightNode->next; + } + LightContext_RemoveLight(Effect_GetGlobalCtx(), &Effect_GetGlobalCtx()->lightCtx, this->lightNode); + } +} + +s32 EffectShieldParticle_Update(void* thisx) { + EffectShieldParticle* this = (EffectShieldParticle*)thisx; + EffectShieldParticleElement* elem; + + if (this == NULL) { + return 0; + } + + for (elem = &this->elements[0]; elem < &this->elements[this->numElements]; elem++) { + elem->endXChange -= this->deceleration; + if (elem->endXChange < 0.0f) { + elem->endXChange = 0.0f; + } + + if (elem->startXChange > 0.0f) { + elem->startXChange -= this->deceleration; + if (elem->startXChange < 0.0f) { + elem->startXChange = 0.0f; + } + } + + elem->endX += elem->endXChange; + elem->startX += elem->startXChange; + + if ((elem->startXChange == 0.0f) && (this->lengthCutoff < (elem->endX - elem->startX))) { + elem->startXChange = elem->initialSpeed; + } + } + + if (this->lightDecay == true) { + this->lightInfo.params.point.radius /= 2; + } + + this->timer++; + + if (this->duration < this->timer) { + return 1; + } + + return 0; +} + +void EffectShieldParticle_GetColors(EffectShieldParticle* this, Color_RGBA8* primColor, Color_RGBA8* envColor) { + s32 halfDuration = this->duration * 0.5f; + + if (halfDuration == 0) { + primColor->r = this->primColorStart.r; + primColor->g = this->primColorStart.g; + primColor->b = this->primColorStart.b; + primColor->a = this->primColorStart.a; + envColor->r = this->envColorStart.r; + envColor->g = this->envColorStart.g; + envColor->b = this->envColorStart.b; + envColor->a = this->envColorStart.a; + } else if (this->timer < halfDuration) { + f32 ratio = this->timer / (f32)halfDuration; + + primColor->r = LERPIMP(this->primColorStart.r, this->primColorMid.r, ratio); + primColor->g = LERPIMP(this->primColorStart.g, this->primColorMid.g, ratio); + primColor->b = LERPIMP(this->primColorStart.b, this->primColorMid.b, ratio); + primColor->a = LERPIMP(this->primColorStart.a, this->primColorMid.a, ratio); + envColor->r = LERPIMP(this->envColorStart.r, this->envColorMid.r, ratio); + envColor->g = LERPIMP(this->envColorStart.g, this->envColorMid.g, ratio); + envColor->b = LERPIMP(this->envColorStart.b, this->envColorMid.b, ratio); + envColor->a = LERPIMP(this->envColorStart.a, this->envColorMid.a, ratio); + } else { + f32 ratio = (this->timer - halfDuration) / (f32)halfDuration; + + primColor->r = LERPIMP(this->primColorMid.r, this->primColorEnd.r, ratio); + primColor->g = LERPIMP(this->primColorMid.g, this->primColorEnd.g, ratio); + primColor->b = LERPIMP(this->primColorMid.b, this->primColorEnd.b, ratio); + primColor->a = LERPIMP(this->primColorMid.a, this->primColorEnd.a, ratio); + envColor->r = LERPIMP(this->envColorMid.r, this->envColorEnd.r, ratio); + envColor->g = LERPIMP(this->envColorMid.g, this->envColorEnd.g, ratio); + envColor->b = LERPIMP(this->envColorMid.b, this->envColorEnd.b, ratio); + envColor->a = LERPIMP(this->envColorMid.a, this->envColorEnd.a, ratio); + } +} + +void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx) { + EffectShieldParticle* this = (EffectShieldParticle*)thisx; + EffectShieldParticleElement* elem; + Color_RGBA8 primColor; + Color_RGBA8 envColor; + + OPEN_DISPS(gfxCtx); + + if (this != NULL) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x26); + + gDPSetCycleType(POLY_XLU_DISP++, G_CYC_2CYCLE); + gDPPipeSync(POLY_XLU_DISP++); + gSPTexture(POLY_XLU_DISP++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); + + gDPLoadTextureBlock(POLY_XLU_DISP++, D_04054F20, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD); + + gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, 0, TEXEL0, 0, 0, 0, + 0, COMBINED, 0, 0, 0, COMBINED); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR); + gSPSetGeometryMode(POLY_XLU_DISP++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH); + + EffectShieldParticle_GetColors(this, &primColor, &envColor); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, primColor.r, primColor.g, primColor.b, primColor.a); + gDPSetEnvColor(POLY_XLU_DISP++, envColor.r, envColor.g, envColor.b, envColor.a); + gDPPipeSync(POLY_XLU_DISP++); + + for (elem = &this->elements[0]; elem < &this->elements[this->numElements]; elem++) { + Mtx* mtx; + MtxF sp104; + MtxF spC4; + MtxF sp84; + f32 temp1 = (elem->endX + elem->startX) * 0.5f; + f32 temp2 = elem->endX - elem->startX; + f32 temp3 = (temp2 * (1.0f / 64.0f)) / 0.02f; + + if (temp3 < 1.0f) { + temp3 = 1.0f; + } + + SkinMatrix_SetTranslate(&spC4, this->position.x, this->position.y, this->position.z); + SkinMatrix_SetRotateRPY(&sp104, 0, elem->yaw, 0); + SkinMatrix_MtxFMtxFMult(&spC4, &sp104, &sp84); + SkinMatrix_SetRotateRPY(&sp104, 0, 0, elem->pitch); + SkinMatrix_MtxFMtxFMult(&sp84, &sp104, &spC4); + SkinMatrix_SetTranslate(&sp104, temp1, 0.0f, 0.0f); + SkinMatrix_MtxFMtxFMult(&spC4, &sp104, &sp84); + SkinMatrix_SetScale(&sp104, temp3 * 0.02f, 0.02f, 0.02f); + SkinMatrix_MtxFMtxFMult(&sp84, &sp104, &spC4); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &spC4); + if (mtx == NULL) { + break; + } + + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPVertex(POLY_XLU_DISP++, sEffShieldParticleVtx, 4, 0); + gSP2Triangles(POLY_XLU_DISP++, 0, 1, 2, 0, 0, 3, 1, 0); + } + } + + CLOSE_DISPS(gfxCtx); +} diff --git a/src/code/z_eff_spark.c b/src/code/z_eff_spark.c index d06bc4b276..27ed1443db 100644 --- a/src/code/z_eff_spark.c +++ b/src/code/z_eff_spark.c @@ -1,9 +1,265 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_spark/EffectSpark_Init.s") +void EffectSpark_Init(void* thisx, void* initParamsx) { + EffectSpark* this = (EffectSpark*)thisx; + EffectSparkInit* initParams = (EffectSparkInit*)initParamsx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_spark/EffectSpark_Destroy.s") + f32 velocityNorm; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_spark/EffectSpark_Update.s") + if ((this != NULL) && (initParams != NULL)) { + if ((initParams->uDiv == 0) || (initParams->vDiv == 0)) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_spark/EffectSpark_Draw.s") + this->position = initParams->position; + this->speed = initParams->speed; + this->gravity = initParams->gravity; + this->uDiv = initParams->uDiv; + this->vDiv = initParams->vDiv; + this->colorStart[0].r = initParams->colorStart[0].r; + this->colorStart[0].g = initParams->colorStart[0].g; + this->colorStart[0].b = initParams->colorStart[0].b; + this->colorStart[0].a = initParams->colorStart[0].a; + this->colorStart[1].r = initParams->colorStart[1].r; + this->colorStart[1].g = initParams->colorStart[1].g; + this->colorStart[1].b = initParams->colorStart[1].b; + this->colorStart[1].a = initParams->colorStart[1].a; + this->colorStart[2].r = initParams->colorStart[2].r; + this->colorStart[2].g = initParams->colorStart[2].g; + this->colorStart[2].b = initParams->colorStart[2].b; + this->colorStart[2].a = initParams->colorStart[2].a; + this->colorStart[3].r = initParams->colorStart[3].r; + this->colorStart[3].g = initParams->colorStart[3].g; + this->colorStart[3].b = initParams->colorStart[3].b; + this->colorStart[3].a = initParams->colorStart[3].a; + this->colorEnd[0].r = initParams->colorEnd[0].r; + this->colorEnd[0].g = initParams->colorEnd[0].g; + this->colorEnd[0].b = initParams->colorEnd[0].b; + this->colorEnd[0].a = initParams->colorEnd[0].a; + this->colorEnd[1].r = initParams->colorEnd[1].r; + this->colorEnd[1].g = initParams->colorEnd[1].g; + this->colorEnd[1].b = initParams->colorEnd[1].b; + this->colorEnd[1].a = initParams->colorEnd[1].a; + this->colorEnd[2].r = initParams->colorEnd[2].r; + this->colorEnd[2].g = initParams->colorEnd[2].g; + this->colorEnd[2].b = initParams->colorEnd[2].b; + this->colorEnd[2].a = initParams->colorEnd[2].a; + this->colorEnd[3].r = initParams->colorEnd[3].r; + this->colorEnd[3].g = initParams->colorEnd[3].g; + this->colorEnd[3].b = initParams->colorEnd[3].b; + this->colorEnd[3].a = initParams->colorEnd[3].a; + this->duration = initParams->duration; + + this->numElements = (this->uDiv * this->vDiv) + 2; + if (this->numElements > ARRAY_COUNT(this->elements)) { + return; + } + + for (i = 0; i < this->numElements; i++) { + EffectSparkElement* elem = &this->elements[i]; + + elem->position.x = this->position.x; + elem->position.y = this->position.y; + elem->position.z = this->position.z; + elem->velocity.x = Rand_ZeroOne() - 0.5f; + elem->velocity.y = Rand_ZeroOne() - 0.5f; + elem->velocity.z = Rand_ZeroOne() - 0.5f; + + velocityNorm = sqrtf(SQXYZ(elem->velocity)); + + if (!(fabsf(velocityNorm) < 0.008f)) { + elem->velocity.x *= this->speed * (1.0f / velocityNorm); + elem->velocity.y *= this->speed * (1.0f / velocityNorm); + elem->velocity.z *= this->speed * (1.0f / velocityNorm); + } else { + elem->velocity.x = elem->velocity.z = 0.0f; + elem->velocity.y = this->speed; + } + + elem->unkVelocity.x = 30000.0f - Rand_ZeroOne() * 15000.0f; + elem->unkVelocity.y = 30000.0f - Rand_ZeroOne() * 15000.0f; + elem->unkVelocity.z = 30000.0f - Rand_ZeroOne() * 15000.0f; + elem->unkPosition.x = Rand_ZeroOne() * 65534.0f; + elem->unkPosition.y = Rand_ZeroOne() * 65534.0f; + elem->unkPosition.z = Rand_ZeroOne() * 65534.0f; + } + + this->timer = 0; + } +} + +void EffectSpark_Destroy(void* thisx) { +} + +s32 EffectSpark_Update(void* thisx) { + EffectSpark* this = (EffectSpark*)thisx; + EffectSparkElement* elem; + s32 i; + + for (i = 0; i < this->numElements; i++) { + elem = &this->elements[i]; + + elem->position.x += elem->velocity.x; + elem->position.y += elem->velocity.y; + elem->position.z += elem->velocity.z; + elem->velocity.y += this->gravity; + elem->unkPosition.x += elem->unkVelocity.x; + elem->unkPosition.y += elem->unkVelocity.y; + elem->unkPosition.z += elem->unkVelocity.z; + } + + this->timer++; + + if (this->duration < this->timer) { + return 1; + } else { + return 0; + } +} + +void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { + Vtx* vertices; + EffectSpark* this = (EffectSpark*)thisx; + GlobalContext* globalCtx = Effect_GetGlobalCtx(); + s32 i; + s32 j; + u8 sp1D3; + u8 sp1D2; + u8 sp1D1; + u8 sp1D0; + u8 sp1CF; + u8 sp1CE; + u8 sp1CD; + u8 sp1CC; + u8 sp1CB; + u8 sp1CA; + u8 sp1C9; + u8 sp1C8; + u8 sp1C7; + u8 sp1C6; + u8 sp1C5; + u8 sp1C4; + f32 ratio; + + OPEN_DISPS(gfxCtx); + + if (this != NULL) { + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x26); + gDPSetCycleType(POLY_XLU_DISP++, G_CYC_2CYCLE); + gDPPipeSync(POLY_XLU_DISP++); + + gSPTexture(POLY_XLU_DISP++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); + gDPLoadTextureBlock(POLY_XLU_DISP++, D_04054F20, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMIRROR | G_TX_WRAP, 5, 5, G_TX_NOLOD, G_TX_NOLOD); + + gDPSetCombineMode(POLY_XLU_DISP++, G_CC_SHADEDECALA, G_CC_PASS2); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR); + gSPSetGeometryMode(POLY_XLU_DISP++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH); + gDPPipeSync(POLY_XLU_DISP++); + + vertices = GRAPH_ALLOC(gfxCtx, ALIGN16(this->numElements * sizeof(Vtx[4]))); + if (vertices == NULL) { + goto end; + } + + j = 0; + + ratio = (f32)this->timer / (f32)this->duration; + sp1D3 = F32_LERPIMP(this->colorStart[0].r, this->colorEnd[0].r, ratio); + sp1D2 = F32_LERPIMP(this->colorStart[0].g, this->colorEnd[0].g, ratio); + sp1D1 = F32_LERPIMP(this->colorStart[0].b, this->colorEnd[0].b, ratio); + sp1D0 = F32_LERPIMP(this->colorStart[0].a, this->colorEnd[0].a, ratio); + sp1CF = F32_LERPIMP(this->colorStart[1].r, this->colorEnd[1].r, ratio); + sp1CE = F32_LERPIMP(this->colorStart[1].g, this->colorEnd[1].g, ratio); + sp1CD = F32_LERPIMP(this->colorStart[1].b, this->colorEnd[1].b, ratio); + sp1CC = F32_LERPIMP(this->colorStart[1].a, this->colorEnd[1].a, ratio); + sp1CB = F32_LERPIMP(this->colorStart[2].r, this->colorEnd[2].r, ratio); + sp1CA = F32_LERPIMP(this->colorStart[2].g, this->colorEnd[2].g, ratio); + sp1C9 = F32_LERPIMP(this->colorStart[2].b, this->colorEnd[2].b, ratio); + sp1C8 = F32_LERPIMP(this->colorStart[2].a, this->colorEnd[2].a, ratio); + sp1C7 = F32_LERPIMP(this->colorStart[3].r, this->colorEnd[3].r, ratio); + sp1C6 = F32_LERPIMP(this->colorStart[3].g, this->colorEnd[3].g, ratio); + sp1C5 = F32_LERPIMP(this->colorStart[3].b, this->colorEnd[3].b, ratio); + sp1C4 = F32_LERPIMP(this->colorStart[3].a, this->colorEnd[3].a, ratio); + + for (i = 0; i < this->numElements; i++) { + MtxF sp12C; + MtxF spEC; + MtxF spAC; + MtxF sp6C; + EffectSparkElement* elem = &this->elements[i]; + Mtx* mtx; + f32 temp; + + SkinMatrix_SetTranslate(&spEC, elem->position.x, elem->position.y, elem->position.z); + temp = ((Rand_ZeroOne() * 2.5f) + 1.5f) / 64.0f; + SkinMatrix_SetScale(&spAC, temp, temp, 1.0f); + SkinMatrix_MtxFMtxFMult(&spEC, &globalCtx->billboardMtxF, &sp6C); + SkinMatrix_MtxFMtxFMult(&sp6C, &spAC, &sp12C); + + vertices[j].v.ob[0] = -32; + vertices[j].v.ob[1] = -32; + vertices[j].v.ob[2] = 0; + vertices[j].v.cn[0] = sp1D3; + vertices[j].v.cn[1] = sp1D2; + vertices[j].v.cn[2] = sp1D1; + vertices[j].v.cn[3] = sp1D0; + vertices[j].v.tc[0] = 0; + vertices[j].v.tc[1] = 1024; + vertices[j].v.flag = 0; + + vertices[j + 1].v.ob[0] = 32; + vertices[j + 1].v.ob[1] = 32; + vertices[j + 1].v.ob[2] = 0; + vertices[j + 1].v.cn[0] = sp1CF; + vertices[j + 1].v.cn[1] = sp1CE; + vertices[j + 1].v.cn[2] = sp1CD; + vertices[j + 1].v.cn[3] = sp1CC; + vertices[j + 1].v.tc[0] = 1024; + vertices[j + 1].v.tc[1] = 0; + vertices[j + 1].v.flag = 0; + + vertices[j + 2].v.ob[0] = -32; + vertices[j + 2].v.ob[1] = 32; + vertices[j + 2].v.ob[2] = 0; + vertices[j + 2].v.cn[0] = sp1CB; + vertices[j + 2].v.cn[1] = sp1CA; + vertices[j + 2].v.cn[2] = sp1C9; + vertices[j + 2].v.cn[3] = sp1C8; + vertices[j + 2].v.tc[0] = 0; + vertices[j + 2].v.tc[1] = 0; + vertices[j + 2].v.flag = 0; + + vertices[j + 3].v.ob[0] = 32; + vertices[j + 3].v.ob[1] = -32; + vertices[j + 3].v.ob[2] = 0; + vertices[j + 3].v.cn[0] = sp1C7; + vertices[j + 3].v.cn[1] = sp1C6; + vertices[j + 3].v.cn[2] = sp1C5; + vertices[j + 3].v.cn[3] = sp1C4; + vertices[j + 3].v.tc[0] = 1024; + vertices[j + 3].v.tc[1] = 1024; + vertices[j + 3].v.flag = 0; + + j += 4; + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &sp12C); + if (mtx == NULL) { + goto end; + } + + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPVertex(POLY_XLU_DISP++, &vertices[4 * i], 4, 0); + gSP2Triangles(POLY_XLU_DISP++, 2, 0, 3, 0, 2, 3, 1, 0); + } + + gDPPipeSync(POLY_XLU_DISP++); + } + +end: + CLOSE_DISPS(gfxCtx); +} diff --git a/src/code/z_eff_ss_dead.c b/src/code/z_eff_ss_dead.c index 12665d6b2f..bd93f5eeda 100644 --- a/src/code/z_eff_ss_dead.c +++ b/src/code/z_eff_ss_dead.c @@ -1,13 +1,111 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_ss_dead/func_800AE2A0.s") +void func_800AE2A0(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) { + f32 cos; + Gfx* displayListHead; + f32 absCos; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_ss_dead/func_800AE434.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_ss_dead/func_800AE5A0.s") + displayListHead = POLY_OPA_DISP; + cos = Math_CosS((0x8000 / arg3) * arg2); + absCos = fabsf(cos); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_ss_dead/func_800AE5E4.s") + gDPPipeSync(displayListHead++); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_ss_dead/func_800AE778.s") + if (color == NULL) { + gDPSetFogColor(displayListHead++, 255, 0, 0, 0); + } else { + gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_ss_dead/func_800AE8EC.s") + gSPFogPosition(displayListHead++, 0, (s16)(absCos * 3000.0f) + 1500); + + POLY_OPA_DISP = displayListHead; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_800AE434(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) { + Gfx* displayListHead; + f32 cos; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + cos = Math_CosS((0x4000 / arg3) * arg2); + displayListHead = POLY_OPA_DISP; + + gDPPipeSync(displayListHead++); + gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a); + gSPFogPosition(displayListHead++, 0, (s16)(2800.0f * fabsf(cos)) + 1700); + + POLY_OPA_DISP = displayListHead; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_800AE5A0(GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_800AE5E4(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) { + f32 cos; + Gfx* displayListHead; + f32 absCos; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + displayListHead = POLY_XLU_DISP; + cos = Math_CosS((0x8000 / arg3) * arg2); + absCos = fabsf(cos); + + gDPPipeSync(displayListHead++); + + if (color == NULL) { + gDPSetFogColor(displayListHead++, 255, 0, 0, 0); + } else { + gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a); + } + + gSPFogPosition(displayListHead++, 0, (s16)(absCos * 3000.0f) + 1500); + + POLY_XLU_DISP = displayListHead; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_800AE778(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) { + f32 cos; + Gfx* displayListHead; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + displayListHead = POLY_XLU_DISP; + cos = Math_CosS((0x4000 / arg3) * arg2); + + gDPPipeSync(displayListHead++); + gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a); + gSPFogPosition(displayListHead++, 0, (s16)(2800.0f * fabsf(cos)) + 1700); + + POLY_XLU_DISP = displayListHead; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_800AE8EC(GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_XLU_DISP++); + POLY_XLU_DISP = func_801660B8(globalCtx, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/code/z_eff_tire_mark.c b/src/code/z_eff_tire_mark.c index 0ae14c86f7..517ee52512 100644 --- a/src/code/z_eff_tire_mark.c +++ b/src/code/z_eff_tire_mark.c @@ -1,17 +1,287 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_tire_mark/func_800AE930.s") +void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f32 arg3, s16 arg4, + CollisionPoly* colPoly, s32 arg6) { + Vec3s spB8; + Vec3s spB0; + EffectTireMarkElement* spAC; + EffectTireMarkElement* spA8; + u32 spA4; + u32 spA0; + Vec3s* vtxList = colCtx->colHeader->vtxList; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_tire_mark/func_800AEF44.s") + if ((arg6 != 50) || (this->numElements >= (ARRAY_COUNT(this->elements) - 1)) || (colPoly == NULL)) { + func_800AEF44(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_InitParticle.s") + spB8.x = (Math_SinS(arg4 - 0x4000) * arg3) + pos->x; + spB8.z = (Math_CosS(arg4 - 0x4000) * arg3) + pos->z; + spB8.y = func_800BFD84(colPoly, spB8.x, spB8.z) + 2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_Init.s") + spB0.x = (Math_SinS(arg4 + 0x4000) * arg3) + pos->x; + spB0.z = (Math_CosS(arg4 + 0x4000) * arg3) + pos->z; + spB0.y = func_800BFD84(colPoly, spB0.x, spB0.z) + 2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_Destroy.s") + spAC = &this->elements[this->numElements - 1]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_Update.s") + if ((this->numElements != 0) && (spAC->colPoly != NULL) && (colPoly != spAC->colPoly) && + (func_800BFDEC(spAC->colPoly, colPoly, &spA4, &spA0) == 2)) { + Vec3f sp90; + Vec3f sp84; + Vec3f sp78; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + Vec3f sp48; + Vec3f sp3C; + Vec3f sp30; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_InitVertices.s") + sp84.x = vtxList[spA4].x; + sp84.y = vtxList[spA4].y; + sp84.z = vtxList[spA4].z; + sp90.x = vtxList[spA0].x; + sp90.y = vtxList[spA0].y; + sp90.z = vtxList[spA0].z; + sp54.x = spAC->p1.x; + sp54.y = spAC->p1.y; + sp54.z = spAC->p1.z; + sp60.x = spB0.x; + sp60.y = spB0.y; + sp60.z = spB0.z; + sp3C.x = spAC->p2.x; + sp3C.y = spAC->p2.y; + sp3C.z = spAC->p2.z; + sp48.x = spB8.x; + sp48.y = spB8.y; + sp48.z = spB8.z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_Draw.s") + if ((func_80179798(&sp84, &sp90, &sp54, &sp60, &sp6C, &sp30) != 0) && + (func_80179798(&sp84, &sp90, &sp3C, &sp48, &sp78, &sp30) != 0)) { + if (!(spAC->flags & 2)) { + spAC->flags |= 1; + } + + spA8 = &this->elements[this->numElements]; + spA8->flags = 0; + spA8->p1.x = sp6C.x; + spA8->p1.y = sp6C.y; + spA8->p1.z = sp6C.z; + spA8->p2.x = sp78.x; + spA8->p2.y = sp78.y; + spA8->p2.z = sp78.z; + spA8->life = this->elemDuration; + spA8->colPoly = NULL; + this->numElements++; + + spAC = &this->elements[this->numElements - 1]; + if (!(spAC->flags & 2)) { + spAC->flags |= 1; + } + + if (spA8) {} // Necessary to match + + spA8 = &this->elements[this->numElements]; + spA8->flags = 0; + spA8->p1 = spB0; + spA8->p2 = spB8; + spA8->life = this->elemDuration; + spA8->colPoly = colPoly; + this->numElements++; + return; + } + + if (!(spAC->flags & 2)) { + spAC->flags |= 1; + } + + spA8 = &this->elements[this->numElements]; + spA8->flags = 0; + spA8->p1 = spB0; + spA8->p2 = spB8; + spA8->life = this->elemDuration; + spA8->colPoly = colPoly; + + this->numElements++; + return; + } + + if (!(spAC->flags & 2)) { + spAC->flags |= 1; + } + + spA8 = &this->elements[this->numElements]; + spA8->flags = 0; + spA8->p1 = spB0; + spA8->p2 = spB8; + spA8->life = this->elemDuration; + spA8->colPoly = colPoly; + + this->numElements++; +} + +void func_800AEF44(EffectTireMark* this) { + EffectTireMarkElement* elem = &this->elements[this->numElements - 1]; + + elem->flags |= 2; +} + +void EffectTireMark_InitElement(EffectTireMarkElement* elem) { + elem->flags = 0; + elem->life = 0; + elem->colPoly = NULL; + elem->p1.x = elem->p1.y = elem->p1.z = elem->p2.x = elem->p2.y = elem->p2.z = 0; +} + +void EffectTireMark_Init(void* thisx, void* initParamsx) { + EffectTireMark* this = (EffectTireMark*)thisx; + EffectTireMarkInit* initParams = (EffectTireMarkInit*)initParamsx; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->elements); i++) { + EffectTireMark_InitElement(&this->elements[i]); + } + + this->unk600 = initParams->unk0; + this->numElements = 0; + + if (initParams->elemDuration > 62) { + this->elemDuration = 62; + } else { + this->elemDuration = initParams->elemDuration; + } + + this->color = initParams->color; +} + +void EffectTireMark_Destroy(void* thisx) { +} + +s32 EffectTireMark_Update(void* thisx) { + EffectTireMark* this = (EffectTireMark*)thisx; + s32 i; + s32 j; + + if (this->numElements == 0) { + return 0; + } + + for (i = 0; i < this->numElements; i++) { + this->elements[i].life--; + } + + if (this->elements[0].life <= 0) { + for (j = 0; j < ARRAY_COUNT(this->elements) - 1; j++) { + this->elements[j] = this->elements[j + 1]; + } + + EffectTireMark_InitElement(&this->elements[j]); + + this->numElements--; + if (this->numElements < 0) { + this->numElements = 0; + } + return 0; + } + + return 0; +} + +void EffectTireMark_SetVertices(Vtx* vtx, EffectTireMarkElement* elem, s32 i, s32 alpha) { + s32 i1 = i * 2; + s32 i2 = i * 2 + 1; + + vtx[i1].v.ob[0] = elem->p1.x; + vtx[i1].v.ob[1] = elem->p1.y; + vtx[i1].v.ob[2] = elem->p1.z; + vtx[i1].v.tc[0] = 2048; + vtx[i1].v.tc[1] = 0; + vtx[i1].v.cn[0] = 255; + vtx[i1].v.cn[1] = 255; + vtx[i1].v.cn[2] = 255; + vtx[i1].v.cn[3] = alpha; + + vtx[i2].v.ob[0] = elem->p2.x; + vtx[i2].v.ob[1] = elem->p2.y; + vtx[i2].v.ob[2] = elem->p2.z; + vtx[i2].v.tc[0] = 2048; + vtx[i2].v.tc[1] = 1024; + vtx[i2].v.cn[0] = 255; + vtx[i2].v.cn[1] = 255; + vtx[i2].v.cn[2] = 255; + vtx[i2].v.cn[3] = alpha; +} + +void EffectTireMark_Draw(void* thisx, GraphicsContext* gfxCtx) { + EffectTireMark* this = (EffectTireMark*)thisx; + EffectTireMarkElement* elem; + Vtx* vtx; + s32 pad; + f32 sp34; + s32 i; + + sp34 = 1.0f / this->elemDuration; + + OPEN_DISPS(gfxCtx); + + if (this->numElements >= 2) { + vtx = GRAPH_ALLOC(gfxCtx, ALIGN16(this->numElements * sizeof(Vtx[2]))); + + if (vtx != NULL) { + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP++, 0x2C); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + + gDPLoadTextureBlock(POLY_OPA_DISP++, D_04014570, G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_WRAP, 6, 5, G_TX_NOLOD, G_TX_NOLOD); + + gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, + COMBINED); + gSPSetGeometryMode(POLY_OPA_DISP++, G_SHADE | G_SHADING_SMOOTH); + gSPClearGeometryMode(POLY_OPA_DISP++, G_CULL_BACK | G_LIGHTING); + + EffectTireMark_SetVertices(vtx, &this->elements[0], 0, 255); + + vtx[0].v.tc[0] = 0; + vtx[0].v.tc[1] = 0; + vtx[1].v.tc[0] = 0; + vtx[1].v.tc[1] = 1024; + + for (i = 1; i < this->numElements; i++) { + elem = &this->elements[i]; + + EffectTireMark_SetVertices(vtx, elem, i, 255); + + if ((elem - 1)->flags & 1) { + if (!(elem->flags & 1)) { + vtx[i * 2 + 0].v.tc[0] = 0; + vtx[i * 2 + 0].v.tc[1] = 0; + vtx[i * 2 + 1].v.tc[0] = 0; + vtx[i * 2 + 1].v.tc[1] = 1024; + dummy_label:; + } else if ((i >= 2) && !((elem - 2)->flags & 1)) { + vtx[i * 2 - 2].v.tc[0] = 0; + vtx[i * 2 - 2].v.tc[1] = 0; + vtx[i * 2 - 1].v.tc[0] = 0; + vtx[i * 2 - 1].v.tc[1] = 1024; + } + + if (i == (this->numElements - 1)) { + vtx[i * 2 + 0].v.tc[0] = 0; + vtx[i * 2 + 0].v.tc[1] = 0; + vtx[i * 2 + 1].v.tc[0] = 0; + vtx[i * 2 + 1].v.tc[1] = 1024; + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->color.r, this->color.g, this->color.b, + (s32)((f32)this->color.a * (f32)elem->life * sp34)); + gSPVertex(POLY_OPA_DISP++, &vtx[i * 2 - 2], 4, 0); + gSP2Triangles(POLY_OPA_DISP++, 0, 1, 3, 0, 0, 3, 2, 0); + } + } + } + } + + CLOSE_DISPS(gfxCtx); +} diff --git a/src/code/z_effect.c b/src/code/z_effect.c index 1c7ad38914..dd696393ff 100644 --- a/src/code/z_effect.c +++ b/src/code/z_effect.c @@ -1,55 +1,57 @@ #include "global.h" -EffInfo sEffInfoTable[] = { +EffectContext sEffectContext; + +EffectInfo sEffectInfoTable[] = { { - sizeof(EffSparkParams), - (eff_init_func)EffectSpark_Init, - (eff_destroy_func)EffectSpark_Destroy, - (eff_update_func)EffectSpark_Update, - (eff_draw_func)EffectSpark_Draw, + sizeof(EffectSpark), + EffectSpark_Init, + EffectSpark_Destroy, + EffectSpark_Update, + EffectSpark_Draw, }, { sizeof(EffectBlure), - (eff_init_func)EffectBlure_Init1, - (eff_destroy_func)EffectBlure_Destroy, - (eff_update_func)EffectBlure_Update, - (eff_draw_func)EffectBlure_Draw, + EffectBlure_Init1, + EffectBlure_Destroy, + EffectBlure_Update, + EffectBlure_Draw, }, { sizeof(EffectBlure), - (eff_init_func)EffectBlure_Init2, - (eff_destroy_func)EffectBlure_Destroy, - (eff_update_func)EffectBlure_Update, - (eff_draw_func)EffectBlure_Draw, + EffectBlure_Init2, + EffectBlure_Destroy, + EffectBlure_Update, + EffectBlure_Draw, }, { - sizeof(EffShieldParticleParams), - (eff_init_func)EffectShieldParticle_Init, - (eff_destroy_func)EffectShieldParticle_Destroy, - (eff_update_func)EffectShieldParticle_Update, - (eff_draw_func)EffectShieldParticle_Draw, + sizeof(EffectShieldParticle), + EffectShieldParticle_Init, + EffectShieldParticle_Destroy, + EffectShieldParticle_Update, + EffectShieldParticle_Draw, }, { - sizeof(EffTireMarkParams), - (eff_init_func)EffectTireMark_Init, - (eff_destroy_func)EffectTireMark_Destroy, - (eff_update_func)EffectTireMark_Update, - (eff_draw_func)EffectTireMark_Draw, + sizeof(EffectTireMark), + EffectTireMark_Init, + EffectTireMark_Destroy, + EffectTireMark_Update, + EffectTireMark_Draw, }, }; -GlobalContext* Effect_GetContext(void) { - return sEffTable.globalCtx; +GlobalContext* Effect_GetGlobalCtx(void) { + return sEffectContext.globalCtx; } -void* Effect_GetParams(s32 index) { +void* Effect_GetByIndex(s32 index) { if (index == TOTAL_EFFECT_COUNT) { return NULL; } if (index < SPARK_COUNT) { - if (sEffTable.sparks[index].base.active == 1) { - return &sEffTable.sparks[index].params; + if (sEffectContext.sparks[index].status.active == true) { + return &sEffectContext.sparks[index].effect; } else { return NULL; } @@ -57,8 +59,8 @@ void* Effect_GetParams(s32 index) { index -= SPARK_COUNT; if (index < BLURE_COUNT) { - if (sEffTable.blures[index].base.active == 1) { - return &sEffTable.blures[index].params; + if (sEffectContext.blures[index].status.active == true) { + return &sEffectContext.blures[index].effect; } else { return NULL; } @@ -66,8 +68,8 @@ void* Effect_GetParams(s32 index) { index -= BLURE_COUNT; if (index < SHIELD_PARTICLE_COUNT) { - if (sEffTable.shieldParticles[index].base.active == 1) { - return &sEffTable.shieldParticles[index].params; + if (sEffectContext.shieldParticles[index].status.active == true) { + return &sEffectContext.shieldParticles[index].effect; } else { return NULL; } @@ -75,8 +77,8 @@ void* Effect_GetParams(s32 index) { index -= SHIELD_PARTICLE_COUNT; if (index < TIRE_MARK_COUNT) { - if (sEffTable.tireMarks[index].base.active == 1) { - return &sEffTable.tireMarks[index].params; + if (sEffectContext.tireMarks[index].status.active == true) { + return &sEffectContext.tireMarks[index].effect; } else { return NULL; } @@ -85,89 +87,87 @@ void* Effect_GetParams(s32 index) { return NULL; } -void Effect_InitCommon(EffCommon* common) { - common->active = 0; - common->unk1 = 0; - common->unk2 = 0; +void Effect_InitStatus(EffectStatus* status) { + status->active = false; + status->unk1 = 0; + status->unk2 = 0; } void Effect_Init(GlobalContext* globalCtx) { s32 i; for (i = 0; i < SPARK_COUNT; i++) { - Effect_InitCommon(&sEffTable.sparks[i].base); + Effect_InitStatus(&sEffectContext.sparks[i].status); } for (i = 0; i < BLURE_COUNT; i++) { - Effect_InitCommon(&sEffTable.blures[i].base); + Effect_InitStatus(&sEffectContext.blures[i].status); } - //! @bug This is probably supposed to loop over shieldParticles, not blures again for (i = 0; i < SHIELD_PARTICLE_COUNT; i++) { - Effect_InitCommon(&sEffTable.blures[i].base); + //! @bug This is probably supposed to initialize shieldParticles, not blures again + Effect_InitStatus(&sEffectContext.blures[i].status); } for (i = 0; i < TIRE_MARK_COUNT; i++) { - Effect_InitCommon(&sEffTable.tireMarks[i].base); + Effect_InitStatus(&sEffectContext.tireMarks[i].status); } - sEffTable.globalCtx = globalCtx; + sEffectContext.globalCtx = globalCtx; } -void Effect_Add(GlobalContext* globalCtx, s32* index, s32 type, u8 param_4, u8 param_5, void* initParams) { +void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams) { u32 slotFound; s32 i; - void* params; - EffCommon* common; + void* effect = NULL; + EffectStatus* status = NULL; - params = NULL; - *index = TOTAL_EFFECT_COUNT; - common = NULL; + *pIndex = TOTAL_EFFECT_COUNT; if (FrameAdvance_IsEnabled(globalCtx) != true) { - slotFound = 0; + slotFound = false; switch (type) { - case 0: + case EFFECT_SPARK: for (i = 0; i < SPARK_COUNT; i++) { - if (sEffTable.sparks[i].base.active == 0) { - slotFound = 1; - *index = i; - params = &sEffTable.sparks[i].params; - common = &sEffTable.sparks[i].base; + if (sEffectContext.sparks[i].status.active == false) { + slotFound = true; + *pIndex = i; + effect = &sEffectContext.sparks[i].effect; + status = &sEffectContext.sparks[i].status; break; } } break; - case 1: - case 2: + case EFFECT_BLURE1: + case EFFECT_BLURE2: for (i = 0; i < BLURE_COUNT; i++) { - if (sEffTable.blures[i].base.active == 0) { - slotFound = 1; - *index = i + 3; - params = &sEffTable.blures[i].params; - common = &sEffTable.blures[i].base; + if (sEffectContext.blures[i].status.active == false) { + slotFound = true; + *pIndex = i + SPARK_COUNT; + effect = &sEffectContext.blures[i].effect; + status = &sEffectContext.blures[i].status; break; } } break; - case 3: + case EFFECT_SHIELD_PARTICLE: for (i = 0; i < SHIELD_PARTICLE_COUNT; i++) { - if (sEffTable.shieldParticles[i].base.active == 0) { - slotFound = 1; - *index = i + 28; - params = &sEffTable.shieldParticles[i].params; - common = &sEffTable.shieldParticles[i].base; + if (sEffectContext.shieldParticles[i].status.active == false) { + slotFound = true; + *pIndex = i + SPARK_COUNT + BLURE_COUNT; + effect = &sEffectContext.shieldParticles[i].effect; + status = &sEffectContext.shieldParticles[i].status; break; } } break; - case 4: + case EFFECT_TIRE_MARK: for (i = 0; i < TIRE_MARK_COUNT; i++) { - if (sEffTable.tireMarks[i].base.active == 0) { - slotFound = 1; - *index = i + 31; - params = &sEffTable.tireMarks[i].params; - common = &sEffTable.tireMarks[i].base; + if (sEffectContext.tireMarks[i].status.active == false) { + slotFound = true; + *pIndex = i + SPARK_COUNT + BLURE_COUNT + SHIELD_PARTICLE_COUNT; + effect = &sEffectContext.tireMarks[i].effect; + status = &sEffectContext.tireMarks[i].status; break; } } @@ -175,10 +175,10 @@ void Effect_Add(GlobalContext* globalCtx, s32* index, s32 type, u8 param_4, u8 p } if (slotFound) { - sEffInfoTable[type].init(params, initParams); - common->unk2 = param_4; - common->unk1 = param_5; - common->active = 1; + sEffectInfoTable[type].init(effect, initParams); + status->unk2 = arg3; + status->unk1 = arg4; + status->active = true; } } } @@ -188,8 +188,8 @@ void Effect_DrawAll(GraphicsContext* gfxCtx) { for (i = 0; i < SPARK_COUNT; i++) { if (1) {} // necessary to match - if (sEffTable.sparks[i].base.active) { - sEffInfoTable[0].draw(&sEffTable.sparks[i].params, gfxCtx); + if (sEffectContext.sparks[i].status.active) { + sEffectInfoTable[EFFECT_SPARK].draw(&sEffectContext.sparks[i].effect, gfxCtx); } } @@ -197,22 +197,22 @@ void Effect_DrawAll(GraphicsContext* gfxCtx) { if (1) { if (gfxCtx) {} } // necessary to match - if (sEffTable.blures[i].base.active) { - sEffInfoTable[1].draw(&sEffTable.blures[i].params, gfxCtx); + if (sEffectContext.blures[i].status.active) { + sEffectInfoTable[EFFECT_BLURE1].draw(&sEffectContext.blures[i].effect, gfxCtx); } } for (i = 0; i < SHIELD_PARTICLE_COUNT; i++) { if (1) {} // necessary to match - if (sEffTable.shieldParticles[i].base.active) { - sEffInfoTable[3].draw(&sEffTable.shieldParticles[i].params, gfxCtx); + if (sEffectContext.shieldParticles[i].status.active) { + sEffectInfoTable[EFFECT_SHIELD_PARTICLE].draw(&sEffectContext.shieldParticles[i].effect, gfxCtx); } } if (1) {} // necessary to match for (i = 0; i < TIRE_MARK_COUNT; i++) { - if (sEffTable.tireMarks[i].base.active) { - sEffInfoTable[4].draw(&sEffTable.tireMarks[i].params, gfxCtx); + if (sEffectContext.tireMarks[i].status.active) { + sEffectInfoTable[EFFECT_TIRE_MARK].draw(&sEffectContext.tireMarks[i].effect, gfxCtx); } } } @@ -222,8 +222,8 @@ void Effect_UpdateAll(GlobalContext* globalCtx) { for (i = 0; i < SPARK_COUNT; i++) { if (1) {} // necessary to match - if (sEffTable.sparks[i].base.active) { - if (sEffInfoTable[0].update(&sEffTable.sparks[i].params) == 1) { + if (sEffectContext.sparks[i].status.active) { + if (sEffectInfoTable[EFFECT_SPARK].update(&sEffectContext.sparks[i].effect) == 1) { Effect_Destroy(globalCtx, i); } } @@ -231,27 +231,27 @@ void Effect_UpdateAll(GlobalContext* globalCtx) { for (i = 0; i < BLURE_COUNT; i++) { if (1) {} // necessary to match - if (sEffTable.blures[i].base.active) { - if (sEffInfoTable[1].update(&sEffTable.blures[i].params) == 1) { - Effect_Destroy(globalCtx, i + 3); + if (sEffectContext.blures[i].status.active) { + if (sEffectInfoTable[EFFECT_BLURE1].update(&sEffectContext.blures[i].effect) == 1) { + Effect_Destroy(globalCtx, i + SPARK_COUNT); } } } for (i = 0; i < SHIELD_PARTICLE_COUNT; i++) { if (1) {} // necessary to match - if (sEffTable.shieldParticles[i].base.active) { - if (sEffInfoTable[3].update(&sEffTable.shieldParticles[i].params) == 1) { - Effect_Destroy(globalCtx, i + 28); + if (sEffectContext.shieldParticles[i].status.active) { + if (sEffectInfoTable[EFFECT_SHIELD_PARTICLE].update(&sEffectContext.shieldParticles[i].effect) == 1) { + Effect_Destroy(globalCtx, i + SPARK_COUNT + BLURE_COUNT); } } } for (i = 0; i < TIRE_MARK_COUNT; i++) { if (1) {} // necessary to match - if (sEffTable.tireMarks[i].base.active) { - if (sEffInfoTable[4].update(&sEffTable.tireMarks[i].params) == 1) { - Effect_Destroy(globalCtx, i + 31); + if (sEffectContext.tireMarks[i].status.active) { + if (sEffectInfoTable[EFFECT_TIRE_MARK].update(&sEffectContext.tireMarks[i].effect) == 1) { + Effect_Destroy(globalCtx, i + SPARK_COUNT + BLURE_COUNT + SHIELD_PARTICLE_COUNT); } } } @@ -263,29 +263,29 @@ void Effect_Destroy(GlobalContext* globalCtx, s32 index) { } if (index < SPARK_COUNT) { - sEffTable.sparks[index].base.active = 0; - sEffInfoTable[0].destroy(&sEffTable.sparks[index].params); + sEffectContext.sparks[index].status.active = false; + sEffectInfoTable[EFFECT_SPARK].destroy(&sEffectContext.sparks[index].effect); return; } index -= SPARK_COUNT; if (index < BLURE_COUNT) { - sEffTable.blures[index].base.active = 0; - sEffInfoTable[1].destroy(&sEffTable.blures[index].params); + sEffectContext.blures[index].status.active = false; + sEffectInfoTable[EFFECT_BLURE1].destroy(&sEffectContext.blures[index].effect); return; } index -= BLURE_COUNT; if (index < SHIELD_PARTICLE_COUNT) { - sEffTable.shieldParticles[index].base.active = 0; - sEffInfoTable[3].destroy(&sEffTable.shieldParticles[index].params); + sEffectContext.shieldParticles[index].status.active = false; + sEffectInfoTable[EFFECT_SHIELD_PARTICLE].destroy(&sEffectContext.shieldParticles[index].effect); return; } index -= SHIELD_PARTICLE_COUNT; if (index < TIRE_MARK_COUNT) { - sEffTable.tireMarks[index].base.active = 0; - sEffInfoTable[4].destroy(&sEffTable.tireMarks[index].params); + sEffectContext.tireMarks[index].status.active = false; + sEffectInfoTable[EFFECT_TIRE_MARK].destroy(&sEffectContext.tireMarks[index].effect); return; } } @@ -294,22 +294,22 @@ void Effect_DestroyAll(GlobalContext* globalCtx) { s32 i; for (i = 0; i < SPARK_COUNT; i++) { - sEffTable.sparks[i].base.active = 0; - sEffInfoTable[0].destroy(&sEffTable.sparks[i].params); + sEffectContext.sparks[i].status.active = false; + sEffectInfoTable[EFFECT_SPARK].destroy(&sEffectContext.sparks[i].effect); } for (i = 0; i < BLURE_COUNT; i++) { - sEffTable.blures[i].base.active = 0; - sEffInfoTable[1].destroy(&sEffTable.blures[i].params); + sEffectContext.blures[i].status.active = false; + sEffectInfoTable[EFFECT_BLURE1].destroy(&sEffectContext.blures[i].effect); } for (i = 0; i < SHIELD_PARTICLE_COUNT; i++) { - sEffTable.shieldParticles[i].base.active = 0; - sEffInfoTable[3].destroy(&sEffTable.shieldParticles[i].params); + sEffectContext.shieldParticles[i].status.active = false; + sEffectInfoTable[EFFECT_SHIELD_PARTICLE].destroy(&sEffectContext.shieldParticles[i].effect); } for (i = 0; i < TIRE_MARK_COUNT; i++) { - sEffTable.tireMarks[i].base.active = 0; - sEffInfoTable[4].destroy(&sEffTable.tireMarks[i].params); + sEffectContext.tireMarks[i].status.active = false; + sEffectInfoTable[EFFECT_TIRE_MARK].destroy(&sEffectContext.tireMarks[i].effect); } } diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index 47c2202f16..11545da016 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -1,20 +1,22 @@ #include "global.h" +EffectSsInfo sEffectSsInfo = { NULL, 0, 0 }; + void EffectSS_Init(GlobalContext* globalCtx, s32 numEntries) { u32 i; EffectSs* effectsSs; EffectSsOverlay* overlay; - EffectSS2Info.data_table = (EffectSs*)THA_AllocEndAlign16(&globalCtx->state.heap, numEntries * sizeof(EffectSs)); - EffectSS2Info.searchIndex = 0; - EffectSS2Info.size = numEntries; + sEffectSsInfo.data_table = (EffectSs*)THA_AllocEndAlign16(&globalCtx->state.heap, numEntries * sizeof(EffectSs)); + sEffectSsInfo.searchIndex = 0; + sEffectSsInfo.size = numEntries; - for (effectsSs = &EffectSS2Info.data_table[0]; effectsSs < &EffectSS2Info.data_table[EffectSS2Info.size]; + for (effectsSs = &sEffectSsInfo.data_table[0]; effectsSs < &sEffectSsInfo.data_table[sEffectSsInfo.size]; effectsSs++) { EffectSS_ResetEntry(effectsSs); } - overlay = &particleOverlayTable[0]; + overlay = &gParticleOverlayTable[0]; for (i = 0; i < EFFECT_SS_MAX; i++) { overlay->loadedRamAddr = NULL; overlay++; @@ -27,39 +29,40 @@ void EffectSS_Clear(GlobalContext* globalCtx) { EffectSsOverlay* overlay; void* addr; - EffectSS2Info.data_table = NULL; - EffectSS2Info.searchIndex = 0; - EffectSS2Info.size = 0; + sEffectSsInfo.data_table = NULL; + sEffectSsInfo.searchIndex = 0; + sEffectSsInfo.size = 0; - // This code is completely useless, as data_table was just set to NULL and size to 0 - for (effectsSs = EffectSS2Info.data_table; effectsSs < EffectSS2Info.data_table + EffectSS2Info.size; effectsSs++) { + //! @bug: Effects left in the table are not properly deleted, as data_table was just set to NULL and size to 0 + for (effectsSs = &sEffectSsInfo.data_table[0]; effectsSs < &sEffectSsInfo.data_table[sEffectSsInfo.size]; + effectsSs++) { EffectSS_Delete(effectsSs); } // Free memory from loaded particle overlays - overlay = &particleOverlayTable[0]; + overlay = &gParticleOverlayTable[0]; for (i = 0; i < EFFECT_SS_MAX; i++) { addr = overlay->loadedRamAddr; if (addr != NULL) { ZeldaArena_Free(addr); } - overlay->loadedRamAddr = 0; + overlay->loadedRamAddr = NULL; overlay++; } } EffectSs* EffectSS_GetTable() { - return EffectSS2Info.data_table; + return sEffectSsInfo.data_table; } void EffectSS_Delete(EffectSs* effectSs) { if (effectSs->flags & 2) { - func_801A72CC(&effectSs->pos); + Audio_StopSfxByPos(&effectSs->pos); } if (effectSs->flags & 4) { - func_801A72CC(&effectSs->vec); + Audio_StopSfxByPos(&effectSs->vec); } EffectSS_ResetEntry(effectSs); @@ -90,27 +93,27 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) { s32 foundFree; s32 i; - if (EffectSS2Info.searchIndex >= EffectSS2Info.size) { - EffectSS2Info.searchIndex = 0; + if (sEffectSsInfo.searchIndex >= sEffectSsInfo.size) { + sEffectSsInfo.searchIndex = 0; } // Search for a unused entry - i = EffectSS2Info.searchIndex; + i = sEffectSsInfo.searchIndex; foundFree = false; while (true) { - if (EffectSS2Info.data_table[i].life == -1) { + if (sEffectSsInfo.data_table[i].life == -1) { foundFree = true; break; } i++; - if (i >= EffectSS2Info.size) { + if (i >= sEffectSsInfo.size) { i = 0; // Loop around the whole table } // After a full loop, break out - if (i == EffectSS2Info.searchIndex) { + if (i == sEffectSsInfo.searchIndex) { break; } } @@ -122,22 +125,22 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) { // If all slots are in use, search for a slot with a lower priority // Note that a lower priority is representend by a higher value - i = EffectSS2Info.searchIndex; + i = sEffectSsInfo.searchIndex; while (true) { // Equal priority should only be considered "lower" if flag 0 is set - if ((priority <= EffectSS2Info.data_table[i].priority) && - !((priority == EffectSS2Info.data_table[i].priority) && (EffectSS2Info.data_table[i].flags & 1))) { + if ((priority <= sEffectSsInfo.data_table[i].priority) && + !((priority == sEffectSsInfo.data_table[i].priority) && (sEffectSsInfo.data_table[i].flags & 1))) { break; } i++; - if (i >= EffectSS2Info.size) { + if (i >= sEffectSsInfo.size) { i = 0; // Loop around the whole table } // After a full loop, return 1 to indicate that we failed to find a suitable slot - if (i == EffectSS2Info.searchIndex) { + if (i == sEffectSsInfo.searchIndex) { return true; } } @@ -151,8 +154,8 @@ void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) { if (FrameAdvance_IsEnabled(globalCtx) != true) { if (EffectSS_FindFreeSpace(effectsSs->priority, &index) == 0) { - EffectSS2Info.searchIndex = index + 1; - EffectSS2Info.data_table[index] = *effectsSs; + sEffectSsInfo.searchIndex = index + 1; + sEffectSsInfo.data_table[index] = *effectsSs; } } } @@ -160,7 +163,7 @@ void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) { void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* initData) { s32 index; u32 overlaySize; - EffectSsOverlay* entry = &particleOverlayTable[type]; + EffectSsOverlay* entry = &gParticleOverlayTable[type]; EffectSsInit* initInfo; if (EffectSS_FindFreeSpace(priority, &index) != 0) { @@ -168,8 +171,8 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init return; } - EffectSS2Info.searchIndex = index + 1; - overlaySize = (u32)entry->vramEnd - (u32)entry->vramStart; + sEffectSsInfo.searchIndex = index + 1; + overlaySize = VRAM_PTR_SIZE(entry); if (entry->vramStart == NULL) { initInfo = entry->initInfo; @@ -184,27 +187,25 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init Load2_LoadOverlay(entry->vromStart, entry->vromEnd, entry->vramStart, entry->vramEnd, entry->loadedRamAddr); } - initInfo = (void*)(u32)( - entry->initInfo != NULL - ? (EffectSsInit*)(-((u32)entry->vramStart - (u32)entry->loadedRamAddr) + (u32)entry->initInfo) - : NULL); + initInfo = (uintptr_t)( + (entry->initInfo != NULL) ? (void*)(-OVERLAY_RELOCATION_OFFSET(entry) + (uintptr_t)entry->initInfo) : NULL); } if (initInfo->init != NULL) { // Delete the previous effect in the slot, in case the slot wasn't free - EffectSS_Delete(&EffectSS2Info.data_table[index]); + EffectSS_Delete(&sEffectSsInfo.data_table[index]); - EffectSS2Info.data_table[index].type = type; - EffectSS2Info.data_table[index].priority = priority; + sEffectSsInfo.data_table[index].type = type; + sEffectSsInfo.data_table[index].priority = priority; - if (initInfo->init(globalCtx, index, &EffectSS2Info.data_table[index], initData) == 0) { - EffectSS_ResetEntry(&EffectSS2Info.data_table[index]); + if (initInfo->init(globalCtx, index, &sEffectSsInfo.data_table[index], initData) == 0) { + EffectSS_ResetEntry(&sEffectSsInfo.data_table[index]); } } } void EffectSS_UpdateParticle(GlobalContext* globalCtx, s32 index) { - EffectSs* particle = &EffectSS2Info.data_table[index]; + EffectSs* particle = &sEffectSsInfo.data_table[index]; if (particle->update != NULL) { particle->velocity.x += particle->accel.x; @@ -222,23 +223,23 @@ void EffectSS_UpdateParticle(GlobalContext* globalCtx, s32 index) { void EffectSS_UpdateAllParticles(GlobalContext* globalCtx) { s32 i; - for (i = 0; i < EffectSS2Info.size; i++) { - if (EffectSS2Info.data_table[i].life > -1) { - EffectSS2Info.data_table[i].life--; + for (i = 0; i < sEffectSsInfo.size; i++) { + if (sEffectSsInfo.data_table[i].life > -1) { + sEffectSsInfo.data_table[i].life--; - if (EffectSS2Info.data_table[i].life < 0) { - EffectSS_Delete(&EffectSS2Info.data_table[i]); + if (sEffectSsInfo.data_table[i].life < 0) { + EffectSS_Delete(&sEffectSsInfo.data_table[i]); } } - if (EffectSS2Info.data_table[i].life > -1) { + if (sEffectSsInfo.data_table[i].life > -1) { EffectSS_UpdateParticle(globalCtx, i); } } } void EffectSS_DrawParticle(GlobalContext* globalCtx, s32 index) { - EffectSs* entry = &EffectSS2Info.data_table[index]; + EffectSs* entry = &sEffectSsInfo.data_table[index]; if (entry->draw != NULL) { entry->draw(globalCtx, index, entry); @@ -252,12 +253,12 @@ void EffectSS_DrawAllParticles(GlobalContext* globalCtx) { Lights_BindAll(lights, globalCtx->lightCtx.listHead, NULL, globalCtx); Lights_Draw(lights, globalCtx->state.gfxCtx); - for (i = 0; i < EffectSS2Info.size; i++) { - if (EffectSS2Info.data_table[i].life > -1) { - if ((EffectSS2Info.data_table[i].pos.x > 32000.0f) || (EffectSS2Info.data_table[i].pos.x < -32000.0f) || - (EffectSS2Info.data_table[i].pos.y > 32000.0f) || (EffectSS2Info.data_table[i].pos.y < -32000.0f) || - (EffectSS2Info.data_table[i].pos.z > 32000.0f) || (EffectSS2Info.data_table[i].pos.z < -32000.0f)) { - EffectSS_Delete(&EffectSS2Info.data_table[i]); + for (i = 0; i < sEffectSsInfo.size; i++) { + if (sEffectSsInfo.data_table[i].life > -1) { + if ((sEffectSsInfo.data_table[i].pos.x > 32000.0f) || (sEffectSsInfo.data_table[i].pos.x < -32000.0f) || + (sEffectSsInfo.data_table[i].pos.y > 32000.0f) || (sEffectSsInfo.data_table[i].pos.y < -32000.0f) || + (sEffectSsInfo.data_table[i].pos.z > 32000.0f) || (sEffectSsInfo.data_table[i].pos.z < -32000.0f)) { + EffectSS_Delete(&sEffectSsInfo.data_table[i]); } else { EffectSS_DrawParticle(globalCtx, i); } diff --git a/src/code/z_effect_soft_sprite_dlftbls.c b/src/code/z_effect_soft_sprite_dlftbls.c new file mode 100644 index 0000000000..e215cdee96 --- /dev/null +++ b/src/code/z_effect_soft_sprite_dlftbls.c @@ -0,0 +1,56 @@ +#include "global.h" +#include "initvars.h" + +#define EFFECT_SS_OVERLAY(name) \ + { \ + SEGMENT_ROM_START(ovl_##name), SEGMENT_ROM_END(ovl_##name), SEGMENT_START(ovl_##name), \ + SEGMENT_END(ovl_##name), NULL, &name##_InitVars, 1, \ + } + +#define EFFECT_SS_OVERLAY_INTERNAL(name) \ + { 0, 0, NULL, NULL, NULL, &name##_InitVars, 1 } + +#define EFFECT_SS_OVERLAY_UNSET \ + { 0 } + +EffectSsOverlay gParticleOverlayTable[] = { + EFFECT_SS_OVERLAY(Effect_Ss_Dust), + EFFECT_SS_OVERLAY(Effect_Ss_Kirakira), + EFFECT_SS_OVERLAY_UNSET, + EFFECT_SS_OVERLAY(Effect_Ss_Bomb2), + EFFECT_SS_OVERLAY(Effect_Ss_Blast), + EFFECT_SS_OVERLAY(Effect_Ss_G_Spk), + EFFECT_SS_OVERLAY(Effect_Ss_D_Fire), + EFFECT_SS_OVERLAY(Effect_Ss_Bubble), + EFFECT_SS_OVERLAY_UNSET, + EFFECT_SS_OVERLAY(Effect_Ss_G_Ripple), + EFFECT_SS_OVERLAY(Effect_Ss_G_Splash), + EFFECT_SS_OVERLAY_UNSET, + EFFECT_SS_OVERLAY(Effect_Ss_G_Fire), + EFFECT_SS_OVERLAY(Effect_Ss_Lightning), + EFFECT_SS_OVERLAY(Effect_Ss_Dt_Bubble), + EFFECT_SS_OVERLAY(Effect_Ss_Hahen), + EFFECT_SS_OVERLAY(Effect_Ss_Stick), + EFFECT_SS_OVERLAY(Effect_Ss_Sibuki), + EFFECT_SS_OVERLAY_UNSET, + EFFECT_SS_OVERLAY_UNSET, + EFFECT_SS_OVERLAY(Effect_Ss_Stone1), + EFFECT_SS_OVERLAY(Effect_Ss_Hitmark), + EFFECT_SS_OVERLAY(Effect_Ss_Fhg_Flash), + EFFECT_SS_OVERLAY(Effect_Ss_K_Fire), + EFFECT_SS_OVERLAY(Effect_Ss_Solder_Srch_Ball), + EFFECT_SS_OVERLAY(Effect_Ss_Kakera), + EFFECT_SS_OVERLAY(Effect_Ss_Ice_Piece), + EFFECT_SS_OVERLAY(Effect_Ss_En_Ice), + EFFECT_SS_OVERLAY(Effect_Ss_Fire_Tail), + EFFECT_SS_OVERLAY(Effect_Ss_En_Fire), + EFFECT_SS_OVERLAY(Effect_Ss_Extra), + EFFECT_SS_OVERLAY_UNSET, + EFFECT_SS_OVERLAY(Effect_Ss_Dead_Db), + EFFECT_SS_OVERLAY(Effect_Ss_Dead_Dd), + EFFECT_SS_OVERLAY(Effect_Ss_Dead_Ds), + EFFECT_SS_OVERLAY_UNSET, + EFFECT_SS_OVERLAY(Effect_Ss_Ice_Smoke), + EFFECT_SS_OVERLAY(Effect_En_Ice_Block), + EFFECT_SS_OVERLAY(Effect_Ss_Sbn), +}; diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 6deeb79434..3f868ecc36 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -124,32 +124,32 @@ void func_800B1054(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* EffectSsDust_Spawn(globalCtx, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1); } -extern Color_RGBA8 D_801AE3B0; -extern Color_RGBA8 D_801AE3B4; +static Color_RGBA8 sDustBrownPrim = { 170, 130, 90, 255 }; +static Color_RGBA8 sDustBrownEnv = { 100, 60, 20, 255 }; void func_800B10C0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, 100, 5, 10, 0); + EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0); } void func_800B1130(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, 100, 5, 10, 0); + EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0); } void func_800B11A0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, scale, scaleStep, 10, 0); + EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0); } void func_800B1210(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, scale, scaleStep, 10, 0); + EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0); } void func_800B1280(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, scale, scaleStep, life, 0); + EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); } void func_800B12F0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, scale, scaleStep, life, 0); + EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); } void func_800B1360(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, @@ -206,12 +206,9 @@ void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) { } } -extern Color_RGBA8 D_801AE3B8; -extern Color_RGBA8 D_801AE3BC; - void EffectSsKiraKira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - Color_RGBA8 primColor = D_801AE3B8; - Color_RGBA8 envColor = D_801AE3BC; + Color_RGBA8 primColor = { 255, 255, 200, 255 }; + Color_RGBA8 envColor = { 255, 200, 0, 0 }; EffectSsKiraKira_SpawnDispersed(globalCtx, pos, velocity, accel, &primColor, &envColor, 1000, 16); } @@ -307,12 +304,12 @@ void EffectSsBlast_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, EffectSs_Spawn(globalCtx, EFFECT_SS_BLAST, 128, &initParams); } -extern Color_RGBA8 D_801AE3C0; -extern Color_RGBA8 D_801AE3C4; - void EffectSsBlast_SpawnWhiteCustomScale(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { - EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, &D_801AE3C0, &D_801AE3C4, scale, scaleStep, 35, life); + static Color_RGBA8 primColor = { 255, 255, 255, 255 }; + static Color_RGBA8 envColor = { 200, 200, 200, 0 }; + + EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, &primColor, &envColor, scale, scaleStep, 35, life); } void EffectSsBlast_SpawnShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, @@ -320,11 +317,11 @@ void EffectSsBlast_SpawnShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* v EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, primColor, envColor, 100, 375, 35, life); } -extern Color_RGBA8 D_801AE3C8; -extern Color_RGBA8 D_801AE3CC; - void EffectSsBlast_SpawnWhiteShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - EffectSsBlast_SpawnShockwave(globalCtx, pos, velocity, accel, &D_801AE3C8, &D_801AE3CC, 10); + static Color_RGBA8 primColor = { 255, 255, 255, 255 }; + static Color_RGBA8 envColor = { 200, 200, 200, 0 }; + + EffectSsBlast_SpawnShockwave(globalCtx, pos, velocity, accel, &primColor, &envColor, 10); } // EffectSsGSpk Spawn Functions @@ -364,24 +361,18 @@ void EffectSsGSpk_SpawnNoAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* po EffectSs_Spawn(globalCtx, EFFECT_SS_G_SPK, 128, &initParams); } -extern Color_RGBA8 D_801AE3D0; -extern Color_RGBA8 D_801AE3D4; - void EffectSsGSpk_SpawnFuse(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - Color_RGBA8 primColor = D_801AE3D0; - Color_RGBA8 envColor = D_801AE3D4; + Color_RGBA8 primColor = { 255, 255, 150, 255 }; + Color_RGBA8 envColor = { 255, 0, 0, 0 }; EffectSsGSpk_SpawnSmall(globalCtx, actor, pos, velocity, accel, &primColor, &envColor); } -extern Color_RGBA8 D_801AE3D8; -extern Color_RGBA8 D_801AE3DC; - // unused void EffectSsGSpk_SpawnRandColor(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { - Color_RGBA8 primColor = D_801AE3D8; - Color_RGBA8 envColor = D_801AE3DC; + Color_RGBA8 primColor = { 255, 255, 150, 255 }; + Color_RGBA8 envColor = { 255, 0, 0, 0 }; s32 randOffset = (Rand_ZeroOne() * 20.0f) - 10.0f; primColor.r += randOffset; @@ -585,12 +576,10 @@ void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstSca } } -extern Vec3f D_801AE3E0; - void func_800B2364(GlobalContext* globalCtx, Vec3f* pos, Gfx* dList) { - Vec3f posVec = D_801AE3E0; + Vec3f accel = { 0.0f, -2.0f, 0.0f }; - EffectSsHahen_Spawn(globalCtx, pos, &D_801D15B0, &posVec, 1, 5, 1, 10, dList); + EffectSsHahen_Spawn(globalCtx, pos, &gZeroVec3f, &accel, 1, 5, 1, 10, dList); } // EffectSsStick Spawn Functions @@ -624,12 +613,9 @@ void EffectSsSibuki_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, EffectSs_Spawn(globalCtx, EFFECT_SS_SIBUKI, 128, &initParams); } -extern Vec3f D_801AE3EC; -extern Vec3f D_801AE3F8; - void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos) { s16 i; - Vec3f zeroVec = D_801AE3EC; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; s16 randDirection = Rand_ZeroOne() * 1.99f; for (i = 0; i < KREG(19) + 30; i++) { @@ -759,11 +745,6 @@ void EffectSsIcePiece_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec EffectSs_Spawn(globalCtx, EFFECT_SS_ICE_PIECE, 128, &initParams); } -extern Vec3f D_801AE3F8; -extern Vec3f D_801AE404[10]; - -#ifdef NON_MATCHING -/* needs data migration to match */ void EffectSsIcePiece_SpawnBurst(GlobalContext* globalCtx, Vec3f* refPos, f32 scale) { static Vec3f accel = { 0.0f, 0.0f, 0.0f }; static Vec3f vecScales[] = { @@ -799,15 +780,11 @@ void EffectSsIcePiece_SpawnBurst(GlobalContext* globalCtx, Vec3f* refPos, f32 sc &accel, 25); } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsIcePiece_SpawnBurst.s") -#endif // EffectSsEnIce Spawn Functions void EffectSsEnIce_SpawnFlyingVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Color_RGBA8* prim, Color_RGBA8* env, f32 scale) { - EffectSsEnIceInitParams initParams; initParams.actor = actor; @@ -818,17 +795,17 @@ void EffectSsEnIce_SpawnFlyingVec3f(GlobalContext* globalCtx, Actor* actor, Vec3 initParams.scale = scale; if (actor != NULL) { - Audio_PlayActorSound2(actor, NA_SE_PL_FREEZE_S); + Actor_PlaySfxAtPos(actor, NA_SE_PL_FREEZE_S); } EffectSs_Spawn(globalCtx, EFFECT_SS_EN_ICE, 80, &initParams); } -extern Color_RGBA8 D_801AE47C; -extern Color_RGBA8 D_801AE480; - void func_800B2B44(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 scale) { - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, actor, pos, &D_801AE47C, &D_801AE480, scale); + static Color_RGBA8 primColor = { 150, 150, 150, 250 }; + static Color_RGBA8 envColor = { 235, 245, 255, 255 }; + + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, actor, pos, &primColor, &envColor, scale); } void func_800B2B7C(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, f32 scale) { @@ -874,29 +851,21 @@ void EffectSsFireTail_Spawn(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, EffectSs_Spawn(globalCtx, EFFECT_SS_FIRE_TAIL, 128, &initParams); } -extern Color_RGBA8 D_801AE484; -extern Color_RGBA8 D_801AE488; - -#ifdef NON_MATCHING -// needs data migration to match void EffectSsFireTail_SpawnFlame(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 arg3, s16 bodyPart, f32 colorIntensity) { + static Color_RGBA8 primColor = { 255, 255, 0, 255 }; + static Color_RGBA8 envColor = { 255, 0, 0, 255 }; - D_801AE484.g = (s32)(255.0f * colorIntensity); - D_801AE484.b = 0; + primColor.g = (s32)(255.0f * colorIntensity); + primColor.b = 0; - D_801AE488.g = 0; - D_801AE488.b = 0; - D_801AE484.r = D_801AE488.r = (s32)(255.0f * colorIntensity); + envColor.g = 0; + envColor.b = 0; + primColor.r = envColor.r = (s32)(255.0f * colorIntensity); - EffectSsFireTail_Spawn(globalCtx, actor, pos, arg3, &actor->velocity, 15, &D_801AE484, &D_801AE488, + EffectSsFireTail_Spawn(globalCtx, actor, pos, arg3, &actor->velocity, 15, &primColor, &envColor, (colorIntensity == 1.0f) ? 0 : 1, bodyPart, 1); } -#else -void EffectSsFireTail_SpawnFlame(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 arg3, s16 bodyPart, - f32 colorIntensity); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsFireTail_SpawnFlame.s") -#endif void EffectSsFireTail_SpawnFlameOnPlayer(GlobalContext* globalCtx, f32 scale, s16 bodyPart, f32 colorIntensity) { Player* player = GET_PLAYER(globalCtx); @@ -919,7 +888,7 @@ void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* po initParams.bodyPart = bodyPart; if (actor != NULL) { - Audio_PlayActorSound2(actor, NA_SE_EV_FLAME_IGNITION); + Actor_PlaySfxAtPos(actor, NA_SE_EV_FLAME_IGNITION); } EffectSs_Spawn(globalCtx, EFFECT_SS_EN_FIRE, 128, &initParams); @@ -939,7 +908,7 @@ void EffectSsEnFire_SpawnVec3s(GlobalContext* globalCtx, Actor* actor, Vec3s* po initParams.bodyPart = bodyPart; if (actor != NULL) { - Audio_PlayActorSound2(actor, NA_SE_EV_FLAME_IGNITION); + Actor_PlaySfxAtPos(actor, NA_SE_EV_FLAME_IGNITION); } EffectSs_Spawn(globalCtx, EFFECT_SS_EN_FIRE, 128, &initParams); @@ -982,12 +951,17 @@ void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_DB, 120, &initParams); } -extern Color_RGBA8 D_801AE48C; -extern Color_RGBA8 D_801AE490[4]; - void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s32 colorIndex) { - EffectSsDeadDb_Spawn(globalCtx, pos, velocity, accel, &D_801AE48C, &D_801AE490[colorIndex], scale, scaleStep, 9); + static Color_RGBA8 primColor = { 255, 255, 255, 255 }; + static Color_RGBA8 envColors[] = { + { 255, 0, 0, 255 }, + { 0, 255, 0, 255 }, + { 0, 0, 255, 255 }, + { 150, 150, 150, 255 }, + }; + + EffectSsDeadDb_Spawn(globalCtx, pos, velocity, accel, &primColor, &envColors[colorIndex], scale, scaleStep, 9); } // EffectSsDeadDd Spawn Functions @@ -1032,7 +1006,7 @@ void EffectSsDeadDs_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, } void func_800B31BC(GlobalContext* globalCtx, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 life) { - EffectSsDeadDs_Spawn(globalCtx, pos, &D_801D15B0, &D_801D15B0, scale, scaleStep, alpha, life); + EffectSsDeadDs_Spawn(globalCtx, pos, &gZeroVec3f, &gZeroVec3f, scale, scaleStep, alpha, life); } // EffectSsIceSmoke Spawn Functions diff --git a/src/code/z_en_a_keep.c b/src/code/z_en_a_keep.c index d5125d2497..1d083b2c7a 100644 --- a/src/code/z_en_a_keep.c +++ b/src/code/z_en_a_keep.c @@ -11,10 +11,10 @@ void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.textId = ((this->actor.params >> 8) & 0xFF) | 0x300; this->actor.params = (this->actor.params & 0xFF) - 9; Actor_ProcessInitChain(&this->actor, &enAObjInitVar); - ActorShape_Init(&this->actor.shape, 0, func_800B3FC0, 12); + ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 12); Collider_InitAndSetCylinder(globalCtx, &this->collision, &this->actor, &enAObjCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collision); - this->actor.colChkInfo.mass = 255; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actionFunc = EnAObj_Update1; } @@ -27,7 +27,7 @@ void EnAObj_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx) { s32 yawDiff; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnAObj_Update2; } else { yawDiff = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)); @@ -39,7 +39,7 @@ void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx) { } void EnAObj_Update2(EnAObj* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actionFunc = EnAObj_Update1; } } @@ -48,10 +48,10 @@ void EnAObj_Update(Actor* thisx, GlobalContext* globalCtx) { EnAObj* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, 45.0f); + Actor_SetFocus(&this->actor, 45.0f); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collision.base); } void EnAObj_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, enAObjDisplayLists[thisx->params]); + Gfx_DrawDListOpa(globalCtx, enAObjDisplayLists[thisx->params]); } diff --git a/src/code/z_en_hy.c b/src/code/z_en_hy.c index 73adc5fa58..e0c4872628 100644 --- a/src/code/z_en_hy.c +++ b/src/code/z_en_hy.c @@ -66,7 +66,7 @@ Actor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) { f32 minDist = 0.0f; do { - doorIter = func_ActorCategoryIterateById(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); + doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); door = doorIter; dist = Actor_DistanceBetweenActors(actor, door); if (!isSetup || (dist < minDist)) { @@ -131,7 +131,7 @@ void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, Actor* door, s16 arg3, Vec3f offset; f32 phi_f0; - Actor_CalcOffsetOrientedToDrawRotation(door, &offset, &enHy->actor.world.pos); + Actor_OffsetOfPointInActorCoords(door, &offset, &enHy->actor.world.pos); phi_f0 = (offset.z >= 0.0f) ? 1.0f : -1.0f; sp3B = ((s8)phi_f0 < 0) ? 0 : 2; EnHy_ChangeObjectAndAnim(enHy, globalCtx, (sp3B == 0) ? arg3 : arg4); @@ -260,12 +260,12 @@ s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThr enHy->isLeftFootOnGround = isFootOnGround = func_8013DB90(globalCtx, &enHy->leftFootPos, distAboveThreshold); if (enHy->isLeftFootOnGround && !wasLeftFootOnGround && isFootOnGround) { - Audio_PlayActorSound2(&enHy->actor, sfxId); + Actor_PlaySfxAtPos(&enHy->actor, sfxId); } enHy->isRightFootOnGround = isFootOnGround = func_8013DB90(globalCtx, &enHy->rightFootPos, distAboveThreshold); if (enHy->isRightFootOnGround && !wasRightFootOnGround && isFootOnGround) { - Audio_PlayActorSound2(&enHy->actor, sfxId); + Actor_PlaySfxAtPos(&enHy->actor, sfxId); } return 0; } diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index acd827f8e9..2f0668c668 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -43,7 +43,7 @@ static InitChainEntry sInitChain[] = { }; void EnItem00_SetObject(EnItem00* this, GlobalContext* globalCtx, f32* shadowOffset, f32* shadowScale) { - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); Actor_SetScale(&this->actor, 0.5f); this->unk154 = 0.5f; *shadowOffset = 0.0f; @@ -63,7 +63,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->params &= 0xFF; // Has to be thisx to match - if (Actor_GetCollectibleFlag(globalCtx, this->collectibleFlag)) { + if (Flags_GetCollectible(globalCtx, this->collectibleFlag)) { if (this->actor.params == ITEM00_HEART_PIECE) { sp30 = 0; this->collectibleFlag = 0; @@ -169,7 +169,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { } this->unk14E = 0; - ActorShape_Init(&this->actor.shape, shadowOffset, func_800B3FC0, shadowScale); + ActorShape_Init(&this->actor.shape, shadowOffset, ActorShadow_DrawCircle, shadowScale); this->actor.shape.shadowAlpha = 180; this->actor.focus.pos = this->actor.world.pos; this->unk14A = GI_NONE; @@ -251,7 +251,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { } if ((getItemId != GI_NONE) && (Actor_HasParent(&this->actor, globalCtx) == 0)) { - func_800B8A1C(&this->actor, globalCtx, getItemId, 50.0f, 20.0f); + Actor_PickUp(&this->actor, globalCtx, getItemId, 50.0f, 20.0f); } this->actionFunc = func_800A6A40; @@ -407,7 +407,7 @@ void func_800A6A40(EnItem00* this, GlobalContext* globalCtx) { if (this->unk14A != GI_NONE) { if (Actor_HasParent(&this->actor, globalCtx) == 0) { - func_800B8A1C(&this->actor, globalCtx, this->unk14A, 50.0f, 80.0f); + Actor_PickUp(&this->actor, globalCtx, this->unk14A, 50.0f, 80.0f); this->unk152++; } else { this->unk14A = GI_NONE; @@ -457,7 +457,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.scale.y = this->actor.scale.x; if (this->actor.gravity != 0.0f) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 15.0f, 15.0f, 0x1D); if (this->actor.floorHeight <= BGCHECK_Y_MIN) { @@ -574,7 +574,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { if (getItemId != GI_NONE) { if (!Actor_HasParent(&this->actor, globalCtx)) { - func_800B8A1C(&this->actor, globalCtx, getItemId, 50.0f, 20.0f); + Actor_PickUp(&this->actor, globalCtx, getItemId, 50.0f, 20.0f); } } @@ -586,7 +586,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { case ITEM00_MAP: case ITEM00_COMPASS: if (Actor_HasParent(&this->actor, globalCtx)) { - Actor_SetCollectibleFlag(globalCtx, this->collectibleFlag); + Flags_SetCollectible(globalCtx, this->collectibleFlag); Actor_MarkForDeath(&this->actor); } return; @@ -598,7 +598,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { play_sound(NA_SE_SY_GET_RUPY); } else if (getItemId != GI_NONE) { if (Actor_HasParent(&this->actor, globalCtx)) { - Actor_SetCollectibleFlag(globalCtx, this->collectibleFlag); + Flags_SetCollectible(globalCtx, this->collectibleFlag); Actor_MarkForDeath(&this->actor); } return; @@ -606,7 +606,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { play_sound(NA_SE_SY_GET_ITEM); } - Actor_SetCollectibleFlag(globalCtx, this->collectibleFlag); + Flags_SetCollectible(globalCtx, this->collectibleFlag); this->unk152 = 15; this->unk14C = 35; @@ -651,7 +651,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { s8 bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEART); if (Object_IsLoaded(&globalCtx->objectCtx, bankIndex)) { this->actor.objBankIndex = bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); this->unk152 = -2; } } else { @@ -828,112 +828,94 @@ s16 func_800A7650(s16 dropId) { return dropId; } -#ifdef NON_MATCHING -// Reordering issues -EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params) { +Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params) { s32 pad; - EnItem00* spawnedActor = NULL; - s32 pad2; - s32 param10000; - s16 param8000; - s16 param7F00; - s32 param20000; - s32 paramFF; + Actor* spawnedActor = NULL; + s32 newParamFF; + s32 param10000 = params & 0x10000; + s16 param8000 = params & 0x8000; + s16 param7F00 = params & 0x7F00; + s32 param20000 = params & 0x20000; + s32 paramFF = params & 0xFF; s32 i; - param10000 = params & 0x10000; - param8000 = params & 0x8000; - param7F00 = params & 0x7F00; - param20000 = params & 0x20000; - paramFF = params & 0xFF; - params &= 0x7FFF; + newParamFF = params & 0xFF; if (paramFF == ITEM00_3_HEARTS) { - for (i = 0; i != 3; i++) { + for (i = 0; i < 3; i++) { spawnedActor = Item_DropCollectible(globalCtx, spawnPos, param7F00 | ITEM00_HEART | param8000); } } else if (paramFF == ITEM00_MUSHROOM_CLOUD) { param7F00 >>= 8; - if (!Actor_GetCollectibleFlag(globalCtx, param7F00)) { + if (!Flags_GetCollectible(globalCtx, param7F00)) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_KINOKO, spawnPos->x, spawnPos->y, spawnPos->z, 0, 0, 0, param7F00); } - } else if (((paramFF == ITEM00_FLEXIBLE) || ((params & 0xFF) == ITEM00_BIG_FAIRY)) && (param10000 == 0)) { - if ((params & 0xFF) == ITEM00_FLEXIBLE) { - // TODO: fix cast, this actor is not an EnItem00 - spawnedActor = - (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, + } else if (((paramFF == ITEM00_FLEXIBLE) || (newParamFF == ITEM00_BIG_FAIRY)) && (param10000 == 0)) { + newParamFF = params & 0xFF; + if (newParamFF == ITEM00_FLEXIBLE) { + spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) << 9) & 0xFE00) | 0x102); - if (!Actor_GetCollectibleFlag(globalCtx, (param7F00 >> 8) & 0x7F)) { - Audio_PlaySoundAtPosition(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); + if (!Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); } } else { - // TODO: fix cast, this actor is not an EnItem00 - spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, spawnPos->x, - spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, - ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7); + spawnedActor = + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f, + spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7); if (param20000 == 0) { - if (!Actor_GetCollectibleFlag(globalCtx, (param7F00 >> 8) & 0x7F)) { - Audio_PlaySoundAtPosition(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); + if (!Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); } } } } else { if (param8000 == 0) { - params = func_800A7650(params & 0xFF); + params = func_800A7650(newParamFF); } - if (params != (u32)ITEM00_NO_DROP) { - spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, - spawnPos->y, spawnPos->z, 0, 0, 0, params | param8000 | param7F00); + if ((s32)params != ITEM00_NO_DROP) { + spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, + spawnPos->z, 0, 0, 0, (s32)params | param8000 | param7F00); if ((spawnedActor != NULL) && (param8000 == 0)) { if (param10000 == 0) { - spawnedActor->actor.velocity.y = 8.0f; + spawnedActor->velocity.y = 8.0f; } else { - spawnedActor->actor.velocity.y = -2.0f; + spawnedActor->velocity.y = -2.0f; } - spawnedActor->actor.speedXZ = 2.0f; - spawnedActor->actor.gravity = -0.9f; - spawnedActor->actor.world.rot.y = randPlusMinusPoint5Scaled(65536.0f); - Actor_SetScale(&spawnedActor->actor, 0.0f); - spawnedActor->actionFunc = func_800A6780; - spawnedActor->unk152 = 0xDC; - if ((spawnedActor->actor.params != ITEM00_SMALL_KEY) && - (spawnedActor->actor.params != ITEM00_HEART_PIECE) && - (spawnedActor->actor.params != ITEM00_HEART_CONTAINER)) { - spawnedActor->actor.room = -1; + spawnedActor->speedXZ = 2.0f; + spawnedActor->gravity = -0.9f; + spawnedActor->world.rot.y = randPlusMinusPoint5Scaled(65536.0f); + Actor_SetScale(spawnedActor, 0.0f); + ((EnItem00*)spawnedActor)->actionFunc = func_800A6780; + ((EnItem00*)spawnedActor)->unk152 = 0xDC; + if ((spawnedActor->params != ITEM00_SMALL_KEY) && (spawnedActor->params != ITEM00_HEART_PIECE) && + (spawnedActor->params != ITEM00_HEART_CONTAINER)) { + spawnedActor->room = -1; } - spawnedActor->actor.flags |= 0x0010; + spawnedActor->flags |= 0x0010; } } } return spawnedActor; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_en_item00/Item_DropCollectible.s") -#endif -#ifdef NON_MATCHING -// Regalloc, minor reordering -Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params) { +Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 params) { Actor* spawnedActor = NULL; - u32 pad; - u32 param10000; - s16 param8000; - s16 param7F00; + s32 pad; + s32 param10000 = params & 0x10000; + s16 param8000 = params & 0x8000; + s16 param7F00 = params & 0x7F00; - param10000 = params & 0x10000; - param8000 = params & 0x8000; - param7F00 = params & 0x7F00; params &= 0xFF; - if (params == ITEM00_3_HEARTS) { + if ((params & 0xFF) == ITEM00_3_HEARTS) { return NULL; } - if (((params == ITEM00_FLEXIBLE) || (params == ITEM00_BIG_FAIRY)) && (param10000 == 0)) { - if (params == ITEM00_FLEXIBLE) { + if ((((params & 0xFF) == ITEM00_FLEXIBLE) || ((params & 0xFF) == ITEM00_BIG_FAIRY)) && (param10000 == 0)) { + if ((params & 0xFF) == ITEM00_FLEXIBLE) { spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) << 9) & 0xFE00) | 0x102); } else { @@ -941,14 +923,14 @@ Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, u32 para Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7); } - if (Actor_GetCollectibleFlag(globalCtx, (param7F00 >> 8) & 0x7F) == 0) { - Audio_PlaySoundAtPosition(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); + if (Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F) == 0) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); } } else { - params = func_800A7650(params); - if (params != (u32)ITEM00_NO_DROP) { + params = func_800A7650(params & 0xFF); + if (params != ITEM00_NO_DROP) { spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, - spawnPos->z, 0, 0, 0, params | param8000 | param7F00); + spawnPos->z, 0, 0, 0, (s32)params | param8000 | param7F00); if (spawnedActor != NULL) { if (param8000 == 0) { spawnedActor->velocity.y = 0.0f; @@ -967,9 +949,6 @@ Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, u32 para return spawnedActor; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_en_item00/Item_DropCollectible2.s") -#endif u8 sDropTable[DROP_TABLE_SIZE * DROP_TABLE_NUMBER] = { ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP, ITEM00_NO_DROP, @@ -1047,17 +1026,14 @@ u8 sDropTableAmounts[DROP_TABLE_SIZE * DROP_TABLE_NUMBER] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, }; -#ifdef NON_MATCHING -// Many regalloc and reordering issues void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3f* spawnPos, s16 params) { EnItem00* spawnedActor; u8 dropId; s32 dropQuantity; - s16 dropTableIndex; - s16 param8000; + s16 dropTableIndex = Rand_ZeroOne() * 16.0f; + s16 param8000 = params & 0x8000; + u8 dropFlag; - dropTableIndex = Rand_ZeroOne() * 16.0f; - param8000 = params & 0x8000; params &= 0x1F0; if (params < 0x101) { @@ -1065,50 +1041,54 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 dropQuantity = sDropTableAmounts[params + dropTableIndex]; if (dropId == ITEM00_MASK) { - dropQuantity = 1; - if (gSaveContext.playerForm != PLAYER_FORM_GORON) { - if (gSaveContext.playerForm != PLAYER_FORM_ZORA) { - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - dropId = ITEM00_RUPEE_GREEN; - } else { - dropId = ITEM00_ARROWS_10; - } - } else { + switch (gSaveContext.playerForm) { + case PLAYER_FORM_HUMAN: + dropId = ITEM00_ARROWS_10; + break; + case PLAYER_FORM_ZORA: dropId = ITEM00_HEART; - } - } else { - dropId = ITEM00_MAGIC_SMALL; + break; + case PLAYER_FORM_GORON: + dropId = ITEM00_MAGIC_SMALL; + break; + default: + dropId = ITEM00_RUPEE_GREEN; + break; } + dropQuantity = 1; } if (fromActor != NULL) { - if (fromActor->dropFlag != 0) { - if ((fromActor->dropFlag & 1) != 0) { + dropFlag = fromActor->dropFlag; + if (dropFlag != 0) { + if (fromActor->dropFlag & 1) { + params = 0x10; dropId = ITEM00_ARROWS_30; + dropQuantity = 1; + } else if (fromActor->dropFlag & 2) { params = 0x10; - } else if ((fromActor->dropFlag & 2) != 0) { dropId = ITEM00_HEART; - params = 0x10; - } else if ((fromActor->dropFlag & 0x20) != 0) { + dropQuantity = 1; + } else if (fromActor->dropFlag & 0x20) { dropId = ITEM00_RUPEE_PURPLE; + dropQuantity = 1; } - dropQuantity = 1; } } if (dropId == ITEM00_FLEXIBLE) { - if (gSaveContext.health < 0x11) { + if (gSaveContext.health <= 0x10) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, 2); - Audio_PlaySoundAtPosition(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); return; } - if (gSaveContext.health < 0x31) { + if (gSaveContext.health <= 0x30) { params = 0x10; dropId = ITEM00_HEART; dropQuantity = 3; - } else if (gSaveContext.health < 0x51) { + } else if (gSaveContext.health <= 0x50) { params = 0x10; dropId = ITEM00_HEART; dropQuantity = 1; @@ -1132,6 +1112,8 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 params = 0xA0; dropId = ITEM00_RUPEE_RED; dropQuantity = 1; + } else { + return; } } @@ -1167,18 +1149,16 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_en_item00/Item_DropCollectibleRandom.s") -#endif -s32 D_801AE194[32] = { ITEM00_NO_DROP, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP, - ITEM00_RUPEE_RED, ITEM00_RUPEE_PURPLE, ITEM00_NO_DROP, ITEM00_RUPEE_HUGE, - ITEM00_COMPASS, ITEM00_MUSHROOM_CLOUD, ITEM00_HEART, ITEM00_3_HEARTS, - ITEM00_HEART_PIECE, ITEM00_HEART_CONTAINER, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_LARGE, - ITEM00_FLEXIBLE, ITEM00_BIG_FAIRY, ITEM00_NO_DROP, ITEM00_NUTS_10, - ITEM00_NO_DROP, ITEM00_BOMBS_A, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_STICK, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_ARROWS_10, ITEM00_ARROWS_30 }; +s32 D_801AE194[32] = { + ITEM00_NO_DROP, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP, ITEM00_RUPEE_RED, + ITEM00_RUPEE_PURPLE, ITEM00_NO_DROP, ITEM00_RUPEE_HUGE, ITEM00_COMPASS, ITEM00_MUSHROOM_CLOUD, + ITEM00_HEART, ITEM00_3_HEARTS, ITEM00_HEART_PIECE, ITEM00_HEART_CONTAINER, ITEM00_MAGIC_SMALL, + ITEM00_MAGIC_LARGE, ITEM00_FLEXIBLE, ITEM00_BIG_FAIRY, ITEM00_NO_DROP, ITEM00_NUTS_10, + ITEM00_NO_DROP, ITEM00_BOMBS_A, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_STICK, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_ARROWS_10, ITEM00_ARROWS_30, +}; s32 func_800A8150(s32 index) { if ((index < 0) || (index >= ARRAY_COUNT(D_801AE194))) { @@ -1188,9 +1168,7 @@ s32 func_800A8150(s32 index) { return D_801AE194[index]; } -u8 D_801AE214[32] = { - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; +u8 D_801AE214[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; s32 func_800A817C(s32 index) { if ((index < 0) || (index >= ARRAY_COUNT(D_801AE214))) { @@ -1201,5 +1179,5 @@ s32 func_800A817C(s32 index) { } s32 func_800A81A4(GlobalContext* globalCtx, s32 a1, s32 a2) { - return (func_800A8150(a1) == ITEM00_BIG_FAIRY) && (!Actor_GetCollectibleFlag(globalCtx, a2)); + return (func_800A8150(a1) == ITEM00_BIG_FAIRY) && (!Flags_GetCollectible(globalCtx, a2)); } diff --git a/src/code/z_fbdemo.c b/src/code/z_fbdemo.c index c2da6f9cef..3d33399e58 100644 --- a/src/code/z_fbdemo.c +++ b/src/code/z_fbdemo.c @@ -1,4 +1,5 @@ #include "global.h" +#include "system_malloc.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/func_80163DC0.s") diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index 6e543d115a..2cf05e02a0 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -1,5 +1,6 @@ #include "global.h" #include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" +#include "objects/gameplay_keep/gameplay_keep.h" typedef enum { FIRE_STATE_0, @@ -130,7 +131,7 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { } } else if (player->unk_B28 == 0) { player->unk_B28 = 0xD2; - Audio_PlaySoundAtPosition(globalCtx, &fire->position, 20, NA_SE_EV_FLAME_IGNITION); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &fire->position, 20, NA_SE_EV_FLAME_IGNITION); } else if (player->unk_B28 < 0xC8) { player->unk_B28 = 0xC8; } @@ -162,7 +163,7 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { Matrix_Scale(fire->xScale, fire->yScale, 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++, D_0407D590); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } } diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 979b28cbaa..15f3a66935 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -44,7 +44,7 @@ void GameOver_Update(GlobalContext* globalCtx) { } gSaveContext.unk_3DC0 = 2000; - gSaveContext.naviTimer = 0; + gSaveContext.tatlTimer = 0; gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.eventInf[0] = 0; diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c index c79b0067f3..5e89f49e97 100644 --- a/src/code/z_kaleido_manager.c +++ b/src/code/z_kaleido_manager.c @@ -1,15 +1,104 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_manager/D_801DF9C0.s") +#define KALEIDO_OVERLAY(name) \ + { \ + NULL, SEGMENT_ROM_START(ovl_##name), SEGMENT_ROM_END(ovl_##name), SEGMENT_START(ovl_##name), \ + SEGMENT_END(ovl_##name), 0, #name, \ + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_manager/func_80163700.s") +KaleidoMgrOverlay gKaleidoMgrOverlayTable[] = { + KALEIDO_OVERLAY(kaleido_scope), + KALEIDO_OVERLAY(player_actor), +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_manager/func_80163758.s") +void* sKaleidoAreaPtr = NULL; +KaleidoMgrOverlay* gKaleidoMgrCurOvl = NULL; +FaultAddrConvClient sKaleidoAreaFaultClient; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_manager/func_801637B4.s") +void* KaleidoManager_FaultAddrConvFunc(void* address, void* param) { + u8* ptr = address; + KaleidoMgrOverlay* ovl = &gKaleidoMgrCurOvl[0]; + u8* ramStart; + u8* ramEnd; + size_t size; + uintptr_t offset; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_manager/func_80163804.s") + if (ovl != NULL) { + size = VRAM_PTR_SIZE(ovl); + ramStart = ovl->loadedRamAddr; + ramEnd = ramStart + size; + offset = (u8*)ovl->vramStart - ramStart; + if (ramStart != NULL) { + if (ptr >= ramStart && ptr < ramEnd) { + return ptr + offset; + } + } + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_manager/func_8016388C.s") +void KaleidoManager_LoadOvl(KaleidoMgrOverlay* ovl) { + ovl->loadedRamAddr = sKaleidoAreaPtr; + Load2_LoadOverlay(ovl->vromStart, ovl->vromEnd, ovl->vramStart, ovl->vramEnd, ovl->loadedRamAddr); + ovl->offset = (uintptr_t)ovl->loadedRamAddr - (uintptr_t)ovl->vramStart; + gKaleidoMgrCurOvl = ovl; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_manager/func_801638D8.s") +void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl) { + if (ovl->loadedRamAddr != NULL) { + ovl->offset = 0; + bzero(ovl->loadedRamAddr, VRAM_PTR_SIZE(ovl)); + ovl->loadedRamAddr = NULL; + gKaleidoMgrCurOvl = NULL; + } +} + +void KaleidoManager_Init(GlobalContext* globalCtx) { + s32 largestSize = 0; + s32 size; + u32 i; + + for (i = 0; i < ARRAY_COUNT(gKaleidoMgrOverlayTable); i++) { + size = VRAM_PTR_SIZE(&gKaleidoMgrOverlayTable[i]); + if (size > largestSize) { + largestSize = size; + } + } + + sKaleidoAreaPtr = THA_AllocEndAlign16(&globalCtx->state.heap, largestSize); + gKaleidoMgrCurOvl = NULL; + Fault_AddAddrConvClient(&sKaleidoAreaFaultClient, KaleidoManager_FaultAddrConvFunc, NULL); +} + +void KaleidoManager_Destroy() { + Fault_RemoveAddrConvClient(&sKaleidoAreaFaultClient); + + if (gKaleidoMgrCurOvl != NULL) { + KaleidoManager_ClearOvl(gKaleidoMgrCurOvl); + gKaleidoMgrCurOvl = NULL; + } + + sKaleidoAreaPtr = NULL; +} + +void* KaleidoManager_GetRamAddr(void* vram) { + if (gKaleidoMgrCurOvl == NULL) { + s32 pad[2]; + KaleidoMgrOverlay* ovl = &gKaleidoMgrOverlayTable[0]; + + do { + if (((uintptr_t)vram >= (uintptr_t)ovl->vramStart) && ((uintptr_t)ovl->vramEnd >= (uintptr_t)vram)) { + KaleidoManager_LoadOvl(ovl); + return (void*)((uintptr_t)vram + ovl->offset); + } + ovl++; + } while (ovl != (KaleidoMgrOverlay*)&sKaleidoAreaPtr); + + return NULL; + } else if (((uintptr_t)vram < (uintptr_t)gKaleidoMgrCurOvl->vramStart) || + ((uintptr_t)vram >= (uintptr_t)gKaleidoMgrCurOvl->vramEnd)) { + return NULL; + } + + return (void*)((uintptr_t)vram + gKaleidoMgrCurOvl->offset); +} diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index 58f30ae165..b6d46eba16 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -1,11 +1,84 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_scope_call/func_801639A0.s") +void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx); +void (*sKaleidoScopeDrawFunc)(GlobalContext* globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_scope_call/func_801639EC.s") +extern void KaleidoScope_Update(GlobalContext* globalCtx); +extern void KaleidoScope_Draw(GlobalContext* globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_scope_call/func_80163A38.s") +void KaleidoScopeCall_LoadPlayer() { + KaleidoMgrOverlay* playerActorOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_PLAYER_ACTOR]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_scope_call/func_80163A58.s") + if (gKaleidoMgrCurOvl != playerActorOvl) { + if (gKaleidoMgrCurOvl != NULL) { + KaleidoManager_ClearOvl(gKaleidoMgrCurOvl); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_scope_call/func_80163C0C.s") + KaleidoManager_LoadOvl(playerActorOvl); + } +} + +void KaleidoScopeCall_Init(GlobalContext* globalCtx) { + sKaleidoScopeUpdateFunc = KaleidoManager_GetRamAddr(KaleidoScope_Update); + sKaleidoScopeDrawFunc = KaleidoManager_GetRamAddr(KaleidoScope_Draw); + KaleidoSetup_Init(globalCtx); +} + +void KaleidoScopeCall_Destroy(GlobalContext* globalCtx) { + KaleidoSetup_Destroy(globalCtx); +} + +void KaleidoScopeCall_Update(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; + + if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.debugState != 0)) { + if (pauseCtx->state == 1 || pauseCtx->state == 19) { + if (ShrinkWindow_GetLetterboxMagnitude() == 0) { + R_PAUSE_MENU_MODE = 1; + pauseCtx->unk_200 = 0; + pauseCtx->unk_208 = 0; + pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; + } + } else if (pauseCtx->state == 8) { + R_PAUSE_MENU_MODE = 1; + pauseCtx->unk_200 = 0; + pauseCtx->unk_208 = 0; + pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; + } else if ((pauseCtx->state == 2) || (pauseCtx->state == 9) || (pauseCtx->state == 20)) { + if (R_PAUSE_MENU_MODE == 3) { + pauseCtx->state++; + } + } else if (pauseCtx->state != 0) { + if (gKaleidoMgrCurOvl != kaleidoScopeOvl) { + if (gKaleidoMgrCurOvl != NULL) { + KaleidoManager_ClearOvl(gKaleidoMgrCurOvl); + } + + KaleidoManager_LoadOvl(kaleidoScopeOvl); + } + + if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { + sKaleidoScopeUpdateFunc(globalCtx); + + if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) { + KaleidoManager_ClearOvl(kaleidoScopeOvl); + KaleidoScopeCall_LoadPlayer(); + } + } + } + } +} + +void KaleidoScopeCall_Draw(GlobalContext* globalCtx) { + KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; + + if (R_PAUSE_MENU_MODE == 3) { + if (((globalCtx->pauseCtx.state >= 4) && (globalCtx->pauseCtx.state <= 7)) || + ((globalCtx->pauseCtx.state >= 11) && (globalCtx->pauseCtx.state <= 26))) { + if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { + sKaleidoScopeDrawFunc(globalCtx); + } + } + } +} diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 8065a9a6b5..7f4d437845 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -4,6 +4,6 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/func_800F4C0C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/func_800F4E20.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Init.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/func_800F4F28.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Destroy.s") diff --git a/src/code/z_lib.c b/src/code/z_lib.c index 5bc49c8aca..84eb8c051c 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -647,8 +647,8 @@ void func_801000CC(u16 sfxId) { func_8019F128(sfxId); } -void func_801000F4(s32 a0, u16 sfxId) { - func_8019F1C0(a0, sfxId); +void Lib_PlaySfxAtPos(Vec3f* pos, u16 sfxId) { + Audio_PlaySfxAtPos(pos, sfxId); } void Lib_Vec3f_TranslateAndRotateY(Vec3f* translation, s16 a, Vec3f* src, Vec3f* dst) { diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index bbfad829f3..738f9373e2 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -399,9 +399,9 @@ void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx) { if (interfaceCtx->lifeSizeChange <= 0) { interfaceCtx->lifeSizeChange = 0; interfaceCtx->lifeSizeChangeDirection = 0; - if (func_801233E4(globalCtx) == 0 && (globalCtx->pauseCtx.state == 0) && + if (Player_InCsMode(&globalCtx->state) == 0 && (globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && LifeMeter_IsCritical() && func_801690CC(globalCtx) == 0) { - // func_801233E4 and func_801690CC : Check if in Cutscene + // Player_InCsMode and func_801690CC : Check if in Cutscene play_sound(NA_SE_SY_HITPOINT_ALARM); } } diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 4d649da2d7..fae6af51e1 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -382,7 +382,7 @@ void Lights_GlowCheck(GlobalContext* globalCtx) { pos.x = params->x; pos.y = params->y; pos.z = params->z; - func_800B4EDC(globalCtx, &pos, &multDest, &wDest); + Actor_GetProjectedPos(globalCtx, &pos, &multDest, &wDest); params->drawGlow = 0; diff --git a/src/code/z_malloc.c b/src/code/z_malloc.c index 8d0bba44ac..781f4310e8 100644 --- a/src/code/z_malloc.c +++ b/src/code/z_malloc.c @@ -1,4 +1,7 @@ #include "global.h" +#include "os_malloc.h" + +Arena sZeldaArena; void* ZeldaArena_Malloc(size_t size) { void* ptr = __osMalloc(&sZeldaArena, size); @@ -34,11 +37,11 @@ void* ZeldaArena_Calloc(u32 num, size_t size) { } void ZeldaArena_GetSizes(size_t* outMaxFree, size_t* outFree, size_t* outAlloc) { - __osAnalyzeArena(&sZeldaArena, outMaxFree, outFree, outAlloc); + __osGetSizes(&sZeldaArena, outMaxFree, outFree, outAlloc); } -void ZeldaArena_Check() { - __osCheckArena(&sZeldaArena); +s32 ZeldaArena_Check() { + return __osCheckArena(&sZeldaArena); } void ZeldaArena_Init(void* start, size_t size) { diff --git a/src/code/z_message.c b/src/code/z_message.c index 0bfbdc53d2..84f2ab951c 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -80,7 +80,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152464.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152498.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_GetState.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015268C.s") diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index c03c0dfc7c..99253188cb 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -38,7 +38,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123358.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801233E4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_InCsMode.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123420.s") @@ -114,7 +114,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012422C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124258.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_GetExplosiveHeld.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124278.s") diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 9c5288139d..e699ff0862 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -608,7 +608,7 @@ void Quake2_Update(void) { player = GET_PLAYER(globalCtx); if (&player->actor != NULL) { - func_800B8248(&playerPosRot, player); + Actor_GetWorldPosShapeRot(&playerPosRot, &player->actor); } angle1Speed = 359.2f; diff --git a/src/code/z_room.c b/src/code/z_room.c index fe4b51d68c..1685acc80e 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -18,14 +18,14 @@ void Room_DrawType0Mesh(GlobalContext* globalCtx, Room* room, u32 flags) { func_800BCBF4(&D_801C1D10, globalCtx); gSPSegment(gfxCtx->polyOpa.p++, 0x03, room->segment); func_8012C268(globalCtx); - gSPMatrix(gfxCtx->polyOpa.p++, &D_801D1DE0, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(gfxCtx->polyOpa.p++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); } if (flags & 2) { func_800BCC68(&D_801C1D10, globalCtx); gSPSegment(gfxCtx->polyXlu.p++, 0x03, room->segment); func_8012C2DC(globalCtx->state.gfxCtx); - gSPMatrix(gfxCtx->polyXlu.p++, &D_801D1DE0, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(gfxCtx->polyXlu.p++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); } mesh = &room->mesh->type0; diff --git a/src/code/z_snap.c b/src/code/z_snap.c index 1c0ab3a27d..6d206eea55 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -20,7 +20,7 @@ s32 func_8013A240(GlobalContext* globalCtx) { } for (; type < 12; type++) { - for (actor = globalCtx->actorCtx.actorList[type].first; actor != NULL; actor = actor->next) { + for (actor = globalCtx->actorCtx.actorLists[type].first; actor != NULL; actor = actor->next) { seen = 0; switch (globalCtx->sceneNum) { @@ -134,7 +134,7 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, ret |= 0x3e; } - func_800B4EDC(globalCtx, pos, &screenSpace, &distance); + Actor_GetProjectedPos(globalCtx, pos, &screenSpace, &distance); x = (s16)(screenSpace.x * distance * 160.0f + 160.0f) - 85; y = (s16)(screenSpace.y * distance * -120.0f + 120.0f) - 67; if ((x < 0) || (0x96 < x) || (y < 0) || (0x69 < y)) { diff --git a/src/code/z_sound_source.c b/src/code/z_sound_source.c new file mode 100644 index 0000000000..ba7036a4ce --- /dev/null +++ b/src/code/z_sound_source.c @@ -0,0 +1,75 @@ +#include "global.h" + +void SoundSource_InitAll(GlobalContext* globalCtx) { + SoundSource* sources = &globalCtx->soundSources[0]; + s32 i; + + // clang-format off + for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { sources[i].countdown = 0; } + // clang-format on +} + +void SoundSource_UpdateAll(GlobalContext* globalCtx) { + SoundSource* source = &globalCtx->soundSources[0]; + s32 i; + + for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { + if (source->countdown != 0) { + if (DECR(source->countdown) == 0) { + Audio_StopSfxByPos(&source->projectedPos); + } else { + SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &source->worldPos, &source->projectedPos); + if (source->playSfxEachFrame) { + Audio_PlaySfxAtPos(&source->projectedPos, source->sfxId); + } + } + } + + source++; + } +} + +void SoundSource_Add(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId, u32 playSfxEachFrame) { + s32 countdown; + SoundSource* source; + s32 smallestCountdown = 0xFFFF; + SoundSource* backupSource = NULL; + s32 i; + + source = &globalCtx->soundSources[0]; + for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { + if (source->countdown == 0) { + break; + } + + // Store the sound source with the smallest remaining countdown + countdown = source->countdown; + if (countdown < smallestCountdown) { + smallestCountdown = countdown; + backupSource = source; + } + source++; + } + + // If no sound source is available, replace the sound source with the smallest remaining countdown + if (i >= ARRAY_COUNT(globalCtx->soundSources)) { + source = backupSource; + Audio_StopSfxByPos(&source->projectedPos); + } + + source->worldPos = *worldPos; + source->countdown = duration; + source->playSfxEachFrame = playSfxEachFrame; + source->sfxId = sfxId; + + SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &source->worldPos, &source->projectedPos); + Audio_PlaySfxAtPos(&source->projectedPos, sfxId); +} + +void SoundSource_PlaySfxAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId) { + SoundSource_Add(globalCtx, worldPos, duration, sfxId, false); +} + +void SoundSource_PlaySfxEachFrameAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId) { + SoundSource_Add(globalCtx, worldPos, duration, sfxId, true); +} diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 1ab44acc10..8f0599b553 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -1,6 +1,40 @@ -#include "global.h" +/* + * File: z_sub_s.c + * Description: Various miscellaneous helpers + */ -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013A7C0.s") +#include "global.h" +#include "overlays/actors/ovl_En_Door/z_en_door.h" + +/** + * Finds the first EnDoor instance with unk_1A4 == 5 and the specified unk_1A5. + */ +EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) { + Actor* actor = NULL; + EnDoor* door; + + while (true) { + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_DOOR, ACTOR_EN_DOOR); + door = (EnDoor*)actor; + + if (actor == NULL) { + break; + } + + if ((door->unk_1A4 == 5) && (door->unk_1A5 == (u8)unk_1A5)) { + break; + } + + if (actor->next == NULL) { + door = NULL; + break; + } + + actor = actor->next; + } + + return door; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013A860.s") @@ -26,7 +60,40 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BB34.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BB7C.s") +/** + * Finds the nearest actor instance of a specified Id and category to an actor. + */ +Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId) { + Actor* actorIter = NULL; + Actor* actorTmp; + f32 dist; + Actor* closestActor = NULL; + f32 minDist = 99999.0f; + s32 isSetup = false; + + do { + actorIter = SubS_FindActor(globalCtx, actorIter, actorCategory, actorId); + + actorTmp = actorIter; + if (actorTmp == NULL) { + break; + } + actorIter = actorTmp; + + if (actorIter != actor) { + dist = Actor_DistanceBetweenActors(actor, actorIter); + if (!isSetup || dist < minDist) { + closestActor = actorIter; + minDist = dist; + isSetup = true; + } + } + + actorIter = actorIter->next; + } while (actorIter != NULL); + + return closestActor; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BC6C.s") @@ -68,7 +135,22 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D924.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_ActorCategoryIterateById.s") +/** + * Finds the first actor instance of a specified Id and category. + */ +Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId) { + Actor* actor = actorListStart; + + if (actor == NULL) { + actor = globalCtx->actorCtx.actorLists[actorCategory].first; + } + + while (actor != NULL && actorId != actor->id) { + actor = actor->next; + } + + return actor; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D9C8.s") @@ -100,7 +182,27 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E5CC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E640.s") +/** + * Finds the first actor instance of a specified Id and category verified with a custom callback. + * The callback should return `true` when the actor is succesfully verified. + */ +Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, + s16 actorId, void* verifyData, VerifyActor verifyActor) { + Actor* actorIter = actorListStart; + + if (actorListStart == NULL) { + actorIter = globalCtx->actorCtx.actorLists[actorCategory].first; + } + + while (actorIter != NULL && (actorId != actorIter->id || + (actorId == actorIter->id && + (verifyActor == NULL || + (verifyActor != NULL && !verifyActor(globalCtx, actor, actorIter, verifyData)))))) { + actorIter = actorIter->next; + } + + return actorIter; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E748.s") diff --git a/src/code/z_vismono.c b/src/code/z_vismono.c index 4e02a0af2c..6c0d1ef223 100644 --- a/src/code/z_vismono.c +++ b/src/code/z_vismono.c @@ -1,4 +1,5 @@ #include "global.h" +#include "system_malloc.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_801418B0.s") diff --git a/src/libultra/io/contchannelreset.c b/src/libultra/io/contchannelreset.c index 841dad7386..d0f1fbd9bc 100644 --- a/src/libultra/io/contchannelreset.c +++ b/src/libultra/io/contchannelreset.c @@ -1,3 +1,27 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/contchannelreset/__osContChannelReset.s") +s32 __osContChannelReset(OSMesgQueue* mq, s32 channel) { + s32 i; + s32 ret; + u8* bufptr = (u8*)&__osPfsPifRam; + + __osSiGetAccess(); + + __osPfsPifRam.status = 1; + + for (i = 0; i < channel; i++) { + *bufptr++ = 0; + } + + *bufptr++ = 0xFD; + *bufptr = CONT_CMD_END; + + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + + __osSiRelAccess(); + + return ret; +} diff --git a/src/libultra/io/contpfs.c b/src/libultra/io/contpfs.c index 3dd0c96ca8..fd4c4e459f 100644 --- a/src/libultra/io/contpfs.c +++ b/src/libultra/io/contpfs.c @@ -1,6 +1,42 @@ #include "ultra64.h" #include "global.h" +__OSInode __osPfsInodeCache; +OSViMode osViModeNtscHpn1 = { + 8, // type + { + // comRegs + 0x324E, // ctrl + 0x500, // width + 0x3E52239, // burst + 0x20C, // vSync + 0xC15, // hSync + 0xC150C15, // leap + 0x6C02EC, // hStart + 0x400, // xScale + 0, // vCurrent + }, + { // fldRegs + { + // [0] + 0x500, // origin + 0x400, // yScale + 0x2301FD, // vStart + 0xE0204, // vBurst + 2, // vIntr + }, + { + // [1] + 0xA00, // origin + 0x400, // yScale + 0x2501FF, // vStart + 0xE0204, // vBurst + 2, // vIntr + } }, +}; +s32 __osPfsInodeCacheChannel = -1; +u8 __osPfsInodeCacheBank = 250; + u16 __osSumcalc(u8* ptr, s32 length) { s32 i; u32 sum = 0; diff --git a/src/libultra/io/contreaddata.c b/src/libultra/io/contreaddata.c index 47b7968d38..b54d894f30 100644 --- a/src/libultra/io/contreaddata.c +++ b/src/libultra/io/contreaddata.c @@ -47,7 +47,7 @@ void __osPackReadData() { __osContPifRam.ramarray[i] = 0; } - __osContPifRam.pifstatus = 1; + __osContPifRam.status = 1; readformat.dummy = 255; readformat.txsize = 1; readformat.rxsize = 4; diff --git a/src/libultra/io/controller.c b/src/libultra/io/controller.c index d84ba2d711..bd82709931 100644 --- a/src/libultra/io/controller.c +++ b/src/libultra/io/controller.c @@ -78,7 +78,7 @@ void __osPackRequestData(u8 poll) { __osContPifRam.ramarray[i] = 0; } - __osContPifRam.pifstatus = 1; + __osContPifRam.status = 1; ptr = (u8*)__osContPifRam.ramarray; requestHeader.align = 255; requestHeader.txsize = 1; diff --git a/src/libultra/io/motor.c b/src/libultra/io/motor.c index b8216dfc78..649a8b368f 100644 --- a/src/libultra/io/motor.c +++ b/src/libultra/io/motor.c @@ -20,7 +20,7 @@ s32 __osMotorAccess(OSPfs* pfs, u32 vibrate) { } __osSiGetAccess(); - osPifBuffers[pfs->channel].pifstatus = 1; + osPifBuffers[pfs->channel].status = 1; buf += pfs->channel; for (i = 0; i < BLOCKSIZE; i++) { ((__OSContRamReadFormat*)buf)->data[i] = vibrate; diff --git a/src/libultra/io/pfsfreeblocks.c b/src/libultra/io/pfsfreeblocks.c index af10a5b887..b90979c595 100644 --- a/src/libultra/io/pfsfreeblocks.c +++ b/src/libultra/io/pfsfreeblocks.c @@ -1,3 +1,37 @@ #include "global.h" +#include "PR/pfs.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsfreeblocks/osPfsFreeBlocks.s") +s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes) { + s32 j; + s32 pages = 0; + __OSInode inode; + s32 ret = 0; + u8 bank; + s32 offset; + + if (!(pfs->status & PFS_INITIALIZED)) { + return PFS_ERR_INVALID; + } + + ret = __osCheckId(pfs); + if (ret != 0) { + return ret; + } + + for (bank = PFS_ID_BANK_256K; bank < pfs->banks; bank++) { + ret = __osPfsRWInode(pfs, &inode, PFS_READ, bank); + if (ret != 0) { + return ret; + } + + offset = ((bank > PFS_ID_BANK_256K) ? 1 : pfs->inodeStartPage); + for (j = offset; j < PFS_INODE_SIZE_PER_PAGE; j++) { + if (inode.inodePage[j].ipage == PFS_PAGE_NOT_USED) { + pages++; + } + } + } + + *leftoverBytes = pages * PFS_ONE_PAGE * BLOCKSIZE; + return 0; +} diff --git a/src/libultra/io/pfsgetstatus.c b/src/libultra/io/pfsgetstatus.c index 8127dde217..1d8e6dcf5f 100644 --- a/src/libultra/io/pfsgetstatus.c +++ b/src/libultra/io/pfsgetstatus.c @@ -1,7 +1,75 @@ +#include "ultra64.h" #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsgetstatus/__osPfsGetStatus.s") +void __osPfsRequestOneChannel(s32 channel, u8 poll); +void __osPfsGetOneChannelData(s32 channel, OSContStatus* contData); -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsgetstatus/__osPfsRequestOneChannel.s") +s32 __osPfsGetStatus(OSMesgQueue* queue, s32 channel) { + s32 ret = 0; + OSMesg msg; + OSContStatus data; -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsgetstatus/__osPfsGetOneChannelData.s") + __osPfsInodeCacheBank = 250; + + __osPfsRequestOneChannel(channel, CONT_CMD_REQUEST_STATUS); + ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + osRecvMesg(queue, &msg, OS_MESG_BLOCK); + + ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); + osRecvMesg(queue, &msg, OS_MESG_BLOCK); + + __osPfsGetOneChannelData(channel, &data); + if (((data.status & CONT_CARD_ON) != 0) && ((data.status & CONT_CARD_PULL) != 0)) { + return PFS_ERR_NEW_PACK; + } else if (data.errno || ((data.status & CONT_CARD_ON) == 0)) { + return PFS_ERR_NOPACK; + } else if ((data.status & CONT_ADDR_CRC_ER) != 0) { + return PFS_ERR_CONTRFAIL; + } + return ret; +} + +void __osPfsRequestOneChannel(s32 channel, u8 poll) { + u8* bufptr; + __OSContRequestHeaderAligned req; + s32 idx; + + __osContLastPoll = CONT_CMD_END; + __osPfsPifRam.status = CONT_CMD_READ_BUTTON; + + bufptr = (u8*)&__osPfsPifRam; + + req.txsize = 1; + req.rxsize = 3; + req.poll = poll; + req.typeh = 0xFF; + req.typel = 0xFF; + req.status = 0xFF; + + for (idx = 0; idx < channel; idx++) { + *bufptr++ = 0; + } + + *((__OSContRequestHeaderAligned*)bufptr) = req; + bufptr += sizeof(req); + *((u8*)bufptr) = CONT_CMD_END; +} + +void __osPfsGetOneChannelData(s32 channel, OSContStatus* contData) { + u8* bufptr = (u8*)&__osPfsPifRam; + __OSContRequestHeaderAligned req; + s32 idx; + + for (idx = 0; idx < channel; idx++) { + bufptr++; + } + + req = *((__OSContRequestHeaderAligned*)bufptr); + contData->errno = (req.rxsize & 0xC0) >> 4; + if (contData->errno) { + return; + } + + contData->type = (req.typel << 8) | req.typeh; + contData->status = req.status; +} diff --git a/src/libultra/io/pfsisplug.c b/src/libultra/io/pfsisplug.c index 358af0c985..474c7f914b 100644 --- a/src/libultra/io/pfsisplug.c +++ b/src/libultra/io/pfsisplug.c @@ -55,7 +55,7 @@ void __osPfsRequestData(u8 poll) { __osContLastPoll = poll; - __osPfsPifRam.pifstatus = 1; + __osPfsPifRam.status = 1; req.align = 0xFF; req.txsize = 1; diff --git a/src/libultra/io/pfsreadwritefile.c b/src/libultra/io/pfsreadwritefile.c index bc2b9741ce..b5ab6e4b4c 100644 --- a/src/libultra/io/pfsreadwritefile.c +++ b/src/libultra/io/pfsreadwritefile.c @@ -1,5 +1,124 @@ +#include "ultra64.h" #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsreadwritefile/__osPfsGetNextPage.s") +#define CHECK_IPAGE(p, pfs) \ + (((p).ipage >= (pfs).inodeStartPage) && ((p).inode_t.bank < (pfs).banks) && ((p).inode_t.page >= 0x01) && \ + ((p).inode_t.page < 0x80)) -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsreadwritefile/osPfsReadWriteFile.s") +s32 __osPfsGetNextPage(OSPfs* pfs, u8* bank, __OSInode* inode, __OSInodeUnit* page) { + s32 ret; + + if (page->inode_t.bank != *bank) { + *bank = page->inode_t.bank; + if ((ret = __osPfsRWInode(pfs, inode, PFS_READ, *bank)) != 0) { + return ret; + } + } + *page = inode->inodePage[page->inode_t.page]; + + if (!CHECK_IPAGE(*page, *pfs)) { + if (page->ipage == PFS_EOF) { + return PFS_ERR_INVALID; + } + return PFS_ERR_INCONSISTENT; + } + return 0; +} + +s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8* data) { + s32 ret; + __OSDir dir; + __OSInode inode; + __OSInodeUnit curPage; + s32 curBlock; + s32 blockSize; + u8* buffer; + u8 bank; + u16 blockno; + + if ((fileNo >= pfs->dir_size) || (fileNo < 0)) { + return PFS_ERR_INVALID; + } + if ((size <= 0) || ((size % BLOCKSIZE) != 0)) { + return PFS_ERR_INVALID; + } + if ((offset < 0) || ((offset % BLOCKSIZE) != 0)) { + return PFS_ERR_INVALID; + } + if (!(pfs->status & PFS_INITIALIZED)) { + return PFS_ERR_INVALID; + } + if (__osCheckId(pfs) == PFS_ERR_NEW_PACK) { + return PFS_ERR_NEW_PACK; + } + if (pfs->activebank != PFS_ID_BANK_256K && (ret = __osPfsSelectBank(pfs, PFS_ID_BANK_256K)) != 0) { + return ret; + } + if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + fileNo, (u8*)&dir)) != 0) { + return ret; + } + if ((dir.company_code == 0) || (dir.game_code == 0)) { + return PFS_ERR_INVALID; + } + if (!CHECK_IPAGE(dir.start_page, *pfs)) { + if (dir.start_page.ipage == PFS_EOF) { + return PFS_ERR_INVALID; + } + return PFS_ERR_INCONSISTENT; + } + if ((flag == PFS_READ) && ((dir.status & PFS_WRITTEN) == 0)) { + return PFS_ERR_BAD_DATA; + } + + bank = 255; + curBlock = offset / BLOCKSIZE; + curPage = dir.start_page; + + while (curBlock >= 8) { + if ((ret = __osPfsGetNextPage(pfs, &bank, &inode, &curPage)) != 0) { + return ret; + } + curBlock -= 8; + } + + blockSize = size / BLOCKSIZE; + buffer = data; + + while (blockSize > 0) { + if (curBlock == 8) { + if ((ret = __osPfsGetNextPage(pfs, &bank, &inode, &curPage)) != 0) { + return ret; + } + curBlock = 0; + } + if (pfs->activebank != curPage.inode_t.bank && (ret = __osPfsSelectBank(pfs, curPage.inode_t.bank)) != 0) { + return ret; + } + + blockno = curPage.inode_t.page * PFS_ONE_PAGE + curBlock; + if (flag == PFS_READ) { + ret = __osContRamRead(pfs->queue, pfs->channel, blockno, buffer); + } else { + ret = __osContRamWrite(pfs->queue, pfs->channel, blockno, buffer, 0); + } + if (ret != 0) { + return ret; + } + + buffer += BLOCKSIZE; + curBlock++; + blockSize--; + } + + if (flag == PFS_WRITE && !(dir.status & PFS_WRITTEN)) { + dir.status |= PFS_WRITTEN; + if (pfs->activebank != PFS_ID_BANK_256K && (ret = __osPfsSelectBank(pfs, PFS_ID_BANK_256K)) != 0) { + return ret; + } + if ((ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + fileNo, (u8*)&dir, 0)) != 0) { + return ret; + } + } + + return __osPfsGetStatus(pfs->queue, pfs->channel); +} diff --git a/src/libultra/io/viswapcontext.c b/src/libultra/io/viswapcontext.c index 014fbbfeb7..514e3aa1df 100644 --- a/src/libultra/io/viswapcontext.c +++ b/src/libultra/io/viswapcontext.c @@ -1,3 +1,66 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/viswapcontext/__osViSwapContext.s") +void __osViSwapContext(void) { + register OSViMode* viMode; + register __OSViContext* viNext; + u32 origin; + u32 hStart; + u32 vstart; + u32 sp34; + u32 field; + register u32 s2; + + field = 0; + viNext = __osViNext; + viMode = viNext->modep; + field = HW_REG(VI_V_CURRENT_LINE_REG, u32) & 1; + s2 = osVirtualToPhysical(viNext->buffer); + origin = (viMode->fldRegs[field].origin) + s2; + if (viNext->state & 2) { + viNext->x.scale |= viMode->comRegs.xScale & ~0xFFF; + } else { + viNext->x.scale = viMode->comRegs.xScale; + } + if (viNext->state & 4) { + sp34 = (u32)(viMode->fldRegs[field].yScale & 0xFFF); + viNext->y.scale = viNext->y.factor * sp34; + viNext->y.scale |= viMode->fldRegs[field].yScale & ~0xFFF; + } else { + viNext->y.scale = viMode->fldRegs[field].yScale; + } + + vstart = (viMode->fldRegs[field].vStart - (__additional_scanline << 0x10)) + __additional_scanline; + hStart = viMode->comRegs.hStart; + + if (viNext->state & 0x20) { + hStart = 0; + } + + if (viNext->state & 0x40) { + viNext->y.scale = 0; + origin = osVirtualToPhysical(viNext->buffer); + } + + if (viNext->state & 0x80) { + viNext->y.scale = (viNext->y.offset << 0x10) & 0x3FF0000; + origin = osVirtualToPhysical(viNext->buffer); + } + + HW_REG(VI_ORIGIN_REG, u32) = origin; + HW_REG(VI_WIDTH_REG, u32) = viMode->comRegs.width; + HW_REG(VI_BURST_REG, u32) = viMode->comRegs.burst; + HW_REG(VI_V_SYNC_REG, u32) = viMode->comRegs.vSync; + HW_REG(VI_H_SYNC_REG, u32) = viMode->comRegs.hSync; + HW_REG(VI_LEAP_REG, u32) = viMode->comRegs.leap; + HW_REG(VI_H_START_REG, u32) = hStart; + HW_REG(VI_V_START_REG, u32) = vstart; + HW_REG(VI_V_BURST_REG, u32) = viMode->fldRegs[field].vBurst; + HW_REG(VI_INTR_REG, u32) = viMode->fldRegs[field].vIntr; + HW_REG(VI_X_SCALE_REG, u32) = viNext->x.scale; + HW_REG(VI_Y_SCALE_REG, u32) = viNext->y.scale; + HW_REG(VI_CONTROL_REG, u32) = viNext->features; + + __osViNext = __osViCurr; + __osViCurr = viNext; + *__osViNext = *__osViCurr; +} diff --git a/src/libultra/voice/voicegetstatus.c b/src/libultra/voice/voicegetstatus.c index 833f5ad272..d8e7edb671 100644 --- a/src/libultra/voice/voicegetstatus.c +++ b/src/libultra/voice/voicegetstatus.c @@ -12,7 +12,7 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { do { if (ret != CONT_ERR_CONTRFAIL) { - __osContPifRam.pifstatus = CONT_CMD_READ_BUTTON; + __osContPifRam.status = CONT_CMD_READ_BUTTON; for (i = 0; i < port; i++, *ptr++ = 0) { ; diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 42834bb57e..1045976983 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -77,7 +77,7 @@ void ArmsHook_Destroy(Actor* thisx, GlobalContext* globalCtx) { void ArmsHook_Wait(ArmsHook* this, GlobalContext* globalCtx) { if (this->actor.parent == NULL) { ArmsHook_SetupAction(this, ArmsHook_Shoot); - func_800B6C04(&this->actor, 20.0f); + Actor_SetSpeeds(&this->actor, 20.0f); this->actor.parent = &GET_PLAYER(globalCtx)->actor; this->timer = 26; } @@ -90,7 +90,7 @@ void func_808C1154(ArmsHook* this) { s32 ArmsHook_AttachToPlayer(ArmsHook* this, Player* player) { player->actor.child = &this->actor; - player->leftHandActor = &this->actor; + player->heldActor = &this->actor; if (this->actor.child != NULL) { player->actor.parent = this->actor.child = NULL; return 1; @@ -149,7 +149,7 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { } } this->timer = 0; - func_8019F1C0(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_STICK_CRE); + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_STICK_CRE); return; } @@ -237,7 +237,7 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { Vec3f prevFrameDiff; Vec3f sp60; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.prevPos, &prevFrameDiff); Math_Vec3f_Sum(&this->unk1E0, &prevFrameDiff, &this->unk1E0); this->actor.shape.rot.x = Math_FAtan2F(this->actor.speedXZ, -this->actor.velocity.y); @@ -265,10 +265,10 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { } } func_808C1154(this); - func_8019F1C0(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_STICK_OBJ); + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_STICK_OBJ); } else { CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &this->actor.world.pos); - func_8019F1C0(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_REFLECT); + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_REFLECT); } } else { if (CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index 14bfdce02e..2bea2f0ff5 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -162,7 +162,7 @@ void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx) { ArrowIce_LerpFiredPosition(&this->firedPos, &this->actor.world.pos, 0.05f); if (arrow->unk_261 & 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_EXPLOSION_ICE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_ICE); ArrowIce_SetupAction(this, ArrowIce_Hit); this->timer = 32; this->alpha = 255; diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c index 5b47f8e4ed..5ce8f18e96 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c @@ -123,7 +123,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { } } } - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WATERWHEEL_LEVEL); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WATERWHEEL_LEVEL); } } @@ -200,7 +200,7 @@ void BgCtowerGear_UpdateOrgan(Actor* thisx, GlobalContext* globalCtx) { // Using BgCtowerGear *this = THIS causes regalloc issues void BgCtowerGear_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_80AD32E8[BGCTOWERGEAR_GET_TYPE(thisx)]); + Gfx_DrawDListOpa(globalCtx, D_80AD32E8[BGCTOWERGEAR_GET_TYPE(thisx)]); } void BgCtowerGear_DrawOrgan(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c index 94868e0cd6..1686906238 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c @@ -67,7 +67,7 @@ void BgCtowerRot_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06017650); this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y - 0x4000; } - Actor_CalcOffsetOrientedToDrawRotation(&this->dyna.actor, &offset, &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); if (offset.z < 0.0f) { this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + (Math_SinS(this->dyna.actor.world.rot.y) * 80.0f); this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + (Math_CosS(this->dyna.actor.world.rot.y) * 80.0f); @@ -91,7 +91,7 @@ void BgCtowerRot_CorridorRotate(BgCtowerRot* this, GlobalContext* globalCtx) { f32 offsetDiffZ; f32 rotZtmp; - Actor_CalcOffsetOrientedToDrawRotation(&this->dyna.actor, &offset, &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); if (offset.z > 1100.0f) { rotZ = 0.0f; } else { @@ -114,7 +114,7 @@ void BgCtowerRot_DoorDoNothing(BgCtowerRot* this, GlobalContext* globalCtx) { void BgCtowerRot_DoorClose(BgCtowerRot* this, GlobalContext* globalCtx) { if (!Math_SmoothStepToF(&this->timer, 0.0f, 0.1f, 15.0f, 0.1f)) { if (this->dyna.actor.params == MAIN_DOOR) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); ActorCutscene_Stop(this->dyna.actor.cutscene); } this->actionFunc = BgCtowerRot_DoorDoNothing; @@ -131,7 +131,7 @@ void BgCtowerRot_DoorIdle(BgCtowerRot* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f offset; - Actor_CalcOffsetOrientedToDrawRotation(&this->dyna.actor, &offset, &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); if (offset.z > 30.0f) { this->unk160 = 0.0f; ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); @@ -159,8 +159,8 @@ void BgCtowerRot_Update(Actor* thisx, GlobalContext* globalCtx) { void BgCtowerRot_Draw(Actor* thisx, GlobalContext* globalCtx) { BgCtowerRot* this = THIS; - func_800BDFC0(globalCtx, bgCtowerRotDlists[this->dyna.actor.params]); + Gfx_DrawDListOpa(globalCtx, bgCtowerRotDlists[this->dyna.actor.params]); if (this->dyna.actor.params == CORRIDOR) { - func_800BE03C(globalCtx, D_060129D0); + Gfx_DrawDListXlu(globalCtx, D_060129D0); } } diff --git a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c index e32492e9c0..e75367f602 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 @@ -78,7 +78,7 @@ void func_80B40160(BgGoronOyu* this, GlobalContext* globalCtx) { func_80B40080(this); } - func_8019F1C0(&D_80B40780, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); + Audio_PlaySfxAtPos(&D_80B40780, NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); } void func_80B401F8(BgGoronOyu* this, GlobalContext* globalCtx) { @@ -95,8 +95,8 @@ void func_80B401F8(BgGoronOyu* this, GlobalContext* globalCtx) { if (dist.x >= 0.0f && dist.x <= this->waterBoxXLength && dist.z >= 0.0f && dist.z <= this->waterBoxZLength && fabsf(dist.y) < 100.0f && player->actor.depthInWater > 12.0f) { - func_800B8A1C(&this->dyna.actor, globalCtx, 0xBA, this->dyna.actor.xzDistToPlayer, - fabsf(this->dyna.actor.playerHeightRel)); + Actor_PickUp(&this->dyna.actor, globalCtx, 0xBA, this->dyna.actor.xzDistToPlayer, + fabsf(this->dyna.actor.playerHeightRel)); } } @@ -133,7 +133,7 @@ void BgGoronOyu_SpawnParticles(BgGoronOyu* this, GlobalContext* globalCtx) { if (BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &poly, &pos1) < this->waterBoxPos.y) { pos1.y = this->waterBoxPos.y + 10.0f; - EffectSsIceSmoke_Spawn(globalCtx, &pos1, &vel1, &D_801D15B0, scale); + EffectSsIceSmoke_Spawn(globalCtx, &pos1, &vel1, &gZeroVec3f, scale); } pos2.x = (Rand_ZeroOne() * this->waterBoxXLength) + this->waterBoxPos.x; pos2.y = this->waterBoxPos.y + 100.0f; @@ -145,7 +145,7 @@ void BgGoronOyu_SpawnParticles(BgGoronOyu* this, GlobalContext* globalCtx) { if (BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &poly, &pos2) < this->waterBoxPos.y) { pos2.y = this->waterBoxPos.y + 10.0f; - EffectSsIceSmoke_Spawn(globalCtx, &pos2, &vel2, &D_801D15B0, scale); + EffectSsIceSmoke_Spawn(globalCtx, &pos2, &vel2, &gZeroVec3f, scale); } } } diff --git a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c index fceb27755e..87686f4c8e 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c +++ b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c @@ -53,7 +53,7 @@ void BgHakaCurtain_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06001588); - if (Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { + if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { func_80B6DE80(this); return; } @@ -71,7 +71,7 @@ void func_80B6DC98(BgHakaCurtain* this) { } void func_80B6DCAC(BgHakaCurtain* this, GlobalContext* globalCtx) { - if (Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { + if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { func_80B6DCEC(this); } } @@ -137,5 +137,5 @@ void BgHakaCurtain_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgHakaCurtain_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06001410); + Gfx_DrawDListOpa(globalCtx, D_06001410); } diff --git a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c index 58ccf1cd91..a36055a3dc 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c +++ b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c @@ -84,11 +84,10 @@ s32 func_80BD6638(s16* arg0, s16* arg1, s32 arg2) { void func_80BD66AC(BgHakaTomb* this, GlobalContext* globalCtx) { s16 temp; - if (Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { + if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { this->dyna.actor.flags |= 9; } - if (!func_80BD6638(&temp, this->cutscenes, 1) && (temp < 0) && - Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { + if (!func_80BD6638(&temp, this->cutscenes, 1) && (temp < 0) && Flags_GetClear(globalCtx, this->dyna.actor.room)) { this->dyna.actor.flags |= 1; if (this->dyna.actor.isTargeted) { func_80BD6754(this); @@ -129,5 +128,5 @@ void BgHakaTomb_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgHakaTomb_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_060007B0); + Gfx_DrawDListOpa(globalCtx, D_060007B0); } diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 77a0cb2eea..0a3ef22ebc 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -187,7 +187,7 @@ void func_80A9B160(BgHakuginPostUnkStruct* unkStruct, GlobalContext* globalCtx) unkStruct->unk_0000[i].unk_24 = 0.0f; unkStruct->unk_0000[i].unk_34 = 1; if (D_80A9D880[unkStruct->unk_0000[i].unk_00].unk_04 != 0) { - Actor_UnsetSwitchFlag(globalCtx, unkStruct->unk_0000[i].unk_2E); + Flags_UnsetSwitch(globalCtx, unkStruct->unk_0000[i].unk_2E); } } } @@ -261,7 +261,7 @@ void func_80A9B3BC(BgHakuginPost* this, GlobalContext* globalCtx) { } if (!(sp20 | sp1C)) { - Actor_SetSwitchFlag(globalCtx, sp28); + Flags_SetSwitch(globalCtx, sp28); this->unk_170 = true; } else { this->unk_170 = sp20; @@ -290,9 +290,9 @@ void func_80A9B46C(BgHakuginPost* this, GlobalContext* globalCtx) { } if (!this->unk_170 && (sp28 == 1)) { - Actor_UnsetSwitchFlag(globalCtx, sp2C); + Flags_UnsetSwitch(globalCtx, sp2C); } else if (!this->unk_174 && (sp24 == 1)) { - Actor_UnsetSwitchFlag(globalCtx, sp30); + Flags_UnsetSwitch(globalCtx, sp30); } this->unk_170 = sp28; @@ -362,7 +362,7 @@ void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU spA0.x = Math_SinS(val) * temp_f20 + spB8.x; spA0.y = (Rand_ZeroOne() * 1.2f - 0.1f) * spE4 + spB8.y; spA0.z = Math_CosS(val) * temp_f20 + spB8.z; - func_800B0E48(globalCtx, &spA0, &D_801D15B0, &D_80A9D8EC, &D_80A9D8E4, &D_80A9D8E8, + func_800B0E48(globalCtx, &spA0, &gZeroVec3f, &D_80A9D8EC, &D_80A9D8E4, &D_80A9D8E8, (Rand_Next() >> 0x1A) + 0x82, (Rand_Next() >> 0x1A) + 0x6E); } @@ -682,9 +682,9 @@ void func_80A9C854(BgHakuginPost* this, GlobalContext* globalCtx) { } if (sp38) { - Actor_SetSwitchFlag(globalCtx, this->dyna.actor.home.rot.x & 0x7F); + Flags_SetSwitch(globalCtx, this->dyna.actor.home.rot.x & 0x7F); } else { - Actor_UnsetSwitchFlag(globalCtx, this->dyna.actor.home.rot.x & 0x7F); + Flags_UnsetSwitch(globalCtx, this->dyna.actor.home.rot.x & 0x7F); } } @@ -840,9 +840,9 @@ void func_80A9CE1C(BgHakuginPost* this, GlobalContext* globalCtx) { temp = (s16)(this->dyna.actor.yawTowardsPlayer + 0x58F0); D_80A9E028.unk_0000[i].unk_28 = ((s16)(player->actor.shape.rot.y - temp) / 3) + temp; D_80A9E028.unk_0000[i].unk_34 = 2; - func_800B8E58(&player->actor, NA_SE_IT_HAMMER_HIT); + func_800B8E58(player, NA_SE_IT_HAMMER_HIT); func_8019F128(NA_SE_EV_SLIDE_DOOR_OPEN); - Actor_SetSwitchFlag(globalCtx, D_80A9E028.unk_0000[i].unk_2E); + Flags_SetSwitch(globalCtx, D_80A9E028.unk_0000[i].unk_2E); this->unk_178 = 20; func_80A9D2C4(this, func_80A9CE00, D_80A9E028.unk_0000[i].unk_14.y + 50.0f, D_80A9E028.unk_0000[i].unk_2A, D_80A9E028.unk_0000[i].unk_2C); diff --git a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c index 653e125044..d497492f33 100644 --- a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c +++ b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c @@ -56,7 +56,7 @@ const ActorInit Bg_Icicle_InitVars = { static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), ICHAIN_F32(gravity, -3, ICHAIN_CONTINUE), - ICHAIN_F32(minVelocityY, -30, ICHAIN_CONTINUE), + ICHAIN_F32(terminalVelocity, -30, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; @@ -107,7 +107,7 @@ void BgIcicle_Break(BgIcicle* this, GlobalContext* globalCtx, f32 arg2) { s32 j; s32 i; - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < 2; i++) { for (j = 0; j < 10; j++) { @@ -144,7 +144,7 @@ void BgIcicle_Shiver(BgIcicle* this, GlobalContext* globalCtx) { } if (!(this->shiverTimer % 4)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ICE_SWING); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_ICE_SWING); } if (this->shiverTimer == 0) { @@ -184,7 +184,7 @@ void BgIcicle_Fall(BgIcicle* this, GlobalContext* globalCtx) { return; } } else { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->dyna.actor); + Actor_MoveWithGravity(&this->dyna.actor); this->dyna.actor.world.pos.y += 40.0f; Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); this->dyna.actor.world.pos.y -= 40.0f; @@ -245,5 +245,5 @@ void BgIcicle_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgIcicle_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_060000D0); + Gfx_DrawDListOpa(globalCtx, D_060000D0); } diff --git a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c index bc3ee78805..e96c20accb 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c @@ -119,5 +119,5 @@ void BgIkanaRay_Draw(Actor* thisx, GlobalContext* globalCtx) { BgIkanaRay* this = THIS; AnimatedMat_Draw(globalCtx, this->animatedTextures); - func_800BE03C(globalCtx, D_06001100); + Gfx_DrawDListXlu(globalCtx, D_06001100); } diff --git a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c index 503c09048a..70b58b4828 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c @@ -77,7 +77,7 @@ void BgIkanaShutter_Init(Actor* thisx, GlobalContext* globalCtx) { func_80BD5828(this); return; } - if (Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { + if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { BgIkanaShutter_SetupDoNothing(this); return; } @@ -166,7 +166,7 @@ void func_80BD5AE8(BgIkanaShutter* this) { } void func_80BD5B04(BgIkanaShutter* this, GlobalContext* globalCtx) { - if (Actor_GetRoomClearedTemp(globalCtx, this->dyna.actor.room)) { + if (Flags_GetClearTemp(globalCtx, this->dyna.actor.room)) { func_80BD5B44(this); } } @@ -179,7 +179,7 @@ void func_80BD5B44(BgIkanaShutter* this) { void func_80BD5B60(BgIkanaShutter* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - Actor_SetRoomCleared(globalCtx, this->dyna.actor.room); + Flags_SetClear(globalCtx, this->dyna.actor.room); func_80BD5BC4(this); return; } @@ -213,5 +213,5 @@ void BgIkanaShutter_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgIkanaShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000CE8); + Gfx_DrawDListOpa(globalCtx, D_06000CE8); } diff --git a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c index 10454f2cb1..f4dca549b3 100644 --- a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c +++ b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c @@ -57,7 +57,7 @@ s32 func_80C0A740(BgIkninSusceil* this, GlobalContext* globalCtx) { Vec3f offset; Player* player = GET_PLAYER(globalCtx); - Actor_CalcOffsetOrientedToDrawRotation(&this->dyna.actor, &offset, &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); return (D_80C0B0E8.x < offset.z) && (offset.z < D_80C0B0E8.y) && (offset.x > -240.0f) && (offset.x < D_80C0B0E4); } @@ -94,7 +94,7 @@ s32 func_80C0A95C(BgIkninSusceil* this, GlobalContext* globalCtx) { Vec3f offset; f32 temp1, temp2, temp3, temp4; - Actor_CalcOffsetOrientedToDrawRotation(&this->dyna.actor, &offset, &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); for (i = 0; i < 7; i++) { temp3 = (D_80C0B0F0[i] * 80.0f) + 0.5f; temp4 = (D_80C0B0F0[i] * 80.0f) + 79.5f; @@ -155,8 +155,8 @@ void func_80C0ABA8(BgIkninSusceil* this, GlobalContext* globalCtx) { this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; if (this->dyna.actor.world.pos.y <= this->dyna.actor.home.pos.y) { func_80C0A86C(this, globalCtx, 4, 14, 1); - Actor_UnsetSwitchFlag(globalCtx, GET_SUSCEIL_SWITCHFLAG(this)); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND); + Flags_UnsetSwitch(globalCtx, GET_SUSCEIL_SWITCHFLAG(this)); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND); func_80C0AC74(this); } else { func_800B9010(&this->dyna.actor, NA_SE_EV_ICE_PILLAR_FALL - SFX_FLAG); @@ -229,7 +229,7 @@ void BgIkninSusceil_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->unk168 == 0) && (this->unk166 > 0) && (player->stateFlags3 & 0x100) && (player->unk_B48 > 1000.0f)) { this->unk168 = 2; if ((func_80C0A95C(this, globalCtx) != 0) && (this->actionFunc != func_80C0AE5C)) { - func_800B8E58(&player->actor, NA_SE_PL_BODY_HIT); + func_800B8E58(player, NA_SE_PL_BODY_HIT); func_80C0AE3C(this); } } @@ -260,5 +260,5 @@ void BgIkninSusceil_Draw(Actor* thisx, GlobalContext* globalCtx) { BgIkninSusceil* this = THIS; AnimatedMat_Draw(globalCtx, this->animatedTexture); - func_800BDFC0(globalCtx, D_0600C308); + Gfx_DrawDListOpa(globalCtx, D_0600C308); } diff --git a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c index 3bf7bf9889..53a0b5ea29 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c @@ -90,7 +90,7 @@ void BgIknvObj_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; gSaveContext.weekEventReg[51] &= (u8)~0x10; - Actor_SetHeight(&this->dyna.actor, IREG(88)); + Actor_SetFocus(&this->dyna.actor, IREG(88)); break; default: Actor_MarkForDeath(&this->dyna.actor); @@ -154,7 +154,7 @@ s32 func_80BD7E0C(BgIknvObj* this, s16 targetRotation, GlobalContext* globalCtx) func_800B9010(&this->dyna.actor, NA_SE_EV_STONEDOOR_OPEN_S - SFX_FLAG); return false; } - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); return true; } diff --git a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c index 817cda67ed..61e6845631 100644 --- a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c +++ b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c @@ -14,7 +14,6 @@ void BgInibsMovebg_Init(Actor* thisx, GlobalContext* globalCtx); void BgInibsMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgInibsMovebg_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Inibs_Movebg_InitVars = { ACTOR_BG_INIBS_MOVEBG, ACTORCAT_BG, @@ -27,17 +26,56 @@ const ActorInit Bg_Inibs_Movebg_InitVars = { (ActorFunc)BgInibsMovebg_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B96578[] = { +extern Gfx D_06001C10[]; +extern Gfx D_06001DC0[]; +extern AnimatedMaterial D_06002598; +extern Gfx D_06006140[]; +extern Gfx D_060062D8[]; +extern AnimatedMaterial D_06006858; +Gfx* D_80B96560[] = { D_060062D8, D_06001DC0 }; +Gfx* D_80B96568[] = { D_06006140, D_06001C10 }; +AnimatedMaterial* D_80B96570[] = { &D_06006858, &D_06002598 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; -#endif +void BgInibsMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { + BgInibsMovebg* this = THIS; -extern InitChainEntry D_80B96578[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Inibs_Movebg/BgInibsMovebg_Init.s") + this->unk_15C = D_80B96560[BGINIBSMOVEBG_GET_F(thisx)]; + this->unk_160 = D_80B96568[BGINIBSMOVEBG_GET_F(thisx)]; + this->unk_164 = D_80B96570[BGINIBSMOVEBG_GET_F(thisx)]; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Inibs_Movebg/BgInibsMovebg_Destroy.s") +void BgInibsMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgInibsMovebg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Inibs_Movebg/BgInibsMovebg_Draw.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void BgInibsMovebg_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgInibsMovebg* this = THIS; + + AnimatedMaterial* animMat; + Gfx* dl1; + Gfx* dl2; + + animMat = this->unk_164; + if (animMat != NULL) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(this->unk_164)); + } + + dl1 = this->unk_15C; + if (dl1 != NULL) { + Gfx_DrawDListOpa(globalCtx, this->unk_15C); + } + + dl2 = this->unk_160; + if (dl2 != NULL) { + Gfx_DrawDListXlu(globalCtx, this->unk_160); + } +} diff --git a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.h b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.h index fea6c8a67e..92494a35f9 100644 --- a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.h +++ b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.h @@ -5,9 +5,13 @@ struct BgInibsMovebg; +#define BGINIBSMOVEBG_GET_F(thisx) ((u16)((thisx)->params) & 0xF) + typedef struct BgInibsMovebg { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x24]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ Gfx* unk_15C; + /* 0x160 */ Gfx* unk_160; + /* 0x164 */ AnimatedMaterial* unk_164; } BgInibsMovebg; // size = 0x168 extern const ActorInit Bg_Inibs_Movebg_InitVars; 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 cc92791fcc..d526c458ba 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c @@ -149,7 +149,7 @@ void BgKin2Fence_SpawnEyeSparkles(BgKin2Fence* this, GlobalContext* globalCtx, s for (i = 0; i < 2; i++) { Matrix_MultiplyVector3fByState(&eyeSparkleSpawnPositions[mask][i], &sp58); - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp58, &D_801D15B0, &D_801D15B0, &primColor, &envColor, 6000, -10); + EffectSsKiraKira_SpawnDispersed(globalCtx, &sp58, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 6000, -10); } } @@ -228,7 +228,7 @@ void BgKin2Fence_SetupPlayOpenCutscene(BgKin2Fence* this) { void BgKin2Fence_PlayOpenCutscene(BgKin2Fence* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - Actor_SetSwitchFlag(globalCtx, this->dyna.actor.params & 0x7F); + Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x7F); BgKin2Fence_SetupWaitBeforeOpen(this); return; } @@ -272,5 +272,5 @@ void BgKin2Fence_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgKin2Fence_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000828); + Gfx_DrawDListOpa(globalCtx, D_06000828); } diff --git a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c index c646c3e6cb..e9326d8cd7 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c @@ -55,7 +55,7 @@ static ColliderTrisInit D_80B6FA08 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_80B6FA24[] = { ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), diff --git a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c index 0acccbc56a..070d8776b2 100644 --- a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c +++ b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c @@ -110,7 +110,7 @@ void BgLadder_ActionStartCutscene(BgLadder* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); this->dyna.actor.draw = BgLadder_Draw; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_SECRET_LADDER_APPEAR); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SECRET_LADDER_APPEAR); this->action = BgLadder_ActionFadeIn; } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); diff --git a/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c b/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c index c07f419f9e..11132cf64e 100644 --- a/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c +++ b/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c @@ -47,5 +47,5 @@ void BgLbfshot_Destroy(Actor* thisx, GlobalContext* globalCtx) { DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void BgLbfshot_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000228); + Gfx_DrawDListOpa(globalCtx, D_06000228); } diff --git a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c index 7499e35cde..e8a2d0b4cc 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -173,5 +173,5 @@ void BgLotus_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgLotus_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000040); + Gfx_DrawDListOpa(globalCtx, D_06000040); } diff --git a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c index b5f8e9c49c..e9a365c91d 100644 --- a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c +++ b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c @@ -41,6 +41,6 @@ void BgMarketStep_Init(Actor* thisx, GlobalContext* globalCtx) { void BgMarketStep_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 index = thisx->params & 1; - func_800BDFC0(globalCtx, D_80AF0120[index]); - func_800BDFC0(globalCtx, D_80AF0128[index]); + Gfx_DrawDListOpa(globalCtx, D_80AF0120[index]); + Gfx_DrawDListOpa(globalCtx, D_80AF0128[index]); } diff --git a/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c b/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c index c805de05c9..8a31c536bc 100644 --- a/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c +++ b/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c @@ -55,5 +55,5 @@ void BgMbarChair_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgMbarChair_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000288); + Gfx_DrawDListOpa(globalCtx, D_06000288); } diff --git a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c index 69ba3e6529..38ce543ccf 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c @@ -65,7 +65,7 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { if (this->timer != prevTimer) { if (1) {} - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONEDOOR_OPEN_S - SFX_FLAG); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_OPEN_S - SFX_FLAG); this->dyna.actor.world.pos.y = (this->yOffset = (this->timer * (5.0f / 3.0f)) + this->dyna.actor.home.pos.y); this->timer2 = 180; } diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 03c1733153..f60141c5d8 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -555,8 +555,8 @@ void func_809DA460(Boss02Effects* effects, Vec3f* vec) { if ((effects->unk_24 == 0) || (effects->unk_24 == 3)) { effects->unk_24 = 4; effects->unk_00 = *vec; - Math_Vec3f_Copy(&effects->unk_0C, &D_801D15B0); - Math_Vec3f_Copy(&effects->unk_18, &D_801D15B0); + Math_Vec3f_Copy(&effects->unk_0C, &gZeroVec3f); + Math_Vec3f_Copy(&effects->unk_18, &gZeroVec3f); effects->unk_2C = 0xFF; effects->unk_34 = 0.0f; break; @@ -740,8 +740,8 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->actor.speedXZ = this->unk_01A8 * D_809DF5B0; } - Actor_SetVelocityXYRotation(&this->actor); - Actor_ApplyMovement(&this->actor); + Actor_UpdateVelocityWithoutGravity(&this->actor); + Actor_UpdatePos(&this->actor); spD0 = this->actor.world.pos; if (D_809E0422 != 0) { @@ -756,7 +756,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_0170 = this->unk_017C; this->unk_0170.y = temp_f0; this->unk_016C = 120; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); } this->actor.flags &= ~1; @@ -965,7 +965,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { D_809E042C->unk_1D5C = 0.0f; play_sound(NA_SE_EN_INBOSS_DEAD_PRE2_OLD); } else if (!(this->unk_0146[1] & 0xF) && (Rand_ZeroOne() < 0.5f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); } return; @@ -987,7 +987,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_0144 = 22; this->actor.gravity = -1.0f * D_809DF5B0; this->actor.velocity.y = 0.0f; - this->actor.minVelocityY = -1000.0f * D_809DF5B0; + this->actor.terminalVelocity = -1000.0f * D_809DF5B0; this->unk_0164 = randPlusMinusPoint5Scaled(0.05f); spCC = player->actor.world.pos.x - this->actor.world.pos.x; @@ -1006,7 +1006,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD); } } return; @@ -1017,7 +1017,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&this->unk_01BC[i], &this->actor.world.pos); this->unk_0B1C[i].y += this->unk_0164; Math_ApproachF(&this->unk_0B1C[i].x, -(M_PI / 2), 0.1f, 0.07f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 4); if (this->actor.bgCheckFlags & 1) { @@ -1100,10 +1100,10 @@ void func_809DBFB4(Boss02* this, GlobalContext* globalCtx) { this->unk_0156 = 15; if (i == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); this->unk_015C = 1; } else { - func_8019F1C0(&this->unk_167C, NA_SE_EN_INBOSS_DAMAGE_OLD); + Audio_PlaySfxAtPos(&this->unk_167C, NA_SE_EN_INBOSS_DAMAGE_OLD); this->unk_015C = 10; } @@ -1227,9 +1227,9 @@ void Boss02_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_016C != 0) { if ((this->unk_016C == 60) && (this->unk_0144 < 20)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_SAND_OLD - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_SAND_OLD - SFX_FLAG); if (this->unk_0144 > 20) { sp3C.x = randPlusMinusPoint5Scaled(100.0f * D_809DF5B0) + this->unk_0170.x; @@ -1820,7 +1820,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { if (D_809E0434 != NULL) { D_809E0434->unk_203 = 0; D_809E0434->unk_204 = 1.0f; - D_809E0434->actor.world.pos.y = 60.0f; + D_809E0434->dyna.actor.world.pos.y = 60.0f; } player->actor.world.pos.x *= 10.0f; @@ -1892,7 +1892,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { if (D_809E0434 != 0) { D_809E0434->unk_203 = 1; D_809E0434->unk_204 = 0.1f; - D_809E0434->actor.world.pos.y = 3155.0f; + D_809E0434->dyna.actor.world.pos.y = 3155.0f; } player->actor.world.pos.x *= 0.1f; @@ -1959,7 +1959,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { player->actor.home.pos = player->actor.world.pos; player->actor.prevPos = player->actor.world.pos; - temp_a0_5 = globalCtx->actorCtx.actorList[ACTORCAT_BG].first; + temp_a0_5 = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; while (temp_a0_5 != NULL) { if (temp_a0_5->id == ACTOR_BG_INIBS_MOVEBG) { Actor_MarkForDeath(temp_a0_5); @@ -1971,7 +1971,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_INIBS_MOVEBG, 0, D_809E0422 ? 3150.0f : 0.0f, 0, 0, 0, 0, D_809E0422); - temp_a0_5 = globalCtx->actorCtx.actorList[ACTORCAT_BOSS].first; + temp_a0_5 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; while (temp_a0_5 != NULL) { if ((temp_a0_5->id == ACTOR_EN_TANRON5) || (temp_a0_5->id == ACTOR_ITEM_B_HEART)) { if (D_809E0422 == 0) { @@ -2002,7 +2002,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { temp_a0_5->velocity.z *= phi_f0_2; temp_a0_5->gravity *= phi_f0_2; - temp_a0_5->minVelocityY *= phi_f0_2; + temp_a0_5->terminalVelocity *= phi_f0_2; temp_a0_5->scale.x *= phi_f0_2; temp_a0_5->scale.y *= phi_f0_2; @@ -2109,11 +2109,11 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { player->actor.shape.rot.y = -0x8000; player->actor.world.rot.y = player->actor.shape.rot.y; this->unk_1D24.x = player->actor.world.pos.x - 20.0f; - this->unk_1D24.y = (func_800B6FC8(player) + player->actor.world.pos.y) - 29.0f; + this->unk_1D24.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 29.0f; this->unk_1D24.z = player->actor.world.pos.z - 50; this->unk_1D30.x = player->actor.world.pos.x; - this->unk_1D30.y = (func_800B6FC8(player) + player->actor.world.pos.y) - 17.0f; + this->unk_1D30.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 17.0f; this->unk_1D30.z = player->actor.world.pos.z; if (this->unk_1D1C >= 30) { if (this->unk_1D1C == 30) { @@ -2177,8 +2177,8 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { } if (this->unk_1D1C == (u32)(KREG(92) + 125)) { - Actor_TitleCardCreate(globalCtx, &globalCtx->actorCtx.titleCtxt, Lib_SegmentedToVirtual(&D_06008650), - 160, 180, 128, 40); + TitleCard_InitBossName(&globalCtx->state, &globalCtx->actorCtx.titleCtxt, + Lib_SegmentedToVirtual(&D_06008650), 160, 180, 128, 40); } if (this->unk_1D1C == (u32)(BREG(27) + 335)) { diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.c b/src/overlays/actors/ovl_Boss_04/z_boss_04.c index 3e3ca12c17..67ea1702e6 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -5,6 +5,7 @@ */ #include "z_boss_04.h" +#include "objects/object_boss04/object_boss04.h" #define FLAGS 0x00000035 @@ -15,14 +16,18 @@ void Boss04_Destroy(Actor* thisx, GlobalContext* globalCtx); void Boss04_Update(Actor* thisx, GlobalContext* globalCtx); void Boss04_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809EC544(Boss04* this); void func_809EC568(Boss04* this, GlobalContext* globalCtx); +void func_809ECD00(Boss04* this, GlobalContext* globalCtx); void func_809ECD18(Boss04* this, GlobalContext* globalCtx); +void func_809ECEF4(Boss04* this); void func_809ECF58(Boss04* this, GlobalContext* globalCtx); +void func_809ED224(Boss04* this); void func_809ED2A0(Boss04* this, GlobalContext* globalCtx); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_809EE150 = { +static u8 D_809EE4D0; + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0xF), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -69,75 +74,777 @@ const ActorInit Boss_04_InitVars = { (ActorFunc)Boss04_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_809EE190[1] = { +static ColliderJntSphElementInit sJntSphElementsInit1[1] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809EE1B4 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809EE190, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit1 = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit1, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_809EE1C4[1] = { +static ColliderJntSphElementInit sJntSphElementsInit2[1] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 70 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809EE1E8 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809EE1C4, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit2 = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit2, }; -#endif +void func_809EC040(s32 index, ColliderJntSph* collider, Vec3f* arg2) { + collider->elements[index].dim.worldSphere.center.x = arg2->x; + collider->elements[index].dim.worldSphere.center.y = arg2->y; + collider->elements[index].dim.worldSphere.center.z = arg2->z; + collider->elements[index].dim.worldSphere.radius = + collider->elements[index].dim.modelSphere.radius * collider->elements[index].dim.scale; +} -extern DamageTable D_809EE150; -extern ColliderJntSphElementInit D_809EE190[1]; -extern ColliderJntSphInit D_809EE1B4; -extern ColliderJntSphElementInit D_809EE1C4[1]; -extern ColliderJntSphInit D_809EE1E8; +void Boss04_Init(Actor* thisx, GlobalContext* globalCtx2) { + static Vec3f D_809EE1F8[] = { + { -1000.0f, 0.0f, 0.0f }, + { 1000.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, -1000.0f }, + { 0.0f, 0.0f, 1000.0f }, + }; + GlobalContext* globalCtx = globalCtx2; + Boss04* this = THIS; + s32 i; + CollisionPoly* spC0; + Vec3f spB4; + Vec3f spA8; + s32 spA4; + f32 phi_f20; + f32 phi_f24; + Vec3f sp90; + s16 phi_s0_2; + s32 pad; -extern UNK_TYPE D_0600004C; -extern UNK_TYPE D_06004510; + if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809EC040.s") + this->actor.params = 0x64; + Actor_SetScale(&this->actor, 0.1f); + this->actor.targetMode = 5; + this->actor.hintId = 0x19; + this->actor.colChkInfo.health = 20; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->unk_700 = 1.0f; + this->unk_6FC = 1.0f; + this->unk_6F8 = 1.0f; + Collider_InitAndSetJntSph(globalCtx, &this->collider1, &this->actor, &sJntSphInit1, this->collider1Elements); + Collider_InitAndSetJntSph(globalCtx, &this->collider2, &this->actor, &sJntSphInit2, this->collider2Elements); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_boss04_Skel_0045E8, &object_boss04_Anim_00004C, + this->jointTable, this->morphtable, 9); + spA8.y = this->actor.world.pos.y + 200.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/Boss04_Init.s") + for (i = 0; i < ARRAY_COUNT(D_809EE1F8); i++) { + spA8.x = D_809EE1F8[i].x + this->actor.world.pos.x; + spA8.z = D_809EE1F8[i].z + this->actor.world.pos.z; + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &spA8, &spB4, &spC0, 1, 0, 0, 1, + &spA4)) { + if (i == 0) { + this->unk_6D8 = spB4.x; + } else if (i == 1) { + this->unk_6DC = spB4.x; + } else if (i == 2) { + this->unk_6E0 = spB4.z; + } else if (i == 3) { + this->unk_6E4 = spB4.z; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/Boss04_Destroy.s") + this->unk_6E8 = this->unk_6D8 + ((this->unk_6DC - this->unk_6D8) * 0.5f); + this->unk_6F0 = this->unk_6E0 + ((this->unk_6E4 - this->unk_6E0) * 0.5f); + this->actor.world.pos.x = this->unk_6E8; + this->actor.world.pos.z = this->unk_6F0; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 60.0f, 60.0f, 4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809EC544.s") + if ((KREG(64) != 0) || (gSaveContext.eventInf[6] & 1)) { + func_809ECD00(this, globalCtx); + this->actor.world.pos.y = this->actor.floorHeight + 160.0f; + phi_f24 = this->actor.floorHeight; + D_809EE4D0 = KREG(41) + 50; + } else { + func_809EC544(this); + this->actor.world.pos.y = KREG(70) + (this->actor.floorHeight + 590.0f); + phi_f24 = KREG(71) + (this->actor.floorHeight + 550.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809EC568.s") + phi_f20 = 110.0f; + this->unk_6F6 = 82; + phi_s0_2 = 0; + for (i = 0; i < 82; i++) { + Matrix_RotateY(phi_s0_2, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(phi_f20, &sp90); + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON2, this->unk_6E8 + sp90.x, + phi_f24, this->unk_6F0 + sp90.z, 0, 0, 0, i); + phi_f20 += 2.5f; + phi_s0_2 += 0x1300; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ECD00.s") + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON2, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 100); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ECD18.s") +void Boss04_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ECEF4.s") +void func_809EC544(Boss04* this) { + this->actionFunc = func_809EC568; + this->actor.flags &= ~1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ECF58.s") +void func_809EC568(Boss04* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 x; + f32 y; + f32 z; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ED224.s") + this->unk_704++; + this->unk_1FE = 15; + if ((this->unk_708 != 0) && (this->unk_708 < 10)) { + this->actor.world.pos.y = (Math_SinS(this->unk_1F4 * 512) * 10.0f) + (this->actor.floorHeight + 160.0f); + Matrix_RotateY(this->actor.yawTowardsPlayer, MTXMODE_NEW); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ED2A0.s") + switch (this->unk_708) { + case 0: + this->unk_2C8 = 50; + this->unk_2D0 = 2000.0f; + if ((player->stateFlags1 & 0x100000) && (this->actor.projectedPos.z > 0.0f) && + (fabsf(this->actor.projectedPos.x) < 300.0f) && (fabsf(this->actor.projectedPos.y) < 300.0f)) { + if ((this->unk_704 >= 15) && (ActorCutscene_GetCurrentIndex() == -1)) { + Actor* boss; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ED45C.s") + this->unk_708 = 10; + this->unk_704 = 0; + func_800EA0D4(globalCtx, &globalCtx->csCtx); + this->unk_70A = func_801694DC(globalCtx); + func_80169590(globalCtx, 0, 1); + func_80169590(globalCtx, this->unk_70A, 7); + func_800B7298(globalCtx, &this->actor, 7); + player->actor.world.pos.x = this->unk_6E8; + player->actor.world.pos.z = this->unk_6F0 + 410.0f; + player->actor.shape.rot.y = 0x7FFF; + player->actor.world.rot.y = player->actor.shape.rot.y; + Math_Vec3f_Copy(&this->unk_70C, &player->actor.world.pos); + this->unk_70C.y += 100.0f; + Math_Vec3f_Copy(&this->unk_718, &this->actor.world.pos); + func_8016566C(150); + this->unk_744 = 60.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ED50C.s") + boss = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + while (boss != NULL) { + if (boss->id == ACTOR_EN_WATER_EFFECT) { + Actor_MarkForDeath(boss); + } + boss = boss->next; + } + } + } else { + this->unk_704 = 0; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/Boss04_Update.s") + case 10: + if (this->unk_704 == 3) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEMO_EYE); + this->unk_74A = 1; + } + this->unk_2D0 = 10000.0f; + this->unk_2C8 = 300; + Math_ApproachF(&this->unk_744, 20.0f, 0.3f, 11.0f); + if (this->unk_704 == 40) { + this->unk_708 = 11; + this->unk_704 = 0; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809EDCCC.s") + case 11: + if (this->unk_704 > 50) { + this->unk_708 = 12; + this->unk_704 = 0; + this->actor.gravity = -3.0f; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809EDECC.s") + case 13: + if (this->unk_704 == 45) { + this->unk_708 = 1; + this->unk_704 = 0; + func_800B7298(globalCtx, &this->actor, 0x15); + this->actor.gravity = 0.0f; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/Boss04_Draw.s") + case 12: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_ATTACK - SFX_FLAG); + Math_ApproachF(&this->unk_718.x, this->actor.world.pos.x, 0.5f, 1000.0f); + Math_ApproachF(&this->unk_718.y, this->actor.world.pos.y, 0.5f, 1000.0f); + Math_ApproachF(&this->unk_718.z, this->actor.world.pos.z, 0.5f, 1000.0f); + if (this->actor.bgCheckFlags & 2) { + play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); + this->unk_6F4 = 15; + this->unk_708 = 13; + this->unk_704 = 0; + this->unk_2DA = 10; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_SPLASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); + this->unk_748 = 20; + } + break; + + case 1: + player->actor.shape.rot.y = 0x7FFF; + player->actor.world.rot.y = player->actor.shape.rot.y; + Matrix_GetStateTranslationAndScaledZ(-100.0f, &this->unk_70C); + + this->unk_70C.x += player->actor.world.pos.x; + this->unk_70C.y = Player_GetHeight(player) + player->actor.world.pos.y + 36.0f; + this->unk_70C.z += player->actor.world.pos.z; + + this->unk_718.x = player->actor.world.pos.x; + this->unk_718.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 4.0f; + this->unk_718.z = player->actor.world.pos.z; + + if (this->unk_704 >= 35) { + this->unk_704 = 0; + this->unk_708 = 2; + this->unk_728 = -200.0f; + } + break; + + case 2: + case 3: + Matrix_GetStateTranslationAndScaledZ(500.0f, &this->unk_70C); + this->unk_70C.x += this->actor.world.pos.x; + this->unk_70C.y += this->actor.world.pos.y - 50.0f; + this->unk_70C.z += this->actor.world.pos.z; + this->unk_718.x = this->actor.world.pos.x; + this->unk_718.z = this->actor.world.pos.z; + this->unk_718.y = (this->actor.world.pos.y - 70.0f) + this->unk_728; + Math_ApproachZeroF(&this->unk_728, 0.05f, this->unk_73C); + Math_ApproachF(&this->unk_73C, 3.0f, 1.0f, 0.05f); + if (this->unk_704 == 20) { + this->unk_708 = 3; + } + + if (this->unk_704 == 70) { + this->unk_2C8 = 300; + this->unk_2D0 = 0.0f; + D_809EE4D0 = 1; + this->unk_2E2 = 60; + this->unk_2E0 = 93; + } + + if (this->unk_704 > 140) { + Camera* sp5C = Play_GetCamera(globalCtx, MAIN_CAM); + + this->unk_708 = 0; + func_809ECD00(this, globalCtx); + sp5C->eye = this->unk_70C; + sp5C->eyeNext = this->unk_70C; + sp5C->at = this->unk_718; + func_80169AFC(globalCtx, this->unk_70A, 0); + this->unk_70A = 0; + func_800EA0EC(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + func_80165690(); + gSaveContext.eventInf[6] |= 1; + } + break; + } + + if (this->unk_70A != 0) { + Vec3f sp50; + + ShrinkWindow_SetLetterboxTarget(0x1B); + if (this->unk_748 != 0) { + this->unk_748--; + } + Math_Vec3f_Copy(&sp50, &this->unk_718); + sp50.y += Math_SinS(this->unk_748 * 0x4000) * this->unk_748 * 1.5f; + Play_CameraSetAtEye(globalCtx, this->unk_70A, &sp50, &this->unk_70C); + func_80169940(globalCtx, this->unk_70A, this->unk_744); + Math_ApproachF(&this->unk_744, 60.0f, 0.1f, 1.0f); + } + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + x = player->actor.world.pos.x - this->actor.world.pos.x; + y = player->actor.world.pos.y - this->actor.world.pos.y; + z = player->actor.world.pos.z - this->actor.world.pos.z; + this->actor.shape.rot.x = Math_Atan2S(-y, sqrtf(SQ(x) + SQ(z))); +} + +void func_809ECD00(Boss04* this, GlobalContext* globalCtx) { + this->actionFunc = func_809ECD18; +} + +void func_809ECD18(Boss04* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_1F4 >= 0x500) { + this->unk_1F4 -= 0x300; + this->unk_1F7 += 1; + } + + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 10, 0x200); + this->actor.world.pos.y = (this->actor.floorHeight + KREG(17) + 160.0f) + (Math_SinS(this->unk_1F4 * 512) * 10.0f); + Math_ApproachF(&this->actor.speedXZ, this->unk_6D4, 1.0f, 0.5f); + + if (this->unk_1F8 == 0) { + this->unk_1F8 = Rand_ZeroFloat(100.0f) + 50.0f; + this->unk_6D4 = Rand_ZeroFloat(3.0f); + if (Rand_ZeroOne() < 0.1f) { + Math_Vec3f_Copy(&this->unk_6C8, &player->actor.world.pos); + } else { + this->unk_6C8.x = randPlusMinusPoint5Scaled(600.0f) + this->unk_6E8; + this->unk_6C8.z = randPlusMinusPoint5Scaled(600.0f) + this->unk_6F0; + } + } + + Math_ApproachS(&this->actor.world.rot.y, + Math_Atan2S(this->unk_6C8.x - this->actor.world.pos.x, this->unk_6C8.z - this->actor.world.pos.z), 5, + 0x200); + + if (((s8)this->actor.colChkInfo.health <= 10) || (KREG(88) != 0)) { + KREG(88) = 0; + func_809ECEF4(this); + } +} + +void func_809ECEF4(Boss04* this) { + this->actionFunc = func_809ECF58; + Math_Vec3s_Copy(&this->actor.world.rot, &this->actor.shape.rot); + this->unk_1F8 = 0; + this->unk_1F6 = 1; + this->unk_1FA = 60; + this->actor.speedXZ = 0.0f; + this->actor.gravity = -3.0f; +} + +void func_809ECF58(Boss04* this, GlobalContext* globalCtx) { + Vec3f sp3C; + + if ((this->unk_1FE == 14) || ((this->actor.bgCheckFlags & 8) && (this->unk_1F8 == 0))) { + this->unk_1F8 = 20; + if ((Rand_ZeroOne() < 0.2f) && (this->unk_1FE == 0)) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->unk_2D0 = 10000.0f; + this->unk_2C8 = 100; + } else { + this->actor.world.rot.y = BINANG_ROT180((s16)Rand_ZeroFloat(8000.0f) + this->actor.world.rot.y); + } + + this->actor.speedXZ = 0.0f; + + if (this->actor.bgCheckFlags & 8) { + play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); + func_800BC848(&this->actor, globalCtx, 15, 10); + this->unk_6F4 = 15; + sp3C.x = this->actor.focus.pos.x; + sp3C.y = this->actor.focus.pos.y; + sp3C.z = this->actor.focus.pos.z; + func_800BBFB0(globalCtx, &sp3C, 100.0f, 40, 500, 10, 0); + } + } + + Math_ApproachS(&this->actor.shape.rot.x, Math_SinS(this->unk_1F4 * 0xFB8) * 5000.0f, 5, 0x800); + Math_ApproachS(&this->actor.shape.rot.z, Math_SinS(this->unk_1F4 * 0xCD0) * 3000.0f, 5, 0x800); + + if (this->unk_6F4 == 0) { + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 5, 0x1000); + if (this->unk_1FA == 0) { + Math_ApproachF(&this->actor.speedXZ, 20.0f, 1.0f, 1.0f); + sp3C.x = this->actor.world.pos.x; + sp3C.y = this->actor.floorHeight + 2.0f; + sp3C.z = this->actor.world.pos.z; + EffectSsGRipple_Spawn(globalCtx, &sp3C, 1400, 500, 0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_ATTACK - SFX_FLAG); + } + } + + if (KREG(88) != 0) { + KREG(88) = 0; + func_809ED224(this); + this->unk_1FE = 100; + this->unk_200 = 100; + } +} + +void func_809ED224(Boss04* this) { + this->actionFunc = func_809ED2A0; + this->unk_1F8 = 60; + this->unk_1FA = 100; + this->actor.speedXZ = 0.0f; + this->unk_2D0 = 10000.0f; + this->unk_2C8 = 200; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_DEAD); + this->actor.flags &= ~1; + func_801A2ED8(); + this->unk_1F6 = 10; +} + +void func_809ED2A0(Boss04* this, GlobalContext* globalCtx) { + this->unk_2DA = 10; + + if (this->unk_1F8 >= 5) { + this->unk_6FC = (Math_SinS(this->unk_1F8 * 0x3000) * 10.0f * 0.01f) + 1.0f; + this->unk_700 = (Math_CosS(this->unk_1F8 * 0x3000) * 10.0f * 0.01f) + 1.0f; + this->unk_6F8 = this->unk_700; + } + + if (this->unk_1F8 == 5) { + this->unk_6F8 *= 1.3f; + this->unk_6FC *= 1.3f; + this->unk_700 *= 1.3f; + } + + if (this->unk_1F8 == 3) { + this->actor.flags &= ~1; + this->unk_700 = 0.0f; + this->unk_6FC = 0.0f; + this->unk_6F8 = 0.0f; + } + + if ((this->unk_1F8 == 2) || (this->unk_1F8 == 5)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_EXPLOSION); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_IT_BIG_BOMB_EXPLOSION); + } + + if (this->unk_1FA == 3) { + this->unk_1F6 = 11; + } + + if (this->unk_1FA == 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_809ED45C(Boss04* this, GlobalContext* globalCtx) { + ColliderJntSphElement* temp_v0; + u8 damage; + + if ((this->unk_1FE == 0) && (this->collider1.elements[0].info.bumperFlags & BUMP_HIT)) { + this->collider1.elements[0].info.bumperFlags &= ~BUMP_HIT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_DAMAGE); + damage = this->actor.colChkInfo.damage; + this->actor.colChkInfo.health = this->actor.colChkInfo.health - damage; + if ((s8)this->actor.colChkInfo.health <= 0) { + func_809ED224(this); + this->unk_1FE = 100; + this->unk_200 = 100; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } else { + this->unk_2DA = 15; + this->unk_1FE = 15; + this->unk_200 = 15; + } + } +} + +void func_809ED50C(Boss04* this) { + s32 i; + + this->unk_2DE += this->unk_2E2; + this->unk_2DC += this->unk_2E0; + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 10.0f, MTXMODE_APPLY); + Matrix_GetStateTranslation(&this->unk_6BC); + Matrix_Scale(this->actor.scale.x * 13.0f, this->actor.scale.y * 13.0f, this->actor.scale.z * 16.0f, MTXMODE_APPLY); + Matrix_RotateY(this->unk_2DC, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_2DE, MTXMODE_APPLY); + Matrix_StatePush(); + + for (i = 0; i < ARRAY_COUNT(this->unk_2E4); i++) { + Matrix_RotateStateAroundXAxis(0.3926991f); + Matrix_GetStateTranslationAndScaledZ(100.0f, &this->unk_2E4[i]); + } + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(38.0f, 0.0f, 0.0f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(this->unk_3A4); i++) { + Matrix_RotateStateAroundXAxis(0.41887903f); + Matrix_GetStateTranslationAndScaledZ(92.0f, &this->unk_3A4[i]); + } + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(-38.0f, 0.0f, 0.0f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(this->unk_458); i++) { + Matrix_RotateStateAroundXAxis(0.41887903f); + Matrix_GetStateTranslationAndScaledZ(92.0f, &this->unk_458[i]); + } + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(71.0f, 0.0f, 0.0f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(this->unk_50C); i++) { + Matrix_RotateStateAroundXAxis(0.5711987f); + Matrix_GetStateTranslationAndScaledZ(71.0f, &this->unk_50C[i]); + } + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(-71.0f, 0.0f, 0.0f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(this->unk_590); i++) { + Matrix_RotateStateAroundXAxis(0.5711987f); + Matrix_GetStateTranslationAndScaledZ(71.0f, &this->unk_590[i]); + } + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(92.0f, 0.0f, 0.0f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(this->unk_614); i++) { + Matrix_RotateStateAroundXAxis(1.0471976f); + Matrix_GetStateTranslationAndScaledZ(38.0f, &this->unk_614[i]); + } + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(-92.0f, 0.0f, 0.0f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(this->unk_65C); i++) { + Matrix_RotateStateAroundXAxis(1.0471976f); + Matrix_GetStateTranslationAndScaledZ(38.0f, &this->unk_65C[i]); + } + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(100.0f, 0.0f, 0.0f, MTXMODE_APPLY); + + Matrix_GetStateTranslation(&this->unk_6A4); + Matrix_StatePop(); + Matrix_InsertTranslation(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_GetStateTranslation(&this->unk_6B0); +} + +void Boss04_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + Boss04* this = THIS; + s16 temp_v0_8; + s32 pad; + + this->unk_1F4++; + if (KREG(63) == 0) { + if (this->unk_1F8 != 0) { + this->unk_1F8--; + } + + if (this->unk_1FA != 0) { + this->unk_1FA--; + } + + if (this->unk_2C8 != 0) { + this->unk_2C8--; + } + if (this->unk_1FE != 0) { + this->unk_1FE--; + } + + if (this->unk_200 != 0) { + this->unk_200--; + } + + if (this->unk_2DA != 0) { + this->unk_2DA--; + } + + if (this->unk_6F4 != 0) { + this->unk_6F4--; + } + + this->actionFunc(this, globalCtx); + + Actor_MoveWithGravity(&this->actor); + this->actor.world.pos.y -= 100.0f; + this->actor.prevPos.y -= 100.0f; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 100.0f, 120.0f, 200.0f, 5); + this->actor.world.pos.y += 100.0f; + this->actor.prevPos.y += 100.0f; + } + + if (this->unk_200 == 10) { + this->unk_2D0 = 0.0f; + this->unk_2C8 = Rand_ZeroFloat(100.0f) + 60.0f; + } + + if (this->unk_2C8 == 0) { + this->unk_2C8 = Rand_ZeroFloat(100.0f) + 60.0f; + this->unk_2D0 = 10000.0f - this->unk_2D0; + } + + Math_ApproachF(&this->unk_2CC, this->unk_2D0, 0.2f, 1000.0f); + if (this->actionFunc != func_809ED2A0) { + temp_v0_8 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (ABS_ALT(temp_v0_8) < 0x6000) { + if (temp_v0_8 > 0x2500) { + this->unk_2D6 = 0x2500; + } else if (temp_v0_8 < -0x2500) { + this->unk_2D6 = -0x2500; + } else { + this->unk_2D6 = temp_v0_8; + } + } else { + this->unk_2D6 = 0; + } + Math_ApproachS(&this->unk_2D4, this->unk_2D6, 5, 0x800); + this->unk_2D8 = 2000; + this->unk_700 = (Math_SinS(this->unk_6F4 * 0x3000) * this->unk_6F4 * 0.02f) + 1.0f; + this->unk_6FC = (Math_CosS(this->unk_6F4 * 0x3000) * this->unk_6F4 * 0.02f) + 1.0f; + this->unk_6F8 = this->unk_6FC; + this->actor.shape.yOffset = (this->unk_6FC - 1.0f) * 1000.0f; + func_809ED45C(this, globalCtx); + if (this->unk_2CC > 3000.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + this->actor.flags |= 1; + } else { + this->actor.flags &= ~1; + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + func_809ED50C(this); + } + + if (D_809EE4D0 != 0) { + D_809EE4D0--; + if (D_809EE4D0 == 0) { + func_801A2E54(0x38); + } + } + + if (this->unk_74A != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_EXIST - SFX_FLAG); + } +} + +s32 Boss04_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + Boss04* this = THIS; + + if (limbIndex == KREG(32)) { + if (!(this->unk_1F4 & 3)) { + *dList = NULL; + } + rot->x += KREG(33) * 256; + rot->y += KREG(34) * 256; + rot->z += KREG(35) * 256; + } + + if ((limbIndex == 5) || (limbIndex == 7)) { + rot->y = (rot->y + (s16)this->unk_2CC) - 0x500; + } + + if (limbIndex == 4) { + rot->y += this->unk_2D8; + rot->z += this->unk_2D4; + if (this->unk_2DA != 0) { + rot->y = (s16)(Math_SinS(this->unk_1F4 * 0x3000) * (this->unk_2DA * 500)) + rot->y; + rot->z = (s16)(Math_SinS(this->unk_1F4 * 0x3500) * (this->unk_2DA * 300)) + rot->z; + } + } + + return false; +} + +void Boss04_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_809EE228 = { 0.0f, -200.0f, 0.0f }; + static Vec3f D_809EE234 = { 0.0f, 720.0f, 0.0f }; + Boss04* this = THIS; + Vec3f sp18; + + if (limbIndex == 1) { + Matrix_GetStateTranslationAndScaledY(-500.0f, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&D_809EE228, &sp18); + func_809EC040(0, &this->collider1, &sp18); + Matrix_MultiplyVector3fByState(&D_809EE234, &sp18); + func_809EC040(0, &this->collider2, &sp18); + } +} + +void Boss04_Draw(Actor* thisx, GlobalContext* globalCtx) { + Boss04* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_200 & 1) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 900, 1099); + } + + Matrix_InsertTranslation(0.0f, 0.0f, 800.0f, MTXMODE_APPLY); + Matrix_Scale(this->unk_6F8, this->unk_6FC, this->unk_700, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + Boss04_OverrideLimbDraw, Boss04_PostLimbDraw, &this->actor); + + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + + if (this->actionFunc != func_809EC568) { + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 150); + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004510); + + Matrix_InsertTranslation(this->unk_6BC.x, this->actor.floorHeight, this->unk_6BC.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, -20.0f, MTXMODE_APPLY); + Matrix_Scale(this->unk_6F8 * 1.8f, 0.0f, this->unk_700 * 2.8f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004550); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.h b/src/overlays/actors/ovl_Boss_04/z_boss_04.h index 7dec60d9ca..f4542cf3a0 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.h +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.h @@ -9,9 +9,70 @@ typedef void (*Boss04ActionFunc)(struct Boss04*, GlobalContext*); typedef struct Boss04 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC0]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[9]; + /* 0x01BE */ Vec3s morphtable[9]; + /* 0x01F4 */ s16 unk_1F4; + /* 0x01F6 */ s8 unk_1F6; + /* 0x01F7 */ u8 unk_1F7; + /* 0x01F8 */ s16 unk_1F8; + /* 0x01FA */ s16 unk_1FA; + /* 0x01FC */ UNK_TYPE1 unk_1FC[2]; + /* 0x01FE */ s16 unk_1FE; + /* 0x0200 */ s16 unk_200; /* 0x0204 */ Boss04ActionFunc actionFunc; - /* 0x0208 */ char unk_208[0x544]; + /* 0x0208 */ ColliderJntSph collider1; + /* 0x0228 */ ColliderJntSphElement collider1Elements[1]; + /* 0x0268 */ ColliderJntSph collider2; + /* 0x0288 */ ColliderJntSphElement collider2Elements[1]; + /* 0x02C8 */ s16 unk_2C8; + /* 0x02CC */ f32 unk_2CC; + /* 0x02D0 */ f32 unk_2D0; + /* 0x02D4 */ s16 unk_2D4; + /* 0x02D6 */ s16 unk_2D6; + /* 0x02D8 */ s16 unk_2D8; + /* 0x02DA */ s16 unk_2DA; + /* 0x02DC */ s16 unk_2DC; + /* 0x02DE */ s16 unk_2DE; + /* 0x02E0 */ s16 unk_2E0; + /* 0x02E2 */ s16 unk_2E2; + /* 0x02E4 */ Vec3f unk_2E4[16]; + /* 0x02E4 */ Vec3f unk_3A4[15]; + /* 0x02E4 */ Vec3f unk_458[15]; + /* 0x02E4 */ Vec3f unk_50C[11]; + /* 0x02E4 */ Vec3f unk_590[11]; + /* 0x02E4 */ Vec3f unk_614[6]; + /* 0x02E4 */ Vec3f unk_65C[6]; + /* 0x02E4 */ Vec3f unk_6A4; + /* 0x02E4 */ Vec3f unk_6B0; + /* 0x06BC */ Vec3f unk_6BC; + /* 0x06C8 */ Vec3f unk_6C8; + /* 0x06D4 */ f32 unk_6D4; + /* 0x06D8 */ f32 unk_6D8; + /* 0x06DC */ f32 unk_6DC; + /* 0x06E0 */ f32 unk_6E0; + /* 0x06E4 */ f32 unk_6E4; + /* 0x06E8 */ f32 unk_6E8; + /* 0x06EC */ UNK_TYPE1 unk_6EC[4]; + /* 0x06F0 */ f32 unk_6F0; + /* 0x06F4 */ s16 unk_6F4; + /* 0x06F6 */ s16 unk_6F6; + /* 0x06F8 */ f32 unk_6F8; + /* 0x06FC */ f32 unk_6FC; + /* 0x0700 */ f32 unk_700; + /* 0x0704 */ u32 unk_704; + /* 0x0708 */ s16 unk_708; + /* 0x070A */ s16 unk_70A; + /* 0x070C */ Vec3f unk_70C; + /* 0x0718 */ Vec3f unk_718; + /* 0x0724 */ UNK_TYPE1 unk_724[4]; + /* 0x0728 */ f32 unk_728; + /* 0x072C */ UNK_TYPE1 unk_72C[0x10]; + /* 0x073C */ f32 unk_73C; + /* 0x0740 */ UNK_TYPE1 unk_740[4]; + /* 0x0744 */ f32 unk_744; + /* 0x0748 */ s16 unk_748; + /* 0x074A */ u8 unk_74A; } Boss04; // size = 0x74C extern const ActorInit Boss_04_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.h b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.h index 4ce31a8a17..00385a1d1a 100644 --- a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.h +++ b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.h @@ -10,7 +10,10 @@ typedef void (*DmHinaActionFunc)(struct DmHina*, GlobalContext*); typedef struct DmHina { /* 0x0000 */ Actor actor; /* 0x0144 */ DmHinaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x3C]; + /* 0x0148 */ char unk_148[0x10]; + /* 0x0158 */ f32 unk_158; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ char unk_160[0x24]; } DmHina; // size = 0x184 extern const ActorInit Dm_Hina_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c index ccda78a8ea..586b231ae4 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c @@ -53,8 +53,8 @@ void DmSa_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk2E0 = 0; this->alpha = 0xFF; this->actor.targetArrowOffset = 3000.0f; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013328, NULL, 0, 0, 0); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013328, NULL, NULL, NULL, 0); func_80A2E960(&this->skelAnime, D_80A2ED00, 0); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = DmSa_DoNothing; diff --git a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c index 8234deec66..edfa0567da 100644 --- a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c +++ b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c @@ -44,5 +44,5 @@ void DmStatue_Update(Actor* thisx, GlobalContext* globalCtx) { void DmStatue_Draw(Actor* thisx, GlobalContext* globalCtx) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_06001788)); - func_800BE03C(globalCtx, D_06000520); + Gfx_DrawDListXlu(globalCtx, D_06000520); } diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index bf934be08d..99a46c1e25 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -260,7 +260,7 @@ void func_80A9FE3C(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames + 20) { case 1195: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); break; case 1232: @@ -268,48 +268,48 @@ void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { case 1252: case 1255: case 1257: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); break; case 1285: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); break; case 1343: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 1410: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); break; case 1603: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_WALK); break; case 1610: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_REVERSE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_REVERSE); break; case 2095: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_SURPRISED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_SURPRISED); break; case 2190: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_JUMP); break; case 2212: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_ONGND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_ONGND); break; case 2214: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL02_LAUGH_SHORT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL02_LAUGH_SHORT); break; case 2250: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL06_SURPRISED); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL06_SURPRISED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); break; case 2255: @@ -338,7 +338,7 @@ void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { case 2508: case 2519: case 2530: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; } } @@ -368,11 +368,11 @@ void func_80AA0100(DmStk* this, GlobalContext* globalCtx) { case 232: case 243: case 254: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 173: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); break; } } @@ -380,15 +380,15 @@ void func_80AA0100(DmStk* this, GlobalContext* globalCtx) { void func_80AA0158(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 18: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_GASAGOSO); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_GASAGOSO); break; case 90: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); break; case 142: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EVIL_POWER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); break; } } @@ -405,11 +405,11 @@ void func_80AA01C0(DmStk* this, GlobalContext* globalCtx) { break; case 560: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL02_LAUGH_SHORT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL02_LAUGH_SHORT); break; case 890: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL21_PSYCHO_VOICE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL21_PSYCHO_VOICE); break; } } @@ -423,7 +423,7 @@ void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { break; case 71: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_BODY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_BODY); break; case 365: @@ -435,30 +435,30 @@ void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { break; case 265: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); break; case 126: - Audio_PlayActorSound2(&player->actor, NA_SE_VO_DUMMY_150); + Actor_PlaySfxAtPos(&player->actor, NA_SE_VO_DUMMY_150); break; case 197: - Audio_PlayActorSound2(&player->actor, NA_SE_VO_DUMMY_134); + Actor_PlaySfxAtPos(&player->actor, NA_SE_VO_DUMMY_134); break; case 207: - Audio_PlayActorSound2(&player->actor, NA_SE_VO_DUMMY_135); + Actor_PlaySfxAtPos(&player->actor, NA_SE_VO_DUMMY_135); break; case 217: - Audio_PlayActorSound2(&player->actor, NA_SE_VO_DUMMY_136); + Actor_PlaySfxAtPos(&player->actor, NA_SE_VO_DUMMY_136); break; } if (player) {} if ((globalCtx->csCtx.frames >= 263) && (globalCtx->csCtx.frames < 698)) { - Audio_PlayActorSound2(&player->actor, NA_SE_EN_STALKIDS_BODY_LEV - SFX_FLAG); + Actor_PlaySfxAtPos(&player->actor, NA_SE_EN_STALKIDS_BODY_LEV - SFX_FLAG); } } @@ -471,37 +471,37 @@ void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { break; case 258: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_TURN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_TURN); break; case 524: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_TURN); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL04_ANGER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_TURN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL04_ANGER); break; case 534: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); break; case 678: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_STRETCH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_STRETCH); break; } if ((this->unk_2E0 == 31) && (globalCtx->csCtx.frames < 700)) { if (Animation_OnFrame(&this->skelAnime, 5.0f) || Animation_OnFrame(&this->skelAnime, 25.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA1); } else if (Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 40.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA2); } } if (globalCtx->csCtx.frames >= 700) { if (D_80AA3CB8 < 128) { if ((D_80AA3CB8 & 0x1F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL20_CALL_MOON); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON); } else if ((D_80AA3CB8 & 0x1F) == 16) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); } D_80AA3CB8++; } @@ -512,14 +512,14 @@ void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { void func_80AA05F0(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.frames == 3) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL06_SURPRISED); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL06_SURPRISED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); } } void func_80AA0634(DmStk* this, GlobalContext* globalCtx) { if ((globalCtx->csCtx.frames >= 642) && (globalCtx->csCtx.frames < 845)) { - Audio_PlayActorSound2(&this->actor, NA_SE_NE_STAL23_COLD - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_NE_STAL23_COLD - SFX_FLAG); } } @@ -531,16 +531,16 @@ void func_80AA066C(DmStk* this, GlobalContext* globalCtx) { case 72: case 77: case 79: - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_WATER2); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_WATER2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_WALK); break; case 186: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); break; case 230: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL22_LAUGH_KID_L); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL22_LAUGH_KID_L); break; } } @@ -552,7 +552,7 @@ void func_80AA071C(DmStk* this, GlobalContext* globalCtx) { break; case 660: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); break; } } @@ -566,27 +566,27 @@ void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { break; case 45: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 93: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 245: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 269: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL11_LAUGH_SHY2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL11_LAUGH_SHY2); break; case 327: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); break; case 455: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 1730: @@ -594,7 +594,7 @@ void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { break; case 1395: - func_800B8E58(&player->actor, NA_SE_VO_DUMMY_34); + func_800B8E58(player, NA_SE_VO_DUMMY_34); break; case 1850: @@ -608,20 +608,20 @@ void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { if (this->unk_2E0 == 0) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } if (Animation_OnFrame(&this->skelAnime, 28.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); } } else if (this->unk_2E0 == 71) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } } else if ((this->unk_2E0 == 70) && (Animation_OnFrame(&this->skelAnime, 16.0f) || Animation_OnFrame(&this->skelAnime, 23.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_NOSE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_NOSE); } } @@ -634,25 +634,25 @@ void func_80AA09DC(DmStk* this, GlobalContext* globalCtx) { break; case 234: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_TURN); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL04_ANGER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_TURN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL04_ANGER); break; case 244: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); break; case 388: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_STRETCH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_STRETCH); break; } if (globalCtx->csCtx.frames >= 408) { if (D_80AA3CBC < 128) { if ((D_80AA3CBC & 0x1F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL20_CALL_MOON); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON); } else if ((D_80AA3CBC & 0x1F) == 16) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); } D_80AA3CBC++; } @@ -668,43 +668,43 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 64: - func_8019F1C0(&this->unk_310, NA_SE_EN_STAL06_SURPRISED); + Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL06_SURPRISED); break; case 327: case 332: case 335: case 344: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 367: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); break; case 470: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_HEADACHE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_HEADACHE); break; case 486: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); - func_8019F1C0(&this->unk_310, NA_SE_EN_STAL08_CRY_BIG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL08_CRY_BIG); break; case 496: - func_8019F1C0(&this->unk_310, NA_SE_EN_STAL09_SCREAM); + Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL09_SCREAM); break; case 590: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 592: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 594: - func_8019F1C0(&this->unk_310, NA_SE_EN_STAL24_SCREAM2); + Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL24_SCREAM2); break; } @@ -712,16 +712,16 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { if ((globalCtx->csCtx.frames >= 62) && (globalCtx->csCtx.frames < 273)) { if ((Rand_ZeroOne() < 0.75f) && ((globalCtx->state.frames % 2) != 0)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_EARTHQUAKE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_EARTHQUAKE); } } if ((globalCtx->csCtx.frames >= 498) && (globalCtx->csCtx.frames < 577)) { if ((globalCtx->state.frames % 4) == 0) { if ((globalCtx->state.frames & 4) != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } } } @@ -734,16 +734,16 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { void func_80AA0DA8(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 551: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_PULLED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_PULLED); break; case 711: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 716: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_ONGND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_ONGND); break; } } @@ -751,16 +751,16 @@ void func_80AA0DA8(DmStk* this, GlobalContext* globalCtx) { void func_80AA0E1C(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 311: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_PULLED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_PULLED); break; case 365: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 372: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_ONGND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_ONGND); break; } } @@ -834,24 +834,24 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { if (this->unk_2E0 == 1) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_WALK); } } else if (this->unk_2E0 == 19) { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 20.0f) || Animation_OnFrame(&this->skelAnime, 27.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_CALM_HIT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_CALM_HIT); } } else if (this->unk_2E0 == 14) { if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_PUT_OUT_ITEM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PUT_OUT_ITEM); } } else if (this->unk_2E0 == 15) { if (Animation_OnFrame(&this->skelAnime, 14.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_UNSKILLFUL_OCARINA); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_UNSKILLFUL_OCARINA); } if (Animation_OnFrame(&this->skelAnime, 45.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL01_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL01_LAUGH); } } } @@ -964,7 +964,7 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2E4 = this->unk_2E4; this->actor.targetArrowOffset = 1100.0f; this->unk_334 = 99; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013328, NULL, NULL, NULL, 0); func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); } @@ -1062,7 +1062,7 @@ void func_80AA19EC(DmStk* this, GlobalContext* globalCtx) { void func_80AA1A50(DmStk* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(0xA)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DAMAGE); ActorCutscene_Start(0xA, &this->actor); this->actor.shape.rot.x = 0; this->actor.world.rot.x = this->actor.shape.rot.x; @@ -1109,7 +1109,7 @@ void func_80AA1B9C(DmStk* this, GlobalContext* globalCtx) { this->unk_2E0 = 39; func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); this->actionFunc = func_80AA1C64; } @@ -1568,9 +1568,9 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params != 1) { if (this->unk_2E0 == 33) { - Actor_SetHeight(&this->actor, 40.0f); + Actor_SetFocus(&this->actor, 40.0f); } else { - Actor_SetHeight(&this->actor, 6.0f); + Actor_SetFocus(&this->actor, 6.0f); } func_80A9FDB0(this, globalCtx); @@ -1592,7 +1592,7 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { switch (this->unk_33A) { case 1: - if (func_800B8718(&this->actor, globalCtx)) { + if (func_800B8718(&this->actor, &globalCtx->state)) { this->unk_33A = 2; } else { func_800B874C(&this->actor, globalCtx, this->actor.xzDistToPlayer, @@ -1719,7 +1719,7 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_337].segment); AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_06008658)); - func_800BDFC0(globalCtx, D_06007840); + Gfx_DrawDListOpa(globalCtx, D_06007840); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_336].segment); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_336].segment); @@ -1829,7 +1829,7 @@ void DmStk_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_33B != 0) { if (this->actor.params == 1) { - func_800BDFC0(globalCtx, D_06006BB0); + Gfx_DrawDListOpa(globalCtx, D_06006BB0); return; } diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index fb983aa6fe..167dbfe69d 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -208,5 +208,5 @@ void DoorAna_Update(Actor* thisx, GlobalContext* globalCtx) { } void DoorAna_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BE03C(globalCtx, D_05000C40); + Gfx_DrawDListXlu(globalCtx, D_05000C40); } diff --git a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c index 1716721dea..3e9754ccfc 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c @@ -205,7 +205,7 @@ void DoorSpiral_Init(Actor* thisx, GlobalContext* globalCtx) { } DoorSpiral_SetupAction(this, DoorSpiral_WaitForObject); - Actor_SetHeight(&this->actor, 60.0f); + Actor_SetFocus(&this->actor, 60.0f); } void DoorSpiral_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -237,7 +237,7 @@ f32 DoorSpiral_GetDistFromPlayer(GlobalContext* globalCtx, DoorSpiral* this, f32 target.y = player->actor.world.pos.y + yOffset; target.z = player->actor.world.pos.z; - Actor_CalcOffsetOrientedToDrawRotation(&this->actor, &offset, &target); + Actor_OffsetOfPointInActorCoords(&this->actor, &offset, &target); if ((spiralWidth < fabsf(offset.x)) || (spiralHeight < fabsf(offset.y))) { return FLT_MAX; @@ -252,7 +252,7 @@ f32 DoorSpiral_GetDistFromPlayer(GlobalContext* globalCtx, DoorSpiral* this, f32 s32 DoorSpiral_PlayerShouldClimb(DoorSpiral* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (!(func_801233E4(globalCtx))) { + if (!Player_InCsMode(&globalCtx->state)) { SpiralInfo* spiralInfo = &sSpiralInfo[this->spiralType]; f32 dist = DoorSpiral_GetDistFromPlayer(globalCtx, this, 0.0f, spiralInfo->spiralWidth, spiralInfo->spiralHeight); diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index 22e2498617..6d933ecd95 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -5,6 +5,7 @@ */ #include "z_door_warp1.h" +#include "objects/object_warp1/object_warp1.h" #define FLAGS 0x00000000 @@ -15,26 +16,39 @@ void DoorWarp1_Destroy(Actor* thisx, GlobalContext* globalCtx); void DoorWarp1_Update(Actor* thisx, GlobalContext* globalCtx); void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx); +void DoorWarp1_SetupAction(DoorWarp1* this, DoorWarp1ActionFunc actionFunc); +void func_808B8924(DoorWarp1* this, GlobalContext* globalCtx); +void func_808B8A7C(DoorWarp1* this, GlobalContext* globalCtx); +void func_808B8C48(DoorWarp1* this, GlobalContext* globalCtx); +void func_808B8E78(DoorWarp1* this, GlobalContext* globalCtx); +void func_808B9094(DoorWarp1* this, GlobalContext* globalCtx); +void func_808B90CC(DoorWarp1* this, GlobalContext* globalCtx); void func_808B921C(DoorWarp1* this, GlobalContext* globalCtx); void func_808B93A0(DoorWarp1* this, GlobalContext* globalCtx); void func_808B94A4(DoorWarp1* this, GlobalContext* globalCtx); void func_808B9524(DoorWarp1* this, GlobalContext* globalCtx); void func_808B958C(DoorWarp1* this, GlobalContext* globalCtx); +void func_808B96A0(DoorWarp1* this, GlobalContext* globalCtx); void func_808B96B0(DoorWarp1* this, GlobalContext* globalCtx); +void func_808B977C(DoorWarp1* this, GlobalContext* globalCtx); void func_808B9840(DoorWarp1* this, GlobalContext* globalCtx); void func_808B98A8(DoorWarp1* this, GlobalContext* globalCtx); void func_808B9B30(DoorWarp1* this, GlobalContext* globalCtx); void func_808B9BE8(DoorWarp1* this, GlobalContext* globalCtx); void func_808B9CE8(DoorWarp1* this, GlobalContext* globalCtx); void func_808B9E94(DoorWarp1* this, GlobalContext* globalCtx); +void func_808B9ED8(DoorWarp1* this, GlobalContext* globalCtx); +void func_808B9F10(DoorWarp1* this, GlobalContext* globalCtx); void func_808B9FD0(DoorWarp1* this, GlobalContext* globalCtx); +void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx); void func_808BA550(DoorWarp1* this, GlobalContext* globalCtx); void func_808BAAF4(DoorWarp1* this, GlobalContext* globalCtx); void func_808BABF4(DoorWarp1* this, GlobalContext* globalCtx); +void func_808BB8D4(DoorWarp1* this, GlobalContext* globalCtx, s32 arg2); -void DoorWarp1_SetupAction(DoorWarp1* this, DoorWarp1ActionFunc actionFunc); +static s16 D_808BC000; +static f32 D_808BC004; -#if 0 const ActorInit Door_Warp1_InitVars = { ACTOR_DOOR_WARP1, ACTORCAT_ITEMACTION, @@ -47,92 +61,1114 @@ const ActorInit Door_Warp1_InitVars = { (ActorFunc)DoorWarp1_Draw, }; +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 4000, ICHAIN_STOP), +}; + +void DoorWarp1_SetupAction(DoorWarp1* this, DoorWarp1ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} + +s32 func_808B849C(DoorWarp1* this, GlobalContext* globalCtx) { + s32 ret = 0; + + if ((globalCtx->sceneNum == SCENE_MITURIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + ret = 1; + } else if ((globalCtx->sceneNum == SCENE_HAKUGIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { + ret = 2; + } else if ((globalCtx->sceneNum == SCENE_SEA_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { + ret = 3; + } else if ((globalCtx->sceneNum == SCENE_INISIE_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + ret = 4; + } + return ret; +} + +void func_808B8568(DoorWarp1* this, GlobalContext* globalCtx) { + s32 pad[2]; + + Lights_PointNoGlowSetInfo(&this->unk_1E0, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, 0, 0, 0, 0); + this->unk_1DC = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->unk_1E0); + Lights_PointNoGlowSetInfo(&this->unk_1F4, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, 0, 0, 0, 0); + this->unk_1F0 = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->unk_1F4); +} + +s32 func_808B866C(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 ret = false; + + if ((fabsf(this->dyna.actor.xzDistToPlayer) < 60.0f) && + (((player->actor.world.pos.y - 20.0f) < this->dyna.actor.world.pos.y) && + (this->dyna.actor.world.pos.y < (player->actor.world.pos.y + 20.0f)))) { + ret = true; + } + return ret; +} + +void DoorWarp1_Init(Actor* thisx, GlobalContext* globalCtx) { + DoorWarp1* this = THIS; + + this->unk_1CC = 0; + this->unk_202 = 0; + this->unk_203 = 0; + this->unk_1A0 = NULL; + this->unk_1C0 = 0.0f; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 0.0f); + + this->unk_1D3 = 0; + this->unk_1D4 = 0; + this->unk_203 = 0; + this->unk_204 = 1.0f; + + switch (DOORWARP1_GET_FF(&this->dyna.actor)) { + case ENDOORWARP1_FF_0: + case ENDOORWARP1_FF_1: + case ENDOORWARP1_FF_2: + case ENDOORWARP1_FF_3: + case ENDOORWARP1_FF_4: + case ENDOORWARP1_FF_5: + func_808B8568(this, globalCtx); + break; + } + + switch (DOORWARP1_GET_FF(&this->dyna.actor)) { + case ENDOORWARP1_FF_0: + func_808B8924(this, globalCtx); + break; + + case ENDOORWARP1_FF_1: + func_808B8A7C(this, globalCtx); + break; + + case ENDOORWARP1_FF_2: + case ENDOORWARP1_FF_3: + case ENDOORWARP1_FF_4: + case ENDOORWARP1_FF_5: + this->unk_1D3 = 1; + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_warp1_Colheader_008BD4); + func_808B8C48(this, globalCtx); + break; + + case ENDOORWARP1_FF_6: + func_808B8E78(this, globalCtx); + break; + } + + if ((globalCtx->sceneNum == SCENE_MITURIN_BS) || (globalCtx->sceneNum == SCENE_HAKUGIN_BS) || + (globalCtx->sceneNum == SCENE_INISIE_BS) || (globalCtx->sceneNum == SCENE_SEA_BS)) { + func_800FE484(); + globalCtx->interfaceCtx.restrictions.unk_312 = 1; + globalCtx->interfaceCtx.restrictions.songOfSoaring = 1; + } +} + +void DoorWarp1_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DoorWarp1* this = THIS; + s16 i; + + 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]; + } + + if (this->unk_1D3 != 0) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} + +void func_808B8924(DoorWarp1* this, GlobalContext* globalCtx) { + this->unk_1C4 = 0; + this->unk_1C6 = -140; + this->unk_1C8 = -80; + this->unk_1BC = 1.0f; + this->unk_1B0 = 0.0f; + this->unk_1B4 = 0.0f; + this->unk_1B8 = 0.0f; + this->unk_1A4 = 0.3f; + this->unk_1A8 = 0.3f; + this->unk_1AC = 0.0f; + this->dyna.actor.shape.yOffset = 1.0f; + this->unk_1D0 = 0; + D_808BC000 = 100; + Lights_PointNoGlowSetInfo(&this->unk_1E0, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, 200, 255, 255, 255); + Lights_PointNoGlowSetInfo(&this->unk_1F4, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, 200, 255, 255, 255); + DoorWarp1_SetupAction(this, func_808B96B0); +} + +void func_808B8A7C(DoorWarp1* this, GlobalContext* globalCtx) { + SkelAnime_Init(globalCtx, &this->skelAnime, &object_warp1_Skel_002CA8, &object_warp1_Anim_001374, NULL, NULL, 0); + Animation_ChangeImpl(&this->skelAnime, &object_warp1_Anim_001374, 1.0f, 1.0f, 1.0f, 2, 40.0f, 1); + this->unk_1C4 = 0; + this->unk_1C6 = -140; + this->unk_1C8 = -80; + this->unk_1D0 = 0; + this->unk_1BC = 1.0f; + this->unk_1A4 = 0.3f; + this->unk_1A8 = 0.3f; + this->unk_1B0 = 0.0f; + this->unk_1B4 = 0.0f; + this->unk_1B8 = 0.0f; + this->unk_1AC = 0.0f; + this->dyna.actor.shape.yOffset = -400.0f; + D_808BC000 = 160; + Lights_PointNoGlowSetInfo(&this->unk_1E0, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, 200, 255, 255, 255); + Lights_PointNoGlowSetInfo(&this->unk_1F4, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, 200, 255, 255, 255); + DoorWarp1_SetupAction(this, func_808B9B30); +} + +void func_808B8C48(DoorWarp1* this, GlobalContext* globalCtx) { + this->dyna.actor.shape.yOffset = 0.0f; + Actor_SetScale(&this->dyna.actor, 0.1f); + Lights_PointNoGlowSetInfo(&this->unk_1E0, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, 200, 255, 255, 255); + Lights_PointNoGlowSetInfo(&this->unk_1F4, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, 200, 255, 255, 255); + if (((DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_2) && CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) || + ((DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_3) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) || + ((DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_4) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) || + ((DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_5) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD))) { + s16 params = DOORWARP1_GET_FF00_2(&this->dyna.actor); + + params |= 6; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_DOOR_WARP1, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 10.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, params); + DoorWarp1_SetupAction(this, func_808BAAF4); + } else { + DoorWarp1_SetupAction(this, func_808BABF4); + } +} + +void func_808B8E78(DoorWarp1* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->dyna.actor, 0.1f); + Lights_PointNoGlowSetInfo(&this->unk_1E0, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, 200, 255, 255, 0); + Lights_PointNoGlowSetInfo(&this->unk_1F4, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, 200, 255, 255, 0); + Actor_SetScale(&this->dyna.actor, 3.0f); + this->unk_1D4 = 1; + this->unk_1D0 = 0; + this->unk_1A8 = 0.0f; + this->unk_1AC = 0.0f; + this->unk_1A4 = 700.0f; + if (globalCtx->sceneNum == SCENE_INISIE_N) { + DoorWarp1_SetupAction(this, func_808B96A0); + } else if (gSaveContext.weekEventReg[86] & 0x80) { + this->unk_1D4 = 0; + DoorWarp1_SetupAction(this, func_808B921C); + } else { + DoorWarp1_SetupAction(this, func_808B9094); + } +} + +s32 func_808B900C(DoorWarp1* this, GlobalContext* globalCtx) { + u32 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) { + ret = true; + } + } + } + + return ret; +} + +void func_808B9094(DoorWarp1* this, GlobalContext* globalCtx) { + if (func_808B900C(this, globalCtx)) { + DoorWarp1_SetupAction(this, func_808B90CC); + } +} + +void func_808B90CC(DoorWarp1* this, GlobalContext* globalCtx) { + s32 pad[2]; + s16 sp2E = 0; + f32 phi_f0 = 0.0f; + + if (globalCtx->sceneNum == SCENE_MITURIN) { + sp2E = -10; + phi_f0 = -5.0f; + } else if (globalCtx->sceneNum == SCENE_HAKUGIN) { + sp2E = -20; + } else if (globalCtx->sceneNum == SCENE_SEA) { + sp2E = -20; + } + + Math_SmoothStepToF(&this->unk_1AC, 40.0f, 0.5f, 1.2f + phi_f0, 0.01f); + Math_SmoothStepToF(&this->unk_1A4, 0.0f, 0.5f, 12.0f, 0.1f); + if ((this->unk_1A4 < 460.0f) && (this->unk_1A4 > 100.0f)) { + func_808BB8D4(this, globalCtx, 6); + } + + if (this->unk_1A4 < 0.1f) { + this->unk_1D0 = sp2E + 30; + this->unk_1D4 = 0; + DoorWarp1_SetupAction(this, func_808B921C); + } + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE_ENERGY - SFX_FLAG); +} + +void func_808B921C(DoorWarp1* this, GlobalContext* globalCtx) { + if (this->unk_1D0 != 0) { + this->unk_1D0--; + return; + } + + Math_SmoothStepToF(&this->unk_1A8, 1.0f, 0.2f, 0.05f, 0.01f); + this->unk_203 = (u8)(this->unk_1A8 * 200.0f); + if (this->unk_1A8 > 0.8f) { + func_808BB8D4(this, globalCtx, 1); + } + + if (func_808B866C(this, globalCtx) && !func_801690CC(globalCtx)) { + func_800B7298(globalCtx, &this->dyna.actor, 7); + func_801518B0(globalCtx, 0xF2, &this->dyna.actor); + DoorWarp1_SetupAction(this, func_808B93A0); + } + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); +} + +void func_808B93A0(DoorWarp1* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (Message_GetState(&globalCtx->msgCtx) == 4 && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + func_800B7298(globalCtx, &this->dyna.actor, 9); + player->unk_3A0.x = this->dyna.actor.world.pos.x; + player->unk_3A0.z = this->dyna.actor.world.pos.z; + this->unk_1CA = 1; + DoorWarp1_SetupAction(this, func_808B9524); + } else { + func_8019F230(); + func_800B7298(globalCtx, &this->dyna.actor, 6); + DoorWarp1_SetupAction(this, func_808B94A4); + } + } + func_808BB8D4(this, globalCtx, 1); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); +} + +void func_808B94A4(DoorWarp1* this, GlobalContext* globalCtx) { + if (!func_808B866C(this, globalCtx) && (ActorCutscene_GetCurrentIndex() != globalCtx->unk_1879C[8])) { + DoorWarp1_SetupAction(this, func_808B921C); + } + func_808BB8D4(this, globalCtx, 1); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); +} + +void func_808B9524(DoorWarp1* this, GlobalContext* globalCtx) { + if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) { + ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]); + } else { + ActorCutscene_Start(globalCtx->unk_1879C[9], NULL); + DoorWarp1_SetupAction(this, func_808B958C); + } +} + +void func_808B958C(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_808BB8D4(this, globalCtx, 1); + + if (this->unk_1CA > 100) { + if (player->actor.velocity.y < 10.0f) { + player->actor.gravity = 0.1f; + } else { + player->actor.gravity = 0.0f; + } + } else { + this->unk_1CA++; + } + + this->unk_1D0++; + if ((this->unk_1D0 > 120) && (gSaveContext.nextCutsceneIndex == 0xFFEF)) { + func_808BA10C(this, globalCtx); + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + } + + Math_SmoothStepToF(&this->unk_1A8, 6.0f, 0.2f, 0.02f, 0.01f); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_LINK_WARP - SFX_FLAG); +} + +void func_808B96A0(DoorWarp1* this, GlobalContext* globalCtx) { +} + +void func_808B96B0(DoorWarp1* this, GlobalContext* globalCtx) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + Math_SmoothStepToF(&this->unk_1B0, 255.0f, 0.4f, 10.0f, 0.01f); + Math_SmoothStepToF(&this->unk_1B4, 255.0f, 0.4f, 10.0f, 0.01f); + + if (this->unk_1C4 < 100) { + this->unk_1C4 += 2; + } + + if (this->unk_1C6 < 120) { + this->unk_1C6 += 4; + } + + if (this->unk_1C8 < 230) { + this->unk_1C8 += 4; + } else { + DoorWarp1_SetupAction(this, func_808B977C); + } +} + +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)) { + Player* player = GET_PLAYER(globalCtx); + + Audio_PlaySfxGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); + func_800B7298(globalCtx, &this->dyna.actor, 9); + player->unk_3A0.x = this->dyna.actor.world.pos.x; + player->unk_3A0.z = this->dyna.actor.world.pos.z; + this->unk_1CA = 1; + DoorWarp1_SetupAction(this, func_808B9840); + } +} + +void func_808B9840(DoorWarp1* this, GlobalContext* globalCtx) { + if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) { + ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]); + } else { + ActorCutscene_Start(globalCtx->unk_1879C[9], NULL); + DoorWarp1_SetupAction(this, func_808B98A8); + } +} + +void func_808B98A8(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_1CA > 100) { + if (player->actor.velocity.y < 10.0f) { + player->actor.gravity = 0.1f; + } else { + player->actor.gravity = 0.0f; + } + } else { + this->unk_1CA++; + } + + Math_SmoothStepToF(&this->unk_1B0, 0.0f, 0.2f, 6.0f, 0.01f); + + this->unk_1D0++; + if (D_808BC000 < this->unk_1D0) { + if ((gSaveContext.nextCutsceneIndex == 0xFFEF) && (D_808BC000 < this->unk_1D0) && + (gSaveContext.nextCutsceneIndex == 0xFFEF)) { + if (DOORWARP1_GET_FF00_1(&this->dyna.actor) != 0xFF) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[DOORWARP1_GET_FF00_3(&this->dyna.actor)]; + Scene_SetExitFade(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + } else { + func_80169FDC(globalCtx); + } + } + } + + Math_StepToF(&this->unk_1A4, 2.0f, 0.01f); + Math_StepToF(&this->unk_1A8, 10.0f, 0.02f); + Lights_PointNoGlowSetInfo(&this->unk_1E0, player->actor.world.pos.x + 10, player->actor.world.pos.y + 10, + player->actor.world.pos.z + 10, 235, 255, 255, 255); + Lights_PointNoGlowSetInfo(&this->unk_1F4, player->actor.world.pos.x - 10, player->actor.world.pos.y - 10, + player->actor.world.pos.z - 10, 235, 255, 255, 255); + Math_SmoothStepToF(&this->dyna.actor.shape.yOffset, 0.0f, 0.5f, 2.0f, 0.1f); +} + +void func_808B9B30(DoorWarp1* this, GlobalContext* globalCtx) { + if (fabsf(this->dyna.actor.xzDistToPlayer) >= 60.0f) { + if (func_808B849C(this, globalCtx)) { + this->unk_1A0 = + (DmHina*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_DM_HINA, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, 0, 0, 0, func_808B849C(this, globalCtx) - 1); + } + DoorWarp1_SetupAction(this, func_808B9BE8); + } +} + +void func_808B9BE8(DoorWarp1* this, GlobalContext* globalCtx) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + Math_SmoothStepToF(&this->unk_1B0, 255.0f, 0.2f, 2.0f, 0.1f); + Math_SmoothStepToF(&this->unk_1B4, 255.0f, 0.2f, 2.0f, 0.1f); + if (this->unk_1C4 < 10) { + this->unk_1C4 += 2; + } + + if (this->unk_1C6 < 120) { + this->unk_1C6 += 4; + } + + if (this->unk_1C8 < 230) { + this->unk_1C8 += 4; + return; + } + + this->dyna.actor.parent = NULL; + if (func_808B849C(this, globalCtx)) { + this->unk_202 = 1; + DoorWarp1_SetupAction(this, func_808B9CE8); + } else { + DoorWarp1_SetupAction(this, func_808B9F10); + } +} + +void func_808B9CE8(DoorWarp1* this, GlobalContext* globalCtx) { + if (this->unk_203 != 0) { + if (1) {} + return; + } + + if (!Actor_HasParent(&this->dyna.actor, globalCtx)) { + Actor_PickUp(&this->dyna.actor, globalCtx, func_808B849C(this, globalCtx) + 84, 30.0f, 80.0f); + return; + } + + switch (globalCtx->sceneNum) { + case SCENE_MITURIN_BS: + gSaveContext.roomInf[126][3] = + (((void)0, gSaveContext.roomInf[126][3]) & 0xFFFFFF00) | (((u8)gSaveContext.roomInf[126][4]) & 0xFF); + break; + + case SCENE_HAKUGIN_BS: + gSaveContext.roomInf[126][3] = (((void)0, gSaveContext.roomInf[126][3]) & 0xFFFF00FF) | + ((((u8)gSaveContext.roomInf[126][4]) & 0xFF) << 8); + break; + + case SCENE_INISIE_BS: + gSaveContext.roomInf[126][3] = (((void)0, gSaveContext.roomInf[126][3]) & 0xFF00FFFF) | + ((((u8)gSaveContext.roomInf[126][4]) & 0xFF) << 0x10); + break; + + case SCENE_SEA_BS: + gSaveContext.roomInf[126][3] = (((void)0, gSaveContext.roomInf[126][3]) & 0x00FFFFFF) | + ((((u8)gSaveContext.roomInf[126][4]) & 0xFF) << 0x18); + break; + } + + gSaveContext.roomInf[126][4] = + (gSaveContext.roomInf[126][4] & 0xFFFFFF00) | ((((u8)gSaveContext.roomInf[126][4]) + 1) & 0xFF); + Item_Give(globalCtx, func_808B849C(this, globalCtx) + (ITEM_REMAINS_ODOLWA - 1)); + DoorWarp1_SetupAction(this, func_808B9E94); +} + +void func_808B9E94(DoorWarp1* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 2) { + this->unk_1CE = 110; + DoorWarp1_SetupAction(this, func_808B9ED8); + } +} + +void func_808B9ED8(DoorWarp1* this, GlobalContext* globalCtx) { + this->unk_1CE--; + if (this->unk_1CE <= 0) { + func_808BA10C(this, 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)) { + Player* player = GET_PLAYER(globalCtx); + + Interface_ChangeAlpha(1); + func_800B7298(globalCtx, &this->dyna.actor, 9); + player->unk_3A0.x = this->dyna.actor.world.pos.x; + player->unk_3A0.z = this->dyna.actor.world.pos.z; + this->unk_1CA = 20; + DoorWarp1_SetupAction(this, func_808B9FD0); + } +} + +void func_808B9FD0(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + + if (this->unk_1CA != 0) { + this->unk_1CA--; + return; + } + + if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) { + ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]); + } else { + ActorCutscene_Start(globalCtx->unk_1879C[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), + Animation_GetLastFrame(&object_warp1_Anim_001374.common), 2, 40.0f, 1); + this->unk_1CA = 50; + D_808BC004 = player2->actor.world.pos.y; + DoorWarp1_SetupAction(this, func_808BA550); + } +} + +void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { + s32 phi_v0_2; + u8 phi_a0; + s32 phi_v0_3; + + if ((globalCtx->sceneNum == SCENE_MITURIN_BS) || (globalCtx->sceneNum == SCENE_HAKUGIN_BS) || + (globalCtx->sceneNum == SCENE_INISIE_BS) || (globalCtx->sceneNum == SCENE_SEA_BS)) { + D_801F4DE2 = globalCtx->sceneNum; + if (globalCtx->sceneNum == SCENE_MITURIN_BS) { + phi_v0_2 = 0; + } else if (globalCtx->sceneNum == SCENE_HAKUGIN_BS) { + phi_v0_2 = 1; + } else if (globalCtx->sceneNum == SCENE_INISIE_BS) { + phi_v0_2 = 2; + } else if (globalCtx->sceneNum == SCENE_SEA_BS) { + phi_v0_2 = 3; + } else { + phi_v0_2 = 0; + } + + if (this->unk_202 != 0) { + if (phi_v0_2 > 0) { + gSaveContext.weekEventReg[7] |= 0x80; + } + + switch (phi_v0_2) { + case 0: + phi_a0 = gSaveContext.roomInf[126][3] & 0xFF; + break; + + case 1: + phi_a0 = (gSaveContext.roomInf[126][3] & 0xFF00) >> 8; + break; + + case 2: + phi_a0 = (gSaveContext.roomInf[126][3] & 0xFF0000) >> 0x10; + break; + + case 3: + phi_a0 = (gSaveContext.roomInf[126][3] & 0xFF000000) >> 0x18; + break; + + default: + phi_a0 = 0; + break; + } + + switch (phi_a0) { + case 0: + phi_v0_3 = 10; + break; + + case 1: + phi_v0_3 = 0; + break; + + case 2: + phi_v0_3 = 1; + break; + + case 3: + phi_v0_3 = 2; + break; + + default: + phi_v0_3 = 10; + break; + } + + globalCtx->nextEntranceIndex = 0xCC00; + if (phi_v0_3 < 10) { + gSaveContext.nextCutsceneIndex = phi_v0_3 + 0xFFF0; + } + + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + } else { + switch (phi_v0_2) { + case 0: + if (gSaveContext.weekEventReg[20] & 2) { + gSaveContext.weekEventReg[7] |= 0x80; + globalCtx->nextEntranceIndex = 0x3010; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + } else { + globalCtx->nextEntranceIndex = 0x8600; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + } + break; + + case 1: + gSaveContext.weekEventReg[33] |= 0x80; + globalCtx->nextEntranceIndex = 0xAE70; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + break; + + case 3: + if (gSaveContext.weekEventReg[55] & 0x80) { + globalCtx->nextEntranceIndex = 0x6A90; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + } else { + gSaveContext.weekEventReg[55] |= 0x80; + globalCtx->nextEntranceIndex = 0x6A80; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + } + break; + + case 2: + gSaveContext.weekEventReg[52] |= 0x20; + globalCtx->nextEntranceIndex = 0x20F0; + gSaveContext.nextCutsceneIndex = 0xFFF2; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + break; + } + } + } else if (DOORWARP1_GET_FF00_1(&this->dyna.actor) != 0xFF) { + if (DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_6) { + gSaveContext.respawnFlag = ~1; + } + globalCtx->nextEntranceIndex = globalCtx->setupExitList[DOORWARP1_GET_FF00_3(&this->dyna.actor)]; + Scene_SetExitFade(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + } else { + func_80169FDC(globalCtx); + } +} + +void func_808BA550(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player2 = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(globalCtx); + s16 i; + s32 temp_f16; + f32 temp_f0; + f32 temp_f2; + s32 temp; + s32 tempS; + + if (this->unk_1CA != 0) { + this->unk_1CA--; + } + + if (this->unk_1CA < 0x1F) { + temp_f0 = 0.0f; + switch (player2->transformation) { + case PLAYER_FORM_FIERCE_DEITY: + temp_f0 = -37.0f; + break; + + case PLAYER_FORM_GORON: + temp_f0 = -37.0f; + break; + + case PLAYER_FORM_ZORA: + temp_f0 = -37.0f; + break; + + case PLAYER_FORM_DEKU: + temp_f0 = -20.0f; + break; + + case PLAYER_FORM_HUMAN: + temp_f0 = -25.0f; + break; + } + + temp_f2 = this->dyna.actor.world.pos.y + (this->dyna.actor.shape.yOffset * 0.1f) + temp_f0; + + if (D_808BC004 < temp_f2) { + player->actor.world.pos.y = temp_f2; + } + + if (this->unk_1CA <= 0) { + if (this->unk_1CC < 4000) { + this->unk_1CC += 40; + } + player->actor.world.rot.y -= this->unk_1CC; + player->actor.shape.rot.y -= this->unk_1CC; + } + Math_SmoothStepToF(&player->actor.world.pos.x, this->dyna.actor.world.pos.x, 0.5f, 0.1f, 0.01f); + Math_SmoothStepToF(&player->actor.world.pos.z, this->dyna.actor.world.pos.z, 0.5f, 0.1f, 0.01f); + } + + this->unk_1D0++; + if ((D_808BC000 < this->unk_1D0) && (gSaveContext.nextCutsceneIndex == 0xFFEF)) { + func_808BA10C(this, globalCtx); + } + + if (this->unk_1D0 > 140) { + globalCtx->envCtx.unk_E5 = 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; + } + + Lights_PointNoGlowSetInfo(&this->unk_1E0, player->actor.world.pos.x + 10.0f, player->actor.world.pos.y + 10.0f, + player->actor.world.pos.z + 10.0f, 235, 255, 255, 255); + Lights_PointNoGlowSetInfo(&this->unk_1F4, player->actor.world.pos.x - 10.0f, player->actor.world.pos.y - 10.0f, + player->actor.world.pos.z - 10.0f, 235, 255, 255, 255); + Math_SmoothStepToF(&this->dyna.actor.shape.yOffset, 800.0f, 0.2f, 15.0f, 0.01f); + this->dyna.actor.shape.rot.y += 0x320; + Math_SmoothStepToF(&this->unk_1BC, 1.13f, 0.2f, 0.1f, 0.01f); + Math_StepToF(&this->unk_1A4, 2.0f, 0.003f); + Math_StepToF(&this->unk_1A8, 10.0f, 0.006f); + Math_SmoothStepToF(&this->unk_1B0, 0.0f, 0.2f, 3.0f, 0.01f); + Math_SmoothStepToF(&this->unk_1B4, 0.0f, 0.2f, 2.0f, 0.01f); + Math_SmoothStepToF(&this->unk_1B8, 255.0f, 0.1f, 1.0f, 0.01f); + + tempS = D_808BC000; + if (1) {} + temp_f0 = 1.0f - ((f32)(D_808BC000 - this->unk_1D0) / ((D_808BC000 - tempS) + 100)); + if (temp_f0 > 0.0f) { + 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.unk_8C.fogNear = -500.0f * temp_f0; + if (globalCtx->envCtx.unk_8C.fogNear < -300) { + globalCtx->roomCtx.currRoom.segment = NULL; + } + } +} + +void func_808BAAF4(DoorWarp1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 cutscene; + f32 phi_f2; + + phi_f2 = 200.0f; + if (globalCtx->sceneNum == SCENE_SEA) { + phi_f2 = 85.0f; + } + + if (!(gSaveContext.weekEventReg[86] & 0x80) && (fabsf(this->dyna.actor.xzDistToPlayer) < phi_f2) && + ((player->actor.world.pos.y - 20.0f) < this->dyna.actor.world.pos.y) && + (this->dyna.actor.world.pos.y < (player->actor.world.pos.y + 20.0f))) { + cutscene = this->dyna.actor.cutscene; + + if (ActorCutscene_GetCanPlayNext(cutscene)) { + ActorCutscene_Start(cutscene, &this->dyna.actor); + gSaveContext.weekEventReg[86] |= 0x80; + DoorWarp1_SetupAction(this, func_808BABF4); + } else { + ActorCutscene_SetIntentToPlay(cutscene); + } + } +} + +void func_808BABF4(DoorWarp1* this, GlobalContext* globalCtx) { +} + +void DoorWarp1_Update(Actor* thisx, GlobalContext* globalCtx) { + DoorWarp1* this = THIS; + + if (this->unk_203 == 0) { + this->unk_204 = 1.0f; + } + + if ((this->unk_1A0 != NULL) && (this->unk_1A0->unk_15C != this->unk_204)) { + this->unk_1A0->actor.world.pos.y = this->dyna.actor.world.pos.y; + this->unk_1A0->unk_158 = this->dyna.actor.world.pos.y; + this->unk_1A0->unk_15C = this->unk_204; + } + + this->actionFunc(this, globalCtx); + + if (DOORWARP1_GET_FF(&this->dyna.actor) < ENDOORWARP1_FF_2) { + Actor_SetScale(&this->dyna.actor, this->unk_1C4 / 100.0f); + } +} + +void func_808BACCC(DoorWarp1* this, GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0xFF, 0xFF, 200, 255, 255, (u8)this->unk_1B8); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, (u8)this->unk_1B8); + + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, + &this->dyna.actor, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + SkelAnime_Update(&this->skelAnime); +} + +void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + s32 sp94 = globalCtx->state.frames * 10; + f32 sp90; + f32 sp8C; + f32 phi_f12; + f32 sp84; + + if (this->unk_1A4 >= 1.0f) { + sp90 = 0.0f; + } else { + sp90 = 1.0f - this->unk_1A4; + } + + if (this->unk_1A8 >= 1.0f) { + sp8C = 0.0f; + } else { + sp8C = 1.0f - this->unk_1A8; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp84 = 1.0f - ((2.0f - this->unk_1A4) / 1.7f); + this->unk_1AC += sp84 * 15.0f; + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255.0f * sp84, 255, 255, (u8)this->unk_1B4); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255.0f * sp84, 255, 255); + + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 1.0f, + this->dyna.actor.world.pos.z, MTXMODE_NEW); + phi_f12 = 1.0f; + if (this->unk_203 != 0) { + phi_f12 = this->unk_204 * phi_f12; + } + Matrix_Scale(phi_f12, phi_f12, phi_f12, MTXMODE_APPLY); + + gSPSegment(POLY_XLU_DISP++, 0x0A, Matrix_NewMtx(globalCtx->state.gfxCtx)); + Matrix_StatePush(); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, sp94 & 0xFF, -((s16)(2.0f * this->unk_1AC) & 0x1FF), 0x100, + 0x100, 1, sp94 & 0xFF, -((s16)(2.0f * this->unk_1AC) & 0x1FF), 0x100, 0x100)); + + Matrix_InsertTranslation(0.0f, this->unk_1A4 * 230.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(((this->unk_1C6 * sp90) / 100.0f) + 1.0f, 1.0f, ((this->unk_1C6 * sp90) / 100.0f) + 1.0f, + MTXMODE_APPLY); + + gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(globalCtx->state.gfxCtx)); + gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_0001A0); + + Matrix_StatePop(); + + if (this->unk_1B0 > 0.0f) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255.0f * sp84, 255, 255, (u8)this->unk_1B0); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255.0f * sp84, 255, 255); + + sp94 *= 2; + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, sp94 & 0xFF, -((s16)this->unk_1AC & 0x1FF), 0x100, + 0x100, 1, sp94 & 0xFF, -((s16)this->unk_1AC & 0x1FF), 0x100, 0x100)); + + Matrix_InsertTranslation(0.0f, this->unk_1A8 * 60.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(((this->unk_1C8 * sp8C) / 100.0f) + 1.0f, 1.0f, ((this->unk_1C8 * sp8C) / 100.0f) + 1.0f, + MTXMODE_APPLY); + + gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(globalCtx->state.gfxCtx)); + gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_0001A0); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_808BB4C4(DoorWarp1* this, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_warp1_DL_0076C0); +} + +#ifdef NON_MATCHING +// GraphicsContext should be compiler-managed? +void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + GraphicsContext* gfxCtx; + Color_RGB8 sp64[] = { + { 50, 150, 0 }, + { 100, 150, 200 }, + { 0, 50, 200 }, + { 120, 150, 0 }, + }; + s32 sp60 = 0; + + if (this->unk_1D4 != 0) { + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + this->unk_1A4, + this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(4.0f, this->unk_1AC, 4.0f, MTXMODE_APPLY); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_warp1_Matanimheader_0044D8)); + Gfx_DrawDListXlu(globalCtx, object_warp1_DL_003230); + return; + } + + if (globalCtx->sceneNum != SCENE_MITURIN) { + if (globalCtx->sceneNum == SCENE_HAKUGIN) { + sp60 = 1; + } else if (globalCtx->sceneNum == SCENE_SEA) { + sp60 = 2; + } else if (globalCtx->sceneNum == SCENE_INISIE_R) { + sp60 = 3; + } + } + + 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.world.rot.y, MTXMODE_APPLY); + Matrix_Scale(1.0f, this->unk_1A8, 1.0f, MTXMODE_APPLY); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_warp1_Matanimheader_0057D8)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_XLU_DISP++, sp64[sp60].r, sp64[sp60].g, sp64[sp60].b, 255); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_004690); + gfxCtx = globalCtx->state.gfxCtx; + + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_warp1_Matanimheader_007238)); + 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.world.rot.y, MTXMODE_APPLY); + Matrix_Scale(1.0f, 0.0f, 1.0f, MTXMODE_APPLY); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + OPEN_DISPS(gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_XLU_DISP++, sp64[sp60].r, sp64[sp60].g, sp64[sp60].b, 255); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->unk_203); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_0058C8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} +#else +static Color_RGB8 D_808BBB50[] = { + { 50, 150, 0 }, + { 100, 150, 200 }, + { 0, 50, 200 }, + { 120, 150, 0 }, +}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BB4F4.s") #endif -extern UNK_TYPE D_060001A0; -extern UNK_TYPE D_06001374; -extern UNK_TYPE D_060044D8; -extern UNK_TYPE D_060076C0; -extern UNK_TYPE D_06008BD4; +void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx) { + DoorWarp1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/DoorWarp1_SetupAction.s") + switch (DOORWARP1_GET_FF(&this->dyna.actor)) { + case ENDOORWARP1_FF_0: + func_808BAE9C(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B849C.s") + case ENDOORWARP1_FF_1: + func_808BACCC(this, globalCtx); + func_808BAE9C(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B8568.s") + case ENDOORWARP1_FF_2: + case ENDOORWARP1_FF_3: + case ENDOORWARP1_FF_4: + case ENDOORWARP1_FF_5: + func_808BB4C4(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B866C.s") + case ENDOORWARP1_FF_6: + func_808BB4F4(this, globalCtx); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/DoorWarp1_Init.s") +#ifdef NON_MATCHING +// casting/macro on temp_s1/s0 +void func_808BB8D4(DoorWarp1* this, GlobalContext* globalCtx, s32 arg2) { + static Vec3f D_808BBB5C = { 0.0f, 0.05f, 0.0f }; + static Vec3f D_808BBB68 = { 0.0f, 0.25f, 0.0f }; + Vec3f sp9C; + Color_RGBA8 sp98; + Color_RGBA8 sp94; + s32 i; + s16 temp_s0; + s32 temp_s1; + s32 phi_s2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/DoorWarp1_Destroy.s") + for (i = 0; i < arg2; i++) { + temp_s1 = (Rand_ZeroOne() * 0x10000); + temp_s0 = temp_s1 - 0x8000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B8924.s") + sp9C.x = (-Math_SinS(temp_s0) * 35.0f) + this->dyna.actor.world.pos.x; + sp9C.y = this->dyna.actor.world.pos.y; + temp_s0 = (s16)(temp_s1 - 0x8000); + sp9C.z = Math_CosS(temp_s0) * 35.0f + this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B8A7C.s") + D_808BBB5C.x = 0.0f; + D_808BBB68.y = 0.25f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B8C48.s") + sp98.r = 255; + sp98.g = 255; + sp98.b = 255; + sp94.r = 200; + sp94.g = 200; + sp94.b = 255; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B8E78.s") + D_808BBB5C.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B900C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B9094.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B90CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B921C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B93A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B94A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B9524.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B958C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B96A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B96B0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B977C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B9840.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B98A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B9B30.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B9BE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B9CE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B9E94.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B9ED8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B9F10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808B9FD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BA10C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BA550.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BAAF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BABF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/DoorWarp1_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BACCC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BAE9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BB4C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BB4F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/DoorWarp1_Draw.s") + temp_s1 = (s16)((Rand_ZeroOne() * 1000.0f) + 800.0f); + phi_s2 = 27; + if (arg2 >= 2) { + phi_s2 = 8; + D_808BBB68.y = 1.8f; + D_808BBB5C.x = -Math_SinS(temp_s0) * 5.0f; + D_808BBB5C.z = Math_CosS(temp_s0) * 5.0f; + } + EffectSsKiraKira_SpawnDispersed(globalCtx, &sp9C, &D_808BBB5C, &D_808BBB68, &sp98, &sp94, temp_s1, phi_s2); + } +} +#else +static Vec3f D_808BBB5C = { 0.0f, 0.05f, 0.0f }; +static Vec3f D_808BBB68 = { 0.0f, 0.25f, 0.0f }; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BB8D4.s") +#endif diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h index e7b67312e9..ca177006bd 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h @@ -2,19 +2,58 @@ #define Z_DOOR_WARP1_H #include "global.h" +#include "overlays/actors/ovl_Dm_Hina/z_dm_hina.h" struct DoorWarp1; typedef void (*DoorWarp1ActionFunc)(struct DoorWarp1*, GlobalContext*); +#define DOORWARP1_GET_FF(thisx) ((thisx)->params & 0xFF) +#define DOORWARP1_GET_FF00_1(thisx) (((thisx)->params >> 8) & 0xFF) +#define DOORWARP1_GET_FF00_2(thisx) ((thisx)->params & 0xFF00) +#define DOORWARP1_GET_FF00_3(thisx) ((thisx)->params >> 8) + +enum { + /* 0 */ ENDOORWARP1_FF_0, + /* 1 */ ENDOORWARP1_FF_1, + /* 2 */ ENDOORWARP1_FF_2, + /* 3 */ ENDOORWARP1_FF_3, + /* 4 */ ENDOORWARP1_FF_4, + /* 5 */ ENDOORWARP1_FF_5, + /* 6 */ ENDOORWARP1_FF_6, +}; + typedef struct DoorWarp1 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x94]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ SkelAnime skelAnime; + /* 0x01A0 */ DmHina* unk_1A0; + /* 0x01A4 */ f32 unk_1A4; + /* 0x01A8 */ f32 unk_1A8; + /* 0x01AC */ f32 unk_1AC; + /* 0x01B0 */ f32 unk_1B0; + /* 0x01B4 */ f32 unk_1B4; + /* 0x01B8 */ f32 unk_1B8; + /* 0x01BC */ f32 unk_1BC; + /* 0x01C0 */ f32 unk_1C0; + /* 0x01C4 */ s16 unk_1C4; + /* 0x01C6 */ s16 unk_1C6; + /* 0x01C8 */ s16 unk_1C8; + /* 0x01CA */ s16 unk_1CA; + /* 0x01CC */ s16 unk_1CC; + /* 0x01CE */ s16 unk_1CE; + /* 0x01D0 */ u16 unk_1D0; + /* 0x01D2 */ s8 unk_1D2; + /* 0x01D3 */ u8 unk_1D3; + /* 0x01D4 */ u8 unk_1D4; /* 0x01D8 */ DoorWarp1ActionFunc actionFunc; - /* 0x01DC */ char unk_1DC[0x27]; + /* 0x01DC */ LightNode* unk_1DC; + /* 0x01E0 */ LightInfo unk_1E0; + /* 0x01F0 */ LightNode* unk_1F0; + /* 0x01F4 */ LightInfo unk_1F4; + /* 0x0202 */ u8 unk_202; /* 0x0203 */ u8 unk_203; /* 0x0204 */ f32 unk_204; - /* 0x0208 */ char unk_208[0x4]; + /* 0x0208 */ u8 unk_208; } DoorWarp1; // size = 0x20C extern const ActorInit Door_Warp1_InitVars; 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 296d6e429f..697ea58e8f 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -5,6 +5,7 @@ */ #include "z_eff_dust.h" +#include "system_malloc.h" #define FLAGS 0x00000030 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 f2590f255b..a638422bff 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -5,6 +5,7 @@ */ #include "z_en_akindonuts.h" +#include "objects/object_dnt/object_dnt.h" #define FLAGS 0x00000039 @@ -15,7 +16,21 @@ void EnAkindonuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnAkindonuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnAkindonuts_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BEEDC0(EnAkindonuts* this, GlobalContext* globalCtx); +void func_80BEEE10(EnAkindonuts* this, GlobalContext* globalCtx); +void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx); +void func_80BEF18C(EnAkindonuts* this, GlobalContext* globalCtx); +void func_80BEF20C(EnAkindonuts* this, GlobalContext* globalCtx); +void func_80BEF360(EnAkindonuts* this, GlobalContext* globalCtx); +void func_80BEF450(EnAkindonuts* this, GlobalContext* globalCtx); +void func_80BEF4B8(EnAkindonuts* this, GlobalContext* globalCtx); +void func_80BEF518(EnAkindonuts* this, GlobalContext* globalCtx); +void func_80BEF770(EnAkindonuts* this, GlobalContext* globalCtx); +void func_80BEF83C(EnAkindonuts* this, GlobalContext* globalCtx); +void func_80BEF9F0(EnAkindonuts* this, GlobalContext* globalCtx); +void func_80BEFAF0(EnAkindonuts* this, GlobalContext* globalCtx); +void func_80BEFD74(EnAkindonuts* this, GlobalContext* globalCtx); + const ActorInit En_Akindonuts_InitVars = { ACTOR_EN_AKINDONUTS, ACTORCAT_NPC, @@ -28,113 +43,1659 @@ const ActorInit En_Akindonuts_InitVars = { (ActorFunc)EnAkindonuts_Draw, }; -// static ColliderCylinderInitType1 sCylinderInit = { -static ColliderCylinderInitType1 D_80BF02F0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 27, 32, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BF04B4[] = { +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 u16 D_80BF048C[] = { + 0x15E4, + 0x15F8, + 0x1609, + 0x161D, +}; + +static u16 D_80BF0494[] = { + 0x15E3, + 0x15F9, + 0x160A, + 0x161E, +}; + +static u16 D_80BF049C[] = { + 0x15E3, + 0x15F7, + 0x160C, + 0x161F, +}; + +static u16 D_80BF04A4[] = { + 0x15E3, + 0x15F7, + 0x160B, + 0x1621, +}; + +static u16 D_80BF04AC[] = { + 0x15E3, + 0x15F7, + 0x160B, + 0x1620, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 0, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), }; -#endif +void func_80BECBE0(EnAkindonuts* this, s16 arg1) { + f32 sp24 = Math_CosS(this->actor.world.rot.x) * this->actor.speedXZ; -extern ColliderCylinderInit D_80BF02F0; -extern InitChainEntry D_80BF04B4[]; + this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * sp24; + this->actor.velocity.y = Math_SinS(this->actor.world.rot.x) * this->actor.speedXZ; + this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * sp24; -extern UNK_TYPE D_06001350; -extern UNK_TYPE D_06005488; + if (arg1) { + this->actor.velocity.x = 0.0f; + this->actor.velocity.z = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BECBE0.s") + Actor_UpdatePos(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BECC7C.s") +void func_80BECC7C(EnAkindonuts* this, GlobalContext* globalCtx) { + if (this->unk_32C & 4) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BECD10.s") + if (this->unk_32C & 2) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 20.0f, 5); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BECEAC.s") +s32 func_80BECD10(EnAkindonuts* 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; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BECF6C.s") + Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BECFBC.s") + 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; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BED034.s") + 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; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BED090.s") + return sp50; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BED140.s") +f32 func_80BECEAC(Path* path, s32 arg1, Vec3f* pos, Vec3s* arg3) { + Vec3s* temp; + Vec3f sp20; + Vec3s* point; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BED208.s") + if (path != NULL) { + temp = Lib_SegmentedToVirtual(path->points); + point = &temp[arg1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BED27C.s") + sp20.x = point->x; + sp20.y = point->y; + sp20.z = point->z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BED2FC.s") + arg3->y = Math_Vec3f_Yaw(pos, &sp20); + arg3->x = Math_Vec3f_Pitch(pos, &sp20); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BED35C.s") + return sp20.y - pos->y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BED3BC.s") +s16 func_80BECF6C(Path* path) { + Vec3s* sp34 = Lib_SegmentedToVirtual(path->points); + Vec3f sp28; + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BED680.s") + Math_Vec3s_ToVec3f(&sp28, &sp34[0]); + Math_Vec3s_ToVec3f(&sp1C, &sp34[1]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BED8A4.s") + return Math_Vec3f_Yaw(&sp28, &sp1C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEDB88.s") +s32 func_80BECFBC(EnAkindonuts* this) { + switch (ENAKINDONUTS_GET_3(&this->actor)) { + case 0: + return 0x98; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEDDAC.s") + case 1: + return 0x99; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEE070.s") + case 2: + return 0x9A; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEE274.s") + case 3: + func_801149A0(ITEM_DEED_OCEAN, SLOT(ITEM_DEED_OCEAN)); + return 0x7; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEE530.s") +s32 func_80BED034(EnAkindonuts* this) { + switch (ENAKINDONUTS_GET_3(&this->actor)) { + case 0: + return 0x35; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEE73C.s") + case 1: + return 0x1D; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEE938.s") + case 2: + return 0x5C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEEB20.s") + case 3: + return 0x5D; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEEDC0.s") +void func_80BED090(GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEEE10.s") + if (player->transformation == PLAYER_FORM_DEKU) { + gSaveContext.weekEventReg[63] |= 0x8; + gSaveContext.weekEventReg[63] &= (u8)~0x10; + } else if (player->transformation == PLAYER_FORM_ZORA) { + gSaveContext.weekEventReg[63] &= (u8)~0x8; + gSaveContext.weekEventReg[63] |= 0x10; + } else if (player->transformation == PLAYER_FORM_GORON) { + gSaveContext.weekEventReg[63] |= 0x8; + gSaveContext.weekEventReg[63] |= 0x10; + } else if (player->transformation == PLAYER_FORM_HUMAN) { + gSaveContext.weekEventReg[63] &= (u8)~0x8; + gSaveContext.weekEventReg[63] &= (u8)~0x10; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEEFA8.s") +s32 func_80BED140(GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEF18C.s") + if (player->transformation == PLAYER_FORM_DEKU) { + if ((gSaveContext.weekEventReg[63] & 0x8) && !(gSaveContext.weekEventReg[63] & 0x10)) { + return true; + } + } else if (player->transformation == PLAYER_FORM_ZORA) { + if (!(gSaveContext.weekEventReg[63] & 0x8) && (gSaveContext.weekEventReg[63] & 0x10)) { + return true; + } + } else if (player->transformation == PLAYER_FORM_GORON) { + if ((gSaveContext.weekEventReg[63] & 0x8) && (gSaveContext.weekEventReg[63] & 0x10)) { + return true; + } + } else if (player->transformation == PLAYER_FORM_HUMAN) { + if (!(gSaveContext.weekEventReg[63] & 0x8) && !(gSaveContext.weekEventReg[63] & 0x10)) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEF20C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEF360.s") +s32 func_80BED208(EnAkindonuts* this) { + if (INV_CONTENT(ITEM_MAGIC_BEANS) != 10U) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEF450.s") + if (gSaveContext.rupees < 10) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEF4B8.s") + if (AMMO(ITEM_MAGIC_BEANS) >= 20) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEF518.s") + this->unk_364 = -10; + this->unk_366 = 10; + return 3; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEF770.s") +s32 func_80BED27C(EnAkindonuts* this) { + if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 3) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEF83C.s") + if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) < 2) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEF9F0.s") + if (gSaveContext.rupees < 200) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEFAF0.s") + this->unk_364 = -200; + this->unk_366 = 88; + return 3; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEFD74.s") +s32 func_80BED2FC(EnAkindonuts* this) { + if (!func_80114E90()) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/EnAkindonuts_Init.s") + if (gSaveContext.rupees < 40) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/EnAkindonuts_Destroy.s") + this->unk_364 = -40; + this->unk_366 = 20; + return 3; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/EnAkindonuts_Update.s") +s32 func_80BED35C(EnAkindonuts* this) { + if (!func_80114E90()) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BEFFB4.s") + if (gSaveContext.rupees < 100) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BF0178.s") + this->unk_364 = -100; + this->unk_366 = 21; + return 3; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/func_80BF0190.s") +void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Akindonuts/EnAkindonuts_Draw.s") + switch (this->unk_33C) { + case 0: + if (player->transformation != PLAYER_FORM_DEKU) { + this->unk_33C = 0x15E0; + break; + } + this->unk_33C = 0x15E7; + break; + + case 0x15E0: + this->unk_33C = 0x15E1; + break; + + case 0x15E1: + this->unk_33C = 0x15E2; + break; + + case 0x15E2: + this->unk_33C = 0xFF; + break; + + case 0x15E7: + if (!(gSaveContext.weekEventReg[61] & 0x20)) { + gSaveContext.weekEventReg[61] |= 0x20; + this->unk_33C = 0x15E8; + break; + } + this->unk_33C = 0x15E9; + break; + + case 0x15E8: + this->unk_33C = 0x15E9; + break; + + case 0x15E9: + this->unk_33C = 0x15EA; + break; + + case 0x15EA: + this->unk_32C |= 0x1; + if (this->unk_32C & 8) { + this->unk_32C &= ~8; + + switch (func_80BED208(this)) { + case 0: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x15EC; + break; + + case 1: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x15ED; + break; + + case 2: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x15EE; + break; + + case 3: + func_8019F208(); + this->unk_32C &= ~0x1; + this->unk_32C |= 0x40; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_33C = 0x15EF; + this->actionFunc = func_80BEF360; + return; + } + } else if (this->unk_32C & 0x10) { + this->unk_32C &= ~0x10; + this->unk_33C = 0x15EB; + break; + } + break; + + case 0x15E4: + this->unk_33C = 0x15E5; + this->unk_32C |= 1; + break; + + case 0x15E5: + this->unk_33C = 0x15E6; + func_80BED090(globalCtx); + gSaveContext.weekEventReg[61] |= 0x10; + this->unk_32C |= 0x20; + break; + + case 0x15EF: + this->unk_32C |= 1; + break; + } + + func_801518B0(globalCtx, this->unk_33C, &this->actor); +} + +void func_80BED680(EnAkindonuts* this, GlobalContext* globalCtx) { + switch (this->unk_33C) { + case 0: + if (func_80BED140(globalCtx) && !(gSaveContext.weekEventReg[61] & 0x40)) { + gSaveContext.weekEventReg[61] |= 0x40; + this->unk_33C = 0x15F0; + break; + } + + this->unk_33C = 0x15F2; + break; + + case 0x15F0: + this->unk_33C = 0x15F1; + break; + + case 0x15F1: + case 0x15F2: + this->unk_33C = 0x15F3; + break; + + case 0x15F3: + this->unk_33C = 0x15EA; + break; + + case 0x15EA: + this->unk_32C |= 1; + if (this->unk_32C & 8) { + this->unk_32C &= ~8; + + switch (func_80BED208(this)) { + case 0: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x15EC; + break; + + case 1: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x15ED; + break; + + case 2: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x15EE; + break; + + case 3: + func_8019F208(); + this->unk_32C |= 0x40; + this->unk_32C &= ~0x1; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_33C = 0x15EF; + this->actionFunc = func_80BEF360; + return; + } + } else if (this->unk_32C & 0x10) { + this->unk_32C &= ~0x10; + this->unk_33C = 0x15EB; + break; + } + break; + + case 0x15EF: + this->unk_32C |= 1; + break; + } + + func_801518B0(globalCtx, this->unk_33C, &this->actor); +} + +void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (this->unk_33C) { + case 0: + if (player->transformation == PLAYER_FORM_DEKU) { + this->unk_33C = 0x15F4; + break; + } else if (player->transformation == PLAYER_FORM_GORON) { + this->unk_33C = 0x15FE; + break; + } + this->unk_33C = 0x15FC; + break; + + case 0x15F4: + this->unk_33C = 0x15F5; + break; + + case 0x15F5: + this->unk_33C = 0x15F6; + break; + + case 0x15F6: + this->unk_33C = 0xFF; + break; + + case 0x15FC: + this->unk_33C = 0x15FD; + this->unk_32C |= 1; + break; + + case 0x15FE: + if (!(gSaveContext.weekEventReg[62] & 1)) { + gSaveContext.weekEventReg[62] |= 1; + this->unk_33C = 0x15FF; + break; + } + this->unk_33C = 0x1600; + break; + + case 0x15FF: + this->unk_33C = 0x1600; + break; + + case 0x1600: + this->unk_33C = 0x15EA; + break; + + case 0x15EA: + this->unk_32C |= 0x1; + if (this->unk_32C & 8) { + this->unk_32C &= ~8; + + switch (func_80BED27C(this)) { + case 2: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x1601; + break; + + case 0: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x1602; + break; + + case 1: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x1603; + break; + + case 3: + func_8019F208(); + this->unk_32C |= 0x40; + this->unk_32C &= ~0x1; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_33C = 0x15EF; + this->actionFunc = func_80BEF360; + return; + } + } else if (this->unk_32C & 0x10) { + this->unk_32C &= ~0x10; + this->unk_33C = 0x1604; + break; + } + break; + + case 0x15F9: + this->unk_33C = 0x15FA; + this->unk_32C |= 1; + break; + + case 0x15FA: + this->unk_33C = 0x15FB; + gSaveContext.weekEventReg[61] |= 0x80; + this->unk_32C |= 0x20; + break; + + case 0x15EF: + this->unk_32C |= 1; + break; + } + + func_801518B0(globalCtx, this->unk_33C, &this->actor); +} + +void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (this->unk_33C) { + case 0: + if ((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.weekEventReg[62] & 2)) { + gSaveContext.weekEventReg[62] |= 0x2; + this->unk_33C = 0x15F0; + break; + } + this->unk_33C = 0x15F2; + break; + + case 0x15F0: + this->unk_33C = 0x1605; + break; + + case 0x15F2: + case 0x1605: + this->unk_33C = 0x1606; + break; + + case 0x1606: + this->unk_33C = 0x15EA; + break; + + case 0x15EA: + this->unk_32C |= 0x1; + if (this->unk_32C & 8) { + this->unk_32C &= ~8; + + switch (func_80BED27C(this)) { + case 2: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x1601; + break; + + case 0: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x1602; + break; + + case 1: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x1603; + break; + + case 3: + func_8019F208(); + this->unk_32C |= 0x40; + this->unk_32C &= ~0x1; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_33C = 0x15EF; + this->actionFunc = func_80BEF360; + return; + } + } else if (this->unk_32C & 0x10) { + this->unk_32C &= ~0x10; + this->unk_33C = 0x15EB; + break; + } + break; + + case 0x15EF: + this->unk_32C |= 1; + break; + } + + func_801518B0(globalCtx, this->unk_33C, &this->actor); +} + +void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (this->unk_33C) { + case 0: + if (player->transformation == PLAYER_FORM_GORON) { + this->unk_33C = 0x1607; + break; + } else if (player->transformation == PLAYER_FORM_ZORA) { + this->unk_33C = 0x1610; + break; + } + this->unk_33C = 0x160E; + break; + + case 0x1607: + this->unk_33C = 0x1608; + break; + + case 0x1608: + this->unk_33C = 0x15E2; + break; + + case 0x15E2: + this->unk_33C = 0xFF; + break; + + case 0x160E: + this->unk_33C = 0x160F; + this->unk_32C |= 1; + break; + + case 0x1610: + if (!(gSaveContext.weekEventReg[62] & 8)) { + gSaveContext.weekEventReg[62] |= 8; + this->unk_33C = 0x1611; + break; + } + this->unk_33C = 0x1612; + break; + + case 0x1611: + this->unk_33C = 0x1612; + break; + + case 0x1612: + this->unk_33C = 0x15EA; + break; + + case 0x15EA: + this->unk_32C |= 0x1; + if (this->unk_32C & 0x8) { + this->unk_32C &= ~8; + + switch (func_80BED2FC(this)) { + case 2: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x1613; + break; + + case 1: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x15ED; + break; + + case 3: + func_8019F208(); + this->unk_32C |= 0x40; + this->unk_32C &= ~0x1; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_33C = 0x15EF; + this->actionFunc = func_80BEF360; + return; + } + } else if (this->unk_32C & 0x10) { + this->unk_32C &= ~0x10; + this->unk_33C = 0x15EB; + break; + } + break; + + case 0x160C: + this->unk_33C = 0x15FA; + this->unk_32C |= 1; + break; + + case 0x15FA: + this->unk_33C = 0x160D; + gSaveContext.weekEventReg[62] |= 0x4; + this->unk_32C |= 0x20; + break; + + case 0x15EF: + this->unk_32C |= 1; + break; + } + + func_801518B0(globalCtx, this->unk_33C, &this->actor); +} + +void func_80BEE070(EnAkindonuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (this->unk_33C) { + case 0: + if ((player->transformation == PLAYER_FORM_GORON) && !(gSaveContext.weekEventReg[62] & 0x10)) { + gSaveContext.weekEventReg[62] |= 0x10; + this->unk_33C = 0x1614; + break; + } + this->unk_33C = 0x1616; + break; + + case 0x1614: + this->unk_33C = 0x1615; + break; + + case 0x1615: + case 0x1616: + this->unk_33C = 0x1617; + break; + + case 0x1617: + this->unk_33C = 0x1618; + break; + + case 0x1618: + this->unk_32C |= 0x1; + if (this->unk_32C & 0x8) { + this->unk_32C &= ~8; + + switch (func_80BED2FC(this)) { + case 2: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x1613; + break; + + case 1: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x15ED; + break; + + case 3: + func_8019F208(); + this->unk_32C |= 0x40; + this->unk_32C &= ~0x1; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_33C = 0x161A; + this->actionFunc = func_80BEF360; + return; + } + } else if (this->unk_32C & 0x10) { + this->unk_32C &= ~0x10; + this->unk_33C = 0x1619; + break; + } + break; + + case 0x161A: + this->unk_32C |= 1; + break; + } + + func_801518B0(globalCtx, this->unk_33C, &this->actor); +} + +void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (this->unk_33C) { + case 0: + if (player->transformation == PLAYER_FORM_ZORA) { + this->unk_33C = 0x161B; + break; + } + this->unk_33C = 0x1624; + break; + + case 0x161B: + this->unk_33C = 0x161C; + break; + + case 0x161C: + this->unk_33C = 0x15E2; + break; + + case 0x15E2: + this->unk_33C = 0xFF; + break; + + case 0x1624: + if (!(gSaveContext.weekEventReg[62] & 0x40)) { + gSaveContext.weekEventReg[62] |= 0x40; + this->unk_33C = 0x1625; + break; + } + this->unk_33C = 0x1627; + break; + + case 0x1625: + case 0x1627: + this->unk_33C = 0x1626; + break; + + case 0x1626: + this->unk_33C = 0x15EA; + break; + + case 0x15EA: + this->unk_32C |= 0x1; + if (this->unk_32C & 0x8) { + this->unk_32C &= ~8; + + switch (func_80BED35C(this)) { + case 2: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x1613; + break; + + case 1: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x15ED; + break; + + case 3: + func_8019F208(); + this->unk_32C |= 0x40; + this->unk_32C &= ~0x1; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_33C = 0x1629; + this->actionFunc = func_80BEF360; + return; + } + } else if (this->unk_32C & 0x10) { + this->unk_32C &= ~0x10; + this->unk_33C = 0x1628; + break; + } + break; + + case 0x1621: + this->unk_33C = 0x1622; + this->unk_32C |= 1; + break; + + case 0x1622: + this->unk_33C = 0x1623; + gSaveContext.weekEventReg[62] |= 0x20; + this->unk_32C |= 0x20; + break; + + case 0x1629: + this->unk_32C |= 1; + break; + } + + func_801518B0(globalCtx, this->unk_33C, &this->actor); +} + +void func_80BEE530(EnAkindonuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (this->unk_33C) { + case 0: + if ((player->transformation == PLAYER_FORM_ZORA) && !(gSaveContext.weekEventReg[62] & 0x80)) { + gSaveContext.weekEventReg[62] |= 0x80; + this->unk_33C = 0x162A; + break; + } + this->unk_33C = 0x162C; + break; + + case 0x162A: + this->unk_33C = 0x162B; + break; + + case 0x162B: + case 0x162C: + this->unk_33C = 0x162D; + break; + + case 0x162D: + this->unk_33C = 0x15EA; + break; + + case 0x15EA: + this->unk_32C |= 0x1; + if (this->unk_32C & 0x8) { + this->unk_32C &= ~8; + + switch (func_80BED35C(this)) { + case 2: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x1613; + break; + + case 1: + play_sound(NA_SE_SY_ERROR); + this->unk_33C = 0x15ED; + break; + + case 3: + func_8019F208(); + this->unk_32C |= 0x40; + this->unk_32C &= ~0x1; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_33C = 0x15EF; + this->actionFunc = func_80BEF360; + return; + } + } else if (this->unk_32C & 0x10) { + this->unk_32C &= ~0x10; + this->unk_33C = 0x162E; + break; + } + break; + + case 0x15EF: + this->unk_32C |= 1; + break; + } + + func_801518B0(globalCtx, this->unk_33C, &this->actor); +} + +void func_80BEE73C(EnAkindonuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s32 params = ENAKINDONUTS_GET_3(&this->actor); + s32 itemActionParam = func_80123810(globalCtx); + + if (itemActionParam > PLAYER_AP_NONE) { + if (itemActionParam == PLAYER_AP_DEED_LAND) { + player->actor.textId = D_80BF048C[params]; + this->unk_33C = player->actor.textId; + if (this->unk_33C == 0x15E4) { + player->exchangeItemId = itemActionParam; + this->actionFunc = func_80BEF20C; + } else { + this->actionFunc = func_80BEF18C; + } + } else if (itemActionParam == PLAYER_AP_DEED_SWAMP) { + player->actor.textId = D_80BF0494[params]; + this->unk_33C = player->actor.textId; + if (this->unk_33C == 0x15F9) { + player->exchangeItemId = itemActionParam; + this->actionFunc = func_80BEF20C; + } else { + this->actionFunc = func_80BEF18C; + } + } else if (itemActionParam == PLAYER_AP_DEED_MOUNTAIN) { + player->actor.textId = D_80BF049C[params]; + this->unk_33C = player->actor.textId; + if (this->unk_33C == 0x160C) { + player->exchangeItemId = itemActionParam; + this->actionFunc = func_80BEF20C; + } else { + this->actionFunc = func_80BEF18C; + } + } else if (itemActionParam == PLAYER_AP_DEED_OCEAN) { + player->actor.textId = D_80BF04A4[params]; + this->unk_33C = player->actor.textId; + if (this->unk_33C == 0x1621) { + player->exchangeItemId = itemActionParam; + this->actionFunc = func_80BEF20C; + } else { + this->actionFunc = func_80BEF18C; + } + } else { + player->actor.textId = D_80BF04AC[params]; + this->unk_33C = player->actor.textId; + this->actionFunc = func_80BEF18C; + } + func_801477B4(globalCtx); + } else if (itemActionParam < PLAYER_AP_NONE) { + this->unk_33C = D_80BF04AC[params]; + func_80151938(globalCtx, this->unk_33C); + this->actionFunc = func_80BEF18C; + } +} + +void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { + switch (ENAKINDONUTS_GET_3(&this->actor)) { + case 0: + if (gSaveContext.weekEventReg[61] & 0x10) { + if (ENAKINDONUTS_GET_4(&this->actor)) { + this->unk_2DC = func_80BED680; + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (ENAKINDONUTS_GET_4(&this->actor)) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_2DC = func_80BED3BC; + } + break; + + case 1: + if (gSaveContext.weekEventReg[61] & 0x80) { + if (ENAKINDONUTS_GET_4(&this->actor)) { + this->unk_2DC = func_80BEDB88; + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (ENAKINDONUTS_GET_4(&this->actor)) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_2DC = func_80BED8A4; + } + break; + + case 2: + if (gSaveContext.weekEventReg[62] & 4) { + if (ENAKINDONUTS_GET_4(&this->actor)) { + this->unk_2DC = func_80BEE070; + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (ENAKINDONUTS_GET_4(&this->actor)) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_2DC = func_80BEDDAC; + } + break; + + case 3: + if (gSaveContext.weekEventReg[62] & 0x20) { + if (ENAKINDONUTS_GET_4(&this->actor)) { + this->unk_2DC = func_80BEE530; + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (ENAKINDONUTS_GET_4(&this->actor)) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_2DC = func_80BEE274; + } + break; + } +} + +void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { + s16 sp26 = this->skelAnime.curFrame; + s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + s16 phi_v0; + + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); + + if ((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (phi_v0) { + if (this->actor.xzDistToPlayer < 200.0f) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (phi_v0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + this->actionFunc = func_80BEEDC0; + this->unk_338 = 3; + this->collider.dim.height = 64; + func_8013BC6C(&this->skelAnime, sAnimations, 3); + return; + } + } + + if (sp26 == sp24) { + if ((this->unk_338 == 4) || (this->unk_338 == 18)) { + this->unk_338 = 17; + this->collider.dim.height = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + func_8013BC6C(&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); + } 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); + } + } else if (this->unk_338 == 16) { + phi_v0 = DECR(this->unk_33A); + if (phi_v0 == 0) { + this->unk_33A = Rand_S16Offset(40, 40); + this->unk_338 = 18; + this->collider.dim.height = 32; + func_8013BC6C(&this->skelAnime, sAnimations, 18); + } + } + } +} + +void func_80BEEDC0(EnAkindonuts* this, GlobalContext* globalCtx) { + if (this->skelAnime.curFrame == this->skelAnime.endFrame) { + this->actionFunc = func_80BEEE10; + func_8013BC6C(&this->skelAnime, sAnimations, 0); + } +} + +void func_80BEEE10(EnAkindonuts* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 2000, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2DC(this, globalCtx); + this->actionFunc = func_80BEEFA8; + } else if (((this->actor.xzDistToPlayer < 100.0f) && + (((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false)) || + this->actor.isTargeted) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } 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); + this->actionFunc = func_80BEEB20; + } +} + +void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (temp_v0 == 5) { + if (func_80147624(globalCtx)) { + if (this->unk_32C & 1) { + this->unk_32C &= ~0x1; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_33C = 0; + this->actionFunc = func_80BEEE10; + } else if (this->unk_32C & 0x20) { + this->unk_32C &= ~0x20; + this->actor.flags &= ~1; + this->unk_32C &= ~0x4; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_338 = 8; + this->unk_33C = 0; + func_8013BC6C(&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)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + this->unk_32C |= 0x8; + this->unk_2DC(this, globalCtx); + break; + + case 1: + func_8019F230(); + this->unk_32C |= 0x10; + this->unk_2DC(this, globalCtx); + break; + } + } + } else if (temp_v0 == 16) { + func_80BEE73C(this, globalCtx); + } +} + +void func_80BEF18C(EnAkindonuts* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_33C = 0; + this->actionFunc = func_80BEEE10; + } +} + +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); + + if (this->unk_356 == 40) { + this->unk_338 = 5; + func_8013BC6C(&this->skelAnime, sAnimations, 5); + } + + this->unk_356++; + + if ((sp24 == sp22) && (this->unk_338 == 5)) { + this->unk_338 = 6; + func_8013BC6C(&this->skelAnime, sAnimations, 6); + } + + if ((sp27 == 5) && func_80147624(globalCtx)) { + if (this->unk_32C & 1) { + this->unk_32C &= ~0x1; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80BEF360; + } else { + this->unk_2DC(this, globalCtx); + } + } +} + +void func_80BEF360(EnAkindonuts* this, GlobalContext* globalCtx) { + if (this->unk_32C & 0x40) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + func_801159EC(this->unk_364); + this->unk_32C &= ~0x40; + this->actionFunc = func_80BEF450; + } else { + Actor_PickUp(&this->actor, globalCtx, func_80BED034(this), 300.0f, 300.0f); + } + } else if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_80BEF450; + } else { + Actor_PickUp(&this->actor, globalCtx, func_80BECFBC(this), 300.0f, 300.0f); + } +} + +void func_80BEF450(EnAkindonuts* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + this->actionFunc = func_80BEF4B8; + } +} + +void func_80BEF4B8(EnAkindonuts* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2DC(this, globalCtx); + this->actionFunc = func_80BEEFA8; + } else { + func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + } +} + +void func_80BEF518(EnAkindonuts* this, GlobalContext* globalCtx) { + s16 sp26 = this->skelAnime.curFrame; + s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + + switch (sp26) { + case 10: + this->unk_33E = 1; + this->unk_340 = 0.1f; + this->unk_344 = 0.1f; + this->unk_348 = 0.1f; + break; + + case 11: + case 12: + this->unk_340 += 0.15f; + this->unk_344 += 0.32f; + this->unk_348 += 0.15f; + break; + + case 13: + this->unk_340 = 0.55f; + this->unk_344 = 1.05f; + this->unk_348 = 0.55f; + break; + + case 14: + this->unk_340 = 1.0f; + this->unk_344 = 2.0f; + this->unk_348 = 1.0f; + break; + + case 15: + case 16: + this->unk_344 -= 0.33f; + break; + + case 17: + this->unk_344 = 1.0f; + break; + + case 18: + case 19: + this->unk_344 += 0.27f; + break; + case 20: + this->unk_33E = 2; + this->unk_344 = 1.8f; + break; + + case 21: + case 22: + case 23: + this->unk_344 -= 0.2f; + break; + + case 24: + this->unk_344 = 1.0f; + break; + } + + if (this->unk_35E == 0) { + if (ActorCutscene_GetCanPlayNext(this->cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + this->unk_35E = 1; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); + return; + } + } + + if (sp26 == sp24) { + this->unk_33E = 3; + this->unk_338 = 19; + func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + this->unk_32C &= ~2; + this->unk_32C |= 0x80; + this->unk_358 = this->actor.world.pos.y; + this->actionFunc = func_80BEF770; + } +} + +void func_80BEF770(EnAkindonuts* this, GlobalContext* globalCtx) { + f32 sp24 = this->unk_358 - this->actor.world.pos.y; + Vec3f sp18; + + this->unk_352 += this->unk_362; + if (!(this->unk_35C & 3)) { + sp18.x = this->actor.world.pos.x; + sp18.y = this->unk_358; + sp18.z = this->actor.world.pos.z; + func_800B14D4(globalCtx, 20.0f, &sp18); + } + + if (sp24 > 5.0f) { + this->unk_33A = 50; + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + this->unk_368 = func_80BECF6C(this->path); + this->actionFunc = func_80BEF83C; + } +} + +void func_80BEF83C(EnAkindonuts* this, GlobalContext* globalCtx) { + Vec3f sp34; + s16 sp32 = this->skelAnime.curFrame; + s16 sp30 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + + if (sp32 == sp30) { + Math_SmoothStepToS(&this->unk_362, 0x1C71, 3, 0x100, 0); + this->unk_352 += this->unk_362; + this->actor.shape.yOffset = 1500.0f; + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_368, 3, 2000, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (DECR(this->unk_33A) == 0) { + if (!(this->unk_35C & 3)) { + sp34 = this->actor.world.pos; + func_800B14D4(globalCtx, 20.0f, &sp34); + } + this->actor.velocity.y = 5.0f; + } else if (!(this->unk_35C & 3)) { + sp34.x = this->actor.world.pos.x; + sp34.y = this->unk_358; + sp34.z = this->actor.world.pos.z; + func_800B14D4(globalCtx, 20.0f, &sp34); + } + 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); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + this->actionFunc = func_80BEF9F0; + } +} + +void func_80BEF9F0(EnAkindonuts* this, GlobalContext* globalCtx) { + this->unk_352 += this->unk_362; + if (this->unk_34C >= 1.0f) { + this->unk_34C = 1.0f; + this->actor.velocity.y = 5.0f; + } else { + this->actor.velocity.y = 5.0f; + this->unk_34C += 0.1f; + } + + 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); + if (ENAKINDONUTS_GET_3(&this->actor) == ENAKINDONUTS_3_2) { + this->unk_32C |= 0x2; + } + this->unk_356 = 0; + this->actionFunc = func_80BEFAF0; + } +} + +void func_80BEFAF0(EnAkindonuts* this, GlobalContext* globalCtx) { + Vec3s sp38; + f32 sp34; + s16 sp32 = false; + + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + + if (this->path != NULL) { + sp34 = func_80BECEAC(this->path, this->unk_334, &this->actor.world.pos, &sp38); + if (this->actor.bgCheckFlags & 0x8) { + sp38.y = this->actor.wallYaw; + } + + if (ENAKINDONUTS_GET_3(&this->actor) == ENAKINDONUTS_3_1) { + Math_SmoothStepToS(&this->actor.world.rot.y, sp38.y, 10, 1000, 0); + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, sp38.y, 10, 300, 0); + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + this->unk_350 = 0x1000; + this->unk_352 += this->unk_362; + this->actor.world.rot.x = -sp38.x; + + if (func_80BECD10(this, this->path, this->unk_334) && (sp34 < 10.0f)) { + if (this->unk_334 >= (this->path->count - 1)) { + ActorCutscene_Stop(this->cutscene); + this->actionFunc = func_80BEFD74; + } else { + this->unk_334++; + } + } + } else if (this->actor.playerHeightRel > 500.0f) { + ActorCutscene_Stop(this->cutscene); + this->actionFunc = func_80BEFD74; + } + + if (ENAKINDONUTS_GET_3(&this->actor) == ENAKINDONUTS_3_2) { + if (this->unk_334 >= 3) { + sp32 = true; + } + Math_ApproachF(&this->actor.speedXZ, 1.5f, 0.2f, 1.0f); + } else { + Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.2f, 1.0f); + } + + func_80BECBE0(this, sp32); + + if (this->unk_35E == 2) { + if (ActorCutscene_GetCanPlayNext(this->cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + this->unk_35E = 3; + } else { + ActorCutscene_SetIntentToPlay(this->cutscene); + return; + } + } else if ((this->unk_35E == 1) && (this->unk_356 == 20)) { + ActorCutscene_Stop(this->cutscene); + this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); + ActorCutscene_SetIntentToPlay(this->cutscene); + this->unk_35E = 2; + } + this->unk_356++; +} + +void func_80BEFD74(EnAkindonuts* this, GlobalContext* globalCtx) { + Actor_MarkForDeath(&this->actor); +} + +void EnAkindonuts_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnAkindonuts* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dnt_Skel_00AC70, &object_dnt_Anim_005488, this->jointTable, + this->morphTable, 28); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + Actor_SetScale(&this->actor, 0.01f); + + this->actor.colChkInfo.cylRadius = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.gravity = -1.0f; + + if (!ENAKINDONUTS_GET_4(&this->actor)) { + this->path = func_8013D648(globalCtx, ENAKINDONUTS_GET_FC00(&this->actor), 0x3F); + if (this->path == NULL) { + Actor_MarkForDeath(&this->actor); + return; + } + } + + func_8013BC6C(&this->skelAnime, sAnimations, 4); + this->unk_32C |= 0x2; + this->unk_32C |= 0x4; + this->unk_338 = 4; + this->cutscene = this->actor.cutscene; + func_80BEE938(this, globalCtx); + this->actionFunc = func_80BEEB20; +} + +void EnAkindonuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAkindonuts* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnAkindonuts_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAkindonuts* this = THIS; + + Actor_SetFocus(&this->actor, 60.0f); + SkelAnime_Update(&this->skelAnime); + Actor_MoveWithGravity(&this->actor); + + this->actionFunc(this, globalCtx); + + if (this->unk_32C & 0x80) { + func_800B9010(&this->actor, NA_SE_EN_AKINDO_FLY - SFX_FLAG); + } + func_80BECC7C(this, globalCtx); +} + +s32 EnAkindonuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnAkindonuts* this = THIS; + + if (((this->unk_338 == 4) && (this->unk_33E == 0)) || ((this->unk_338 == 8) && (this->unk_33E == 0)) || + (this->unk_338 == 18) || (this->unk_338 == 2) || (this->unk_338 == 3) || (this->unk_338 == 17) || + (this->unk_338 == 5) || (this->unk_338 == 6) || (this->unk_338 == 7) || (this->unk_338 == 16)) { + if ((limbIndex == 16) || (limbIndex == 21) || (limbIndex == 27) || (limbIndex == 23) || (limbIndex == 24) || + (limbIndex == 15)) { + *dList = NULL; + } + } else if ((this->unk_338 == 8) || (this->unk_338 == 19)) { + switch (this->unk_33E) { + case 1: + if ((limbIndex == 16) || (limbIndex == 21) || (limbIndex == 27) || (limbIndex == 25)) { + *dList = NULL; + } + break; + + case 2: + case 3: + if ((limbIndex == 16) || (limbIndex == 21) || (limbIndex == 27) || (limbIndex == 15) || + (limbIndex == 25)) { + *dList = NULL; + } + break; + } + } else if (((this->unk_338 == 9) || (this->unk_338 == 10)) && ((limbIndex == 15) || (limbIndex == 25))) { + *dList = NULL; + } + + if (limbIndex == 26) { + if ((this->unk_338 == 6) || (this->unk_338 == 5) || (this->unk_338 == 7)) { + *dList = object_dnt_DL_001350; + } else { + *dList = object_dnt_DL_008290; + } + } + return 0; +} + +void EnAkindonuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +void EnAkindonuts_UnkActorDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnAkindonuts* this = THIS; + + if (((this->unk_33E == 1) || (this->unk_33E == 2)) && ((limbIndex == 23) || (limbIndex == 24))) { + Matrix_Scale(this->unk_340, this->unk_344, this->unk_348, MTXMODE_APPLY); + } + + if ((this->unk_338 == 9) && ((limbIndex == 16) || (limbIndex == 21) || (limbIndex == 27))) { + Matrix_Scale(this->unk_34C, this->unk_34C, this->unk_34C, MTXMODE_APPLY); + } + + if (limbIndex == 24) { + Matrix_RotateY(this->unk_352, MTXMODE_APPLY); + } +} + +void EnAkindonuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAkindonuts* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnAkindonuts_OverrideLimbDraw, EnAkindonuts_PostLimbDraw, EnAkindonuts_UnkActorDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.h b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.h index 08efd89752..e5d134f454 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.h +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.h @@ -6,12 +6,48 @@ struct EnAkindonuts; typedef void (*EnAkindonutsActionFunc)(struct EnAkindonuts*, GlobalContext*); +typedef void (*EnAkindonutsUnkFunc)(struct EnAkindonuts*, GlobalContext*); + +#define ENAKINDONUTS_GET_3(thisx) ((thisx)->params & 3) +#define ENAKINDONUTS_GET_4(thisx) (((thisx)->params & 4) >> 2) +#define ENAKINDONUTS_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) + +enum { + /* 1 */ ENAKINDONUTS_3_1 = 1, + /* 2 */ ENAKINDONUTS_3_2, +}; typedef struct EnAkindonuts { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x194]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[28]; + /* 0x0230 */ Vec3s morphTable[28]; /* 0x02D8 */ EnAkindonutsActionFunc actionFunc; - /* 0x02DC */ char unk_2DC[0x90]; + /* 0x02DC */ EnAkindonutsUnkFunc unk_2DC; + /* 0x02E0 */ ColliderCylinder collider; + /* 0x032C */ u16 unk_32C; + /* 0x0330 */ Path* path; + /* 0x0334 */ s32 unk_334; + /* 0x0338 */ s16 unk_338; + /* 0x033A */ s16 unk_33A; + /* 0x033C */ u16 unk_33C; + /* 0x033E */ s16 unk_33E; + /* 0x0340 */ f32 unk_340; + /* 0x0344 */ f32 unk_344; + /* 0x0348 */ f32 unk_348; + /* 0x034C */ f32 unk_34C; + /* 0x0350 */ s16 unk_350; + /* 0x0352 */ s16 unk_352; + /* 0x0354 */ UNK_TYPE1 unk354[0x2]; + /* 0x0356 */ s16 unk_356; + /* 0x0358 */ f32 unk_358; + /* 0x035C */ s16 unk_35C; + /* 0x035E */ s16 unk_35E; + /* 0x0360 */ s16 cutscene; + /* 0x0362 */ s16 unk_362; + /* 0x0364 */ s16 unk_364; + /* 0x0366 */ s8 unk_366; + /* 0x0368 */ s16 unk_368; } EnAkindonuts; // size = 0x36C extern const ActorInit En_Akindonuts_InitVars; 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 e434c69c2e..4c7b1d6cb2 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -5,6 +5,9 @@ */ #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 @@ -28,8 +31,8 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx); void func_809C2BE4(EnAob01* this, GlobalContext* globalCtx); void func_809C2C9C(EnAob01* this, GlobalContext* globalCtx); void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx); +s32 func_809C2EC4(EnAob01* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Aob_01_InitVars = { ACTOR_EN_AOB_01, ACTORCAT_NPC, @@ -42,92 +45,1012 @@ const ActorInit En_Aob_01_InitVars = { (ActorFunc)EnAob01_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809C3820 = { - { 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 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 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 } }, }; -#endif +typedef struct { + Vec3f unk_00; + s16 unk_04; + s16 unk_06; +} EnAobStruct; -extern ColliderCylinderInit D_809C3820; +static EnAobStruct D_809C384C[] = { + { { -4130.0f, 150.0f, 1367.0f }, 84, 0 }, { { -4861.0f, 172.0f, 1606.0f }, 94, 4 }, + { { -4139.0f, 155.0f, 2133.0f }, 73, 6 }, { { -4406.0f, 144.0f, 1416.0f }, 88, 2 }, + { { -4156.0f, 155.0f, 1731.0f }, 42, 0 }, { { -4033.0f, 157.0f, 1994.0f }, -65, 1 }, + { { -4582.0f, 158.0f, 1206.0f }, 144, 2 }, { { -4595.0f, 156.0f, 1493.0f }, 61, 3 }, + { { -4526.0f, 146.0f, 1702.0f }, 61, 4 }, { { -3820.0f, 162.0f, 1965.0f }, 109, 5 }, + { { -4395.0f, 147.0f, 1569.0f }, -24, 0 }, { { -4315.0f, 150.0f, 2048.0f }, 61, 6 }, + { { -4827.0f, 168.0f, 1328.0f }, 115, 4 }, { { -4130.0f, 150.0f, 1367.0f }, 112, 0 }, +}; -extern UNK_TYPE D_06000180; -extern UNK_TYPE D_06003D18; +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); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C10B0.s") +void func_809C1124(void) { + u16 time = gSaveContext.time; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C1124.s") + gSaveContext.time = (u16)REG(15) + time; + time = gSaveContext.time; + gSaveContext.time = (u16)gSaveContext.unk_14 + time; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C1158.s") +void func_809C1158(EnAob01* this, GlobalContext* globalCtx) { + s32 temp_s0 = ENAOB01_GET_7E00_2(&this->actor); + s16 i = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C11EC.s") + if (temp_s0 != 0x3F) { + do { + this->unk_1D8[i] = func_8013D648(globalCtx, temp_s0, 0x3F); + temp_s0 = this->unk_1D8[i]->unk1; + i++; + } while (temp_s0 != 0xFF); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C1304.s") +void func_809C11EC(EnAob01* this, GlobalContext* globalCtx) { + s32 unk; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C1424.s") + func_809C1158(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C14D0.s") + for (i = 0; i < ARRAY_COUNT(D_809C384C); i++) { + unk = (this->unk_1D8[D_809C384C[i].unk_06]->unk1 << 0xA) | (i << 5); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C15BC.s") + this->unk_3F8[i] = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_DG, D_809C384C[i].unk_00.x, D_809C384C[i].unk_00.y, + D_809C384C[i].unk_00.z, 0, D_809C384C[i].unk_04 * 182.04445f, 0, unk, 0xFFFF, this->actor.unk20, NULL); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C165C.s") +void func_809C1304(EnAob01* this, GlobalContext* globalCtx) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C16DC.s") + for (i = 0; i < ARRAY_COUNT(this->unk_3F8); i++) { + this->unk_3F8[i] = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_RACEDOG, (i * 15.0f) + -3897.0f, 130.0f, 1290.0f - (i * 10.0f), 0, + 0x1555, 0, (i << 5) | ENAOB01_GET_7E00_1(&this->actor), 0xFFFF, this->actor.unk20, NULL); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C1C9C.s") +s32 func_809C1424(EnAob01* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(D_809C3790[this->unk_43C].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C1D64.s") + if (this->unk_43C == 1) { + if (curFrame == lastFrame) { + this->unk_43C = 2; + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 2); + return true; + } + } else if (this->unk_43C == 2) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C1EC8.s") +s32 func_809C14D0(EnAob01* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(D_809C3790[this->unk_43C].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2060.s") + if ((this->unk_43C == 0) || (this->unk_43C == 5)) { + if (curFrame == lastFrame) { + this->unk_43C = 3; + Actor_ChangeAnimation(&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); + return true; + } + } else if (this->unk_43C == 4) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C21E0.s") +s32 func_809C15BC(EnAob01* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(D_809C3790[this->unk_43C].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2504.s") + if ((this->unk_43C != 0) && (this->unk_43C != 5)) { + if (curFrame == lastFrame) { + this->unk_43C = 5; + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 5); + return true; + } + } else { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2594.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C25E4.s") +void func_809C165C(EnAob01* 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); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2680.s") +void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C26E4.s") + switch (this->unk_210) { + case 0: + case 0x3524: + case 0x3535: + case 0x3548: + case 0x3549: + case 0x354A: + switch (gSaveContext.day) { + case 1: + if (!gSaveContext.isNight) { + if (!(gSaveContext.weekEventReg[64] & 0x80)) { + gSaveContext.weekEventReg[64] |= 0x80; + this->unk_210 = 0x3520; + } else { + this->unk_210 = 0x352F; + } + } else { + if (!(gSaveContext.weekEventReg[65] & 1)) { + gSaveContext.weekEventReg[65] |= 1; + this->unk_210 = 0x3530; + } else { + this->unk_210 = 0x352F; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2730.s") + case 2: + if (!gSaveContext.isNight) { + if (!(gSaveContext.weekEventReg[65] & 2)) { + gSaveContext.weekEventReg[65] |= 2; + this->unk_210 = 0x3531; + } else { + this->unk_210 = 0x352F; + } + } else { + if (!(gSaveContext.weekEventReg[65] & 4)) { + gSaveContext.weekEventReg[65] |= 4; + this->unk_210 = 0x3532; + } else { + this->unk_210 = 0x352F; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2788.s") + case 3: + if (!gSaveContext.isNight) { + if (!(gSaveContext.weekEventReg[65] & 8)) { + gSaveContext.weekEventReg[65] |= 8; + this->unk_210 = 0x3533; + } else { + this->unk_210 = 0x352F; + } + } else { + if (!(gSaveContext.weekEventReg[65] & 0x10)) { + gSaveContext.weekEventReg[65] |= 0x10; + this->unk_210 = 0x3534; + } else { + this->unk_210 = 0x352F; + } + } + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2824.s") + case 0x3520: + case 0x352F: + case 0x3530: + case 0x3531: + case 0x3532: + case 0x3533: + case 0x3534: + this->unk_210 = 0x3521; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C28B8.s") + case 0x3521: + if (this->unk_2D2 & 2) { + this->unk_2D2 &= ~2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2A64.s") + switch (player->transformation) { + case PLAYER_FORM_GORON: + this->unk_210 = 0x3548; + this->unk_2D2 |= 0x10; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2BE4.s") + case PLAYER_FORM_ZORA: + this->unk_210 = 0x3549; + this->unk_2D2 |= 0x10; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2C9C.s") + case PLAYER_FORM_DEKU: + this->unk_210 = 0x354A; + this->unk_2D2 |= 0x10; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2D0C.s") + case PLAYER_FORM_HUMAN: + if (gSaveContext.rupees < 10) { + this->unk_210 = 0x3524; + this->unk_2D2 |= 0x10; + } else { + this->unk_210 = 0x3522; + this->unk_2D2 |= 4; + this->unk_2D2 |= 0x10; + } + } + } else { + this->unk_2D2 |= 0x10; + this->unk_210 = 0x3535; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2EC4.s") + case 0x3522: + case 0x3523: + if (this->unk_2D2 & 8) { + this->unk_210 = 0x3525; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2F34.s") + this->unk_210 = 0x3523; + this->unk_2D2 |= 0x40; + this->unk_2D2 |= 0x10; + this->unk_43C = 1; + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C2FA0.s") + case 0x3525: + case 0x3526: + if (this->unk_2D2 & 4) { + if (this->unk_2D2 & 8) { + this->unk_210 = 0x3525; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/EnAob01_Init.s") + this->unk_210 = 0x3523; + this->unk_2D2 |= 0x40; + this->unk_2D2 |= 0x10; + this->unk_43C = 1; + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/EnAob01_Destroy.s") + if (this->unk_2D2 & 2) { + this->unk_2D2 &= ~2; + this->unk_210 = 0x3527; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/EnAob01_Update.s") + this->unk_210 = 0x3526; + this->unk_2D2 |= 0x40; + this->unk_2D2 |= 4; + this->unk_2D2 |= 0x10; + this->unk_43C = 1; + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C33D8.s") + case 0x3527: + this->unk_210 = 0x3528; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C35B4.s") + case 0x3528: + if (gSaveContext.rupees < this->unk_434) { + this->unk_210 = 0x3536; + this->unk_2D2 |= 0x40; + this->unk_43C = 1; + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/func_809C35F4.s") + if (this->unk_434 == 0) { + this->unk_210 = 0x3537; + this->unk_2D2 |= 0x40; + this->unk_43C = 1; + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Aob_01/EnAob01_Draw.s") + gSaveContext.unk_3F5C = this->unk_434; + globalCtx->msgCtx.bankRupees = this->unk_434; + this->unk_210 = 0x3529; + break; + + case 0x3529: + if (this->unk_2D2 & 2) { + this->unk_2D2 &= ~2; + func_801159EC(-this->unk_434); + func_800B7298(globalCtx, NULL, 7); + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_809C1C9C; + return; + } + this->unk_210 = 0x3528; + break; + + case 0x3536: + case 0x3537: + this->unk_210 = 0x3528; + break; + } + + func_801518B0(globalCtx, this->unk_210, &this->actor); +} + +void func_809C1C9C(EnAob01* this, GlobalContext* globalCtx) { + if (gSaveContext.rupeeAccumulator == 0) { + gSaveContext.weekEventReg[63] |= 1; + gSaveContext.weekEventReg[63] &= (u8)~2; + this->unk_2D2 |= 0x20; + func_800FD750(0x40); + globalCtx->nextEntranceIndex = 0x7C10; + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 0x40; + gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 2; + gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (this->unk_432 * 8); + globalCtx->sceneLoadFlag = 0x14; + } +} + +void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (temp_v0 == 4) { + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (gSaveContext.rupees < 10) { + play_sound(NA_SE_SY_ERROR); + this->unk_210 = 0x3524; + func_801518B0(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); + this->actionFunc = func_809C21E0; + } + break; + + case 1: + func_8019F230(); + this->unk_210 = 0x3535; + func_801518B0(globalCtx, this->unk_210, &this->actor); + break; + } + } + } else if ((temp_v0 == 5) && func_80147624(globalCtx)) { + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_210 = 0; + this->actionFunc = func_809C2060; + } +} + +void func_809C1EC8(EnAob01* this, GlobalContext* globalCtx) { + static u16 D_809C392C[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; + Player* player = GET_PLAYER(globalCtx); + Vec3f sp30; + + SkelAnime_Update(&this->skelAnime); + if (func_8013D5E8(this->actor.shape.rot.y, 14000, 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; + func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk_2D4, &this->unk_2DA, + &this->unk_2E0, D_809C392C); + } else { + Math_SmoothStepToS(&this->unk_2D4.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2D4.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2DA.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2DA.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2E0.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2E0.y, 0, 4, 1000, 1); + } + func_809C10B0(this, 3); + func_8013D9C8(globalCtx, this->unk_2F8, this->unk_318, 0x10); + func_809C165C(this, globalCtx); + if (player->stateFlags1 & 0x20) { + func_809C1124(); + } +} + +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; + func_800B8614(&this->actor, globalCtx, 100.0f); + this->unk_2D2 |= 8; + this->actionFunc = func_809C21E0; + } + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_2D2 & 0x100)) { + this->unk_2D2 &= ~0x100; + this->unk_2E6 = this->unk_2D4; + this->unk_2EC = this->unk_2DA; + this->unk_2F2 = this->unk_2E0; + func_809C16DC(this, globalCtx); + this->actionFunc = func_809C21E0; + } else { + this->unk_2D2 &= ~0x100; + if ((this->actor.xzDistToPlayer < 100.0f) && !(this->collider.base.ocFlags2 & OC2_HIT_PLAYER)) { + this->unk_2D2 |= 0x100; + func_800B8614(&this->actor, globalCtx, 100.0f); + } + } + } +} + +void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { + u8 sp2F = Message_GetState(&globalCtx->msgCtx); + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 4000, 1); + + if ((this->unk_2D2 & 8) && !func_809C2EC4(this, globalCtx)) { + if ((this->unk_210 != 0) && (this->unk_210 != 0x3535) && (this->unk_210 != 0x3524) && + (this->unk_210 != 0x3548) && (this->unk_210 != 0x3549) && (this->unk_210 != 0x354A)) { + this->unk_210 = 0x3523; + } + this->actor.textId = 0; + this->unk_2D2 &= ~8; + this->actor.flags &= ~0x10000; + this->actionFunc = func_809C2060; + return; + } + + if (this->unk_2D2 & 0x40) { + if (!func_809C1424(this)) { + return; + } + } else if (!func_809C15BC(this)) { + return; + } + + if (this->unk_2D2 & 8) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~0x10000; + func_80123E90(globalCtx, &this->actor); + if (this->unk_2D2 & 4) { + func_809C16DC(this, globalCtx); + this->unk_2D2 &= ~4; + } else { + 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); + } + this->unk_2D2 &= ~8; + } + } else if (sp2F == 4) { + if (func_80147624(globalCtx)) { + this->unk_2D2 &= ~0x40; + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + this->unk_2D2 |= 2; + func_809C16DC(this, globalCtx); + break; + + case 1: + func_8019F230(); + func_809C16DC(this, globalCtx); + break; + } + } + } else if (sp2F == 5) { + if (func_80147624(globalCtx)) { + this->unk_2D2 &= ~0x40; + if (this->unk_2D2 & 0x10) { + this->unk_2D2 &= ~0x10; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_809C2060; + } else { + func_809C16DC(this, globalCtx); + } + } + } else if ((sp2F == 14) && func_80147624(globalCtx)) { + this->unk_2D2 &= ~0x40; + this->unk_434 = globalCtx->msgCtx.bankRupeesSelected; + func_809C16DC(this, globalCtx); + } +} + +s32 func_809C2504(EnAob01* this, GlobalContext* globalCtx) { + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + + while (npc != NULL) { + if ((npc->id == ACTOR_EN_RACEDOG) && (func_800F2178(this->unk_430) == ((EnRacedog*)npc)->unk_1E8)) { + ActorCutscene_Stop(this->unk_430); + this->unk_3F4 = npc; + this->unk_430 = ActorCutscene_GetAdditionalCutscene(this->unk_430); + return true; + } + npc = npc->next; + } + + return false; +} + +s32 func_809C2594(EnAob01* this, GlobalContext* globalCtx) { + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + + while (npc != NULL) { + if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->unk_290 == ((EnRacedog*)npc)->unk_292)) { + this->unk_3F4 = npc; + return true; + } + npc = npc->next; + } + + return false; +} + +s32 func_809C25E4(EnAob01* this, GlobalContext* globalCtx) { + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + s16 count = 0; + + while (npc != NULL) { + if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->unk_29C == 3)) { + count++; + } + npc = npc->next; + } + + if (count >= 14) { + return true; + } + + if ((count >= 10) && (DECR(this->unk_440) == 0)) { + return true; + } + return false; +} + +s32 func_809C2680(EnAob01* this) { + if ((ActorCutscene_GetLength(this->unk_430) > 0) && (ActorCutscene_GetCurrentIndex() != this->unk_430)) { + this->unk_430 = ActorCutscene_GetAdditionalCutscene(this->unk_430); + return true; + } + return false; +} + +void func_809C26E4(EnAob01* this, GlobalContext* globalCtx) { + ActorCutscene_Stop(this->unk_430); + this->unk_430 = ActorCutscene_GetAdditionalCutscene(this->unk_430); + this->actionFunc = func_809C2824; +} + +void func_809C2730(EnAob01* this, GlobalContext* globalCtx) { + if (func_809C2504(this, globalCtx) || func_809C2680(this)) { + ActorCutscene_SetIntentToPlay(this->unk_430); + this->actionFunc = func_809C2824; + } +} + +void func_809C2788(EnAob01* this, GlobalContext* globalCtx) { + this->unk_2D2 |= 0x20; + if (func_809C25E4(this, globalCtx)) { + globalCtx = globalCtx; + if (func_801A8A50(0) != 0x41) { + globalCtx->nextEntranceIndex = 0x7C10; + gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 3; + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 3; + globalCtx->sceneLoadFlag = 0x14; + } + } +} + +void func_809C2824(EnAob01* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->unk_430)) { + ActorCutscene_Start(this->unk_430, this->unk_3F4); + switch (func_800F2178(this->unk_430)) { + case 255: + this->actionFunc = func_809C26E4; + break; + + case 99: + this->actionFunc = func_809C2788; + break; + + default: + this->actionFunc = func_809C2730; + } + } else { + ActorCutscene_SetIntentToPlay(this->unk_430); + } +} + +void func_809C28B8(EnAob01* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~0x10000; + func_80123E90(globalCtx, &this->actor); + this->unk_434 = gSaveContext.unk_3F5C; + switch ((gSaveContext.eventInf[0] & 0xF8) >> 3) { + case 1: + this->unk_210 = 0x352A; + this->unk_2D2 |= 0x80; + this->unk_434 *= 3; + func_801159EC(this->unk_434); + globalCtx->msgCtx.bankRupees = this->unk_434; + break; + + case 2: + this->unk_210 = 0x352B; + this->unk_2D2 |= 0x80; + this->unk_434 *= 2; + func_801159EC(this->unk_434); + globalCtx->msgCtx.bankRupees = this->unk_434; + break; + + case 3: + case 4: + case 5: + this->unk_210 = 0x352C; + func_801159EC(this->unk_434); + break; + + default: + this->unk_210 = 0x352D; + this->unk_2D2 |= 0x40; + this->unk_43C = 1; + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + break; + } + + func_801518B0(globalCtx, this->unk_210, &this->actor); + this->actionFunc = func_809C2D0C; + } else if (this->actor.xzDistToPlayer < 100.0f) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} + +void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { + u8 sp2F = Message_GetState(&globalCtx->msgCtx); + + if (func_809C15BC(this)) { + if ((sp2F == 5) && func_80147624(globalCtx)) { + this->unk_434 = 0; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->unk_2D4 = this->unk_2E6; + this->unk_2DA = this->unk_2EC; + this->unk_2E0 = this->unk_2F2; + this->actor.parent = NULL; + this->actor.shape.rot.y = this->actor.world.rot.y; + if (gSaveContext.weekEventReg[8] & 0x20) { + this->actionFunc = func_809C2BE4; + } else { + gSaveContext.weekEventReg[8] |= 0x20; + this->actionFunc = func_809C2BE4; + } + } else if (gSaveContext.weekEventReg[8] & 0x20) { + Actor_PickUp(&this->actor, globalCtx, 4, 300.0f, 300.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, 12, 300.0f, 300.0f); + } + } +} + +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 (gSaveContext.weekEventReg[63] & 2) { + gSaveContext.weekEventReg[63] &= (u8)~2; + } + + if (gSaveContext.weekEventReg[63] & 1) { + gSaveContext.weekEventReg[63] &= (u8)~1; + } + + this->unk_210 = 0; + func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + gSaveContext.eventInf[0] &= (u8)~7; + this->actionFunc = func_809C2C9C; + } +} + +void func_809C2C9C(EnAob01* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_210 = 0x354C; + func_80151938(globalCtx, this->unk_210); + this->actionFunc = func_809C1D64; + } else { + func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + } +} + +void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { + u8 sp2F = Message_GetState(&globalCtx->msgCtx); + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 4000, 1); + + if (this->unk_2D2 & 0x40) { + if (!func_809C1424(this)) { + return; + } + } else if (this->unk_2D2 & 0x80) { + if (!func_809C14D0(this)) { + return; + } + } + + if ((sp2F == 5) && func_80147624(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); + this->actionFunc = func_809C2A64; + } else { + this->unk_2D4 = this->unk_2E6; + this->unk_2DA = this->unk_2EC; + this->unk_2E0 = this->unk_2F2; + + this->unk_434 = 0; + this->actor.shape.rot.y = this->actor.world.rot.y; + if (gSaveContext.weekEventReg[63] & 2) { + gSaveContext.weekEventReg[63] &= (u8)~2; + } + + if (gSaveContext.weekEventReg[63] & 1) { + gSaveContext.weekEventReg[63] &= (u8)~1; + } + + this->unk_210 = 0x354C; + func_801518B0(globalCtx, this->unk_210, &this->actor); + this->actionFunc = func_809C1D64; + gSaveContext.eventInf[0] &= (u8)~7; + } + } +} + +s32 func_809C2EC4(EnAob01* this, GlobalContext* globalCtx) { + Actor* dog = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; + + while (dog != NULL) { + if (dog->id == ACTOR_EN_DG) { + this->unk_432 = ((EnDg*)dog)->unk_288; + if (this->unk_432 == -1) { + return false; + } + + if (this->unk_432 == ENDG_GET_3E0(dog)) { + return true; + } + } + dog = dog->next; + } + + return false; +} + +void func_809C2F34(EnAob01* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.world.pos.x = -4134.0f; + player->actor.world.pos.z = 1464.0f; + player->actor.shape.rot.y = player->actor.world.rot.y; + player->actor.draw = NULL; + player->stateFlags1 |= 0x20; + this->actor.world.pos.x = -4308.0f; + this->actor.world.pos.z = 1620.0f; + this->actor.prevPos = this->actor.world.pos; +} + +void func_809C2FA0(void) { + u8 i; + u8 idx; + u8 idx2; + u8 orig; + u8 orig2; + u8 sp44[7]; + u8 sp34[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + }; + + for (i = 0; i < ARRAY_COUNT(sp34); i++) { + idx = Rand_ZeroFloat(14.0f); + orig = sp34[i]; + + sp34[i] = sp34[idx]; + sp34[idx] = orig; + } + + for (i = 0; i < ARRAY_COUNT(sp44); i++) { + gSaveContext.weekEventReg[42 + i] = 0; + sp44[i] = 0; + } + + for (i = 0; i < ARRAY_COUNT(sp34); i++) { + orig2 = sp34[i]; + idx2 = i / 2; + + if (i % 2) { + sp44[idx2] |= orig2 << 0x4; + idx = gSaveContext.weekEventReg[42 + idx2]; + gSaveContext.weekEventReg[42 + idx2] = idx | sp44[idx2]; + } else { + sp44[idx2] |= orig2; + } + } +} + +void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + 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); + 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_SetScale(&this->actor, 0.01f); + + switch (gSaveContext.eventInf[0] & 7) { + case 0: + func_809C2FA0(); + func_809C11EC(this, globalCtx); + this->actor.flags |= 1; + this->actionFunc = func_809C2060; + break; + + case 2: + this->unk_440 = 500; + func_809C1304(this, globalCtx); + this->actor.draw = NULL; + this->unk_430 = this->actor.cutscene; + func_809C2594(this, globalCtx); + ActorCutscene_SetIntentToPlay(this->unk_430); + this->actor.flags &= ~1; + func_809C2F34(this, globalCtx); + this->actionFunc = func_809C2824; + break; + + case 3: + func_809C2FA0(); + func_809C11EC(this, globalCtx); + this->actor.flags |= 1; + this->actor.flags |= 0x10000; + this->actionFunc = func_809C28B8; + break; + } +} + +void EnAob01_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAob01* this = THIS; + + if (!(this->unk_2D2 & 0x20)) { + gSaveContext.weekEventReg[63] &= (u8)~1; + } + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnAob01_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAob01* this = THIS; + + this->actionFunc(this, globalCtx); + func_809C1EC8(this, globalCtx); +} + +s32 EnAob01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnAob01* this = THIS; + UNK_TYPE sp38[] = { + &object_aob_Tex_000658, + &object_aob_Tex_000E58, + &object_aob_Tex_001658, + }; + + if (limbIndex == 15) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + *dList = object_aob_DL_003D18; + + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(sp38[this->unk_3EE])); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == 15) { + 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) { + 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)) { + rot->y += (s16)Math_SinS(this->unk_2F8[limbIndex]) * 200; + rot->z += (s16)Math_CosS(this->unk_318[limbIndex]) * 200; + } + return false; +} + +void EnAob01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_809C3968 = { 0.0f, 0.0f, 0.0f }; + EnAob01* this = THIS; + + if (limbIndex == 15) { + Matrix_MultiplyVector3fByState(&D_809C3968, &this->actor.focus.pos); + } +} + +void EnAob01_UnkDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +} + +void EnAob01_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnAob01* this = THIS; + Vec3f sp5C; + Vec3f sp50; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, 50, 80, 0, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 50, 80, 0, 0)); + gDPPipeSync(POLY_OPA_DISP++); + + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnAob01_OverrideLimbDraw, EnAob01_PostLimbDraw, EnAob01_UnkDraw, &this->actor); + + if (this->actor.draw != NULL) { + func_8012C2DC(globalCtx->state.gfxCtx); + sp5C = this->actor.world.pos; + sp50.x = 0.5f; + sp50.y = 0.5f; + sp50.z = 0.5f; + func_800BC620(&sp5C, &sp50, 0xFF, globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h index 5f30ef196e..be7655fad0 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 @@ -7,10 +7,38 @@ struct EnAob01; typedef void (*EnAob01ActionFunc)(struct EnAob01*, GlobalContext*); +#define ENAOB01_GET_7E00_1(thisx) ((thisx)->params & 0x7E00) +#define ENAOB01_GET_7E00_2(thisx) (((thisx)->params & 0x7E00) >> 9) + typedef struct EnAob01 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnAob01ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x2FC]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnAob01ActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ Path* unk_1D8[14]; + /* 0x210 */ u16 unk_210; + /* 0x212 */ Vec3s jointTable[16]; + /* 0x272 */ Vec3s morphTable[16]; + /* 0x2D2 */ u16 unk_2D2; + /* 0x2D4 */ Vec3s unk_2D4; + /* 0x2DA */ Vec3s unk_2DA; + /* 0x2E0 */ Vec3s unk_2E0; + /* 0x2E6 */ Vec3s unk_2E6; + /* 0x2EC */ Vec3s unk_2EC; + /* 0x2F2 */ Vec3s unk_2F2; + /* 0x2F8 */ s16 unk_2F8[16]; + /* 0x318 */ s16 unk_318[16]; + /* 0x338 */ UNK_TYPE1 unk338[0xB6]; + /* 0x3EE */ s16 unk_3EE; + /* 0x3F0 */ s16 unk_3F0; + /* 0x3F4 */ Actor* unk_3F4; + /* 0x3F8 */ Actor* unk_3F8[14]; + /* 0x430 */ s16 unk_430; + /* 0x432 */ s16 unk_432; + /* 0x434 */ s32 unk_434; + /* 0x438 */ UNK_TYPE1 unk438[4]; + /* 0x43C */ s32 unk_43C; + /* 0x440 */ s16 unk_440; } EnAob01; // size = 0x444 extern const ActorInit En_Aob_01_InitVars; diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index bacb293950..097c90fe08 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -42,7 +42,7 @@ static ColliderQuadInit D_8088C1E0 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_8088C230[] = { - ICHAIN_F32(minVelocityY, -150, ICHAIN_STOP), + ICHAIN_F32(terminalVelocity, -150, ICHAIN_STOP), }; #endif diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c index 1e84a0f7bf..2668c1d680 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -5,6 +5,8 @@ */ #include "z_en_baguo.h" +#include "objects/object_gmo/object_gmo.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000005 @@ -106,16 +108,11 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, NEJIRON_DMGEFF_KILL), }; -extern Gfx D_060014C8; -extern Gfx D_060018C8; -extern Gfx D_06001CC8; -extern SkeletonHeader D_060020E8; - void EnBaguo_Init(Actor* thisx, GlobalContext* globalCtx) { EnBaguo* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 0.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &D_060020E8, NULL, this->jointTable, this->morphTable, 3); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gNejironSkel, NULL, this->jointTable, this->morphTable, 3); this->actor.hintId = 0xB; this->maxDistanceFromHome = 240.0f; this->maxDistanceFromHome += this->actor.world.rot.z * 40.0f; @@ -148,7 +145,7 @@ void EnBaguo_UndergroundIdle(EnBaguo* this, GlobalContext* globalCtx) { this->action = NEJIRON_ACTION_INACTIVE; if (this->actor.xzDistToPlayer < 200.0f && Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { this->actor.draw = EnBaguo_DrawBody; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_APPEAR); this->actor.world.rot.z = 0; this->actor.world.rot.x = this->actor.world.rot.z; this->actor.flags &= ~0x8000000; @@ -162,8 +159,8 @@ void EnBaguo_EmergeFromUnderground(EnBaguo* this, GlobalContext* globalCtx) { this->actor.world.rot.y += 0x1518; this->actor.shape.rot.y = this->actor.world.rot.y; if ((globalCtx->gameplayFrames % 8) == 0) { - func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 10, 8.0f, - 500, 10, 1); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, + 10, 8.0f, 500, 10, 1); } Math_ApproachF(&this->actor.shape.shadowScale, 50.0f, 0.3f, 5.0f); Math_ApproachF(&this->actor.shape.yOffset, 2700.0f, 100.0f, 500.0f); @@ -191,9 +188,9 @@ void EnBaguo_Idle(EnBaguo* this, GlobalContext* globalCtx) { if (fabsf(this->actor.world.rot.y - this->actor.yawTowardsPlayer) > 200.0f) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 30, 300, 1000); if ((globalCtx->gameplayFrames % 8) == 0) { - func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, - this->actor.shape.shadowScale - 20.0f, 10, 8.0f, 500, 10, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_VOICE); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, + this->actor.shape.shadowScale - 20.0f, 10, 8.0f, 500, 10, 1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_VOICE); } } } @@ -203,8 +200,8 @@ void EnBaguo_Idle(EnBaguo* this, GlobalContext* globalCtx) { yaw = this->actor.yawTowardsPlayer - this->actor.world.rot.y; absoluteYaw = ABS_ALT(yaw); - Math_Vec3f_Copy(&this->targetRotation, &D_801D15B0); - Math_Vec3f_Copy(&this->currentRotation, &D_801D15B0); + Math_Vec3f_Copy(&this->targetRotation, &gZeroVec3f); + Math_Vec3f_Copy(&this->currentRotation, &gZeroVec3f); if (absoluteYaw < 0x2000) { this->targetRotation.x = 2000.0f; } else { @@ -255,7 +252,7 @@ void EnBaguo_Roll(EnBaguo* this, GlobalContext* globalCtx) { this->actor.world.rot.z -= (s16)this->currentRotation.z; } } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_ROLL - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_ROLL - SFX_FLAG); } void EnBaguo_SetupRetreatUnderground(EnBaguo* this) { @@ -268,8 +265,8 @@ void EnBaguo_RetreatUnderground(EnBaguo* this, GlobalContext* globalCtx) { this->actor.world.rot.y -= 0x1518; this->actor.shape.rot.y = this->actor.world.rot.y; if ((globalCtx->gameplayFrames % 8) == 0) { - func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 10, 8.0f, - 500, 10, 1); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, + 10, 8.0f, 500, 10, 1); } Math_ApproachF(&this->actor.shape.yOffset, -3000.0f, 100.0f, 500.0f); Math_ApproachZeroF(&this->actor.shape.shadowScale, 0.3f, 5.0f); @@ -277,7 +274,7 @@ void EnBaguo_RetreatUnderground(EnBaguo* this, GlobalContext* globalCtx) { this->actor.shape.yOffset = -3000.0f; this->actor.draw = EnBaguo_DrawBody; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_APPEAR); this->actor.flags |= 0x8000000; this->actor.flags &= ~1; this->actionFunc = EnBaguo_UndergroundIdle; @@ -314,7 +311,7 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { if ((this->collider.base.acFlags & AC_HIT || i)) { this->collider.base.acFlags &= ~AC_HIT; if (i || this->actor.colChkInfo.damageEffect == NEJIRON_DMGEFF_KILL) { - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->action = NEJIRON_ACTION_EXPLODING; this->actor.speedXZ = 0.0f; this->actor.shape.shadowScale = 0.0f; @@ -332,8 +329,8 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_POP); - Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_DEAD); this->timer = 30; this->actor.flags |= 0x8000000; this->actor.flags &= ~1; @@ -350,7 +347,7 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { void EnBaguo_Update(Actor* thisx, GlobalContext* globalCtx) { EnBaguo* this = THIS; - Actor_SetHeight(&this->actor, 30.0f); + Actor_SetFocus(&this->actor, 30.0f); EnBaguo_UpdateParticles(this, globalCtx); EnBaguo_CheckForDetonation(this, globalCtx); this->actionFunc(this, globalCtx); @@ -372,7 +369,7 @@ void EnBaguo_Update(Actor* thisx, GlobalContext* globalCtx) { this->blinkTimer = Rand_ZeroFloat(60.0f) + 20.0f; } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); if (this->action != NEJIRON_ACTION_INACTIVE) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); @@ -390,7 +387,7 @@ void EnBaguo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } void EnBaguo_DrawBody(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sEyeTextures[] = { &D_060014C8, &D_060018C8, &D_06001CC8 }; + static TexturePtr sEyeTextures[] = { &gNejironEyeOpenTex, &gNejironEyeHalfTex, &gNejironEyeClosedTex }; EnBaguo* this = THIS; Gfx* gfx; s32 eyeIndex; @@ -483,7 +480,7 @@ void EnBaguo_DrawRockParticles(EnBaguo* this, GlobalContext* globalCtx) { Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_OPA_DISP++, 0, 1, 255, 255, 255, 255); - gSPDisplayList(POLY_OPA_DISP++, &D_0401FA40); + gSPDisplayList(POLY_OPA_DISP++, &gameplay_keep_DL_01FA40); } } CLOSE_DISPS(gfxCtx); diff --git a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c index 7323c95b35..fcbd60ed0a 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c @@ -68,7 +68,7 @@ static u8 animModes[] = { 0, 0 }; void EnBaisen_Init(Actor* thisx, GlobalContext* globalCtx) { EnBaisen* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06007908, &D_060011C0, this->jointTable, this->morphTable, 20); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->paramCopy = this->actor.params; @@ -124,7 +124,7 @@ void func_80BE871C(EnBaisen* this) { } void func_80BE87B0(EnBaisen* this, GlobalContext* globalCtx) { - Actor* actorIterator = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (actorIterator != NULL) { if (actorIterator->id == ACTOR_EN_HEISHI) { @@ -151,7 +151,7 @@ void func_80BE87FC(EnBaisen* this) { } void func_80BE887C(EnBaisen* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80BE895C(this, globalCtx); } else { if (this->paramCopy != 0) { @@ -176,7 +176,7 @@ void func_80BE895C(EnBaisen* this, GlobalContext* globalCtx) { if (this->unk2A4 != NULL) { this->unk290 = true; this->unk2AC = 1; - func_800B86C8(this->unk2A4, globalCtx, this->unk2A4); + Actor_ChangeFocus(this->unk2A4, globalCtx, this->unk2A4); } this->unk29C = 1; if (this->paramCopy == 0) { @@ -223,7 +223,7 @@ void func_80BE8AAC(EnBaisen* this, GlobalContext* globalCtx) { EnBaisen_ChangeAnimation(this, 0); } } - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); this->textIdIndex++; if (this->textIdIndex < 6) { @@ -233,7 +233,7 @@ void func_80BE8AAC(EnBaisen* this, GlobalContext* globalCtx) { } else { this->unk2A4 = &this->actor; } - func_800B86C8(this->unk2A4, globalCtx, this->unk2A4); + Actor_ChangeFocus(this->unk2A4, globalCtx, this->unk2A4); } else { func_80BE87FC(this); } @@ -254,13 +254,13 @@ void EnBaisen_Update(Actor* thisx, GlobalContext* globalCtx) { return; } this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); Actor_SetScale(&this->actor, 0.01f); if (this->unk290) { func_80BE871C(this); } - Actor_SetHeight(&this->actor, 60.0f); + Actor_SetFocus(&this->actor, 60.0f); Math_SmoothStepToS(&this->headRotX, this->headRotXTarget, 1, 0xBB8, 0); Math_SmoothStepToS(&this->headRotY, this->headRotYTarget, 1, 0x3E8, 0); Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index ddc5742423..5b31f76013 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -5,6 +5,8 @@ */ #include "z_en_bigpo.h" +#include "objects/object_bigpo/object_bigpo.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00001215 @@ -32,6 +34,7 @@ void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, GlobalContext* globalCtx); void EnBigpo_SpawnCutsceneStage7(EnBigpo* this); void EnBigpo_SpawnCutsceneStage8(EnBigpo* this, GlobalContext* globalCtx); +s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx); void EnBigpo_LowerCutsceneSubCamera(EnBigpo* this, GlobalContext* globalCtx); void EnBigpo_WellWaitForProximity(EnBigpo* this, GlobalContext* globalCtx); void EnBigpo_WaitCutsceneQueue(EnBigpo* this, GlobalContext* globalCtx); @@ -48,7 +51,6 @@ void EnBigpo_SpinAttack(EnBigpo* this, GlobalContext* globalCtx); void EnBigpo_SetupSpinDown(EnBigpo* this); void EnBigpo_SpinningDown(EnBigpo* this, GlobalContext* globalCtx); void EnBigpo_CheckHealth(EnBigpo* this, GlobalContext* globalCtx); -s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx); void EnBigpo_SetupDeath(EnBigpo* this); void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx); void EnBigpo_SetupLanternDrop(EnBigpo* this, GlobalContext* globalCtx); @@ -80,17 +82,6 @@ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx); void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx); void EnBigpo_RevealedFire(Actor* thisx, GlobalContext* globalCtx); -extern AnimationHeader D_06001360; -extern SkeletonHeader D_06005C18; -extern AnimationHeader D_06000924; -extern AnimationHeader D_06000924; -extern AnimationHeader D_06000454; -extern Gfx D_060041A0; -extern Gfx D_06001BB0; -extern Gfx D_060058B8; -extern Gfx D_060042C8; -extern Gfx D_060043F8; - extern const ActorInit En_Bigpo_InitVars; const ActorInit En_Bigpo_InitVars = { @@ -203,7 +194,7 @@ void EnBigpo_Init(Actor* thisx, GlobalContext* globalCtx2) { return; } - SkelAnime_Init(globalCtx, &this->skelAnime, &D_06005C18, &D_06000924, this->jointTable, this->morphTable, + SkelAnime_Init(globalCtx, &this->skelAnime, &gBigpoSkeleton, &gBigpoFloatAnim, this->jointTable, this->morphTable, ENBIGPO_LIMBCOUNT); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -216,7 +207,7 @@ void EnBigpo_Init(Actor* thisx, GlobalContext* globalCtx2) { 255, 0); } - ActorShape_Init(&thisx->shape, 0.0f, func_800B3FC0, 45.0f); + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 45.0f); thisx->bgCheckFlags |= 0x400; this->savedHeight = thisx->home.pos.y + 100.0f; this->mainColor.r = 255; @@ -244,7 +235,7 @@ void EnBigpo_Destroy(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.params != ENBIGPO_POSSIBLEFIRE) && (this->actor.params != ENBIGPO_CHOSENFIRE) && (this->actor.params != ENBIGPO_REVEALEDFIRE) && (this->actor.params != ENBIGPO_UNK5)) { - // if NOT a fire type, *ENBIGPO_REGULAR and ENBIGPO_SUMMONED combat types only) + // if NOT a fire type, *ENBIGPO_REGULAR and ENBIGPO_SUMMONED (combat types only) if (1) {} globalCtx2 = globalCtx; for (fireCount = 0; fireCount < ARRAY_COUNT(this->fires); fireCount++) { @@ -254,7 +245,7 @@ void EnBigpo_Destroy(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B61914(EnBigpo* this) { +void EnBigpo_RotateSpawnCutsceneFires(EnBigpo* this) { EnBigpoFireEffect* firePtr; s32 i; @@ -271,11 +262,13 @@ void EnBigpo_UpdateSpin(EnBigpo* this) { this->actor.shape.rot.y += this->rotVelocity; if ((oldYaw < 0) && (this->actor.shape.rot.y > 0)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); // spinning sfx during spin attack + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); // spinning sfx during spin attack } } -// Lowers the position/eye of the camera during the Big Poe spawn cutscene +/* + * Lowers the position/eye of the camera during the Big Poe spawn cutscene + */ void EnBigpo_LowerCutsceneSubCamera(EnBigpo* this, GlobalContext* globalContext) { Camera* subCam; @@ -330,7 +323,7 @@ void EnBigpo_SpawnCutsceneStage1(EnBigpo* this, GlobalContext* globalCtx) { this->actor.draw = EnBigpo_DrawCircleFlames; this->actor.shape.rot.y = BINANG_ROT180(this->actor.yawTowardsPlayer); - func_80B61914(this); + EnBigpo_RotateSpawnCutsceneFires(this); for (i = 0; i < ARRAY_COUNT(this->fires); i++) { this->fires[i].pos.y = this->actor.world.pos.y; @@ -383,7 +376,7 @@ void EnBigpo_SpawnCutsceneStage4(EnBigpo* this, GlobalContext* globalCtx) { this->actor.velocity.y += 0.25f; } this->actor.shape.rot.y += this->rotVelocity; - func_80B61914(this); + EnBigpo_RotateSpawnCutsceneFires(this); if (1) {} for (i = 0; i < ARRAY_COUNT(this->fires); i++) { @@ -402,10 +395,10 @@ void EnBigpo_SpawnCutsceneStage4(EnBigpo* this, GlobalContext* globalCtx) { * big poe starts to visibly appear */ void EnBigpo_SpawnCutsceneStage5(EnBigpo* this) { - Animation_PlayLoop(&this->skelAnime, &D_06001360); + Animation_PlayLoop(&this->skelAnime, &gBigpoAwakenStretchAnim); this->actor.draw = EnBigpo_DrawMainBigpo; Actor_SetScale(&this->actor, 0.014f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); this->actionFunc = EnBigpo_SpawnCutsceneStage6; } @@ -420,7 +413,7 @@ void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actor.shape.rot.y += this->rotVelocity; alphaPlus = this->mainColor.a + 10; // decrease transparency - func_80B61914(this); + EnBigpo_RotateSpawnCutsceneFires(this); if (alphaPlus >= 90) { this->rotVelocity -= 0x80; this->actor.velocity.y -= 0.25f; @@ -471,7 +464,7 @@ void EnBigpo_SpawnCutsceneStage8(EnBigpo* this, GlobalContext* globalCtx) { Play_CameraSetAtEye(globalCtx, MAIN_CAM, &subCam->at, &subCam->eye); this->cutsceneSubCamId = SUBCAM_FREE; if (this->actor.params == ENBIGPO_SUMMONED) { - dampe = func_ActorCategoryIterateById(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_TK); + dampe = SubS_FindActor(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_TK); if (dampe != NULL) { // if dampe exists, switch to viewing his running away cutscene dampe->params = this->actor.cutscene; @@ -493,7 +486,7 @@ void EnBigpo_SetupWarpOut(EnBigpo* this) { this->idleTimer = 32; this->actor.flags &= ~0x1; // targetable OFF this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DISAPPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DISAPPEAR); this->actionFunc = EnBigpo_WarpingOut; } @@ -515,8 +508,8 @@ void EnBigpo_SetupWarpIn(EnBigpo* this, GlobalContext* globalCtx) { f32 distance = CLAMP_MIN(this->actor.xzDistToPlayer, 200.0f); s16 randomYaw = (Rand_Next() >> 0x14) + this->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); - Animation_PlayLoop(&this->skelAnime, &D_06001360); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Animation_PlayLoop(&this->skelAnime, &gBigpoAwakenStretchAnim); this->rotVelocity = 0x2000; this->actor.world.pos.x = (Math_SinS(randomYaw) * distance) + player->actor.world.pos.x; this->actor.world.pos.z = (Math_CosS(randomYaw) * distance) + player->actor.world.pos.z; @@ -543,7 +536,7 @@ void EnBigpo_WarpingIn(EnBigpo* this, GlobalContext* globalCtx) { } void EnBigpo_SetupIdleFlying(EnBigpo* this) { - Animation_MorphToLoop(&this->skelAnime, &D_06000924, -5.0f); + Animation_MorphToLoop(&this->skelAnime, &gBigpoFloatAnim, -5.0f); // if poe missed attack, idle 4 seconds, otherwise its reappearing: attack immediately this->idleTimer = (this->actionFunc == EnBigpo_SpinningDown) ? 80 : 0; this->hoverHeightCycleTimer = 40; @@ -654,8 +647,8 @@ void EnBigpo_SpinningDown(EnBigpo* this, GlobalContext* globalCtx) { * called by EnBigpo_ApplyDamage */ void EnBigpo_HitStun(EnBigpo* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_06000454, -6.0f); - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 0x10); + Animation_MorphToPlayOnce(&this->skelAnime, &gBigpoShockAnim, -6.0f); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0x10); this->collider.base.acFlags &= ~AC_ON; func_800BE504(&this->actor, &this->collider); this->actionFunc = EnBigpo_CheckHealth; @@ -714,13 +707,13 @@ void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx) { // not sure what we're turning this into, but its based on the timer modifiedTimer = ((f32)((this->idleTimer * 10) + 80) * 1.4000001f); - func_800B3030(globalCtx, &tempVec, &D_80B6506C, &D_801D15B0, modifiedTimer, 0, 2); + func_800B3030(globalCtx, &tempVec, &D_80B6506C, &gZeroVec3f, modifiedTimer, 0, 2); tempVec.x = (2.0f * this->actor.world.pos.x) - tempVec.x; tempVec.z = (2.0f * this->actor.world.pos.z) - tempVec.z; - func_800B3030(globalCtx, &tempVec, &D_80B6506C, &D_801D15B0, modifiedTimer, 0, 2); + func_800B3030(globalCtx, &tempVec, &D_80B6506C, &gZeroVec3f, modifiedTimer, 0, 2); tempVec.x = this->actor.world.pos.x; tempVec.z = this->actor.world.pos.z; - func_800B3030(globalCtx, &tempVec, &D_80B6506C, &D_801D15B0, modifiedTimer, 0, 2); + func_800B3030(globalCtx, &tempVec, &D_80B6506C, &gZeroVec3f, modifiedTimer, 0, 2); } else if (this->idleTimer >= 28) { EnBigpo_SetupLanternDrop(this, globalCtx); @@ -735,7 +728,7 @@ void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx) { func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); // burning sfx } if (this->idleTimer == 18) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); } } @@ -761,10 +754,11 @@ void EnBigpo_SetupLanternDrop(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_LanternFalling(EnBigpo* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1 || this->actor.floorHeight == BGCHECK_Y_MIN) { if (this->switchFlags != 0xFF) { - Actor_SetSwitchFlag(globalCtx, this->switchFlags); + Flags_SetSwitch(globalCtx, this->switchFlags); } - EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 6.0f, 0, 1, 1, 15, OBJECT_BIGPO, 10, &D_060041A0); + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 6.0f, 0, 1, 1, 15, OBJECT_BIGPO, 10, + gBigpoDrawLanternFallingDL); EnBigpo_SpawnScoopSoul(this); } } @@ -805,7 +799,7 @@ void EnBigpo_SpawnScoopSoul(EnBigpo* this) { this->actor.scale.x = 0.0f; this->actor.scale.y = 0.0f; this->savedHeight = this->actor.world.pos.y; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_METAL_BOX_BOUND); // misnamed? + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_METAL_BOX_BOUND); // misnamed? this->actionFunc = EnBigpo_ScoopSoulAppearing; } @@ -819,7 +813,7 @@ void EnBigpo_ScoopSoulAppearing(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SetupScoopSoulIdle(EnBigpo* this) { this->savedHeight = this->actor.world.pos.y; - Actor_SetHeight(&this->actor, -10.0f); + Actor_SetFocus(&this->actor, -10.0f); this->idleTimer = 400; // 20 seconds this->actor.flags |= 0x1; // targetable ON this->actionFunc = EnBigpo_ScoopSoulIdle; @@ -831,10 +825,10 @@ void EnBigpo_ScoopSoulIdle(EnBigpo* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } else if (this->idleTimer == 0) { // took too long, soul is leaving - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); EnBigpo_SetupScoopSoulLeaving(this); } else { - func_800B8A1C(&this->actor, globalCtx, GI_MAX, 35.0f, 60.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 35.0f, 60.0f); this->actor.world.pos.y = (sin_rad(this->idleTimer * (M_PI / 20)) * 5.0f) + this->savedHeight; } } @@ -1054,7 +1048,7 @@ void EnBigpo_FlameCircleCutscene(EnBigpo* this, GlobalContext* globalCtx) { this->idleTimer--; if (this->idleTimer == 0) { EnBigpo* parentPoh = (EnBigpo*)this->actor.parent; - Actor_SetSwitchFlag(globalCtx, this->switchFlags); + Flags_SetSwitch(globalCtx, this->switchFlags); Math_Vec3f_Copy(&parentPoh->fires[this->unk20C].pos, &this->actor.world.pos); Actor_MarkForDeath(&this->actor); if (this->unk20C == 0) { @@ -1132,13 +1126,13 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx) { if (Actor_ApplyDamage(&this->actor) == 0) { this->actor.flags &= ~0x1; // targetable OFF - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); Enemy_StartFinishingBlow(globalCtx, &this->actor); if (this->actor.params == ENBIGPO_SUMMONED) { // dampe type func_801A2ED8(); } } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DAMAGE); } // light arrows @@ -1173,23 +1167,23 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk20C = 0; } if (this->unk20C == 40) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); EnBigpo_SetupWarpOut(this); } } this->actionFunc(this, globalCtx); if ((this->actionFunc != EnBigpo_SpawnCutsceneStage6) && (this->actionFunc != EnBigpo_SpawnCutsceneStage4)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } if (this->actionFunc == EnBigpo_LanternFalling) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 27.0f, 60.0f, 4); } if (this->actor.draw == EnBigpo_DrawScoopSoul) { - Actor_SetHeight(&this->actor, -10.0f); + Actor_SetFocus(&this->actor, -10.0f); } else { - Actor_SetHeight(&this->actor, 42.0f); + Actor_SetFocus(&this->actor, 42.0f); } EnBigpo_UpdateColor(this); @@ -1252,7 +1246,7 @@ void EnBigpo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if ((this->actionFunc == EnBigpo_BurnAwayDeath) && (this->idleTimer >= 2) && (limbIndex == 8)) { gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfx)++, &D_060058B8); + gSPDisplayList((*gfx)++, &gBigpoDrawCrispyBodyDL); } if (limbIndex == 7) { @@ -1305,7 +1299,7 @@ void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx) { // fully visible OR fully transparent dispHead = POLY_OPA_DISP; gSPDisplayList(dispHead, &sSetupDL[6 * 0x19]); - gSPSegment(&dispHead[1], 0x0C, &D_801AEFA0); + gSPSegment(&dispHead[1], 0x0C, &D_801AEFA0); // empty display list for no transparency gSPSegment(&dispHead[2], 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, this->mainColor.r, this->mainColor.g, this->mainColor.b, this->mainColor.a)); @@ -1315,7 +1309,7 @@ void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx) { } else { dispHead = POLY_XLU_DISP; gSPDisplayList(dispHead, &sSetupDL[6 * 0x19]); - gSPSegment(&dispHead[1], 0x0C, &D_801AEF88); + gSPSegment(&dispHead[1], 0x0C, &D_801AEF88); // transparency display list gSPSegment(&dispHead[2], 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, this->mainColor.r, this->mainColor.g, this->mainColor.b, this->mainColor.a)); @@ -1360,7 +1354,7 @@ void EnBigpo_DrawScoopSoul(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, &D_06001BB0); + gSPDisplayList(POLY_XLU_DISP++, &gBigpoDrawSoulDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1384,7 +1378,7 @@ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { magnitude2 = (magnitude > 1.0f) ? (20.0f / magnitude) : (20.0f); Math_Vec3f_Scale(&vec1, magnitude2); } else { - Math_Vec3f_Copy(&vec1, &D_801D15B0); + Math_Vec3f_Copy(&vec1, &gZeroVec3f); } { @@ -1412,9 +1406,9 @@ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(&dispHead[3], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(&dispHead[4], &D_060042C8); + gSPDisplayList(&dispHead[4], &gBigpoDrawLanternMainDL); - gSPDisplayList(&dispHead[5], &D_060043F8); + gSPDisplayList(&dispHead[5], &gBigpoDrawLanternPurpleTopDL); // fully transparent OR fully invisible if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { @@ -1461,7 +1455,7 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, &D_0407D590); // flame displaylist + gSPDisplayList(POLY_XLU_DISP++, &gGameplayKeepDrawFlameDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1488,7 +1482,7 @@ void EnBigpo_RevealedFire(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, &D_0407D590); // flame displaylist + gSPDisplayList(POLY_XLU_DISP++, &gGameplayKeepDrawFlameDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } 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 f67e80980d..d32947951c 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -1,10 +1,12 @@ /* * File: z_en_bigslime.c * Overlay: ovl_En_Bigslime - * Description: Mad Jelly (miniboss) + * Description: Mad Jelly & Gekko Miniboss: Fused Jellies & Gekko */ #include "z_en_bigslime.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "objects/object_bigslime/object_bigslime.h" #define FLAGS 0x00000235 @@ -12,40 +14,200 @@ void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx); void EnBigslime_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnBigslime_Update(Actor* thisx, GlobalContext* globalCtx); -void EnBigslime_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBigslime_UpdateGekko(Actor* thisx, GlobalContext* globalCtx); +void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx); -void func_808E6E80(EnBigslime* this, GlobalContext* globalCtx); -void func_808E6F50(EnBigslime* this, GlobalContext* globalCtx); -void func_808E7048(EnBigslime* this, GlobalContext* globalCtx); -void func_808E71FC(EnBigslime* this, GlobalContext* globalCtx); -void func_808E7354(EnBigslime* this, GlobalContext* globalCtx); -void func_808E7B80(EnBigslime* this, GlobalContext* globalCtx); -void func_808E84DC(EnBigslime* this, GlobalContext* globalCtx); -void func_808E89CC(EnBigslime* this, GlobalContext* globalCtx); -void func_808E8CCC(EnBigslime* this, GlobalContext* globalCtx); -void func_808E91EC(EnBigslime* this, GlobalContext* globalCtx); -void func_808E97D0(EnBigslime* this, GlobalContext* globalCtx); -void func_808E9AE0(EnBigslime* this, GlobalContext* globalCtx); -void func_808E9DD0(EnBigslime* this, GlobalContext* globalCtx); -void func_808E9FC0(EnBigslime* this, GlobalContext* globalCtx); -void func_808EA1C8(EnBigslime* this, GlobalContext* globalCtx); -void func_808EA2D0(EnBigslime* this, GlobalContext* globalCtx); -void func_808EA5E8(EnBigslime* this, GlobalContext* globalCtx); -void func_808EA7A4(EnBigslime* this, GlobalContext* globalCtx); -void func_808EA860(EnBigslime* this, GlobalContext* globalCtx); -void func_808EA9B8(EnBigslime* this, GlobalContext* globalCtx); -void func_808EAA8C(EnBigslime* this, GlobalContext* globalCtx); -void func_808EAB74(EnBigslime* this, GlobalContext* globalCtx); -void func_808EACEC(EnBigslime* this, GlobalContext* globalCtx); -void func_808EB0A8(EnBigslime* this, GlobalContext* globalCtx); -void func_808EB24C(EnBigslime* this, GlobalContext* globalCtx); -void func_808EB574(EnBigslime* this, GlobalContext* globalCtx); -void func_808EB708(EnBigslime* this, GlobalContext* globalCtx); -void func_808EB804(EnBigslime* this, GlobalContext* globalCtx); -void func_808EB8B4(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_EndCutscene(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_CutsceneStartBattle(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupCutsceneNoticePlayer(EnBigslime* this); +void EnBigslime_CutsceneNoticePlayer(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupCallMinislime(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_CallMinislime(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_MoveOnCeiling(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupDrop(EnBigslime* this); +void EnBigslime_Drop(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetTargetVtxToWideCone(EnBigslime* this); +void EnBigslime_SquishFlat(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupSquishFlat(EnBigslime* this); +void EnBigslime_SetTargetVtxToThinCone(EnBigslime* this); +void EnBigslime_SetTargetVtxToInverseCone(EnBigslime* this); +void EnBigslime_SetTargetVtxToStaticVtx(EnBigslime* this); +void EnBigslime_SetupRise(EnBigslime* this); +void EnBigslime_Rise(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_CutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupAttackPlayerInBigslime(EnBigslime* this); +void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupWindupThrowPlayer(EnBigslime* this); +void EnBigslime_WindupThrowPlayer(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupSetDynamicVtxThrowPlayer(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetDynamicVtxThrowPlayer(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupFrozenGround(EnBigslime* this); +void EnBigslime_FrozenGround(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_Freeze(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_Melt(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupFrozenFall(EnBigslime* this); +void EnBigslime_FrozenFall(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupJumpGekko(EnBigslime* this); +void EnBigslime_JumpGekko(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupIdleLookAround(EnBigslime* this); +void EnBigslime_IdleLookAround(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupIdleNoticePlayer(EnBigslime* this); +void EnBigslime_IdleNoticePlayer(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupThrowMinislime(EnBigslime* this); +void EnBigslime_DamageGekko(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_StunGekko(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_CutsceneFormBigslime(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupFormBigslime(EnBigslime* this); +void EnBigslime_FormBigslime(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_CutsceneDefeat(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupGekkoDespawn(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_GekkoDespawn(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupFrogSpawn(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_FrogSpawn(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupDespawn(EnBigslime* this); +void EnBigslime_Despawn(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupInitEntrance(EnBigslime* this); +void EnBigslime_InitEntrance(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_ThrowMinislime(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_SetupCutscene(EnBigslime* this); +void EnBigslime_PlayCutscene(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx); +void EnBigslime_UpdateBigslime(Actor* thisx, GlobalContext* globalCtx); +void EnBigslime_DrawBigslime(Actor* thisx, GlobalContext* globalCtx); +void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx); + +/* + * Bigslime Spherical Vtx Data: + * - The vtx data for Bigslime is put directly into the overlay + * - This vtx is directly manipulated in a significant number of functions in this overlay + * - The initialized vtx data has the following properties: (some of this data may change as overlay functions are + * called) + * -- It is a sphere with radius 1000 + * -- There are 162 vertices numbered top to bottom along the y-axis, + * with vertex 0 being the top apex, and vertex 161 being the bottom apex + * -- There are 4 entire copies of the sphere + * --- The first 3 copies are identical + * --- All 4 copies have identical coordinates and number of vertices + * --- See below (variants) for the uses of these copies + * + * Vtx Rings: + * - The vtx mesh was designed to be seperated into distint "rings" of vertices and faces + * from top to bottom at discrete y-intervals + * - These different rings of vertices lie in the xzPlane along discrete y-direction steps of the sphere + * -- There are the single apex nodes at the top (vertex 0 y-coordiante 1000) and bottom (vertex 161 + * y-coordiante -1000) + * -- There are a cluster of vertices (vertex 1-5) which all have y-coordinate 962 + * and form a ring of vertices in the xz-plane + * -- There are a cluster of vertices (vertex 6-15) which all have y-coordinate around 870 + * and form a ring of vertices in the xz-plane + * -- So on and so forth (See sVtxRingStartIndex) + * -- BIGSLIME_NUM_RING_VTX: There are a total of 13 rings of vertices including the two single apex vertex + * -- BIGSLIME_NUM_RING_FACES: There are a total of 12 rings of faces between the rings of vertices + * - A collider is assigned to each of the 12 rings of faces for bigslime + * + * Three Variants of the Spherical Vtx: + * Static (1 copy): + * - Fixed mesh, no values are ever modified + * - Used as reference to store the original vertices + * - Never drawn, only used in calculations + * Dynamic (2 copies): + * - Coordinate are updated and deformed, mesh is drawn as the deforming Fused Jelly. + * - Initially Identical to Static. + * - Two copies are used that alternate every frame and copies over coordinates/normals immediately. + * One copy is the version that is drawn, and the other copy is updated in the background + * - Alpha values remain fixed + * Target (1 copy): + * - Used to define the target vertices/shape for the dynamic vertices to smoothly step to. + * - When frozen: + * -- The current target vertices are set to the current dynamic vertices + * -- These are the vertices that are used to draw the frozen Fused Jelly + * -- The alpha values are used for the frozen effects alpha + */ + +// Reference data: used to store the original vertices +static Vtx sBigslimeStaticVtx[BIGSLIME_NUM_VTX] = { +#include "overlays/ovl_En_Bigslime/sBigslimeStaticVtx.vtx.inc" +}; + +// Dynamic data: used to draw the real shape and has 2 states +static Vtx sBigslimeDynamicVtx[2][BIGSLIME_NUM_VTX] = { + { +#include "overlays/ovl_En_Bigslime/sBigslimeDynamicState0Vtx.vtx.inc" + }, + { +#include "overlays/ovl_En_Bigslime/sBigslimeDynamicState1Vtx.vtx.inc" + }, +}; + +// Target data: used to define the shape the dynamic vertices morph to +static Vtx sBigslimeTargetVtx[BIGSLIME_NUM_VTX] = { +#include "overlays/ovl_En_Bigslime/sBigslimeTargetVtx.vtx.inc" +}; + +/* + * Triangle face + * Connectivity matrix for mesh above. Covers every triangle in the sphere + * 320 triangles x 3 vertices per triangle + * Purpose: indices to calculate/update normal vector for lighting calculations + * "EnBigslimeTri" struct based on "Tri" struct from gbi.h, but without the flag + */ +static EnBigslimeTri sEnbigslimeTri[BIGSLIME_NUM_FACES] = { + { 0, 2, 1 }, { 1, 7, 6 }, { 1, 2, 7 }, { 2, 8, 7 }, { 6, 17, 16 }, { 6, 7, 17 }, + { 8, 19, 18 }, { 7, 8, 18 }, { 7, 18, 17 }, { 9, 21, 20 }, { 0, 3, 2 }, { 2, 9, 8 }, + { 2, 3, 9 }, { 3, 10, 9 }, { 8, 20, 19 }, { 8, 9, 20 }, { 10, 22, 21 }, { 9, 10, 21 }, + { 0, 4, 3 }, { 3, 11, 10 }, { 3, 4, 11 }, { 4, 12, 11 }, { 10, 23, 22 }, { 10, 11, 23 }, + { 12, 25, 24 }, { 11, 12, 24 }, { 11, 24, 23 }, { 13, 27, 26 }, { 0, 5, 4 }, { 4, 13, 12 }, + { 4, 5, 13 }, { 5, 14, 13 }, { 12, 26, 25 }, { 12, 13, 26 }, { 14, 28, 27 }, { 13, 14, 27 }, + { 0, 1, 5 }, { 5, 15, 14 }, { 5, 1, 15 }, { 1, 6, 15 }, { 14, 29, 28 }, { 14, 15, 29 }, + { 6, 16, 30 }, { 15, 6, 30 }, { 15, 30, 29 }, { 16, 32, 31 }, { 16, 17, 32 }, { 17, 33, 32 }, + { 17, 18, 33 }, { 18, 34, 33 }, { 18, 19, 34 }, { 19, 35, 34 }, { 19, 20, 36 }, { 20, 37, 36 }, + { 20, 21, 37 }, { 21, 38, 37 }, { 21, 22, 38 }, { 22, 39, 38 }, { 19, 36, 35 }, { 22, 40, 39 }, + { 22, 23, 40 }, { 23, 41, 40 }, { 23, 24, 41 }, { 24, 42, 41 }, { 24, 25, 42 }, { 25, 43, 42 }, + { 25, 26, 44 }, { 26, 45, 44 }, { 26, 27, 45 }, { 27, 46, 45 }, { 27, 28, 46 }, { 28, 47, 46 }, + { 25, 44, 43 }, { 28, 48, 47 }, { 28, 29, 48 }, { 29, 49, 48 }, { 29, 30, 49 }, { 30, 50, 49 }, + { 30, 16, 50 }, { 16, 31, 50 }, { 31, 32, 51 }, { 32, 52, 51 }, { 32, 33, 52 }, { 33, 53, 52 }, + { 33, 34, 53 }, { 34, 54, 53 }, { 34, 35, 54 }, { 35, 55, 54 }, { 35, 36, 55 }, { 36, 56, 55 }, + { 36, 37, 56 }, { 37, 57, 56 }, { 37, 38, 57 }, { 38, 58, 57 }, { 38, 39, 58 }, { 39, 59, 58 }, + { 39, 40, 59 }, { 40, 60, 59 }, { 40, 41, 60 }, { 41, 61, 60 }, { 41, 42, 61 }, { 42, 62, 61 }, + { 42, 43, 62 }, { 43, 63, 62 }, { 51, 72, 71 }, { 51, 52, 72 }, { 52, 73, 72 }, { 52, 53, 73 }, + { 53, 74, 73 }, { 53, 54, 74 }, { 54, 75, 74 }, { 54, 55, 75 }, { 55, 76, 75 }, { 55, 56, 76 }, + { 56, 77, 76 }, { 56, 57, 77 }, { 57, 78, 77 }, { 57, 58, 78 }, { 58, 79, 78 }, { 58, 59, 79 }, + { 59, 80, 79 }, { 59, 60, 80 }, { 60, 81, 80 }, { 60, 61, 81 }, { 61, 82, 81 }, { 61, 62, 82 }, + { 62, 83, 82 }, { 62, 63, 83 }, { 71, 72, 91 }, { 72, 92, 91 }, { 72, 73, 92 }, { 73, 93, 92 }, + { 73, 74, 93 }, { 74, 94, 93 }, { 74, 75, 94 }, { 75, 95, 94 }, { 75, 76, 95 }, { 76, 96, 95 }, + { 76, 77, 96 }, { 77, 97, 96 }, { 77, 78, 97 }, { 78, 98, 97 }, { 78, 79, 98 }, { 79, 99, 98 }, + { 79, 80, 99 }, { 80, 100, 99 }, { 80, 81, 100 }, { 81, 101, 100 }, { 81, 82, 101 }, { 82, 102, 101 }, + { 82, 83, 102 }, { 83, 103, 102 }, { 91, 112, 111 }, { 91, 92, 112 }, { 92, 113, 112 }, { 92, 93, 113 }, + { 93, 114, 113 }, { 93, 94, 114 }, { 94, 115, 114 }, { 94, 95, 115 }, { 95, 116, 115 }, { 95, 96, 116 }, + { 96, 117, 116 }, { 96, 97, 117 }, { 97, 118, 117 }, { 97, 98, 118 }, { 98, 119, 118 }, { 98, 99, 119 }, + { 99, 120, 119 }, { 99, 100, 120 }, { 100, 121, 120 }, { 100, 101, 121 }, { 101, 122, 121 }, { 101, 102, 122 }, + { 102, 123, 122 }, { 102, 103, 123 }, { 43, 44, 63 }, { 44, 64, 63 }, { 44, 45, 64 }, { 45, 65, 64 }, + { 45, 46, 65 }, { 46, 66, 65 }, { 46, 47, 66 }, { 47, 67, 66 }, { 47, 48, 67 }, { 48, 68, 67 }, + { 48, 49, 68 }, { 49, 69, 68 }, { 49, 50, 69 }, { 50, 70, 69 }, { 50, 31, 70 }, { 31, 51, 70 }, + { 63, 84, 83 }, { 63, 64, 84 }, { 64, 85, 84 }, { 64, 65, 85 }, { 65, 86, 85 }, { 65, 66, 86 }, + { 66, 87, 86 }, { 66, 67, 87 }, { 67, 88, 87 }, { 67, 68, 88 }, { 68, 89, 88 }, { 68, 69, 89 }, + { 69, 90, 89 }, { 69, 70, 90 }, { 70, 71, 90 }, { 70, 51, 71 }, { 83, 84, 103 }, { 84, 104, 103 }, + { 84, 85, 104 }, { 85, 105, 104 }, { 85, 86, 105 }, { 86, 106, 105 }, { 86, 87, 106 }, { 87, 107, 106 }, + { 87, 88, 107 }, { 88, 108, 107 }, { 88, 89, 108 }, { 89, 109, 108 }, { 89, 90, 109 }, { 90, 110, 109 }, + { 90, 71, 110 }, { 71, 91, 110 }, { 103, 124, 123 }, { 103, 104, 124 }, { 104, 125, 124 }, { 104, 105, 125 }, + { 105, 126, 125 }, { 105, 106, 126 }, { 106, 127, 126 }, { 106, 107, 127 }, { 107, 128, 127 }, { 107, 108, 128 }, + { 108, 129, 128 }, { 108, 109, 129 }, { 109, 130, 129 }, { 109, 110, 130 }, { 110, 111, 130 }, { 110, 91, 111 }, + { 161, 160, 156 }, { 155, 146, 160 }, { 146, 156, 160 }, { 146, 147, 156 }, { 144, 145, 155 }, { 145, 146, 155 }, + { 145, 131, 146 }, { 131, 147, 146 }, { 131, 132, 147 }, { 134, 135, 149 }, { 161, 156, 157 }, { 147, 148, 156 }, + { 148, 157, 156 }, { 148, 149, 157 }, { 132, 133, 147 }, { 133, 148, 147 }, { 133, 134, 148 }, { 134, 149, 148 }, + { 161, 157, 158 }, { 149, 150, 157 }, { 150, 158, 157 }, { 150, 151, 158 }, { 135, 136, 149 }, { 136, 150, 149 }, + { 136, 137, 150 }, { 137, 151, 150 }, { 137, 138, 151 }, { 140, 141, 153 }, { 161, 158, 159 }, { 151, 152, 158 }, + { 152, 159, 158 }, { 152, 153, 159 }, { 138, 139, 151 }, { 139, 152, 151 }, { 139, 140, 152 }, { 140, 153, 152 }, + { 161, 159, 160 }, { 153, 154, 159 }, { 154, 160, 159 }, { 154, 155, 160 }, { 141, 142, 153 }, { 142, 154, 153 }, + { 142, 143, 154 }, { 143, 155, 154 }, { 143, 144, 155 }, { 111, 131, 145 }, { 111, 112, 131 }, { 112, 132, 131 }, + { 112, 113, 132 }, { 113, 114, 132 }, { 114, 133, 132 }, { 114, 115, 133 }, { 115, 116, 134 }, { 116, 135, 134 }, + { 116, 117, 135 }, { 117, 118, 135 }, { 118, 136, 135 }, { 118, 119, 136 }, { 115, 134, 133 }, { 119, 137, 136 }, + { 119, 120, 137 }, { 120, 138, 137 }, { 120, 121, 138 }, { 121, 122, 138 }, { 122, 139, 138 }, { 122, 123, 139 }, + { 139, 123, 140 }, { 140, 123, 124 }, { 140, 124, 141 }, { 141, 124, 125 }, { 141, 125, 126 }, { 141, 126, 142 }, + { 142, 127, 143 }, { 143, 127, 128 }, { 143, 128, 144 }, { 144, 128, 129 }, { 144, 129, 130 }, { 144, 130, 145 }, + { 142, 126, 127 }, { 130, 111, 145 }, +}; -#if 0 const ActorInit En_Bigslime_InitVars = { ACTOR_EN_BIGSLIME, ACTORCAT_BOSS, @@ -54,289 +216,2940 @@ const ActorInit En_Bigslime_InitVars = { sizeof(EnBigslime), (ActorFunc)EnBigslime_Init, (ActorFunc)EnBigslime_Destroy, - (ActorFunc)EnBigslime_Update, - (ActorFunc)EnBigslime_Draw, + (ActorFunc)EnBigslime_UpdateGekko, + (ActorFunc)EnBigslime_DrawGekko, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808F02A0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 30, 60, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808F02CC = { 10, 100, 100, 50 }; +static CollisionCheckInfoInit sColChkInfoInit = { 10, 100, 100, 50 }; -// static DamageTable sDamageTable = { -static DamageTable D_808F02D4 = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* 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, 0xF), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(1, 0x2), - /* Ice arrow */ DMG_ENTRY(1, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0xD), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(0, 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, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(1, 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 */ BIGSLIME_DMGEFF_NONE, + /* 0x0 */ BIGSLIME_DMGEFF_STUN, + /* 0x2 */ BIGSLIME_DMGEFF_FIRE, + /* 0x3 */ BIGSLIME_DMGEFF_ICE, + /* 0x4 */ BIGSLIME_DMGEFF_LIGHT, + /* 0x5 */ BIGSLIME_DMGEFF_ELECTRIC_STUN, + /* 0xD */ BIGSLIME_DMGEFF_DEKU_STUN = 0xD, + /* 0xE */ BIGSLIME_DMGEFF_HOOKSHOT, + /* 0xF */ BIGSLIME_DMGEFF_BREAK_ICE, +} BigslimeDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, BIGSLIME_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, BIGSLIME_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, BIGSLIME_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, BIGSLIME_DMGEFF_BREAK_ICE), + /* Zora boomerang */ DMG_ENTRY(1, BIGSLIME_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, BIGSLIME_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, BIGSLIME_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, BIGSLIME_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, BIGSLIME_DMGEFF_BREAK_ICE), + /* Sword */ DMG_ENTRY(1, BIGSLIME_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, BIGSLIME_DMGEFF_BREAK_ICE), + /* Fire arrow */ DMG_ENTRY(1, BIGSLIME_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(1, BIGSLIME_DMGEFF_ICE), + /* Light arrow */ DMG_ENTRY(2, BIGSLIME_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, BIGSLIME_DMGEFF_BREAK_ICE), + /* Deku spin */ DMG_ENTRY(0, BIGSLIME_DMGEFF_DEKU_STUN), + /* Deku bubble */ DMG_ENTRY(1, BIGSLIME_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, BIGSLIME_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, BIGSLIME_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, BIGSLIME_DMGEFF_ELECTRIC_STUN), + /* Normal shield */ DMG_ENTRY(0, BIGSLIME_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, BIGSLIME_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, BIGSLIME_DMGEFF_BREAK_ICE), + /* Zora punch */ DMG_ENTRY(1, BIGSLIME_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, BIGSLIME_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(1, BIGSLIME_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, BIGSLIME_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, BIGSLIME_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, BIGSLIME_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, BIGSLIME_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, BIGSLIME_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, BIGSLIME_DMGEFF_BREAK_ICE), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808F0338[] = { +// Start vtx numbers for each ring in the vtx sphere +static s32 sVtxRingStartIndex[] = { + 0, 1, 6, 16, 31, 51, 71, 91, 111, 131, 146, 156, 161, BIGSLIME_NUM_VTX, +}; + +static AnimationHeader* sGekkoAttackAnimations[] = { + &gGekkoJabPunchAnim, + &gGekkoHookPunchAnim, + &gGekkoKickAnim, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 95, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(targetArrowOffset, -13221, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 5, ICHAIN_STOP), }; -#endif - -extern ColliderCylinderInit D_808F02A0; -extern CollisionCheckInfoInit D_808F02CC; -extern DamageTable D_808F02D4; -extern InitChainEntry D_808F0338[]; - -extern UNK_TYPE D_060010F4; -extern UNK_TYPE D_06001B08; -extern UNK_TYPE D_0600276C; -extern UNK_TYPE D_06002E0C; -extern UNK_TYPE D_0600347C; -extern UNK_TYPE D_060039C4; -extern UNK_TYPE D_060066B4; -extern UNK_TYPE D_060069FC; -extern UNK_TYPE D_06007790; -extern UNK_TYPE D_0600F048; -extern UNK_TYPE D_0600F990; -extern UNK_TYPE D_0600FB40; -extern UNK_TYPE D_06010530; -extern UNK_TYPE D_06011050; -extern UNK_TYPE D_060113B0; - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/EnBigslime_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/EnBigslime_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E5388.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E5430.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E5484.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E574C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E5988.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E5A00.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E5BB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E5ED4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E601C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E616C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E62B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E64D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6538.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6570.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E670C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6828.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E68AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E69AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E69F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6A70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6B08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6B68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6C18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6C44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6C70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6CC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6D58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6E80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6F08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6F50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E6FE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E7048.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E7154.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E71FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E732C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E7354.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E75D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E7770.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E7AF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E7B80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E7D68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E8064.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E836C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E844C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E84DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E88B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E89CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E8C38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E8CCC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E90A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E91EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E9778.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E97D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E994C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E9AE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E9DA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E9DD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E9F38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808E9FC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EA14C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EA1C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EA264.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EA2D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EA538.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EA5E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EA748.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EA7A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EA80C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EA860.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EA8FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EA9B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EAA40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EAA8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EAAF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EAB74.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EABCC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EACEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EAEBC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EB0A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EB178.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EB24C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EB328.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EB574.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EB690.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EB708.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EB7F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EB804.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EB83C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EB8B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EB9E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EBBE4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EBED0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EC158.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EC354.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/EnBigslime_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EC708.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808EC990.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808ECD14.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808ED07C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/EnBigslime_Draw.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bigslime/func_808ED3F4.s") +void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx) { + // gSaveContext.weekEventReg[KEY] = VALUE + // KEY | VALUE + static s32 isFrogReturnedFlags[] = { + (32 << 8) | 0x40, // Woodfall Temple Frog Returned + (32 << 8) | 0x80, // Great Bay Temple Frog Returned + (33 << 8) | 0x01, // Southern Swamp Frog Returned + (33 << 8) | 0x02, // Laundry Pool Frog Returned + }; + EnBigslime* this = THIS; + GlobalContext* globalCtx2 = globalCtx; + s32 i; + + Actor_ProcessInitChain(&this->actor, sInitChain); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGekkoSkel, &gGekkoLookAroundAnim, this->jointTable, + this->morphTable, GEKKO_LIMB_MAX); + + for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { + Collider_InitAndSetCylinder(globalCtx, &this->bigslimeCollider[i], &this->actor, &sCylinderInit); + } + + this->bigslimeCollider[0].base.atFlags &= ~AT_ON; + Collider_InitAndSetCylinder(globalCtx, &this->gekkoCollider, &this->actor, &sCylinderInit); + this->gekkoCollider.base.colType = COLTYPE_HIT6; + this->gekkoCollider.info.elemType = ELEMTYPE_UNK1; + this->gekkoCollider.base.atFlags &= ~AT_ON; + this->gekkoCollider.base.ocFlags1 &= ~OC1_NO_PUSH; + this->actor.params = CLAMP(this->actor.params, 1, 4); + + if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { + Actor_MarkForDeath(&this->actor); + if (!(gSaveContext.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & + (u8)isFrogReturnedFlags[this->actor.params - 1])) { + Actor_Spawn(&globalCtx2->actorCtx, globalCtx, ACTOR_EN_MINIFROG, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, + this->actor.params); + } + } else { + this->cutscene = this->actor.cutscene; + this->actor.scale.x = this->actor.scale.z = 0.15f; + this->actor.scale.y = 0.075f; + this->vtxScaleX = this->vtxScaleZ = 0.015000001f; + this->actor.home.pos.x = GBT_ROOM_5_CENTER_X; + this->actor.home.pos.y = GBT_ROOM_5_MAX_Y - 75.0f; + this->actor.home.pos.z = GBT_ROOM_5_CENTER_Z; + for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { + this->minislime[i] = (EnMinislime*)Actor_SpawnAsChild(&globalCtx2->actorCtx, &this->actor, globalCtx, + ACTOR_EN_MINISLIME, 0.0f, 0.0f, 0.0f, 0, 0, 0, i); + if (this->minislime[i] == NULL) { + for (i = i - 1; i >= 0; i--) { + Actor_MarkForDeath(&this->minislime[i]->actor); + } + + Actor_MarkForDeath(&this->actor); + return; + } + } + + this->minislimeFrozenTexAnim = Lib_SegmentedToVirtual(&gMinislimeFrozenTexAnim); + 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.shape.shadowAlpha = 255; + this->gekkoScale = 0.007f; + this->actor.shape.rot.y = 0; + this->minislimeToThrow = this->minislime[0]; + EnBigslime_SetupInitEntrance(this); + } +} + +void EnBigslime_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBigslime* this = THIS; + s32 i; + + for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { + Collider_DestroyCylinder(globalCtx, &this->bigslimeCollider[i]); + } + + Collider_DestroyCylinder(globalCtx, &this->gekkoCollider); + Audio_StopSfxByPos(&this->gekkoProjectedPos); +} + +void EnBigslime_DynamicVtxCopyState(EnBigslime* this) { + Vtx* dynamicVtxDest; + Vtx* dynamicVtxSrc; + s32 i; + s32 j; + + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + dynamicVtxDest = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + dynamicVtxSrc = &sBigslimeDynamicVtx[this->dynamicVtxState ^ 1][i]; + for (j = 0; j < 3; j++) { + dynamicVtxDest->n.ob[j] = dynamicVtxSrc->n.ob[j]; + dynamicVtxDest->n.n[j] = dynamicVtxSrc->n.n[j]; + } + } +} + +void EnBigslime_Vec3fNormalize(Vec3f* vec) { + f32 magnitude = Math3D_Vec3fMagnitude(vec); + + if (magnitude > 1.0f) { + Math_Vec3f_Scale(vec, 1.0f / magnitude); + } +} + +/** + * Updates the surface normal vector of each vertex in the fused jelly mesh + * each frame as the dynamic vtx is constantly changing shape + */ +void EnBigslime_UpdateSurfaceNorm(EnBigslime* this) { + Vec3f vtxNorm[BIGSLIME_NUM_VTX]; + Vec3f vecTriEdge1; + Vec3f vecTriEdge2; + Vec3f vecTriNorm; + Vec3f* vtxNormAddr; + Vtx* dynamicVtx; + Vtx* dynamicVtx12; + Vtx* dynamicVtx0; + s32 i; + + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + Math_Vec3f_Copy(&vtxNorm[i], &gZeroVec3f); + } + + for (i = 0; i < BIGSLIME_NUM_FACES; i++) { + dynamicVtx0 = &sBigslimeDynamicVtx[this->dynamicVtxState][sEnbigslimeTri[i].v[0]]; + dynamicVtx12 = &sBigslimeDynamicVtx[this->dynamicVtxState][sEnbigslimeTri[i].v[1]]; + vecTriEdge1.x = dynamicVtx12->n.ob[0] - dynamicVtx0->n.ob[0]; + vecTriEdge1.y = dynamicVtx12->n.ob[1] - dynamicVtx0->n.ob[1]; + vecTriEdge1.z = dynamicVtx12->n.ob[2] - dynamicVtx0->n.ob[2]; + + dynamicVtx12 = &sBigslimeDynamicVtx[this->dynamicVtxState][sEnbigslimeTri[i].v[2]]; + vecTriEdge2.x = dynamicVtx12->n.ob[0] - dynamicVtx0->n.ob[0]; + vecTriEdge2.y = dynamicVtx12->n.ob[1] - dynamicVtx0->n.ob[1]; + vecTriEdge2.z = dynamicVtx12->n.ob[2] - dynamicVtx0->n.ob[2]; + + Math3D_CrossProduct(&vecTriEdge1, &vecTriEdge2, &vecTriNorm); + EnBigslime_Vec3fNormalize(&vecTriNorm); + + Math_Vec3f_Sum(&vtxNorm[sEnbigslimeTri[i].v[0]], &vecTriNorm, &vtxNorm[sEnbigslimeTri[i].v[0]]); + Math_Vec3f_Sum(&vtxNorm[sEnbigslimeTri[i].v[1]], &vecTriNorm, &vtxNorm[sEnbigslimeTri[i].v[1]]); + Math_Vec3f_Sum(&vtxNorm[sEnbigslimeTri[i].v[2]], &vecTriNorm, &vtxNorm[sEnbigslimeTri[i].v[2]]); + } + + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + vtxNormAddr = &vtxNorm[i]; + EnBigslime_Vec3fNormalize(vtxNormAddr); + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + dynamicVtx->n.n[0] = vtxNormAddr->x * 120.0f; + dynamicVtx->n.n[1] = vtxNormAddr->y * 120.0f; + dynamicVtx->n.n[2] = vtxNormAddr->z * 120.0f; + } +} + +void EnBigslime_GetMaxMinVertices(EnBigslime* this, Vec3f* vtxMax, Vec3f* vtxMin) { + Vtx* dynamicVtx; + s16 vtxMaxX = 0; + s16 vtxMaxY = 0; + s16 vtxMaxZ = 0; + s16 vtxMinX = 0; + s16 vtxMinY = 0; + s16 vtxMinZ = 0; + s32 i; + + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + + if (vtxMaxX < dynamicVtx->n.ob[0]) { + vtxMaxX = dynamicVtx->n.ob[0]; + } else if (vtxMinX > dynamicVtx->n.ob[0]) { + vtxMinX = dynamicVtx->n.ob[0]; + } + + if (vtxMaxY < dynamicVtx->n.ob[1]) { + vtxMaxY = dynamicVtx->n.ob[1]; + } else if (vtxMinY > dynamicVtx->n.ob[1]) { + vtxMinY = dynamicVtx->n.ob[1]; + } + + if (vtxMaxZ < dynamicVtx->n.ob[2]) { + vtxMaxZ = dynamicVtx->n.ob[2]; + } else if (vtxMinZ > dynamicVtx->n.ob[2]) { + vtxMinZ = dynamicVtx->n.ob[2]; + } + } + + vtxMax->x = vtxMaxX * this->actor.scale.x; + vtxMax->y = vtxMaxY * this->actor.scale.y; + vtxMax->z = vtxMaxZ * this->actor.scale.z; + + vtxMin->x = vtxMinX * this->actor.scale.x; + vtxMin->y = vtxMinY * this->actor.scale.y; + vtxMin->z = vtxMinZ * this->actor.scale.z; +} + +void EnBigslime_UpdateScale(EnBigslime* this, Vec3f* vtxMax, Vec3f* vtxMin) { + if (vtxMin->x < vtxMax->x) { + this->vtxScaleX = vtxMax->x * (0.100000005f / BIGSLIME_RADIUS_F); + } else { + this->vtxScaleX = -vtxMin->x * (0.100000005f / BIGSLIME_RADIUS_F); + } + + if (vtxMin->z < vtxMax->z) { + this->vtxScaleZ = vtxMax->z * (0.100000005f / BIGSLIME_RADIUS_F); + } else { + this->vtxScaleZ = -vtxMin->z * (0.100000005f / BIGSLIME_RADIUS_F); + } +} + +/** + * Checks the world position against all walls, the floor, and the ceiling to ensure + * bigslime is not outside this range. Accounts only for the world position, and the + * maximum and minimum verticies. If any boundaries are crossed, the world position + * and bgCheckFlags are updated accordingly. + * + * Differs from EnBigslime_CheckVtxWallBoundaries by checking and updating + * a single world position instead of checking and updating individual vertices + */ +void EnBigslime_CheckRoomBoundaries(EnBigslime* this, Vec3f* vtxMax, Vec3f* vtxMin) { + f32 worldPosX; + f32 vtxMaxX; + f32 vtxMinX; + f32 worldPosZ; + f32 vtxMaxZ; + f32 vtxMinZ; + + this->actor.bgCheckFlags &= ~(0x2 | 0x8 | 0x10); + if ((this->actor.world.pos.y + vtxMax->y) > GBT_ROOM_5_MAX_Y) { + this->actor.world.pos.y = GBT_ROOM_5_MAX_Y - vtxMax->y; + this->actor.bgCheckFlags |= 0x10; + } + + if ((this->actor.world.pos.y + vtxMin->y) <= GBT_ROOM_5_MIN_Y) { + this->actor.world.pos.y = GBT_ROOM_5_MIN_Y - vtxMin->y; + if (!(this->actor.bgCheckFlags & 1)) { + this->actor.bgCheckFlags |= 2; + } + + this->actor.bgCheckFlags |= 1; + } else { + this->actor.bgCheckFlags &= ~1; + } + + if ((this->actionFunc != EnBigslime_Freeze) || !(this->actor.bgCheckFlags & 1)) { + worldPosX = this->actor.world.pos.x; + vtxMaxX = vtxMax->x; + if (GBT_ROOM_5_MAX_X < (worldPosX + vtxMaxX)) { + this->actor.bgCheckFlags |= 8; + this->actor.world.pos.x = GBT_ROOM_5_MAX_X - vtxMaxX; + } else { + vtxMinX = vtxMin->x; + if ((worldPosX + vtxMinX) < GBT_ROOM_5_MIN_X) { + this->actor.world.pos.x = GBT_ROOM_5_MIN_X - vtxMinX; + this->actor.bgCheckFlags |= 8; + } + } + + worldPosZ = this->actor.world.pos.z; + vtxMaxZ = vtxMax->z; + if (GBT_ROOM_5_MAX_Z < (worldPosZ + vtxMaxZ)) { + this->actor.bgCheckFlags |= 8; + this->actor.world.pos.z = GBT_ROOM_5_MAX_Z - vtxMaxZ; + } else { + vtxMinZ = vtxMin->z; + if ((worldPosZ + vtxMinZ) < GBT_ROOM_5_MIN_Z) { + this->actor.world.pos.z = GBT_ROOM_5_MIN_Z - vtxMinZ; + this->actor.bgCheckFlags |= 8; + } + } + } +} + +void EnBigslime_UpdateBigslimeCollider(EnBigslime* this, GlobalContext* globalCtx) { + Vtx* dynamicVtx; + f32 xzDist; + s16 vtxRingMaxY[BIGSLIME_NUM_RING_VTX]; + s16 vtxRingMinY[BIGSLIME_NUM_RING_VTX]; + f32 vtxRingMaxXZDist[BIGSLIME_NUM_RING_VTX]; + Cylinder16* dim; + f32 maxScaleXScaleZ = (this->actor.scale.z < this->actor.scale.x ? this->actor.scale.x : this->actor.scale.z); + s32 i; + s32 j; + + for (i = 0; i < BIGSLIME_NUM_RING_VTX; i++) { + vtxRingMaxY[i] = -30000; + vtxRingMinY[i] = 30000; + vtxRingMaxXZDist[i] = 0.0f; + + for (j = sVtxRingStartIndex[i]; j < sVtxRingStartIndex[i + 1]; j++) { + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][j]; + if (vtxRingMaxY[i] < dynamicVtx->n.ob[1]) { + vtxRingMaxY[i] = dynamicVtx->n.ob[1]; + } + + if (vtxRingMinY[i] > dynamicVtx->n.ob[1]) { + vtxRingMinY[i] = dynamicVtx->n.ob[1]; + } + + xzDist = sqrtf(SQ(dynamicVtx->n.ob[0]) + SQ(dynamicVtx->n.ob[2])); + if (vtxRingMaxXZDist[i] < xzDist) { + vtxRingMaxXZDist[i] = xzDist; + } + } + } + + for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { + dim = &this->bigslimeCollider[i].dim; + dim->pos.y = (vtxRingMinY[i + 1] * this->actor.scale.y) + this->actor.world.pos.y; + dim->height = (vtxRingMaxY[i] - vtxRingMinY[i + 1]) * this->actor.scale.y; + dim->radius = maxScaleXScaleZ * + (vtxRingMaxXZDist[i] < vtxRingMaxXZDist[i + 1] ? vtxRingMaxXZDist[i + 1] : vtxRingMaxXZDist[i]); + dim->height = CLAMP_MIN(dim->height, 1); + dim->pos.x = this->actor.world.pos.x; + dim->pos.z = this->actor.world.pos.z; + } + + if (this->bigslimeCollider[0].base.atFlags & AT_ON) { + for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->bigslimeCollider[i].base); + } + } + + if (this->bigslimeCollider[0].base.acFlags & AC_ON) { + for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bigslimeCollider[i].base); + } + } + + for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bigslimeCollider[i].base); + } +} + +void EnBigslime_AddWavySurface(EnBigslime* this) { + s32 randInt; + f32 randFloat; + s32 i; + + this->wavySurfaceTimer = 24; + randInt = (s32)(Rand_ZeroOne() * 6.0f) >> 1; + randFloat = (Rand_ZeroOne() * 40.0f) + 50.0f; + + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + if ((i % 6) == 0) { + randFloat = (Rand_ZeroOne() * 40.0f) + 50.0f; + } + + this->vtxSurfacePerturbation[i] = sin_rad((randInt + i) * (M_PI / 3)) * randFloat * 0.001f; + } +} + +void EnBigslime_UpdateWavySurface(EnBigslime* this) { + f32 vtxSurfaceWave; + Vtx* staticVtx; + Vtx* dynamicVtx; + s32 i; + s32 j; + + if (this->wavySurfaceTimer == 0) { + EnBigslime_AddWavySurface(this); + } + + this->wavySurfaceTimer--; + vtxSurfaceWave = sin_rad(this->wavySurfaceTimer * (M_PI / 12)); + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + staticVtx = &sBigslimeStaticVtx[i]; + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + for (j = 0; j < 3; j++) { + // Formula: dynamicVtx = staticVtx * (1 + sin * perturbation) + dynamicVtx->n.ob[j] = + staticVtx->n.ob[j] + (s32)(vtxSurfaceWave * staticVtx->n.ob[j] * this->vtxSurfacePerturbation[i]); + } + } +} + +void EnBigslime_InitFallMinislime(EnBigslime* this) { + EnMinislime* minislime; + s32 i; + + for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { + minislime = this->minislime[i]; + minislime->actor.params = MINISLIME_INIT_FALL; + minislime->actor.world.pos.x = randPlusMinusPoint5Scaled(80.0f) + (GBT_ROOM_5_MIN_X + ((i % 4) + 1) * 192.0f); + minislime->actor.world.pos.y = Rand_ZeroFloat(250.0f) + (GBT_ROOM_5_CENTER_Y + 50.0f); + minislime->actor.world.pos.z = randPlusMinusPoint5Scaled(80.0f) + (GBT_ROOM_5_MIN_Z + ((i / 4) + 1) * 192.0f); + } + + this->minislimeState = MINISLIME_ACTIVE_INIT_STATE; +} + +void EnBigslime_SetMinislimeBreakLocation(EnBigslime* this) { + // Minislime spawn at these vertices when Frozen Bigslime Shatters + static s32 minislimeSpawnVtx[] = { + 7, 9, 11, 13, 15, // 5 equally spaced vertices on vtx ring 2 from top + 52, 56, 60, 64, 68, // 5 equally spaced vertices on vtx ring 5 from top + 94, 98, 102, 106, 110, // 5 equally spaced vertices on vtx ring 7 from top + }; + Vtx* dynamicVtx; + EnMinislime* minislime; + s32 i; + + this->minislimeState = MINISLIME_ACTIVE_CONTINUE_STATE; + for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][minislimeSpawnVtx[i]]; + minislime = this->minislime[i]; + minislime->actor.params = MINISLIME_BREAK_BIGSLIME; + minislime->actor.world.pos.x = (dynamicVtx->n.ob[0] * this->actor.scale.x) + this->actor.world.pos.x; + minislime->actor.world.pos.y = (dynamicVtx->n.ob[1] * this->actor.scale.y) + this->actor.world.pos.y; + minislime->actor.world.pos.z = (dynamicVtx->n.ob[2] * this->actor.scale.z) + this->actor.world.pos.z; + minislime->actor.world.rot.x = 0x1000 + 0x333 * (MINISLIME_NUM_SPAWN - i); + } +} + +void EnBigslime_SetPlayerParams(EnBigslime* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (player->stateFlags2 & 0x80) { + player->actor.parent = NULL; + player->unk_AE8 = 100; + func_800B8D98(globalCtx, &this->actor, 10.0f, this->actor.world.rot.y, 10.0f); + } +} + +void EnBigslime_EndThrowMinislime(EnBigslime* this) { + if (this->actionFunc == EnBigslime_ThrowMinislime && + this->minislimeToThrow->actor.params == MINISLIME_SETUP_GEKKO_THROW) { + this->minislimeToThrow->actor.params = MINISLIME_IDLE; + } +} + +void EnBigslime_BreakIntoMinislime(EnBigslime* this, GlobalContext* globalCtx) { + s32 i; + s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + + Quake_SetSpeed(quake, 20000); + Quake_SetQuakeValues(quake, 15, 0, 0, 0); + Quake_SetCountdown(quake, 15); + func_8013ECE0(this->actor.xyzDistToPlayerSq, 180, 20, 100); + this->bigslimeCollider[0].base.atFlags &= ~AT_ON; + this->gekkoCollider.base.acFlags &= ~(AC_ON | AC_HIT); + + for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { + this->bigslimeCollider[i].base.acFlags &= ~AC_HIT; + } + + EnBigslime_SetMinislimeBreakLocation(this); + this->actor.update = EnBigslime_UpdateGekko; + this->actor.draw = EnBigslime_DrawGekko; + this->actor.gravity = -2.0f; + EnBigslime_SetPlayerParams(this, globalCtx); + EnBigslime_EndCutscene(this, globalCtx); + this->actor.colChkInfo.mass = 50; + this->actor.flags &= ~(0x1 | 0x400); + this->actor.flags |= 0x200; + this->actor.hintId = 95; + this->gekkoRot.x = 0; + this->gekkoRot.y = 0; + this->actor.bgCheckFlags &= ~1; + this->formBigslimeTimer = 2; + EnBigslime_AddIceShardEffect(this, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_BREAK); + EnBigslime_SetupJumpGekko(this); +} + +/** + * Smoothly moves the camera to a side view and keeps it there + * as bigslime grabs player and the Gekko melee-attacks player + */ +void EnBigslime_UpdateCameraGrabPlayer(EnBigslime* this, GlobalContext* globalCtx) { + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); + Vec3f subCamEye; + Vec3f subCamAt; + + Math_Vec3f_Copy(&subCamEye, &subCam->eye); + Math_Vec3f_Copy(&subCamAt, &subCam->at); + + Math_StepToF(&subCamEye.x, (Math_SinS(this->subCamYawGrabPlayer) * 250.0f) + this->actor.world.pos.x, 10.0f); + Math_StepToF(&subCamEye.y, GBT_ROOM_5_MIN_Y + 187.5f, 10.0f); + Math_StepToF(&subCamEye.z, (Math_CosS(this->subCamYawGrabPlayer) * 250.0f) + this->actor.world.pos.z, 10.0f); + + Math_StepToF(&subCamAt.x, this->actor.world.pos.x, 10.0f); + Math_StepToF(&subCamAt.y, GBT_ROOM_5_MIN_Y + 87.5f, 10.0f); + Math_StepToF(&subCamAt.z, this->actor.world.pos.z, 10.0f); + + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCamEye); +} + +/** + * Takes the camera eye and instantaneously moves it 10% closer to the focus point "at". + * This gives the camera a "jerk" feeling + * Used everytime player is hit inside of bigslime while being grabbed + */ +void EnBigslime_JerkCameraPlayerHit(EnBigslime* this, GlobalContext* globalCtx) { + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); + Vec3f subCamEye; + + Math_Vec3f_Diff(&subCam->eye, &subCam->at, &subCamEye); + Math_Vec3f_Scale(&subCamEye, 0.9f); + Math_Vec3f_Sum(&subCamEye, &subCam->at, &subCamEye); + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCam->at, &subCamEye); +} + +/** + * Performs the camera motion for the intro cutscene as the player enters the room + * and the battle starts. Positions the camera slightly offset from player, + * then zooms into the Gekko until the Gekko calls the minislimes down from the ceiling + */ +void EnBigslime_UpdateCameraIntroCs(EnBigslime* this, GlobalContext* globalCtx, s32 noticeTimer) { + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); + Vec3f subCamEye; + f32 zoom = (noticeTimer * 19.0f) + 67.0f; + s16 yawOffset = this->actor.yawTowardsPlayer + (noticeTimer * 0x31); + + subCamEye.x = Math_SinS(yawOffset) * zoom + subCam->at.x; + subCamEye.z = Math_CosS(yawOffset) * zoom + subCam->at.z; + subCamEye.y = subCam->at.y + -4.0f + (noticeTimer * 2.0f); + + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCam->at, &subCamEye); +} + +/** + * Takes the camera and makes the focus point (at) point at bigslime, who is on the + * center of the roof. This is used when the minislimes merges into bigslime. + */ +void EnBigslime_UpdateCameraFormingBigslime(EnBigslime* this, GlobalContext* globalCtx) { + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, + &Play_GetCamera(globalCtx, this->subCamId)->eye); +} + +void EnBigslime_EndCutscene(EnBigslime* this, GlobalContext* globalCtx) { + Camera* subCam; + + if (this->subCamId != MAIN_CAM) { + subCam = Play_GetCamera(globalCtx, this->subCamId); + Play_CameraSetAtEye(globalCtx, MAIN_CAM, &subCam->at, &subCam->eye); + this->subCamId = MAIN_CAM; + ActorCutscene_Stop(this->cutscene); + this->cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + func_800B724C(globalCtx, &this->actor, 6); + } +} + +void EnBigslime_Scale(EnBigslime* this, s16 pitch, f32 xzScale, f32 yScale) { + this->actor.scale.x = ((Math_SinS(pitch) * xzScale) + 1.5f) * 0.1f; // = 0.15f + 0.1f * xzScale * sin(pitch) + this->actor.scale.y = ((Math_CosS(pitch) * yScale) + 0.75f) * 0.1f; // = 0.075f + 0.1f * yScale * cos(pitch) + this->actor.scale.z = 0.3f - this->actor.scale.x; // = 0.15f - 0.1f * xzScale * sin(pitch) +} + +/** + * 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; + Math_Vec3f_Copy(&this->frozenPos, &this->actor.world.pos); + this->frozenPos.y = GBT_ROOM_5_MIN_Y; + this->shockwaveAlpha = 235; + this->shockwaveScale = 0.025f; +} + +/** + * Restores bigslime behaviour to the state before it was frozen + */ +void EnBigslime_SetTargetVtxFromPreFrozen(EnBigslime* this) { + this->bigslimeCollider[0].base.acFlags |= AC_ON; + this->actionFunc = this->actionFuncStored; + this->skelAnime.playSpeed = 1.0f; + if (this->actionFunc == EnBigslime_SquishFlat) { + this->bigslimeCollider[0].base.atFlags |= AT_ON; + EnBigslime_SetTargetVtxToWideCone(this); + } else if (this->actionFunc == EnBigslime_Rise) { + if (this->riseCounter == 0) { + EnBigslime_SetTargetVtxToThinCone(this); + } else if (this->riseCounter == 1) { + EnBigslime_SetTargetVtxToInverseCone(this); + } else { + EnBigslime_SetTargetVtxToStaticVtx(this); + } + } +} + +/** + * Plays the standard Gekko sound effects without reverb + */ +void EnBigslime_GekkoSfxOutsideBigslime(EnBigslime* this, u16 sfxId) { + Audio_PlaySfxAtPos(&this->gekkoProjectedPos, sfxId); +} + +/** + * Adds reverb to Gekko sound effects when enclosed by bigslime + */ +void EnBigslime_GekkoSfxInsideBigslime(EnBigslime* this, u16 sfxId) { + func_8019F420(&this->gekkoProjectedPos, sfxId); +} + +void EnBigslime_GekkoFreeze(EnBigslime* this) { + this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_FROZEN; + 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; +} + +void EnBigslime_GekkoThaw(EnBigslime* this, GlobalContext* globalCtx) { + if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_FROZEN) { + this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + this->gekkoCollider.base.colType = COLTYPE_HIT6; + this->gekkoCollider.info.elemType = ELEMTYPE_UNK1; + this->unk_388 = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); + this->actor.flags |= 0x200; + } +} + +void EnBigslime_SetupCutsceneStartBattle(EnBigslime* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); + + globalCtx->envCtx.unk_C3 = 4; + Animation_PlayLoop(&this->skelAnime, &gGekkoLookAroundAnim); + + this->bigslimeCollider[0].base.atFlags &= ~AT_ON; + this->bigslimeCollider[0].base.acFlags &= ~AC_ON; + + Math_Vec3f_Copy(&subCam->at, &this->actor.focus.pos); + func_800B7298(globalCtx, &this->actor, 4); + + player->actor.shape.rot.y = this->actor.yawTowardsPlayer + 0x8000; + player->actor.world.pos.x = Math_SinS(this->actor.yawTowardsPlayer) * 347.0f + this->actor.world.pos.x; + player->actor.world.pos.z = Math_CosS(this->actor.yawTowardsPlayer) * 347.0f + this->actor.world.pos.z; + + EnBigslime_UpdateCameraIntroCs(this, globalCtx, 25); + + this->gekkoRot.y = this->actor.yawTowardsPlayer + 0x8000; + this->isInitJump = false; + this->actionFunc = EnBigslime_CutsceneStartBattle; +} + +void EnBigslime_CutsceneStartBattle(EnBigslime* this, GlobalContext* globalCtx) { + if (this->isAnimUpdate) { + EnBigslime_SetupCutsceneNoticePlayer(this); + } else if (!this->isInitJump && Math_ScaledStepToS(&this->gekkoRot.y, this->actor.yawTowardsPlayer, 0x200)) { + Animation_PlayOnce(&this->skelAnime, &gGekkoSurpriseJumpAnim); + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_JUMP); + this->isInitJump = true; + } +} + +void EnBigslime_SetupCutsceneNoticePlayer(EnBigslime* this) { + Animation_PlayLoop(&this->skelAnime, &gGekkoNervousIdleAnim); + this->noticeTimer = 25; + this->actionFunc = EnBigslime_CutsceneNoticePlayer; +} + +void EnBigslime_CutsceneNoticePlayer(EnBigslime* this, GlobalContext* globalCtx) { + if (this->noticeTimer != 0) { + this->noticeTimer--; + } + + EnBigslime_UpdateCameraIntroCs(this, globalCtx, this->noticeTimer); + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 4.0f)) { + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EV_WALK_WATER); + } + + if (this->noticeTimer == 0) { + EnBigslime_SetupCallMinislime(this, globalCtx); + } +} + +void EnBigslime_SetupCallMinislime(EnBigslime* this, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&this->skelAnime, &gGekkoCallAnim, 5.0f); + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_GREET); + this->callTimer = 0; + func_800B7298(globalCtx, &this->actor, 7); + this->actionFunc = EnBigslime_CallMinislime; +} + +void EnBigslime_CallMinislime(EnBigslime* this, GlobalContext* globalCtx) { + if (this->callTimer > 0) { + this->callTimer--; + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 4.0f)) { + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EV_WALK_WATER); + } + + if (this->callTimer == 0) { + EnBigslime_EndCutscene(this, globalCtx); + this->formBigslimeTimer = 2; + this->actor.flags |= 1; + EnBigslime_SetupIdleNoticePlayer(this); + } + } else if (this->isAnimUpdate) { + Animation_PlayLoop(&this->skelAnime, &gGekkoNervousIdleAnim); + EnBigslime_UpdateCameraIntroCs(this, globalCtx, 25); + func_801A2E54(0x38); + EnBigslime_InitFallMinislime(this); + globalCtx->envCtx.unk_C3 = 0xFF; + this->callTimer = 35; + func_800B7298(globalCtx, &this->actor, 4); + } +} + +void EnBigslime_SetupMoveOnCeiling(EnBigslime* this) { + Animation_PlayLoop(&this->skelAnime, &gGekkoSwimForwardAnim); + this->actor.gravity = 0.0f; + this->actor.velocity.y = 20.0f; + + if (this->subCamId != MAIN_CAM) { + this->actor.speedXZ = 0.0f; + this->ceilingMoveTimer = 20; + } else { + this->ceilingMoveTimer = 320; + this->actor.speedXZ = 5.0f; + } + + this->wavySurfaceTimer = 0; + this->bigslimeCollider[0].base.acFlags |= AC_ON; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.flags &= ~0x200; + this->actionFunc = EnBigslime_MoveOnCeiling; +} + +void EnBigslime_MoveOnCeiling(EnBigslime* this, GlobalContext* globalCtx) { + s16 pitch; // polar (zenith) angle + + Math_ScaledStepToS(&this->gekkoRot.x, 0, 0x400); + this->ceilingMoveTimer--; + pitch = this->ceilingMoveTimer * 0x800; + EnBigslime_Scale(this, pitch, 0.04f, 0.04f); + EnBigslime_UpdateWavySurface(this); + + if (this->subCamId != MAIN_CAM) { + if (this->ceilingMoveTimer == 0) { + EnBigslime_EndCutscene(this, globalCtx); + this->ceilingMoveTimer = 320; + } + } else if ((this->actor.xzDistToPlayer < 250.0f) || (this->ceilingMoveTimer == 0)) { + EnBigslime_SetupDrop(this); + } else { + this->actor.speedXZ = (fabsf(Math_SinS(pitch)) * 3.0f) + 5.0f; + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 10, 0x800, 0x80); + this->gekkoRot.y = this->actor.world.rot.y; + } +} + +void EnBigslime_SetupDrop(EnBigslime* this) { + this->actor.velocity.y = 0.0f; + this->ceilingDropTimer = 30; + this->actor.speedXZ = 0.0f; + this->actionFunc = EnBigslime_Drop; +} + +void EnBigslime_Drop(EnBigslime* this, GlobalContext* globalCtx) { + Vtx* staticVtx; + Vtx* dynamicVtx; + s32 i; + + Math_ScaledStepToS(&this->gekkoRot.x, 0x4000, 0x400); + if (this->ceilingDropTimer != 0) { + s32 requiredScopeTemp; + + this->ceilingDropTimer--; + this->ceilingMoveTimer--; + EnBigslime_UpdateWavySurface(this); + EnBigslime_Scale(this, this->ceilingMoveTimer * 0x4000, 0.2f, 0.15); + this->actor.scale.z = this->actor.scale.x; + if (this->ceilingDropTimer == 0) { + this->actor.gravity = -2.0f; + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_DOWN); + this->rotation = 0; + } + } else if (this->actor.bgCheckFlags & 1) { + EnBigslime_SetupSquishFlat(this); + } else { + Math_StepToF(&this->actor.scale.x, 0.15f, 0.0025f); + Math_StepToF(&this->actor.scale.y, 0.080000006f, 0.0025f); + Math_StepToF(&this->actor.scale.z, 0.15f, 0.0025f); + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + staticVtx = &sBigslimeStaticVtx[i]; + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + if (i > 145) { + Math_StepToS(&dynamicVtx->n.ob[1], staticVtx->n.ob[1] * 0.9f, 5); + } else if (i < 16) { + Math_StepToS(&dynamicVtx->n.ob[1], staticVtx->n.ob[1] * 1.3f, 5); + } else { + Math_StepToS(&dynamicVtx->n.ob[1], staticVtx->n.ob[1], 5); + } + Math_StepToS(&dynamicVtx->n.ob[0], staticVtx->n.ob[0], 5); + Math_StepToS(&dynamicVtx->n.ob[2], staticVtx->n.ob[2], 5); + } + } +} + +/** + * Checks each individual vertex to see if it is outside the walls of the room. + * If it is, updates the vertex to be back inside the boundary of the room. + * Also raises the vertex in the y-direction 100 units in model-space for a single wall + * and 200 unites in the y-direction for two walls i.e a corner. + * + * Differs from EnBigslime_CheckRoomBoundaries by checking and updating + * individual vertices instead of checking and updating a single world position + */ +void EnBigslime_CheckVtxWallBoundaries(EnBigslime* this) { + Vtx* dynamicVtx; + f32 vtxX; + f32 vtxZ; + s32 collisionCounter; + s32 i; + s16 updateVtxY; + + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + vtxX = dynamicVtx->n.ob[0] * this->actor.scale.x; + vtxZ = dynamicVtx->n.ob[2] * this->actor.scale.z; + collisionCounter = 0; + if ((this->actor.world.pos.x + vtxX) > GBT_ROOM_5_MAX_X) { + dynamicVtx->n.ob[0] = (GBT_ROOM_5_MAX_X - this->actor.world.pos.x) / this->actor.scale.x; + collisionCounter++; + } else if ((this->actor.world.pos.x + vtxX) < GBT_ROOM_5_MIN_X) { + dynamicVtx->n.ob[0] = (GBT_ROOM_5_MIN_X - this->actor.world.pos.x) / this->actor.scale.x; + collisionCounter++; + } + + if ((this->actor.world.pos.z + vtxZ) > GBT_ROOM_5_MAX_Z) { + dynamicVtx->n.ob[2] = (GBT_ROOM_5_MAX_Z - this->actor.world.pos.z) / this->actor.scale.z; + collisionCounter++; + } else if ((this->actor.world.pos.z + vtxZ) < GBT_ROOM_5_MIN_Z) { + dynamicVtx->n.ob[2] = (GBT_ROOM_5_MIN_Z - this->actor.world.pos.z) / this->actor.scale.z; + collisionCounter++; + } + + if (dynamicVtx->n.ob[1] != -BIGSLIME_RADIUS_S) { + updateVtxY = collisionCounter * 100; + dynamicVtx->n.ob[1] += updateVtxY; + } + } +} + +/** + * This sets the target vertices into a wide cone shape + * + * Notes: + * - The flat surface of the cone is in the xz-plane at y = -1000 + * - The radius of the flat surface of the cone is 1000 units + * - The apex/point of the cone is at the point (0, 1000, 0) + * - It is wide because it is smooth and thicker near the apex than a standard cone + */ +void EnBigslime_SetTargetVtxToWideCone(EnBigslime* this) { + Vtx* staticVtx; + Vtx* targetVtx; + s16 vtxY; + f32 xzDist; + f32 xzScaleVtx; + s32 i; + s32 j; + + for (i = 0; i < BIGSLIME_NUM_RING_FACES / 2; i++) { + vtxY = (((cos_rad(i * (M_PI / 6)) + 1.0f) * 0.925f) + -0.85f) * BIGSLIME_RADIUS_F; + for (j = sVtxRingStartIndex[i]; j < sVtxRingStartIndex[i + 1]; j++) { + staticVtx = &sBigslimeStaticVtx[j]; + targetVtx = &sBigslimeTargetVtx[j]; + xzDist = sqrtf(SQ(staticVtx->n.ob[0]) + SQ(staticVtx->n.ob[2])); + + if (xzDist > 1.0f) { + xzScaleVtx = (BIGSLIME_RADIUS_F / (5.0f * xzDist)) * i; + } else { + xzScaleVtx = 200.0f * i; // only taken when i = 0, making 200.0f useless + } + + targetVtx->n.ob[0] = staticVtx->n.ob[0] * xzScaleVtx; + targetVtx->n.ob[2] = staticVtx->n.ob[2] * xzScaleVtx; + targetVtx->n.ob[1] = vtxY; + } + } + + for (; i < BIGSLIME_NUM_RING_VTX; i++) { + vtxY = ((cos_rad((i - BIGSLIME_NUM_RING_FACES / 2) * (M_PI / 16)) * 0.05f) + -1.0f) * BIGSLIME_RADIUS_F; + for (j = sVtxRingStartIndex[i]; j < sVtxRingStartIndex[i + 1]; j++) { + staticVtx = &sBigslimeStaticVtx[j]; + targetVtx = &sBigslimeTargetVtx[j]; + xzDist = sqrtf(SQ(staticVtx->n.ob[0]) + SQ(staticVtx->n.ob[2])); + if (xzDist > 1.0f) { + xzScaleVtx = (BIGSLIME_RADIUS_F / (8.0f * xzDist)) * (14 - i); + } else { + // only taken when j = 161, but gets immediately written over (bottom vtx of the sphere) + xzScaleVtx = 125.0f * (14 - i); + } + + targetVtx->n.ob[0] = staticVtx->n.ob[0] * xzScaleVtx; + targetVtx->n.ob[2] = staticVtx->n.ob[2] * xzScaleVtx; + targetVtx->n.ob[1] = vtxY; + } + } + + // Bottom vtx of the sphere + sBigslimeTargetVtx[BIGSLIME_NUM_VTX - 1].n.ob[0] = 0; + sBigslimeTargetVtx[BIGSLIME_NUM_VTX - 1].n.ob[2] = 0; + sBigslimeTargetVtx[BIGSLIME_NUM_VTX - 1].n.ob[1] = -BIGSLIME_RADIUS_S; +} + +void EnBigslime_SetupSquishFlat(EnBigslime* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_JUMP2); + this->squishFlatTimer = 20; + this->actor.scale.x = 0.2f; + this->actor.scale.z = 0.2f; + this->actor.scale.y = 0.05f; + this->actor.world.pos.y = GBT_ROOM_5_MIN_Y + 50.0f; + EnBigslime_SetTargetVtxToWideCone(this); + EnBigslime_CheckVtxWallBoundaries(this); + this->bigslimeCollider[0].base.atFlags |= AT_ON; + this->actionFunc = EnBigslime_SquishFlat; +} + +/** + * Squishes flat like a pancake to try and grab player + * + * Notes: + * - The vtx shape of Fused Jelly starts from a wide cone shape + * - The squishing occurs throught the large changes in &this->actor.scale + */ +void EnBigslime_SquishFlat(EnBigslime* this, GlobalContext* globalCtx) { + Player* player; + Vtx* dynamicVtx; + Vtx* targetVtx; + s32 i; + + this->squishFlatTimer--; + Math_ScaledStepToS(&this->gekkoRot.x, 0, 0x400); + Math_SmoothStepToF(&this->actor.scale.x, 0.35f, 0.4f, 0.035f, 0.0034999999f); + Math_SmoothStepToF(&this->actor.scale.y, 0.030000001f, 0.4f, 0.0030000003f, 0.0003f); + this->actor.scale.z = this->actor.scale.x; + + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + targetVtx = &sBigslimeTargetVtx[i]; + Math_SmoothStepToS(&dynamicVtx->n.ob[0], targetVtx->n.ob[0], 5, 40, 5); + Math_SmoothStepToS(&dynamicVtx->n.ob[2], targetVtx->n.ob[2], 5, 40, 5); + Math_SmoothStepToS(&dynamicVtx->n.ob[1], targetVtx->n.ob[1], 2, 600, 3); + } + + EnBigslime_CheckVtxWallBoundaries(this); + + // Checks if any collider is interacting with player. If so, player is grabbed + for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { + if (this->bigslimeCollider[i].base.atFlags & AT_HIT) { + break; + } + } + + if (i != BIGSLIME_NUM_RING_FACES) { + player = GET_PLAYER(globalCtx); + if (globalCtx->grabPlayer(globalCtx, player)) { + player->actor.parent = &this->actor; + EnBigslime_SetupCutscene(this); + return; + } + } + + if (this->squishFlatTimer == 0) { + EnBigslime_SetupRise(this); + } +} + +/** + * This sets the target vertices into a thin cone shape + * + * Notes: + * - The flat surface of the cone is in the xz-plane at y = -1000 + * - The radius of the flat surface of the cone is 1000 units + * - The apex/point of the cone is at the point (0, 1000, 0) + * - It is thin because it is smooth and thinner near the apex than a standard cone + */ +void EnBigslime_SetTargetVtxToThinCone(EnBigslime* this) { + Vtx* targetVtx; + Vtx* staticVtx; + f32 xzDistVtx; + f32 xzScaleVtx; + s32 i; + s32 j; + s16 upperSphereCos; + f32 lowerSphereCos; + s32 targetVtxY; + + // Top vtx of the sphere + sBigslimeTargetVtx[0].n.ob[1] = BIGSLIME_RADIUS_S; + sBigslimeTargetVtx[0].n.ob[0] = 0; + sBigslimeTargetVtx[0].n.ob[2] = 0; + + for (i = 1; i < BIGSLIME_NUM_RING_FACES / 2; i++) { + upperSphereCos = (((cos_rad((i - 1) * (M_PI / 5)) + 1.0f) * 0.925f) + -0.85f) * BIGSLIME_RADIUS_F; + for (j = sVtxRingStartIndex[i]; j < sVtxRingStartIndex[i + 1]; j++) { + staticVtx = &sBigslimeStaticVtx[j]; + targetVtx = &sBigslimeTargetVtx[j]; + xzDistVtx = sqrtf(SQ(staticVtx->n.ob[0]) + SQ(staticVtx->n.ob[2])); + xzDistVtx = (BIGSLIME_RADIUS_F / (5.0f * xzDistVtx)) * i; + // xzDistVtx is always less than 500.0f + xzScaleVtx = + xzDistVtx < 500.0f ? xzDistVtx * 0.75f : BIGSLIME_RADIUS_F - ((BIGSLIME_RADIUS_F - xzDistVtx) * 0.75f); + + targetVtx->n.ob[0] = staticVtx->n.ob[0] * xzScaleVtx; + targetVtx->n.ob[2] = staticVtx->n.ob[2] * xzScaleVtx; + targetVtx->n.ob[1] = upperSphereCos; + } + } + + for (; i < BIGSLIME_NUM_RING_FACES; i++) { + lowerSphereCos = cos_rad((i - BIGSLIME_NUM_RING_FACES / 2) * (M_PI / BIGSLIME_NUM_RING_FACES)); + for (j = sVtxRingStartIndex[i]; j < sVtxRingStartIndex[i + 1]; j++) { + staticVtx = &sBigslimeStaticVtx[j]; + targetVtx = &sBigslimeTargetVtx[j]; + targetVtx->n.ob[0] = staticVtx->n.ob[0]; + targetVtx->n.ob[2] = staticVtx->n.ob[2]; + targetVtxY = (s16)(((lowerSphereCos * 0.05f) + -1.0f) * BIGSLIME_RADIUS_F); + targetVtx->n.ob[1] = targetVtxY; + } + } + + // Bottom vtx of the sphere + sBigslimeTargetVtx[BIGSLIME_NUM_VTX - 1].n.ob[1] = -BIGSLIME_RADIUS_S; + sBigslimeTargetVtx[BIGSLIME_NUM_VTX - 1].n.ob[0] = 0; + sBigslimeTargetVtx[BIGSLIME_NUM_VTX - 1].n.ob[2] = 0; +} + +/** + * This sets the target vertices into a thin inverse cone shape + * + * Notes: + * - The flat surface of the cone is in the xz-plane at y = +1000 + * - The radius of the flat surface of the cone is 1000 units + * - The apex/point of the cone is at the point (0, -1000, 0) + * - It is thin because it is smooth and thinner near the apex than a standard cone + */ +void EnBigslime_SetTargetVtxToInverseCone(EnBigslime* this) { + Vtx* targetVtx; + Vtx* staticVtx; + f32 xzDistVtx; + f32 upperSphereCos; + s16 lowerSphereCos; + f32 xzScaleVtx; + s32 i; + s32 j; + s32 vtxY; + + // Top vtx of the sphere + sBigslimeTargetVtx[0].n.ob[1] = BIGSLIME_RADIUS_S; + sBigslimeTargetVtx[0].n.ob[0] = 0; + sBigslimeTargetVtx[0].n.ob[2] = 0; + + for (i = 1; i < BIGSLIME_NUM_RING_FACES / 2; i++) { + upperSphereCos = cos_rad((i - 1) * (M_PI / 10)); + for (j = sVtxRingStartIndex[i]; j < sVtxRingStartIndex[i + 1]; j++) { + staticVtx = &sBigslimeStaticVtx[j]; + targetVtx = &sBigslimeTargetVtx[j]; + targetVtx->n.ob[0] = staticVtx->n.ob[0]; + targetVtx->n.ob[2] = staticVtx->n.ob[2]; + vtxY = (s16)(((upperSphereCos * 0.1f) + 0.9f) * BIGSLIME_RADIUS_F); + targetVtx->n.ob[1] = vtxY; + } + } + + for (; i < BIGSLIME_NUM_RING_FACES; i++) { + lowerSphereCos = + (((cos_rad((i - BIGSLIME_NUM_RING_FACES / 2) * (M_PI / 5)) + 1) * 0.925f) + -1.0f) * BIGSLIME_RADIUS_F; + for (j = sVtxRingStartIndex[i]; j < sVtxRingStartIndex[i + 1]; j++) { + staticVtx = &sBigslimeStaticVtx[j]; + targetVtx = &sBigslimeTargetVtx[j]; + xzDistVtx = sqrtf(SQ(staticVtx->n.ob[0]) + SQ(staticVtx->n.ob[2])); + xzDistVtx = (BIGSLIME_RADIUS_F / (6.0f * xzDistVtx)) * (BIGSLIME_NUM_RING_FACES - i); + // xzDistVtx is always less than 500.0f + xzScaleVtx = + xzDistVtx < 500.0f ? xzDistVtx * 0.75f : BIGSLIME_RADIUS_F - ((BIGSLIME_RADIUS_F - xzDistVtx) * 0.75f); + + targetVtx->n.ob[0] = staticVtx->n.ob[0] * xzScaleVtx; + targetVtx->n.ob[2] = staticVtx->n.ob[2] * xzScaleVtx; + targetVtx->n.ob[1] = lowerSphereCos; + } + } + + // Bottom vtx of the sphere + sBigslimeTargetVtx[BIGSLIME_NUM_VTX - 1].n.ob[1] = -BIGSLIME_RADIUS_S; + sBigslimeTargetVtx[BIGSLIME_NUM_VTX - 1].n.ob[0] = 0; + sBigslimeTargetVtx[BIGSLIME_NUM_VTX - 1].n.ob[2] = 0; +} + +void EnBigslime_SetTargetVtxToStaticVtx(EnBigslime* this) { + s32 i; + Vtx* staticVtx; + + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + staticVtx = &sBigslimeStaticVtx[i]; + sBigslimeTargetVtx[i].n.ob[0] = staticVtx->n.ob[0]; + sBigslimeTargetVtx[i].n.ob[2] = staticVtx->n.ob[2]; + sBigslimeTargetVtx[i].n.ob[1] = staticVtx->n.ob[1]; + } +} + +void EnBigslime_SetupRise(EnBigslime* this) { + Animation_PlayLoop(&this->skelAnime, &gGekkoSwimForwardAnim); + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_JUMP_ABOVE); + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_UTSUBO_APPEAR_TRG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_JUMP1); + this->riseCounter = 0; + this->bigslimeCollider[0].base.atFlags &= ~AT_ON; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + EnBigslime_SetTargetVtxToThinCone(this); + this->actor.world.rot.y = this->gekkoRot.y; + this->actionFunc = EnBigslime_Rise; +} + +/** + * Moves Fused Jelly from a squish pancake on the floor to the ceiling + * + * Notes: + * - When riseCounter == 0, Fused Jelly is un-squishing into a thin cone shape + * - When riseCounter == 1, Fused Jelly is deforming into an inverse thin cone shape + * - When riseCounter == 2 to 9, Fused Jelly is returning to its default spherical shape + * - When riseCounter == 10, Fused Jelly starts moving on the ceiling + */ +void EnBigslime_Rise(EnBigslime* this, GlobalContext* globalCtx) { + Vtx* dynamicVtx; + Vtx* targetVtx; + s32 i; + + if (this->riseCounter < 2) { + Math_SmoothStepToF(&this->actor.scale.x, 0.13f, 0.2f, 0.039f, 0.0038999997f); + Math_ScaledStepToS(&this->gekkoRot.x, -0x4000, 0x400); + } else { + Math_SmoothStepToF(&this->actor.scale.x, 0.15f, 0.4f, 0.015000001f, 0.0015f); + Math_ScaledStepToS(&this->gekkoRot.x, 0, 0x400); + } + + this->actor.scale.z = this->actor.scale.x; + EnBigslime_CheckVtxWallBoundaries(this); + if (this->riseCounter == 0) { + if (Math_SmoothStepToF(&this->actor.scale.y, 0.3f, 0.5f, 0.015000001f, 0.00075f) < 0.01f) { + this->riseCounter = 1; + EnBigslime_SetTargetVtxToInverseCone(this); + } + + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + targetVtx = &sBigslimeTargetVtx[i]; + Math_SmoothStepToS(&dynamicVtx->n.ob[1], targetVtx->n.ob[1], 5, 550, 3); + Math_SmoothStepToS(&dynamicVtx->n.ob[0], targetVtx->n.ob[0], 5, 40, 5); + Math_SmoothStepToS(&dynamicVtx->n.ob[2], targetVtx->n.ob[2], 5, 40, 5); + } + + } else if (this->riseCounter == 1) { + if (Math_SmoothStepToF(&this->actor.scale.y, 0.075f, 0.4f, 0.0075000003f, 0.00075f) < 0.01f) { + EnBigslime_SetTargetVtxToStaticVtx(this); + this->riseCounter++; + } + + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + targetVtx = &sBigslimeTargetVtx[i]; + Math_SmoothStepToS(&dynamicVtx->n.ob[1], targetVtx->n.ob[1], 5, 50, 3); + Math_SmoothStepToS(&dynamicVtx->n.ob[0], targetVtx->n.ob[0], 5, 40, 5); + Math_SmoothStepToS(&dynamicVtx->n.ob[2], targetVtx->n.ob[2], 5, 40, 5); + } + + this->actor.world.pos.y = GBT_ROOM_5_MAX_Y - (this->actor.scale.y * BIGSLIME_RADIUS_F); + } else if (this->riseCounter == 10) { + EnBigslime_SetupMoveOnCeiling(this); + } else { + this->riseCounter++; + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + targetVtx = &sBigslimeTargetVtx[i]; + Math_SmoothStepToS(&dynamicVtx->n.ob[1], targetVtx->n.ob[1], 5, 550, 3); + Math_SmoothStepToS(&dynamicVtx->n.ob[0], targetVtx->n.ob[0], 5, 40, 5); + Math_SmoothStepToS(&dynamicVtx->n.ob[2], targetVtx->n.ob[2], 5, 40, 5); + } + } + + EnBigslime_CheckVtxWallBoundaries(this); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 10, 0x800, 0x80); +} + +void EnBigslime_SetupCutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalCtx) { + Camera* mainCam = Play_GetCamera(globalCtx, MAIN_CAM); + s16 yaw; + + Play_CameraSetAtEye(globalCtx, this->subCamId, &mainCam->at, &mainCam->eye); + this->grabPlayerTimer = 15; + this->wavySurfaceTimer = 0; + this->bigslimeCollider[0].base.atFlags &= ~AT_ON; + this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + yaw = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) - this->actor.world.rot.y; + + if (yaw > 0x4000) { + this->subCamYawGrabPlayer = -0x2000; + } else if (yaw > 0) { + this->subCamYawGrabPlayer = -0x6000; + } else if (yaw < -0x4000) { + this->subCamYawGrabPlayer = 0x2000; + } else { + this->subCamYawGrabPlayer = 0x6000; + } + + this->subCamYawGrabPlayer += this->actor.world.rot.y; + Animation_PlayLoop(&this->skelAnime, &gGekkoBoxingStanceAnim); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_EAT); + this->actionFunc = EnBigslime_CutsceneGrabPlayer; +} + +void EnBigslime_CutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 invgrabPlayerTimer; + f32 magPosXZOffset; + Vtx* dynamicVtx; + s32 i; + s32 j; + + player->unk_AE8 = 0; + Math_ScaledStepToS(&this->gekkoRot.x, 0, 0x400); + EnBigslime_UpdateCameraGrabPlayer(this, globalCtx); + if (this->grabPlayerTimer > 0) { + invgrabPlayerTimer = 1.0f / this->grabPlayerTimer; + + this->actor.scale.x = F32_LERPIMP(this->actor.scale.x, 0.15f, invgrabPlayerTimer); + this->actor.scale.y = F32_LERPIMP(this->actor.scale.y, 0.075f, invgrabPlayerTimer); + this->actor.scale.z = this->actor.scale.x; + + player->actor.world.pos.x = F32_LERPIMP(player->actor.world.pos.x, this->actor.world.pos.x, invgrabPlayerTimer); + player->actor.world.pos.z = F32_LERPIMP(player->actor.world.pos.z, this->actor.world.pos.z, invgrabPlayerTimer); + player->actor.world.pos.y = F32_LERPIMP( + player->actor.world.pos.y, this->actor.world.pos.y + this->actor.scale.y * -500.0f, invgrabPlayerTimer); + + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + + // loop over x, y, z + for (j = 0; j < 3; j++) { + // Linearly interpolate dynamicVtx --> staticVtx + dynamicVtx->n.ob[j] += + (s16)((sBigslimeStaticVtx[i].n.ob[j] - dynamicVtx->n.ob[j]) * invgrabPlayerTimer); + } + } + + invgrabPlayerTimer = (15 - this->grabPlayerTimer) / 15.0f; + magPosXZOffset = invgrabPlayerTimer * -50.0f; + this->gekkoPosOffset.x = Math_SinS(this->gekkoRot.y) * magPosXZOffset; + this->gekkoPosOffset.y = invgrabPlayerTimer * -40.0f; + this->gekkoPosOffset.z = Math_CosS(this->gekkoRot.y) * magPosXZOffset; + this->grabPlayerTimer--; + if (this->grabPlayerTimer == 0) { + EnBigslime_SetupAttackPlayerInBigslime(this); + } + } +} + +void EnBigslime_SetupAttackPlayerInBigslime(EnBigslime* this) { + Animation_PlayOnce(&this->skelAnime, sGekkoAttackAnimations[(s32)Rand_ZeroFloat(3.0f) % 3]); + this->numGekkoMeleeAttacks = (s32)Rand_ZeroFloat(3.0f) + 1; + this->numGekkoPosGrabPlayer = 6; + this->actionFunc = EnBigslime_AttackPlayerInBigslime; +} + +void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 pitch = this->scaleFactor * 0x3333; // polar (zenith) angle + + player->unk_AE8 = 0; + Math_ScaledStepToS(&this->gekkoRot.x, 0, 0x400); + EnBigslime_UpdateCameraGrabPlayer(this, globalCtx); + EnBigslime_UpdateWavySurface(this); + + if (this->scaleFactor != 0) { + this->scaleFactor--; + } + + // Checks to see if it's the frame of impact + if (((this->skelAnime.animation == &gGekkoJabPunchAnim) && + Animation_OnFrame(&this->skelAnime, 2.0f)) || // Jab punch makes impact on frame 2 of animation + ((this->skelAnime.animation == &gGekkoHookPunchAnim) && + Animation_OnFrame(&this->skelAnime, 9.0f)) || // Hook Punch makes impact on frames 9 of animation + ((this->skelAnime.animation == &gGekkoKickAnim) && + Animation_OnFrame(&this->skelAnime, 2.0f))) { // Kick makes impact on frame 2 of animation + this->scaleFactor = 10; + player->actor.world.pos.x += 20.0f * Math_SinS(this->gekkoRot.y); + player->actor.world.pos.z += 20.0f * Math_CosS(this->gekkoRot.y); + EnBigslime_JerkCameraPlayerHit(this, globalCtx); + if (this->skelAnime.animation == &gGekkoKickAnim) { + EnBigslime_GekkoSfxInsideBigslime(this, NA_SE_EN_FROG_KICK); + } else { + EnBigslime_GekkoSfxInsideBigslime(this, NA_SE_EN_FROG_PUNCH1); + } + } else { + Math_StepToF(&player->actor.world.pos.x, this->actor.world.pos.x, 4.0f); + Math_StepToF(&player->actor.world.pos.z, this->actor.world.pos.z, 4.0f); + } + + EnBigslime_Scale(this, pitch, ((this->scaleFactor * 0.08f) + 0.2f) * 0.15f, + ((this->scaleFactor * 0.08f) + 0.2f) * 0.05f); + player->actor.world.pos.y = this->actor.world.pos.y + (this->actor.scale.y * -500.0f); + if (this->isAnimUpdate) { + this->numGekkoMeleeAttacks--; + if (this->numGekkoMeleeAttacks == 0) { + this->numGekkoPosGrabPlayer--; + + if ((gSaveContext.health < 5) || (this->numGekkoPosGrabPlayer == 0)) { + this->numGekkoPosGrabPlayer = 0; + this->gekkoRot.y = this->actor.world.rot.y; + this->gekkoPosOffset.x = Math_SinS(this->gekkoRot.y) * -50.0f; + this->gekkoPosOffset.z = Math_CosS(this->gekkoRot.y) * -50.0f; + EnBigslime_SetupWindupThrowPlayer(this); + return; + } + + globalCtx->damagePlayer(globalCtx, -4); + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + this->gekkoRot.y += (s16)(Rand_S16Offset(0x4000, 0x4000) * (Rand_ZeroOne() < 0.5f ? -1 : 1)); + this->gekkoPosOffset.x = Math_SinS(this->gekkoRot.y) * -50.0f; + this->gekkoPosOffset.z = Math_CosS(this->gekkoRot.y) * -50.0f; + this->numGekkoMeleeAttacks = (s32)Rand_ZeroFloat(3.0f) + 1; + } + Animation_PlayOnce(&this->skelAnime, sGekkoAttackAnimations[((s32)Rand_ZeroFloat(3.0f) % 3)]); + } + + func_800B9010(&this->actor, NA_SE_EN_B_SLIME_PUNCH_MOVE - SFX_FLAG); +} + +/** + * Calculates the surface perturbation (multiplicative offset from the static vertices) + * used to update dynamic vertices when bigslime is about to throw/eject player from inside + * at the end of the grab-player cutscene + * + * A unit normal vector (unitVec) is used to represent the direction player will be thrown. + * This unit vector has the following spherical coordinates: + * - radius = 1 + * - yaw (azimuthal angle) = this->actor.world.rot.y + * - pitch (polar/zenith angle) = M_PI / 4 + * + * This unit normal vector is converted into x-y-z coordinates and dot-producted with + * the model coordinates of each individual vertex. The surface perturbation is then + * set to be linearly proportional to this dot product + * + * This leads to the bending shape observed during windup as player is about being thrown out of bigslime + */ +void EnBigslime_SetupWindupThrowPlayer(EnBigslime* this) { + Vtx* dynamicVtx; + f32 dotXYZ; + f32 unitVecX = Math_SinS(this->actor.world.rot.y) * M_SQRT1_2; + f32 unitVecZ = Math_CosS(this->actor.world.rot.y) * M_SQRT1_2; + s32 i; + + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + + // vector dot product between each dynamicVtx and the unit normal vector describing player's thrown direction + dotXYZ = (dynamicVtx->n.ob[0] * unitVecX + dynamicVtx->n.ob[1] * M_SQRT1_2 + dynamicVtx->n.ob[2] * unitVecZ) * + 0.001f; + if (dotXYZ < 0.01f) { + this->vtxSurfacePerturbation[i] = 0.0f; + } else { + this->vtxSurfacePerturbation[i] = dotXYZ * 0.5f; + } + } + + this->windupPunchTimer = 27; + Animation_PlayOnce(&this->skelAnime, &gGekkoWindupPunchAnim); + EnBigslime_GekkoSfxInsideBigslime(this, NA_SE_EN_FROG_PUNCH2); + this->actionFunc = EnBigslime_WindupThrowPlayer; +} + +void EnBigslime_WindupThrowPlayer(EnBigslime* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 scale; + f32 invWindupPunchTimer; + Vtx* dynamicVtx; + Vtx* staticVtx; + s32 i; + s32 j; + + this->windupPunchTimer--; + EnBigslime_UpdateCameraGrabPlayer(this, globalCtx); + if (this->windupPunchTimer > 0) { + invWindupPunchTimer = 1.0f / this->windupPunchTimer; + scale = cos_rad(this->windupPunchTimer * (M_PI / 27)) + 1.0f; + player->actor.world.pos.y = this->actor.world.pos.y + (this->actor.scale.y * -500.0f); + + // Linearly interpolate gekkoRot.y --> this->actor.world.rot.y + this->gekkoRot.y += (s16)((s16)(this->actor.world.rot.y - this->gekkoRot.y) * invWindupPunchTimer); + this->gekkoPosOffset.x = Math_SinS(this->gekkoRot.y) * -50.0f; + this->gekkoPosOffset.z = Math_CosS(this->gekkoRot.y) * -50.0f; + } else { + if (this->windupPunchTimer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_REVERSE); + EnBigslime_GekkoSfxInsideBigslime(this, NA_SE_EN_FROG_PUNCH1); + } + + scale = 0.5f - cos_rad(-this->windupPunchTimer * (M_PI / 5)) * 0.5f; + if (this->windupPunchTimer == -5) { + if (player->stateFlags2 & 0x80) { + player->actor.parent = NULL; + player->unk_AE8 = 100; + } + + player->actor.velocity.y = 0.0f; + func_800B8D50(globalCtx, &this->actor, 10.0f, this->actor.world.rot.y, 10.0f, 4); + EnBigslime_SetupSetDynamicVtxThrowPlayer(this, globalCtx); + } + + player->actor.world.pos.x = + (Math_SinS(this->actor.world.rot.y) * (1060.5f * this->actor.scale.x) * scale) + this->actor.world.pos.x; + player->actor.world.pos.z = + (Math_CosS(this->actor.world.rot.y) * (1060.5f * this->actor.scale.z) * scale) + this->actor.world.pos.z; + player->actor.world.pos.y = + this->actor.world.pos.y + (this->actor.scale.y * -500.0f) + (1060.5f * this->actor.scale.y * scale); + invWindupPunchTimer = 1.0f / (this->windupPunchTimer + 6); + // this->gekkoPosOffset *= (1 - invWindupPunchTimer) + this->gekkoPosOffset.x -= this->gekkoPosOffset.x * invWindupPunchTimer; + this->gekkoPosOffset.y -= this->gekkoPosOffset.y * invWindupPunchTimer; + this->gekkoPosOffset.z -= this->gekkoPosOffset.z * invWindupPunchTimer; + scale = 2.0f - (3.0f * scale); + } + + // Deforming Bigslime during the final windup punch while grabbing player using vtxSurfacePerturbation + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + staticVtx = &sBigslimeStaticVtx[i]; + if (this->vtxSurfacePerturbation[i] != 0.0f) { + if (this->windupPunchTimer > 0) { + // loop over x, y, z + for (j = 0; j < 3; j++) { + // Linearly interpolate dynamicVtx --> staticVtx * (1 - scale * vtxSurfacePerturbation) + dynamicVtx->n.ob[j] += (s16)( + ((staticVtx->n.ob[j] - (s32)(scale * staticVtx->n.ob[j] * this->vtxSurfacePerturbation[i])) - + dynamicVtx->n.ob[j]) * + invWindupPunchTimer); + } + } else { + // loop over x, y, z + for (j = 0; j < 3; j++) { + // Directly set dynamicVtx --> staticVtx * (1 - scale * vtxSurfacePerturbation) + dynamicVtx->n.ob[j] = + staticVtx->n.ob[j] - (s32)((scale * staticVtx->n.ob[j]) * this->vtxSurfacePerturbation[i]); + } + } + } else { + if (this->windupPunchTimer > 0) { + // loop over x, y, z + for (j = 0; j < 3; j++) { + // Linearly interpolate dynamicVtx --> staticVtx + dynamicVtx->n.ob[j] += (s16)((staticVtx->n.ob[j] - dynamicVtx->n.ob[j]) * invWindupPunchTimer); + } + } + } + } +} + +void EnBigslime_SetupSetDynamicVtxThrowPlayer(EnBigslime* this, GlobalContext* globalCtx) { + this->grabPlayerTimer = 10; + EnBigslime_SetTargetVtxToWideCone(this); + EnBigslime_CheckVtxWallBoundaries(this); + EnBigslime_EndCutscene(this, globalCtx); + this->actionFunc = EnBigslime_SetDynamicVtxThrowPlayer; +} + +/** + * Restores bigslime to wide cone after player is thrown + */ +void EnBigslime_SetDynamicVtxThrowPlayer(EnBigslime* this, GlobalContext* globalCtx) { + f32 invThrowPlayerTimer; + Vtx* targetVtx; + Vtx* dynamicVtx; + s32 i; + s32 j; + + this->throwPlayerTimer--; + if (this->throwPlayerTimer > 0) { + invThrowPlayerTimer = 1.0f / this->throwPlayerTimer; + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + targetVtx = &sBigslimeTargetVtx[i]; + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + + // loop over x, y, z + for (j = 0; j < 3; j++) { + // Linearly interpolate dynamicVtx --> targetVtx + dynamicVtx->n.ob[j] += (s16)((targetVtx->n.ob[j] - dynamicVtx->n.ob[j]) * invThrowPlayerTimer); + } + } + + this->actor.scale.x = F32_LERPIMP(this->actor.scale.x, 0.2f, invThrowPlayerTimer); + this->actor.scale.y = F32_LERPIMP(this->actor.scale.y, 0.05f, invThrowPlayerTimer); + this->actor.scale.z = this->actor.scale.x; + EnBigslime_CheckVtxWallBoundaries(this); + } + + if (this->throwPlayerTimer == 0) { + EnBigslime_SetupRise(this); + } +} + +/** + * Sets the frozen effect as a seed on the bottom 4 nodes of a sphere + * The frozen effect is initially set to be dimmer the farther from the initial seed you are + */ +void EnBigslime_SetupFreeze(EnBigslime* this) { + Vtx* targetVtx; + Vtx* dynamicVtx; + s32 i; + s32 j; + + this->actor.speedXZ = 0.0f; + this->freezeTimer = 40; + if (this->actor.bgCheckFlags & 1) { + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + } else if ((this->actionFunc == EnBigslime_Rise) && (this->riseCounter < 2)) { + this->actor.gravity = -2.0f; + } + + this->bigslimeCollider[0].base.atFlags &= ~AT_ON; + this->bigslimeCollider[0].base.acFlags &= ~AC_ON; + + // Resets frozen effect alpha to 0 + for (i = 0; i < BIGSLIME_NUM_VTX; i++) { + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][i]; + targetVtx = &sBigslimeTargetVtx[i]; + for (j = 0; j < 3; j++) { + targetVtx->n.ob[j] = dynamicVtx->n.ob[j]; + } + targetVtx->n.a = 0; + } + + // Initalizes frozen effect alpha near bottom of sphere by increasing levels of alpha + for (i = 0; i < 20; i++) { + sBigslimeTargetVtx[i + 138].n.a = 10 * i; + } + + // Initalizes/seeds frozen effect alpha in bottom 4 nodes in vtx sphere to highest level of alpha + for (i = 0; i < 4; i++) { + sBigslimeTargetVtx[i + 158].n.a = 200; + } + + for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { + this->bigslimeCollider[i].base.ocFlags1 &= ~OC1_NO_PUSH; + } + + this->actionFuncStored = this->actionFunc; + this->actionFunc = EnBigslime_Freeze; +} + +/** + * Propogates the frozen effect from the seed at the bottom out through all vertices + */ +void EnBigslime_Freeze(EnBigslime* this, GlobalContext* globalCtx) { + f32 randFloat; + Vtx* targetVtx; + Vtx* dynamicVtx; + s32 vtxIceUpdate; + s32 vtxIceSeed; + s32 j; + + if (this->freezeTimer) { + this->freezeTimer--; + } + + this->skelAnime.playSpeed = this->freezeTimer / 40.0f; + vtxIceSeed = this->freezeTimer * 4; + for (vtxIceUpdate = 0; vtxIceUpdate < 4; vtxIceUpdate++, vtxIceSeed++) { + if (vtxIceSeed < BIGSLIME_NUM_VTX) { + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][vtxIceSeed]; + targetVtx = &sBigslimeTargetVtx[vtxIceSeed]; + randFloat = randPlusMinusPoint5Scaled(40.0f); + dynamicVtx->n.ob[0] += (s16)(randFloat / this->actor.scale.x); + dynamicVtx->n.ob[1] += (s16)(randFloat / this->actor.scale.y); + dynamicVtx->n.ob[2] += (s16)(randFloat / this->actor.scale.z); + if (((dynamicVtx->n.ob[1] * this->actor.scale.y) + this->actor.world.pos.y) < GBT_ROOM_5_MIN_Y) { + dynamicVtx->n.ob[1] = ((GBT_ROOM_5_MIN_Y - this->actor.world.pos.y) / this->actor.scale.y) - 1.0f; + } + + for (j = 0; j < 3; j++) { + targetVtx->n.ob[j] = dynamicVtx->n.ob[j]; + } + } + } + + for (vtxIceUpdate = 4; vtxIceUpdate < BIGSLIME_NUM_VTX; vtxIceUpdate++) { + sBigslimeTargetVtx[vtxIceUpdate - 4].n.a = sBigslimeTargetVtx[vtxIceUpdate].n.a; + } + + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + if (this->actor.bgCheckFlags & 2) { + if (this->freezeTimer == 0) { + EnBigslime_BreakIntoMinislime(this, globalCtx); + } else { + this->bigslimeCollider[0].base.acFlags |= AC_ON; + EnBigslime_AddIceShardEffect(this, globalCtx); + EnBigslime_SetupSquishFlat(this); + } + } else if (this->freezeTimer == 0) { + if (!(this->actor.bgCheckFlags & 1)) { + EnBigslime_SetupFrozenFall(this); + } else { + EnBigslime_SetupFrozenGround(this); + } + } +} + +void EnBigslime_SetupFrozenGround(EnBigslime* this) { + this->freezeTimer = 80; + this->bigslimeCollider[0].base.acFlags |= AC_ON; + this->actionFunc = EnBigslime_FrozenGround; +} + +void EnBigslime_FrozenGround(EnBigslime* this, GlobalContext* globalCtx) { + f32 invFreezerTimer; + s32 randSign; + f32 randFloat; + + this->freezeTimer--; + if (this->freezeTimer == 0) { + EnBigslime_AddIceShardEffect(this, globalCtx); + EnBigslime_SetTargetVtxFromPreFrozen(this); + } else if (this->freezeTimer == 40) { + Math_Vec3f_Copy(&this->frozenPos, &this->actor.world.pos); + } else if ((this->freezeTimer < 20) || ((this->freezeTimer < 40) && ((this->freezeTimer % 2) != 0))) { + invFreezerTimer = 1.0f / this->freezeTimer; + + // clang-format off + randFloat = Rand_ZeroFloat(4.0f * invFreezerTimer); + randSign = Rand_ZeroOne() < 0.5f ? -1 : 1; \ + this->actor.world.pos.x = randSign * (1.0f + invFreezerTimer + randFloat) + this->frozenPos.x; + // clang-format on + + randFloat = Rand_ZeroFloat(4.0f * invFreezerTimer); + randSign = Rand_ZeroOne() < 0.5f ? -1 : 1; + this->actor.world.pos.z = randSign * (1.0f + invFreezerTimer + randFloat) + this->frozenPos.z; + } +} + +void EnBigslime_SetupMelt(EnBigslime* this) { + s32 i; + + this->bigslimeCollider[0].base.acFlags &= ~AC_ON; + for (i = 0; i < 2; i++) { + sBigslimeTargetVtx[i].n.a = 0; + } + + for (i = 0; i < 20; i++) { + sBigslimeTargetVtx[i + 2].n.a = 10 * i; + } + + this->meltCounter = 0; + this->actionFunc = EnBigslime_Melt; +} + +void EnBigslime_Melt(EnBigslime* this, GlobalContext* globalCtx) { + static Vec3f iceSmokeVelocity = { 0.0f, 2.0f, 0.0f }; + Vec3f iceSmokePos; + Vtx* targetVtx; + Vtx* dynamicVtx; + s32 i; + + this->meltCounter++; + if ((this->meltCounter < 70) && ((this->meltCounter % 2) != 0)) { + dynamicVtx = + &sBigslimeDynamicVtx[this->dynamicVtxState][(s32)Rand_ZeroFloat(BIGSLIME_NUM_VTX) % BIGSLIME_NUM_VTX]; + iceSmokePos.x = (dynamicVtx->n.ob[0] * this->actor.scale.x) + this->actor.world.pos.x; + iceSmokePos.y = (dynamicVtx->n.ob[1] * this->actor.scale.y) + this->actor.world.pos.y; + iceSmokePos.z = (dynamicVtx->n.ob[2] * this->actor.scale.z) + this->actor.world.pos.z; + EffectSsIceSmoke_Spawn(globalCtx, &iceSmokePos, &iceSmokeVelocity, &gZeroVec3f, 600); + } + + func_800B9010(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); + for (i = 159; i >= 0; i--) { + sBigslimeTargetVtx[i + 2].n.a = sBigslimeTargetVtx[i].n.a; + } + + if (this->meltCounter == 100) { + EnBigslime_SetTargetVtxFromPreFrozen(this); + } else if (this->meltCounter == 50) { + globalCtx->envCtx.unk_C3 = 0xFF; + } +} + +void EnBigslime_SetupFrozenFall(EnBigslime* this) { + s32 i; + + this->bigslimeCollider[0].base.atFlags |= AT_ON; + this->actor.gravity = -2.0f; + this->actor.velocity.y = 0.0f; + + for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { + this->bigslimeCollider[i].base.ocFlags1 |= OC1_NO_PUSH; + } + + this->actionFunc = EnBigslime_FrozenFall; +} + +void EnBigslime_FrozenFall(EnBigslime* this, GlobalContext* globalCtx) { + s32 i; + + for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { + if (this->bigslimeCollider[i].base.atFlags & AT_HIT) { + break; + } + } + + if (i != BIGSLIME_NUM_RING_FACES) { + func_800B8D50(globalCtx, &this->actor, 7.0f, this->actor.yawTowardsPlayer, 5.0f, 0x10); + } + + if (this->actor.bgCheckFlags & 1) { + EnBigslime_BreakIntoMinislime(this, globalCtx); + } +} + +void EnBigslime_SetupJumpGekko(EnBigslime* this) { + Animation_PlayLoop(&this->skelAnime, &gGekkoJumpForwardAnim); + this->actor.speedXZ = 8.0f; + this->jumpTimer = 100; + this->actor.world.rot.y = this->gekkoRot.y; + this->gekkoYaw = this->actor.yawTowardsPlayer + 0x8000; + this->actionFunc = EnBigslime_JumpGekko; +} + +void EnBigslime_JumpGekko(EnBigslime* this, GlobalContext* globalCtx) { + s16 yaw; + s16 yawDiff; + + if (this->actor.bgCheckFlags & 1) { + this->gekkoCollider.base.acFlags |= AC_ON; + this->actor.flags |= 1; + } + + this->jumpTimer--; + if (Animation_OnFrame(&this->skelAnime, 1.0f)) { + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_JUMP); + } else if (Animation_OnFrame(&this->skelAnime, 11.0f)) { + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EV_WALK_WATER); + } + + if (!(this->actor.bgCheckFlags & 1) || ((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 12.0f))) { + this->actor.speedXZ = 8.0f; + } else { + this->actor.speedXZ = 0.0f; + } + + if (Math_SmoothStepToS(&this->actor.world.rot.y, this->gekkoYaw, 5, 0x1000, 0x80) == 0) { + if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 240.0f) { + yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + yawDiff = yaw - (s16)(this->actor.yawTowardsPlayer + 0x8000); + this->gekkoYaw = + ABS_ALT(yawDiff) < 0x3000 ? yaw : (yawDiff / 2) + (s16)(this->actor.yawTowardsPlayer + 0x8000); + } else { + this->gekkoYaw = this->actor.yawTowardsPlayer + 0x8000; + } + } + + this->gekkoRot.y = this->actor.world.rot.y; + if (this->jumpTimer == 0) { + if (this->formBigslimeTimer == 0) { + EnBigslime_SetupCutscene(this); + } else { + this->formBigslimeTimer--; + EnBigslime_SetupIdleLookAround(this); + } + } else if ((this->actor.xzDistToPlayer > 300.0f) && (this->gekkoCollider.base.ocFlags1 & OC1_HIT)) { + if ((this->gekkoCollider.base.oc->params == MINISLIME_IDLE) && + (this->gekkoCollider.base.oc->id == ACTOR_EN_MINISLIME)) { + this->gekkoCollider.base.oc->params = MINISLIME_SETUP_GEKKO_THROW; + this->minislimeToThrow = (EnMinislime*)this->gekkoCollider.base.oc; + EnBigslime_SetupThrowMinislime(this); + } + } +} + +void EnBigslime_SetupIdleLookAround(EnBigslime* this) { + Animation_PlayOnce(&this->skelAnime, &gGekkoNervousIdleAnim); + this->idleTimer = 60; + this->actor.speedXZ = 0.0f; + if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { + this->gekkoYaw = this->gekkoRot.y + ((u32)Rand_Next() >> 20) + 0x2000; + } else { + this->gekkoYaw = this->gekkoRot.y - ((u32)Rand_Next() >> 20) - 0x2000; + } + this->actionFunc = EnBigslime_IdleLookAround; +} + +void EnBigslime_IdleLookAround(EnBigslime* this, GlobalContext* globalCtx) { + s16 yawDiff; + + this->idleTimer--; + if (this->isAnimUpdate) { + if (Rand_ZeroOne() < 0.25f) { + Animation_PlayOnce(&this->skelAnime, &gGekkoLookAroundAnim); + } else { + Animation_PlayOnce(&this->skelAnime, &gGekkoNervousIdleAnim); + } + } + + if ((this->skelAnime.animation == &gGekkoNervousIdleAnim) && + Math_ScaledStepToS(&this->gekkoRot.y, this->gekkoYaw, 0x400)) { + if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { + this->gekkoYaw = this->gekkoRot.y + ((u32)Rand_Next() >> 20) + 0x2000; + } else { + this->gekkoYaw = this->gekkoRot.y - ((u32)Rand_Next() >> 20) - 0x2000; + } + } + + yawDiff = this->actor.yawTowardsPlayer - this->gekkoRot.y; + if ((this->idleTimer == 0) || ((ABS_ALT(yawDiff) < 0x2800) && (this->actor.xzDistToPlayer < 240.0f))) { + EnBigslime_SetupIdleNoticePlayer(this); + } +} + +void EnBigslime_SetupIdleNoticePlayer(EnBigslime* this) { + Animation_PlayOnce(&this->skelAnime, &gGekkoSurpriseJumpAnim); + this->gekkoYaw = this->gekkoRot.y + 0x8000; + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_JUMP_MID); + this->actionFunc = EnBigslime_IdleNoticePlayer; +} + +void EnBigslime_IdleNoticePlayer(EnBigslime* this, GlobalContext* globalCtx) { + s16* yaw = &this->gekkoRot.y; + + if (this->skelAnime.curFrame > 10.0f) { + Math_ScaledStepToS(yaw, this->gekkoYaw, 0x800); + } + if (this->isAnimUpdate) { + EnBigslime_SetupJumpGekko(this); + } +} + +void EnBigslime_SetupThrowMinislime(EnBigslime* this) { + Animation_PlayOnce(&this->skelAnime, &gGekkoWindupPunchAnim); + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_HOLD_SLIME); + this->actor.speedXZ = 0.0f; + this->actionFunc = EnBigslime_ThrowMinislime; +} + +void EnBigslime_ThrowMinislime(EnBigslime* this, GlobalContext* globalCtx) { + s16 jumpTimerStored; + + Math_ScaledStepToS(&this->gekkoRot.y, this->actor.yawTowardsPlayer, 0x300); + if (Animation_OnFrame(&this->skelAnime, 27.0f) && + (this->minislimeToThrow->actor.params == MINISLIME_SETUP_GEKKO_THROW)) { + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_THROW_SLIME); + this->minislimeToThrow->actor.params = MINISLIME_GEKKO_THROW; + } + if (this->isAnimUpdate) { + jumpTimerStored = this->jumpTimer; // Stores jumpTimer so it doesn't get overwritten back to 100 + EnBigslime_SetupJumpGekko(this); + this->jumpTimer = jumpTimerStored; + } +} + +void EnBigslime_SetupDamageGekko(EnBigslime* this, s32 isNotFrozen) { + Animation_MorphToPlayOnce(&this->skelAnime, &gGekkoDamagedAnim, -3.0f); + this->gekkoCollider.base.acFlags &= ~AC_ON; + this->damageSpinTimer = 20; + this->actor.speedXZ = 10.0f; + this->actor.gravity = -2.0f; + this->actor.velocity.y = 0.0f; + if (isNotFrozen) { + func_800BE504(&this->actor, &this->gekkoCollider); + } + + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_DAMAGE); + if ((this->actor.flags & 0x2000) == 0x2000) { + this->actor.flags &= ~0x2000; + } + + this->actionFunc = EnBigslime_DamageGekko; +} + +/** + * Spins Gekko around as it takes damage + */ +void EnBigslime_DamageGekko(EnBigslime* this, GlobalContext* globalCtx) { + s32 damageSpinTimer; + + this->damageSpinTimer--; + damageSpinTimer = CLAMP_MAX(this->damageSpinTimer, 10); + this->gekkoRot.y += 0x300 * damageSpinTimer; + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + if (this->damageSpinTimer == 0) { + EnBigslime_SetupCutscene(this); + } +} + +void EnBigslime_SetupStunGekko(EnBigslime* this) { + if ((this->skelAnime.animation == &gGekkoJumpForwardAnim) || + (this->skelAnime.animation == &gGekkoSurpriseJumpAnim)) { + this->skelAnime.curFrame = 1.0f; + } + this->actionFunc = EnBigslime_StunGekko; + this->skelAnime.playSpeed = 0.0f; + this->actor.speedXZ = 0.0f; +} + +void EnBigslime_StunGekko(EnBigslime* this, GlobalContext* globalCtx) { + this->stunTimer--; + if (this->stunTimer == 0) { + if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_FROZEN) { + EnBigslime_GekkoThaw(this, globalCtx); + EnBigslime_SetupDamageGekko(this, false); + } else { + this->gekkoCollider.base.acFlags &= ~AC_ON; + EnBigslime_SetupCutscene(this); + } + } +} + +void EnBigslime_SetupCutsceneFormBigslime(EnBigslime* this) { + Animation_PlayOnce(&this->skelAnime, &gGekkoJumpUpAnim); + this->gekkoCollider.base.acFlags &= ~AC_ON; + this->actor.world.rot.x = -Actor_PitchToPoint(&this->actor, &this->actor.home.pos); + this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->actionFunc = EnBigslime_CutsceneFormBigslime; + this->actor.speedXZ = 0.0f; +} + +void EnBigslime_CutsceneFormBigslime(EnBigslime* this, GlobalContext* globalCtx) { + EnBigslime_UpdateCameraFormingBigslime(this, globalCtx); + Math_ScaledStepToS(&this->gekkoRot.y, this->actor.world.rot.y, 0x800); + if (Animation_OnFrame(&this->skelAnime, 18.0f)) { + EnBigslime_SetupFormBigslime(this); + } +} + +void EnBigslime_SetupFormBigslime(EnBigslime* this) { + s32 i; + + this->actor.gravity = 0.0f; + this->gekkoRot.x = 0x4000 - this->actor.world.rot.x; + this->formBigslimeTimer = 0; + this->wavySurfaceTimer = 0; + this->actor.speedXZ = 25.0f; + this->gekkoRot.y = this->actor.world.rot.y; + this->formBigslimeCutsceneTimer = 2; + + for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { + this->minislime[i]->actor.params = MINISLIME_FORM_BIGSLIME; + } + + for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { + this->bigslimeCollider[i].base.ocFlags1 |= OC1_NO_PUSH; + } + + this->actor.update = EnBigslime_UpdateBigslime; + this->actor.draw = EnBigslime_DrawBigslime; + Actor_SetScale(&this->actor, 0.0f); + this->vtxScaleX = 0.0f; + this->vtxScaleZ = 0.0f; + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_JUMP_ABOVE); + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_UTSUBO_APPEAR_TRG); + this->actionFunc = EnBigslime_FormBigslime; +} + +void EnBigslime_FormBigslime(EnBigslime* this, GlobalContext* globalCtx) { + f32 xzScale; + f32 yScaleFactor; + s32 i; + + EnBigslime_UpdateWavySurface(this); + EnBigslime_UpdateCameraFormingBigslime(this, globalCtx); + if (this->formBigslimeCutsceneTimer < 0) { + Math_ScaledStepToS(&this->gekkoRot.x, 0, 0x400); + } else if (this->actor.world.pos.y > (GBT_ROOM_5_MAX_Y - 100.0f)) { + this->gekkoRot.x -= 0x4000; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + Animation_PlayLoop(&this->skelAnime, &gGekkoSwimForwardAnim); + this->formBigslimeCutsceneTimer--; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_COMBINE); + } else if (this->isAnimUpdate) { + this->formBigslimeCutsceneTimer--; + if (this->formBigslimeCutsceneTimer == 0) { + Animation_PlayLoop(&this->skelAnime, &gGekkoSwimUpAnim); + } + } + + for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { + if (this->minislime[i]->actor.params == MINISLIME_SETUP_DISAPPEAR) { + this->minislime[i]->actor.params = MINISLIME_DISAPPEAR; + this->minislimeCounter++; + } + } + + if (this->minislimeCounter > 0) { + yScaleFactor = sqrtf(this->minislimeCounter * (2.0f / 30.0f)) * 0.6f + 0.4f; + xzScale = 0.15f * yScaleFactor; + this->actor.scale.x = xzScale; + this->actor.scale.y = 0.079f * yScaleFactor; + this->actor.scale.z = xzScale; + } + + if (this->minislimeCounter == MINISLIME_NUM_SPAWN) { + this->minislimeState = MINISLIME_INACTIVE_STATE; + this->actor.hintId = 3; + EnBigslime_SetupMoveOnCeiling(this); + } +} + +void EnBigslime_SetupCutsceneDefeat(EnBigslime* this, GlobalContext* globalCtx) { + Vec3f subCamEye; + Vec3f subCamAt; + s32 i; + s16 yawOffset; + + Animation_Change(&this->skelAnime, &gGekkoDamagedAnim, 0.5f, 0.0f, + Animation_GetLastFrame(&gGekkoDamagedAnim.common), 3, 0.0f); + this->gekkoCollider.base.acFlags &= ~AC_ON; + this->defeatTimer = 60; + this->actor.speedXZ = 10.0f; + this->actor.gravity = -2.0f; + this->actor.velocity.y = 0.0f; + EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_DEAD); + + // Points the camera at the defeated Gekko + subCamAt.x = this->actor.world.pos.x; + subCamAt.y = this->actor.world.pos.y + 40.0f; + subCamAt.z = this->actor.world.pos.z; + + if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->actor.world.rot.y) > 0) { + yawOffset = this->actor.world.rot.y + 0x4000; + } else { + yawOffset = this->actor.world.rot.y - 0x4000; + } + + // Moves the camera to the side of player and Gekko + subCamEye.x = (Math_SinS(yawOffset) * 250.0f) + subCamAt.x; + subCamEye.y = subCamAt.y + 60.0f; + subCamEye.z = (Math_CosS(yawOffset) * 250.0f) + subCamAt.z; + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCamEye); + + for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { + this->minislime[i]->actor.params = MINISLIME_DEFEAT_IDLE; + } + + this->actor.flags &= ~1; + EnBigslime_GekkoThaw(this, globalCtx); + this->actionFunc = EnBigslime_CutsceneDefeat; +} + +void EnBigslime_CutsceneDefeat(EnBigslime* this, GlobalContext* globalCtx) { + s32 defeatTimer; + Camera* subCam; + Vec3f subCamAt; + + this->defeatTimer--; + defeatTimer = CLAMP_MAX(this->defeatTimer, 10); + this->gekkoRot.y += 0x300 * defeatTimer; + if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f)) { + EnBigslime_SetupGekkoDespawn(this, globalCtx); + } else { + // Continue for the camera to follow Gekko as it spins in defeat + subCam = Play_GetCamera(globalCtx, this->subCamId); + subCamAt.x = this->actor.world.pos.x; + subCamAt.y = this->actor.world.pos.y + 40.0f; + subCamAt.z = this->actor.world.pos.z; + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCam->eye); + } +} + +void EnBigslime_SetupGekkoDespawn(EnBigslime* this, GlobalContext* globalCtx) { + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); + f32 magnitude; + f32 invMagnitude; + + Math_Vec3f_Diff(&subCam->eye, &subCam->at, &this->subCamDistToFrog); + magnitude = Math3D_Vec3fMagnitude(&this->subCamDistToFrog); + if (magnitude > 78.0f) { + invMagnitude = 1.0f / magnitude; + magnitude -= 77.0f; + magnitude /= 20.0f; + Math_Vec3f_Scale(&this->subCamDistToFrog, magnitude * invMagnitude); + } else { + Math_Vec3f_Copy(&this->subCamDistToFrog, &gZeroVec3f); + } + + this->shockwaveAlpha = 0; + this->despawnTimer = 20; + this->actionFunc = EnBigslime_GekkoDespawn; +} + +void EnBigslime_GekkoDespawn(EnBigslime* this, GlobalContext* globalCtx) { + Vec3f subCamEye; + Vec3f subCamAt; + Camera* subCam; + + this->despawnTimer--; + this->gekkoScale = this->despawnTimer * 0.00035000002f; + if (this->despawnTimer == 0) { + EnBigslime_SetupFrogSpawn(this, globalCtx); + } else { + subCam = Play_GetCamera(globalCtx, this->subCamId); + Math_Vec3f_Copy(&subCamAt, &subCam->at); + Math_Vec3f_Diff(&subCam->eye, &this->subCamDistToFrog, &subCamEye); + subCamEye.y -= 1.8f; + subCamAt.y -= 1.7f; + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCamEye); + } +} + +void EnBigslime_SetupFrogSpawn(EnBigslime* this, GlobalContext* globalCtx) { + static Color_RGBA8 dustPrimColor = { 250, 250, 250, 255 }; + static Color_RGBA8 dustEnvColor = { 180, 180, 180, 255 }; + static Vec3f hahenAccel = { 0.0f, -0.5f, 0.0f }; + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); + Vec3f* worldPos; + Vec3f dustPos; + Vec3f hahenVel; + s16 yaw = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)); + s16 yawReverse = yaw + 0x8000; + s32 i; + + this->gekkoCollider.base.ocFlags1 &= ~OC1_ON; + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MINIFROG, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, yawReverse, 0, this->actor.params); + + dustPos.x = (Math_SinS(yawReverse) * 20.0f) + this->actor.world.pos.x; + dustPos.y = this->actor.world.pos.y + 20.0f; + worldPos = &this->actor.world.pos; + dustPos.z = (Math_CosS(yawReverse) * 20.0f) + this->actor.world.pos.z; + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, worldPos, 40, NA_SE_EN_NPC_APPEAR); + + // dust cloud where the red frog appears + func_800B0DE0(globalCtx, &dustPos, &gZeroVec3f, &gZeroVec3f, &dustPrimColor, &dustEnvColor, 500, 50); + + for (i = 0; i < 25; i++) { + hahenVel.x = randPlusMinusPoint5Scaled(5.0f); + hahenVel.y = Rand_ZeroFloat(3.0f) + 4.0f; + hahenVel.z = randPlusMinusPoint5Scaled(5.0f); + EffectSsHahen_Spawn(globalCtx, worldPos, &hahenVel, &hahenAccel, 0, Rand_S16Offset(12, 3), HAHEN_OBJECT_DEFAULT, + 10, 0); + } + + this->spawnFrogTimer = 40; + Math_Vec3f_Diff(&subCam->eye, &subCam->at, &this->subCamDistToFrog); + this->actionFunc = EnBigslime_FrogSpawn; +} + +void EnBigslime_FrogSpawn(EnBigslime* this, GlobalContext* globalCtx) { + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); + Vec3f subCamEye; + f32 subCamZoom; + + this->spawnFrogTimer--; + + // Zoom the camera in and out at the newly spawned red frog + subCamZoom = sin_rad(this->spawnFrogTimer * (M_PI / 5)) * ((0.04f * (this->spawnFrogTimer * 0.1f)) + 0.02f) + 1.0f; + subCamEye.x = subCam->at.x + (this->subCamDistToFrog.x * subCamZoom); + subCamEye.z = subCam->at.z + (this->subCamDistToFrog.z * subCamZoom); + subCamEye.y = subCam->at.y + (this->subCamDistToFrog.y * subCamZoom); + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCam->at, &subCamEye); + + if (this->spawnFrogTimer == 0) { + EnBigslime_EndCutscene(this, globalCtx); + EnBigslime_SetupDespawn(this); + } +} + +void EnBigslime_SetupDespawn(EnBigslime* this) { + s32 i; + + for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { + this->minislime[i]->actor.params = MINISLIME_DEFEAT_MELT; + } + + this->isDespawned = false; + this->gekkoCollider.base.ocFlags1 &= ~OC1_ON; + this->actionFunc = EnBigslime_Despawn; +} + +void EnBigslime_Despawn(EnBigslime* this, GlobalContext* globalCtx) { + s32 i; + s32 counter = 0; + + for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { + if (this->minislime[i]->actor.shape.shadowAlpha == 0) { + counter++; + } + } + + if (!this->isDespawned) { + Flags_SetClearTemp(globalCtx, globalCtx->roomCtx.currRoom.num); + this->isDespawned = true; + } + + if (counter == MINISLIME_NUM_SPAWN) { + for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { + this->minislime[i]->actor.params = MINISLIME_DESPAWN; + } + + Actor_MarkForDeath(&this->actor); + } +} + +void EnBigslime_SetupInitEntrance(EnBigslime* this) { + this->actionFunc = EnBigslime_InitEntrance; +} + +void EnBigslime_InitEntrance(EnBigslime* this, GlobalContext* globalCtx) { + if (globalCtx->roomCtx.prevRoom.num == -1) { + EnBigslime_SetupCutscene(this); + } +} + +void EnBigslime_SetupCutscene(EnBigslime* this) { + if (ActorCutscene_GetCurrentIndex() == 0x7D) { + ActorCutscene_Stop(0x7D); + } + + if (this->actor.colChkInfo.health == 0) { + this->cutscene = this->actor.cutscene; + } + + ActorCutscene_SetIntentToPlay(this->cutscene); + this->actionFuncStored = this->actionFunc; + this->actionFunc = EnBigslime_PlayCutscene; + this->actor.speedXZ = 0.0f; +} + +void EnBigslime_PlayCutscene(EnBigslime* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() == 0x7D) { + ActorCutscene_Stop(0x7D); + ActorCutscene_SetIntentToPlay(this->cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->cutscene)) { + ActorCutscene_Start(this->cutscene, &this->actor); + if (this->actionFuncStored != EnBigslime_SquishFlat) { + func_800B724C(globalCtx, &this->actor, 7); + } + + this->subCamId = ActorCutscene_GetCurrentCamera(this->cutscene); + if (this->actor.colChkInfo.health == 0) { + EnBigslime_SetupCutsceneDefeat(this, globalCtx); + } else if ((this->actionFuncStored == EnBigslime_DamageGekko) || + (this->actionFuncStored == EnBigslime_JumpGekko) || + (this->actionFuncStored == EnBigslime_StunGekko)) { + EnBigslime_SetupCutsceneFormBigslime(this); + } else if (this->actionFuncStored == EnBigslime_SquishFlat) { + EnBigslime_SetupCutsceneGrabPlayer(this, globalCtx); + } else { + EnBigslime_SetupCutsceneStartBattle(this, globalCtx); + } + } else { + ActorCutscene_SetIntentToPlay(this->cutscene); + } +} + +void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, GlobalContext* globalCtx) { + s32 i; + + for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { + if (this->bigslimeCollider[i].base.acFlags & AC_HIT) { + this->bigslimeCollider[i].base.acFlags &= ~AC_HIT; + if (this->actionFunc == EnBigslime_FrozenGround) { + if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_BREAK_ICE) { + EnBigslime_BreakIntoMinislime(this, globalCtx); + break; + } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) { + EnBigslime_SetPlayerParams(this, globalCtx); + EnBigslime_SetupMelt(this); + break; + } + } else { + if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ICE) { + EnMinislime* minislime; + + globalCtx->envCtx.unk_C3 = 2; + EnBigslime_SetPlayerParams(this, globalCtx); + this->rotation = 0; + EnBigslime_SetupFreeze(this); + minislime = (EnMinislime*)SubS_FindActor(globalCtx, NULL, ACTORCAT_ITEMACTION, ACTOR_ARROW_ICE); + if (minislime != NULL) { + minislime->shakeRefPos.z = -100.0f; + } + break; + } + + if ((this->actor.colChkInfo.damageEffect != BIGSLIME_DMGEFF_STUN) && (this->itemDropTimer == 0)) { + f32 randFloat = Rand_ZeroOne(); + + if (randFloat < 0.15f) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_ARROWS_10); + } else if (randFloat < 0.3f) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_MAGIC_SMALL); + } + this->itemDropTimer = 40; + } + } + } + } + + for (; i < BIGSLIME_NUM_RING_FACES; i++) { + this->bigslimeCollider[i].base.acFlags &= ~AC_HIT; + } +} + +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) || + !(this->gekkoCollider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + EnBigslime_EndThrowMinislime(this); + if (this->actor.colChkInfo.damageEffect != BIGSLIME_DMGEFF_HOOKSHOT) { + if (Actor_ApplyDamage(&this->actor) == 0) { + func_800BE504(&this->actor, &this->gekkoCollider); + func_801A2ED8(); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + this->gekkoCollider.base.acFlags &= ~AC_ON; + 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; + if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) { + this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + } else { + this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->gekkoCollider.info.bumper.hitPos.x, + this->gekkoCollider.info.bumper.hitPos.y, + this->gekkoCollider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ICE) { + EnBigslime_GekkoFreeze(this); + } + EnBigslime_SetupCutscene(this); + } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ELECTRIC_STUN) { + this->stunTimer = 40; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_ELECTRIC_STUN; + this->unk_38C = 0.75f; + this->unk_388 = 2.0f; + EnBigslime_SetupStunGekko(this); + } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_STUN || + this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_DEKU_STUN) { + this->stunTimer = 40; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnBigslime_SetupStunGekko(this); + } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ICE) { + EnBigslime_GekkoFreeze(this); + func_800BE504(&this->actor, &this->gekkoCollider); + EnBigslime_SetupStunGekko(this); + } else { + 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; + if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) { + this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + } else { + this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->gekkoCollider.info.bumper.hitPos.x, + this->gekkoCollider.info.bumper.hitPos.y, + this->gekkoCollider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + } + EnBigslime_SetupDamageGekko(this, true); + } + } + } + } +} + +/** + * Adds ice shard effects and calls EnBigslime_InitShockwave + */ +void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx) { + Vtx* targetVtx = &sBigslimeTargetVtx[0]; + EnBigslimeIceShardEffect* iceShardEffect; + s32 i; + f32 randFloat; + s16 randPitch; // Elevation Angle + s16 vtxX; + s16 vtxZ; + f32 xzDist; + + for (i = 0; i < BIGSLIME_NUM_VTX; i++, targetVtx++) { + if (targetVtx->n.a > 0) { + iceShardEffect = &this->iceShardEffect[i]; + iceShardEffect->pos.x = (targetVtx->n.ob[0] * this->actor.scale.x) + this->actor.world.pos.x; + iceShardEffect->pos.y = (targetVtx->n.ob[1] * this->actor.scale.y) + this->actor.world.pos.y; + iceShardEffect->pos.z = (targetVtx->n.ob[2] * this->actor.scale.z) + this->actor.world.pos.z; + iceShardEffect->rotation.x = Rand_Next() >> 0x10; + iceShardEffect->rotation.y = Rand_Next() >> 0x10; + iceShardEffect->rotation.z = Rand_Next() >> 0x10; + iceShardEffect->isActive = true; + randPitch = Rand_S16Offset(0x1000, 0x3000); + vtxZ = targetVtx->n.ob[2]; + vtxX = targetVtx->n.ob[0]; + xzDist = sqrtf(SQ(vtxZ) + SQ(vtxX)); + randFloat = Rand_ZeroFloat(5.0f) + 14.0f; + if (xzDist > 1.0f) { + xzDist = Math_CosS(randPitch) * randFloat / xzDist; + } else { + xzDist = Math_CosS(randPitch) * randFloat; + } + + iceShardEffect->vel.x = targetVtx->n.ob[0] * xzDist; + iceShardEffect->vel.y = Math_SinS(randPitch) * randFloat; + iceShardEffect->vel.z = targetVtx->n.ob[2] * xzDist; + iceShardEffect->scale = 0.001f * (Rand_ZeroFloat(6.0f) + 2.0f); + } + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); + EnBigslime_InitShockwave(this, globalCtx); +} + +/** + * Updates ice shard effects, shockwave effects, and actor damage draw effects + */ +void EnBigslime_UpdateEffects(EnBigslime* this) { + EnBigslimeIceShardEffect* iceShardEffect; + s32 i; + + // Update ice shards + for (i = 0; i < BIGSLIME_NUM_ICE_SHARD; i++) { + iceShardEffect = &this->iceShardEffect[i]; + if (iceShardEffect->isActive > false) { + iceShardEffect->vel.y += -1.0f; + Math_Vec3f_Sum(&iceShardEffect->pos, &iceShardEffect->vel, &iceShardEffect->pos); + if (iceShardEffect->pos.y < (GBT_ROOM_5_MIN_Y - 20.0f)) { + iceShardEffect->isActive = false; + } + iceShardEffect->rotation.x += (s16)(((u32)Rand_Next() >> 0x17) + 0x700); + iceShardEffect->rotation.y += (s16)(((u32)Rand_Next() >> 0x17) + 0x900); + iceShardEffect->rotation.z += (s16)(((u32)Rand_Next() >> 0x17) + 0xB00); + } + } + + // update shockwave + if (this->shockwaveAlpha > 0) { + this->shockwaveAlpha = (this->shockwaveAlpha - 10 < 0) ? 0 : (this->shockwaveAlpha - 10); + this->shockwaveScale += 0.0013f; + } + + // 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)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +void EnBigslime_UpdateBigslime(Actor* thisx, GlobalContext* globalCtx) { + EnBigslime* this = THIS; + s32 i; + Vec3f vtxMax; + Vec3f vtxMin; + + if (globalCtx->envCtx.unk_C3 == 3) { + globalCtx->envCtx.unk_C3 = 0xFF; + } + + func_8019F540(1); + this->dynamicVtxState ^= 1; + EnBigslime_DynamicVtxCopyState(this); + this->isAnimUpdate = SkelAnime_Update(&this->skelAnime); + if (this->actionFunc != EnBigslime_PlayCutscene) { + EnBigslime_ApplyDamageEffectBigslime(this, globalCtx); + } else { + for (i = 0; i < BIGSLIME_NUM_RING_FACES; i++) { + this->bigslimeCollider[i].base.acFlags &= ~AC_HIT; + } + } + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != EnBigslime_FormBigslime) { + Actor_MoveWithGravity(&this->actor); + } else { + Actor_MoveWithoutGravity(&this->actor); + } + + if (this->actionFunc != EnBigslime_JumpGekko) { + EnBigslime_GetMaxMinVertices(this, &vtxMax, &vtxMin); + EnBigslime_UpdateScale(this, &vtxMax, &vtxMin); + EnBigslime_CheckRoomBoundaries(this, &vtxMax, &vtxMin); + EnBigslime_UpdateSurfaceNorm(this); + EnBigslime_UpdateBigslimeCollider(this, globalCtx); + } + + EnBigslime_UpdateEffects(this); + + if (this->itemDropTimer > 0) { + this->itemDropTimer--; + } +} + +void EnBigslime_UpdateGekko(Actor* thisx, GlobalContext* globalCtx) { + static s32 isGekkoOnGround = false; + EnBigslime* this = THIS; + Player* player; + s32 pad; + + if (globalCtx->envCtx.unk_C3 == 3) { + globalCtx->envCtx.unk_C3 = 0xFF; + } + + func_8019F540(0); + this->isAnimUpdate = SkelAnime_Update(&this->skelAnime); + if (this->actionFunc != EnBigslime_PlayCutscene) { + EnBigslime_ApplyDamageEffectGekko(this, globalCtx); + } else { + this->gekkoCollider.base.acFlags &= ~AC_HIT; + } + + this->actionFunc(this, globalCtx); + if (this->actionFunc != EnBigslime_FormBigslime) { + Actor_MoveWithGravity(&this->actor); + } else { + Actor_MoveWithoutGravity(&this->actor); + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 40.0f, 80.0f, 0x1F); + this->gekkoCollider.dim.pos.x = (s16)this->actor.world.pos.x; + this->gekkoCollider.dim.pos.z = (s16)this->actor.world.pos.z; + if (this->gekkoCollider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->gekkoCollider.base); + } + + if ((this->actor.update == EnBigslime_UpdateGekko) && (this->gekkoCollider.base.ocFlags1 & OC1_ON)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->gekkoCollider.base); + } + + EnBigslime_UpdateEffects(this); + + if ((this->actionFunc != EnBigslime_StunGekko) && + (this->gekkoCollider.dim.pos.y < (s16)(3.0f + GBT_ROOM_5_MIN_Y))) { + Vec3f vtxNorm; + + if (((globalCtx->gameplayFrames % 4) == 0) || !isGekkoOnGround) { + player = GET_PLAYER(globalCtx); + vtxNorm.x = this->actor.world.pos.x; + vtxNorm.z = this->actor.world.pos.z; + vtxNorm.y = player->actor.world.pos.y + player->actor.depthInWater; + EffectSsGRipple_Spawn(globalCtx, &vtxNorm, 150, 550, 0); + isGekkoOnGround = true; + } + } else { + isGekkoOnGround = false; + } +} + +/** + * Related to transforming and drawing shadows + */ +void EnBigslime_SetSysMatrix(Vec3f* pos, GlobalContext* globalCtx, Gfx* shadowDList, f32 scaleX, f32 scalez, f32 scaleY, + s16 rotation, f32 alpha) { + f32 yDistMinY; + f32 xz; + MtxF* sysMatrix = Matrix_GetCurrentState(); + + yDistMinY = pos->y - scaleY - GBT_ROOM_5_MIN_Y; + yDistMinY = CLAMP((yDistMinY), 0.0f, (GBT_ROOM_5_CENTER_Y - GBT_ROOM_5_MIN_Y) / 2); + xz = 1.0f - (yDistMinY * (1.0f / 1550.0f)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); + sysMatrix->xx = xz; + sysMatrix->yy = 1.0f; + sysMatrix->zz = xz; + sysMatrix->xz = sysMatrix->xy = 0.0f; + sysMatrix->yz = sysMatrix->yx = 0.0f; + sysMatrix->zy = sysMatrix->zx = 0.0f; + sysMatrix->wx = pos->x; + sysMatrix->wy = GBT_ROOM_5_MIN_Y; + sysMatrix->wz = pos->z; + sysMatrix->xw = sysMatrix->yw = sysMatrix->zw = 0.0f; + sysMatrix->ww = 1.0f; + + Matrix_RotateY(rotation, MTXMODE_APPLY); + Matrix_Scale(scaleX, 1.0f, scalez, MTXMODE_APPLY); + if (shadowDList != gBigslimeShadowDL) { + gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, + COMBINED); + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u8)(alpha * xz)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, shadowDList); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnBigslime_DrawMinislime(EnBigslime* this, GlobalContext* globalCtx) { + EnMinislime* minislime; + GlobalContext* globalCtx2 = globalCtx; + s32 pad; + s32 currIndex; + s32 i; + Lights* lights; + s32 indices[MINISLIME_NUM_SPAWN]; + + for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { + indices[i] = i; + } + + // Insertion sorting algorithm based on z projected Pos + for (i = 0; i < MINISLIME_NUM_SPAWN - 1; i++) { + if (this->minislime[indices[i]]->actor.projectedPos.z < this->minislime[indices[i + 1]]->actor.projectedPos.z) { + currIndex = indices[i]; + indices[i] = indices[i + 1]; + indices[i + 1] = currIndex; + if (i != 0) { + i -= 2; + } + } + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { + minislime = this->minislime[indices[i]]; + lights = LightContext_NewLights(&globalCtx2->lightCtx, globalCtx->state.gfxCtx); + Lights_BindAll(lights, globalCtx2->lightCtx.listHead, &minislime->actor.world.pos, globalCtx); + Lights_Draw(lights, globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + func_800B8118(&minislime->actor, globalCtx, 0); + Matrix_SetStateRotationAndTranslation(minislime->actor.world.pos.x, minislime->actor.world.pos.y, + minislime->actor.world.pos.z, &minislime->actor.shape.rot); + Matrix_Scale(minislime->actor.scale.x, minislime->actor.scale.y, minislime->actor.scale.z, MTXMODE_APPLY); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, minislime->actor.shape.shadowAlpha); + 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_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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, &gMinislimeFrozenDL); + } + + EnBigslime_SetSysMatrix(&minislime->actor.world.pos, globalCtx, gBigslimeShadowDL, + (minislime->actor.scale.x * 0.4f) * 0.1f, (minislime->actor.scale.z * 0.4f) * 0.1f, + minislime->actor.scale.y * 400.0f, minislime->actor.shape.rot.y, + minislime->actor.shape.shadowAlpha * (175.0f / 255.0f)); + } + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnBigslime_DrawBigslime(Actor* thisx, GlobalContext* globalCtx) { + // 28 equidistance-spaced vtx Points (uniformally over the sphere) + static EnBigslimeBubbles bubblesInfo[] = { + { 0, 0.3f }, { 6, 0.1f }, { 12, 0.45f }, { 18, 0.5f }, { 24, 0.6f }, { 30, 0.2f }, { 36, 0.4f }, + { 42, 0.25f }, { 48, 0.35f }, { 54, 0.65f }, { 60, 0.25f }, { 66, 0.55f }, { 72, 0.3f }, { 78, 0.1f }, + { 84, 0.45f }, { 90, 0.5f }, { 96, 0.6f }, { 102, 0.2f }, { 108, 0.4f }, { 114, 0.15f }, { 120, 0.35f }, + { 126, 0.65f }, { 132, 0.25f }, { 138, 0.3f }, { 144, 0.15f }, { 150, 0.45f }, { 156, 0.3f }, { 161, 0.25f }, + }; + EnBigslime* this = THIS; + EnBigslimeBubbles* bubblesInfoPtr; + Vtx* dynamicVtx; + MtxF* billboardMtxF; + s32 i; + + func_8012C2DC(globalCtx->state.gfxCtx); + func_800B8118(&this->actor, globalCtx, 0); + OPEN_DISPS(globalCtx->state.gfxCtx); + + // Draw Bigslime + gSPSegment(POLY_XLU_DISP++, 0x09, sBigslimeDynamicVtx[this->dynamicVtxState]); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, &gBigslimeNormalDL); + gSPDisplayList(POLY_XLU_DISP++, &gBigslimeVtxDL); + + // Draw frozen Bigslime + if ((this->actionFunc == EnBigslime_Freeze) || (this->actionFunc == EnBigslime_FrozenGround) || + (this->actionFunc == EnBigslime_FrozenFall) || (this->actionFunc == EnBigslime_Melt)) { + AnimatedMat_Draw(globalCtx, this->bigslimeFrozenTexAnim); + gSPSegment(POLY_XLU_DISP++, 0x09, sBigslimeTargetVtx); + gSPDisplayList(POLY_XLU_DISP++, &gBigslimeFrozenVtxDL); + gSPDisplayList(POLY_XLU_DISP++, &gBigslimeVtxDL); + } + + // Draw bubbles inside Bigslime + if (this->actor.scale.x > 0.0f) { + Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Scale(0.0050000003f, 0.0050000003f, 0.0050000003f, MTXMODE_APPLY); + billboardMtxF = Matrix_GetCurrentState(); + + for (i = 0; i < 28; i++) { + bubblesInfoPtr = &bubblesInfo[i]; + dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][bubblesInfoPtr->v]; + billboardMtxF->wx = + dynamicVtx->n.ob[0] * this->actor.scale.x * bubblesInfoPtr->scaleVtx + this->actor.world.pos.x; + billboardMtxF->wy = + dynamicVtx->n.ob[1] * this->actor.scale.y * bubblesInfoPtr->scaleVtx + this->actor.world.pos.y; + billboardMtxF->wz = + dynamicVtx->n.ob[2] * this->actor.scale.z * bubblesInfoPtr->scaleVtx + this->actor.world.pos.z; + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, &gBigslimeBubbleDL); + } + } + CLOSE_DISPS(globalCtx->state.gfxCtx); + + EnBigslime_SetSysMatrix(&this->actor.world.pos, globalCtx, gBigslimeShadowDL, this->vtxScaleX, this->vtxScaleZ, + this->actor.scale.y * BIGSLIME_RADIUS_F, this->rotation, 175.0f); + EnBigslime_DrawGekko(&this->actor, globalCtx); +} + +void EnBigslime_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + /* value -1: Limb Not used + * value 0: GEKKO_LIMB_WAIST + * value 1: GEKKO_LIMB_L_SHIN + * value 2: GEKKO_LIMB_L_FOOT + * value 3: GEKKO_LIMB_R_SHIN + * value 4: GEKKO_LIMB_R_FOOT + * value 5: GEKKO_LIMB_L_UPPER_ARM + * value 6: GEKKO_LIMB_L_FOREARM + * value 7: GEKKO_LIMB_L_HAND + * value 8: GEKKO_LIMB_R_UPPER_ARM + * value 9: GEKKO_LIMB_R_FOREARM + * value 10: GEKKO_LIMB_R_HAND + * value 11: GEKKO_LIMB_JAW + */ + static s8 limbPosIndex[] = { + -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, 6, -1, 7, 8, 9, -1, 10, -1, 11, -1, -1, + }; + // Some kind of offset for the position of the Gekkos right foot + static Vec3f rightFootOffsetRef = { 1500.0f, 2200.0f, 0.0f }; + EnBigslime* this = THIS; + Vec3f rightFootOffset; + + if (limbIndex == GEKKO_LIMB_HEAD) { + Matrix_GetStateTranslation(&this->actor.focus.pos); + this->actor.focus.rot.y = this->gekkoRot.y; + } + + if (limbPosIndex[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->limbPos[limbPosIndex[limbIndex]]); + } + + if (limbIndex == GEKKO_LIMB_R_ANKLE) { + Matrix_MultiplyVector3fByState(&rightFootOffsetRef, &rightFootOffset); + this->gekkoCollider.dim.pos.y = rightFootOffset.y; + } +} + +void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx) { + static Color_RGBA8 gekkoDamageColor = { 255, 0, 0, 0 }; + static Color_RGBA8 gekkoStunColor = { 0, 0, 255, 0 }; + Vec3f gekkoPos; + EnBigslime* this = THIS; + s32 pad; + + func_8012C28C(globalCtx->state.gfxCtx); + if (this->actionFunc == EnBigslime_DamageGekko) { + func_800AE434(globalCtx, &gekkoDamageColor, this->damageSpinTimer, 20); + } 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) { + func_800AE434(globalCtx, &gekkoDamageColor, this->stunTimer, 80); + } else if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_ELECTRIC_STUN) { + func_800AE434(globalCtx, &gekkoStunColor, this->stunTimer, 40); + } else { + func_800AE434(globalCtx, &gekkoStunColor, this->stunTimer, 40); + } + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Math_Vec3f_Sum(&this->actor.world.pos, &this->gekkoPosOffset, &gekkoPos); + Matrix_SetStateRotationAndTranslation(gekkoPos.x, gekkoPos.y, gekkoPos.z, &this->gekkoRot); + Matrix_Scale(this->gekkoScale, this->gekkoScale, this->gekkoScale, MTXMODE_APPLY); + SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &gekkoPos, &this->gekkoProjectedPos); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnBigslime_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if ((this->actionFunc == EnBigslime_DamageGekko) || (this->actionFunc == EnBigslime_CutsceneDefeat) || + (this->actionFunc == EnBigslime_GekkoDespawn) || (this->actionFunc == EnBigslime_StunGekko)) { + func_800AE5A0(globalCtx); + } + + EnBigslime_SetSysMatrix(&gekkoPos, globalCtx, D_04076BC0, this->gekkoScale * (550.0f / 7.0f), + this->gekkoScale * (550.0f / 7.0f), 0.0f, 0, 255.0f); + + if (this->minislimeState != MINISLIME_INACTIVE_STATE) { + EnBigslime_DrawMinislime(this, 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); +} + +void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx) { + EnBigslimeIceShardEffect* iceShardEffect; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + // Draw Shockwave + if (this->shockwaveAlpha > 0) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, this->shockwaveAlpha); + gSPSegment(POLY_XLU_DISP++, 0x0D, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames % 128, + (u8)(globalCtx->gameplayFrames * 8), 32, 64, 1, + (-globalCtx->gameplayFrames * 2) % 64, 0, 16, 16)); + Matrix_InsertTranslation(this->frozenPos.x, this->frozenPos.y, this->frozenPos.z, MTXMODE_NEW); + Matrix_Scale(this->shockwaveScale, this->shockwaveScale, this->shockwaveScale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, &gBigslimeShockwaveDL); + } + + // Draw Ice Shards + AnimatedMat_Draw(globalCtx, this->iceShardTexAnim); + gSPDisplayList(POLY_XLU_DISP++, &gBigslimeIceShardDL); + + for (i = 0; i < BIGSLIME_NUM_ICE_SHARD; i++) { + iceShardEffect = &this->iceShardEffect[i]; + if (iceShardEffect->isActive > false) { + Matrix_SetStateRotationAndTranslation(iceShardEffect->pos.x, iceShardEffect->pos.y, iceShardEffect->pos.z, + &iceShardEffect->rotation); + Matrix_Scale(iceShardEffect->scale, iceShardEffect->scale, iceShardEffect->scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, &gBigslimeIceShardVtxDL); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 419b6c1f61..3f57f1666e 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h @@ -63,7 +63,7 @@ typedef struct EnBigslime { u8 minislimeCounter; u8 numGekkoMeleeAttacks; // The Gekko will melee-attack link at 1-3 times at each position while engulfed in bigslime }; - /* 0x02B4 */ u8 iceShardAlpha; + /* 0x02B4 */ u8 shockwaveAlpha; /* 0x02B5 */ u8 gekkoDrawEffect; /* 0x02B6 */ s16 gekkoYaw; /* 0x02B8 */ s16 cutscene; @@ -95,16 +95,16 @@ typedef struct EnBigslime { }; /* 0x02C2 */ s16 ceilingDropTimer; // Bigslime is still during this timer and shakes before dropping /* 0x02C4 */ s16 numGekkoPosGrabPlayer; // The Gekko will melee-attack link at 6 positions while engulfed in bigslime - /* 0x02C6 */ s16 camId; - /* 0x02C8 */ s16 cameraYawGrabPlayer; + /* 0x02C6 */ s16 subCamId; + /* 0x02C8 */ s16 subCamYawGrabPlayer; /* 0x02CA */ s16 rotation; // is always 0, used in Matrix_RotateY /* 0x02CC */ s16 itemDropTimer; // items only drop when zero, Set to 40 then decrements, prevents itemDrop spam /* 0x02CE */ Vec3s gekkoRot; /* 0x02D4 */ Vec3f gekkoPosOffset; // Used when Bigslime grabs link /* 0x02E0 */ Vec3f gekkoProjectedPos; /* 0x02EC */ union { - Vec3f iceShardRefPos; - Vec3f eyeDistToFrog; // Used to zoom into frogs as Gekko despawns/Frog spawns + Vec3f frozenPos; + 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 @@ -114,14 +114,14 @@ typedef struct EnBigslime { /* 0x0398 */ f32 vtxSurfacePerturbation[BIGSLIME_NUM_VTX]; /* 0x0620 */ f32 vtxScaleX; /* 0x0624 */ f32 vtxScaleZ; - /* 0x0628 */ f32 iceShardScale; + /* 0x0628 */ f32 shockwaveScale; /* 0x062C */ ColliderCylinder gekkoCollider; /* 0x0678 */ ColliderCylinder bigslimeCollider[BIGSLIME_NUM_RING_FACES]; /* 0x0A14 */ EnMinislime* minislime[MINISLIME_NUM_SPAWN]; /* 0x0A44 */ EnMinislime* minislimeToThrow; - /* 0x0A48 */ AnimatedMaterial* bigslimeFrozenTex; - /* 0x0A4C */ AnimatedMaterial* minislimeFrozenTex; - /* 0x0A50 */ AnimatedMaterial* iceShardTex; + /* 0x0A48 */ AnimatedMaterial* bigslimeFrozenTexAnim; + /* 0x0A4C */ AnimatedMaterial* minislimeFrozenTexAnim; + /* 0x0A50 */ AnimatedMaterial* iceShardTexAnim; /* 0x0A54 */ EnBigslimeIceShardEffect iceShardEffect[BIGSLIME_NUM_ICE_SHARD]; // 312 = 162 (bigslime) + 10 * 15 (minislime) } EnBigslime; // size = 0x3634 diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index ee51c74444..d1c876b6cc 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -105,7 +105,7 @@ void func_809CCEE8(EnBji01* this, GlobalContext* globalCtx) { this->actor.flags &= ~0x10000; } } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.unk11F22 = 0; globalCtx->msgCtx.unk11F10 = 0; func_809CD028(this, globalCtx); @@ -116,10 +116,9 @@ void func_809CCEE8(EnBji01* this, GlobalContext* globalCtx) { return; } } else { - this->moonsTear = - (ObjMoonStone*)func_ActorCategoryIterateById(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); + this->moonsTear = (ObjMoonStone*)SubS_FindActor(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); } - func_800B8500(&this->actor, globalCtx, 60.0f, 10.0f, 0); + func_800B8500(&this->actor, globalCtx, 60.0f, 10.0f, EXCH_ITEM_NONE); } } @@ -172,7 +171,8 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { } else { this->textId = 0x5F1; } - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, + EXCH_ITEM_NONE); break; case PLAYER_FORM_HUMAN: this->textId = 0x5F7; @@ -205,7 +205,7 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { } void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x444); func_809CCDE0(this, globalCtx); @@ -323,7 +323,7 @@ void func_809CD70C(EnBji01* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x444); func_809CCDE0(this, globalCtx); if (this->actor.shape.rot.y == this->actor.yawTowardsPlayer) { - func_800B86C8(&this->moonsTear->actor, globalCtx, &this->actor); /* Z-Target the Moon's Tear? */ + Actor_ChangeFocus(&this->moonsTear->actor, globalCtx, &this->actor); /* Z-Target the Moon's Tear? */ this->actionFunc = func_809CD77C; } } @@ -337,7 +337,7 @@ void func_809CD77C(EnBji01* this, GlobalContext* globalCtx) { void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { EnBji01* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600578C, &D_06000FDC, this->jointTable, this->morphTable, BJI_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -350,8 +350,7 @@ void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); /* initializes all elements of cutscenes to -1 */ - this->moonsTear = - (ObjMoonStone*)func_ActorCategoryIterateById(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); + this->moonsTear = (ObjMoonStone*)SubS_FindActor(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); switch (gSaveContext.entranceIndex) { case 0x4C00: /* Observatory from ECT */ @@ -396,7 +395,7 @@ void EnBji01_Update(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_SetHeight(&this->actor, 40.0f); + Actor_SetFocus(&this->actor, 40.0f); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } diff --git a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h index ce6fd67244..9ac9fafa08 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h @@ -10,7 +10,12 @@ typedef void (*EnBombalActionFunc)(struct EnBombal*, GlobalContext*); typedef struct EnBombal { /* 0x0000 */ Actor actor; /* 0x0144 */ EnBombalActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x28FC]; + /* 0x0148 */ char unk148[0x4]; + /* 0x014C */ s16 unk_14C; + /* 0x0150 */ f32 unk_150; + /* 0x0154 */ char unk154[0x150]; + /* 0x02A4 */ Vec3f unk_2A4; + /* 0x02B0 */ char unk2B0[0x2794]; } EnBombal; // size = 0x2A44 extern const ActorInit En_Bombal_InitVars; diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 5a003ef85d..4664f2b9f8 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -4,7 +4,9 @@ * Description: Bombers - Jim */ +#include "overlays/actors/ovl_En_Bombal/z_en_bombal.h" #include "z_en_bomjima.h" +#include "objects/object_cs/object_cs.h" #define FLAGS 0x00000019 @@ -16,8 +18,11 @@ void EnBomjima_Update(Actor* thisx, GlobalContext* globalCtx); void EnBomjima_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BFEA94(EnBomjima* this, GlobalContext* globalCtx); +void func_80BFEB1C(EnBomjima* this); void func_80BFEB64(EnBomjima* this, GlobalContext* globalCtx); +void func_80BFEFF0(EnBomjima* this); void func_80BFF03C(EnBomjima* this, GlobalContext* globalCtx); +void func_80BFF120(EnBomjima* this); void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx); void func_80BFF430(EnBomjima* this, GlobalContext* globalCtx); void func_80BFF52C(EnBomjima* this, GlobalContext* globalCtx); @@ -26,13 +31,17 @@ void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx); void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx); void func_80BFFB40(EnBomjima* this, GlobalContext* globalCtx); void func_80BFFBC4(EnBomjima* this, GlobalContext* globalCtx); +void func_80BFFCFC(EnBomjima* this); void func_80BFFD48(EnBomjima* this, GlobalContext* globalCtx); void func_80BFFE48(EnBomjima* this, GlobalContext* globalCtx); void func_80BFFF54(EnBomjima* this, GlobalContext* globalCtx); void func_80C00168(EnBomjima* this, GlobalContext* globalCtx); +void func_80C00234(EnBomjima* this); void func_80C00284(EnBomjima* this, GlobalContext* globalCtx); -#if 0 +static s32 D_80C009F0 = 0; +static s32 D_80C009F4 = 0; + const ActorInit En_Bomjima_InitVars = { ACTOR_EN_BOMJIMA, ACTORCAT_NPC, @@ -45,83 +54,1075 @@ const ActorInit En_Bomjima_InitVars = { (ActorFunc)EnBomjima_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C00A18 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 30, 0, { 0, 0, 0 } }, }; +static u16 D_80C00A44[] = { + 0x0719, + 0x071A, + 0x071B, + 0x0708, +}; + +static u16 D_80C00A4C[] = { + 0x0739, + 0x073A, + 0x073B, + 0x0000, +}; + +static u16 D_80C00A54[] = { 0x0739, 0x073A, 0x073B, 0x0714, 0x0709, 0x070A, 0x070B, + 0x070C, 0x070D, 0x070E, 0x070F, 0x0712, 0x0713 }; + +static u16 D_80C00A70[] = { 0x0739, 0x073A, 0x073B, 0x0759, 0x0753, 0x0754, 0x0755, + 0x0756, 0x070D, 0x0757, 0x0758, 0x0712, 0x0713 }; + +static u16 D_80C00A8C[] = { + 0x0736, + 0x0737, + 0x0738, + 0x074E, +}; + +static AnimationHeader* sAnimations[] = { + &object_cs_Anim_0064B8, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, + &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, + &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, &object_cs_Anim_001708, + &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, &object_cs_Anim_0031C4, +}; + +static u8 D_80C00AE4[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, +}; + +void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBomjima* this = THIS; + s32 cs; + s32 i; + + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + this->actor.gravity = -3.0f; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, + this->morphTable, 21); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + gSaveContext.weekEventReg[83] &= (u8)~0x4; + this->actor.targetMode = 0; + this->unk_2E6 = ENBOMJIMA_GET_F0(&this->actor); + this->unk_2E4 = ENBOMJIMA_GET_F(&this->actor); + Actor_SetScale(&this->actor, 0.01f); + + if (this->unk_2E6 == 0) { + cs = this->actor.cutscene; + i = 0; + + while (cs != -1) { + // clang-format off + this->unk_2D4[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); + // clang-format on + i++; + } + + this->actionFunc = func_80BFEA94; + } else if (this->unk_2E6 == 2) { + func_80BFFCFC(this); + } + + if ((gSaveContext.weekEventReg[75] & 0x40) || (gSaveContext.weekEventReg[73] & 0x10) || + (gSaveContext.weekEventReg[85] & 2)) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnBomjima_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBomjima* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void func_80BFE32C(EnBomjima* this, GlobalContext* globalCtx, s32 arg2) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_2CA = arg2; + if (player->transformation == PLAYER_FORM_GORON) { + this->unk_2C8 = 1; + } + if (player->transformation == PLAYER_FORM_ZORA) { + this->unk_2C8 = 2; + } + + switch (this->unk_2CA) { + case 0: + if (player->transformation == PLAYER_FORM_DEKU) { + this->actor.textId = 0x759; + if (!(gSaveContext.weekEventReg[73] & 0x20)) { + this->actor.textId = 0x708; + } + } else if (player->transformation == PLAYER_FORM_HUMAN) { + this->actor.textId = 0x75A; + if (!(gSaveContext.weekEventReg[84] & 0x80)) { + this->actor.textId = 0x719; + } + } else if ((this->unk_2C8 == 1) || (this->unk_2C8 == 2)) { + this->actor.textId = D_80C00A44[this->unk_2C8]; + } + break; + + case 1: + this->actor.textId = D_80C00A4C[this->unk_2C8]; + break; + + case 2: + if (player->transformation == PLAYER_FORM_DEKU) { + this->actor.textId = D_80C00A54[this->unk_2C8]; + return; + } + this->actor.textId = D_80C00A70[this->unk_2C8]; + break; + + case 3: + this->actor.textId = D_80C00A8C[this->unk_2C8]; + break; + } +} + +void func_80BFE494(EnBomjima* this, s32 arg1, f32 arg2) { + this->unk_2EC = arg1; + this->unk_2CC = Animation_GetLastFrame(sAnimations[arg1]); + Animation_Change(&this->skelAnime, sAnimations[this->unk_2EC], arg2, 0.0f, this->unk_2CC, D_80C00AE4[this->unk_2EC], + -4.0f); +} + +void func_80BFE524(EnBomjima* this) { + if ((this->unk_2EC == 5) && + (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || + Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 18.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } + + if ((this->unk_2EC == 18) && + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 2.0f) || + Animation_OnFrame(&this->skelAnime, 4.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } + + if ((this->unk_2EC == 15) && Animation_OnFrame(&this->skelAnime, 15.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + } + + if ((this->unk_2EC == 6) && Animation_OnFrame(&this->skelAnime, 8.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + } +} + +void func_80BFE65C(EnBomjima* this) { + this->unk_2BC = 0; + this->unk_2C0 = 0; + this->unk_2BE = 0; + this->unk_2A2 = 0; + this->unk_290 = 0; + this->unk_29A = 0; +} + +void func_80BFE67C(EnBomjima* this, GlobalContext* globalCtx) { + f32 sp84 = this->skelAnime.curFrame; + f32 x; + f32 z; + s16 abs; + s16 abs2; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + CollisionPoly* sp50; + s32 sp4C; + + this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2A4); + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); + + switch (this->unk_2A2) { + case 0: + if (this->unk_2C0 == 0) { + Math_Vec3f_Copy(&sp54, &this->actor.home.pos); + + sp54.x += randPlusMinusPoint5Scaled(150.0f); + sp54.z += randPlusMinusPoint5Scaled(150.0f); + + abs = ABS_ALT(BINANG_SUB(this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp54))); + if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp6C, + &sp50, 1, 0, 0, 1, &sp4C)) { + func_80BFE494(this, 5, 1.0f); + Math_Vec3f_Copy(&this->unk_2A4, &sp54); + this->unk_2BE = Rand_S16Offset(30, 50); + this->unk_2A2++; + } + } + break; + + case 1: + if (sp84 >= 0.0f) { + this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2A4); + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 10, 2000, 20); + } + + abs2 = BINANG_SUB(this->actor.world.rot.y, this->unk_2DC); + if ((s16)ABS_ALT(abs2) < 0x100) { + Math_Vec3f_Copy(&sp60, &this->actor.world.pos); + + sp60.x += Math_SinS(this->actor.world.rot.y) * 60.0f; + sp60.z += Math_CosS(this->actor.world.rot.y) * 60.0f; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp60, &sp6C, &sp50, 1, 0, 0, 1, + &sp4C)) { + this->unk_2C0 = 0; + if (Rand_ZeroOne() < 0.5f) { + func_80BFE494(this, 19, 1.0f); + } else { + func_80BFE494(this, 0, 1.0f); + } + this->unk_2A2 = 0; + this->unk_2D0 = 0.0f; + break; + } + } + + x = this->unk_2A4.x - this->actor.world.pos.x; + z = this->unk_2A4.z - this->actor.world.pos.z; + + if ((this->unk_2BE == 0) || (sqrtf(SQ(x) + SQ(z)) < 4.0f)) { + this->unk_2C0 = Rand_S16Offset(20, 20); + if (!(this->unk_2C0 & 1)) { + func_80BFE494(this, 19, 1.0f); + } else { + func_80BFE494(this, 0, 1.0f); + } + this->unk_2A2 = 0; + this->unk_2D0 = 0.0f; + } else if (sp84 >= 0.0f) { + Math_ApproachF(&this->actor.world.pos.x, this->unk_2A4.x, 0.3f, this->unk_2D0); + Math_ApproachF(&this->actor.world.pos.z, this->unk_2A4.z, 0.3f, this->unk_2D0); + Math_ApproachF(&this->unk_2D0, 1.0f, 0.3f, 0.5f); + } + break; + } +} + +void func_80BFEA94(EnBomjima* this, GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + + while (actor != NULL) { + if (actor->id != ACTOR_EN_BOMBAL) { + actor = actor->next; + continue; + } + + this->unk_2F0 = (EnBombal*)actor; + Math_Vec3f_Copy(&this->unk_2B0, &actor->world.pos); + if (this->unk_2F4 == 0) { + this->unk_2F4 = this->unk_2F0->actor.cutscene; + } + func_80BFEB1C(this); + break; + } +} + +void func_80BFEB1C(EnBomjima* this) { + func_80BFE494(this, 1, 1.0f); + func_80BFE65C(this); + this->unk_2A0 = 0; + this->actionFunc = func_80BFEB64; +} + +void func_80BFEB64(EnBomjima* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad[2]; + Vec3f sp40; + + func_80BFE32C(this, globalCtx, 0); + if (player->transformation == PLAYER_FORM_DEKU) { + if (gSaveContext.weekEventReg[73] & 0x20) { + this->unk_2C8 = 3; + func_80BFE32C(this, globalCtx, 3); + } else if (gSaveContext.weekEventReg[77] & 2) { + this->unk_2C8 = 11; + func_80BFE32C(this, globalCtx, 2); + } + } else if (player->transformation == PLAYER_FORM_HUMAN) { + if (gSaveContext.weekEventReg[84] & 0x80) { + this->unk_2C8 = 0; + func_80BFE32C(this, globalCtx, 3); + } else if (gSaveContext.weekEventReg[85] & 1) { + this->unk_2C8 = 11; + func_80BFE32C(this, globalCtx, 2); + } + } + + if (Text_GetFaceReaction(globalCtx, 0x11) != 0) { + this->actor.textId = Text_GetFaceReaction(globalCtx, 0x11); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2DC = this->actor.yawTowardsPlayer; + func_80C00234(this); + return; + } + + if (ActorCutscene_GetCurrentIndex() == -1) { + func_800B8614(&this->actor, globalCtx, 70.0f); + } + + if ((this->unk_2F0->actor.update == NULL) || (this->unk_2F0->actor.colChkInfo.health == 0)) { + func_80BFEFF0(this); + return; + } + + switch (this->unk_2A2) { + case 0: + func_80BFE494(this, 4, 1.0f); + this->unk_29A = -7000; + this->unk_2A2++; + break; + + case 1: + this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2F0->actor.world.pos); + if (Animation_OnFrame(&this->skelAnime, 19.0f)) { + this->unk_2C0 = 5; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_SHOT_BREATH); + } + + if (this->unk_2C0 == 1) { + s16 sp3E = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2F0->actor.world.pos); + + if (Rand_ZeroOne() < 0.5f) { + sp3E += 0x4000; + } else { + sp3E += 0xC000; + } + + sp40.x = (Math_SinS(sp3E) * (Rand_ZeroFloat(20.0f) + 40.0f)) + this->unk_2F0->actor.world.pos.x; + sp40.y = this->unk_2F0->actor.world.pos.y - randPlusMinusPoint5Scaled(40.0f); + sp40.z = (Math_CosS(sp3E) * (Rand_ZeroFloat(20.0f) + 40.0f)) + this->unk_2F0->actor.world.pos.z; + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &sp40, 50, NA_SE_EV_BOMBERS_SHOT_EXPLOSUIN); + EffectSsHitMark_SpawnFixedScale(globalCtx, 0, &sp40); + this->unk_2BC++; + + if (((s16)Rand_ZeroFloat(2.0f) + 3) < this->unk_2BC) { + func_80BFE494(this, 5, 1.0f); + this->unk_29A = 0; + Math_Vec3f_Copy(&this->unk_2A4, &this->actor.home.pos); + this->unk_2A4.x += randPlusMinusPoint5Scaled(150.0f); + this->unk_2A4.z += randPlusMinusPoint5Scaled(150.0f); + this->unk_2A2++; + } + } + break; + + case 2: + this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2A4); + Math_ApproachF(&this->actor.world.pos.x, this->unk_2A4.x, 0.3f, 2.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_2A4.z, 0.3f, 2.0f); + if (sqrtf(SQ(this->actor.world.pos.x - this->unk_2A4.x) + SQ(this->actor.world.pos.z - this->unk_2A4.z)) < + 4.0f) { + func_80BFE65C(this); + } + break; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); +} + +void func_80BFEFF0(EnBomjima* this) { + this->unk_2F0 = NULL; + func_80BFE494(this, 19, 1.0f); + func_80BFE65C(this); + this->unk_2A0 = 1; + this->actionFunc = func_80BFF03C; +} + +void func_80BFF03C(EnBomjima* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D4[0]); + } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D4[0])) { + ActorCutscene_SetIntentToPlay(this->unk_2D4[0]); + } else { + player->stateFlags1 &= ~0x20; + gSaveContext.weekEventReg[83] &= (u8)~4; + this->actor.world.rot.y = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)); + this->unk_2DC = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)); + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[0], &this->actor); + func_80BFF120(this); + } +} + +void func_80BFF120(EnBomjima* this) { + func_80BFE65C(this); + this->unk_2C4 = 30; + func_80BFE494(this, 6, 1.0f); + this->unk_2DE = 0; + this->unk_2A0 = 2; + this->actionFunc = func_80BFF174; +} + +void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx) { + f32 sp2C = this->skelAnime.curFrame; + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_2C4 == 1) { + ActorCutscene_Stop(this->unk_2D4[0]); + this->unk_2DE = 1; + } + + if (Text_GetFaceReaction(globalCtx, 0x11) != 0) { + this->actor.textId = Text_GetFaceReaction(globalCtx, 0x11); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2DC = this->actor.yawTowardsPlayer; + func_80C00234(this); + return; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); + + if ((this->unk_2CC <= sp2C) && (this->unk_2BC < 5)) { + this->unk_2BC++; + if (this->unk_2EC != 19) { + func_80BFE494(this, 19, 1.0f); + } + } + + if (player->transformation == PLAYER_FORM_DEKU) { + if (gSaveContext.weekEventReg[73] & 0x20) { + this->unk_2C8 = 3; + func_80BFE32C(this, globalCtx, 3); + } else { + if (!(gSaveContext.weekEventReg[77] & 2)) { + if (this->unk_2E8 == 0) { + this->unk_2C8 = 4; + } else { + this->unk_2C8 = 3; + } + } else { + this->unk_2C8 = 11; + } + func_80BFE32C(this, globalCtx, 2); + } + } else if (player->transformation == PLAYER_FORM_HUMAN) { + if (gSaveContext.weekEventReg[84] & 0x80) { + this->unk_2C8 = 0; + func_80BFE32C(this, globalCtx, 3); + } else { + if (!(gSaveContext.weekEventReg[85] & 1)) { + if (this->unk_2EA == 0) { + this->unk_2C8 = 4; + } else { + this->unk_2C8 = 3; + } + } else { + this->unk_2C8 = 11; + } + func_80BFE32C(this, globalCtx, 2); + } + } else if (this->unk_2CA != 1) { + func_80BFE32C(this, globalCtx, 1); + } + + if (this->unk_2DE != 0) { + if (this->unk_2BC >= 5) { + func_80BFE67C(this, globalCtx); + } + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void func_80BFF3F0(EnBomjima* this) { + func_80BFE494(this, 15, 1.0f); + this->unk_2A0 = 3; + this->actionFunc = func_80BFF430; +} + +void func_80BFF430(EnBomjima* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->unk_2CC <= curFrame) { + EnBombal* bombal = (EnBombal*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBAL, this->unk_2B0.x, + this->unk_2B0.y, this->unk_2B0.z, 0, 0, 0, 0); + + if (bombal != NULL) { + bombal->unk_150 = 0.0f; + bombal->unk_14C = this->unk_2F4; + Actor_ChangeFocus(&this->actor, globalCtx, &bombal->actor); + gSaveContext.weekEventReg[83] &= (u8)~4; + func_80BFE65C(this); + func_801477B4(globalCtx); + this->actionFunc = func_80BFEA94; + } + } +} + +void func_80BFF4F4(EnBomjima* this) { + func_80BFE65C(this); + this->unk_2A0 = 4; + this->actionFunc = func_80BFF52C; +} + +void func_80BFF52C(EnBomjima* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + if (globalCtx->msgCtx.choiceIndex == 0) { + Player* player = GET_PLAYER(globalCtx); + + func_8019F208(); + func_80BFE65C(this); + this->unk_28E = 0; + this->unk_29A = 0; + this->unk_2C8 = 8; + if (player->transformation == PLAYER_FORM_DEKU) { + this->actor.textId = D_80C00A54[this->unk_2C8]; + } else { + this->actor.textId = D_80C00A70[this->unk_2C8]; + } + func_80151938(globalCtx, this->actor.textId); + play_sound(NA_SE_SY_FOUND); + func_80BFE494(this, 15, 1.0f); + this->unk_2A0 = 5; + this->actionFunc = func_80BFF6CC; + } else { + Player* player = GET_PLAYER(globalCtx); + + func_8019F230(); + func_80BFE65C(this); + this->unk_2C8 = 10; + if (player->transformation == PLAYER_FORM_DEKU) { + this->actor.textId = D_80C00A54[this->unk_2C8]; + this->unk_2E8 = 1; + } else { + this->actor.textId = D_80C00A70[this->unk_2C8]; + this->unk_2EA = 1; + } + func_80151938(globalCtx, this->actor.textId); + func_80C00234(this); + } + } +} + +void func_80BFF6CC(EnBomjima* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->unk_2CC <= curFrame) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + func_80BFE494(this, 1, 1.0f); + this->actionFunc = func_80BFF754; + } + } +} + +#ifdef NON_EQUIVALENT +// Data indexing is wrong + +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; +} EnBombjimaStruct; + +void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { + static EnBombjimaStruct D_80C00AF8[] = { + { 0x4000, 0x003C }, + { 0x4000, 0x001E }, + { 0xC000, 0x001E }, + { 0xC000, 0x003C }, + }; + Player* player = GET_PLAYER(globalCtx); + Vec3f spA0; + EnBombal* temp_s3; + s32 i; + f32 x; + f32 y; + f32 z; + + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D4[1]); + return; + } + + if (!ActorCutscene_GetCanPlayNext(this->unk_2D4[1])) { + ActorCutscene_SetIntentToPlay(this->unk_2D4[1]); + return; + } + + for (i = 1; i < 5; i++) { + Math_Vec3f_Copy(&spA0, &player->actor.world.pos); + + x = spA0.x - this->actor.world.pos.x; + y = spA0.y - this->actor.world.pos.y; + z = spA0.z - this->actor.world.pos.z; + + spA0.x += x * (2.0f + (i * 0.2f)); + spA0.y += y * (2.0f + (i * 0.2f)); + spA0.z += z * (2.0f + (i * 0.2f)); + + temp_s3 = (EnBombal*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BOMJIMA, spA0.x, + spA0.y, spA0.z, 0, 0, 0, i + 32); + if (temp_s3 != NULL) { + s32 idx1 = (i * 2) - 1; + s32 idx2 = i * 2; + + Math_Vec3f_Copy(&spA0, &this->actor.world.pos); + + spA0.x += Math_SinS(D_80C00AF8[idx1 - 1].unk_00 + this->actor.world.rot.y) * D_80C00AF8[idx2].unk_02; + spA0.z += Math_CosS(D_80C00AF8[idx2].unk_00 + this->actor.world.rot.y) * D_80C00AF8[idx2].unk_02; + + Math_Vec3f_Copy(&temp_s3->unk_2A4, &spA0); + } + } + + D_80C009F0 = 0; + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[1], &this->actor); + this->actionFunc = func_80BFF9B0; +} +#else +static s16 D_80C00AF8[][2] = { + { 0x4000, 0x003C }, + { 0x4000, 0x001E }, + { 0xC000, 0x001E }, + { 0xC000, 0x003C }, +}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF754.s") #endif -extern ColliderCylinderInit D_80C00A18; +void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { + if (D_80C009F0 >= 4) { + Player* player = GET_PLAYER(globalCtx); -extern UNK_TYPE D_060064B8; + D_80C009F0 = 0; + this->unk_2C8 = 9; + if (player->transformation == PLAYER_FORM_DEKU) { + gSaveContext.weekEventReg[73] |= 0x10; + gSaveContext.weekEventReg[77] |= 2; + } else { + gSaveContext.weekEventReg[85] |= 2; + gSaveContext.weekEventReg[85] |= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/EnBomjima_Init.s") + gSaveContext.weekEventReg[11] &= (u8)~1; + gSaveContext.weekEventReg[11] &= (u8)~2; + gSaveContext.weekEventReg[11] &= (u8)~4; + gSaveContext.weekEventReg[11] &= (u8)~8; + gSaveContext.weekEventReg[11] &= (u8)~0x10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/EnBomjima_Destroy.s") + gSaveContext.weekEventReg[76] &= (u8)~1; + gSaveContext.weekEventReg[76] &= (u8)~2; + gSaveContext.weekEventReg[76] &= (u8)~4; + gSaveContext.weekEventReg[76] &= (u8)~8; + gSaveContext.weekEventReg[76] &= (u8)~0x10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFE32C.s") + gSaveContext.unk_FE6 = 0; + gSaveContext.unk_FE7[0] = 0; + gSaveContext.unk_FE7[1] = 0; + gSaveContext.unk_FE7[2] = 0; + gSaveContext.unk_FE7[3] = 0; + gSaveContext.unk_FE7[4] = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFE494.s") + func_80BFE494(this, 3, 1.0f); + this->unk_2C8 = 9; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFE524.s") + if (player->transformation == PLAYER_FORM_DEKU) { + this->actor.textId = D_80C00A54[this->unk_2C8]; + } else { + this->actor.textId = D_80C00A70[this->unk_2C8]; + } + func_80151938(globalCtx, this->actor.textId); + this->actionFunc = func_80BFFB40; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFE65C.s") +void func_80BFFB40(EnBomjima* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + func_80BFE494(this, 15, 1.0f); + D_80C009F0 = 100; + this->unk_2DC = 0; + this->actionFunc = func_80BFFBC4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFE67C.s") +void func_80BFFBC4(EnBomjima* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFEA94.s") + if ((this->unk_2EC != 1) && (this->unk_2CC <= curFrame)) { + func_80BFE494(this, 1, 1.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFEB1C.s") + if ((D_80C009F4 != 0) && (this->unk_2C2 == 0)) { + this->unk_2C2 = Rand_S16Offset(5, 5); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFEB64.s") + if (this->unk_2C2 == 1) { + this->unk_2DC = -10000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFEFF0.s") + Math_SmoothStepToS(&this->unk_290, this->unk_2DC, 1, 5000, 0); + if (D_80C009F0 >= 104) { + D_80C009F0 = 0; + func_801477B4(globalCtx); + globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(6); + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 20; + globalCtx->unk_1887F = 0x56; + gSaveContext.nextTransition = 3; + ActorCutscene_Stop(this->unk_2D4[1]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF03C.s") +void func_80BFFCFC(EnBomjima* this) { + func_80BFE65C(this); + func_80BFE494(this, 18, 1.0f); + this->unk_2A0 = 6; + this->actionFunc = func_80BFFD48; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF120.s") +void func_80BFFD48(EnBomjima* this, GlobalContext* globalCtx) { + s32 pad[2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF174.s") + this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2A4); + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); + Math_ApproachF(&this->actor.world.pos.x, this->unk_2A4.x, 0.3f, 4.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_2A4.z, 0.3f, 4.0f); + if (sqrtf(SQ(this->actor.world.pos.x - this->unk_2A4.x) + SQ(this->actor.world.pos.z - this->unk_2A4.z)) < 4.0f) { + D_80C009F0++; + this->unk_2DC = this->actor.parent->world.rot.y; + func_80BFE494(this, 0, 1.0f); + this->actionFunc = func_80BFFE48; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF3F0.s") +void func_80BFFE48(EnBomjima* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); + Math_ApproachF(&this->actor.world.pos.x, this->unk_2A4.x, 0.3f, 4.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_2A4.z, 0.3f, 4.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF430.s") + if (D_80C009F0 >= 100) { + if (this->unk_2E4 != 4) { + func_80BFE494(this, 15, 1.0f); + this->unk_2DC = 0; + func_80BFE65C(this); + this->actionFunc = func_80BFFF54; + } else { + Math_SmoothStepToS(&this->unk_290, 10000, 1, 5000, 0); + if (D_80C009F0 >= 103) { + this->unk_2DC = 0; + func_80BFE494(this, 15, 1.0f); + func_80BFE65C(this); + this->actionFunc = func_80BFFF54; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF4F4.s") +void func_80BFFF54(EnBomjima* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF52C.s") + Math_SmoothStepToS(&this->unk_290, this->unk_2DC, 1, 5000, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF6CC.s") + if ((D_80C009F4 != 0) && (this->unk_2C2 == 0)) { + this->unk_2C2 = Rand_S16Offset(5, 5); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF754.s") + if (this->unk_2C2 == 1) { + this->unk_2DC = -10000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF9B0.s") + if (this->unk_2E4 != 4) { + if ((this->unk_2EC != 0) && (this->unk_2CC <= curFrame)) { + D_80C009F0++; + func_80BFE494(this, 0, 1.0f); + } + } else if ((this->unk_2EC != 8) && (this->unk_2CC <= curFrame)) { + func_80BFE494(this, 8, 1.0f); + D_80C009F4 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFFB40.s") + if (this->unk_2EC == 8) { + if ((D_80C009F4 == 1) && Animation_OnFrame(&this->skelAnime, 7.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); + D_80C009F4 = 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFFBC4.s") + if ((this->unk_2CC <= curFrame) && (this->unk_2C0 == 0)) { + this->unk_2C0 = 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFFCFC.s") + if (this->unk_2C0 == 1) { + D_80C009F0++; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFFD48.s") +void func_80C0011C(EnBomjima* this) { + func_80BFE65C(this); + func_80BFE494(this, 0, 1.0f); + this->unk_2A0 = 7; + this->actionFunc = func_80C00168; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFFE48.s") +void func_80C00168(EnBomjima* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFFF54.s") + if (player->transformation == PLAYER_FORM_HUMAN) { + this->unk_2C8 = 4; + } else if (player->transformation == PLAYER_FORM_DEKU) { + this->unk_2C8 = 7; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80C0011C.s") + func_80BFE32C(this, globalCtx, 0); + func_80BFE67C(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80C00168.s") + if (Text_GetFaceReaction(globalCtx, 0x11) != 0) { + this->actor.textId = Text_GetFaceReaction(globalCtx, 0x11); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80C00234.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2DC = this->actor.yawTowardsPlayer; + func_80C00234(this); + } else { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80C00284.s") +void func_80C00234(EnBomjima* this) { + func_80BFE494(this, 3, 1.0f); + this->collider.dim.radius = 15; + this->collider.dim.height = 40; + func_80BFE65C(this); + this->actionFunc = func_80C00284; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/EnBomjima_Update.s") +void func_80C00284(EnBomjima* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 sp28 = this->skelAnime.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80C007F4.s") + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); + if (((this->unk_2A0 == 0) || (this->unk_2C8 == 10) || (this->unk_2C8 == 11) || (this->unk_2CA == 1)) && + (this->unk_2CC <= sp28)) { + if (!(this->unk_2BC & 1)) { + func_80BFE494(this, 3, 1.0f); + } else { + func_80BFE494(this, 16, 1.0f); + } + this->unk_2BC++; + this->unk_2BC &= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/EnBomjima_Draw.s") + if ((player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_ZORA)) { + if (player->transformation == PLAYER_FORM_HUMAN) { + this->unk_28E = -4000; + } + } else { + this->unk_28E = -6000; + } + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + this->collider.dim.radius = 10; + this->collider.dim.height = 30; + if ((this->unk_2A0 == 4) || (this->unk_2CA == 1) || ((this->unk_2CA == 3) && (this->unk_2C8 >= 2))) { + this->unk_28E = 0; + if (player->stateFlags1 & 0x20) { + player->stateFlags1 &= ~0x20; + } + + if ((this->unk_2F0 == 0) || (this->unk_2F0->actor.update == NULL) || + (this->unk_2F0->actor.colChkInfo.health <= 0)) { + func_80BFF3F0(this); + } else { + func_80BFE65C(this); + func_801477B4(globalCtx); + this->actionFunc = func_80BFEA94; + } + return; + } + + func_801477B4(globalCtx); + + switch (this->unk_2CA) { + case 0: + this->unk_28E = 0; + if (this->unk_2A0 == 7) { + func_80C0011C(this); + } else { + func_80BFEB1C(this); + } + break; + + case 2: + if (this->unk_2C8 == 10) { + func_80BFE65C(this); + this->unk_28E = 0; + func_80BFE494(this, 1, 1.0f); + this->unk_2A0 = 2; + this->actionFunc = func_80BFF174; + return; + } + + this->unk_2C8++; + if (player->transformation == PLAYER_FORM_DEKU) { + if ((this->unk_2E8 != 0) && (this->unk_2C8 == 4)) { + this->unk_2C8 = 6; + } + this->actor.textId = D_80C00A54[this->unk_2C8]; + } else { + if ((this->unk_2EA != 0) && (this->unk_2C8 == 4)) { + this->unk_2C8 = 6; + } + this->actor.textId = D_80C00A70[this->unk_2C8]; + } + func_80151938(globalCtx, this->actor.textId); + if ((this->unk_2C8 == 7) || (this->unk_2C8 == 12)) { + func_80BFF4F4(this); + } + break; + + case 3: + this->unk_2C8++; + this->actor.textId = D_80C00A8C[this->unk_2C8]; + func_80151938(globalCtx, this->actor.textId); + if (this->unk_2C8 >= 2) { + func_80BFE494(this, 17, 1.0f); + } + break; + } + } +} + +void EnBomjima_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBomjima* this = THIS; + + if (this->unk_2BE != 0) { + this->unk_2BE--; + } + + if (this->unk_2C2 != 0) { + this->unk_2C2--; + } + + if (this->unk_2C0 != 0) { + this->unk_2C0--; + } + + if (this->unk_2C6 != 0) { + this->unk_2C6--; + } + + if (this->unk_2C4 != 0) { + this->unk_2C4--; + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y = this->actor.world.rot.y; + func_80BFE524(this); + Actor_SetFocus(&this->actor, 20.0f); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 5000, 0); + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 1000, 0); + Math_SmoothStepToS(&this->unk_294, this->unk_29A, 1, 1000, 0); + + if (this->unk_2E2 == 0) { + this->unk_2E0++; + if (this->unk_2E0 >= 3) { + this->unk_2E0 = 0; + this->unk_2E2 = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + this->actor.uncullZoneForward = 500.0f; + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 EnBomjima_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBomjima* this = THIS; + + if (limbIndex == 8) { + rot->z += this->unk_294; + } + + if ((limbIndex == 15) && (this->unk_2E6 == 2)) { + *dList = NULL; + } + + if (limbIndex == 17) { + rot->x += this->unk_28A; + rot->z += this->unk_288; + } + + if ((limbIndex == 19) && (this->unk_2E6 == 2)) { + *dList = NULL; + } + + if ((limbIndex == 20) && (this->unk_2E6 == 0)) { + *dList = NULL; + } + + return false; +} + +#include "overlays/ovl_En_Bomjima/ovl_En_Bomjima.c" + +void EnBomjima_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* D_80C00B28[] = { + gEnBomjima_D_80C00B08, gEnBomjima_D_80C00B18, gEnBomjima_D_80C00B18, + gEnBomjima_D_80C00B18, gEnBomjima_D_80C00B18, + }; + static TexturePtr D_80C00B3C[] = { + &object_cs_Tex_00C520, + &object_cs_Tex_00CD20, + &object_cs_Tex_00D520, + }; + static TexturePtr D_80C00B48[] = { + &object_cs_Tex_00E620, &object_cs_Tex_00EA20, &object_cs_Tex_00EE20, + &object_cs_Tex_00DD20, &object_cs_Tex_00F220, + }; + EnBomjima* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C00B3C[this->unk_2E0])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C00B48[this->unk_2E4])); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_80C00B28[this->unk_2E4])); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnBomjima_OverrideLimbDraw, NULL, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h index b24725d217..c01e70bd51 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h @@ -7,11 +7,53 @@ struct EnBomjima; typedef void (*EnBomjimaActionFunc)(struct EnBomjima*, GlobalContext*); +#define ENBOMJIMA_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) +#define ENBOMJIMA_GET_F(thisx) ((thisx)->params & 0xF) + typedef struct EnBomjima { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x140]; - /* 0x0284 */ EnBomjimaActionFunc actionFunc; - /* 0x0288 */ char unk_288[0xBC]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[21]; + /* 0x206 */ Vec3s morphTable[21]; + /* 0x284 */ EnBomjimaActionFunc actionFunc; + /* 0x288 */ s16 unk_288; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ UNK_TYPE1 unk28C[2]; + /* 0x28E */ s16 unk_28E; + /* 0x290 */ s16 unk_290; + /* 0x292 */ UNK_TYPE1 unk292[2]; + /* 0x294 */ s16 unk_294; + /* 0x296 */ UNK_TYPE1 unk296[4]; + /* 0x29A */ s16 unk_29A; + /* 0x29C */ UNK_TYPE1 unk29C[4]; + /* 0x2A0 */ s16 unk_2A0; + /* 0x2A2 */ s16 unk_2A2; + /* 0x2A4 */ Vec3f unk_2A4; + /* 0x2B0 */ Vec3f unk_2B0; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C2 */ s16 unk_2C2; + /* 0x2C4 */ s16 unk_2C4; + /* 0x2C6 */ s16 unk_2C6; + /* 0x2C8 */ s16 unk_2C8; + /* 0x2CA */ s16 unk_2CA; + /* 0x2CC */ f32 unk_2CC; + /* 0x2D0 */ f32 unk_2D0; + /* 0x2D4 */ s16 unk_2D4[2]; + /* 0x2D8 */ UNK_TYPE1 unk2D8[4]; // maybe a part of the above? + /* 0x2DC */ s16 unk_2DC; + /* 0x2DE */ s16 unk_2DE; + /* 0x2E0 */ s16 unk_2E0; + /* 0x2E2 */ s16 unk_2E2; + /* 0x2E4 */ s16 unk_2E4; + /* 0x2E6 */ s16 unk_2E6; + /* 0x2E8 */ s16 unk_2E8; + /* 0x2EA */ s16 unk_2EA; + /* 0x2EC */ s32 unk_2EC; + /* 0x2F0 */ EnBombal* unk_2F0; + /* 0x2F4 */ s16 unk_2F4; + /* 0x2F8 */ ColliderCylinder collider; } EnBomjima; // size = 0x344 extern const ActorInit En_Bomjima_InitVars; diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index b052bb6af5..dc776fa59a 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -5,6 +5,8 @@ */ #include "z_en_bomjimb.h" +#include "overlays/actors/ovl_En_Niw/z_en_niw.h" +#include "objects/object_cs/object_cs.h" #define FLAGS 0x00000009 @@ -15,19 +17,29 @@ void EnBomjimb_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBomjimb_Update(Actor* thisx, GlobalContext* globalCtx); void EnBomjimb_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80C01494(EnBomjimb* this); void func_80C014E4(EnBomjimb* this, GlobalContext* globalCtx); +void func_80C01984(EnBomjimb* this, GlobalContext* globalCtx); void func_80C01A24(EnBomjimb* this, GlobalContext* globalCtx); +void func_80C01B40(EnBomjimb* this); void func_80C01B74(EnBomjimb* this, GlobalContext* globalCtx); +void func_80C01C18(EnBomjimb* this, GlobalContext* globalCtx); void func_80C01CD0(EnBomjimb* this, GlobalContext* globalCtx); void func_80C0201C(EnBomjimb* this, GlobalContext* globalCtx); +void func_80C02108(EnBomjimb* this); void func_80C0217C(EnBomjimb* this, GlobalContext* globalCtx); +void func_80C0250C(EnBomjimb* this); void func_80C02570(EnBomjimb* this, GlobalContext* globalCtx); +void func_80C0267C(EnBomjimb* this); void func_80C02704(EnBomjimb* this, GlobalContext* globalCtx); +void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx); void func_80C02A14(EnBomjimb* this, GlobalContext* globalCtx); void func_80C02BCC(EnBomjimb* this, GlobalContext* globalCtx); +void func_80C02CA4(EnBomjimb* this, GlobalContext* globalCtx); void func_80C02DAC(EnBomjimb* this, GlobalContext* globalCtx); -#if 0 +static Actor* D_80C03170 = NULL; + const ActorInit En_Bomjimb_InitVars = { ACTOR_EN_BOMJIMB, ACTORCAT_NPC, @@ -40,79 +52,873 @@ const ActorInit En_Bomjimb_InitVars = { (ActorFunc)EnBomjimb_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C03194 = { - { COLTYPE_NONE, AT_NONE, AC_ON | 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 sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | 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, + }, { 20, 30, 0, { 0, 0, 0 } }, }; -#endif +void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBomjimb* this = THIS; -extern ColliderCylinderInit D_80C03194; + 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); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.targetMode = 6; + Actor_SetScale(&this->actor, 0.01f); -extern UNK_TYPE D_060064B8; + this->unk_2C6 = ENBOMJIMB_GET_F0(&this->actor); + this->unk_2B2 = ENBOMJIMB_GET_FF00(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/EnBomjimb_Init.s") + if (this->unk_2C6 != ENBOMJIMB_F0_0) { + this->unk_2C8 = ENBOMJIMB_GET_F(&this->actor) + 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/EnBomjimb_Destroy.s") + if (this->unk_2C8 < ENBOMJIMB_F_0) { + this->unk_2C8 = ENBOMJIMB_F_0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C0113C.s") + if (this->unk_2C6 < ENBOMJIMB_F0_0) { + this->unk_2C6 = ENBOMJIMB_F0_0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C011CC.s") + if ((gSaveContext.weekEventReg[73] & 0x10) || (gSaveContext.weekEventReg[85] & 2)) { + switch (this->unk_2C8) { + case ENBOMJIMB_F_0: + if (gSaveContext.weekEventReg[11] & 1) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C012E0.s") + case ENBOMJIMB_F_1: + if (gSaveContext.weekEventReg[11] & 2) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C012FC.s") + case ENBOMJIMB_F_2: + if (gSaveContext.weekEventReg[11] & 4) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C013B4.s") + case ENBOMJIMB_F_3: + if (gSaveContext.weekEventReg[11] & 8) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C013F0.s") + case ENBOMJIMB_F_4: + if (gSaveContext.weekEventReg[11] & 0x10) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C01494.s") + if ((!(gSaveContext.weekEventReg[73] & 0x10) && !(gSaveContext.weekEventReg[85] & 2)) || + (gSaveContext.weekEventReg[75] & 0x40)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C014E4.s") + Math_Vec3f_Copy(&this->unk_2A0, &this->actor.home.pos); + if ((this->unk_2C6 == ENBOMJIMB_F0_0) || (this->unk_2C6 == ENBOMJIMB_F0_1) || (this->unk_2C6 != ENBOMJIMB_F0_2)) { + func_80C01494(this); + } else { + func_80C01984(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C01984.s") +void EnBomjimb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBomjimb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C01A24.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C01B40.s") +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, + &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, + &object_cs_Anim_001708, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, + &object_cs_Anim_0031C4, &object_cs_Anim_010B68, + }; + static u8 D_80C03218[] = { + 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 0, 2, 0, 0, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C01B74.s") + this->unk_2DC = arg1; + this->unk_2B8 = Animation_GetLastFrame(sAnimations[arg1]); + Animation_Change(&this->skelAnime, sAnimations[this->unk_2DC], arg2, 0.0f, this->unk_2B8, D_80C03218[this->unk_2DC], + -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C01C18.s") +void func_80C011CC(EnBomjimb* this) { + if ((this->unk_2DC == 5) && + (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || + Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 18.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C01CD0.s") + if ((this->unk_2DC == 19) && + (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C01FD4.s") + if ((this->unk_2DC == 18) && Animation_OnFrame(&this->skelAnime, 15.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C0201C.s") + if ((this->unk_2DC == 7) && Animation_OnFrame(&this->skelAnime, 8.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C02108.s") +void func_80C012E0(EnBomjimb* this) { + this->unk_2C0 = 0; + this->unk_2AE = 0; + this->unk_2B0 = 0; + this->unk_2CC = 0; + this->unk_290 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C0217C.s") +s32 func_80C012FC(EnBomjimb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C0250C.s") + if (!func_801690CC(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); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C02570.s") +s32 func_80C013B4(EnBomjimb* this) { + if (this->collider.base.acFlags & AC_HIT) { + func_80C0267C(this); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C0267C.s") +s32 func_80C013F0(EnBomjimb* this, GlobalContext* globalCtx) { + Actor* sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C02704.s") + if (this->collider.base.ocFlags1 & OC1_HIT) { + sp1C = this->collider.base.oc; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C02740.s") + if ((sp1C->id == ACTOR_OBJ_KIBAKO) && (D_80C03170 == NULL) && (sp1C->update != NULL) && + !Actor_HasParent(sp1C, globalCtx)) { + D_80C03170 = sp1C; + this->unk_2E4 = sp1C; + func_80C01C18(this, globalCtx); + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C02A14.s") +void func_80C01494(EnBomjimb* this) { + func_80C012E0(this); + Math_Vec3f_Copy(&this->unk_2A0, &this->actor.world.pos); + this->unk_2CA = 3; + this->actionFunc = func_80C014E4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C02BCC.s") +void func_80C014E4(EnBomjimb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 curFrame = this->skelAnime.curFrame; + CollisionPoly* colPoly; + s16 abs; + f32 x; + f32 z; + f32 phi_f0; + Vec3f sp60; + Vec3f sp54; + Vec3f sp48; + s32 sp44; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C02CA4.s") + if (func_80C012FC(this, globalCtx) || func_80C013B4(this) || func_80C013F0(this, globalCtx)) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C02DAC.s") + switch (this->unk_2CC) { + case 0: + if (this->unk_2AE == 0) { + Math_Vec3f_Copy(&sp48, &this->actor.home.pos); + sp48.x += randPlusMinusPoint5Scaled(150.0f); + sp48.z += randPlusMinusPoint5Scaled(150.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/EnBomjimb_Update.s") + 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)) { + func_80C0113C(this, 5, 1.0f); + Math_Vec3f_Copy(&this->unk_294, &sp48); + this->unk_2B0 = Rand_S16Offset(30, 50); + this->unk_2CC++; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/func_80C02FA8.s") + case 1: + if (curFrame >= 0.0f) { + this->unk_2D6 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_294); + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2D6, 10, 2000, 20); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjimb/EnBomjimb_Draw.s") + if ((s16)ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->unk_2D6)) < 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, &sp60, &colPoly, 1, 0, 0, + 1, &sp44)) { + this->unk_2AE = 0; + if (Rand_ZeroOne() < 0.5f) { + func_80C0113C(this, 20, 1.0f); + } else { + func_80C0113C(this, 0, 1.0f); + } + this->unk_2CC = 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_2B0 == 0) || (sqrtf(SQ(x) + SQ(z)) < 4.0f)) { + this->unk_2AE = Rand_S16Offset(20, 20); + if (!(this->unk_2AE & 1)) { + func_80C0113C(this, 20, 1.0f); + } else { + func_80C0113C(this, 0, 1.0f); + } + this->unk_2CC = 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 (player->stateFlags3 != 0x1000000) { + phi_f0 = 200.0f; + + abs = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.world.rot.y)); + if (abs > 0x2890) { + phi_f0 = 150.0f; + } + + if (this->actor.xzDistToPlayer < phi_f0) { + func_80C02108(this); + } + } +} + +void func_80C01984(EnBomjimb* this, GlobalContext* globalCtx) { + func_80C012E0(this); + this->unk_2E4 = + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NIW, this->actor.world.pos.x, + this->actor.world.pos.y + 30.0f, this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, 2); + if (this->unk_2E4 != NULL) { + func_80C0113C(this, 11, 1.0f); + } + this->unk_2CA = 0; + this->actionFunc = func_80C01A24; +} + +void func_80C01A24(EnBomjimb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->actor.gravity = -0.1f; + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + if ((this->unk_2E4 != NULL) && (this->unk_2E4->update != NULL)) { + ((EnNiw*)this->unk_2E4)->unk2BC.z = 90000.0f; + } + this->actor.speedXZ = 0.0f; + this->unk_2E4 = NULL; + this->actor.gravity = -2.0f; + func_80C02108(this); + return; + } + + if ((this->actor.xzDistToPlayer < 200.0f) && (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 40.0f)) { + this->unk_2C0 = 1; + } + + if (this->unk_2C0 != 0) { + Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.5f, 2.0f); + } + + if ((this->unk_2C0 != 0) && !(this->actor.bgCheckFlags & 1)) { + func_80C01B40(this); + } +} + +void func_80C01B40(EnBomjimb* this) { + func_80C012E0(this); + this->unk_2CA = 0; + this->actionFunc = func_80C01B74; +} + +void func_80C01B74(EnBomjimb* this, GlobalContext* globalCtx) { + Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.5f, 2.0f); + if ((this->collider.base.acFlags & AC_HIT) || (this->actor.bgCheckFlags & 1)) { + this->collider.base.acFlags &= ~AC_HIT; + if ((this->unk_2E4 != NULL) && (this->unk_2E4->update != NULL)) { + ((EnNiw*)this->unk_2E4)->unk2BC.z = 90000.0f; + } + this->actor.speedXZ = 0.0f; + this->unk_2E4 = NULL; + this->actor.gravity = -2.0f; + func_80C02108(this); + } +} + +void func_80C01C18(EnBomjimb* this, GlobalContext* globalCtx) { + func_80C012E0(this); + if (this->unk_2E4 != NULL) { + if (this->unk_2E4->update != NULL) { + this->unk_2E4->velocity.y = 8.0f; + this->unk_2E4->shape.rot.z = BINANG_SUB(4000, ((s16)(globalCtx->gameplayFrames & 2) * 4000)); + this->unk_294.x = this->unk_2E4->world.pos.x; + this->unk_294.y = this->actor.world.pos.y; + this->unk_294.z = this->unk_2E4->world.pos.z; + } + } + this->actor.speedXZ = 0.0f; + this->unk_2CA = 2; + this->actionFunc = func_80C01CD0; +} + +void func_80C01CD0(EnBomjimb* this, GlobalContext* globalCtx) { + f32 sp3C = this->skelAnime.curFrame; + s32 pad[2]; + + if ((this->unk_2E4 != NULL) && ((this->unk_2E4->update == NULL) || Actor_HasParent(this->unk_2E4, globalCtx))) { + this->actor.draw = EnBomjimb_Draw; + D_80C03170 = NULL; + this->unk_2E4 = NULL; + func_80C02108(this); + return; + } + + if (this->unk_2DC != 7) { + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_294), 1, 3000, + 0); + Math_ApproachF(&this->actor.world.pos.x, this->unk_294.x, 0.3f, 2.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_294.z, 0.3f, 2.0f); + if (sqrtf(SQ(this->actor.world.pos.x - this->unk_294.x) + SQ(this->actor.world.pos.z - this->unk_294.z)) < + 3.0f) { + func_80C0113C(this, 7, 1.0f); + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_294); + } + } else if (this->unk_2B8 <= sp3C) { + this->actor.draw = NULL; + } + + if ((this->unk_2C0 == 0) && (this->unk_2E4->bgCheckFlags & 1)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PUT_DOWN_WOODBOX); + this->unk_2C0 = 1; + } + + if (this->unk_2AE == 0) { + if (this->actor.draw == NULL) { + this->unk_2AE = Rand_S16Offset(20, 30); + this->unk_2E4->shape.rot.z = 1000; + return; + } + + this->unk_2AE = 10; + if ((this->unk_2E4 != NULL) && (this->unk_2E4->update != NULL)) { + if ((globalCtx->gameplayFrames % 16) == 0) { + this->unk_2E4->shape.rot.z = -this->unk_2E4->shape.rot.z; + this->unk_2E4->shape.rot.z *= 0.1f; + } + + if (fabsf(this->unk_2E4->shape.rot.z) < 100.0f) { + this->unk_2E4->shape.rot.z = 0; + } + } + return; + } + + if (this->actor.draw == 0) { + this->unk_2E4->shape.rot.z = -this->unk_2E4->shape.rot.z; + this->unk_2E4->shape.rot.z *= 0.1f; + if (fabsf(this->unk_2E4->shape.rot.z) < 100.0f) { + this->unk_2E4->shape.rot.z = 0; + } + } +} + +void func_80C01FD4(EnBomjimb* this) { + this->actor.textId = 0x72D; + func_80C0113C(this, 9, 1.0f); + this->unk_2CA = 4; + this->actionFunc = func_80C0201C; +} + +void func_80C0201C(EnBomjimb* this, GlobalContext* globalCtx) { + s16 abs = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.world.rot.y)); + + this->unk_290 = 0; + if ((this->actor.xzDistToPlayer < 200.0f) && (abs < 0x61A8)) { + this->unk_290 = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + if (this->unk_290 > 10000) { + this->unk_290 = 10000; + } else if (this->unk_290 < -10000) { + this->unk_290 = -10000; + } + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2CA = 10; + this->actionFunc = func_80C02A14; + } else { + func_800B8614(&this->actor, globalCtx, 40.0f); + } +} + +void func_80C02108(EnBomjimb* this) { + func_80C0113C(this, 6, 1.0f); + this->unk_2D6 = BINANG_ROT180(this->actor.yawTowardsPlayer); + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + func_80C012E0(this); + Math_Vec3f_Copy(&this->unk_2A0, &this->actor.world.pos); + this->unk_2D4 = 0; + this->unk_2CA = 5; + this->actionFunc = func_80C0217C; +} + +void func_80C0217C(EnBomjimb* this, GlobalContext* globalCtx) { + Vec3f sp74; + CollisionPoly* sp70; + Vec3f sp64; + s32 sp60; + s32 sp5C = this->actor.floorBgId; + CollisionPoly* sp58 = this->actor.floorPoly; + Player* player = GET_PLAYER(globalCtx); + s32 sp50 = false; + + if (func_80C012FC(this, globalCtx) || func_80C013B4(this) || func_80C013F0(this, globalCtx)) { + return; + } + + if (player->stateFlags3 == 0x1000000) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 3000, 0); + func_80C01494(this); + return; + } + + if (this->unk_2DC == 6) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->unk_2B8 <= curFrame) { + func_80C0113C(this, 19, 2.0f); + } + return; + } + + Math_ApproachF(&this->actor.speedXZ, 8.0f, 0.5f, 2.0f); + Math_Vec3f_Copy(&sp74, &this->actor.world.pos); + + sp74.x += Math_SinS(this->actor.world.rot.y) * 50.0f; + 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)) { + s16 temp = BINANG_SUB((this->actor.world.rot.y - this->actor.yawTowardsPlayer), 0x8000); + this->unk_2D6 = temp; + + if (temp < 0) { + this->unk_2D6 += BINANG_ADD((s32)Rand_ZeroFloat(0x200), 0x4000); + if (this->unk_2D0 != 0) { + this->unk_2D6 += BINANG_ADD((s32)Rand_ZeroFloat(0x200), 0x4000); + } + this->unk_2D0 = 1; + } else { + this->unk_2D6 -= BINANG_ADD((s32)Rand_ZeroFloat(0x200), 0x4000); + if (this->unk_2D0 != 0) { + this->unk_2D6 -= BINANG_ADD((s32)Rand_ZeroFloat(0x200), 0x4000); + } + this->unk_2D0 = 1; + } + sp50 = true; + } + + if (!sp50) { + this->unk_2D0 = 0; + if (this->actor.xzDistToPlayer < 60.0f) { + this->unk_2D6 = BINANG_ROT180(this->actor.yawTowardsPlayer); + } + } + + this->actor.world.rot.y = this->unk_2D6 + this->unk_2D4; + + if (SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, sp58, sp5C)) { + s16 temp = BINANG_SUB(this->actor.world.rot.y, this->actor.yawTowardsPlayer - 0x8000); + + if (temp < 0) { + this->unk_2D4 -= 0x1000; + } else { + this->unk_2D4 += 0x1000; + } + this->actor.world.rot.y = this->unk_2D6 + this->unk_2D4; + return; + } + + this->unk_2D4 = 0; + if (!sp50 && (this->actor.xzDistToPlayer > 200.0f)) { + func_80C0250C(this); + } +} + +void func_80C0250C(EnBomjimb* this) { + func_80C0113C(this, 15, 1.0f); + this->unk_2D4 = 0; + this->actor.speedXZ = 0.0f; + this->unk_2D6 = BINANG_ROT180(this->actor.yawTowardsPlayer); + func_80C012E0(this); + this->unk_2CA = 6; + this->actionFunc = func_80C02570; +} + +void func_80C02570(EnBomjimb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (func_80C012FC(this, globalCtx) || func_80C013B4(this) || func_80C013F0(this, globalCtx)) { + return; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 5000, 0); + + if (this->actor.xzDistToPlayer < 200.0f) { + this->unk_2D6 = BINANG_ROT180(this->actor.yawTowardsPlayer); + func_80C0113C(this, 19, 2.0f); + this->actionFunc = func_80C0217C; + } else if ((player->stateFlags3 == 0x1000000) || (this->actor.xzDistToPlayer > 410.0f)) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 3000, 0); + func_80C01494(this); + } +} + +void func_80C0267C(EnBomjimb* this) { + func_80C012E0(this); + func_80C0113C(this, 8, 1.0f); + this->actor.speedXZ = 0.0f; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->unk_2AE = 40; + this->unk_2C2 = 0; + this->unk_2C4 = (s32)Rand_ZeroFloat(60.0f) + 20; + this->unk_2CA = 7; + this->actionFunc = func_80C02704; +} + +void func_80C02704(EnBomjimb* this, GlobalContext* globalCtx) { + if (!func_80C012FC(this, globalCtx) && (this->unk_2AE == 0)) { + func_80C0250C(this); + } +} + +void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { + static u16 D_80C03230[] = { + 0x0721, 0x0722, 0x0723, 0x0724, 0x072C, + }; + Player* player = GET_PLAYER(globalCtx); + s16 idx; + + func_80C012E0(this); + 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); + player->stateFlags1 |= 0x10000000; + player->actor.freezeTimer = 3; + func_80C012E0(this); + this->unk_2CA = 9; + this->actionFunc = func_80C02BCC; + return; + } + + if (((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.weekEventReg[73] & 0x10)) || + ((player->transformation == PLAYER_FORM_HUMAN) && !(gSaveContext.weekEventReg[85] & 2))) { + func_80C0113C(this, 17, 1.0f); + func_801518B0(globalCtx, 0x72E, &this->actor); + player->stateFlags1 |= 0x10000000; + player->actor.freezeTimer = 3; + func_80C012E0(this); + this->unk_2CA = 9; + this->actionFunc = func_80C02BCC; + return; + } + + idx = gSaveContext.unk_FE6; + func_801518B0(globalCtx, D_80C03230[idx], &this->actor); + idx = gSaveContext.unk_FE6; + gSaveContext.unk_FE7[idx] = this->unk_2C8 + 1; + gSaveContext.unk_FE6++; + + if (gSaveContext.unk_FE6 > 4) { + func_801A3098(0x922); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); + } + + switch (this->unk_2C8) { + case ENBOMJIMB_F_0: + gSaveContext.weekEventReg[76] |= 1; + gSaveContext.weekEventReg[11] |= 1; + break; + + case ENBOMJIMB_F_1: + gSaveContext.weekEventReg[76] |= 2; + gSaveContext.weekEventReg[11] |= 2; + break; + + case ENBOMJIMB_F_2: + gSaveContext.weekEventReg[76] |= 4; + gSaveContext.weekEventReg[11] |= 4; + break; + + case ENBOMJIMB_F_3: + gSaveContext.weekEventReg[76] |= 8; + gSaveContext.weekEventReg[11] |= 8; + break; + + case ENBOMJIMB_F_4: + gSaveContext.weekEventReg[76] |= 0x10; + gSaveContext.weekEventReg[11] |= 0x10; + break; + } + + if (!func_801690CC(globalCtx)) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags1 |= 0x10000000; + player->actor.freezeTimer = 3; + } + this->unk_2CA = 8; + this->actionFunc = func_80C02A14; +} + +void func_80C02A14(EnBomjimb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 curFrame = this->skelAnime.curFrame; + + if (this->unk_2DC == 21) { + player->actor.freezeTimer = 3; + if (this->unk_2B8 <= curFrame) { + func_80C0113C(this, 9, 1.0f); + } + return; + } + + if ((this->unk_2CA == 8) && (this->unk_2DC == 9)) { + player->actor.freezeTimer = 3; + if (this->unk_2E0 == 0) { + if (Animation_OnFrame(&this->skelAnime, 7.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); + this->unk_2E0 = 1; + } + } + } + + if ((this->unk_2DC == 15) && (this->unk_2CA == 8)) { + player->actor.freezeTimer = 3; + } + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + if ((this->unk_2CA == 8) && (gSaveContext.unk_FE6 >= 5)) { + func_80C02CA4(this, globalCtx); + } else { + if (this->unk_2CA == 8) { + player->stateFlags1 &= ~0x10000000; + } + func_80C01FD4(this); + } + } +} + +void func_80C02BCC(EnBomjimb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(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)) { + func_801477B4(globalCtx); + this->unk_2C0 = 1; + player->stateFlags1 &= ~0x10000000; + } + } else if (this->actor.xzDistToPlayer > 200.0f) { + func_80C01494(this); + } +} + +void func_80C02CA4(EnBomjimb* this, GlobalContext* globalCtx) { + if (BREG(13) == 0) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[this->unk_2B2]; + gSaveContext.nextCutsceneIndex = 0; + Scene_SetExitFade(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + } else { + globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(5); + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 0x56; + gSaveContext.nextTransition = 3; + } + gSaveContext.weekEventReg[75] |= 0x40; + gSaveContext.weekEventReg[83] |= 4; + this->actionFunc = func_80C02DAC; +} + +void func_80C02DAC(EnBomjimb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.freezeTimer = 3; +} + +void EnBomjimb_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnBomjimb* this = THIS; + + if (this->unk_2B0 != 0) { + this->unk_2B0--; + } + + if (this->unk_2AE != 0) { + this->unk_2AE--; + } + + if (this->unk_2AC != 0) { + this->unk_2AC--; + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y = this->actor.world.rot.y; + func_80C011CC(this); + Actor_SetFocus(&this->actor, 20.0f); + + this->actionFunc(this, globalCtx); + + Actor_MoveWithGravity(&this->actor); + + if (this->unk_2CA == 0) { + if ((this->unk_2E4 != NULL) && (this->unk_2E4->update != NULL)) { + Math_Vec3f_Copy(&this->unk_2E4->world.pos, &this->actor.world.pos); + if (this->actor.bgCheckFlags & 1) { + this->unk_2E4->world.pos.y = this->actor.world.pos.y + 35.0f; + } else { + this->unk_2E4->world.pos.y = this->actor.world.pos.y + 25.0f; + } + } + } + + Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 5000, 0); + + if (this->unk_2C4 == 0) { + this->unk_2C2++; + if (this->unk_2C2 > 2) { + this->unk_2C2 = 0; + this->unk_2C4 = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->unk_2CA != 2) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +s32 EnBomjimb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBomjimb* this = THIS; + + if (limbIndex == 15) { + *dList = NULL; + } + + if (limbIndex == 17) { + rot->x += this->unk_28A; + rot->z += this->unk_288; + } + + if ((limbIndex == 19) && (this->unk_2C8 != ENBOMJIMB_F_0)) { + *dList = NULL; + } + + if ((limbIndex == 20) && (this->unk_2C8 == ENBOMJIMB_F_0)) { + *dList = NULL; + } + + return false; +} + +#include "overlays/ovl_En_Bomjimb/ovl_En_Bomjimb.c" + +void EnBomjimb_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* D_80C03260[] = { + gEnBomjimb_D_80C03240, gEnBomjimb_D_80C03250, gEnBomjimb_D_80C03250, + gEnBomjimb_D_80C03250, gEnBomjimb_D_80C03250, + }; + static TexturePtr D_80C03274[] = { + &object_cs_Tex_00C520, + &object_cs_Tex_00CD20, + &object_cs_Tex_00D520, + }; + static TexturePtr D_80C03280[] = { + &object_cs_Tex_00E620, &object_cs_Tex_00EA20, &object_cs_Tex_00EE20, + &object_cs_Tex_00DD20, &object_cs_Tex_00F220, + }; + EnBomjimb* 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_80C03274[this->unk_2C2])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C03280[this->unk_2C8])); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_80C03260[this->unk_2C8])); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnBomjimb_OverrideLimbDraw, NULL, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.h b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.h index 664b34224c..7a961461c8 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.h +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.h @@ -7,11 +7,58 @@ struct EnBomjimb; typedef void (*EnBomjimbActionFunc)(struct EnBomjimb*, GlobalContext*); +#define ENBOMJIMB_GET_F(thisx) ((thisx)->params & 0xF) +#define ENBOMJIMB_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) +#define ENBOMJIMB_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + +enum { + /* 0 */ ENBOMJIMB_F_0, + /* 1 */ ENBOMJIMB_F_1, + /* 2 */ ENBOMJIMB_F_2, + /* 3 */ ENBOMJIMB_F_3, + /* 4 */ ENBOMJIMB_F_4, +}; + +enum { + /* 0 */ ENBOMJIMB_F0_0, + /* 1 */ ENBOMJIMB_F0_1, + /* 2 */ ENBOMJIMB_F0_2, +}; + typedef struct EnBomjimb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x140]; - /* 0x0284 */ EnBomjimbActionFunc actionFunc; - /* 0x0288 */ char unk_288[0xAC]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[21]; + /* 0x206 */ Vec3s morphTable[21]; + /* 0x284 */ EnBomjimbActionFunc actionFunc; + /* 0x288 */ s16 unk_288; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ UNK_TYPE1 unk28C[4]; + /* 0x290 */ s16 unk_290; + /* 0x294 */ Vec3f unk_294; + /* 0x2A0 */ Vec3f unk_2A0; + /* 0x2AC */ s16 unk_2AC; + /* 0x2AE */ s16 unk_2AE; + /* 0x2B0 */ s16 unk_2B0; + /* 0x2B2 */ s16 unk_2B2; + /* 0x2B4 */ f32 unk_2B4; + /* 0x2B8 */ f32 unk_2B8; + /* 0x2BC */ UNK_TYPE1 unk2BC[4]; + /* 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 */ s16 unk_2CC; + /* 0x2D0 */ s32 unk_2D0; + /* 0x2D4 */ s16 unk_2D4; + /* 0x2D6 */ s16 unk_2D6; + /* 0x2D8 */ UNK_TYPE1 unk2D8[4]; + /* 0x2DC */ s32 unk_2DC; + /* 0x2E0 */ u8 unk_2E0; + /* 0x2E4 */ Actor* unk_2E4; + /* 0x2E8 */ ColliderCylinder collider; } EnBomjimb; // size = 0x334 extern const ActorInit En_Bomjimb_InitVars; diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.c b/src/overlays/actors/ovl_En_Box/z_en_box.c index 37331740ef..98e6b06c58 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -150,7 +150,7 @@ void func_80867C8C(func_80867BDC_a0* arg0, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023210); } Matrix_StatePop(); - gSPMatrix(POLY_XLU_DISP++, &D_801D1DE0, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); CLOSE_DISPS(globalCtx->state.gfxCtx); } } @@ -206,7 +206,7 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { this->iceSmokeTimer = 0; this->unk_1F3 = 0; this->dyna.actor.gravity = -5.5f; - this->dyna.actor.minVelocityY = -50.0f; + this->dyna.actor.terminalVelocity = -50.0f; this->switchFlag = this->dyna.actor.world.rot.z; this->dyna.actor.floorHeight = this->dyna.actor.world.pos.y; if (this->dyna.actor.world.rot.x == 180) { @@ -221,7 +221,7 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->shape.rot.x = this->dyna.actor.world.rot.x; this->getItem = (thisx->params >> 5) & 0x7F; - if (Actor_GetChestFlag(globalCtx, (this->dyna.actor.params & 0x1F)) || this->getItem == 0) { + if (Flags_GetTreasure(globalCtx, (this->dyna.actor.params & 0x1F)) || this->getItem == 0) { this->alpha = 255; this->iceSmokeTimer = 100; EnBox_SetupAction(this, EnBox_Open); @@ -239,7 +239,7 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { this->movementFlags |= ENBOX_MOVE_IMMOBILE; this->dyna.actor.flags |= 0x10; } else if ((this->type == ENBOX_TYPE_ROOM_CLEAR_BIG || this->type == ENBOX_TYPE_ROOM_CLEAR_SMALL) && - !Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { + !Flags_GetClear(globalCtx, this->dyna.actor.room)) { EnBox_SetupAction(this, EnBox_AppearOnRoomClear); func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); if (this->movementFlags & ENBOX_MOVE_0x80) { @@ -273,22 +273,22 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { this->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; } - if (this->getItem == 0x11 && !Actor_GetChestFlag(globalCtx, this->dyna.actor.params & 0x1F)) { + if (this->getItem == 0x11 && !Flags_GetTreasure(globalCtx, this->dyna.actor.params & 0x1F)) { this->dyna.actor.flags |= 0x10; } this->dyna.actor.shape.rot.y += 0x8000; this->dyna.actor.home.rot.z = this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z = 0; - SkelAnime_Init(globalCtx, &this->skelAnime, &object_box_Skel_0066A0, &object_box_Anim_00043C, &this->jointTable, - &this->morphTable, 5); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_box_Skel_0066A0, &object_box_Anim_00043C, this->jointTable, + this->morphTable, 5); Animation_Change(&this->skelAnime, &object_box_Anim_00043C, 1.5f, animFrame, animFrameEnd, 2, 0.0f); if (func_800BE63C(this) != 0) { Actor_SetScale(&this->dyna.actor, 0.0075f); - Actor_SetHeight(&this->dyna.actor, 20.0f); + Actor_SetFocus(&this->dyna.actor, 20.0f); } else { Actor_SetScale(&this->dyna.actor, 0.01f); - Actor_SetHeight(&this->dyna.actor, 40.0f); + Actor_SetFocus(&this->dyna.actor, 40.0f); } this->cutsceneIdxA = -1; @@ -363,7 +363,7 @@ void EnBox_Fall(EnBox* this, GlobalContext* globalCtx) { this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; EnBox_SetupAction(this, EnBox_WaitOpen); } - func_8019F1C0(&this->dyna.actor.projectedPos, NA_SE_EV_TRE_BOX_BOUND); + Audio_PlaySfxAtPos(&this->dyna.actor.projectedPos, NA_SE_EV_TRE_BOX_BOUND); EnBox_SpawnDust(this, globalCtx); } yDiff = this->dyna.actor.world.pos.y - this->dyna.actor.floorHeight; @@ -401,10 +401,10 @@ void EnBox_AppearSwitchFlag(EnBox* this, GlobalContext* globalCtx) { void EnBox_AppearOnRoomClear(EnBox* this, GlobalContext* globalCtx) { func_800B8C50(&this->dyna.actor, globalCtx); - if (Actor_GetRoomClearedTemp(globalCtx, this->dyna.actor.room)) { + if (Flags_GetClearTemp(globalCtx, this->dyna.actor.room)) { if (ActorCutscene_GetCanPlayNext(this->cutsceneIdxA)) { ActorCutscene_StartAndSetUnkLinkFields(this->cutsceneIdxA, &this->dyna.actor); - Actor_SetRoomCleared(globalCtx, this->dyna.actor.room); + Flags_SetClear(globalCtx, this->dyna.actor.room); EnBox_SetupAction(this, func_80868AFC); this->unk_1A0 = -30; } else { @@ -418,7 +418,7 @@ void func_80868AFC(EnBox* this, GlobalContext* globalCtx) { EnBox_SetupAction(this, func_80868B74); this->unk_1A0 = 0; func_80867FBC(&this->unk_1F4, globalCtx, (this->movementFlags & ENBOX_MOVE_0x80) != 0); - func_8019F1C0(&this->dyna.actor.projectedPos, 0x287B); + Audio_PlaySfxAtPos(&this->dyna.actor.projectedPos, NA_SE_EV_TRE_BOX_APPEAR); } } @@ -489,28 +489,28 @@ void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) { this->movementFlags |= ENBOX_MOVE_0x20; } else { if (this->getItem == GI_HEART_PIECE || this->getItem == GI_5A) { - Actor_SetCollectibleFlag(globalCtx, this->collectableFlag); + Flags_SetCollectible(globalCtx, this->collectableFlag); } - Actor_SetChestFlag(globalCtx, this->dyna.actor.params & 0x1F); + Flags_SetTreasure(globalCtx, this->dyna.actor.params & 0x1F); } } else { player = GET_PLAYER(globalCtx); - Actor_CalcOffsetOrientedToDrawRotation(&this->dyna.actor, &offset, &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); if (offset.z > -50.0f && offset.z < 0.0f && fabsf(offset.y) < 10.0f && fabsf(offset.x) < 20.0f && - Actor_IsLinkFacingActor(&this->dyna.actor, 0x3000, globalCtx)) { + Player_IsFacingActor(&this->dyna.actor, 0x3000, globalCtx)) { if ((this->getItem == GI_HEART_PIECE || this->getItem == GI_5A) && - Actor_GetCollectibleFlag(globalCtx, this->collectableFlag)) { - this->getItem = GI_0A; + Flags_GetCollectible(globalCtx, this->collectableFlag)) { + this->getItem = GI_RECOVERY_HEART; } if (this->getItem == 0x7C && INV_CONTENT(ITEM_MASK_CAPTAIN) == ITEM_MASK_CAPTAIN) { - this->getItem = GI_0A; + this->getItem = GI_RECOVERY_HEART; } if (this->getItem == 0x7D && INV_CONTENT(ITEM_MASK_GIANT) == ITEM_MASK_GIANT) { - this->getItem = GI_0A; + this->getItem = GI_RECOVERY_HEART; } - func_800B8B84(&this->dyna.actor, globalCtx, -this->getItem); + Actor_PickUpNearby(&this->dyna.actor, globalCtx, -this->getItem); } - if (Actor_GetChestFlag(globalCtx, this->dyna.actor.params & 0x1F)) { + if (Flags_GetTreasure(globalCtx, this->dyna.actor.params & 0x1F)) { EnBox_SetupAction(this, EnBox_Open); } } @@ -554,7 +554,7 @@ void EnBox_Open(EnBox* this, GlobalContext* globalCtx) { sfxId = NA_SE_EV_TBOX_OPEN; } if (sfxId != 0) { - func_8019F1C0(&this->dyna.actor.projectedPos, sfxId); + Audio_PlaySfxAtPos(&this->dyna.actor.projectedPos, sfxId); } if (this->skelAnime.jointTable[3].z > 0) { this->unk_1A8 = (0x7D00 - this->skelAnime.jointTable[3].z) * 0.00006f; @@ -602,7 +602,7 @@ void EnBox_Update(Actor* thisx, GlobalContext* globalCtx) { this->movementFlags &= ~ENBOX_MOVE_STICK_TO_GROUND; EnBox_ClipToGround(this, globalCtx); } - if (this->getItem == 0x11 && !Actor_GetChestFlag(globalCtx, this->dyna.actor.params & 0x1F)) { + if (this->getItem == 0x11 && !Flags_GetTreasure(globalCtx, this->dyna.actor.params & 0x1F)) { globalCtx->actorCtx.unk5 |= 8; } this->actionFunc(this, globalCtx); @@ -610,10 +610,10 @@ void EnBox_Update(Actor* thisx, GlobalContext* globalCtx) { this->movementFlags |= ENBOX_MOVE_IMMOBILE; } if (!(this->movementFlags & ENBOX_MOVE_IMMOBILE)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->dyna.actor); + Actor_MoveWithGravity(&this->dyna.actor); Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x1C); } - Actor_SetHeight(&this->dyna.actor, 40.0f); + Actor_SetFocus(&this->dyna.actor, 40.0f); if (this->getItem == 0x76 && this->actionFunc == EnBox_Open && this->skelAnime.curFrame > 45.0f && this->iceSmokeTimer < 100) { EnBox_SpawnIceSmoke(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Bu/z_en_bu.c b/src/overlays/actors/ovl_En_Bu/z_en_bu.c index 3c56535256..6dab7f307d 100644 --- a/src/overlays/actors/ovl_En_Bu/z_en_bu.c +++ b/src/overlays/actors/ovl_En_Bu/z_en_bu.c @@ -44,7 +44,7 @@ void EnBu_DoNothing(EnBu* this, GlobalContext* globalCtx) { void EnBu_Update(Actor* thisx, GlobalContext* globalCtx) { EnBu* this = THIS; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); this->actionFunc(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Cha/z_en_cha.c b/src/overlays/actors/ovl_En_Cha/z_en_cha.c index d8f32613f4..d5a2f0be06 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.c +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.c @@ -86,12 +86,12 @@ void EnCha_Ring(EnCha* this, GlobalContext* globalCtx) { void EnCha_Idle(EnCha* this, GlobalContext* globalCtx) { if (gSaveContext.weekEventReg[60] & 4) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_DOOR_BELL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); gSaveContext.weekEventReg[60] &= 0xFB; this->actor.home.rot.z = 0x7D0; } if (this->collider.base.acFlags & AC_HIT) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_DOOR_BELL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); this->actor.home.rot.z = 0x7D0; if (!(gSaveContext.weekEventReg[51] & 4)) { gSaveContext.weekEventReg[51] |= 4; @@ -117,8 +117,8 @@ void EnCha_Update(Actor* thisx, GlobalContext* globalCtx) { void EnCha_Draw(Actor* thisx, GlobalContext* globalCtx) { EnCha* this = THIS; - func_800BDFC0(globalCtx, D_06000710); + Gfx_DrawDListOpa(globalCtx, D_06000710); Matrix_InsertTranslation(-1094.0f, 4950.0f, 9.0f, MTXMODE_APPLY); Matrix_InsertXRotation_s(this->actor.home.rot.x, MTXMODE_APPLY); - func_800BDFC0(globalCtx, D_06000958); + Gfx_DrawDListOpa(globalCtx, D_06000958); } diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index f76b22296c..d323c98d27 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -538,7 +538,7 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { func_80169590(globalCtx, 0, 1); func_80169590(globalCtx, this->camId, 7); func_800B7298(globalCtx, &this->actor, 4); - camera = Play_GetCamera(globalCtx, 0); + camera = Play_GetCamera(globalCtx, MAIN_CAM); this->eye.x = camera->eye.x; this->eye.y = camera->eye.y; this->eye.z = camera->eye.z; @@ -556,8 +556,8 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { } player->actor.speedXZ = 0.0f; - if (func_80152498(&globalCtx->msgCtx) == 0) { - camera = Play_GetCamera(globalCtx, 0); + if (Message_GetState(&globalCtx->msgCtx) == 0) { + camera = Play_GetCamera(globalCtx, MAIN_CAM); camera->eye = this->eye; camera->eyeNext = this->eye; camera->at = this->at; diff --git a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c index d65232214b..531e0b1229 100644 --- a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c +++ b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c @@ -1,10 +1,12 @@ /* * File: z_en_col_man.c * Overlay: ovl_En_Col_Man - * Description: Piece of Heart spawned by Fish2 + * Description: Lab HP, Garo Master falling rocks, Garo Master bomb */ #include "z_en_col_man.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00100000 @@ -13,17 +15,35 @@ void EnColMan_Init(Actor* thisx, GlobalContext* globalCtx); void EnColMan_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnColMan_Update(Actor* thisx, GlobalContext* globalCtx); - +void func_80AFDD60(EnColMan* this); void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx); -void func_80AFDF00(EnColMan* this, GlobalContext* globalCtx); +void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, GlobalContext* globalCtx); +void func_80AFDF60(EnColMan* this); void func_80AFDFB4(EnColMan* this, GlobalContext* globalCtx); +void func_80AFE234(EnColMan* this); void func_80AFE25C(EnColMan* this, GlobalContext* globalCtx); +void func_80AFE414(Actor* thisx, GlobalContext* globalCtx); +void func_80AFE4AC(Actor* thisx, GlobalContext* globalCtx); +void func_80AFE584(Actor* thisx, GlobalContext* globalCtx); +void func_80AFE650(Actor* thisx, GlobalContext* globalCtx); -#if 0 -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AFE730 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 11, 1, { 0, 0, 0 } }, }; @@ -39,34 +59,217 @@ const ActorInit En_Col_Man_InitVars = { (ActorFunc)NULL, }; -#endif +static Color_RGBA8 primColor = { 60, 50, 20, 255 }; +static Color_RGBA8 envColor = { 40, 30, 30, 255 }; -extern ColliderCylinderInit D_80AFE730; +void EnColMan_Init(Actor* thisx, GlobalContext* globalCtx) { + EnColMan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/EnColMan_Init.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.targetMode = 1; + this->scale = (BREG(55) / 1000.0f) + 0.01f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/EnColMan_Destroy.s") + switch (this->actor.params) { + case EN_COL_MAN_HEART_PIECE: + case EN_COL_MAN_RECOVERY_HEART: + default: + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); + func_80AFDD60(this); + break; + case EN_COL_MAN_FALLING_ROCK: + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); + func_80AFDF60(this); + break; + case EN_COL_MAN_CUTSCENE_BOMB: + case EN_COL_MAN_GAMEPLAY_BOMB: + func_80AFE234(this); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFDD60.s") +void EnColMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnColMan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFDE00.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFDF00.s") +void func_80AFDD60(EnColMan* this) { + if (!(gSaveContext.weekEventReg[56] & 2)) { + this->actor.draw = func_80AFE414; + this->actor.shape.yOffset = 700.0f; + if (this->actor.params == EN_COL_MAN_HEART_PIECE) { + this->actor.gravity = -2.0f; + } + this->type = EN_COL_MAN_HEART_PIECE; + } else { + this->actor.draw = func_80AFE4AC; + this->actor.shape.yOffset = 300.0f; + this->actor.shape.shadowScale = 5.0f; + if (this->actor.params == EN_COL_MAN_HEART_PIECE) { + this->actor.gravity = -2.0f; + } + this->type = EN_COL_MAN_RECOVERY_HEART; + } + this->actionFunc = func_80AFDE00; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFDF60.s") +void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx) { + if (this->actor.bgCheckFlags & 1) { + if (this->actor.params == EN_COL_MAN_HEART_PIECE) { + this->actor.params = EN_COL_MAN_RECOVERY_HEART; + this->actor.speedXZ = 2.0f; + this->actor.velocity.y = 8.0f; + } else { + this->actor.speedXZ = 0.0f; + } + } + if (!(gSaveContext.weekEventReg[56] & 2)) { + this->actor.shape.rot.y += 0x3E8; + } + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actor.draw = NULL; + this->actionFunc = EnColMan_SetHeartPieceCollectedAndKill; + } else if (!(gSaveContext.weekEventReg[56] & 2)) { + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 40.0f, 40.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_RECOVERY_HEART, 40.0f, 40.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFDFB4.s") +void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + gSaveContext.weekEventReg[56] |= 2; + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFE234.s") +void func_80AFDF60(EnColMan* this) { + this->actor.draw = func_80AFE584; + this->actor.flags |= 0x10; + this->actor.flags |= 0x20; + this->type = EN_COL_MAN_FALLING_ROCK; + this->actionFunc = func_80AFDFB4; + this->actor.shape.shadowScale = 5.0f; + this->actor.gravity = -3.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFE25C.s") +void func_80AFDFB4(EnColMan* this, GlobalContext* globalCtx) { + s32 i; + Vec3f velocity; + Vec3f accel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/EnColMan_Update.s") + this->scale = (BREG(55) / 10000.0f) + 0.0015f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFE414.s") + if ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f)) { + if (!this->hasSetRandomValues) { + this->actor.world.rot.y = randPlusMinusPoint5Scaled(30000.0f); + this->actor.speedXZ = 2.0f + BREG(56) + Rand_ZeroFloat(2.0f); + this->actor.velocity.y = 12.0f + BREG(57) + Rand_ZeroFloat(5.0f); + this->hasSetRandomValues = true; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ANSATSUSYA_ROCK); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFE4AC.s") + for (i = 0; i < 2; i++) { + velocity.x = randPlusMinusPoint5Scaled(2.0f); + velocity.y = Rand_ZeroFloat(2.0f) + 1.0f; + velocity.z = randPlusMinusPoint5Scaled(2.0f); + accel.y = -0.1f; + accel.z = 0.0f; + accel.x = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFE584.s") + func_800B0EB0(globalCtx, &this->actor.world.pos, &velocity, &accel, &primColor, &envColor, + Rand_ZeroFloat(50.0f) + 60.0f, 30, Rand_ZeroFloat(5.0f) + 20.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFE650.s") + Actor_MarkForDeath(&this->actor); + } +} + +void func_80AFE234(EnColMan* this) { + this->actor.draw = func_80AFE650; + this->type = EN_COL_MAN_CUTSCENE_BOMB; + this->actionFunc = func_80AFE25C; +} + +void func_80AFE25C(EnColMan* this, GlobalContext* globalCtx) { + this->scale = BREG(55) * 0.01f + 0.05f; + + if (BREG(60) || (this->actor.world.rot.z != 0)) { + if (this->actor.params == EN_COL_MAN_CUTSCENE_BOMB) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.parent->world.pos.x, + this->actor.parent->world.pos.y, this->actor.parent->world.pos.z, 0, 0, 0, + CLEAR_TAG_SMALL_EXPLOSION); + } else { + EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + + if (bomb != NULL) { + bomb->timer = 0; + } + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_MarkForDeath(&this->actor); + } +} + +void EnColMan_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnColMan* this = THIS; + + Actor_SetScale(&this->actor, this->scale); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 30.0f, 30.0f, 0x1F); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80AFE414(Actor* thisx, GlobalContext* globalCtx) { + EnColMan* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + func_800B8118(&this->actor, globalCtx, 0); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_05AAB0); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80AFE4AC(Actor* thisx, GlobalContext* globalCtx) { + EnColMan* this = THIS; + + func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(globalCtx->state.gfxCtx); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&gameplay_keep_Tex_05E6F0)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80AFE584(Actor* thisx, GlobalContext* globalCtx) { + func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06AB30); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80AFE650(Actor* thisx, GlobalContext* globalCtx) { + func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(globalCtx->state.gfxCtx); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&gameplay_keep_Tex_05CEF0)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.h b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.h index 6bab3c11a6..ab1ac285dd 100644 --- a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.h +++ b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.h @@ -8,10 +8,21 @@ struct EnColMan; typedef void (*EnColManActionFunc)(struct EnColMan*, GlobalContext*); typedef struct EnColMan { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnColManActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x58]; -} EnColMan; // size = 0x1A0 + /* 0x000 */ Actor actor; + /* 0x144 */ EnColManActionFunc actionFunc; + /* 0x148 */ s16 type; // never used, only set + /* 0x14C */ s32 hasSetRandomValues; + /* 0x150 */ f32 scale; + /* 0x154 */ ColliderCylinder collider; +} EnColMan; /* size = 0x1A0 */ + +typedef enum { + /* 0 */ EN_COL_MAN_HEART_PIECE, + /* 1 */ EN_COL_MAN_RECOVERY_HEART, + /* 2 */ EN_COL_MAN_FALLING_ROCK, + /* 3 */ EN_COL_MAN_CUTSCENE_BOMB, + /* 4 */ EN_COL_MAN_GAMEPLAY_BOMB, +} EnColManType; extern const ActorInit En_Col_Man_InitVars; diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index 54eb091b76..9f997cc1eb 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -108,7 +108,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnCow* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 72.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 72.0f); switch (EN_COW_TYPE(thisx)) { case EN_COW_TYPE_DEFAULT: @@ -207,7 +207,7 @@ void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { } void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { this->actor.flags &= ~0x10000; func_801477B4(globalCtx); this->actionFunc = EnCow_Idle; @@ -215,7 +215,7 @@ void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { } void EnCow_GiveMilkEnd(EnCow* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actor.flags &= ~0x10000; this->actionFunc = EnCow_Idle; } @@ -226,21 +226,21 @@ void EnCow_GiveMilkWait(EnCow* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = EnCow_GiveMilkEnd; } else { - func_800B8A1C(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); } } void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { this->actor.flags &= ~0x10000; func_801477B4(globalCtx); this->actionFunc = EnCow_GiveMilkWait; - func_800B8A1C(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); } } void EnCow_CheckForEmptyBottle(EnCow* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { if (func_80114E90()) { func_80151938(globalCtx, 0x32C9); // Text to give milk. this->actionFunc = EnCow_GiveMilk; @@ -252,7 +252,7 @@ void EnCow_CheckForEmptyBottle(EnCow* this, GlobalContext* globalCtx) { } void EnCow_Talk(EnCow* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->actor.textId == 0x32C8) { // Text to give milk after playing Epona's Song. this->actionFunc = EnCow_CheckForEmptyBottle; } else if (this->actor.textId == 0x32C9) { // Text to give milk. @@ -345,13 +345,13 @@ void EnCow_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders[0].base); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders[1].base); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (SkelAnime_Update(&this->skelAnime)) { if (this->skelAnime.animation == &D_060001CC) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_COW_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_COW_CRY); Animation_Change(&this->skelAnime, &D_06004264, 1.0f, 0.0f, Animation_GetLastFrame(&D_06004264), ANIMMODE_ONCE, 1.0f); } else { diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index 8f14b6c678..0e83d1091f 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -192,7 +192,7 @@ s32 func_80B3E69C(EnDai* this, GlobalContext* globalCtx) { if ((globalCtx->csCtx.state != 0) && (globalCtx->sceneNum == SCENE_12HAKUGINMAE) && (globalCtx->csCtx.unk_12 == 0) && !(gSaveContext.weekEventReg[30] & 1)) { if (!(this->unk_1CE & 0x10)) { - Actor_SetSwitchFlag(globalCtx, 20); + Flags_SetSwitch(globalCtx, 20); this->unk_1CE |= (0x80 | 0x10); this->unk_1CE &= ~(0x100 | 0x20); this->unk_1CC = 0xFF; @@ -216,7 +216,7 @@ s32 func_80B3E7C8(EnDai* this, GlobalContext* globalCtx) { s32 ret = false; if (this->unk_1CE & 7) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_8013AED4(&this->unk_1CE, 0, 7); this->actionFunc = func_80B3EF90; ret = true; @@ -304,7 +304,7 @@ s32 func_80B3E96C(EnDai* this, GlobalContext* globalCtx) { break; case 1: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SNOWSTORM_HARD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SNOWSTORM_HARD); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WEATHER_TAG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0x1388, 0x708, 0x3E8, 0); func_80B3E5DC(this, 3); @@ -470,7 +470,7 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { break; case 2: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROLL_AND_FALL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROLL_AND_FALL); break; case 3: @@ -493,27 +493,27 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { case 2: if (globalCtx->csCtx.frames == 360) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIGOLON_SLEEP3 - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIGOLON_SLEEP3 - SFX_FLAG); } if (Animation_OnFrame(&this->skelAnime, 43.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GORON_BOUND_1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_1); } this->unk_1D6 = func_80B3E8BC(this, this->unk_1CC); break; case 3: if (Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIGOLON_SLEEP1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIGOLON_SLEEP1); } this->unk_1D6 = func_80B3E8BC(this, this->unk_1CC); break; case 4: if (Animation_OnFrame(&this->skelAnime, 30.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIGOLON_SLEEP2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIGOLON_SLEEP2); } if (Animation_OnFrame(&this->skelAnime, 35.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GORON_BOUND_0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_0); } this->unk_1D6 = func_80B3E8BC(this, this->unk_1CC); break; @@ -525,7 +525,7 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { EnDai* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 0.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060130D0, NULL, this->jointTable, this->morphTable, 19); this->unk_A70 = -1; func_80B3E5DC(this, 0); @@ -591,7 +591,7 @@ s32 func_80B3F598(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p } if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&D_801D15B0, &this->unk_1E4); + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_1E4); } if (limbIndex == 10) { diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c index 40eac8099a..4971193a32 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -76,7 +76,7 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { EnDaiku* this = THIS; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 40.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); this->actor.targetMode = 0; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->unk_278 = ENDAIKU_GET_FF(&this->actor); @@ -195,7 +195,7 @@ void func_809438F8(EnDaiku* this, GlobalContext* globalCtx) { this->actor.textId = sTextIds[this->unk_28C]; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80943BC0(this); return; } @@ -255,7 +255,7 @@ void func_80943BDC(EnDaiku* this, GlobalContext* globalCtx) { } } - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); func_80943820(this); } @@ -286,8 +286,8 @@ void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->actor.shape.rot.y = this->actor.world.rot.y; - Actor_SetHeight(&this->actor, 65.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_SetFocus(&this->actor, 65.0f); + Actor_MoveWithGravity(&this->actor); Math_SmoothStepToS(&this->unk_260, this->unk_266, 1, 0xBB8, 0); Math_SmoothStepToS(&this->unk_25E, this->unk_264, 1, 0xBB8, 0); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c index daa1597884..6776086cc6 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -95,7 +95,7 @@ void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx) { s32 day = gSaveContext.day; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 40.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600A850, &D_06002FA0, this->jointTable, this->morphTable, 17); this->actor.targetMode = 0; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -158,7 +158,7 @@ s32 func_80BE64C0(EnDaiku2* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp30, &this->actor.world.pos); Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); - bomb = (EnBom*)func_800BE0B8(globalCtx, &this->actor, -1, ACTORCAT_EXPLOSIVES, BREG(7) + 240.0f); + bomb = (EnBom*)Actor_FindNearby(globalCtx, &this->actor, -1, ACTORCAT_EXPLOSIVES, BREG(7) + 240.0f); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); if ((this->unk_278 >= ENDAIKU2_GET_7F_0) && !Flags_GetSwitch(globalCtx, this->unk_278) && (bomb != NULL) && (bomb->actor.id == ACTOR_EN_BOM)) { @@ -233,7 +233,7 @@ void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { this->actor.textId = sTextIds[this->unk_28A]; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80BE6B40(this, globalCtx); return; } @@ -245,7 +245,7 @@ void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { func_800B8614(&this->actor, globalCtx, 80.0f); if ((this->unk_276 == 8) && Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROCK_BROKEN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROCK_BROKEN); for (i = 0; i < 10; i++) { Math_Vec3f_Copy(&sp70, &this->actor.world.pos); @@ -304,7 +304,7 @@ void func_80BE6B40(EnDaiku2* this, GlobalContext* globalCtx) { void func_80BE6BC0(EnDaiku2* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0x0); - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { s32 day = gSaveContext.day - 1; func_801477B4(globalCtx); @@ -342,7 +342,7 @@ void func_80BE6D40(EnDaiku2* this, GlobalContext* globalCtx) { s32 pad[3]; s16 sp3A = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_268); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80BE6BC0; return; } @@ -376,7 +376,7 @@ void func_80BE6EF0(EnDaiku2* this, GlobalContext* globalCtx) { Vec3f sp40; s16 var; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80BE6BC0; return; } @@ -460,8 +460,8 @@ void EnDaiku2_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actionFunc(this, globalCtx); this->actor.shape.rot.y = this->actor.world.rot.y; - Actor_SetHeight(&this->actor, 65.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_SetFocus(&this->actor, 65.0f); + Actor_MoveWithGravity(&this->actor); Math_ApproachF(&this->unk_260, this->unk_264, 0.3f, 2.0f); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index 1ab2c9654b..e75bbade9a 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -131,7 +131,7 @@ void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx) { EnDekunuts* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 35.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &D_06002468, &D_0600326C, this->jointTable, this->morphTable, 10); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -165,7 +165,7 @@ void func_808BD348(EnDekunuts* this) { this->unk_210 = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_190 = 80; - func_800BCB70(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808BD3B4(EnDekunuts* this, GlobalContext* globalCtx) { @@ -173,7 +173,7 @@ void func_808BD3B4(EnDekunuts* this, GlobalContext* globalCtx) { this->unk_18E = 0; this->collider.base.colType = COLTYPE_HIT6; this->unk_210 = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->unk_21C, 8, 2, 0.2f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_21C, 8, 2, 0.2f, 0.2f); } } @@ -200,7 +200,7 @@ void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 9.0f)) { this->collider.base.acFlags |= AC_ON; } else if (Animation_OnFrame(&this->skelAnime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); } this->collider.dim.height = (s32)((CLAMP(this->skelAnime.curFrame, 9.0f, 12.0f) - 9.0f) * 9.0f) + 5; @@ -333,7 +333,7 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NUTSBALL, pos.x, pos.y, pos.z, this->actor.world.rot.x, this->actor.shape.rot.y, 0, params) != NULL) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_THROW); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_THROW); } } else if ((this->unk_190 >= 2) && Animation_OnFrame(&this->skelAnime, 12.0f)) { Animation_MorphToPlayOnce(&this->skelAnime, &D_06000168, -3.0f); @@ -346,7 +346,7 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { void func_808BDC9C(EnDekunuts* this) { Animation_MorphToPlayOnce(&this->skelAnime, &D_06002A5C, -5.0f); this->unk_190 = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->actionFunc = func_808BDD54; } @@ -354,7 +354,7 @@ void func_808BDCF0(EnDekunuts* this) { Animation_MorphToPlayOnce(&this->skelAnime, &D_06002A5C, -5.0f); this->collider.base.acFlags &= ~AC_ON; this->unk_190 = 80; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->actionFunc = func_808BDD54; } @@ -382,7 +382,7 @@ void func_808BDE7C(EnDekunuts* this) { Animation_MorphToPlayOnce(&this->skelAnime, &D_06002DD4, -3.0f); this->collider.dim.height = 37; this->actor.colChkInfo.mass = 50; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); this->actor.world.rot.x = 0; this->actor.flags |= 0x20; this->collider.base.acFlags &= ~AC_ON; @@ -418,7 +418,7 @@ void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx) { } if (this->unk_18C != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); this->unk_18C = 0; } else { this->unk_18C = 1; @@ -490,9 +490,9 @@ void func_808BE294(EnDekunuts* this, s32 arg1) { this->actor.world.rot.x = 0; this->collider.base.acFlags &= ~AC_ON; this->actionFunc = func_808BE358; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DAMAGE); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_CUTBODY); - func_800BCB70(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&D_0600259C)); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CUTBODY); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&D_0600259C)); } void func_808BE358(EnDekunuts* this, GlobalContext* globalCtx) { @@ -534,7 +534,7 @@ void func_808BE484(EnDekunuts* this) { Animation_PlayOnce(&this->skelAnime, &D_06002BD4); this->actionFunc = func_808BE4D4; this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); } void func_808BE4D4(EnDekunuts* this, GlobalContext* globalCtx) { @@ -547,8 +547,8 @@ void func_808BE4D4(EnDekunuts* this, GlobalContext* globalCtx) { 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, &D_801D15B0, &D_801D15B0, &D_808BEF90, &D_808BEF94, 200, 0, 13); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + EffectSsDeadDb_Spawn(globalCtx, &sp40, &gZeroVec3f, &gZeroVec3f, &D_808BEF90, &D_808BEF94, 200, 0, 13); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, 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); Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xE0); @@ -578,7 +578,7 @@ void func_808BE6C4(EnDekunuts* this, GlobalContext* globalCtx) { void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - func_800BE258(&this->actor, &this->collider.info); + Actor_SetDropFlag(&this->actor, &this->collider.info); if ((this->unk_18E != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { func_808BD3B4(this, globalCtx); if ((this->actor.colChkInfo.mass == 50) || (this->actor.params != ENDEKUNUTS_GET_FF00_0)) { @@ -603,8 +603,8 @@ void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 1) { this->unk_190 = 40; - func_800BCB70(&this->actor, 0, 255, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_808BE3A8(this); return; } @@ -651,7 +651,7 @@ void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { func_808BE73C(this, globalCtx); this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->collider.dim.radius, this->collider.dim.height, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); @@ -747,7 +747,7 @@ void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.colorFilterTimer != 0) { func_800AE5A0(globalCtx); } - func_800BDFC0(globalCtx, D_06001E50); + Gfx_DrawDListOpa(globalCtx, D_06001E50); func_800BE680(globalCtx, &this->actor, this->unk_21C, 8, this->unk_214, this->unk_218, this->unk_210, this->unk_18E); } diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 2c5a330ab7..907344cf5a 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -302,37 +302,37 @@ void func_80989864(EnDg* this, GlobalContext* globalCtx) { sp38.x = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.x; sp38.y = this->actor.world.pos.y; sp38.z = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.z; - func_800BBDAC(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 300, 0, 1); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 300, 0, 1); } } void func_80989974(EnDg* this) { if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 7.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_MONKEY_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); } } void func_809899C8(EnDg* this, f32 arg1) { if (Animation_OnFrame(&this->skelAnime, arg1)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_BARK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); } } void func_80989A08(EnDg* this, f32 arg1) { if (Animation_OnFrame(&this->skelAnime, arg1)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); } } void func_80989A48(EnDg* this) { if (Animation_OnFrame(&this->skelAnime, 23.0f) || Animation_OnFrame(&this->skelAnime, 28.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_WHINE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_WHINE); } } void func_80989A9C(EnDg* this, f32 arg1) { if (Animation_OnFrame(&this->skelAnime, arg1)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); } } @@ -402,7 +402,7 @@ void func_80989E18(EnDg* this, GlobalContext* globalCtx) { } if (Actor_HasParent(&this->actor, globalCtx)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_BARK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); this->unk_290 = 1; D_8098C2FC = D_8098C2A8[this->unk_286]; if (D_8098C2A0 == 0) { @@ -422,12 +422,12 @@ void func_80989E18(EnDg* this, GlobalContext* globalCtx) { this->actionFunc = func_8098BA64; } } else { - func_800B8BB0(&this->actor, globalCtx); + Actor_LiftActor(&this->actor, globalCtx); } } s32 func_80989FC8(GlobalContext* globalCtx) { - EnDg* enemy = (EnDg*)globalCtx->actorCtx.actorList[ACTORCAT_ENEMY].first; + EnDg* enemy = (EnDg*)globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; f32 minDist = 9999.0f; f32 dist; @@ -470,7 +470,7 @@ void func_8098A064(EnDg* this, GlobalContext* globalCtx) { } else if ((this->actionFunc == func_8098B004) || (this->actionFunc == func_8098AB48)) { if (DECR(this->unk_292) == 0) { this->unk_292 = 10; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_BARK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); } } } @@ -567,7 +567,7 @@ void func_8098A468(EnDg* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; func_80989674(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (player->transformation == PLAYER_FORM_HUMAN) { func_80989E18(this, globalCtx); } @@ -619,7 +619,7 @@ void func_8098A618(EnDg* this, GlobalContext* globalCtx) { } this->actor.world.rot.y = this->actor.shape.rot.y; Math_ApproachF(&this->actor.speedXZ, -1.5f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } func_80989974(this); @@ -655,12 +655,12 @@ void func_8098A70C(EnDg* this, GlobalContext* globalCtx) { this->actor.speedXZ = 7.0f; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80989974(this); if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_CRY); } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_MONKEY_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); } } @@ -707,7 +707,7 @@ void func_8098A938(EnDg* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 1.0f); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80989974(this); func_80989A08(this, 5.0f); } @@ -715,7 +715,7 @@ void func_8098A938(EnDg* this, GlobalContext* globalCtx) { void func_8098AAAC(EnDg* this, GlobalContext* globalCtx) { this->unk_280 &= ~8; Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.1f, 0.5f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (DECR(this->unk_28E) == 0) { this->unk_28E = 20; this->actionFunc = func_8098A938; @@ -790,7 +790,7 @@ void func_8098AC34(EnDg* this, GlobalContext* globalCtx) { if (sp26 >= 0x18) { func_80989864(this, globalCtx); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } func_80989A9C(this, 10.0f); @@ -808,7 +808,7 @@ void func_8098AE58(EnDg* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00); this->actor.world.rot.y = this->actor.shape.rot.y; Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } func_80989974(this); @@ -818,7 +818,7 @@ void func_8098AE58(EnDg* this, GlobalContext* globalCtx) { void func_8098AF44(EnDg* this, GlobalContext* globalCtx) { if (func_801A46F8() == 1) { this->unk_292 = 10; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_BARK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); this->actionFunc = func_8098B004; } } @@ -829,7 +829,7 @@ void func_8098AF98(EnDg* this, GlobalContext* globalCtx) { this->actionFunc = func_8098A468; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_809899C8(this, 3.0f); } @@ -859,7 +859,7 @@ void func_8098B004(EnDg* this, GlobalContext* globalCtx) { } func_8098A064(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80989974(this); if (!(this->unk_280 & 0x20)) { func_809899C8(this, 3.0f); @@ -881,7 +881,7 @@ void func_8098B198(EnDg* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; Math_ApproachF(&this->actor.speedXZ, -1.0f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80989974(this); func_80989A9C(this, 4.0f); } @@ -901,11 +901,11 @@ void func_8098B28C(EnDg* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; Math_ApproachF(&this->actor.speedXZ, -2.0f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } func_80989974(this); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); } void func_8098B390(EnDg* this, GlobalContext* globalCtx) { @@ -936,12 +936,12 @@ void func_8098B464(EnDg* this, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; this->actor.velocity.y = -3.0f; this->unk_284 = 10; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMB_DROP_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); this->actionFunc = func_8098B560; } Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_8098B560(EnDg* this, GlobalContext* globalCtx) { @@ -963,7 +963,7 @@ void func_8098B560(EnDg* this, GlobalContext* globalCtx) { if (DECR(this->unk_284) == 0) { if (!(this->unk_280 & 4)) { this->unk_280 |= 4; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_OUT_OF_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); } this->unk_284 = 5; EffectSsGRipple_Spawn(globalCtx, &sp54, 100, 500, 30); @@ -999,7 +999,7 @@ void func_8098B560(EnDg* this, GlobalContext* globalCtx) { this->unk_280 &= ~4; this->unk_28C = 8; this->unk_282 = Rand_S16Offset(60, 60); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_OUT_OF_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); func_80989140(&this->skelAnime, sAnimations, 2); Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); this->actionFunc = func_8098A468; @@ -1008,7 +1008,7 @@ void func_8098B560(EnDg* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, sp46, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_8098B88C(EnDg* this, GlobalContext* globalCtx) { @@ -1040,7 +1040,7 @@ void func_8098B88C(EnDg* this, GlobalContext* globalCtx) { this->actor.velocity.y = 10.0f; this->actor.gravity = -3.0f; this->unk_282 = Rand_S16Offset(60, 60); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_OUT_OF_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); func_80989140(&this->skelAnime, sAnimations, 2); this->actionFunc = func_8098A468; Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); @@ -1048,7 +1048,7 @@ void func_8098B88C(EnDg* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_8098BA64(EnDg* this, GlobalContext* globalCtx) { @@ -1063,7 +1063,7 @@ void func_8098BA64(EnDg* this, GlobalContext* globalCtx) { this->unk_288 = -1; D_8098C2FC.unk_02 = this->unk_288; this->unk_28A = 100; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); this->unk_280 |= 0x10; this->actionFunc = func_8098BB10; } @@ -1075,7 +1075,7 @@ void func_8098BB10(EnDg* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { if (this->unk_280 & 0x10) { this->unk_280 &= ~0x10; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_MONKEY_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); } this->actor.speedXZ = 0.0f; @@ -1091,11 +1091,11 @@ void func_8098BB10(EnDg* this, GlobalContext* globalCtx) { this->actionFunc = func_8098A468; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_8098BBEC(EnDg* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; func_80989D38(this, globalCtx); this->actionFunc = func_8098BC54; @@ -1105,7 +1105,7 @@ void func_8098BBEC(EnDg* this, GlobalContext* globalCtx) { } void func_8098BC54(EnDg* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 2) { + if (Message_GetState(&globalCtx->msgCtx) == 2) { func_80989140(&this->skelAnime, sAnimations, 0); this->actionFunc = func_8098BA64; } @@ -1115,7 +1115,7 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { EnDg* this = THIS; s32 pad; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060080F0, NULL, this->jointTable, this->morphTable, 13); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index bf0f977b74..7c7b2811cb 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -278,7 +278,7 @@ static InitChainEntry sInitChain[] = { void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx) { static s32 D_8089E364 = 0; - static EffBlureInit2 D_8089E368 = { + static EffectBlureInit2 D_8089E368 = { 0, 8, 0, { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, { 255, 255, 255, 0 }, { 255, 255, 255, 0 }, 8, 0, 2, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, }; @@ -287,8 +287,8 @@ void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx) { ColliderJntSphElementDim* dim; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B42F8, 90.0f); - Effect_Add(globalCtx, &this->unk_2A0, 2, 0, 0, &D_8089E368); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFeet, 90.0f); + Effect_Add(globalCtx, &this->unk_2A0, EFFECT_BLURE2, 0, 0, &D_8089E368); Collider_InitAndSetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphElement); Collider_InitAndSetQuad(globalCtx, &this->colliderQuad, &this->actor, &sQuadInit); @@ -353,7 +353,7 @@ s32 func_8089A968(EnDinofos* this) { void func_8089A9B0(EnDinofos* this, GlobalContext* globalCtx) { if (func_8089A968(this)) { if (this->actor.xzDistToPlayer < 100.0f) { - if (!func_800BC5EC(globalCtx, &this->actor) && + if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && (((this->actionFunc != func_8089C56C) && (Rand_ZeroOne() > 0.35f)) || ((this->actionFunc == func_8089C56C) && (Rand_ZeroOne() > 0.8f)))) { func_8089C4F8(this); @@ -400,7 +400,7 @@ void func_8089AC70(EnDinofos* this) { this->unk_2B0 = 1.0f; this->unk_290 = 80; this->actor.flags &= ~0x400; - func_800BCB70(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_8089ACEC(EnDinofos* this, GlobalContext* globalCtx) { @@ -408,7 +408,7 @@ void func_8089ACEC(EnDinofos* this, GlobalContext* globalCtx) { this->unk_28A = 0; this->colliderJntSph.base.colType = COLTYPE_HIT0; this->unk_2B0 = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->unk_2D4, 12, 2, 0.3f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D4, 12, 2, 0.3f, 0.2f); this->actor.flags |= 0x400; } } @@ -436,7 +436,7 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { temp_v1 = (Actor_YawBetweenActors(&this->actor, temp_v0) - this->actor.shape.rot.y) - this->unk_28E; if (ABS_ALT(temp_v1) < 0x3000) { func_8089D11C(this, temp_v1 + this->unk_28E); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WARAU); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WARAU); return true; } } @@ -446,7 +446,7 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { temp_v1_2 = (Actor_YawBetweenActors(&this->actor, temp_v0) - this->actor.shape.rot.y) - this->unk_28E; if (ABS_ALT(temp_v1_2) < 0x3000) { func_8089C024(this, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WARAU); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WARAU); return true; } } @@ -457,13 +457,13 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { } if ((this->actor.xzDistToPlayer < 100.0f) && (player->swordState != 0) && this->actor.isTargeted && - (Rand_ZeroOne() < 0.5f) && func_8089A968(this) && Actor_IsLinkFacingActor(&this->actor, 0x2000, globalCtx)) { + (Rand_ZeroOne() < 0.5f) && func_8089A968(this) && Player_IsFacingActor(&this->actor, 0x2000, globalCtx)) { if (Rand_ZeroOne() < 0.5f) { func_8089C024(this, 2); } else { func_8089C024(this, 3); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WARAU); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WARAU); return true; } @@ -485,7 +485,7 @@ void func_8089B100(EnDinofos* this, GlobalContext* globalCtx) { Animation_Change(&this->skelAnime, &D_06001CCC, 1.0f, Animation_GetLastFrame(&D_06001CCC), Animation_GetLastFrame(&D_06001CCC), 2, 0.0f); - func_800BE33C(&camera->eye, &camera->at, &this->unk_29A, 1); + func_800BE33C(&camera->eye, &camera->at, &this->unk_29A, true); Math_Vec3f_Diff(&this->actor.world.pos, &player->actor.world.pos, &sp3C); this->unk_2BC.x = player->actor.world.pos.x + (0.4f * sp3C.x); this->unk_2BC.y = player->actor.world.pos.y + 5.0f; @@ -513,7 +513,7 @@ void func_8089B288(EnDinofos* this, GlobalContext* globalCtx) { void func_8089B320(EnDinofos* this) { this->actor.gravity = -2.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_CRY); this->unk_2BC.x = (Math_SinS(this->actor.shape.rot.y - 0x0E00) * 86.0f) + this->actor.world.pos.x; this->unk_2BC.y = this->actor.floorHeight + 6.0f; this->unk_2BC.z = (Math_CosS(this->actor.shape.rot.y - 0x0E00) * 86.0f) + this->actor.world.pos.z; @@ -553,7 +553,7 @@ void func_8089B4A4(EnDinofos* this) { this->unk_2BC.x = (Math_SinS(this->actor.shape.rot.y + 0x200) * 123.0f) + this->actor.world.pos.x; this->unk_2BC.y = this->actor.floorHeight + 11.0f; this->unk_2BC.z = (Math_CosS(this->actor.shape.rot.y + 0x200) * 123.0f) + this->actor.world.pos.z; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BOMCHU_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_WALK); this->unk_290 = 0; this->unk_292 = -1; this->actionFunc = func_8089B580; @@ -595,7 +595,7 @@ void func_8089B6E8(EnDinofos* this) { void func_8089B72C(EnDinofos* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 2.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_ATTACK); } if (SkelAnime_Update(&this->skelAnime)) { @@ -636,7 +636,7 @@ void func_8089B8B0(EnDinofos* this, GlobalContext* globalCtx) { if (this->actionFunc != func_8089B98C) { Animation_MorphToLoop(&this->skelAnime, &D_06000580, -4.0f); - if (func_800BC5EC(globalCtx, &this->actor)) { + if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { phi_f0 = 170.0f; } else { phi_f0 = 70.0f; @@ -658,7 +658,7 @@ void func_8089B98C(EnDinofos* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (!func_8089AE00(this, globalCtx)) { - if (func_800BC5EC(globalCtx, &this->actor)) { + if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { phi_f0 = 170.0f; } else { phi_f0 = 70.0f; @@ -683,7 +683,7 @@ void func_8089B98C(EnDinofos* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } } } @@ -782,7 +782,7 @@ void func_8089BD28(EnDinofos* this, GlobalContext* globalCtx) { } this->actor.world.rot.y = BINANG_ADD(this->actor.shape.rot.y, 0x4000); - if (func_800BC5EC(globalCtx, &this->actor)) { + if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { sp2C = 100.0f; } @@ -804,7 +804,7 @@ void func_8089BD28(EnDinofos* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } } } @@ -853,7 +853,7 @@ void func_8089C164(EnDinofos* this) { } this->actor.bgCheckFlags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_JUMP); this->actionFunc = func_8089C1F8; } @@ -868,7 +868,7 @@ void func_8089C244(EnDinofos* this) { this->actor.bgCheckFlags &= ~1; this->actor.speedXZ = 8.0f; this->actor.velocity.y = 16.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_JUMP); this->unk_290 = 0; this->unk_292 = -1; this->actionFunc = func_8089C2A8; @@ -905,7 +905,7 @@ void func_8089C398(EnDinofos* this) { this->actor.speedXZ = 0.0f; func_8089AD70(this); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BOMCHU_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_WALK); this->actionFunc = func_8089C44C; } @@ -923,7 +923,7 @@ void func_8089C44C(EnDinofos* this, GlobalContext* globalCtx) { void func_8089C4F8(EnDinofos* this) { Animation_PlayOnce(&this->skelAnime, &D_060025B4); this->colliderQuad.base.atFlags &= ~AT_BOUNCED; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_CRY); this->unk_290 = 0; this->unk_292 = -1; this->actor.speedXZ = 0.0f; @@ -936,7 +936,7 @@ void func_8089C56C(EnDinofos* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x800); this->actor.world.rot.y = this->actor.shape.rot.y; if (SkelAnime_Update(&this->skelAnime)) { - func_800A8514(Effect_GetParams(this->unk_2A0)); + EffectBlure_AddSpace(Effect_GetByIndex(this->unk_2A0)); this->colliderQuad.base.atFlags &= ~AT_ON; func_8089A9B0(this, globalCtx); } else if (Animation_OnFrame(&this->skelAnime, 7.0f)) { @@ -945,7 +945,7 @@ void func_8089C56C(EnDinofos* this, GlobalContext* globalCtx) { } else if (Animation_OnFrame(&this->skelAnime, 13.0f)) { this->colliderQuad.base.atFlags &= ~AT_ON; } else if (Animation_OnFrame(&this->skelAnime, 11.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_ATTACK); } else if (this->skelAnime.curFrame < 7.0f) { func_8089AE00(this, globalCtx); } @@ -1010,9 +1010,9 @@ void func_8089C87C(EnDinofos* this, s32 arg1) { this->actor.velocity.y = 0.0f; } this->unk_28E = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_DAMAGE); this->colliderJntSph.base.acFlags &= ~AC_ON; - func_800BCB70(&this->actor, 0x4000, 255, 0, 18); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 18); this->actionFunc = func_8089C938; } @@ -1145,7 +1145,7 @@ void func_8089CF70(EnDinofos* this, GlobalContext* globalCtx) { void func_8089CFAC(EnDinofos* this) { Animation_PlayOnce(&this->skelAnime, &D_0600ABD0); this->actor.flags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_DEAD); this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_8089D018; @@ -1173,7 +1173,7 @@ void func_8089D018(EnDinofos* this, GlobalContext* globalCtx) { this->actor.shape.shadowAlpha = this->unk_288; } else if (Animation_OnFrame(&this->skelAnime, 26.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } } @@ -1206,7 +1206,7 @@ void func_8089D1E0(EnDinofos* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } } @@ -1263,7 +1263,7 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { if (this->colliderJntSph.base.acFlags & AC_HIT) { this->colliderJntSph.base.acFlags &= ~AC_HIT; - func_800BE2B8(&this->actor, &this->colliderJntSph); + Actor_SetDropFlagJntSph(&this->actor, &this->colliderJntSph); for (i = 0; i < ARRAY_COUNT(this->colliderJntSphElement); i++) { if (this->colliderJntSph.elements[i].info.bumperFlags & BUMP_HIT) { @@ -1317,19 +1317,19 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 1) { this->unk_290 = 40; - func_800BCB70(&this->actor, 0, 255, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_8089C784(this); return true; } if (this->actor.colChkInfo.damageEffect == 5) { this->unk_290 = 40; - func_800BCB70(&this->actor, 0, 255, 0, 40); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); this->unk_2B4 = 0.55f; this->unk_2B0 = 2.0f; this->unk_28A = 31; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_8089C784(this); return true; } @@ -1369,7 +1369,7 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { } this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 30.0f, 60.0f, 0x5D); if (this->actionFunc != func_8089C7B8) { if ((this->actor.depthInWater > 0.0f) && (this->actor.depthInWater < 10.0f)) { @@ -1454,7 +1454,7 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Matrix_MultiplyVector3fByState(&D_8089E398, &sp5C); Collider_SetQuadVertices(&this->colliderQuad, &sp5C, &sp68, &sp74, &sp80); if (this->colliderQuad.base.atFlags & AT_ON) { - func_800A81F0(Effect_GetParams(this->unk_2A0), &sp68, &sp5C); + EffectBlure_AddVertex(Effect_GetByIndex(this->unk_2A0), &sp68, &sp5C); } this->unk_292 = this->unk_290; } @@ -1475,7 +1475,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, &D_801D15B0, 30, 22, 255 - (sp58 * 20), 20, 3, 8); + EffectSsDFire_Spawn(globalCtx, &this->unk_34C, &sp4C, &gZeroVec3f, 30, 22, 255 - (sp58 * 20), 20, 3, 8); this->unk_292 = this->unk_290; } } 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 be0f95eb93..7e4b67b7c3 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -47,7 +47,7 @@ void func_80A4FDD0(EnDnbParticle* particle, EnDnb* this, s16* alloc, s32 idx) { particle->unk_00 = sp1C; particle->unk_0C = sp1C; particle->unk_24 = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &sp1C); - particle->unk_18 = D_801D15BC; + particle->unk_18 = gZeroVec3s; } s32 func_80A4FEBC(EnDnbParticle* particle, f32 arg1) { @@ -76,7 +76,7 @@ void func_80A4FFE8(EnDnbParticle* particle, s16 arg1) { particle->unk_1E.x = (Rand_ZeroOne() - 0.5f) * 400.0f; particle->unk_1E.y = (Rand_ZeroOne() - 0.5f) * 400.0f; particle->unk_1E.z = (Rand_ZeroOne() - 0.5f) * 400.0f; - particle->unk_18 = D_801D15BC; + particle->unk_18 = gZeroVec3s; particle->unk_30 = 40.0f; particle->unk_2C = 0.0f; particle->unk_26 = arg1; @@ -86,7 +86,7 @@ void func_80A4FFE8(EnDnbParticle* particle, s16 arg1) { s32 func_80A500F8(EnDnb* this) { static Vec3f D_80A50CB0 = { 0.0f, 0.0f, 1000.0f }; Actor* actor = &this->dyna.actor; - Vec3f spA8 = D_801D15B0; + Vec3f spA8 = gZeroVec3f; Vec3f sp9C; s32 i; f32 temp_f20; 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 7fd5c84b8f..2dcf85e3d0 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -265,7 +265,7 @@ void EnDnk_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); SkelAnime_Update(&this->skelAnime); func_80A515C4(this); - Actor_SetHeight(&this->actor, 34.0f); + Actor_SetFocus(&this->actor, 34.0f); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); @@ -283,7 +283,7 @@ s32 func_80A51A78(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnDnk* this = THIS; MtxF sp5C; - Vec3f sp50 = D_801D15B0; + Vec3f sp50 = gZeroVec3f; Vec3f sp44; Vec3s sp3C; @@ -359,7 +359,7 @@ s32 func_80A51D78(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p void func_80A51DA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnDnk* this = THIS; MtxF sp5C; - Vec3f sp50 = D_801D15B0; + Vec3f sp50 = gZeroVec3f; Vec3f sp44; Vec3s sp3C; @@ -436,11 +436,11 @@ void func_80A52074(EnDnk* this, GlobalContext* globalCtx) { break; case 438: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKNUTS_DANCE_BIG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKNUTS_DANCE_BIG); break; case 493: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); break; } diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index 5a6b883685..2a352380cf 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -6,6 +6,7 @@ #include "z_en_dno.h" #include "overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000039 @@ -134,10 +135,10 @@ void func_80A714B4(EnDno* this, GlobalContext* globalCtx) { Actor* actor = NULL; do { - actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (actor != NULL) { - if ((s32)ENDNO_GET_F(actor) == ENDNO_GET_F_1) { - Actor_SetSwitchFlag(globalCtx, ENDNO_GET_7F0(actor)); + if (ENDNO_GET_F(actor) == ENDNO_GET_F_1) { + Flags_SetSwitch(globalCtx, ENDNO_GET_7F0(actor)); } actor = actor->next; } @@ -164,8 +165,7 @@ void func_80A715DC(EnDno* this, GlobalContext* globalCtx) { Vec3f sp70; do { - crace = - (BgCraceMovebg*)func_ActorCategoryIterateById(globalCtx, &crace->actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); + crace = (BgCraceMovebg*)SubS_FindActor(globalCtx, &crace->actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (crace != NULL) { if (ENDNO_GET_F(&crace->actor) == ENDNO_GET_F_0 && !(crace->unk_170 & 1)) { if (func_8013E5CC(&crace->actor.home.pos, &crace->actor.home.rot, &D_80A73B2C, &this->actor.prevPos, @@ -187,9 +187,9 @@ void func_80A71788(EnDno* this, GlobalContext* globalCtx) { Actor* actor = NULL; do { - actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (actor != NULL) { - Actor_UnsetSwitchFlag(globalCtx, ENDNO_GET_7F0(actor)); + Flags_UnsetSwitch(globalCtx, ENDNO_GET_7F0(actor)); actor = actor->next; } } while (actor != NULL); @@ -201,7 +201,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { Actor* actor = NULL; while (true) { - actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_DNO); + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_DNO); if (actor != NULL) { if (actor != thisx) { Actor_MarkForDeath(thisx); @@ -212,7 +212,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { if (actor == NULL) { Actor_ProcessInitChain(thisx, sInitChain); - ActorShape_Init(&thisx->shape, 0.0f, func_800B3FC0, 21.0f); + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 21.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600E1F8, &D_06007CA4, this->jointTable, this->morphTable, 28); Collider_InitCylinder(globalCtx, &this->collider); @@ -248,7 +248,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(thisx); } else { func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); - this->unk_460 = func_ActorCategoryIterateById(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_DNQ); + this->unk_460 = SubS_FindActor(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_DNQ); if (this->unk_460 == NULL) { Actor_MarkForDeath(thisx); } else { @@ -339,7 +339,7 @@ void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x222); } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.unk11F22 = 0; globalCtx->msgCtx.unk11F10 = 0; func_80A71E54(this, globalCtx); @@ -374,7 +374,7 @@ void func_80A71E54(EnDno* this, GlobalContext* globalCtx) { void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->unk_466, 0, 0x16C); - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: if (!(this->unk_3B0 & 0x10) || Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xE38)) { @@ -528,7 +528,7 @@ void func_80A724B8(EnDno* this, GlobalContext* globalCtx) { func_80A71424(&this->unk_466, 0, this->actor.yawTowardsPlayer, this->actor.home.rot.y, 0x2000, 0x2D8); } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80A725E0(this, globalCtx); } else if (this->actor.xzDistToPlayer < 60.0f) { func_800B8614(&this->actor, globalCtx, 60.0f); @@ -536,11 +536,11 @@ void func_80A724B8(EnDno* this, GlobalContext* globalCtx) { } void func_80A7256C(EnDno* this, GlobalContext* globalCtx) { - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, -1); + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, EXCH_ITEM_MINUS1); } void func_80A72598(EnDno* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80A725E0(this, globalCtx); } else { func_80A7256C(this, globalCtx); @@ -555,7 +555,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { s32 pad[2]; func_80A71424(&this->unk_466, 0, 0, 0, 0x2000, 0x16C); - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: switch (this->unk_328) { case 0: @@ -597,7 +597,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame <= 23.0f) { this->unk_452 = 3; if (Animation_OnFrame(&this->skelAnime, 23.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_OPEN_AMBRELLA); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OPEN_AMBRELLA); } } else if (this->skelAnime.curFrame <= 24.0f) { this->unk_452 = 4; @@ -633,7 +633,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { } else { this->unk_458 = GI_MASK_SCENTS; } - func_800B8A1C(&this->actor, globalCtx, this->unk_458, 60.0f, 60.0f); + Actor_PickUp(&this->actor, globalCtx, this->unk_458, 60.0f, 60.0f); func_801477B4(globalCtx); func_80A72B84(this, globalCtx); } @@ -697,7 +697,7 @@ void func_80A72BA4(EnDno* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = func_80A72598; } else { - func_800B8A1C(&this->actor, globalCtx, this->unk_458, 60.0f, 60.0f); + Actor_PickUp(&this->actor, globalCtx, this->unk_458, 60.0f, 60.0f); } } @@ -709,9 +709,11 @@ void func_80A72C04(EnDno* this, GlobalContext* globalCtx) { func_8013DCE0(globalCtx, &this->unk_334, &this->actor, &this->unk_340, globalCtx->setupPathList, ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); func_8013DF3C(globalCtx, &this->unk_340); + this->actor.world.rot.y = this->unk_340.unk_54.y; this->actor.world.rot.x = this->unk_340.unk_54.x; - Actor_SetSwitchFlag(globalCtx, ENDNO_GET_3F80(&this->actor)); + + Flags_SetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor)); this->actionFunc = func_80A730A0; } @@ -831,7 +833,7 @@ void func_80A73244(EnDno* this, GlobalContext* globalCtx) { this->actor.flags |= (8 | 1); this->unk_328 = 2; this->actor.speedXZ = 0.0f; - Actor_UnsetSwitchFlag(globalCtx, ENDNO_GET_3F80(&this->actor)); + Flags_UnsetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor)); gSaveContext.unk_3DD0[1] = 5; this->unk_44E = 0; this->actionFunc = func_80A732C8; @@ -856,14 +858,14 @@ void func_80A732C8(EnDno* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 4.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CLOSE_AMBRELLA); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOSE_AMBRELLA); this->unk_452 = 4; } else if (Animation_OnFrame(&this->skelAnime, 5.0f)) { this->unk_452 = 3; } } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80A73408(EnDno* this, GlobalContext* globalCtx) { @@ -914,7 +916,7 @@ void EnDno_Update(Actor* thisx, GlobalContext* globalCtx) { } Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_SetHeight(&this->actor, 51.0f); + Actor_SetFocus(&this->actor, 51.0f); } void EnDno_Draw(Actor* thisx, GlobalContext* globalCtx) { @@ -1015,7 +1017,7 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, -frames * 20, 0x20, 0x80)); gDPSetPrimColor(&gfxXlu[2], 0x80, 0x80, 255, 255, 0, 255); gDPSetEnvColor(&gfxXlu[3], 255, 0, 0, 0); - gSPDisplayList(&gfxXlu[4], D_0407D590); + gSPDisplayList(&gfxXlu[4], gGameplayKeepDrawFlameDL); POLY_XLU_DISP = gfxXlu + 5; 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 8e0bbbaab2..98884c1149 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -104,37 +104,37 @@ s32 func_80B3CA20(EnDnp* this) { if ((this->unk_340 == 2) || (this->unk_340 == 9)) { if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_TURN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_TURN); } } else if ((this->unk_340 == 24) || (this->unk_340 == 7)) { if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_TURN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_TURN); } } else if (this->unk_340 == 14) { if (Animation_OnFrame(&this->skelAnime, 7.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_GREET); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET); } if (Animation_OnFrame(&this->skelAnime, 22.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_GREET2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET2); } } else if (this->unk_340 == 8) { if (Animation_OnFrame(&this->skelAnime, 9.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_GREET); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET); } if (Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_GREET2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET2); } } else if ((this->unk_340 == 17) && (this->unk_340 == 18)) { if (Animation_OnFrame(&this->skelAnime, 7.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_WALK); } } else if (this->unk_340 == 21) { if (Animation_OnFrame(&this->skelAnime, 17.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_WALK); } } else if (this->unk_340 == 23) { if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_WALK); } } @@ -212,7 +212,7 @@ s32 func_80B3CEC0(EnDnp* this, GlobalContext* globalCtx) { s32 func_80B3CF60(EnDnp* this, GlobalContext* globalCtx) { s32 ret = false; - if ((this->unk_322 & 7) && func_800B84D0(&this->actor, globalCtx)) { + if ((this->unk_322 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_8013AED4(&this->unk_322, 0, 7); this->unk_322 |= 8; this->actionFunc = func_80B3D3F8; @@ -276,7 +276,7 @@ void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx) { } if (this->unk_340 == 19) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_DHVO04); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_DHVO04); } if (this->unk_340 == 24) { @@ -307,15 +307,15 @@ void func_80B3D2D4(EnDnp* this, GlobalContext* globalCtx) { void func_80B3D338(EnDnp* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((this->unk_32E != 0) && (func_80152498(&globalCtx->msgCtx) == 2)) { + if ((this->unk_32E != 0) && (Message_GetState(&globalCtx->msgCtx) == 2)) { Actor_MarkForDeath(&this->actor); } else if (this->unk_32E == 0) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_32E = 1; } else { this->actor.textId = 0x971; player->actor.textId = this->actor.textId; - func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, -1); + func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, EXCH_ITEM_MINUS1); } } } @@ -357,7 +357,7 @@ void func_80B3D558(EnDnp* this, GlobalContext* globalCtx) { void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx) { EnDnp* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 16.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 16.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06010D60, NULL, this->jointTable, this->morphTable, 26); this->unk_340 = -1; func_80B3CC38(this, 15); @@ -413,15 +413,15 @@ void EnDnp_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); func_80B3CD1C(this); func_80B3CEC0(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); sp2C = this->collider.dim.radius + 50; sp28 = this->collider.dim.height + 30; if ((this->unk_322 & 0x400) && !(gSaveContext.weekEventReg[23] & 0x20)) { - func_800B8A1C(&this->actor, globalCtx, GI_MAX, sp2C, sp28); + Actor_PickUp(&this->actor, globalCtx, GI_MAX, sp2C, sp28); } func_8013C964(&this->actor, globalCtx, sp2C, sp28, 0, this->unk_322 & 7); - Actor_SetHeight(&this->actor, 30.0f); + Actor_SetFocus(&this->actor, 30.0f); func_80B3CC80(this, globalCtx); } @@ -435,7 +435,7 @@ s32 func_80B3D974(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp6C; MtxF sp2C; - Matrix_MultiplyVector3fByState(&D_801D15B0, &sp74); + Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp74); Matrix_CopyCurrentState(&sp2C); func_8018219C(&sp2C, &sp6C, 0); *arg2 = sp74; diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c index a52d7fa110..f1e500e0fb 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -324,7 +324,7 @@ s32* func_80A52CF8(EnDnq* this, GlobalContext* globalCtx) { s32 func_80A52D44(EnDnq* this, GlobalContext* globalCtx) { s32 ret = false; - if ((this->unk_37C & 7) && func_800B84D0(&this->actor, globalCtx)) { + if ((this->unk_37C & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_8013AED4(&this->unk_37C, 0, 7); this->unk_380 = func_80A52CF8(this, globalCtx); this->actionFunc = func_80A52FB8; @@ -347,7 +347,7 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { if (!(gSaveContext.weekEventReg[23] & 0x20)) { this->unk_390 = 70.0f; if (func_80114F2C(ITEM_DEKU_PRINCESS) && !func_801690CC(globalCtx) && - (func_80152498(&globalCtx->msgCtx) == 0) && (ActorCutscene_GetCurrentIndex() == -1)) { + (Message_GetState(&globalCtx->msgCtx) == 0) && (ActorCutscene_GetCurrentIndex() == -1)) { if ((DECR(this->unk_384) == 0) && (gSaveContext.weekEventReg[29] & 0x40)) { func_801518B0(globalCtx, 0x969, NULL); this->unk_384 = 200; @@ -404,7 +404,7 @@ void func_80A53038(EnDnq* this, GlobalContext* globalCtx) { } if ((this->unk_398 == 4) && Animation_OnFrame(&this->skelAnime, 2.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KINGNUTS_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KINGNUTS_DAMAGE); } if (((this->unk_398 == 3) || (this->unk_398 == 6)) && @@ -461,7 +461,7 @@ void EnDnq_Update(Actor* thisx, GlobalContext* globalCtx) { func_8013C964(&this->actor, globalCtx, this->unk_390, fabsf(this->actor.playerHeightRel) + 1.0f, 0, this->unk_37C & 7); this->actor.xzDistToPlayer = this->unk_394; - Actor_SetHeight(&this->actor, 46.0f); + Actor_SetFocus(&this->actor, 46.0f); func_80A52604(this, globalCtx); } } diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index e75f1aa461..b6e75ef3ce 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -85,7 +85,7 @@ void func_8092C5C0(EnDns* this) { if (((this->unk_2F8 == 2) || (this->unk_2F8 == 3) || (this->unk_2F8 == 6) || (this->unk_2F8 == 7)) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 3.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); } } @@ -220,7 +220,7 @@ s32 func_8092CAD0(EnDns* this, GlobalContext* globalCtx) { s32 ret = false; if (this->unk_2C6 & 7) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_8013AED4(&this->unk_2C6, 0, 7); this->unk_2C6 &= ~0x10; if (ENDNS_GET_4000(&this->actor)) { @@ -284,15 +284,15 @@ s32 func_8092CCEC(EnDns* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp30, &this->actor.world.pos); Math_Vec3f_Copy(&sp3C, &player->actor.world.pos); - this->unk_2D6 = Math_Vec3f_Yaw(&D_801D15B0, &sp3C); - this->unk_2D4 = Math_Vec3f_Yaw(&D_801D15B0, &sp30); - this->unk_2EC = Math_Vec3f_DistXZ(&sp30, &D_801D15B0); - sp2E = Math_Vec3f_Yaw(&D_801D15B0, &sp3C); - sp2E -= Math_Vec3f_Yaw(&D_801D15B0, &sp30); + this->unk_2D6 = Math_Vec3f_Yaw(&gZeroVec3f, &sp3C); + this->unk_2D4 = Math_Vec3f_Yaw(&gZeroVec3f, &sp30); + this->unk_2EC = Math_Vec3f_DistXZ(&sp30, &gZeroVec3f); + sp2E = Math_Vec3f_Yaw(&gZeroVec3f, &sp3C); + sp2E -= Math_Vec3f_Yaw(&gZeroVec3f, &sp30); this->unk_2D8 = (Rand_ZeroOne() * 182.0f) + 182.0f; this->unk_2D8 = (sp2E > 0) ? this->unk_2D8 : -this->unk_2D8; this->unk_2D0 = 0x28; - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; return 1; } @@ -308,7 +308,7 @@ s32 func_8092CE38(EnDns* this) { this->unk_2C6 &= ~0x200; this->skelAnime.curFrame = 0.0f; if (this->unk_2D2 == 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_JUMP); } this->unk_2D2++; if (this->unk_2D2 >= 3) { @@ -321,7 +321,7 @@ s32 func_8092CE38(EnDns* this) { this->actor.world.rot.y = BINANG_ROT180(this->actor.world.rot.y); this->unk_2E4 = 0.0f; this->actor.shape.rot.y = this->actor.world.rot.y; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_JUMP); } else if (this->skelAnime.curFrame < 13.0f) { frame = this->skelAnime.curFrame; this->actor.shape.rot.y = this->actor.world.rot.y; @@ -332,7 +332,7 @@ s32 func_8092CE38(EnDns* this) { } else { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); } if (this->skelAnime.curFrame > 7.0f) { @@ -413,7 +413,7 @@ void EnDns_DoNothing(EnDns* this, GlobalContext* globalCtx) { void func_8092D330(EnDns* this, GlobalContext* globalCtx) { s32 pad; - Vec3f sp30 = D_801D15B0; + Vec3f sp30 = gZeroVec3f; s16 temp = this->unk_2D6 - this->unk_2D4; if (ABS_ALT(temp) < 0xC16) { @@ -426,7 +426,7 @@ void func_8092D330(EnDns* this, GlobalContext* globalCtx) { sp30.x = Math_SinS(this->unk_2D4) * this->unk_2EC; sp30.z = Math_CosS(this->unk_2D4) * this->unk_2EC; Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp30), 3, 0x2AA8); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } if ((this->unk_2C6 & 0x100) && (DECR(this->unk_2D0) == 0)) { this->unk_2C6 &= ~0x100; @@ -538,7 +538,7 @@ void EnDns_Update(Actor* thisx, GlobalContext* globalCtx) { func_8092C86C(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); func_8013C964(&this->actor, globalCtx, 80.0f, 40.0f, 0, this->unk_2C6 & 7); - Actor_SetHeight(&this->actor, 34.0f); + Actor_SetFocus(&this->actor, 34.0f); func_8092C6FC(this, globalCtx); func_8092C5C0(this); } @@ -549,7 +549,7 @@ s32 func_8092D954(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp6C; MtxF sp2C; - Matrix_MultiplyVector3fByState(&D_801D15B0, &sp74); + Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp74); Matrix_CopyCurrentState(&sp2C); func_8018219C(&sp2C, &sp6C, 0); *arg2 = sp74; 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 693ea4ec4f..bf7955ec7b 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -288,7 +288,7 @@ static InitChainEntry sInitChain[] = { }; void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { - static EffBlureInit2 D_80879308 = { + static EffectBlureInit2 D_80879308 = { 2, 8, 0, { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, { 255, 255, 255, 0 }, { 255, 255, 255, 0 }, 8, 0, 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, }; @@ -303,7 +303,7 @@ void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_330.g = 10; this->unk_330.a = 200; Math_Vec3f_Copy(&this->unk_314, &D_801C5DB0); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 48.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 48.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &D_06008318, &D_06004C20, this->jointTable, this->morphTable, 31); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Collider_InitAndSetJntSph(globalCtx, &this->collider2, &this->actor, &sJntSphInit2, this->collider2Elements); @@ -315,7 +315,7 @@ void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider2.elements[i].info.bumper.dmgFlags = 0x77C34FE6; } - Effect_Add(globalCtx, &this->unk_338, 2, 0, 0, &D_80879308); + Effect_Add(globalCtx, &this->unk_338, EFFECT_BLURE2, 0, 0, &D_80879308); if (this->actor.params == 0) { Actor_SetScale(&this->actor, 3.0f / 160.0f); this->unk_334 = 1.0f; @@ -384,7 +384,7 @@ void func_80876930(EnDodongo* this, GlobalContext* globalCtx, Vec3f* arg2) { sp88.z = randPlusMinusPoint5Scaled(temp3) + arg2->z; D_8087933C.x = randPlusMinusPoint5Scaled(2.0f); D_8087933C.z = randPlusMinusPoint5Scaled(2.0f); - func_800B0DE0(globalCtx, &sp88, &D_801D15B0, &D_8087933C, sp80, sp7C, temp1, temp2); + func_800B0DE0(globalCtx, &sp88, &gZeroVec3f, &D_8087933C, sp80, sp7C, temp1, temp2); } } @@ -429,7 +429,7 @@ void func_80876CAC(EnDodongo* this) { this->unk_33C = 1.0f; this->timer = 80; this->actor.flags &= ~0x400; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); } void func_80876D28(EnDodongo* this, GlobalContext* globalCtx) { @@ -439,7 +439,8 @@ void func_80876D28(EnDodongo* this, GlobalContext* globalCtx) { this->unk_300 = 0; this->collider1.base.colType = COLTYPE_HIT0; this->unk_33C = 0.0f; - func_800BF7CC(globalCtx, &this->actor, &this->unk_348[0], 9, 2, this->unk_334 * 0.3f, this->unk_334 * 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, &this->unk_348[0], 9, 2, this->unk_334 * 0.3f, + this->unk_334 * 0.2f); this->actor.flags |= 0x400; } } @@ -522,13 +523,13 @@ s32 func_8087721C(EnDodongo* this) { s32 func_80877278(EnDodongo* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Actor* explosive = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; + Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; Vec3f sp44; // Bugfix from OoT while (explosive != NULL) { if (!explosive->params && (explosive->parent == NULL) && (explosive->update != NULL) && - (explosive != player->unk_388) && + (explosive != player->interactRangeActor) && (((explosive->id == ACTOR_EN_BOM) && (((EnBom*)explosive)->timer > 0)) || ((explosive->id == ACTOR_EN_BOMBF) && (((EnBombf*)explosive)->timer > 0)))) { Math_Vec3f_Diff(&explosive->world.pos, &this->unk_308, &sp44); @@ -577,13 +578,13 @@ void func_80877500(EnDodongo* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 19.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_WALK); sp30.x = this->collider1Elements[2].dim.worldSphere.center.x; sp30.y = this->collider1Elements[2].dim.worldSphere.center.y; sp30.z = this->collider1Elements[2].dim.worldSphere.center.z; func_80876930(this, globalCtx, &sp30); } else if (Animation_OnFrame(&this->skelAnime, 39.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_WALK); sp30.x = this->collider1Elements[1].dim.worldSphere.center.x; sp30.y = this->collider1Elements[1].dim.worldSphere.center.y; sp30.z = this->collider1Elements[1].dim.worldSphere.center.z; @@ -649,7 +650,7 @@ void func_8087784C(EnDodongo* this, GlobalContext* globalCtx) { f32 temp_f12; if (Animation_OnFrame(&this->skelAnime, 24.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_CRY); } if (func_8087721C(this)) { @@ -713,7 +714,7 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { Vec3f sp84; Vec3f sp78; s16 i; - Actor* explosive = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; + Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; Vec3f sp64; s32 pad; s16 sp5E; @@ -736,7 +737,7 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 28.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_EAT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_EAT); if (this->actor.child != NULL) { Actor_MarkForDeath(this->actor.child); this->actor.child = NULL; @@ -759,14 +760,14 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { this->unk_334 * 10.0f, 10); } - Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); if (this->actor.colChkInfo.health <= 4) { this->actor.colChkInfo.health = 0; Enemy_StartFinishingBlow(globalCtx, &this->actor); } else { this->actor.colChkInfo.health -= 4; } - func_800BCB70(&this->actor, 0x4000, 0x78, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0x78, 0, 8); } } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { this->timer--; @@ -780,13 +781,13 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { sp5E = this->unk_334 * 50.0f; sp5C = this->unk_334 * 5.0f; Math_Vec3f_Copy(&sp64, &this->unk_348[0]); - func_800B0DE0(globalCtx, &sp64, &D_801D15B0, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); + 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, &D_801D15B0, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); + 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; - func_800B0DE0(globalCtx, &sp64, &D_801D15B0, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); + func_800B0DE0(globalCtx, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); } } @@ -818,7 +819,7 @@ void func_80878354(EnDodongo* this) { sp18 = &D_06003B14; } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_TAIL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_TAIL); Animation_PlayOnceSetSpeed(&this->skelAnime, sp18, 2.0f); this->timer = 0; this->collider1.base.atFlags |= AT_ON; @@ -879,11 +880,11 @@ void func_808785B0(EnDodongo* this, GlobalContext* globalCtx) { void func_8087864C(EnDodongo* this) { Animation_MorphToPlayOnce(&this->skelAnime, &D_06001A44, -4.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_DAMAGE); this->timer = 0; this->unk_304 = 0; this->actor.speedXZ = 0.0f; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->actionFunc = func_808786C8; } @@ -901,10 +902,10 @@ void func_80878724(EnDodongo* this) { Animation_MorphToPlayOnce(&this->skelAnime, &D_060013C4, -8.0f); this->timer = 0; this->unk_304 = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_DEAD); this->actor.flags &= ~1; this->actor.speedXZ = 0.0f; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->actionFunc = func_808787B0; } @@ -916,7 +917,7 @@ void func_808787B0(EnDodongo* this, GlobalContext* globalCtx) { func_80876DC4(this, globalCtx); } } else if (this->actor.colorFilterTimer == 0) { - func_800BCB70(&this->actor, 0x4000, 0x78, 0, 4); + Actor_SetColorFilter(&this->actor, 0x4000, 0x78, 0, 4); } if (SkelAnime_Update(&this->skelAnime)) { @@ -929,7 +930,7 @@ void func_808787B0(EnDodongo* this, GlobalContext* globalCtx) { this->timer = 8; } } else if (Animation_OnFrame(&this->skelAnime, 52.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } if (this->timer != 0) { @@ -974,7 +975,7 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { } else if (this->collider1.base.acFlags & AC_HIT) { this->collider2.base.acFlags &= ~AC_HIT; this->collider1.base.acFlags &= ~AC_HIT; - func_800BE2B8(&this->actor, &this->collider1); + Actor_SetDropFlagJntSph(&this->actor, &this->collider1); for (i = 0; i < ARRAY_COUNT(this->collider1Elements); i++) { if (this->collider1.elements[i].info.bumperFlags & BUMP_HIT) { @@ -1000,13 +1001,13 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { } } else if (this->actor.colChkInfo.damageEffect == 1) { this->timer = 40; - func_800BCB70(&this->actor, 0, 0xFF, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_80878594(this); } else if (this->actor.colChkInfo.damageEffect == 5) { this->timer = 40; - func_800BCB70(&this->actor, 0, 0xFF, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->unk_300 = 30; this->unk_340 = 0.75f; this->unk_33C = 2.0f; @@ -1029,10 +1030,10 @@ void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx2) { EnDodongo_UpdateDamage(this, globalCtx); this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 60.0f, 70.0f, 0x1D); if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); @@ -1099,7 +1100,7 @@ void EnDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } if ((limbIndex == 30) && (this->actionFunc == func_80878424) && (this->timer != this->unk_304)) { - func_800A81F0(Effect_GetParams(this->unk_338), &this->unk_320, &this->unk_348[4]); + EffectBlure_AddVertex(Effect_GetByIndex(this->unk_338), &this->unk_320, &this->unk_348[4]); this->unk_304 = this->timer; } } diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.h b/src/overlays/actors/ovl_En_Door/z_en_door.h index 7331339fcf..6ed5aac156 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.h +++ b/src/overlays/actors/ovl_En_Door/z_en_door.h @@ -12,7 +12,10 @@ typedef struct EnDoor { /* 0x144 */ char unk_144[0x5C]; /* 0x1A0 */ s8 unk_1A0; /* 0x1A1 */ s8 unk_1A1; - /* 0x1A2 */ char unk_1A2[0x5]; + /* 0x1A2 */ char unk_1A2[0x2]; + /* 0x1A4 */ u8 unk_1A4; + /* 0x1A5 */ u8 unk_1A5; + /* 0x1A6 */ s8 unk_1A6; /* 0x1A7 */ s8 unk_1A7; /* 0x1A8 */ char unk_1A8[0x20]; /* 0x1C8 */ EnDoorActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c index a67805e574..564b52fcb1 100644 --- a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c +++ b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c @@ -82,9 +82,9 @@ void EnDyExtra_Update(Actor* thisx, GlobalContext* globalCtx) { EnDyExtra* this = THIS; DECR(this->unk14C); - Audio_PlayActorSound2(&this->actor, NA_SE_PL_SPIRAL_HEAL_BEAM - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_SPIRAL_HEAL_BEAM - SFX_FLAG); this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void EnDyExtra_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 1af159e0ba..d614223e76 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -15,16 +15,25 @@ void EnElf_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnElf_Update(Actor* thisx, GlobalContext* globalCtx); void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnElf_SetupAction(EnElf* this, EnElfActionFunc actionFunc); +void func_8088C9CC(EnElf* this, GlobalContext* globalCtx); +void func_8088D3EC(EnElf* this, GlobalContext* globalCtx); +void func_8088D470(EnElf* this, GlobalContext* globalCtx); +void func_8088D504(EnElf* this, GlobalContext* globalCtx); void func_8088DD34(EnElf* this, GlobalContext* globalCtx); void func_8088E018(EnElf* this, GlobalContext* globalCtx); void func_8088E0E0(EnElf* this, GlobalContext* globalCtx); void func_8088E0F0(EnElf* this, GlobalContext* globalCtx); void func_8088E484(EnElf* this, GlobalContext* globalCtx); void func_8088E850(EnElf* this, GlobalContext* globalCtx); +void func_8088EFA4(EnElf* this, GlobalContext* globalCtx); +void func_8088F214(EnElf* this, GlobalContext* globalCtx); +void func_8088F5F4(EnElf* this, GlobalContext* globalCtx, s32 arg2); +void func_8089010C(Actor* thisx, GlobalContext* globalCtx); +void func_808908D0(Vec3f* arg0, GlobalContext* globalCtx, u32 arg2); -void EnElf_SetupAction(EnElf* this, EnElfActionFunc actionFunc); +extern SkeletonHeader D_0402AF58; -#if 0 const ActorInit En_Elf_InitVars = { ACTOR_EN_ELF, ACTORCAT_ITEMACTION, @@ -37,96 +46,1592 @@ const ActorInit En_Elf_InitVars = { (ActorFunc)EnElf_Draw, }; -#endif +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 8, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/EnElf_SetupAction.s") +static Color_RGBAf sInnerColors[] = { + { 255.0f, 255.0f, 230.0f, 255.0f }, + { 255.0f, 220.0f, 220.0f, 255.0f }, + { 255.0f, 235.0f, 220.0f, 255.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088C51C.s") +static Color_RGBAf sOuterColors[] = { + { 220.0f, 160.0f, 80.0f, 255.0f }, + { 255.0f, 50.0f, 100.0f, 255.0f }, + { 255.0f, 150.0f, 0.0f, 255.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088C804.s") +typedef struct { + u8 r, g, b; +} FairyColorFlags; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088C858.s") +static FairyColorFlags sColorFlags[] = { + { 0, 0, 0 }, { 1, 0, 0 }, { 1, 2, 0 }, { 1, 0, 2 }, { 0, 1, 0 }, { 2, 1, 0 }, { 0, 1, 2 }, + { 0, 0, 1 }, { 2, 0, 1 }, { 0, 2, 1 }, { 1, 1, 0 }, { 1, 0, 1 }, { 0, 1, 1 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088C920.s") +void EnElf_SetupAction(EnElf* this, EnElfActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088C9CC.s") +void func_8088C51C(EnElf* this, s32 arg1) { + this->unk_244 = arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088CBAC.s") + switch (this->unk_244) { + case 0: + this->unk_24A = 0x400; + this->unk_24C = 0x200; + this->unk_26C = func_8088D3EC; + this->unk_25C = 0x64; + this->skelAnime.playSpeed = 1.0f; + this->unk_250 = 5.0f; + this->unk_254 = 20.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088CC48.s") + case 10: + this->unk_24A = 0x400; + this->unk_24C = 0x200; + this->unk_26C = func_8088D3EC; + this->unk_25C = 0x64; + this->unk_250 = 1.0f; + this->skelAnime.playSpeed = 1.0f; + this->unk_254 = 5.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088CD3C.s") + case 8: + this->unk_24A = 0x400; + this->unk_24C = 0; + this->unk_26C = func_8088D3EC; + this->skelAnime.playSpeed = 1.0f; + this->unk_254 = 0.0f; + this->unk_250 = 5.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/EnElf_Init.s") + case 7: + this->unk_24A = 0x1000; + this->unk_24C = 0x200; + this->unk_26C = func_8088D3EC; + this->skelAnime.playSpeed = 1.0f; + this->unk_250 = 3.0f; + this->unk_254 = 10.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/EnElf_Destroy.s") + case 5: + this->unk_26C = func_8088D3EC; + this->unk_24A = 0x1E; + this->unk_25C = 1; + this->unk_250 = 0.0f; + this->unk_254 = 0.0f; + this->skelAnime.playSpeed = 1.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088D3EC.s") + case 6: + this->unk_24A = 0x1000; + this->unk_24C = 0x200; + this->unk_26C = func_8088D3EC; + this->unk_250 = 0.0f; + this->unk_254 = 0.0f; + this->skelAnime.playSpeed = 1.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088D470.s") + case 1: + this->unk_24A = 0x1000; + this->unk_24C = 0x800; + this->unk_26C = func_8088D3EC; + this->unk_250 = 5.0f; + this->unk_254 = 7.5f; + this->skelAnime.playSpeed = 2.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088D504.s") + case 2: + this->unk_24A = 0x400; + this->unk_24C = 0x1000; + this->unk_26C = func_8088D470; + this->skelAnime.playSpeed = 1.0f; + this->unk_250 = 10.0f; + this->unk_254 = 20.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088D5A0.s") + case 3: + this->unk_24C = 0x600; + this->unk_26C = func_8088D504; + this->unk_254 = 1.0f; + this->unk_250 = 1.0f; + this->skelAnime.playSpeed = 1.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088D660.s") + case 4: + this->unk_24A = 0x1000; + this->unk_24C = 0x800; + this->unk_26C = func_8088D3EC; + this->unk_250 = 60.0f; + this->unk_254 = 20.0f; + this->skelAnime.playSpeed = 2.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088D7F8.s") + case 9: + this->unk_24A = 0x400; + this->unk_24C = 0x2000; + this->unk_26C = func_8088D3EC; + this->unk_25C = 0x2A; + this->unk_254 = 1.0f; + this->skelAnime.playSpeed = 1.0f; + this->unk_250 = 5.0f; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088D864.s") +s32 func_8088C804(Vec3f* arg0, Vec3f* arg1, f32 arg2) { + return SQ(arg2) < SQ(arg1->x - arg0->x) + SQ(arg1->z - arg0->z); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088D8D0.s") +void func_8088C858(EnElf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088D9BC.s") + if (!func_8088C804(&this->actor.world.pos, &player->actor.world.pos, 30.0f)) { + this->unk_254 = 0.5f; + } else { + this->unk_254 = 2.0f; + } + if (this->unk_25C > 0) { + this->unk_25C--; + } else { + this->unk_244 = 1; + this->unk_248 = 128; + this->unk_254 = Rand_ZeroFloat(1.0f) + 0.5f; + this->unk_24C = randPlusMinusPoint5Scaled(0x7FFF); + this->unk_26C = func_8088C9CC; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088DB4C.s") +void func_8088C920(EnElf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088DCA4.s") + if (func_8088C804(&this->actor.world.pos, &player->actor.world.pos, 50.0f)) { + if (this->unk_25C > 0) { + this->unk_25C--; + } else { + this->unk_244 = 1; + this->unk_248 = 128; + this->unk_254 = Rand_ZeroFloat(1.0f) + 0.5f; + this->unk_24C = randPlusMinusPoint5Scaled(0x7FFF); + this->unk_26C = func_8088C9CC; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088DD34.s") +void func_8088C9CC(EnElf* this, GlobalContext* globalCtx) { + f32 xzDistToPlayer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088E018.s") + if (this->unk_25C > 0) { + this->unk_25C--; + } else { + xzDistToPlayer = this->actor.xzDistToPlayer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088E0E0.s") + if (xzDistToPlayer < 50.0f) { + if (Rand_ZeroOne() < 0.2f) { + this->unk_244 = 2; + this->unk_248 = 0x400; + this->unk_254 = 2.0f; + this->actor.speedXZ = 1.5f; + this->unk_26C = func_8088C920; + this->unk_25C = (s32)Rand_ZeroFloat(8.0f) + 4; + } else { + this->unk_25C = 10; + } + } else { + if (xzDistToPlayer > 150.0f) { + xzDistToPlayer = 150.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088E0F0.s") + xzDistToPlayer = ((xzDistToPlayer - 50.0f) * 0.95f) + 0.05f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088E304.s") + if (Rand_ZeroOne() < xzDistToPlayer) { + this->unk_244 = 3; + this->unk_248 = 0x200; + this->unk_254 = (2.0f * xzDistToPlayer) + 1.0f; + this->unk_26C = func_8088C858; + this->unk_25C = (s32)Rand_ZeroFloat(16.0f) + 16; + } else { + this->unk_25C = 10; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088E484.s") + if (Rand_ZeroOne() < 0.1f) { + this->unk_244 = 1; + this->unk_248 = 128; + this->unk_254 = Rand_ZeroFloat(0.5f) + 0.5f; + this->unk_24C = randPlusMinusPoint5Scaled(0x7FFF); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088E5A8.s") +void func_8088CBAC(EnElf* this, GlobalContext* globalCtx) { + f32 phi_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088E60C.s") + if (this->fairyFlags & 0x4000) { + phi_f0 = 0.0f; + } else { + phi_f0 = 100.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088E850.s") + if (func_8088C804(&this->unk_224, &this->actor.world.pos, phi_f0)) { + this->unk_244 = 0; + this->unk_248 = 0x200; + this->unk_254 = 1.5f; + this->unk_26C = func_8088C9CC; + } else { + this->unk_26C(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088EF18.s") +void func_8088CC48(EnElf* this, GlobalContext* globalCtx) { + EnElf_SetupAction(this, func_8088DD34); + this->unk_250 = Rand_ZeroFloat(10.0f) + 10.0f; + this->unk_246 = 0; + this->unk_24A = (s32)Rand_ZeroFloat(1048.0f) + 0x200; + this->unk_224 = this->actor.world.pos; + this->unk_258 = randPlusMinusPoint5Scaled(0x7FFF); + this->unk_26C = func_8088C9CC; + func_8088CBAC(this, globalCtx); + this->unk_25C = 0; + this->disappearTimer = 240; + if ((this->fairyFlags & 0x400) && Flags_GetCollectible(globalCtx, this->unk_260)) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088EFA4.s") +f32 func_8088CD3C(s32 colorFlag) { + switch (colorFlag) { + case 1: + return Rand_ZeroFloat(55.0f) + 200.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088F214.s") + case 2: + return Rand_ZeroFloat(255.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088F5F4.s") + return 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088F9E4.s") +void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnElf* this = THIS; + Player* player = GET_PLAYER(globalCtx); + s32 colorConfig; + s32 params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088FA38.s") + Actor_ProcessInitChain(thisx, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &D_0402AF58, &D_04029140, this->jointTable, this->morphTable, 7); + ActorShape_Init(&thisx->shape, 0.0f, NULL, 15.0f); + thisx->shape.shadowAlpha = 255; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088FC34.s") + Lights_PointGlowSetInfo(&this->lightInfoGlow, thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 255, 255, + 255, 0); + this->lightNodeGlow = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfoGlow); + Lights_PointNoGlowSetInfo(&this->lightInfoNoGlow, thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 255, + 255, 255, 0); + this->lightNodeNoGlow = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfoNoGlow); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088FD04.s") + this->fairyFlags = 0; + this->disappearTimer = 600; + this->unk_240 = 0.0f; + colorConfig = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088FDCC.s") + this->unk_260 = ENELF_GET_FE00(&this->actor); + params = ENELF_GET_F(&this->actor); + if (thisx->params & 0x100) { + this->fairyFlags |= 0x400; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8088FE64.s") + this->actor.params = params; + switch (params) { + case 0: + thisx->room = -1; + EnElf_SetupAction(this, func_8088E850); + func_8088C51C(this, 0); + this->fairyFlags |= 4; + thisx->update = func_8089010C; + this->elfMsg = NULL; + this->unk_234 = NULL; + this->unk_269 = 20; + if ((gSaveContext.tatlTimer >= 25800) || (gSaveContext.tatlTimer < 3000)) { + gSaveContext.tatlTimer = 0; + } + this->unk_266 = ElfMessage_GetFirstCycleHint(globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_8089010C.s") + case 1: + colorConfig = -1; + gSaveContext.unk_1016 = 0; + EnElf_SetupAction(this, func_8088E0F0); + this->unk_254 = Math_Vec3f_DistXZ(&thisx->world.pos, &player->actor.world.pos); + this->unk_248 = player->actor.shape.rot.y; + this->unk_24C = -0x1000; + this->unk_224.y = thisx->world.pos.y - player->actor.world.pos.y; + this->unk_246 = 0; + this->unk_250 = 0.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/EnElf_Update.s") + case 5: + colorConfig = -1; + EnElf_SetupAction(this, func_8088E484); + this->unk_254 = 0.0f; + this->unk_248 = player->actor.shape.rot.y; + this->unk_24C = 0; + this->unk_224.y = thisx->world.pos.y - player->actor.world.pos.y; + this->unk_246 = 0; + this->unk_250 = 7.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_80890494.s") + case 7: + this->fairyFlags |= 0x200; + thisx->shape.shadowDraw = ActorShadow_DrawWhiteCircle; + this->fairyFlags |= 0x100; + colorConfig = -1; + this->fairyFlags |= 0x800; + this->fairyFlags |= 0x1000; + func_8088CC48(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/EnElf_Draw.s") + case 2: + this->fairyFlags |= 0x100; + colorConfig = -1; + this->fairyFlags |= 0x800; + this->fairyFlags |= 0x2000; + this->fairyFlags |= 0x1000; + func_8088CC48(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elf/func_808908D0.s") + case 6: + colorConfig = -1; + this->fairyFlags |= 0x800; + this->fairyFlags |= 0x2000; + this->fairyFlags |= 0x1000; + func_8088CC48(this, globalCtx); + break; + + case 9: + this->fairyFlags |= 0x1000; + + case 10: + colorConfig = -2; + func_8088CC48(this, globalCtx); + break; + + case 8: + Actor_MarkForDeath(thisx); + return; + + case 3: + colorConfig = Rand_ZeroFloat(11.99f) + 1.0f; + EnElf_SetupAction(this, func_8088E018); + func_8088C51C(this, 0); + break; + + case 4: + EnElf_SetupAction(this, func_8088E0E0); + func_8088C51C(this, 6); + this->fairyFlags |= 8; + { + s32 i; + + for (i = 0; i < 8; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, thisx->world.pos.x, + thisx->world.pos.y - 30.0f, thisx->world.pos.z, 0, 0, 0, 6); + } + } + break; + } + + this->unk_23C = 3.0f; + this->innerColor = sInnerColors[0]; + if (colorConfig > 0) { + this->outerColor.r = func_8088CD3C(sColorFlags[colorConfig].r); + this->outerColor.g = func_8088CD3C(sColorFlags[colorConfig].g); + this->outerColor.b = func_8088CD3C(sColorFlags[colorConfig].b); + this->outerColor.a = 0; + } else { + this->innerColor = sInnerColors[-colorConfig]; + this->outerColor = sOuterColors[-colorConfig]; + } +} + +void EnElf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnElf* this = THIS; + + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNodeGlow); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNodeNoGlow); +} + +void func_8088D3EC(EnElf* this, GlobalContext* globalCtx) { + this->unk_224.x = Math_SinS(this->unk_248) * this->unk_254; + this->unk_224.y = Math_SinS(this->unk_246) * this->unk_250; + this->unk_224.z = Math_CosS(this->unk_248) * this->unk_254; + this->unk_248 += this->unk_24C; + this->unk_246 += this->unk_24A; +} + +void func_8088D470(EnElf* this, GlobalContext* globalCtx) { + f32 xzScale = (Math_CosS(this->unk_246) * this->unk_250) + this->unk_254; + + this->unk_224.x = Math_SinS(this->unk_248) * xzScale; + this->unk_224.y = 0.0f; + this->unk_224.z = Math_CosS(this->unk_248) * xzScale; + + this->unk_248 += this->unk_24C; + this->unk_246 += this->unk_24A; +} + +void func_8088D504(EnElf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_246 = (this->unk_248 * 2) & 0xFFFF; + this->unk_224.x = Math_SinS(this->unk_248) * this->unk_254; + this->unk_224.y = Math_SinS(this->unk_246) * this->unk_250; + this->unk_224.z = -Math_SinS(player->actor.shape.rot.y) * this->unk_224.x; + this->unk_224.x = Math_CosS(player->actor.shape.rot.y) * this->unk_224.x; + this->unk_248 += this->unk_24C; +} + +void func_8088D5A0(EnElf* this, Vec3f* arg1, f32 arg2) { + f32 yVelTarget = ((arg1->y + this->unk_224.y) - this->actor.world.pos.y) * arg2; + f32 yVelAbs = fabsf(yVelTarget); + f32 yVelDirection = (yVelTarget >= 0.0f) ? 1.0f : -1.0f; + + yVelAbs = CLAMP(yVelAbs, 0.0f, 30.0f); + Math_StepToF(&this->actor.velocity.y, yVelAbs * yVelDirection, 32.0f); +} + +void func_8088D660(EnElf* this, Vec3f* targetPos, f32 arg2) { + f32 xVelTarget = ((targetPos->x + this->unk_224.x) - this->actor.world.pos.x) * arg2; + f32 zVelTarget = ((targetPos->z + this->unk_224.z) - this->actor.world.pos.z) * arg2; + f32 xVelDirection = (xVelTarget >= 0.0f) ? 1.0f : -1.0f; + f32 zVelDirection = (zVelTarget >= 0.0f) ? 1.0f : -1.0f; + + xVelTarget = fabsf(xVelTarget); + zVelTarget = fabsf(zVelTarget); + + xVelTarget = CLAMP(xVelTarget, 0.0f, 30.0f) * xVelDirection; + zVelTarget = CLAMP(zVelTarget, 0.0f, 30.0f) * zVelDirection; + + func_8088D5A0(this, targetPos, arg2); + Math_StepToF(&this->actor.velocity.x, xVelTarget, 1.5f); + Math_StepToF(&this->actor.velocity.z, zVelTarget, 1.5f); + Actor_UpdatePos(&this->actor); +} + +void func_8088D7F8(EnElf* this, Vec3f* targetPos) { + func_8088D5A0(this, targetPos, 0.2f); + this->actor.velocity.x = 0.0f; + this->actor.velocity.z = 0.0f; + Actor_UpdatePos(&this->actor); + this->actor.world.pos.x = targetPos->x + this->unk_224.x; + this->actor.world.pos.z = targetPos->z + this->unk_224.z; +} + +void func_8088D864(EnElf* this, Vec3f* targetPos) { + func_8088D5A0(this, targetPos, 0.2f); + this->actor.velocity.z = 0.0f; + this->actor.velocity.x = 0.0f; + Actor_UpdatePos(&this->actor); + this->actor.world.pos.x = targetPos->x + this->unk_224.x; + this->actor.world.pos.z = targetPos->z + this->unk_224.z; +} + +void func_8088D8D0(EnElf* this, Vec3f* arg1) { + f32 yVelTarget = (((Math_SinS(this->unk_246) * this->unk_250) + arg1->y) - this->actor.world.pos.y) * 0.2f; + f32 yVelAbs = fabsf(yVelTarget); + f32 yVelDirection = (yVelTarget >= 0.0f) ? 1.0f : -1.0f; + + this->unk_246 += this->unk_24A; + yVelAbs = CLAMP(yVelAbs, 0.0f, 30.0f); + + Math_StepToF(&this->actor.velocity.y, yVelAbs * yVelDirection, 1.5f); +} + +void func_8088D9BC(EnElf* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + s16 targetYaw; + Vec3f* vec = &this->unk_224; + + if (this->fairyFlags & 0x4000) { + Math_SmoothStepToF(&this->actor.speedXZ, 5.0f, 0.5f, 1.0f, 0.01f); + } else { + Math_SmoothStepToF(&this->actor.speedXZ, this->unk_254, 0.2f, 0.5f, 0.01f); + } + + switch (this->unk_244) { + case 0: + targetYaw = Math_FAtan2F(-(this->actor.world.pos.z - vec->z), -(this->actor.world.pos.x - vec->x)); + break; + + case 3: + targetYaw = Math_FAtan2F(-(this->actor.world.pos.z - player->actor.world.pos.z), + -(this->actor.world.pos.x - player->actor.world.pos.x)); + break; + + case 2: + targetYaw = Math_FAtan2F(this->actor.world.pos.z - player->actor.world.pos.z, + this->actor.world.pos.x - player->actor.world.pos.x); + break; + + default: + targetYaw = this->unk_24C; + break; + } + + if (this->fairyFlags & 0x4000) { + Math_SmoothStepToS(&this->unk_258, targetYaw, 10, this->unk_248, 0x1000); + } else { + Math_SmoothStepToS(&this->unk_258, targetYaw, 10, this->unk_248, 0x20); + } + + this->actor.world.rot.y = this->unk_258; + Actor_MoveWithGravity(&this->actor); +} + +void func_8088DB4C(EnElf* this, Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4) { + f32 xVelTarget = ((arg1->x + this->unk_224.x) - this->actor.world.pos.x) * arg4; + f32 zVelTarget = ((arg1->z + this->unk_224.z) - this->actor.world.pos.z) * arg4; + f32 xzVelocity; + f32 clampedXZ; + + arg4 += 0.3f; + arg3 += 30.0f; + + func_8088D5A0(this, arg1, arg4); + + xzVelocity = sqrtf(SQ(xVelTarget) + SQ(zVelTarget)); + clampedXZ = CLAMP(xzVelocity, arg2, arg3); + this->actor.speedXZ = clampedXZ; + + if ((xzVelocity != clampedXZ) && (xzVelocity != 0.0f)) { + xzVelocity = clampedXZ / xzVelocity; + xVelTarget *= xzVelocity; + zVelTarget *= xzVelocity; + } + + Math_StepToF(&this->actor.velocity.x, xVelTarget, 5.0f); + Math_StepToF(&this->actor.velocity.z, zVelTarget, 5.0f); + Actor_UpdatePos(&this->actor); +} + +s32 func_8088DCA4(EnElf* this) { + if (this->disappearTimer > 0) { + this->disappearTimer--; + } else { + this->disappearTimer--; + if (this->disappearTimer > -10) { + Actor_SetScale(&this->actor, (this->disappearTimer + 10) * 0.008f * 0.1f); + } else { + Actor_MarkForDeath(&this->actor); + return true; + } + } + return false; +} + +void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { + Player* refActor = GET_PLAYER(globalCtx); + s32 pad; + Player* player2 = GET_PLAYER(globalCtx); + f32 heightDiff; + + SkelAnime_Update(&this->skelAnime); + + if (Rand_ZeroOne() < 0.05f) { + this->unk_250 = Rand_ZeroFloat(10.0f) + 10.0f; + this->unk_24A = (s32)Rand_ZeroFloat(0x400) + 0x200; + } + + func_8088CBAC(this, globalCtx); + if (this->fairyFlags & 0x800) { + this->unk_224.y = player2->bodyPartsPos[0].y; + } + + func_8088D8D0(this, &this->unk_224); + func_8088D9BC(this, globalCtx); + if (Actor_HasParent(&this->actor, globalCtx)) { + if (this->fairyFlags & 0x400) { + Flags_SetCollectible(globalCtx, this->unk_260); + } + Actor_MarkForDeath(&this->actor); + return; + } + + if (Player_InCsMode(&globalCtx->state)) { + if ((this->fairyFlags & 0x4000) && (this->fairyFlags & 0x100) && func_8088DCA4(this)) { + return; + } + return; + } + + heightDiff = this->actor.world.pos.y - refActor->actor.world.pos.y; + + if ((this->fairyFlags & 0x1000) && (heightDiff > 0.0f) && (heightDiff < 60.0f) && + !func_8088C804(&this->actor.world.pos, &refActor->actor.world.pos, 10.0f)) { + func_80115908(globalCtx, 0x80); + if (this->fairyFlags & 0x200) { + Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + (gSaveContext.doubleMagic * 0x30) + 0x30); + } + gSaveContext.unk_1016 = 0; + this->unk_254 = 50.0f; + this->unk_248 = refActor->actor.shape.rot.y; + this->unk_24C = -0x1000; + this->unk_224.y = 30.0f; + this->unk_250 = 0.0f; + this->unk_246 = 0; + EnElf_SetupAction(this, func_8088E0F0); + if (this->fairyFlags & 0x400) { + Flags_SetCollectible(globalCtx, this->unk_260); + } + return; + } + + if (this->fairyFlags & 0x100) { + if (func_8088DCA4(this)) { + return; + } + } else { + Actor_SetScale(&this->actor, 0.008f); + } + + if (this->fairyFlags & 0x2000) { + Actor_PickUp(&this->actor, globalCtx, 0xBA, 80.0f, 60.0f); + } +} + +void func_8088E018(EnElf* this, GlobalContext* globalCtx) { + Vec3f parentPos; + Actor* parent; + + SkelAnime_Update(&this->skelAnime); + func_8088D3EC(this, globalCtx); + parent = this->actor.parent; + + if ((parent != NULL) && (parent->update != NULL)) { + parentPos = this->actor.parent->world.pos; + parentPos.y += (1500.0f * this->actor.scale.y) + 40.0f; + func_8088D660(this, &parentPos, 0.2f); + } else { + Actor_MarkForDeath(&this->actor); + } + this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); +} + +void func_8088E0E0(EnElf* this, GlobalContext* globalCtx) { +} + +void func_8088E0F0(EnElf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToF(&this->unk_254, 30.0f, 0.1f, 4.0f, 1.0f); + + this->unk_224.x = Math_CosS(this->unk_248) * this->unk_254; + this->unk_224.y += this->unk_250; + + switch (this->unk_246) { + case 0: + if (this->unk_250 < 2.0f) { + this->unk_250 += 0.1f; + } else { + gSaveContext.healthAccumulator = 160; + this->unk_246++; + } + break; + + case 1: + if (this->unk_250 > -1.0f) { + this->unk_250 -= 0.2f; + } + break; + } + + this->unk_224.z = Math_SinS(this->unk_248) * -this->unk_254; + this->unk_248 += this->unk_24C; + func_8088D660(this, &player->actor.world.pos, 0.2f); + + if (this->unk_250 < 0.0f) { + if ((this->unk_224.y < 20.0f) && (this->unk_224.y > 0.0f)) { + Actor_SetScale(&this->actor, this->unk_224.y * 0.008f * 0.05f); + } + } + + if (this->unk_224.y < -10.0f) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); + func_8088F5F4(this, globalCtx, 32); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); +} + +void func_8088E304(EnElf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&this->skelAnime); + if (this->unk_224.y > 200.0f) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->unk_24A >= 0x7E) { + this->unk_254 += 0.1f; + this->unk_250 += 0.5f; + this->unk_224.y += this->unk_250; + } else { + this->unk_24A++; + if (this->unk_254 < 30.0f) { + this->unk_254 += 0.5f; + } + + if (this->unk_224.y > 0.0f) { + this->unk_224.y -= 0.7f; + } + } + + this->unk_224.x = Math_CosS(this->unk_248) * this->unk_254; + this->unk_224.z = Math_SinS(this->unk_248) * -this->unk_254; + this->unk_248 += this->unk_24C; + + func_8088D7F8(this, &player->bodyPartsPos[0]); + this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); + func_8088F5F4(this, globalCtx, 0x20); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); +} + +void func_8088E484(EnElf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&this->skelAnime); + + this->unk_224.z = 0.0f; + this->unk_224.x = 0.0f; + this->unk_224.y += this->unk_250; + this->unk_250 -= 0.35f; + + if (this->unk_250 <= 0.0f) { + EnElf_SetupAction(this, func_8088E304); + this->unk_24C = 0x800; + this->unk_24A = 0; + this->unk_250 = 0.0f; + this->unk_254 = 1.0f; + } + + func_8088D7F8(this, &player->bodyPartsPos[0]); + Actor_SetScale(&this->actor, (1.0f - (SQ(this->unk_250) * SQ(1.0f / 9.0f))) * 0.008f); + this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); + func_8088F5F4(this, globalCtx, 32); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); +} + +void func_8088E5A8(EnElf* this, GlobalContext* globalCtx) { + if (this->fairyFlags & 4) { + func_8088EFA4(this, globalCtx); + } + + SkelAnime_Update(&this->skelAnime); + + this->unk_26C(this, globalCtx); +} + +void func_8088E60C(EnElf* this, GlobalContext* globalCtx) { + s16 glowLightRadius; + Player* player = GET_PLAYER(globalCtx); + + if (player->stateFlags1 & 0x400) { + glowLightRadius = 200; + } else { + glowLightRadius = 100; + } + + if ((this->unk_244 == 6) || (player->stateFlags1 & 2) || (this->fairyFlags & 0x8000)) { + glowLightRadius = 0; + } + + if (func_800EE29C(globalCtx, 0xC9)) { + if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0xC9)]->unk0 == 6) { + glowLightRadius = 0; + } + } + + if (this->fairyFlags & 0x20) { + Player* player = GET_PLAYER(globalCtx); + + Lights_PointNoGlowSetInfo(&this->lightInfoNoGlow, player->actor.world.pos.x, player->actor.world.pos.y + 60.0f, + player->actor.world.pos.z, 255, 255, 255, 200); + } else { + Lights_PointNoGlowSetInfo(&this->lightInfoNoGlow, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 255, 255, 255, -1); + } + + Lights_PointGlowSetInfo(&this->lightInfoGlow, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 255, 255, 255, glowLightRadius); + this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); + Actor_SetScale(&this->actor, this->actor.scale.x); +} + +void func_8088E850(EnElf* this, GlobalContext* globalCtx) { + Vec3f nextPos; + Player* player = GET_PLAYER(globalCtx); + Actor* arrowPointedActor; + f32 xScale; + f32 distFromLinksHead; + u32 sp38; + + func_8088F214(this, globalCtx); + func_8088E5A8(this, globalCtx); + xScale = 0.0f; + + if (func_800EE29C(globalCtx, 0xC9)) { + sp38 = func_800EE200(globalCtx, 0xC9); + 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) { + func_8088F5F4(this, globalCtx, 16); + } + + if (this->unk_244 == 8) { + func_8088D864(this, &nextPos); + } else { + func_8088D660(this, &nextPos, 0.2f); + } + + 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))) { + 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)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + } + } else { + this->actor.shape.rot.x = 0; + distFromLinksHead = Math_Vec3f_DistXYZ(&player->bodyPartsPos[8], &this->actor.world.pos); + switch (this->unk_244) { + case 5: + func_8088D660(this, &player->bodyPartsPos[8], 1.0f - (this->unk_24A * 0.033333335f)); + xScale = Math_Vec3f_DistXYZ(&player->bodyPartsPos[8], &this->actor.world.pos); + + if (distFromLinksHead < 7.0f) { + this->unk_25C = 0; + xScale = 0; + } else if (distFromLinksHead < 25.0f) { + xScale = (xScale - 5.0f) * 0.05f; + xScale = 1.0f - xScale; + xScale = (1.0f - SQ(xScale)) * 0.008f; + } else { + xScale = 0.008f; + } + func_8088F5F4(this, globalCtx, 16); + break; + + case 6: + func_8088D660(this, &player->bodyPartsPos[8], 0.2f); + this->actor.world.pos = player->bodyPartsPos[8]; + break; + + case 9: + nextPos = player->bodyPartsPos[8]; + nextPos.y += 1500.0f * this->actor.scale.y; + + func_8088D7F8(this, &nextPos); + func_8088F5F4(this, globalCtx, 16); + + if (this->unk_254 <= 19.0f) { + this->unk_254 += 1.0f; + } + + if (this->unk_254 >= 21.0f) { + this->unk_254 -= 1.0f; + } + + if (this->unk_25C < 0x20) { + this->unk_24C = (this->unk_25C * 240) + 0x200; + } + break; + + case 10: + nextPos = GET_ACTIVE_CAM(globalCtx)->eye; + nextPos.y += -2000.0f * this->actor.scale.y; + func_8088DB4C(this, &nextPos, 0.0f, 30.0f, 0.2f); + break; + + default: + arrowPointedActor = globalCtx->actorCtx.targetContext.arrowPointedActor; + if ((player->stateFlags1 & 0x40) && (player->targetActor != NULL)) { + Math_Vec3f_Copy(&nextPos, &player->targetActor->focus.pos); + } else { + Math_Vec3f_Copy(&nextPos, &globalCtx->actorCtx.targetContext.unk0); + } + nextPos.y += 1500.0f * this->actor.scale.y; + + if (arrowPointedActor != NULL) { + func_8088DB4C(this, &nextPos, 0.0f, 30.0f, 0.2f); + if (this->actor.speedXZ >= 5.0f) { + func_8088F5F4(this, globalCtx, 0x10); + } + } else { + if ((this->timer % 32) == 0) { + this->unk_23C = Rand_ZeroFloat(7.0f) + 3.0f; + } + + if (this->fairyFlags & 2) { + if (distFromLinksHead < 30.0f) { + this->fairyFlags ^= 2; + } + func_8088DB4C(this, &nextPos, 0.0f, 30.0f, 0.2f); + func_8088F5F4(this, globalCtx, 0x10); + } else { + if (distFromLinksHead > 100.0f) { + this->fairyFlags |= 2; + if (this->unk_269 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); + } + this->unk_25C = 100; + } + func_8088DB4C(this, &nextPos, 0.0f, this->unk_23C, 0.2f); + } + } + break; + } + } + + if (this->unk_244 == 5) { + this->actor.scale.x = xScale; + } else if (this->unk_244 == 6) { + this->actor.scale.x = 0.0f; + } else { + Math_SmoothStepToF(&this->actor.scale.x, 0.008f, 0.3f, 0.00080000004f, 0.000080000005f); + } + + func_8088E60C(this, globalCtx); + + if (!func_800EE29C(globalCtx, 0xC9)) { + this->actor.shape.rot.y = this->unk_258; + } +} + +void func_8088EF18(Color_RGBAf* dest, Color_RGBAf* newColor, Color_RGBAf* curColor, f32 rate) { + Color_RGBAf rgbaDiff; + + rgbaDiff.r = newColor->r - curColor->r; + rgbaDiff.g = newColor->g - curColor->g; + rgbaDiff.b = newColor->b - curColor->b; + rgbaDiff.a = newColor->a - curColor->a; + + dest->r += rgbaDiff.r * rate; + dest->g += rgbaDiff.g * rate; + dest->b += rgbaDiff.b * rate; + dest->a += rgbaDiff.a * rate; +} + +void func_8088EFA4(EnElf* this, GlobalContext* globalCtx) { + Actor* arrayPointerActor = globalCtx->actorCtx.targetContext.arrowPointedActor; + Player* player = GET_PLAYER(globalCtx); + f32 transitionRate; + + if (!(this->unk_264 & 8)) { + this->unk_264 &= ~0x10; + } + + if (this->unk_264 & 8) { + if (this->unk_264 & 0x10) { + this->unk_238 = 1.0f; + this->unk_264 &= ~8; + this->unk_268 = 0; + this->unk_264 &= ~0x10; + } else { + this->innerColor.r = 255.0f; + this->innerColor.g = 0.0f; + this->innerColor.b = 0.0f; + this->innerColor.a = 255.0f; + + this->outerColor.r = 200.0f; + this->outerColor.g = 80.0f; + this->outerColor.b = 80.0f; + this->outerColor.a = 0.0f; + } + } else if (globalCtx->actorCtx.targetContext.unk40 != 0.0f) { + this->unk_268 = 0; + this->unk_238 = 1.0f; + if (!this->unk_269) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); + } + } else if (this->unk_268 == 0) { + if ((arrayPointerActor == NULL) || + (Math_Vec3f_DistXYZ(&this->actor.world.pos, &globalCtx->actorCtx.targetContext.unk0) < 50.0f)) { + this->unk_268 = 1; + } + } else if (this->unk_238 != 0.0f) { + if (Math_StepToF(&this->unk_238, 0.0f, 0.25f)) { + this->innerColor = globalCtx->actorCtx.targetContext.fairyInner; + this->outerColor = globalCtx->actorCtx.targetContext.fairyOuter; + } else { + transitionRate = 0.25f / this->unk_238; + func_8088EF18(&this->innerColor, &globalCtx->actorCtx.targetContext.fairyInner, &this->innerColor, + transitionRate); + func_8088EF18(&this->outerColor, &globalCtx->actorCtx.targetContext.fairyOuter, &this->outerColor, + transitionRate); + } + } + + if (this->fairyFlags & 1) { + if ((arrayPointerActor == NULL) || (player->unk_730 == NULL)) { + this->fairyFlags ^= 1; + } + } else if ((arrayPointerActor != NULL) && (player->unk_730 != NULL)) { + u8 temp = this->unk_269; + u16 targetSfxId = this->unk_269 == 0 ? NA_SE_PL_WALK_GROUND - SFX_FLAG : NA_SE_PL_WALK_GROUND - SFX_FLAG; + + if (!temp) { + Actor_PlaySfxAtPos(&this->actor, targetSfxId); + } + this->fairyFlags |= 1; + } +} + +void func_8088F214(EnElf* this, GlobalContext* globalCtx) { + s32 sp34; + Actor* arrowPointedActor; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + + if (globalCtx->csCtx.state != 0) { + if (func_800EE29C(globalCtx, 0xC9)) { + switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0xC9)]->unk0) { + case 4: + sp34 = 7; + break; + + case 3: + sp34 = 4; + break; + + case 1: + sp34 = 8; + break; + + default: + sp34 = 0; + break; + } + } else { + sp34 = 0; + this->unk_25C = 100; + } + } else if (this->unk_264 & 8) { + sp34 = 1; + func_800B9010(&this->actor, NA_SE_EV_BELL_ANGER - SFX_FLAG); + } else { + arrowPointedActor = globalCtx->actorCtx.targetContext.arrowPointedActor; + if (player->stateFlags1 & 0x400) { + sp34 = 10; + this->unk_25C = 100; + } else if ((arrowPointedActor == NULL) || (arrowPointedActor->category == 4)) { + if (arrowPointedActor != NULL) { + this->unk_25C = 100; + player->stateFlags2 |= 0x100000; + sp34 = 0; + } else { + switch (this->unk_244) { + case 0: + if (this->unk_25C != 0) { + this->unk_25C--; + sp34 = 0; + } else if (!(player->stateFlags1 & 0x40)) { + if (this->unk_269 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); + } + sp34 = 5; + } else { + sp34 = 0; + } + break; + + case 5: + if (this->unk_25C != 0) { + if (this->unk_24A > 0) { + this->unk_24A--; + sp34 = 5; + } else { + player->stateFlags2 |= 0x100000; + sp34 = 0; + } + } else { + sp34 = 6; + } + break; + + case 6: + sp34 = 6; + break; + + case 9: + sp34 = this->unk_244; + if (this->unk_25C > 0) { + this->unk_25C--; + } else { + sp34 = 0; + } + break; + + default: + sp34 = 0; + break; + } + } + } else { + sp34 = 1; + } + + switch (sp34) { + case 0: + if (!(player->stateFlags2 & 0x100000)) { + sp34 = 5; + if (this->unk_269 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); + } + } + break; + + case 6: + if (player->stateFlags2 & 0x100000) { + sp34 = 9; + this->unk_25C = 0x2A; + if (this->unk_269 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); + } + } else if (player->stateFlags1 & 0x40) { + player->stateFlags2 |= 0x100000; + sp34 = 0; + this->unk_25C = 0; + } + break; + + case 5: + player->stateFlags2 &= ~0x100000; + break; + + default: + player->stateFlags2 |= 0x100000; + break; + } + } + + if (sp34 != this->unk_244) { + func_8088C51C(this, sp34); + if (sp34 == 9) { + this->unk_254 = Math_Vec3f_DistXZ(&player->bodyPartsPos[8], &this->actor.world.pos); + this->unk_248 = Math_Vec3f_Yaw(&this->actor.world.pos, &player->bodyPartsPos[8]); + } + } +} + +void func_8088F5F4(EnElf* this, GlobalContext* globalCtx, s32 sparkleLife) { + static Vec3f sparkleVelocity = { 0.0f, -0.05f, 0.0f }; + static Vec3f sparkleAccel = { 0.0f, -0.025f, 0.0f }; + s32 pad; + Vec3f sparklePos; + Color_RGBA8 primColor; + Color_RGBA8 envColor; + + if (!(this->fairyFlags & 8)) { + sparklePos.x = randPlusMinusPoint5Scaled(6.0f) + this->actor.world.pos.x; + sparklePos.y = (Rand_ZeroOne() * 6.0f) + this->actor.world.pos.y; + sparklePos.z = randPlusMinusPoint5Scaled(6.0f) + this->actor.world.pos.z; + + primColor.r = this->innerColor.r; + primColor.g = this->innerColor.g; + primColor.b = this->innerColor.b; + + envColor.r = this->outerColor.r; + envColor.g = this->outerColor.g; + envColor.b = this->outerColor.b; + + EffectSsKiraKira_SpawnDispersed(globalCtx, &sparklePos, &sparkleVelocity, &sparkleAccel, &primColor, &envColor, + 1000, sparkleLife); + } +} + +void func_8088F9E4(Actor* thisx, GlobalContext* globalCtx) { + EnElf* this = THIS; + s32 bgId; + + thisx->floorHeight = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &thisx->floorPoly, &bgId, + &this->actor, &thisx->world.pos); + thisx->shape.shadowAlpha = 50; +} + +void func_8088FA38(EnElf* this, GlobalContext* globalCtx) { + Vec3f refPos; + Player* player = GET_PLAYER(globalCtx); + + if (this->fairyFlags & 0x10) { + refPos = globalCtx->actorCtx.targetContext.unk0; + + if (this->unk_234 != NULL) { + refPos = this->unk_234->world.pos; + } else { + if ((player->unk_730 == NULL) || (&player->actor == player->unk_730) || (&this->actor == player->unk_730) || + (this->unk_264 & 4)) { + refPos.x = player->bodyPartsPos[7].x + (Math_SinS(player->actor.shape.rot.y) * 20.0f); + refPos.y = player->bodyPartsPos[7].y + 5.0f; + refPos.z = player->bodyPartsPos[7].z + (Math_CosS(player->actor.shape.rot.y) * 20.0f); + this->unk_264 &= ~4; + } + } + this->actor.focus.pos = refPos; + this->fairyFlags &= ~0x10; + } + + func_8088E5A8(this, globalCtx); + refPos = this->actor.focus.pos; + func_8088DB4C(this, &refPos, 0, 30.0f, 0.2f); + + if (this->actor.speedXZ >= 5.0f) { + func_8088F5F4(this, globalCtx, 0x10); + } + + Math_SmoothStepToF(&this->actor.scale.x, 0.008f, 0.3f, 0.00080000004f, 0.000080000005f); + func_8088E60C(this, globalCtx); +} + +void func_8088FC34(EnElf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_258, 5, 0x1000, 0x400); + this->timer++; + + if (this->unk_234 == NULL) { + if (this->unk_264 & 0x20) { + this->unk_240 = 0.0f; + } else { + Math_StepToF(&this->unk_240, 1.0f, 0.05f); + } + func_800FD2B4(globalCtx, SQ(this->unk_240), player->actor.projectedPos.z + 780.0f, 0.2f, 0.5f); + } +} + +void func_8088FD04(EnElf* this) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + this->unk_264 &= ~1; + this->unk_264 |= 2; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->unk_264 |= 1; + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + this->unk_264 &= ~1; + this->unk_264 |= 2; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->unk_264 |= 1; + } +} + +void func_8088FDCC(EnElf* this) { + this->actor.update = func_8089010C; + func_8088C51C(this, 0); + this->fairyFlags &= ~0x20; + this->actor.focus.pos = this->actor.world.pos; + this->unk_234 = NULL; + if ((this->unk_264 & 2) && (this->actor.cutscene != 0x7C)) { + ActorCutscene_Stop(this->actor.cutscene); + } + this->unk_264 &= ~0x20; +} + +void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnElf* this = THIS; + + func_8088FA38(this, globalCtx); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 4: + if (func_80147624(globalCtx)) { + if (globalCtx->msgCtx.unk11F04 == 0x202) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F230(); + break; + + case 1: + func_8019F208(); + break; + } + } + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 - 1); + break; + + case 1: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + } + } + break; + + case 5: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 576: + func_80151938(globalCtx, 0x245); + break; + + case 0x21D: + case 0x21E: + case 0x21F: + case 0x220: + case 0x221: + case 0x222: + case 0x223: + case 0x23F: + case 0x241: + case 0x242: + case 0x243: + case 0x244: + switch (CURRENT_DAY) { + case 1: + func_80151938(globalCtx, 0x246); + break; + + case 2: + func_80151938(globalCtx, 0x247); + break; + + case 3: + if (!gSaveContext.isNight) { + func_80151938(globalCtx, 0x248); + } else if ((gSaveContext.time < CLOCK_TIME(6, 0)) && + (gSaveContext.weekEventReg[74] & 0x20)) { + func_80151938(globalCtx, 0x225); + } else { + func_80151938(globalCtx, 0x249); + } + break; + } + break; + + default: + func_801477B4(globalCtx); + func_8088FDCC(this); + break; + } + } + break; + + case 2: + func_8088FDCC(this); + break; + } + + func_8088FC34(this, globalCtx); + + if (this->unk_264 & 1) { + func_8088FD04(this); + } +} + +void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnElf* this = THIS; + Player* player = GET_PLAYER(globalCtx); + u16 temp_v0 = ElfMessage_GetFirstCycleHint(globalCtx); + + if (temp_v0 != this->unk_266) { + this->unk_266 = temp_v0; + gSaveContext.tatlTimer = 0; + } + + if ((player->tatlTextId == 0) && (player->unk_730 == NULL)) { + if ((gSaveContext.tatlTimer >= 600) && (gSaveContext.tatlTimer <= 3000)) { + player->tatlTextId = ElfMessage_GetFirstCycleHint(globalCtx); + } + } + + if (player->tatlTextId < 0) { + thisx->flags |= 0x10000; + } + + if (Actor_ProcessTalkRequest(thisx, &globalCtx->state)) { + func_8019FDC8(&D_801DB4A4, NA_SE_VO_NA_LISTEN, 0x20); + thisx->focus.pos = thisx->world.pos; + + if (thisx->textId == ElfMessage_GetFirstCycleHint(globalCtx)) { + this->fairyFlags |= 0x80; + gSaveContext.tatlTimer = 3001; + } + + this->fairyFlags |= 0x10; + this->fairyFlags |= 0x20; + thisx->update = func_8088FE64; + func_8088C51C(this, 3); + if (this->elfMsg != NULL) { + this->elfMsg->flags |= 0x100; + thisx->cutscene = this->elfMsg->cutscene; + if (thisx->cutscene != -1) { + func_8088FD04(this); + } + if (this->elfMsg->home.rot.x == -0x961) { + this->unk_234 = this->elfMsg; + Actor_ChangeFocus(thisx, globalCtx, this->elfMsg); + } + } else { + thisx->cutscene = -1; + } + thisx->flags &= ~0x10000; + } else if (this->unk_264 & 4) { + thisx->focus.pos = thisx->world.pos; + this->fairyFlags |= 0x10; + this->fairyFlags |= 0x20; + thisx->update = func_8088FE64; + func_8088C51C(this, 3); + } else { + this->actionFunc(this, globalCtx); + + if (!func_801690CC(globalCtx)) { + if (gSaveContext.tatlTimer < 25800) { + gSaveContext.tatlTimer++; + } else if (!(this->fairyFlags & 0x80)) { + gSaveContext.tatlTimer = 0; + } + } + } + + this->elfMsg = NULL; + this->timer++; + + if ((this->unk_240 >= 0.0f) && func_800FD2B4(globalCtx, SQ(this->unk_240) * this->unk_240, + player->actor.projectedPos.z + 780.0f, 0.2f, 0.5f)) { + Math_StepToF(&this->unk_240, -0.05f, 0.05f); + } + + if (this->unk_269 > 0) { + this->unk_269--; + } + + if (!this->unk_269 && (globalCtx->csCtx.state != 0)) { + this->unk_269 = 1; + } +} + +void EnElf_Update(Actor* thisx, GlobalContext* globalCtx) { + EnElf* this = THIS; + + this->actionFunc(this, globalCtx); + + thisx->shape.rot.y = this->unk_258; + this->timer++; + + if (this->fairyFlags & 0x200) { + func_8088F9E4(thisx, globalCtx); + } +} + +s32 EnElf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + s32 pad; + EnElf* this = THIS; + Vec3f sp34; + f32 scale; + + if (limbIndex == 6) { + scale = ((Math_SinS(this->timer * 4096) * 0.1f) + 1.0f) * 0.012f; + if (this->fairyFlags & 0x200) { + scale *= 2.0f; + } + scale *= this->actor.scale.x * 124.99999f; + + Matrix_MultiplyVector3fByState(&zeroVec, &sp34); + Matrix_InsertTranslation(sp34.x, sp34.y, sp34.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + } + + if ((this->fairyFlags & 0x200) && + ((limbIndex == 4) || (limbIndex == 7) || (limbIndex == 11) || (limbIndex == 14))) { + *dList = NULL; + } + return false; +} + +void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnElf* this = THIS; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s32 pad2; + + if (player->currentMask != PLAYER_MASK_GIANT) { + if (!(this->fairyFlags & 8) && + (!func_800EE29C(globalCtx, 0xC9) || + (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0xC9)]->unk0 != 6)) && + (!(player->stateFlags1 & 0x100000) || (kREG(90) < this->actor.projectedPos.z))) { + Gfx* dListHead = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); + f32 alphaScale; + s32 envAlpha; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C94C(globalCtx->state.gfxCtx); + + envAlpha = (this->timer * 50) & 0x1FF; + envAlpha = (envAlpha >= 0x100) ? 511 - envAlpha : envAlpha; + + alphaScale = (this->disappearTimer < 0) ? (this->disappearTimer * 0.0011666666f) + 1.0f : 1.0f; + + gSPSegment(POLY_XLU_DISP++, 0x08, dListHead); + + gDPPipeSync(dListHead++); + gDPSetPrimColor(dListHead++, 0, 0x01, (u8)(s8)this->innerColor.r, (u8)(s8)this->innerColor.g, + (u8)(s8)this->innerColor.b, (u8)(s8)(this->innerColor.a * alphaScale)); + + if (this->fairyFlags & 4) { + gDPSetRenderMode(dListHead++, G_RM_PASS, G_RM_CLD_SURF2); + } else { + gDPSetRenderMode(dListHead++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + } + + gSPEndDisplayList(dListHead); + + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(s8)this->outerColor.r, (u8)(s8)this->outerColor.g, + (u8)(s8)this->outerColor.b, (u8)(s8)(envAlpha * alphaScale)); + + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + EnElf_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void func_808908D0(Vec3f* vec, GlobalContext* globalCtx, u32 action) { + Vec3f startPos; + Vec3f endPos; + CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[action]; + f32 lerp; + + startPos.x = npcAction->unk0C.x; + startPos.y = npcAction->unk0C.y; + startPos.z = npcAction->unk0C.z; + + endPos.x = npcAction->unk18.x; + endPos.y = npcAction->unk18.y; + endPos.z = npcAction->unk18.z; + + lerp = func_800F5A8C(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames, globalCtx); + VEC3F_LERPIMPDST(vec, &startPos, &endPos, lerp); +} diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.h b/src/overlays/actors/ovl_En_Elf/z_en_elf.h index 0bc20043cc..52c5e2af17 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.h +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.h @@ -6,12 +6,46 @@ struct EnElf; typedef void (*EnElfActionFunc)(struct EnElf*, GlobalContext*); +typedef void (*EnElfUnkFunc)(struct EnElf*, GlobalContext*); + +#define ENELF_GET_F(thisx) ((thisx)->params & 0xF) +#define ENELF_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) typedef struct EnElf { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x120]; - /* 0x0264 */ u16 unk264; - /* 0x0266 */ char unk_266[0xA]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[7]; + /* 0x01B2 */ Vec3s morphTable[7]; + /* 0x01DC */ Color_RGBAf innerColor; + /* 0x01EC */ Color_RGBAf outerColor; + /* 0x01FC */ LightInfo lightInfoGlow; + /* 0x020C */ LightNode* lightNodeGlow; + /* 0x0210 */ LightInfo lightInfoNoGlow; + /* 0x0220 */ LightNode* lightNodeNoGlow; + /* 0x0224 */ Vec3f unk_224; + /* 0x0230 */ Actor* elfMsg; + /* 0x0234 */ Actor* unk_234; + /* 0x0238 */ f32 unk_238; + /* 0x023C */ f32 unk_23C; + /* 0x0240 */ f32 unk_240; + /* 0x0244 */ s16 unk_244; + /* 0x0246 */ s16 unk_246; + /* 0x0248 */ s16 unk_248; + /* 0x024A */ s16 unk_24A; + /* 0x024C */ s16 unk_24C; + /* 0x0250 */ f32 unk_250; + /* 0x0254 */ f32 unk_254; + /* 0x0258 */ s16 unk_258; + /* 0x025A */ u16 timer; + /* 0x025C */ s16 unk_25C; + /* 0x025E */ s16 disappearTimer; + /* 0x0260 */ s16 unk_260; + /* 0x0262 */ u16 fairyFlags; + /* 0x0264 */ u16 unk_264; + /* 0x0266 */ u16 unk_266; + /* 0x0268 */ u8 unk_268; + /* 0x0269 */ u8 unk_269; + /* 0x026C */ EnElfUnkFunc unk_26C; /* 0x0270 */ EnElfActionFunc actionFunc; } EnElf; // size = 0x274 diff --git a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c index cd574fb318..e0eed3f3c0 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -62,7 +62,7 @@ void EnElfbub_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 16.0f, func_800B3FC0, 0.2f); + ActorShape_Init(&this->actor.shape, 16.0f, ActorShadow_DrawCircle, 0.2f); this->actor.hintId = 0x16; Actor_SetScale(&this->actor, 1.25f); @@ -117,7 +117,7 @@ void EnElfbub_Pop(EnElfbub* this, GlobalContext* globalCtx) { Rand_S16Offset(100, 50), 25, 0); } - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 60, NA_SE_EN_AWA_BREAK); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 60, NA_SE_EN_AWA_BREAK); Actor_MarkForDeath(&this->actor); } } @@ -143,7 +143,7 @@ void EnElfbub_Update(Actor* thisx, GlobalContext* globalCtx) { EnElfbub* this = THIS; Collider_UpdateCylinder(&this->actor, &this->collider); this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, this->actor.shape.yOffset); + Actor_SetFocus(&this->actor, this->actor.shape.yOffset); } void EnElfbub_Draw(Actor* thisx, GlobalContext* globalCtx2) { diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 6ca10601cd..65863f546d 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -5,6 +5,7 @@ */ #include "z_en_elforg.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000010 @@ -72,7 +73,8 @@ void EnElforg_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->flags = 0; this->direction = 0; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0402CA98, &D_0402B494, this->jointTable, this->jointTable, 10); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gStrayFairySkel, &gStrayFairyFlyingAnim, this->jointTable, + this->jointTable, STRAY_FAIRY_LIMB_MAX); this->skelAnime.playSpeed = 1.0f; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); this->actor.shape.shadowAlpha = 255; @@ -85,7 +87,7 @@ void EnElforg_Init(Actor* thisx, GlobalContext* globalCtx) { } break; case STRAY_FAIRY_TYPE_COLLECTIBLE: - if (Actor_GetCollectibleFlag(globalCtx, STRAY_FAIRY_FLAG(&this->actor))) { + if (Flags_GetCollectible(globalCtx, STRAY_FAIRY_FLAG(&this->actor))) { Actor_MarkForDeath(&this->actor); return; } @@ -224,7 +226,7 @@ void EnElforg_MoveToTargetFairyFountain(EnElforg* this, Vec3f* homePos) { targetAngle += angleAdjustment; Math_SmoothStepToS(&this->actor.world.rot.y, targetAngle, 2, 4000, 1000); EnElforg_ApproachTargetSpeedXZ(this); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } /** @@ -247,7 +249,7 @@ void EnElforg_MoveToTarget(EnElforg* this, Vec3f* targetPos) { Math_SmoothStepToS(&this->actor.world.rot.y, targetAngle, 10, 0x200, 0x80); } EnElforg_ApproachTargetSpeedXZ(this); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80ACCBB8(EnElforg* this, GlobalContext* globalCtx) { @@ -401,7 +403,7 @@ void EnElforg_ClockTownFairyCollected(EnElforg* this, GlobalContext* globalCtx) EnElforg_CirclePlayer(this, globalCtx); player->actor.freezeTimer = 100; player->stateFlags1 |= 0x20000000; - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { player->actor.freezeTimer = 0; player->stateFlags1 &= ~0x20000000; Actor_MarkForDeath(&this->actor); @@ -435,19 +437,19 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { } scaledYDistance = this->actor.playerHeightRel - (this->actor.shape.yOffset * this->actor.scale.y); - if (!func_801233E4(globalCtx)) { + if (!Player_InCsMode(&globalCtx->state)) { if ((this->actor.xzDistToPlayer < 30.0f) && (scaledYDistance < 12.0f) && (scaledYDistance > -68.0f)) { EnElforg_SetupFairyCollected(this, globalCtx); func_80115908(globalCtx, 48); switch (STRAY_FAIRY_TYPE(&this->actor)) { case STRAY_FAIRY_TYPE_COLLECTIBLE: - Actor_SetCollectibleFlag(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); + Flags_SetCollectible(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); break; case STRAY_FAIRY_TYPE_CHEST: - Actor_SetChestFlag(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); + Flags_SetTreasure(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); break; default: - Actor_SetSwitchFlag(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); + Flags_SetSwitch(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); break; } @@ -491,7 +493,7 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { Actor* EnElforg_GetHoldingEnemy(EnElforg* this, GlobalContext* globalCtx) { Actor* enemy; - for (enemy = globalCtx->actorCtx.actorList[ACTORCAT_ENEMY].first; enemy != NULL; enemy = enemy->next) { + for (enemy = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; enemy != NULL; enemy = enemy->next) { if ((enemy->home.pos.x == this->actor.home.pos.x) && (enemy->home.pos.y == this->actor.home.pos.y) && (enemy->home.pos.z == this->actor.home.pos.z)) { return enemy; @@ -507,7 +509,7 @@ void EnElforg_TrappedByEnemy(EnElforg* this, GlobalContext* globalCtx) { EnElforg_InitializeParams(this); this->actionFunc = EnElforg_FreeFloating; this->actor.draw = EnElforg_Draw; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHIBI_FAIRY_SAVED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHIBI_FAIRY_SAVED); } else { // The enemy is still alive, so have the Stray Fairy // track the enemy in case it's moving around. @@ -540,7 +542,7 @@ void EnElforg_HiddenByCollider(EnElforg* this, GlobalContext* globalCtx) { this->actor.draw = EnElforg_Draw; this->actor.world.pos.y += 40.0f; this->actor.home.pos.y += 40.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHIBI_FAIRY_SAVED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHIBI_FAIRY_SAVED); } else { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } @@ -575,13 +577,14 @@ s32 EnElforg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi EnElforg* this = THIS; if (this->direction < 0) { - if (limbIndex == 9) { + if (limbIndex == STRAY_FAIRY_LIMB_LEFT_FACING_HEAD) { *dList = NULL; } - } else if (limbIndex == 1) { + } else if (limbIndex == STRAY_FAIRY_LIMB_RIGHT_FACING_HEAD) { *dList = NULL; } - return 0; + + return false; } void EnElforg_Draw(Actor* thisx, GlobalContext* globalCtx) { @@ -589,22 +592,23 @@ void EnElforg_Draw(Actor* thisx, GlobalContext* globalCtx) { EnElforg* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); switch (this->area) { case STRAY_FAIRY_AREA_WOODFALL: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C908)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyWoodfallTexAnim)); break; case STRAY_FAIRY_AREA_SNOWHEAD: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C890)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairySnowheadTexAnim)); break; case STRAY_FAIRY_AREA_GREAT_BAY: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C980)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyGreatBayTexAnim)); break; case STRAY_FAIRY_AREA_STONE_TOWER: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C9F8)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyStoneTowerTexAnim)); break; default: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C818)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyClockTownTexAnim)); break; } Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h index 5195235a31..fbf982beb4 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h @@ -33,6 +33,20 @@ typedef enum { STRAY_FAIRY_AREA_MAX } StrayFairyArea; +typedef enum { + /* 0 */ STRAY_FAIRY_LIMB_NONE, + /* 1 */ STRAY_FAIRY_LIMB_RIGHT_FACING_HEAD, + /* 2 */ STRAY_FAIRY_LIMB_LEFT_WING, + /* 3 */ STRAY_FAIRY_LIMB_RIGHT_WING, + /* 4 */ STRAY_FAIRY_LIMB_GLOW, + /* 5 */ STRAY_FAIRY_LIMB_TORSO, + /* 6 */ STRAY_FAIRY_LIMB_RIGHT_ARM, + /* 7 */ STRAY_FAIRY_LIMB_PELVIS_AND_LEGS, + /* 8 */ STRAY_FAIRY_LIMB_LEFT_ARM, + /* 9 */ STRAY_FAIRY_LIMB_LEFT_FACING_HEAD, + /* 10 */ STRAY_FAIRY_LIMB_MAX, +} StrayFairyLimbs; + struct EnElforg; typedef void (*EnElforgActionFunc)(struct EnElforg*, GlobalContext*); @@ -40,11 +54,11 @@ typedef void (*EnElforgActionFunc)(struct EnElforg*, GlobalContext*); typedef struct EnElforg { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[10]; + /* 0x188 */ Vec3s jointTable[STRAY_FAIRY_LIMB_MAX]; /* 0x1C4 */ ColliderCylinder collider; /* 0x210 */ Actor* enemy; /* 0x214 */ u16 flags; - /* 0x216 */ s16 direction; // negative when facing left, positive when facing right + /* 0x216 */ s16 direction; // negative when facing right, positive when facing left /* 0x218 */ s16 area; /* 0x21C */ s32 timer; /* 0x220 */ s32 secondaryTimer; diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index f196fa54bb..58bf7e1fe7 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -109,7 +109,7 @@ void EnEncount2_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&D_06002420, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - ActorShape_Init(&this->dyna.actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->dyna.actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, &this->colElement); @@ -172,7 +172,7 @@ void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx) { EnEncount2_InitParticles(this, &curPos, 10); } - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_MUJURA_BALLOON_BROKEN); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_MUJURA_BALLOON_BROKEN); this->deathTimer = 30; this->actionFunc = EnEncount2_Die; } @@ -180,7 +180,7 @@ void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx) { void EnEncount2_Die(EnEncount2* this, GlobalContext* globalCtx) { if (this->deathTimer == 0) { if (this->switchFlag >= 0) { - Actor_SetSwitchFlag(globalCtx, this->switchFlag); + Flags_SetSwitch(globalCtx, this->switchFlag); } Actor_MarkForDeath(&this->dyna.actor); } @@ -193,10 +193,10 @@ void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx) { DECR(this->deathTimer); this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; - Actor_SetHeight(&this->dyna.actor, 30.0f); + Actor_SetFocus(&this->dyna.actor, 30.0f); Actor_SetScale(&this->dyna.actor, this->scale); this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->dyna.actor); + Actor_MoveWithGravity(&this->dyna.actor); EnEncount2_UpdateParticles(this, globalCtx); if (!this->isPopped) { @@ -209,8 +209,8 @@ void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx) { void EnEncount2_Draw(Actor* thisx, GlobalContext* globalCtx) { EnEncount2* this = THIS; if (this->isPopped != true) { - func_800BDFC0(globalCtx, D_06000A00); - func_800BDFC0(globalCtx, D_06000D78); + Gfx_DrawDListOpa(globalCtx, D_06000A00); + Gfx_DrawDListOpa(globalCtx, D_06000D78); } EnEncount2_DrawParticles(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c index e94c19f258..f483b3289d 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c +++ b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c @@ -49,7 +49,7 @@ void EnEndingHero_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 6; this->actor.gravity = -3.0f; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B0CC, &D_06000BE0, this->jointTable, this->morphTable, 15); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C1E748(this); } @@ -76,7 +76,7 @@ void EnEndingHero_Update(Actor* thisx, GlobalContext* globalCtx) { } } this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c index 045bf8deb2..8df6a328dd 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c +++ b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c @@ -41,7 +41,7 @@ void EnEndingHero2_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 6; this->actor.gravity = -3.0f; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06007908, &D_060011C0, this->jointTable, this->morphTable, 20); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C232E8(this); } @@ -61,7 +61,7 @@ void EnEndingHero2_Update(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero2* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c index 2f9c8391f3..b89196d58d 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c +++ b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c @@ -41,7 +41,7 @@ void EnEndingHero3_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 6; this->actor.gravity = -3.0f; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06007150, &D_06000E50, this->jointTable, this->morphTable, 17); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C23518(this); } @@ -61,7 +61,7 @@ void EnEndingHero3_Update(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero3* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c index fd5eae6249..5f2ad62224 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c +++ b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c @@ -41,7 +41,7 @@ void EnEndingHero4_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 6; this->actor.gravity = -3.0f; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600D640, &D_06002A84, this->jointTable, this->morphTable, 17); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C23748(this); } @@ -61,7 +61,7 @@ void EnEndingHero4_Update(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero4* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c index 77fc673085..3a8f317f55 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c +++ b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c @@ -47,7 +47,7 @@ void EnEndingHero5_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 6; this->actor.gravity = -3.0f; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600A850, &D_06002FA0, this->jointTable, this->morphTable, 17); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); this->unk25C = this->actor.params; func_80C23980(this); } @@ -68,7 +68,7 @@ void EnEndingHero5_Update(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero5* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c index d692d4f112..7af0874336 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c +++ b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c @@ -78,7 +78,7 @@ void EnEndingHero6_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -3.0f; SkelAnime_InitFlex(globalCtx, &this->skelAnime, sSkeletons[this->npcIndex], sAnimations[this->npcIndex], this->jointTable, this->morphTable, sLimbCounts[this->npcIndex]); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); EnEndingHero6_SetupIdle(this); } @@ -119,7 +119,7 @@ void EnEndingHero6_Update(Actor* thisx, GlobalContext* globalCtx) { } this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index 43582bf264..0474bc1323 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -1,10 +1,24 @@ /* * File: z_en_fall.c * Overlay: ovl_En_Fall - * Description: The Moon and related effects + * Description: The moon and related effects, along with the Moon's Tear that falls from its eye. + * + * This actor handles mutliple types of moon as well as a variety of effects. Specifically, it handles: + * - A high-detail moon, used in Termina Field, the Clock Tower, and a few cutscenes + * - A high-detail open-mouthed moon, used in the cutscene prior to warping to the moon's interior. + * - An enlarged high-detail moon, used for when the moon is crashing. + * - A low-detail moon, used everywhere else. Its object file is named "Lodmoon". + * - The Moon's Tear that can be seen falling from the telescope, along with its associated fire trail. + * - The ball of fire that surrounds the moon when it is crashing. + * - The debris that rises from the ground as the moon is crashing. + * - The ring of fire that expands outward when the moon is almost done crashing. */ #include "z_en_fall.h" +#include "objects/object_fall/object_fall.h" +#include "objects/object_fall2/object_fall2.h" +#include "objects/object_lodmoon/object_lodmoon.h" +#include "objects/object_moonston/object_moonston.h" #define FLAGS 0x00000030 @@ -14,16 +28,34 @@ void EnFall_Init(Actor* thisx, GlobalContext* globalCtx); void EnFall_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFall_Update(Actor* thisx, GlobalContext* globalCtx); -void func_80A6C3FC(EnFall* this, GlobalContext* globalCtx); -void func_80A6C9A8(EnFall* this, GlobalContext* globalCtx); -void func_80A6CA9C(EnFall* this, GlobalContext* globalCtx); -void func_80A6CB74(EnFall* this, GlobalContext* globalCtx); -void func_80A6CD38(EnFall* this, GlobalContext* globalCtx); -void func_80A6CD74(EnFall* this, GlobalContext* globalCtx); -void func_80A6CF60(EnFall* this, GlobalContext* globalCtx); -void func_80A6CF70(EnFall* this, GlobalContext* globalCtx); +void EnFall_Setup(EnFall* this, GlobalContext* globalCtx); +void EnFall_CrashingMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx); +void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx); +void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx); +void EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx); +void EnFall_Moon_PerformDefaultActions(EnFall* this, GlobalContext* globalCtx); +void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx); +void EnFall_FireBall_Update(Actor* thisx, GlobalContext* globalCtx); +void EnFall_RisingDebris_Update(Actor* thisx, GlobalContext* globalCtx); +void EnFall_FireRing_Update(Actor* thisx, GlobalContext* globalCtx); +void EnFall_Moon_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFall_OpenMouthMoon_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFall_LodMoon_DrawWithoutLerp(Actor* thisx, GlobalContext* globalCtx); +void EnFall_LodMoon_DrawWithLerp(Actor* thisx, GlobalContext* globalCtx); +void EnFall_FireBall_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFall_RisingDebris_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFall_FireRing_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFall_MoonsTear_Draw(Actor* thisx, GlobalContext* globalCtx); + +typedef struct { + u8 dListIndex; + Vec3f pos; + Vec3f velocity; + Vec3s rot; +} EnFallDebrisParticle; + +EnFallDebrisParticle debrisParticles[50]; -#if 0 const ActorInit En_Fall_InitVars = { ACTOR_EN_FALL, ACTORCAT_ITEMACTION, @@ -36,75 +68,792 @@ const ActorInit En_Fall_InitVars = { (ActorFunc)NULL, }; -#endif +/** + * Sets the scale of the moon depending on the current day. On the Final Day, + * it also moves the moon closer to the ground depending on the current time. + */ +void EnFall_Moon_AdjustScaleAndPosition(EnFall* this, GlobalContext* globalCtx) { + u16 currentTime = gSaveContext.time; + u16 dayStartTime = this->dayStartTime; + f32 finalDayRelativeHeight; -extern UNK_TYPE D_06000198; -extern UNK_TYPE D_060004C0; -extern UNK_TYPE D_060010E0; -extern UNK_TYPE D_060011D0; -extern UNK_TYPE D_06001220; -extern UNK_TYPE D_06002970; -extern UNK_TYPE D_06004E38; -extern UNK_TYPE D_060077F0; + if (currentTime < dayStartTime) { + finalDayRelativeHeight = 1.0f - (((f32)dayStartTime - (f32)currentTime) * (1.0f / 0x10000)); + } else { + finalDayRelativeHeight = ((f32)currentTime - (f32)dayStartTime) * (1.0f / 0x10000); + } + switch (CURRENT_DAY) { + case 0: + Actor_SetScale(&this->actor, this->scale * 1.2f); + this->actor.world.pos.y = this->actor.home.pos.y; + break; + case 1: + Actor_SetScale(&this->actor, this->scale * 2.4f); + this->actor.world.pos.y = this->actor.home.pos.y; + break; + case 2: + Actor_SetScale(&this->actor, this->scale * 3.6f); + this->actor.world.pos.y = this->actor.home.pos.y; + break; + case 3: + Actor_SetScale(&this->actor, this->scale * 3.6f); + if (EN_FALL_TYPE(&this->actor) == EN_FALL_TYPE_LODMOON_INVERTED_STONE_TOWER) { + this->actor.world.pos.y = + this->actor.home.pos.y + (finalDayRelativeHeight * 6700.0f * (this->scale * 6.25f)); + } else { + this->actor.world.pos.y = + this->actor.home.pos.y - (finalDayRelativeHeight * 6700.0f * (this->scale * 6.25f)); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6BF90.s") +void EnFall_RisingDebris_ResetParticles(EnFall* this) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6C1DC.s") + for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { + debrisParticles[i].dListIndex = 3; + } + this->activeDebrisParticleCount = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/EnFall_Init.s") +void EnFall_Init(Actor* thisx, GlobalContext* globalCtx) { + EnFall* this = THIS; + s32 objectIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/EnFall_Destroy.s") + this->eyeGlowIntensity = 0.0f; + this->flags = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6C3AC.s") + // This system is basically never used in the final game; all instances + // of EnFall will use the default case. + switch (EN_FALL_SCALE(&this->actor)) { + case 1: + this->scale = 0.08f; + break; + case 2: + this->scale = 0.04f; + break; + case 3: + this->scale = 0.02f; + break; + case 4: + this->scale = 0.01f; + break; + default: + this->scale = 0.16f; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6C3FC.s") + switch (EN_FALL_TYPE(&this->actor)) { + case EN_FALL_TYPE_LODMOON_NO_LERP: + case EN_FALL_TYPE_LODMOON: + case EN_FALL_TYPE_LODMOON_INVERTED_STONE_TOWER: + objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_LODMOON); + break; + case EN_FALL_TYPE_MOONS_TEAR: + objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MOONSTON); + break; + case EN_FALL_TYPE_STOPPED_MOON_OPEN_MOUTH: + objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_FALL2); + break; + default: + objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_FALL); + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6C7C0.s") + if (objectIndex < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + this->objIndex = objectIndex; + this->actionFunc = EnFall_Setup; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6C9A8.s") +void EnFall_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6CA9C.s") +/** + * Finds the Termina Field moon so the Moon's Tear can spawn in the correct place. + */ +Actor* EnFall_MoonsTear_GetTerminaFieldMoon(GlobalContext* globalCtx) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6CB74.s") + while (itemAction != NULL) { + if (itemAction->id == ACTOR_EN_FALL && EN_FALL_TYPE(itemAction) == EN_FALL_TYPE_TERMINA_FIELD_MOON) { + return itemAction; + } + itemAction = itemAction->next; + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6CD38.s") +void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { + Actor* moon; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6CD74.s") + if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { + this->actor.objBankIndex = this->objIndex; + this->actionFunc = EnFall_Moon_PerformDefaultActions; + switch (EN_FALL_TYPE(&this->actor)) { + case EN_FALL_TYPE_TITLE_SCREEN_MOON: + this->actor.draw = EnFall_Moon_Draw; + this->actionFunc = EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions; + Actor_SetScale(&this->actor, this->scale); + break; + case EN_FALL_TYPE_STOPPED_MOON_CLOSED_MOUTH: + this->actor.draw = EnFall_Moon_Draw; + this->actionFunc = EnFall_StoppedClosedMouthMoon_PerformCutsceneActions; + Actor_SetScale(&this->actor, this->scale * 3.0f); + if (!(gSaveContext.weekEventReg[0x19] & 2)) { + Actor_MarkForDeath(&this->actor); + } + break; + case EN_FALL_TYPE_CLOCK_TOWER_MOON: + this->actionFunc = EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions; + Actor_SetScale(&this->actor, this->scale * 3.0f); + this->actor.draw = EnFall_Moon_Draw; + if (gSaveContext.weekEventReg[0x19] & 2) { + Actor_MarkForDeath(&this->actor); + } + break; + case EN_FALL_TYPE_CRASHING_MOON: + this->actor.draw = EnFall_Moon_Draw; + Actor_SetScale(&this->actor, this->scale * 5.3999996f); + this->actionFunc = EnFall_CrashingMoon_PerformCutsceneActions; + break; + case EN_FALL_TYPE_CRASH_FIRE_BALL: + this->actor.update = EnFall_FireBall_Update; + this->actor.draw = EnFall_FireBall_Draw; + this->scale = 1.0f; + this->actor.shape.rot.z = 0; + this->fireBallIntensity = 0.0f; + this->fireBallAlpha = 100; + this->actor.shape.rot.x = this->actor.shape.rot.z; + break; + case EN_FALL_TYPE_CRASH_RISING_DEBRIS: + this->actor.update = EnFall_RisingDebris_Update; + this->actor.draw = EnFall_RisingDebris_Draw; + this->scale = 1.0f; + EnFall_RisingDebris_ResetParticles(this); + Actor_SetScale(&this->actor, 1.0f); + this->actor.shape.rot.x = 0; + break; + case EN_FALL_TYPE_LODMOON_NO_LERP: + this->actor.draw = EnFall_LodMoon_DrawWithoutLerp; + this->dayStartTime = CLOCK_TIME(6, 0); + this->currentDay = CURRENT_DAY; + EnFall_Moon_AdjustScaleAndPosition(this, globalCtx); + break; + case EN_FALL_TYPE_LODMOON: + case EN_FALL_TYPE_LODMOON_INVERTED_STONE_TOWER: + this->actor.draw = EnFall_LodMoon_DrawWithLerp; + this->dayStartTime = CLOCK_TIME(6, 0); + this->currentDay = CURRENT_DAY; + EnFall_Moon_AdjustScaleAndPosition(this, globalCtx); + break; + case EN_FALL_TYPE_MOONS_TEAR: + this->actor.update = EnFall_Update; + this->actor.draw = NULL; + this->actionFunc = EnFall_MoonsTear_Fall; + Actor_SetScale(&this->actor, 0.02f); + if (!(globalCtx->actorCtx.unk5 & 2)) { + Actor_MarkForDeath(&this->actor); + } + moon = EnFall_MoonsTear_GetTerminaFieldMoon(globalCtx); + this->actor.child = moon; + if (moon == NULL) { + Actor_MarkForDeath(&this->actor); + } + break; + case EN_FALL_TYPE_STOPPED_MOON_OPEN_MOUTH: + this->actor.draw = NULL; + this->actionFunc = EnFall_StoppedOpenMouthMoon_PerformCutsceneActions; + Actor_SetScale(&this->actor, this->scale * 3.0f); + break; + case EN_FALL_TYPE_CRASH_FIRE_RING: + this->actor.update = EnFall_FireRing_Update; + this->actor.draw = EnFall_FireRing_Draw; + Actor_SetScale(&this->actor, 0.2f); + break; + default: + this->actor.draw = EnFall_Moon_Draw; + this->dayStartTime = CLOCK_TIME(6, 0); + this->currentDay = CURRENT_DAY; + EnFall_Moon_AdjustScaleAndPosition(this, globalCtx); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6CECC.s") +void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globalCtx) { + static s32 sGiantsCutsceneState = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6CF60.s") + if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 1 && globalCtx->csCtx.unk_12 == 0) { + switch (sGiantsCutsceneState) { + case 0: + if (globalCtx->csCtx.state != 0) { + sGiantsCutsceneState += 2; + } + break; + 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.weekEventReg[0x5D] & 4) { + if (ActorCutscene_GetCanPlayNext(0xC)) { + ActorCutscene_Start(0xC, &this->actor); + sGiantsCutsceneState++; + } else { + ActorCutscene_SetIntentToPlay(0xC); + } + } else if (ActorCutscene_GetCanPlayNext(0xB)) { + ActorCutscene_Start(0xB, &this->actor); + gSaveContext.weekEventReg[0x5D] |= 4; + sGiantsCutsceneState++; + } else { + ActorCutscene_SetIntentToPlay(0xB); + } + } else if (globalCtx->csCtx.frames > 1600) { + globalCtx->nextEntranceIndex = 0x2C00; + gSaveContext.nextCutsceneIndex = 0xFFF2; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; + gSaveContext.nextTransition = 2; + sGiantsCutsceneState = 9; + } + break; + case 9: + globalCtx->csCtx.frames--; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6CF70.s") +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) { + 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)); + } + } + } else { + this->actor.draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/EnFall_Update.s") +void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { + if (func_800EE29C(globalCtx, 0x85)) { + switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0) { + case 3: + if (this->eyeGlowIntensity == 0.0f) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MOON_EYE_FLASH); + } + this->eyeGlowIntensity += 0.033333335f; + if (this->eyeGlowIntensity > 1.0f) { + this->eyeGlowIntensity = 1.0f; + } + break; + case 4: + this->actor.draw = EnFall_OpenMouthMoon_Draw; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6D100.s") +void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { + if (func_800EE29C(globalCtx, 0x85)) { + switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0) { + case 2: + func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x85)); + break; + case 4: + this->actor.draw = NULL; + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6D220.s") + if (globalCtx->sceneNum == SCENE_OKUJOU && gSaveContext.sceneSetupIndex == 2) { + switch (globalCtx->csCtx.unk_12) { + case 0: + switch (globalCtx->csCtx.frames) { + case 1060: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MOON_SCREAM1); + break; + case 1089: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MOON_CRY); + break; + case 1303: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIP_MOON); + break; + } + if (globalCtx->csCtx.frames >= 1145) { + func_800B9010(&this->actor, NA_SE_EV_FALL_POWER - SFX_FLAG); + } + break; + case 1: + switch (globalCtx->csCtx.frames) { + case 561: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MOON_SCREAM1); + break; + case 590: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MOON_CRY); + break; + case 737: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIP_MOON); + break; + } + if (globalCtx->csCtx.frames >= 650) { + func_800B9010(&this->actor, NA_SE_EV_FALL_POWER - SFX_FLAG); + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6D444.s") +void EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != 0 && globalCtx->sceneNum == SCENE_OKUJOU) { + func_800B9010(&this->actor, NA_SE_EV_MOON_FALL - SFX_FLAG); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6D504.s") +/** + * This is rarely used in the final game. One example of where it *is* used + * is when the moon is crashing; there is a second, smaller moon hidden within + * the larger moon that uses this action function. + */ +void EnFall_Moon_PerformDefaultActions(EnFall* this, GlobalContext* globalCtx) { + u16 currentDay; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6D698.s") + if (func_800EE29C(globalCtx, 0x85)) { + if (func_800EE29C(globalCtx, 0x85) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0 == 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)); + } + } + } else { + if (this->actor.draw == NULL) { + this->actor.draw = EnFall_Moon_Draw; + } + currentDay = CURRENT_DAY; + if ((u16)this->currentDay != (u32)currentDay) { + this->currentDay = currentDay; + this->dayStartTime = gSaveContext.time; + } + EnFall_Moon_AdjustScaleAndPosition(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6D75C.s") +void EnFall_MoonsTear_Initialize(EnFall* this) { + s32 pad[2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6D88C.s") + this->actor.draw = EnFall_MoonsTear_Draw; + if (this->actor.child != NULL) { + // The focus of the child needs to be shifted in EnFall_Moon_Draw first, + // otherwise the tear will spawn in the wrong place. + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.child->focus.pos); + } + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); + this->actor.world.rot.x = Math_Vec3f_Pitch(&this->actor.world.pos, &this->actor.home.pos); + this->actor.speedXZ = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->actor.home.pos) / 82.0f; + this->actor.shape.rot.x = this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6D98C.s") +void EnFall_DoNothing(EnFall* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6DA7C.s") +void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6DC20.s") + if (func_800EE29C(globalCtx, 0x205) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x205)]->unk0 == 2 && + this->actor.draw == NULL) { + EnFall_MoonsTear_Initialize(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6DC40.s") + 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.weekEventReg[0x4A] |= 0x80; + gSaveContext.weekEventReg[0x4A] |= 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, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_EXPLOSION); + this->actor.draw = NULL; + this->actionFunc = EnFall_DoNothing; + } else { + func_800B9010(&this->actor, NA_SE_EV_MOONSTONE_FALL - SFX_FLAG); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6DD3C.s") +void EnFall_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFall* this = THIS; + this->actionFunc(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6E07C.s") +/** + * Updates the alpha for every vertex in the fire ball so that some parts of + * the sphere are more transparent or opaque than others. + */ +void EnFall_FireBall_SetPerVertexAlpha(f32 fireBallAlpha) { + static u8 sAlphaTableIndex[] = { + 4, 4, 0, 1, 1, 1, 1, 1, 1, 3, 3, 0, 0, 3, 0, 1, 1, 1, 4, 0, 4, 0, 1, 1, 1, 3, 0, 3, 0, 1, 1, 1, 4, 4, 1, + 1, 0, 4, 4, 0, 1, 1, 1, 1, 1, 1, 3, 3, 0, 0, 3, 3, 0, 0, 1, 1, 1, 1, 1, 4, 0, 4, 4, 0, 4, 4, 1, 1, 1, 1, + 1, 1, 3, 3, 0, 0, 3, 3, 0, 0, 1, 1, 1, 1, 1, 1, 4, 4, 0, 4, 0, 1, 1, 1, 3, 0, 3, 3, 0, 0, 1, 1, 1, 1, 1, + 1, 4, 4, 0, 4, 4, 0, 1, 1, 1, 1, 1, 1, 3, 3, 0, 0, 0, 0, 0, 2, 2, 1, 1, 0, 0, 2, 2, 0, 1, 1, 0, 0, 1, 0, + 2, 0, 0, 1, 0, 2, 0, 0, 2, 1, 2, 0, 1, 0, 1, 0, 0, 1, 2, 2, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0, 0, 2, 2, 0, 0, + 0, 0, 2, 0, 2, 2, 0, 1, 1, 0, 0, 1, 0, 0, 1, 2, 2, 0, 0, 0, 2, 2, 1, 1, 0, 0, 1, 1, 0, 0, 2, 2, 0, 0, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6E214.s") + s32 pad; + u8 perVertexAlphaTable[5]; + Vtx* vertices = Lib_SegmentedToVirtual(&object_fall_Vtx_0004C0); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall/func_80A6E37C.s") + if (fireBallAlpha > 1.0f) { + fireBallAlpha = 1.0f; + } + perVertexAlphaTable[0] = 0; + perVertexAlphaTable[1] = (s8)(255.0f * fireBallAlpha); + perVertexAlphaTable[2] = (s8)(155.0f * fireBallAlpha); + perVertexAlphaTable[3] = (s8)(104.0f * fireBallAlpha); + perVertexAlphaTable[4] = (s8)(54.0f * fireBallAlpha); + + for (i = 0; i < ARRAY_COUNT(sAlphaTableIndex); i++, vertices++) { + vertices->v.cn[3] = perVertexAlphaTable[sAlphaTableIndex[i]]; + } +} + +void EnFall_FireBall_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFall* this = THIS; + + if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 0 && globalCtx->csCtx.unk_12 == 2) { + globalCtx->skyboxCtx.rotY -= 0.05f; + } + + if (func_800EE29C(globalCtx, 0x1C2)) { + this->actor.draw = EnFall_FireBall_Draw; + if (this->flags & EN_FALL_FLAG_FIRE_BALL_INTENSIFIES) { + this->fireBallIntensity += 0.01f; + if (this->fireBallIntensity > 1.0f) { + this->fireBallIntensity = 1.0f; + } + } + func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x1C2)); + + switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1C2)]->unk0) { + default: + this->actor.draw = NULL; + this->fireBallAlpha = 0; + break; + case 2: + if (this->fireBallAlpha < 100) { + this->fireBallAlpha += 4; + } + if (this->fireBallAlpha > 100) { + this->fireBallAlpha = 100; + } + EnFall_FireBall_SetPerVertexAlpha(this->fireBallAlpha * 0.01f); + break; + case 3: + if (this->fireBallAlpha > 0) { + this->fireBallAlpha -= 2; + } + if (this->fireBallAlpha < 0) { + this->fireBallAlpha = 0; + } + EnFall_FireBall_SetPerVertexAlpha(this->fireBallAlpha * 0.01f); + break; + case 4: + this->flags |= EN_FALL_FLAG_FIRE_BALL_INTENSIFIES; + break; + case 5: + break; + } + } else { + this->actor.draw = NULL; + } + + if (func_800EE29C(globalCtx, 0x1C2) && this->fireBallAlpha > 0) { + func_8019F128(NA_SE_EV_MOON_FALL_LAST - SFX_FLAG); + } + Actor_SetScale(&this->actor, this->scale * 1.74f); +} + +void EnFall_RisingDebris_UpdateParticles(EnFall* this) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { + if (debrisParticles[i].dListIndex < 3) { + debrisParticles[i].pos.x += debrisParticles[i].velocity.x; + debrisParticles[i].pos.y += debrisParticles[i].velocity.y; + debrisParticles[i].pos.z += debrisParticles[i].velocity.z; + debrisParticles[i].rot.x += 0x64; + debrisParticles[i].rot.y += 0xC8; + debrisParticles[i].rot.z += 0x12C; + if ((this->actor.world.pos.y + 3000.0f) < debrisParticles[i].pos.y) { + debrisParticles[i].dListIndex = 3; + this->activeDebrisParticleCount--; + } + } + } +} + +s32 EnFall_RisingDebris_InitializeParticles(EnFall* this) { + s16 angle; + s32 i; + f32 scale; + + for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { + if (debrisParticles[i].dListIndex >= 3) { + debrisParticles[i].dListIndex = (s32)Rand_ZeroFloat(3.0f); + debrisParticles[i].pos.x = this->actor.world.pos.x; + debrisParticles[i].pos.y = this->actor.world.pos.y; + debrisParticles[i].pos.z = this->actor.world.pos.z; + angle = randPlusMinusPoint5Scaled(0x10000); + scale = (1.0f - (Rand_ZeroFloat(1.0f) * Rand_ZeroFloat(1.0f))) * 3000.0f; + debrisParticles[i].pos.x += Math_SinS(angle) * scale; + debrisParticles[i].pos.z += Math_CosS(angle) * scale; + debrisParticles[i].velocity.x = 0.0f; + debrisParticles[i].velocity.z = 0.0f; + debrisParticles[i].velocity.y = 80.0f; + debrisParticles[i].rot.x = randPlusMinusPoint5Scaled(0x10000); + debrisParticles[i].rot.y = randPlusMinusPoint5Scaled(0x10000); + debrisParticles[i].rot.z = randPlusMinusPoint5Scaled(0x10000); + this->activeDebrisParticleCount++; + return true; + } + } + + return false; +} + +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) { + EnFall_RisingDebris_UpdateParticles(this); + EnFall_RisingDebris_InitializeParticles(this); + } else if (this->activeDebrisParticleCount != 0) { + EnFall_RisingDebris_ResetParticles(this); + } + } else if (thisx->home.rot.x != 0) { + EnFall_RisingDebris_UpdateParticles(this); + EnFall_RisingDebris_InitializeParticles(this); + } +} + +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 (!(this->flags & EN_FALL_FLAG_FIRE_RING_APPEARS)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_DM_RING_EXPLOSION); + } + this->flags |= EN_FALL_FLAG_FIRE_RING_APPEARS; + } + if (this->flags & EN_FALL_FLAG_FIRE_RING_APPEARS) { + this->fireRingAlpha += 0.033333335f; + if (this->fireRingAlpha > 1.0f) { + this->fireRingAlpha = 1.0f; + } + if (this->actor.scale.x < 18.0f) { + this->actor.scale.x += 0.2f; + } + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = Math_SinS(this->fireWallYScale) * 5.0f; + if (this->fireWallYScale < 0x4000) { + this->fireWallYScale += 0x147; + } + } +} + +void EnFall_Moon_Draw(Actor* thisx, GlobalContext* globalCtx) { + // This offsets the moon's focus so that the Moon's Tear actually falls + // out of its eye when looking at it through the telescope. + static Vec3f sFocusOffset[] = { 1800.0f, 1000.0f, 4250.0f }; + EnFall* this = THIS; + s32 primColor; + + 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); + Matrix_MultiplyVector3fByState(sFocusOffset, &this->actor.focus.pos); + primColor = (this->eyeGlowIntensity * 200.0f) + 40.0f; + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, primColor, primColor, primColor, 255); + gSPDisplayList(POLY_OPA_DISP++, object_fall_DL_0077F0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFall_OpenMouthMoon_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnFall* this = THIS; + s32 primColor; + + 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); + primColor = (this->eyeGlowIntensity * 200.0f) + 40.0f; + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, primColor, primColor, primColor, 255); + gSPDisplayList(POLY_OPA_DISP++, object_fall2_DL_002970); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFall_LodMoon_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFall* this = THIS; + s32 primColor; + + 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); + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 20, 25, 30, 0, 0x3E7, 0x3200); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); + gSPLoadGeometryMode(POLY_OPA_DISP++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); + primColor = (this->eyeGlowIntensity * 200.0f) + 40.0f; + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, primColor, primColor, primColor, 255); + gSPDisplayList(POLY_OPA_DISP++, object_lodmoon_DL_0010E0); + gSPLoadGeometryMode(POLY_OPA_DISP++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH); + gSPDisplayList(POLY_OPA_DISP++, object_lodmoon_DL_001158); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFall_LodMoon_DrawWithoutLerp(Actor* thisx, GlobalContext* globalCtx) { + EnFall_LodMoon_Draw(thisx, globalCtx); +} + +/** + * If the moon is more than 9000 units away from the eye, this will lerp it + * to be 9000 units away before drawing it. + */ +void EnFall_LodMoon_DrawWithLerp(Actor* thisx, GlobalContext* globalCtx) { + f32 distanceToEye = Actor_DistanceToPoint(thisx, &globalCtx->view.eye); + f32 scale; + Vec3f translation; + + if (distanceToEye > 9000.0f) { + scale = 9000.0f / distanceToEye; + translation.x = (-(globalCtx->view.eye.x - thisx->world.pos.x) * scale) + globalCtx->view.eye.x; + translation.y = (-(globalCtx->view.eye.y - thisx->world.pos.y) * scale) + globalCtx->view.eye.y; + translation.z = (-(globalCtx->view.eye.z - thisx->world.pos.z) * scale) + globalCtx->view.eye.z; + Matrix_InsertTranslation(translation.x, translation.y, translation.z, MTXMODE_NEW); + Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); + Matrix_RotateY(thisx->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(thisx->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(thisx->shape.rot.z, MTXMODE_APPLY); + } + EnFall_LodMoon_Draw(thisx, globalCtx); +} + +void EnFall_FireBall_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFall* this = THIS; + u32 gameplayFrames = globalCtx->gameplayFrames; + + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(globalCtx->state.gfxCtx); + this->fireBallYTexScroll1 += (s32)(4.0f + (this->fireBallIntensity * 12.0f)); + this->fireBallYTexScroll2 += (s32)(2.0f + (this->fireBallIntensity * 6.0f)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, + (s32)(((1.0f - this->fireBallIntensity) * 160.0f) + (255.0f * this->fireBallIntensity)), + (s32)((70.0f * (1.0f - this->fireBallIntensity)) + (255.0f * this->fireBallIntensity)), + (s32)(70.0f * (1.0f - this->fireBallIntensity)), 255); + gDPSetEnvColor( + POLY_XLU_DISP++, (s32)(((1.0f - this->fireBallIntensity) * 50.0f) + (200.0f * this->fireBallIntensity)), + (s32)(20.0f * (1.0f - this->fireBallIntensity)), (s32)(20.0f * (1.0f - this->fireBallIntensity)), 255); + + // Glowing sphere of fire + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, gameplayFrames, -this->fireBallYTexScroll2, 64, 64, 1, + -gameplayFrames, -this->fireBallYTexScroll1, 64, 64)); + + // "Flecks" of fire + gSPSegment(POLY_XLU_DISP++, 0x0A, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, gameplayFrames * 2, -this->fireBallYTexScroll1, 64, 64, 1, + -gameplayFrames * 2, -this->fireBallYTexScroll1, 64, 64)); + + gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); + gSPDisplayList(POLY_XLU_DISP++, object_fall_DL_0011D0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFall_RisingDebris_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* sDebrisDLists[] = { object_fall_DL_000220, object_fall_DL_000428, object_fall_DL_000498 }; + EnFall* this = THIS; + f32 scale = this->scale * 0.06f; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, object_fall_DL_000198); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { + if (debrisParticles[i].dListIndex < 3) { + Matrix_InsertTranslation(debrisParticles[i].pos.x, debrisParticles[i].pos.y, debrisParticles[i].pos.z, + MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_InsertRotation(debrisParticles[i].rot.x, debrisParticles[i].rot.y, debrisParticles[i].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++, sDebrisDLists[debrisParticles[i].dListIndex]); + } + } + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFall_FireRing_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFall* this = THIS; + + if (!(this->fireRingAlpha <= 0.0f)) { + if (this->fireRingAlpha > 1.0f) { + this->fireRingAlpha = 1.0f; + } + OPEN_DISPS(globalCtx->state.gfxCtx); + AnimatedMat_DrawXlu(globalCtx, Lib_SegmentedToVirtual(&object_fall_Matanimheader_004E38)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(globalCtx->state.gfxCtx); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, (s32)(this->fireRingAlpha * 255.0f)); + gSPDisplayList(POLY_XLU_DISP++, object_fall_DL_003C30); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnFall_MoonsTear_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_moonston_Matanimheader_001220)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, object_moonston_DL_000400); + Matrix_Scale(3.0f, 3.0f, 6.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); + gSPDisplayList(POLY_XLU_DISP++, object_moonston_DL_0004C8); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.h b/src/overlays/actors/ovl_En_Fall/z_en_fall.h index fb149f7e54..0124087d95 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.h +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.h @@ -3,14 +3,54 @@ #include "global.h" +#define EN_FALL_SCALE(thisx) ((thisx)->params & 0x7F) +#define EN_FALL_TYPE(thisx) (((thisx)->params & 0xF80) >> 7) + +#define EN_FALL_FLAG_FIRE_BALL_INTENSIFIES (1 << 0) +#define EN_FALL_FLAG_FIRE_RING_APPEARS (1 << 1) + +typedef enum { + /* 0 */ EN_FALL_TYPE_TERMINA_FIELD_MOON, + /* 1 */ EN_FALL_TYPE_TITLE_SCREEN_MOON, + /* 2 */ EN_FALL_TYPE_CRASHING_MOON, + /* 3 */ EN_FALL_TYPE_CRASH_FIRE_BALL, + /* 4 */ EN_FALL_TYPE_CRASH_RISING_DEBRIS, + /* 5 */ EN_FALL_TYPE_LODMOON_NO_LERP, // unused in final game + /* 6 */ EN_FALL_TYPE_LODMOON, + /* 7 */ EN_FALL_TYPE_STOPPED_MOON_CLOSED_MOUTH, + /* 8 */ EN_FALL_TYPE_MOONS_TEAR, + /* 9 */ EN_FALL_TYPE_CLOCK_TOWER_MOON, + /* 10 */ EN_FALL_TYPE_STOPPED_MOON_OPEN_MOUTH, + /* 11 */ EN_FALL_TYPE_CRASH_FIRE_RING, + /* 12 */ EN_FALL_TYPE_LODMOON_INVERTED_STONE_TOWER, +} EnFallType; + struct EnFall; typedef void (*EnFallActionFunc)(struct EnFall*, GlobalContext*); typedef struct EnFall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; - /* 0x0160 */ EnFallActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 dayStartTime; + /* 0x146 */ s16 currentDay; + /* 0x148 */ u8 objIndex; + /* 0x14C */ f32 scale; + /* 0x150 */ union { + f32 eyeGlowIntensity; + f32 fireBallIntensity; + f32 fireRingAlpha; + }; + /* 0x154 */ u16 flags; + /* 0x158 */ union { + s32 fireBallAlpha; + s32 activeDebrisParticleCount; + }; + /* 0x15C */ union { + s16 fireBallYTexScroll1; + s16 fireWallYScale; + }; + /* 0x15E */ s16 fireBallYTexScroll2; + /* 0x160 */ EnFallActionFunc actionFunc; } EnFall; // size = 0x164 extern const ActorInit En_Fall_InitVars; diff --git a/src/overlays/actors/ovl_En_Fg/z_en_fg.c b/src/overlays/actors/ovl_En_Fg/z_en_fg.c index f91ee7a312..6123310541 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -184,7 +184,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { switch (EnFg_GetDamageEffect(this)) { case FG_DMGEFFECT_DEKUSTICK: this->actor.flags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_CRY_1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_1); this->skelAnime.playSpeed = 0.0f; this->actor.shape.shadowDraw = NULL; this->actor.scale.x *= 1.5f; @@ -210,7 +210,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { break; case FG_DMGEFFECT_EXPLOSION: this->actor.flags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_CRY_0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_0); if (1) {} this->actor.params = FG_BLACK; this->skelAnime.playSpeed = 0.0f; @@ -226,14 +226,14 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { break; default: if (DECR(this->timer) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_JUMP); EnFg_UpdateAnimation(&this->skelAnime, 3); this->actor.velocity.y = 10.0f; this->timer = Rand_S16Offset(30, 30); this->actionFunc = EnFg_Jump; } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { @@ -261,7 +261,7 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { break; case FG_DMGEFFECT_EXPLOSION: this->actor.flags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_CRY_0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_0); EnFg_UpdateAnimation(&this->skelAnime, 0); this->actor.params = FG_BLACK; this->skelAnime.playSpeed = 0.0f; @@ -286,7 +286,7 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { this->actionFunc = EnFg_Idle; this->actor.velocity.y = 0.0f; } else { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } } } @@ -313,14 +313,14 @@ void EnFg_Knockback(EnFg* this, GlobalContext* globalCtx) { EnFg_AddDust(&this->dustEffect[0], &this->actor.world.pos); } this->actor.shape.rot.x += 0x1000; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } } void EnFg_Init(Actor* thisx, GlobalContext* globalCtx) { EnFg* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 10.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B538, NULL, this->jointTable, this->morphTable, 24); EnFg_UpdateAnimation(&this->skelAnime, 0); Collider_InitCylinder(globalCtx, &this->collider); diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index 32d5d5e819..5c5952cc6b 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -127,7 +127,7 @@ void EnFirefly_Init(Actor* thisx, GlobalContext* globalCtx) { EnFirefly* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &D_060018B8, &D_0600017C, this->jointTable, this->morphTable, 28); Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -173,7 +173,7 @@ void EnFirefly_SpawnIceEffects(EnFirefly* this, GlobalContext* globalCtx) { if (this->unk_18F == 0xA) { this->unk_18F = 0; this->unk_2E8.x = 0.0f; - func_800BF7CC(globalCtx, &this->actor, &this->unk_2F8, 3, 2, 0.2f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, &this->unk_2F8, 3, 2, 0.2f, 0.2f); } } @@ -223,7 +223,7 @@ s32 EnFirefly_ReturnToPerch(EnFirefly* this, GlobalContext* globalCtx) { } s32 EnFirefly_SeekTorch(EnFirefly* this, GlobalContext* globalCtx) { - ObjSyokudai* findTorch = (ObjSyokudai*)globalCtx->actorCtx.actorList[ACTORCAT_PROP].first; + ObjSyokudai* findTorch = (ObjSyokudai*)globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; ObjSyokudai* closestTorch = NULL; f32 currentMinDist = 35000.0f; f32 currentDist; @@ -332,13 +332,13 @@ void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) { this->timer = 40; this->actor.velocity.y = 0.0f; Animation_Change(&this->skelAnime, &D_0600017C, 0.0f, 6.0f, 6.0f, 2, 0.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_DEAD); this->actor.flags |= 0x10; if (this->isInvisible) { - func_800BCB70(&this->actor, 0x4000, 255, 0x2000, 40); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0x2000, 40); } else { - func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); } if (this->actor.colChkInfo.damageEffect == 3) { @@ -431,7 +431,7 @@ void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 8) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300); Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2800)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2800)) { if (Animation_OnFrame(&this->skelAnime, 4.0f)) { this->skelAnime.playSpeed = 0.0f; this->skelAnime.curFrame = 4.0f; @@ -534,9 +534,9 @@ void EnFirefly_FlyAway(EnFirefly* this, GlobalContext* globalCtx) { void EnFirefly_SetupStunned(EnFirefly* this) { if (this->isInvisible) { - func_800BCB70(&this->actor, 0, 255, 0x2000, this->timer); + Actor_SetColorFilter(&this->actor, 0, 255, 0x2000, this->timer); } else { - func_800BCB70(&this->actor, 0, 255, 0, this->timer); + Actor_SetColorFilter(&this->actor, 0, 255, 0, this->timer); } if (this->actionFunc != EnFirefly_Stunned) { @@ -545,7 +545,7 @@ void EnFirefly_SetupStunned(EnFirefly* this) { } this->auraType = KEESE_AURA_NONE; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = EnFirefly_Stunned; } @@ -633,7 +633,7 @@ void EnFirefly_DisturbDiveAttack(EnFirefly* this, GlobalContext* globalCtx) { void EnFirefly_UpdateDamage(EnFirefly* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - func_800BE258(&this->actor, &this->collider.info); + Actor_SetDropFlag(&this->actor, &this->collider.info); if (this->actor.colChkInfo.damageEffect == 1) { this->timer = 40; @@ -666,7 +666,7 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_ATTACK); if (this->currentType != KEESE_NORMAL) { EnFirefly_Extinguish(this); @@ -682,13 +682,13 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { if (!(this->actor.flags & 0x8000)) { if ((this->actor.colChkInfo.health == 0) || (this->actionFunc == EnFirefly_Stunned)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } else { if (this->actionFunc != EnFirefly_Rebound) { this->actor.world.rot.x = 0x1554 - this->actor.shape.rot.x; } - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); } } @@ -706,7 +706,7 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actor.world.rot.y = this->actor.shape.rot.y; if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_FLY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_FLY); } } diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.c b/src/overlays/actors/ovl_En_Fish/z_en_fish.c index 61f08534b7..24d8efb58a 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -5,6 +5,7 @@ */ #include "z_en_fish.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -15,19 +16,56 @@ void EnFish_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFish_Update(Actor* thisx, GlobalContext* globalCtx); void EnFish_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8091FA60[1] = { +void func_8091DF68(Actor* thisx, GlobalContext* globalCtx); +void func_8091E070(EnFish* this); +void func_8091E128(Actor* thisx, GlobalContext* globalCtx); +void func_8091E2E0(EnFish* this); +void func_8091E34C(Actor* thisx, GlobalContext* globalCtx2); +void func_8091E5EC(EnFish* this); +void func_8091E658(Actor* thisx, GlobalContext* globalCtx); +void func_8091E810(EnFish* this); +void func_8091E880(Actor* thisx, GlobalContext* globalCtx); +void func_8091E9A4(EnFish* this); +void func_8091EAF0(Actor* thisx, GlobalContext* globalCtx); +void func_8091ECF4(EnFish* this); +void func_8091ED70(Actor* thisx, GlobalContext* globalCtx); +void func_8091EF30(EnFish* this); +void func_8091EFE8(Actor* thisx, GlobalContext* globalCtx); +void func_8091F344(EnFish* this); +void func_8091F3BC(Actor* thisx, GlobalContext* globalCtx); +void func_8091F994(Actor* thisx, GlobalContext* globalCtx); + +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 5 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8091FA84 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_8091FA60, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static Color_RGB8 D_8091FA94[] = { + { 255, 155, 55 }, + { 255, 47, 157 }, + { 215, 97, 7 }, }; const ActorInit En_Fish_InitVars = { @@ -42,87 +80,874 @@ const ActorInit En_Fish_InitVars = { (ActorFunc)EnFish_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8091FAC0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 720, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 40, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 40, ICHAIN_STOP), }; -#endif +f32 func_8091D630(Vec3f* arg0, Vec3f* arg1) { + return SQ(arg0->x - arg1->x) + SQ(arg0->z - arg1->z); +} -extern ColliderJntSphElementInit D_8091FA60[1]; -extern ColliderJntSphInit D_8091FA84; -extern InitChainEntry D_8091FAC0[]; +void func_8091D660(EnFish* this) { + Animation_Change(&this->skelAnime, &gameplay_keep_Anim_02F0EC, 1.0f, 0.0f, + Animation_GetLastFrame(&gameplay_keep_Anim_02F0EC), 1, 2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D630.s") +void func_8091D6C4(EnFish* this) { + Animation_Change(&this->skelAnime, &gameplay_keep_Anim_02E65C, 1.0f, 0.0f, + Animation_GetLastFrame(&gameplay_keep_Anim_02E65C), 1, 2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D660.s") +void func_8091D728(EnFish* this) { + f32 phi_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D6C4.s") + this->actor.scale.x = this->unk_250 * this->unk_25C; + this->actor.scale.y = this->unk_254 * this->unk_25C; + this->actor.scale.z = this->unk_258 * this->unk_25C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D728.s") + if (this->actor.scale.z > 0.00001f) { + phi_f0 = 1.0f / this->actor.scale.z; + } else { + phi_f0 = 0.0f; + } + this->unk_264 = 16.0f * phi_f0; + this->unk_266 = 12.0f * phi_f0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D7C4.s") +void func_8091D7C4(EnFish* this) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D840.s") + Math_ScaledStepToS(&this->actor.world.rot.x, this->unk_268, this->unk_26E); + Math_ScaledStepToS(&this->actor.world.rot.y, this->unk_26A, this->unk_270); + if (this->actor.world.rot.z != this->unk_26C) { + Math_ScaledStepToS(&this->actor.world.rot.z, this->unk_26C, this->unk_272); + } + this->actor.shape.rot = this->actor.world.rot; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D904.s") +void func_8091D840(Actor* thisx, GlobalContext* globalCtx, s32 arg2, f32 arg3) { + EnFish* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D944.s") + for (i = 0; i < arg2; i++) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, arg3, arg3, (Rand_ZeroOne() * 0.09f) + 0.06f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091DA14.s") +void func_8091D904(EnFish* this) { + this->unk_242 = 400; + this->unk_25C = this->unk_260 * 0.1f; + func_8091D728(this); + this->actor.draw = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/EnFish_Init.s") +Actor* func_8091D944(EnFish* this, GlobalContext* globalCtx) { + f32 distSq; + Actor* retActor = NULL; + f32 minDistSq = FLT_MAX; + Actor* foundActor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/EnFish_Destroy.s") + while (foundActor != NULL) { + if ((foundActor->id == ACTOR_EN_FISH) && (foundActor->params == ENFISH_2) && + (foundActor->room == this->actor.room)) { + distSq = Math3D_Vec3fDistSq(&foundActor->world.pos, &this->actor.world.pos); + if (retActor == NULL) { + retActor = foundActor; + minDistSq = distSq; + } else if (distSq < minDistSq) { + minDistSq = distSq; + } + } + foundActor = foundActor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091DD48.s") + return retActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091DDF4.s") +s32 func_8091DA14(EnFish* this, GlobalContext* globalCtx) { + return globalCtx->sceneNum == SCENE_LABO && func_8091D944(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091DEE4.s") +void EnFish_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFish* this = THIS; + s16 sp36 = this->actor.params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091DF68.s") + Collider_InitJntSph(globalCtx, &this->collider); + if (sp36 == ENFISH_2) { + this->actor.draw = NULL; + this->actor.update = func_8091F994; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E070.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->unk_250 = 1.0f; + this->unk_254 = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E128.s") + if (sp36 == ENFISH_MINUS1) { + this->unk_258 = (Rand_ZeroOne() * 0.9f) + 0.6f; + this->unk_25C = ((Rand_ZeroOne() * 1.2f) + 0.6f) * 0.01f; + } else { + this->unk_258 = 1.0f; + this->unk_25C = 0.01f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E2E0.s") + this->unk_260 = this->unk_25C; + func_8091D728(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E34C.s") + if ((this->unk_258 * this->unk_25C * 100.0f) < 1.02f) { + this->unk_278 = 2; + } else if ((this->unk_258 * this->unk_25C * 100.0f) < 2.0f) { + this->unk_278 = 1; + } else { + this->unk_278 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E5EC.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gameplay_keep_Skel_02F028, &gameplay_keep_Anim_02F0EC, + this->jointTable, this->morphTable, 7); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E658.s") + this->actor.colChkInfo.mass = this->unk_25C * 30.0f; + this->unk_244 = (u32)Rand_Next() >> 0x10; + this->unk_246 = (u32)Rand_Next() >> 0x10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E810.s") + if (sp36 == ENFISH_0) { + this->actor.flags |= 0x10; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 8.0f); + func_8091E810(this); + } else if (sp36 == ENFISH_1) { + func_8091F344(this); + } else { + func_8091E070(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E880.s") +void EnFish_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnFish* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E9A4.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091EAF0.s") +void func_8091DD48(EnFish* this) { + this->actor.shape.yOffset += (Math_SinS(this->unk_246) * 5.0f) + (Math_SinS(this->unk_244) * 10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091ECF4.s") + if (this->actor.shape.yOffset < -200.0f) { + this->actor.shape.yOffset = -200.0f; + } else if (this->actor.shape.yOffset > 200.0f) { + this->actor.shape.yOffset = 200.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091ED70.s") +s32 func_8091DDF4(EnFish* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091EF30.s") + if (this->actor.xzDistToPlayer < 50.0f) { + sp1C.x = (Math_SinS(BINANG_ROT180(this->actor.yawTowardsPlayer)) * 30.0f) + player->actor.world.pos.x; + sp1C.y = player->actor.world.pos.y; + sp1C.z = (Math_CosS(BINANG_ROT180(this->actor.yawTowardsPlayer)) * 30.0f) + player->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091EFE8.s") + if (func_8091D630(&sp1C, &this->actor.world.pos) <= SQ(30.0f)) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091F344.s") +void func_8091DEE4(EnFish* this) { + static s16 D_8091FACC[] = { 85, 60, 45 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091F3BC.s") + this->actor.gravity = 0.0f; + this->actor.terminalVelocity = 0.0f; + this->unk_240 = Rand_S16Offset(5, D_8091FACC[this->unk_278]); + this->unk_248 = 0; + this->unk_26E = 400; + this->unk_272 = 400; + this->unk_268 = 0; + this->unk_26C = 0; + func_8091D660(this); + this->unk_24C = 0.0f; + this->unkFunc = func_8091DF68; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091F5A4.s") +void func_8091DF68(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091F830.s") + func_8091DD48(this); + Math_SmoothStepToF(&thisx->speedXZ, 0.0f, 0.05f, 0.3f, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/EnFish_Update.s") + if ((thisx->speedXZ * 1.4f) + 0.8f > 2.0f) { + this->skelAnime.playSpeed = 2.0f; + } else { + this->skelAnime.playSpeed = (thisx->speedXZ * 1.4f) + 0.8f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091F994.s") + this->unk_270 >>= 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/EnFish_Draw.s") + if (this->unk_240 <= 0) { + func_8091E070(this); + } else if (thisx == thisx->child) { + func_8091E5EC(this); + } else if ((thisx->xzDistToPlayer < 60.0f) || (this->unk_276 > 0)) { + func_8091E2E0(this); + } +} + +void func_8091E070(EnFish* this) { + static s16 D_8091FAD4[] = { 20, 30, 40 }; + s16 phi_a1; + + this->actor.gravity = 0.0f; + this->actor.terminalVelocity = 0.0f; + + if ((Rand_Next() & 3) == 0) { + if (((Rand_Next() & 7) == 0) && (this->unk_278 != 0)) { + phi_a1 = 80; + } else { + phi_a1 = 45; + } + } else { + phi_a1 = D_8091FAD4[this->unk_278]; + } + this->unk_240 = Rand_S16Offset(15, phi_a1); + this->unk_248 = 0; + this->unk_26E = 400; + this->unk_272 = 400; + this->unk_26C = 0; + func_8091D660(this); + this->unkFunc = func_8091E128; +} + +void func_8091E128(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFish* this = THIS; + + func_8091DD48(this); + Math_SmoothStepToF(&thisx->speedXZ, 1.8f, 0.08f, 0.4f, 0.0f); + + if ((func_8091D630(&thisx->world.pos, &thisx->home.pos) > SQ(80.0f)) || (this->unk_240 < 4)) { + this->unk_270 = this->unk_264; + this->unk_26A = Math_Vec3f_Yaw(&thisx->world.pos, &thisx->home.pos); + this->unk_24C = 1.0f; + } else if ((thisx->child != NULL) && (thisx != thisx->child)) { + this->unk_270 = this->unk_264; + this->unk_26A = Math_Vec3f_Yaw(&thisx->world.pos, &thisx->child->world.pos); + this->unk_24C = 1.2f; + } else { + this->unk_270 >>= 2; + this->unk_24C = 0.0f; + } + + if ((thisx->speedXZ * 1.5f) + 0.8f > 4.0f) { + this->skelAnime.playSpeed = 4.0f; + } else { + this->skelAnime.playSpeed = (thisx->speedXZ * 1.5f) + 0.8f; + } + + if (this->unk_240 <= 0) { + func_8091DEE4(this); + } else if (thisx == thisx->child) { + func_8091E5EC(this); + } else if ((thisx->xzDistToPlayer < 60.0f) || (this->unk_276 > 0)) { + func_8091E2E0(this); + } +} + +void func_8091E2E0(EnFish* this) { + this->actor.gravity = 0.0f; + this->actor.terminalVelocity = 0.0f; + this->unk_240 = Rand_S16Offset(10, 40); + this->unk_248 = 0; + this->unk_26E = 400; + this->unk_272 = 400; + this->unk_268 = 0; + this->unk_26C = 0; + func_8091D660(this); + this->unkFunc = func_8091E34C; +} + +void func_8091E34C(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnFish* this = THIS; + s32 sp3C = thisx->xzDistToPlayer < 60.0f; + s32 sp38 = this->unk_276 > 0; + s32 pad; + + func_8091DD48(this); + Math_SmoothStepToF(&thisx->speedXZ, 4.2f, 0.08f, 1.4f, 0.0f); + + if (func_8091D630(&thisx->world.pos, &thisx->home.pos) > SQ(160.0f)) { + this->unk_270 = this->unk_264; + this->unk_26A = Math_Vec3f_Yaw(&thisx->world.pos, &thisx->home.pos); + this->unk_24C = 0.8f; + } else if ((thisx->child != NULL) && (thisx != thisx->child)) { + this->unk_270 = this->unk_266; + this->unk_26A = Math_Vec3f_Yaw(&thisx->world.pos, &thisx->child->world.pos); + this->unk_24C = 1.0f; + } else if (sp3C) { + this->unk_26A = BINANG_ROT180(thisx->yawTowardsPlayer); + if ((globalCtx->state.frames & 0x10) == 0) { + if ((globalCtx->state.frames & 0x20) == 0) { + this->unk_26A += 0x2000; + } + } else if ((globalCtx->state.frames & 0x20) == 0) { + this->unk_26A -= 0x2000; + } + this->unk_270 = this->unk_266; + this->unk_24C = 1.2f; + } else if (sp38 != 0) { + if ((globalCtx->state.frames & 0x10) == 0) { + s16 temp = BINANG_SUB(thisx->shape.rot.y, this->unk_274); + + if (temp < 0) { + this->unk_26A = BINANG_SUB(this->unk_274, 0x4000); + } else { + this->unk_26A = BINANG_ADD(this->unk_274, 0x4000); + } + } else { + this->unk_26A = BINANG_ROT180(this->unk_274); + } + this->unk_24C = 1.2f; + this->unk_270 = this->unk_266; + } else { + this->unk_270 >>= 2; + this->unk_24C = 0.0f; + } + + if ((thisx->speedXZ * 1.5f) + 0.8f > 4.0f) { + this->skelAnime.playSpeed = 4.0f; + } else { + this->skelAnime.playSpeed = (thisx->speedXZ * 1.5f) + 0.8f; + } + + if ((this->unk_240 <= 0) || (!sp3C && (sp38 == 0))) { + func_8091DEE4(this); + } else if (thisx == thisx->child) { + func_8091E5EC(this); + } +} + +void func_8091E5EC(EnFish* this) { + this->actor.gravity = 0.0f; + this->actor.terminalVelocity = 0.0f; + this->unk_26E = 400; + this->unk_272 = 400; + this->unk_268 = 0; + this->unk_26C = 0; + func_8091D660(this); + this->unk_240 = Rand_S16Offset(10, 30); + this->unk_248 = 0; + this->unkFunc = func_8091E658; +} + +void func_8091E658(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + Vec3f sp38; + s32 pad2; + s16 sp32; + + func_8091DD48(this); + Math_SmoothStepToF(&thisx->speedXZ, 1.8f, 0.1f, 0.5f, 0.0f); + + if (func_8091D630(&thisx->world.pos, &thisx->home.pos) > SQ(80.0f)) { + this->unk_270 = this->unk_264; + this->unk_26A = Math_Vec3f_Yaw(&thisx->world.pos, &thisx->home.pos); + this->unk_24C = 1.0f; + } else { + if ((globalCtx->state.frames & 0x40) == 0) { + sp32 = BINANG_ADD(thisx->yawTowardsPlayer, 0x9000); + } else { + sp32 = BINANG_ADD(thisx->yawTowardsPlayer, 0x7000); + } + + sp38.x = (Math_SinS(sp32) * 20.0f) + player->actor.world.pos.x; + sp38.y = player->actor.world.pos.y; + sp38.z = (Math_CosS(sp32) * 20.0f) + player->actor.world.pos.z; + + this->unk_270 = this->unk_264; + this->unk_26A = Math_Vec3f_Yaw(&thisx->world.pos, &sp38); + this->unk_24C = 1.2f; + } + + if ((thisx->speedXZ * 1.5f) + 0.8f > 4.0f) { + this->skelAnime.playSpeed = 4.0f; + } else { + this->skelAnime.playSpeed = (thisx->speedXZ * 1.5f) + 0.8f; + } + + if (this->unk_240 <= 0) { + func_8091DEE4(this); + } +} + +void func_8091E810(EnFish* this) { + this->unk_270 = 0; + this->unk_26A = 0; + this->actor.gravity = -1.0f; + this->actor.terminalVelocity = -10.0f; + this->actor.shape.yOffset = 0.0f; + func_8091D6C4(this); + this->unk_248 = 5; + this->unkFunc = func_8091E880; + this->unk_24C = 0.0f; + this->unk_240 = 300; +} + +void func_8091E880(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.1f, 0.0f); + this->unk_26E = 0x43; + this->unk_272 = 0x43; + this->unk_268 = 0x4000; + this->unk_26C = -0x4000; + if (this->actor.bgCheckFlags & 1) { + this->unk_240 = 400; + func_8091E9A4(this); + } else if (this->actor.bgCheckFlags & 0x20) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + func_8091D840(thisx, globalCtx, 10, 15.0f); + if (func_8091DA14(this, globalCtx)) { + func_8091EF30(this); + } else { + func_8091ECF4(this); + } + } else if ((this->unk_240 <= 0) && (this->actor.params == ENFISH_0) && + (this->actor.floorHeight < BGCHECK_Y_MIN + 10)) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_8091E9A4(EnFish* this) { + s32 pad[2]; + s32 sp24; + f32 temp_f0; + + this->actor.gravity = -1.0f; + this->actor.terminalVelocity = -10.0f; + + temp_f0 = Rand_ZeroOne(); + if (temp_f0 < 0.1f) { + this->actor.velocity.y = (Rand_ZeroOne() * 3.0f) + 2.5f; + sp24 = true; + } else if (temp_f0 < 0.2f) { + this->actor.velocity.y = (Rand_ZeroOne() * 1.2f) + 0.2f; + sp24 = true; + } else { + this->actor.velocity.y = 0.0f; + if (Rand_ZeroOne() < 0.2f) { + sp24 = true; + } else { + sp24 = false; + } + } + + this->actor.shape.yOffset = 300.0f; + func_8091D6C4(this); + this->unkFunc = func_8091EAF0; + this->unk_248 = 5; + this->unk_24C = 0.0f; + if (sp24 && (this->actor.draw != NULL)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FISH_LEAP); + } +} + +void func_8091EAF0(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + s32 sp40 = globalCtx->state.frames; + s16 phi_v1; + + Math_SmoothStepToF(&this->actor.speedXZ, Rand_ZeroOne() * 0.2f, 0.1f, 0.1f, 0.0f); + phi_v1 = (s16)((((sp40 >> 5) & 2) | ((sp40 >> 2) & 1)) << 0xB) * 0.3f; + if (sp40 & 4) { + phi_v1 *= -1; + } + this->unk_268 = phi_v1; + this->unk_26E = 0xA6B; + this->unk_26C = 0x4000; + this->unk_272 = 0x29B; + this->unk_270 = ((Math_SinS(this->unk_244) * 1333.0f) + (Math_SinS(this->unk_246) * 667.0f)) * Rand_ZeroOne(); + + if (this->unk_270 >= 0) { + this->unk_26A = BINANG_ADD(this->actor.world.rot.y, 0x4000); + } else { + this->unk_26A = BINANG_SUB(this->actor.world.rot.y, 0x4000); + this->unk_270 = -this->unk_270; + } + + if (this->unk_240 <= 0) { + Actor_MarkForDeath(&this->actor); + } else if (this->unk_240 <= 60) { + if (sp40 & 4) { + this->actor.draw = EnFish_Draw; + } else { + this->actor.draw = NULL; + } + } else if (this->actor.bgCheckFlags & 0x20) { + if (func_8091DA14(this, globalCtx)) { + func_8091EF30(this); + } else { + func_8091ECF4(this); + } + } else if (this->actor.bgCheckFlags & 1) { + func_8091E9A4(this); + } +} + +void func_8091ECF4(EnFish* this) { + this->actor.home.pos = this->actor.world.pos; + this->actor.gravity = 0.0f; + this->actor.terminalVelocity = 0.0f; + this->actor.shape.yOffset = 0.0f; + this->actor.flags |= 0x10; + this->unk_240 = 200; + func_8091D660(this); + this->unkFunc = func_8091ED70; + this->unk_248 = 5; + this->unk_24C = 0.0f; +} + +void func_8091ED70(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + s32 pad; + s16 sp2E; + + if (this->unk_240 >= 0xBF) { + func_8091D840(thisx, globalCtx, 2, 25.0f); + } + + Math_SmoothStepToF(&thisx->speedXZ, 2.8f, 0.1f, 0.4f, 0.0f); + + if ((thisx->bgCheckFlags & 8) || !(thisx->bgCheckFlags & 0x20)) { + sp2E = Math_Vec3f_Yaw(&thisx->world.pos, &thisx->home.pos); + thisx->home.rot.y = Rand_S16Offset(-100, 100) + sp2E; + thisx->speedXZ *= 0.5f; + } + + this->unk_268 = 0; + this->unk_26A = thisx->home.rot.y; + this->unk_26C = 0; + this->unk_26E = 1000; + this->unk_270 = 2000; + this->unk_272 = 0x29B; + + if (thisx->bgCheckFlags & 1) { + Math_StepToF(&thisx->world.pos.y, thisx->home.pos.y - 4.0f, 2.0f); + } else { + Math_StepToF(&thisx->world.pos.y, thisx->home.pos.y - 10.0f, 2.0f); + } + + if (this->unk_240 < 100) { + this->unk_25C *= 0.982f; + func_8091D728(this); + } + + if ((thisx->speedXZ * 1.5f) + 1.0f > 4.8f) { + this->skelAnime.playSpeed = 4.8f; + } else { + this->skelAnime.playSpeed = (thisx->speedXZ * 1.5f) + 1.0f; + } + + if (this->unk_240 <= 0) { + Actor_MarkForDeath(thisx); + } +} + +void func_8091EF30(EnFish* this) { + this->actor.gravity = -2.0f; + this->actor.terminalVelocity = -10.0f; + this->actor.shape.yOffset = 0.0f; + if (this->actor.velocity.y < -1.0f) { + this->actor.velocity.y = -1.0f; + } + this->actor.flags |= 0x10; + this->actor.home.pos.x = this->actor.world.pos.x; + this->actor.home.pos.y = this->actor.world.pos.y - 20.0f; + this->actor.home.pos.z = this->actor.world.pos.z; + func_8091D660(this); + this->unk_240 = 15; + this->unk_279 = 10; + this->unkFunc = func_8091EFE8; + this->unk_248 = 5; + this->unk_24C = 0.0f; +} + +void func_8091EFE8(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + s32 temp_v0_2; + Actor* sp3C = func_8091D944(this, globalCtx); + f32 temp_f0; + f32 sp34; + f32 sp30; + s16 sp2E; + + if (sp3C == 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->unk_240 <= 0) { + this->unk_240 = Rand_S16Offset(5, 35); + } + + if (this->unk_277 == 0) { + Math_SmoothStepToF(&this->actor.speedXZ, 2.8f, 0.1f, 0.4f, 0.0f); + if (this->unk_240 < 6) { + this->actor.speedXZ *= 0.75f; + } + } + + if ((this->actor.bgCheckFlags & 8) && !(this->actor.bgCheckFlags & 0x20)) { + this->actor.speedXZ *= 0.5f; + } + + if (!((u32)Rand_Next() >> 0x1B) || ((this->actor.bgCheckFlags & 8) && !((u32)Rand_Next() >> 0x1E)) || + !(this->actor.bgCheckFlags & 0x20)) { + temp_f0 = Rand_ZeroOne(); + sp34 = (1.0f - SQ(temp_f0)) * sp3C->home.rot.x; + sp30 = Rand_ZeroOne() * sp3C->home.rot.z; + sp2E = (u32)Rand_Next() >> 0x10; + this->actor.home.pos.x = (Math_SinS(sp2E) * sp34) + sp3C->world.pos.x; + this->actor.home.pos.y = sp3C->world.pos.y + sp30; + this->actor.home.pos.z = (Math_CosS(sp2E) * sp34) + sp3C->world.pos.z; + this->actor.home.rot.y = + Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos) + Rand_S16Offset(-100, 100); + } + + this->unk_268 = Math_Vec3f_Pitch(&this->actor.world.pos, &this->actor.home.pos); + this->unk_26C = 0; + this->unk_26A = this->actor.home.rot.y; + + temp_v0_2 = BINANG_SUB(this->unk_268, this->actor.shape.rot.x); + temp_v0_2 = ABS_ALT(temp_v0_2); + + temp_v0_2 = temp_v0_2 / 11; + if (temp_v0_2 > 800) { + temp_v0_2 = 800; + } else if (temp_v0_2 < 100) { + temp_v0_2 = 100; + } + + if (this->unk_279 > 0) { + this->unk_279--; + this->unk_26E = 1000; + } else { + this->unk_26E = temp_v0_2; + } + + if (this->unk_240 < 10) { + this->unk_270 = 400; + } else { + this->unk_270 = 2000; + } + + this->unk_272 = 0x29B; + if (fabsf(this->actor.world.pos.y - this->actor.home.pos.y) < 2.0f) { + this->actor.gravity = 0.0f; + } else if (this->actor.home.pos.y < this->actor.world.pos.y) { + this->actor.gravity = -0.15f; + } else { + this->actor.gravity = 0.15f; + } + + this->actor.velocity.y *= 0.8f; + if ((this->actor.speedXZ * 1.5f) + 1.0f > 4.8f) { + this->skelAnime.playSpeed = 4.8f; + } else { + this->skelAnime.playSpeed = (this->actor.speedXZ * 1.5f) + 1.0f; + } +} + +void func_8091F344(EnFish* this) { + this->actor.gravity = 0.0f; + this->actor.terminalVelocity = 0.0f; + this->unk_240 = Rand_S16Offset(5, 35); + this->unk_248 = 1; + this->unk_268 = 0; + this->unk_26C = 0; + this->unk_26E = 1500; + this->unk_272 = 0; + func_8091D660(this); + this->unkFunc = func_8091F3BC; + this->unk_24C = 0.0f; +} + +void func_8091F3BC(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f D_8091FADC = { 0.0f, 0.04f, 0.09f }; + static Vec3f D_8091FAE8 = { 0.5f, 0.1f, 0.15f }; + EnFish* this = THIS; + s32 sp40 = globalCtx->gameplayFrames; + Vec3f* sp3C; + f32 phi_f0; + f32 temp_f2; + + if ((this->actor.xzDistToPlayer < 60.0f) || ((sp40 & 0x1FF) < 20)) { + if (this->unk_240 < 12) { + sp3C = &D_8091FAE8; + } else { + sp3C = &D_8091FADC; + } + } else if (this->unk_240 < 4) { + sp3C = &D_8091FAE8; + } else { + sp3C = &D_8091FADC; + } + + func_8091DD48(this); + Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 2.0f); + Math_SmoothStepToF(&this->actor.speedXZ, sp3C->x, sp3C->y, sp3C->z, 0.0f); + this->unk_24C = 0.0f; + + if (func_8091D630(&this->actor.world.pos, &this->actor.home.pos) > SQ(15.0f)) { + this->unk_26A = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); + this->unk_270 = 0x85; + phi_f0 = 0.4f; + } else if (this->unk_240 < 4) { + this->unk_26A = sp40 << 7; + this->unk_270 = 0x43; + phi_f0 = 0.4f; + } else { + this->unk_270 = 0; + phi_f0 = 0.0f; + } + + temp_f2 = this->actor.speedXZ + 0.4f + phi_f0; + this->skelAnime.playSpeed = CLAMP(temp_f2, 0.5f, 1.6f); + + if (this->unk_240 <= 0) { + this->unk_240 = Rand_S16Offset(5, 80); + } +} + +void func_8091F5A4(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + Actor* temp_v0_2; + s16 temp_v0; + s16 temp_v0_4; + s32 temp_v1; + s32 phi_v1; + f32 phi_f0; + + if (this->unk_240 > 0) { + this->unk_240--; + } + + this->unk_244 += 0x111; + this->unk_246 += 0x500; + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (thisx != this->actor.child)) { + this->actor.child = NULL; + } + + if ((this->unkFunc == NULL) || (this->unkFunc(&this->actor, globalCtx), (this->actor.update != NULL))) { + if ((ABS_ALT(BINANG_SUB(this->unk_26A, this->actor.shape.rot.y)) > 0x3000) && (this->unk_270 > 1000)) { + this->skelAnime.playSpeed += this->unk_24C; + } + SkelAnime_Update(&this->skelAnime); + func_8091D7C4(this); + Actor_MoveWithGravity(&this->actor); + if (this->unk_248 != 0) { + u32 temp = (globalCtx->sceneNum ^ SCENE_LABO) != 0; + phi_f0 = BREG(1) + 10.0f; + + if (temp) { + phi_f0 = 6.0f; + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 17.5f, phi_f0, 0.0f, this->unk_248); + } + + if ((this->actor.xzDistToPlayer < 70.0f) && (this->unkFunc != func_8091EFE8)) { + ColliderJntSphElement* element = &this->collider.elements[0]; + + element->dim.worldSphere.center.x = this->actor.world.pos.x; + element->dim.worldSphere.center.y = this->actor.world.pos.y; + element->dim.worldSphere.center.z = this->actor.world.pos.z; + element->dim.worldSphere.radius = this->unk_25C * 500.0f; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + Actor_SetFocus(&this->actor, this->actor.shape.yOffset * 0.01f); + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + if (this->actor.params == ENFISH_0) { + Actor_MarkForDeath(&this->actor); + } else { + func_8091D904(this); + } + } else if (func_8091DDF4(this, globalCtx)) { + Actor_PickUp(&this->actor, globalCtx, 0xBA, 80.0f, 25.0f); + } + } +} + +void func_8091F830(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + + if (this->actor.params == ENFISH_1) { + Actor_MarkForDeath(&this->actor); + return; + } + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (thisx != this->actor.child)) { + this->actor.child = NULL; + } + + if ((this->unkFunc == NULL) || (this->unkFunc(&this->actor, globalCtx), (this->actor.update != NULL))) { + func_8091D7C4(this); + Actor_MoveWithGravity(&this->actor); + + if (this->unk_242 == 20) { + this->actor.draw = EnFish_Draw; + } else if (this->unk_242 == 0) { + this->unk_25C = this->unk_260; + func_8091D728(this); + } else if (this->unk_242 < 20) { + this->unk_25C += 0.1f * this->unk_260; + if (this->unk_260 < this->unk_25C) { + this->unk_25C = this->unk_260; + } + func_8091D728(this); + } + } +} + +void EnFish_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + + if (this->unk_242 > 0) { + this->unk_242--; + func_8091F830(thisx, globalCtx); + } else { + func_8091F5A4(thisx, globalCtx); + } + + if (this->unk_276 > 0) { + this->unk_276--; + } +} + +void func_8091F994(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnFish_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + Color_RGB8* colour = &D_8091FA94[this->unk_278]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, colour->r, colour->g, colour->b, 255); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, NULL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.h b/src/overlays/actors/ovl_En_Fish/z_en_fish.h index 7d4a9f0cf2..fd35ef6262 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.h +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.h @@ -5,11 +5,47 @@ struct EnFish; +typedef void (*EnFishUnkFunc)(Actor*, GlobalContext*); + +enum { + /* -1 */ ENFISH_MINUS1 = -1, + /* 0 */ ENFISH_0, + /* 1 */ ENFISH_1, + /* 2 */ ENFISH_2, +}; + typedef struct EnFish { /* 0x000 */ Actor actor; - /* 0x144 */ char unk144[0x133]; - /* 0x277 */ s8 unk_277; - /* 0x278 */ char unk278[0x4]; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElements[1]; + /* 0x1A4 */ SkelAnime skelAnime; + /* 0x1E8 */ Vec3s jointTable[7]; + /* 0x212 */ Vec3s morphTable[7]; + /* 0x23C */ EnFishUnkFunc unkFunc; + /* 0x240 */ s16 unk_240; + /* 0x242 */ s16 unk_242; + /* 0x244 */ s16 unk_244; + /* 0x246 */ s16 unk_246; + /* 0x248 */ s32 unk_248; + /* 0x24C */ f32 unk_24C; + /* 0x250 */ f32 unk_250; + /* 0x254 */ f32 unk_254; + /* 0x258 */ f32 unk_258; + /* 0x25C */ f32 unk_25C; + /* 0x260 */ f32 unk_260; + /* 0x264 */ s16 unk_264; + /* 0x266 */ s16 unk_266; + /* 0x268 */ s16 unk_268; + /* 0x26A */ s16 unk_26A; + /* 0x26C */ s16 unk_26C; + /* 0x26E */ s16 unk_26E; + /* 0x270 */ s16 unk_270; + /* 0x272 */ s16 unk_272; + /* 0x274 */ s16 unk_274; + /* 0x276 */ s8 unk_276; + /* 0x277 */ u8 unk_277; + /* 0x278 */ s8 unk_278; + /* 0x279 */ s8 unk_279; } EnFish; // size = 0x27C extern const ActorInit En_Fish_InitVars; diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index f9dfa048d6..ee36b9107a 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -160,7 +160,7 @@ void EnFish2_Init(Actor* thisx, GlobalContext* globalCtx) { D_80B2B2F0++; if (this->actor.params == 0) { - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06006190, &D_060013AC, this->jointTable, this->morphTable, 24); this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -328,10 +328,10 @@ void func_80B28B5C(EnFish2* this) { } void func_80B28C14(EnFish2* this, GlobalContext* globalCtx) { - Actor* itemAction = globalCtx->actorCtx.actorList[ACTORCAT_ITEMACTION].first; + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; WaterBox* waterbox; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80B29128(this); return; } @@ -438,7 +438,7 @@ void func_80B29128(EnFish2* this) { } void func_80B2913C(EnFish2* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); func_80B28B5C(this); } @@ -533,7 +533,7 @@ void func_80B2951C(EnFish2* this) { Actor_MarkForDeath(this->unk_350); this->unk_350 = NULL; D_80B2B2F4 = &this->actor; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_EAT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_M_EAT); this->actionFunc = func_80B295A4; } @@ -642,7 +642,7 @@ void func_80B297FC(EnFish2* this, GlobalContext* globalCtx) { } this->unk_2B6 = 4; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FISH_GROW_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FISH_GROW_UP); this->unk_2C4++; } break; @@ -747,7 +747,7 @@ void func_80B297FC(EnFish2* this, GlobalContext* globalCtx) { } void func_80B29E5C(EnFish2* this, GlobalContext* globalCtx) { - Actor* prop = globalCtx->actorCtx.actorList[ACTORCAT_PROP].first; + Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; while (prop != NULL) { if (prop->id != ACTOR_EN_FISH2) { @@ -893,7 +893,7 @@ void func_80B2A498(EnFish2* this, GlobalContext* globalCtx) { if (temp_v0 != NULL) { temp_v0->speedXZ = 4.0f; temp_v0->velocity.y = 15.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_SY_PIECE_OF_HEART); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); gSaveContext.weekEventReg[81] &= (u8)~0x10; gSaveContext.weekEventReg[81] &= (u8)~0x20; gSaveContext.weekEventReg[81] &= (u8)~0x40; @@ -912,7 +912,7 @@ void func_80B2A498(EnFish2* this, GlobalContext* globalCtx) { Vec3f sp6C; s32 i; - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_BOMB_DROP_WATER); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_BOMB_DROP_WATER); for (i = 0; i < 10; i++) { Math_Vec3f_Copy(&sp6C, &this->actor.world.pos); @@ -958,7 +958,7 @@ void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx2) { } this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, 0); + Actor_SetFocus(&this->actor, 0); if (this->actor.params != 1) { WaterBox* sp6C; @@ -990,7 +990,7 @@ void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx2) { this->unk_2F4.z += (Math_CosS(this->actor.world.rot.y) * 25.0f) - this->unk_330; this->unk_33C = 25.0f - ((this->unk_330 - 0.01f) * 1000.0f); Actor_SetScale(&this->actor, this->unk_330); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0, 15.0f, 10.0f, 7); if (this->actor.params != 2) { @@ -1069,11 +1069,11 @@ void EnFish2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == 14) { - Matrix_MultiplyVector3fByState(&D_801D15B0, &this->unk_318); + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_318); } if (limbIndex == 17) { - Matrix_MultiplyVector3fByState(&D_801D15B0, &this->unk_300); + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_300); } Collider_UpdateSpheres(limbIndex, &this->collider); diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c index d1f93bdbc8..4de4d0955e 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -1,21 +1,204 @@ /* * File: z_en_fishing.c * Overlay: ovl_En_Fishing - * Description: Fishing + * Description: Fishing Pond Elements (Owner, Fish, Props, Effects...) */ #include "z_en_fishing.h" +#include "objects/object_fish/object_fish.h" +#include "overlays/actors/ovl_En_Kanban/z_en_kanban.h" #define FLAGS 0x00000010 #define THIS ((EnFishing*)thisx) +#define WATER_SURFACE_Y(globalCtx) globalCtx->colCtx.colHeader->waterBoxes->minPos.y + void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx); void EnFishing_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFishing_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFishing_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx); +void EnFishing_DrawFish(Actor* thisx, GlobalContext* globalCtx); + +void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx); +void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx); + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x02 */ Vec3s pos; + /* 0x08 */ u8 unk_08; + /* 0x0C */ f32 unk_0C; +} FishingFishInit; // size = 0x10 + +#define EFFECT_COUNT 130 + +typedef enum { + /* 0x00 */ FS_EFF_NONE, + /* 0x01 */ FS_EFF_RIPPLE, + /* 0x02 */ FS_EFF_DUST_SPLASH, + /* 0x03 */ FS_EFF_WATER_DUST, + /* 0x04 */ FS_EFF_BUBBLE, + /* 0x05 */ FS_EFF_RAIN_DROP, + /* 0x06 */ FS_EFF_OWNER_HAT, + /* 0x07 */ FS_EFF_RAIN_RIPPLE, + /* 0x08 */ FS_EFF_RAIN_SPLASH +} FishingEffectType; + +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3f vel; + /* 0x18 */ Vec3f accel; + /* 0x24 */ u8 type; + /* 0x25 */ u8 timer; + /* 0x26 */ UNK_TYPE1 unk_26[0x04]; + /* 0x2A */ s16 alpha; + /* 0x2C */ s16 unk_2C; + /* 0x2E */ s16 unk_2E; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; + /* 0x3C */ f32 unk_3C; +} FishingEffect; // size = 0x40 + +#define POND_PROP_COUNT 140 + +typedef enum { + /* 0x00 */ FS_PROP_NONE, + /* 0x01 */ FS_PROP_REED, + /* 0x02 */ FS_PROP_LILY_PAD, + /* 0x03 */ FS_PROP_ROCK, + /* 0x04 */ FS_PROP_WOOD_POST, + /* 0x23 */ FS_PROP_INIT_STOP = 0x23 +} FishingPropType; + +typedef struct { + /* 0x00 */ u8 type; + /* 0x02 */ Vec3s pos; +} FishingPropInit; // size = 0x08 + +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ f32 rotX; + /* 0x10 */ f32 rotY; + /* 0x14 */ f32 reedAngle; + /* 0x18 */ Vec3f projectedPos; + /* 0x24 */ f32 scale; + /* 0x28 */ s16 lilyPadAngle; + /* 0x2C */ f32 lilyPadOffset; + /* 0x30 */ u8 type; + /* 0x32 */ s16 timer; + /* 0x34 */ u8 shouldDraw; + /* 0x38 */ f32 drawDistance; +} FishingProp; // size = 0x3C + +typedef enum { + /* 0x00 */ FS_GROUP_FISH_NONE, + /* 0x01 */ FS_GROUP_FISH_NORMAL +} FishingGroupFishType; + +#define GROUP_FISH_COUNT 60 + +typedef struct { + /* 0x00 */ u8 type; + /* 0x02 */ s16 timer; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f unk_10; + /* 0x1C */ Vec3f projectedPos; + /* 0x28 */ f32 unk_28; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; + /* 0x3C */ s16 unk_3C; + /* 0x3E */ s16 unk_3E; + /* 0x40 */ s16 unk_40; + /* 0x42 */ s16 unk_42; + /* 0x44 */ u8 shouldDraw; +} FishingGroupFish; // size = 0x48 + +#define LINE_SEG_COUNT 200 +#define SINKING_LURE_SEG_COUNT 20 + +static f32 D_809101B0; +static f32 D_809101B4; +static s16 D_809101B8; +static f32 D_809101BC; +static f32 D_809101C0; +static f32 D_809101C4; +static f32 D_809101C8; +static s16 D_809101CC; +static f32 D_809101D0; +static Vec3f sRodTipPos; +static Vec3f sReelLinePos[LINE_SEG_COUNT]; +static Vec3f sReelLineRot[LINE_SEG_COUNT]; +static Vec3f sReelLineUnk[LINE_SEG_COUNT]; +static Vec3f sLureHookRefPos[2]; +static f32 sLureHookRotY[2]; +static u8 D_80911E28; +static Vec3f sSinkingLurePos[SINKING_LURE_SEG_COUNT]; +static s16 D_80911F20; +static f32 sProjectedW; +static Vec3f sCameraEye; +static Vec3f sCameraAt; +static s16 sCameraId; +static f32 D_80911F48; +static f32 D_80911F4C; +static f32 D_80911F50; +static Vec3f sSinkingLureBasePos; +static f32 D_80911F64; +static s32 sRandSeed0; +static s32 sRandSeed1; +static s32 sRandSeed2; +static FishingProp sPondProps[POND_PROP_COUNT]; +static FishingGroupFish sGroupFishes[GROUP_FISH_COUNT]; +static f32 sFishGroupAngle1; +static f32 sFishGroupAngle2; +static f32 sFishGroupAngle3; +static FishingEffect sFishingEffects[EFFECT_COUNT]; +static Vec3f sStreamSoundProjectedPos; +static EnFishing* sFishingMain; +static u8 D_809171C8; +static u8 sLinkAge; +static u8 D_809171CA; +static u8 D_809171CB; +static f32 D_809171CC; +static u8 D_809171D0; +static u8 D_809171D1; +static u8 D_809171D2; +static s16 D_809171D4; +static u8 D_809171D6; +static u16 D_809171D8; +static u16 D_809171DA; +static s8 D_809171DC; +static Vec3f sOwnerHeadPos; +static Vec3s sEffOwnerHatRot; +static u8 D_809171F2; +static s16 D_809171F4; +static s16 D_809171F6; +static EnFishing* sFishingHookedFish; +static s16 D_809171FC; +static s16 D_809171FE; +static s16 D_80917200; +static s16 D_80917202; +static s16 D_80917204; +static u8 D_80917206; +static Vec3f sLurePos; +static Vec3f D_80917218; +static Vec3f sLureRot; +static Vec3f D_80917238; +static Vec3f D_80917248; +static f32 D_80917254; +static f32 D_80917258; +static f32 D_8091725C; +static f32 D_80917260; +static s8 D_80917264; +static s16 D_80917266; +static u8 D_80917268; +static f32 D_8091726C; +static u8 D_80917270; +static s16 D_80917272; +static u8 D_80917274; +static Vec3f D_80917278; -#if 0 const ActorInit En_Fishing_InitVars = { ACTOR_EN_FISHING, ACTORCAT_NPC, @@ -24,181 +207,5503 @@ const ActorInit En_Fishing_InitVars = { sizeof(EnFishing), (ActorFunc)EnFishing_Init, (ActorFunc)EnFishing_Destroy, - (ActorFunc)EnFishing_Update, - (ActorFunc)EnFishing_Draw, + (ActorFunc)EnFishing_UpdateFish, + (ActorFunc)EnFishing_DrawFish, }; -// static ColliderJntSphElementInit sJntSphElementsInit[12] = { -static ColliderJntSphElementInit D_8090CD58[12] = { +static f32 D_8090CCD0 = 0.0f; +static u8 D_8090CCD4 = 0; +static f32 D_8090CCD8 = 0.0f; +static Vec3f D_8090CCDC = { 0.0f, 0.0f, 0.0f }; +static f32 D_8090CCE8 = 0.0f; +static u8 sSinkingLureLocation = 0; +static f32 D_8090CCF0 = 0.0f; +static u8 D_8090CCF4 = true; +static u16 D_8090CCF8 = 0; +static u8 D_8090CCFC = 0; +static s32 D_8090CD00 = 0; +static s16 D_8090CD04 = 0; +static u8 D_8090CD08 = 0; +static u8 D_8090CD0C = 0; +static u8 D_8090CD10 = 0; +static s16 D_8090CD14 = 0; +static Vec3f sFishMouthOffset = { 500.0f, 500.0f, 0.0f }; +static u8 D_8090CD24 = 0; +static f32 D_8090CD28 = 0; +static f32 D_8090CD2C = 0; +static f32 D_8090CD30 = 0.0f; +static f32 D_8090CD34 = 0.0f; +static f32 D_8090CD38 = 0.0f; +static f32 D_8090CD3C = 0.0f; +static f32 D_8090CD40 = 0.0f; +static s16 D_8090CD44 = 0; +static s16 D_8090CD48 = 0; +static u8 D_8090CD4C = 0; +static u8 D_8090CD50 = 0; +static u8 D_8090CD54 = 0; + +static ColliderJntSphElementInit sJntSphElementsInit[12] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8090CF08 = { - { COLTYPE_NONE, AT_NONE | AT_TYPE_ENEMY, AC_NONE | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 12, D_8090CD58, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE | AT_TYPE_ENEMY, + AC_NONE | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 12, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8090D4D0[] = { +static u8 D_8090CF18 = 0; +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; +static Vec3f D_8090CF28 = { 0.0f, 0.0f, 2000.0f }; // Unused + +void EnFishing_SetColliderElement(s32 index, ColliderJntSph* collider, Vec3f* pos, f32 scale) { + collider->elements[index].dim.worldSphere.center.x = pos->x; + collider->elements[index].dim.worldSphere.center.y = pos->y; + collider->elements[index].dim.worldSphere.center.z = pos->z; + collider->elements[index].dim.worldSphere.radius = + collider->elements[index].dim.modelSphere.radius * collider->elements[index].dim.scale * scale * 1.6f; +} + +void EnFishing_SeedRand(s32 seed0, s32 seed1, s32 seed2) { + sRandSeed0 = seed0; + sRandSeed1 = seed1; + sRandSeed2 = seed2; +} + +f32 EnFishing_RandZeroOne(void) { + f32 rand; + + // Wichmann-Hill algorithm + sRandSeed0 = (sRandSeed0 * 171) % 30269; + sRandSeed1 = (sRandSeed1 * 172) % 30307; + sRandSeed2 = (sRandSeed2 * 170) % 30323; + + rand = (sRandSeed0 / 30269.0f) + (sRandSeed1 / 30307.0f) + (sRandSeed2 / 30323.0f); + while (rand >= 1.0f) { + rand -= 1.0f; + } + + return fabsf(rand); +} + +s16 EnFishing_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step) { + s16 stepSize; + s16 diff; + + diff = target - *pValue; + stepSize = diff / scale; + + if (stepSize > step) { + stepSize = step; + } + + if (stepSize < -step) { + stepSize = -step; + } + + *pValue += stepSize; + + return stepSize; +} + +void EnFishing_SpawnRipple(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 arg3, f32 arg4, s16 arg5, + s16 countLimit) { + s16 i; + + if ((projectedPos != NULL) && ((projectedPos->z > 500.0f) || (projectedPos->z < 0.0f))) { + return; + } + + for (i = 0; i < countLimit; i++) { + if (effect->type == FS_EFF_NONE) { + effect->type = FS_EFF_RIPPLE; + effect->pos = *pos; + effect->vel = sZeroVec; + effect->accel = sZeroVec; + effect->unk_30 = arg3 * 0.0025f; + effect->unk_34 = arg4 * 0.0025f; + + if (arg3 > 300.0f) { + effect->alpha = 0; + effect->unk_2E = arg5; + effect->unk_2C = 0; + effect->unk_38 = (effect->unk_34 - effect->unk_30) * 0.05f; + } else { + effect->alpha = arg5; + effect->unk_2C = 1; + effect->unk_38 = (effect->unk_34 - effect->unk_30) * 0.1f; + } + break; + } + + effect++; + } +} + +void EnFishing_SpawnDustSplash(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, Vec3f* vel, f32 scale) { + s16 i; + Vec3f accel = { 0.0f, -1.0f, 0.0f }; + + if ((projectedPos != NULL) && ((projectedPos->z > 500.0f) || (projectedPos->z < 0.0f))) { + return; + } + + for (i = 0; i < 100; i++) { + if ((effect->type == FS_EFF_NONE) || (effect->type == FS_EFF_RAIN_DROP) || + (effect->type == FS_EFF_RAIN_RIPPLE) || (effect->type == FS_EFF_RAIN_SPLASH)) { + effect->type = FS_EFF_DUST_SPLASH; + effect->pos = *pos; + effect->vel = *vel; + effect->accel = accel; + effect->alpha = 100 + Rand_ZeroFloat(100.0f); + effect->unk_30 = scale; + break; + } + + effect++; + } +} + +void EnFishing_SpawnWaterDust(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 scale) { + s16 i; + Vec3f accel = { 0.0f, 0.05f, 0.0f }; + + if ((projectedPos != NULL) && ((projectedPos->z > 500.0f) || (projectedPos->z < 0.0f))) { + return; + } + + for (i = 0; i < 90; i++) { + if (effect->type == FS_EFF_NONE) { + effect->type = FS_EFF_WATER_DUST; + effect->pos = *pos; + effect->vel = sZeroVec; + effect->accel = accel; + effect->alpha = 255; + effect->timer = Rand_ZeroFloat(100.0f); + effect->unk_30 = scale; + effect->unk_34 = 2.0f * scale; + break; + } + + effect++; + } +} + +void EnFishing_SpawnBubble(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 scale, u8 arg4) { + s16 i; + Vec3f vel = { 0.0f, 1.0f, 0.0f }; + + if ((projectedPos != NULL) && ((projectedPos->z > 500.0f) || (projectedPos->z < 0.0f))) { + return; + } + + for (i = 0; i < 90; i++) { + if (effect->type == FS_EFF_NONE) { + effect->type = FS_EFF_BUBBLE; + effect->pos = *pos; + effect->vel = vel; + effect->accel = sZeroVec; + effect->timer = Rand_ZeroFloat(100.0f); + effect->unk_30 = scale; + effect->unk_2C = arg4; + break; + } + + effect++; + } +} + +void EnFishing_SpawnRainDrop(FishingEffect* effect, Vec3f* pos, Vec3f* rot) { + s16 i; + Vec3f velSrc; + + velSrc.x = 0.0f; + velSrc.y = 0.0f; + velSrc.z = 300.0f; + + effect += 30; + + for (i = 30; i < EFFECT_COUNT; i++) { + if (effect->type == FS_EFF_NONE) { + effect->type = FS_EFF_RAIN_DROP; + effect->pos = *pos; + effect->accel = sZeroVec; + effect->unk_34 = rot->x; + effect->unk_38 = rot->y; + effect->unk_3C = rot->z; + Matrix_InsertYRotation_f(rot->y, MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(rot->x); + Matrix_MultiplyVector3fByState(&velSrc, &effect->vel); + break; + } + + effect++; + } +} + +static FishingPropInit sPondPropInits[POND_PROP_COUNT + 1] = { + { FS_PROP_ROCK, { 529, -53, -498 } }, + { FS_PROP_ROCK, { 461, -66, -480 } }, + { FS_PROP_ROCK, { 398, -73, -474 } }, + { FS_PROP_ROCK, { -226, -52, -691 } }, + { FS_PROP_ROCK, { -300, -41, -710 } }, + { FS_PROP_ROCK, { -333, -50, -643 } }, + { FS_PROP_ROCK, { -387, -46, -632 } }, + { FS_PROP_ROCK, { -484, -43, -596 } }, + { FS_PROP_ROCK, { -409, -57, -560 } }, + { FS_PROP_WOOD_POST, { 444, -87, -322 } }, + { FS_PROP_WOOD_POST, { 447, -91, -274 } }, + { FS_PROP_WOOD_POST, { 395, -109, -189 } }, + { FS_PROP_REED, { 617, -29, 646 } }, + { FS_PROP_REED, { 698, -26, 584 } }, + { FS_PROP_REED, { 711, -29, 501 } }, + { FS_PROP_REED, { 757, -28, 457 } }, + { FS_PROP_REED, { 812, -29, 341 } }, + { FS_PROP_REED, { 856, -30, 235 } }, + { FS_PROP_REED, { 847, -31, 83 } }, + { FS_PROP_REED, { 900, -26, 119 } }, + { FS_PROP_LILY_PAD, { 861, -22, 137 } }, + { FS_PROP_LILY_PAD, { 836, -22, 150 } }, + { FS_PROP_LILY_PAD, { 829, -22, 200 } }, + { FS_PROP_LILY_PAD, { 788, -22, 232 } }, + { FS_PROP_LILY_PAD, { 803, -22, 319 } }, + { FS_PROP_LILY_PAD, { 756, -22, 348 } }, + { FS_PROP_LILY_PAD, { 731, -22, 377 } }, + { FS_PROP_LILY_PAD, { 700, -22, 392 } }, + { FS_PROP_LILY_PAD, { 706, -22, 351 } }, + { FS_PROP_LILY_PAD, { 677, -22, 286 } }, + { FS_PROP_LILY_PAD, { 691, -22, 250 } }, + { FS_PROP_LILY_PAD, { 744, -22, 290 } }, + { FS_PROP_LILY_PAD, { 766, -22, 201 } }, + { FS_PROP_LILY_PAD, { 781, -22, 128 } }, + { FS_PROP_LILY_PAD, { 817, -22, 46 } }, + { FS_PROP_LILY_PAD, { 857, -22, -50 } }, + { FS_PROP_LILY_PAD, { 724, -22, 110 } }, + { FS_PROP_LILY_PAD, { 723, -22, 145 } }, + { FS_PROP_LILY_PAD, { 728, -22, 202 } }, + { FS_PROP_LILY_PAD, { 721, -22, 237 } }, + { FS_PROP_LILY_PAD, { 698, -22, 312 } }, + { FS_PROP_LILY_PAD, { 660, -22, 349 } }, + { FS_PROP_LILY_PAD, { 662, -22, 388 } }, + { FS_PROP_LILY_PAD, { 667, -22, 432 } }, + { FS_PROP_LILY_PAD, { 732, -22, 429 } }, + { FS_PROP_LILY_PAD, { 606, -22, 366 } }, + { FS_PROP_LILY_PAD, { 604, -22, 286 } }, + { FS_PROP_LILY_PAD, { 620, -22, 217 } }, + { FS_PROP_LILY_PAD, { 663, -22, 159 } }, + { FS_PROP_LILY_PAD, { 682, -22, 73 } }, + { FS_PROP_LILY_PAD, { 777, -22, 83 } }, + { FS_PROP_LILY_PAD, { 766, -22, 158 } }, + { FS_PROP_REED, { 1073, 0, -876 } }, + { FS_PROP_REED, { 970, 0, -853 } }, + { FS_PROP_REED, { 896, 0, -886 } }, + { FS_PROP_REED, { 646, -27, -651 } }, + { FS_PROP_REED, { 597, -29, -657 } }, + { FS_PROP_REED, { 547, -32, -651 } }, + { FS_PROP_REED, { 690, -29, -546 } }, + { FS_PROP_REED, { 720, -29, -490 } }, + { FS_PROP_REED, { -756, -30, -409 } }, + { FS_PROP_REED, { -688, -34, -458 } }, + { FS_PROP_REED, { -613, -34, -581 } }, + { FS_PROP_LILY_PAD, { -593, -22, -479 } }, + { FS_PROP_LILY_PAD, { -602, -22, -421 } }, + { FS_PROP_LILY_PAD, { -664, -22, -371 } }, + { FS_PROP_LILY_PAD, { -708, -22, -316 } }, + { FS_PROP_LILY_PAD, { -718, -22, -237 } }, + { FS_PROP_REED, { -807, -36, -183 } }, + { FS_PROP_REED, { -856, -29, -259 } }, + { FS_PROP_LILY_PAD, { -814, -22, -317 } }, + { FS_PROP_LILY_PAD, { -759, -22, -384 } }, + { FS_PROP_LILY_PAD, { -718, -22, -441 } }, + { FS_PROP_LILY_PAD, { -474, -22, -567 } }, + { FS_PROP_LILY_PAD, { -519, -22, -517 } }, + { FS_PROP_LILY_PAD, { -539, -22, -487 } }, + { FS_PROP_LILY_PAD, { -575, -22, -442 } }, + { FS_PROP_LILY_PAD, { -594, -22, -525 } }, + { FS_PROP_LILY_PAD, { -669, -22, -514 } }, + { FS_PROP_LILY_PAD, { -653, -22, -456 } }, + { FS_PROP_REED, { -663, -28, -606 } }, + { FS_PROP_REED, { -708, -26, -567 } }, + { FS_PROP_REED, { -739, -27, -506 } }, + { FS_PROP_REED, { -752, -28, -464 } }, + { FS_PROP_REED, { -709, -29, -513 } }, + { FS_PROP_LILY_PAD, { -544, -22, -436 } }, + { FS_PROP_LILY_PAD, { -559, -22, -397 } }, + { FS_PROP_LILY_PAD, { -616, -22, -353 } }, + { FS_PROP_LILY_PAD, { -712, -22, -368 } }, + { FS_PROP_LILY_PAD, { -678, -22, -403 } }, + { FS_PROP_LILY_PAD, { -664, -22, -273 } }, + { FS_PROP_LILY_PAD, { -630, -22, -276 } }, + { FS_PROP_LILY_PAD, { -579, -22, -311 } }, + { FS_PROP_LILY_PAD, { -588, -22, -351 } }, + { FS_PROP_LILY_PAD, { -555, -22, -534 } }, + { FS_PROP_LILY_PAD, { -547, -22, -567 } }, + { FS_PROP_LILY_PAD, { -592, -22, -571 } }, + { FS_PROP_LILY_PAD, { -541, -22, -610 } }, + { FS_PROP_LILY_PAD, { -476, -22, -629 } }, + { FS_PROP_LILY_PAD, { -439, -22, -598 } }, + { FS_PROP_LILY_PAD, { -412, -22, -550 } }, + { FS_PROP_LILY_PAD, { -411, -22, -606 } }, + { FS_PROP_LILY_PAD, { -370, -22, -634 } }, + { FS_PROP_LILY_PAD, { -352, -22, -662 } }, + { FS_PROP_LILY_PAD, { -413, -22, -641 } }, + { FS_PROP_LILY_PAD, { -488, -22, -666 } }, + { FS_PROP_LILY_PAD, { -578, -22, -656 } }, + { FS_PROP_LILY_PAD, { -560, -22, -640 } }, + { FS_PROP_LILY_PAD, { -531, -22, -654 } }, + { FS_PROP_LILY_PAD, { -451, -22, -669 } }, + { FS_PROP_LILY_PAD, { -439, -22, -699 } }, + { FS_PROP_LILY_PAD, { -482, -22, -719 } }, + { FS_PROP_LILY_PAD, { -524, -22, -720 } }, + { FS_PROP_LILY_PAD, { -569, -22, -714 } }, + { FS_PROP_REED, { -520, -27, -727 } }, + { FS_PROP_REED, { -572, -28, -686 } }, + { FS_PROP_REED, { -588, -32, -631 } }, + { FS_PROP_REED, { -622, -34, -571 } }, + { FS_PROP_REED, { -628, -36, -510 } }, + { FS_PROP_REED, { -655, -36, -466 } }, + { FS_PROP_REED, { -655, -41, -393 } }, + { FS_PROP_REED, { -661, -47, -328 } }, + { FS_PROP_REED, { -723, -40, -287 } }, + { FS_PROP_REED, { -756, -33, -349 } }, + { FS_PROP_REED, { -755, -43, -210 } }, + { FS_PROP_LILY_PAD, { -770, -22, -281 } }, + { FS_PROP_LILY_PAD, { -750, -22, -313 } }, + { FS_PROP_LILY_PAD, { -736, -22, -341 } }, + { FS_PROP_LILY_PAD, { -620, -22, -418 } }, + { FS_PROP_LILY_PAD, { -601, -22, -371 } }, + { FS_PROP_LILY_PAD, { -635, -22, -383 } }, + { FS_PROP_LILY_PAD, { -627, -22, -311 } }, + { FS_PROP_LILY_PAD, { -665, -22, -327 } }, + { FS_PROP_LILY_PAD, { -524, -22, -537 } }, + { FS_PROP_LILY_PAD, { -514, -22, -579 } }, + { FS_PROP_LILY_PAD, { -512, -22, -623 } }, + { FS_PROP_LILY_PAD, { -576, -22, -582 } }, + { FS_PROP_LILY_PAD, { -600, -22, -608 } }, + { FS_PROP_LILY_PAD, { -657, -22, -531 } }, + { FS_PROP_LILY_PAD, { -641, -22, -547 } }, + { FS_PROP_INIT_STOP, { 0 } }, +}; + +void EnFishing_InitPondProps(EnFishing* this, GlobalContext* globalCtx) { + FishingProp* prop = &sPondProps[0]; + Vec3f colliderPos; + s16 i; + + EnFishing_SeedRand(1, 29100, 9786); + + for (i = 0; i < POND_PROP_COUNT; i++) { + if (sPondPropInits[i].type == FS_PROP_INIT_STOP) { + break; + } + + prop->type = sPondPropInits[i].type; + prop->pos.x = sPondPropInits[i].pos.x; + prop->pos.y = sPondPropInits[i].pos.y; + prop->pos.z = sPondPropInits[i].pos.z; + prop->rotX = 0.0f; + prop->reedAngle = 0.0f; + + prop->timer = Rand_ZeroFloat(100.0f); + prop->drawDistance = 800.0f; + + if (prop->type == FS_PROP_REED) { + prop->scale = (EnFishing_RandZeroOne() * 0.25f) + 0.75f; + prop->reedAngle = Rand_ZeroFloat(2 * M_PI); + if (sLinkAge == 1) { + prop->scale *= 0.6f; + } + prop->drawDistance = 1200.0f; + } else if (prop->type == FS_PROP_WOOD_POST) { + prop->scale = 0.08f; + prop->drawDistance = 1200.0f; + colliderPos = prop->pos; + colliderPos.y += 50.0f; + EnFishing_SetColliderElement(i, &sFishingMain->collider, &colliderPos, prop->scale * 3.5f); + } else if (prop->type == FS_PROP_LILY_PAD) { + prop->scale = (EnFishing_RandZeroOne() * 0.3f) + 0.5f; + prop->rotY = Rand_ZeroFloat(2 * M_PI); + if (sLinkAge == 1) { + if ((i % 4) != 0) { + prop->scale *= 0.6f; + } else { + prop->type = FS_PROP_NONE; + } + } + } else { + prop->scale = (EnFishing_RandZeroOne() * 0.1f) + 0.3f; + prop->rotY = Rand_ZeroFloat(2 * M_PI); + prop->drawDistance = 1000.0f; + EnFishing_SetColliderElement(i, &sFishingMain->collider, &prop->pos, prop->scale); + } + + prop++; + } +} + +static FishingFishInit sFishInits[] = { + { 0, { 666, -45, 354 }, 38, 0.1f }, { 0, { 681, -45, 240 }, 36, 0.1f }, { 0, { 670, -45, 90 }, 41, 0.05f }, + { 0, { 615, -45, -450 }, 35, 0.2f }, { 0, { 500, -45, -420 }, 39, 0.1f }, { 0, { 420, -45, -550 }, 44, 0.05f }, + { 0, { -264, -45, -640 }, 40, 0.1f }, { 0, { -470, -45, -540 }, 34, 0.2f }, { 0, { -557, -45, -430 }, 54, 0.01f }, + { 0, { -260, -60, -330 }, 47, 0.05f }, { 0, { -500, -60, 330 }, 42, 0.06f }, { 0, { 428, -40, -283 }, 33, 0.2f }, + { 0, { 409, -70, -230 }, 57, 0.0f }, { 0, { 450, -67, -300 }, 63, 0.0f }, { 0, { -136, -65, -196 }, 71, 0.0f }, + { 1, { -561, -35, -547 }, 45, 0.0f }, { 1, { 667, -35, 317 }, 43, 0.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), }; +void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnFishing* this = THIS; + u16 fishCount; + + Actor_ProcessInitChain(thisx, sInitChain); + ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); + + sLinkAge = gSaveContext.linkAge; + + if (thisx->params < 100) { + s16 i; + FishingGroupFish* fish; + + D_809171C8 = 0; + sFishingMain = this; + Collider_InitJntSph(globalCtx, &sFishingMain->collider); + Collider_SetJntSph(globalCtx, &sFishingMain->collider, thisx, &sJntSphInit, sFishingMain->colliderElements); + + thisx->params = 1; + + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingOwnerSkel, &gFishingOwnerAnim, NULL, NULL, 0); + Animation_MorphToLoop(&this->skelAnime, &gFishingOwnerAnim, 0.0f); + + thisx->update = EnFishing_UpdateOwner; + thisx->draw = EnFishing_DrawOwner; + + thisx->shape.rot.y = -0x6000; + thisx->world.pos.x = 160.0f; + thisx->world.pos.y = -2.0f; + thisx->world.pos.z = 1208.0f; + + Actor_SetScale(thisx, 0.011f); + + thisx->focus.pos = thisx->world.pos; + thisx->focus.pos.y += 75.0f; + thisx->flags |= 9; + + if (sLinkAge != 1) { + // HIGH_SCORE(HS_FISHING) from OoT + if (gSaveContext.roomInf[127][2] & 0x1000) { + D_8090CD08 = 0; + } else { + D_8090CD08 = 1; + } + } else { + D_8090CD08 = 2; + } + + D_8090CD04 = 20; + globalCtx->specialEffects = sFishingEffects; + REG(15) = 1; // gTimeIncrement in OoT + D_809171FC = 0; + D_809171F6 = 10; + + Audio_QueueSeqCmd(0x100100FF); + + if (sLinkAge == 1) { + if (gSaveContext.roomInf[127][2] & 0x7F) { + D_809171CC = gSaveContext.roomInf[127][2] & 0x7F; + } else { + D_809171CC = 40.0f; + } + } else if (gSaveContext.roomInf[127][2] & 0x7F000000) { + D_809171CC = (gSaveContext.roomInf[127][2] & 0x7F000000) >> 0x18; + } else { + D_809171CC = 45.0f; + } + + D_809171D1 = (gSaveContext.roomInf[127][2] & 0xFF0000) >> 0x10; + if ((D_809171D1 & 7) == 7) { + globalCtx->roomCtx.unk7A[0] = 90; + D_809171CA = 1; + } else { + globalCtx->roomCtx.unk7A[0] = 40; + D_809171CA = 0; + } + + if ((D_809171D1 & 7) == 6) { + D_809171CB = 100; + } else { + D_809171CB = 0; + } + + for (i = 0; i < EFFECT_COUNT; i++) { + sFishingEffects[i].type = FS_EFF_NONE; + } + + for (i = 0; i < POND_PROP_COUNT; i++) { + sPondProps[i].type = FS_PROP_NONE; + } + + sFishGroupAngle1 = 0.7f; + sFishGroupAngle2 = 2.3f; + sFishGroupAngle3 = 4.6f; + + for (i = 0; i < GROUP_FISH_COUNT; i++) { + fish = &sGroupFishes[i]; + + fish->type = FS_GROUP_FISH_NORMAL; + + if (i <= 20) { + fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle1) * 720.0f; + fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle1) * 720.0f; + } else if (i <= 40) { + fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle2) * 720.0f; + fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle2) * 720.0f; + } else { + fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle3) * 720.0f; + fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle3) * 720.0f; + } + + fish->unk_10.y = fish->pos.y = -35.0f; + + fish->timer = Rand_ZeroFloat(100.0f); + + fish->unk_3C = 0; + fish->unk_3E = 0; + fish->unk_40 = 0; + + if (sLinkAge != 1) { + if (((i >= 15) && (i < 20)) || ((i >= 35) && (i < 40)) || ((i >= 55) && (i < 60))) { + fish->type = FS_GROUP_FISH_NONE; + } + } + } + + EnFishing_InitPondProps(this, globalCtx); + Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_KANBAN, 53.0f, -17.0f, 982.0f, 0, 0, 0, + ENKANBAN_FISHING); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FISHING, 0.0f, 0.0f, 0.0f, 0, 0, 0, 200); + + if ((D_809171D1 & 3) == 3) { + if (sLinkAge != 1) { + fishCount = 16; + } else { + fishCount = 17; + } + } else { + fishCount = 15; + } + + for (i = 0; i < fishCount; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FISHING, sFishInits[i].pos.x, sFishInits[i].pos.y, + sFishInits[i].pos.z, 0, Rand_ZeroFloat(0x10000), 0, 100 + i); + } + + return; + } + + thisx->bgCheckFlags |= 0x800; // Added in MM + + if ((thisx->params < 115) || (thisx->params == 200)) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, NULL, NULL, 0); + Animation_MorphToLoop(&this->skelAnime, &gFishingFishAnim, 0.0f); + } else { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingLoachSkel, &gFishingLoachAnim, NULL, NULL, 0); + Animation_MorphToLoop(&this->skelAnime, &gFishingLoachAnim, 0.0f); + } + + SkelAnime_Update(&this->skelAnime); + + if (thisx->params == 200) { + this->unk_150 = 100; + func_800BC154(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_PROP); + thisx->targetMode = 0; + thisx->flags |= 9; + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + } else { + this->unk_150 = 10; + this->unk_152 = 10; + + this->unk_148 = sFishInits[thisx->params - 100].unk_00; + this->unk_1A0 = sFishInits[thisx->params - 100].unk_0C; + this->unk_1A4 = sFishInits[thisx->params - 100].unk_08; + + this->unk_1A4 += Rand_ZeroFloat(4.99999f); + + if ((this->unk_1A4 >= 65.0f) && (Rand_ZeroOne() < 0.05f)) { + this->unk_1A4 += Rand_ZeroFloat(7.99999f); + } + + if (sLinkAge == 1) { + this->unk_1A4 *= 0.73f; + } + } +} + +void EnFishing_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnFishing* this = THIS; + + SkelAnime_Free(&this->skelAnime, globalCtx); + + if (thisx->params == 200) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + } else if (thisx->params == 1) { + Collider_DestroyJntSph(globalCtx, &this->collider); + } +} + +void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { + f32 rippleY; + s16 i; + + for (i = 0; i < EFFECT_COUNT; i++) { + if (effect->type) { + effect->timer++; + effect->pos.x += effect->vel.x; + effect->pos.y += effect->vel.y; + effect->pos.z += effect->vel.z; + effect->vel.y += effect->accel.y; + + if (effect->type == FS_EFF_RIPPLE) { + Math_ApproachF(&effect->unk_30, effect->unk_34, 0.2f, effect->unk_38); + + if (effect->unk_2C == 0) { + effect->alpha += 20; + + if (effect->alpha >= effect->unk_2E) { + effect->alpha = effect->unk_2E; + effect->unk_2C++; + } + } else { + effect->alpha -= 8; + + if (effect->alpha <= 0) { + effect->type = FS_EFF_NONE; + } + } + } else if (effect->type == FS_EFF_WATER_DUST) { + Math_ApproachF(&effect->unk_30, effect->unk_34, 0.1f, 0.1f); + effect->alpha -= 10; + + if (effect->pos.y > (WATER_SURFACE_Y(globalCtx) - 5.0f)) { + effect->accel.y = 0.0f; + effect->vel.y = 0.0f; + effect->alpha -= 5; + } + + if (effect->alpha <= 0) { + effect->type = FS_EFF_NONE; + } + } else if (effect->type == FS_EFF_BUBBLE) { + if (effect->unk_2C == 0) { + rippleY = WATER_SURFACE_Y(globalCtx); + } else { + rippleY = 69.0f; + } + + if (effect->pos.y >= rippleY) { + effect->type = FS_EFF_NONE; + + if (Rand_ZeroOne() < 0.3f) { + Vec3f pos = effect->pos; + pos.y = rippleY; + EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &pos, 20.0f, 60.0f, 150, 90); + } + } + } else if (effect->type == FS_EFF_DUST_SPLASH) { + if (effect->vel.y < -20.0f) { + effect->vel.y = -20.0f; + effect->accel.y = 0.0f; + } + + if (effect->pos.y <= WATER_SURFACE_Y(globalCtx)) { + effect->type = FS_EFF_NONE; + if (Rand_ZeroOne() < 0.5f) { + Vec3f pos = effect->pos; + pos.y = WATER_SURFACE_Y(globalCtx); + EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &pos, 40.0f, 110.0f, 150, 90); + } + } + } else if (effect->type == FS_EFF_RAIN_DROP) { + if (effect->pos.y < WATER_SURFACE_Y(globalCtx)) { + f32 sqDistXZ = SQ(effect->pos.x) + SQ(effect->pos.z); + + if (sqDistXZ > SQ(920.0f)) { + effect->pos.y = WATER_SURFACE_Y(globalCtx) + ((sqrtf(sqDistXZ) - 920.0f) * 0.11f); + effect->timer = 2; + effect->type = FS_EFF_RAIN_SPLASH; + effect->unk_30 = (KREG(18) + 30) * 0.001f; + } else { + effect->pos.y = WATER_SURFACE_Y(globalCtx) + 3.0f; + effect->timer = 0; + if (Rand_ZeroOne() < 0.75f) { + effect->type = FS_EFF_RAIN_RIPPLE; + effect->vel = sZeroVec; + effect->unk_30 = 30 * 0.001f; + } else { + effect->type = FS_EFF_NONE; + } + } + + effect->vel = sZeroVec; + } + } else if (effect->type >= FS_EFF_RAIN_RIPPLE) { + effect->unk_30 += (KREG(18) + 30) * 0.001f; + + if (effect->timer >= 6) { + effect->type = FS_EFF_NONE; + } + } else if (effect->type == FS_EFF_OWNER_HAT) { + f32 sqDistXZ; + f32 bottomY; + + effect->unk_30 = 0.010000001f; + + Math_ApproachS(&sEffOwnerHatRot.y, 0, 20, 100); + Math_ApproachS(&sEffOwnerHatRot.x, 0, 20, 100); + Math_ApproachS(&sEffOwnerHatRot.z, -0x4000, 20, 100); + + sqDistXZ = SQ(effect->pos.x) + SQ(effect->pos.z); + bottomY = WATER_SURFACE_Y(globalCtx) + ((sqrtf(sqDistXZ) - 920.0f) * 0.147f); + + if (effect->pos.y > (bottomY - 10.0f)) { + effect->pos.y -= 0.1f; + } + + if ((effect->timer % 16) == 0) { + Vec3f pos = effect->pos; + pos.y = WATER_SURFACE_Y(globalCtx); + EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &pos, 30.0f, 300.0f, 150, 90); + } + + if (effect->unk_2C >= 0) { + effect->unk_2C++; + } + + if (effect->unk_2C == 30) { + func_801518B0(globalCtx, 0x40B3, NULL); + } + + if ((effect->unk_2C >= 100) && (Message_GetState(&globalCtx->msgCtx) == 5)) { + if (func_80147624(globalCtx) || !Message_GetState(&globalCtx->msgCtx)) { + func_801477B4(globalCtx); + func_801159EC(-50); + effect->unk_2C = -1; + } + } + } + } + + effect++; + } +} + +void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { + u8 flag = 0; + f32 rotY; + s16 i; + s32 pad; + FishingEffect* firstEffect = effect; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + gDPPipeSync(POLY_XLU_DISP++); + + for (i = 0; i < 100; i++) { + if (effect->type == FS_EFF_RIPPLE) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gFishingRippleSetupDL); + gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, effect->alpha); + + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Scale(effect->unk_30, 1.0f, effect->unk_30, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gFishingRippleVtxDL); + } + effect++; + } + + effect = firstEffect; + flag = 0; + for (i = 0; i < 100; i++) { + if (effect->type == FS_EFF_DUST_SPLASH) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gFishingDustSplashSetupDL); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 0); + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, effect->alpha); + + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gFishingDustSplashVtxDL); + } + effect++; + } + + effect = firstEffect; + flag = 0; + for (i = 0; i < 100; i++) { + if (effect->type == FS_EFF_WATER_DUST) { + if (flag == 0) { + gSPDisplayList(POLY_OPA_DISP++, gFishingWaterDustSetupDL); + gDPSetEnvColor(POLY_OPA_DISP++, 40, 90, 80, 128); + flag++; + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 40, 90, 80, effect->alpha); + + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->timer + (i * 3), + (effect->timer + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); + + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gFishingWaterDustVtxDL); + } + effect++; + } + + effect = firstEffect; + flag = 0; + for (i = 0; i < 100; i++) { + if (effect->type == FS_EFF_BUBBLE) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gFishingBubbleSetupDL); + gDPSetEnvColor(POLY_XLU_DISP++, 150, 150, 150, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + flag++; + } + + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gFishingBubbleVtxDL); + } + effect++; + } + + effect = firstEffect + 30; + flag = 0; + for (i = 30; i < EFFECT_COUNT; i++) { + if (effect->type == FS_EFF_RAIN_DROP) { + if (flag == 0) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); + gDPSetCombineMode(POLY_XLU_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 150, 255, 255, 30); + flag++; + } + + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(effect->unk_38, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(effect->unk_34); + Matrix_InsertZRotation_f(effect->unk_3C, MTXMODE_APPLY); + Matrix_Scale(0.002f, 1.0f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gFishingRainDropVtxDL); + } + effect++; + } + + func_8012C2DC(globalCtx->state.gfxCtx); + + effect = firstEffect + 30; + flag = 0; + for (i = 30; i < EFFECT_COUNT; i++) { + if (effect->type == FS_EFF_RAIN_RIPPLE) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gFishingRippleSetupDL); + gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 130); + flag++; + } + + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Scale(effect->unk_30, 1.0f, effect->unk_30, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gFishingRippleVtxDL); + } + effect++; + } + + effect = firstEffect + 30; + flag = 0; + for (i = 30; i < EFFECT_COUNT; i++) { + if (effect->type == FS_EFF_RAIN_SPLASH) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gFishingRainSplashSetupDL); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, KREG(19) + 80); + flag++; + } + + if (Rand_ZeroOne() < 0.5f) { + rotY = 0.0f; + } else { + rotY = M_PI; + } + + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_InsertYRotation_f(rotY, MTXMODE_APPLY); + Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gFishingRainSplashVtxDL); + } + effect++; + } + + effect = firstEffect; + if (effect->type == FS_EFF_OWNER_HAT) { + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f((sEffOwnerHatRot.y * M_PI) / 32768, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis((sEffOwnerHatRot.x * M_PI) / 32768); + Matrix_InsertZRotation_f((sEffOwnerHatRot.z * M_PI) / 32768, MTXMODE_APPLY); + Matrix_Scale(effect->unk_30, effect->unk_30, effect->unk_30, MTXMODE_APPLY); + Matrix_InsertTranslation(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(M_PI / 2); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); + } + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFishing_DrawStreamSplash(GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames * 1, + globalCtx->gameplayFrames * 8, 32, 64, 1, -globalCtx->gameplayFrames * 2, 0, 16, 16)); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, 50); + + Matrix_InsertTranslation(670.0f, -24.0f, -600.0f, MTXMODE_NEW); + Matrix_Scale(0.02f, 1.0f, 0.02f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingStreamSplashDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 func_808FEF70(Vec3f* vec) { + if (((vec->x >= 110.0f) && (vec->x <= 150.0f) && (vec->z <= 1400.0f) && (vec->z >= 1160.0f)) || + ((vec->x >= 110.0f) && (vec->x <= 210.0f) && (vec->z <= 1200.0f) && (vec->z >= 1160.0f))) { + if (vec->y <= 42.0f) { + return true; + } + } + + return false; +} + +void EnFishing_UpdateLine(GlobalContext* globalCtx, Vec3f* basePos, Vec3f* pos, Vec3f* rot, Vec3f* unk) { + s32 i; + s32 k; + f32 dx; + f32 dy; + f32 dz; + f32 rx; + f32 ry; + f32 dist; + f32 spD8; + s32 temp_s2; + s32 pad; + f32 temp_f20; + Vec3f posSrc = { 0.0f, 0.0f, 0.0f }; + Vec3f posStep; + f32 phi_f12; + Vec3f spA4; + Vec3f sp98; + f32 sp94; + f32 sp90; + f32 sp8C; + f32 sqDistXZ; + f32 temp_f18; + + if (D_8090CD24 != 0) { + spA4 = *basePos; + sp98 = pos[LINE_SEG_COUNT - 1]; + + sp94 = sp98.x - spA4.x; + sp90 = sp98.y - spA4.y; + sp8C = sp98.z - spA4.z; + + temp_f20 = sqrtf(SQ(sp94) + SQ(sp90) + SQ(sp8C)) * 0.97f; + if (temp_f20 > 1000.0f) { + temp_f20 = 1000.0f; + } + + D_809101C0 = 200.0f - (temp_f20 * 200.0f * 0.001f); + } + + temp_s2 = D_809101C0; + posSrc.z = 5.0f; + + for (i = 0; i < LINE_SEG_COUNT; i++) { + if (i <= temp_s2) { + pos[i] = *basePos; + } else if (D_8090CD24 != 0) { + temp_f20 = (f32)(i - temp_s2) / (f32)(LINE_SEG_COUNT - temp_s2 + 1); + Math_ApproachF(&pos[i].x, (sp94 * temp_f20) + spA4.x, 1.0f, 20.0f); + Math_ApproachF(&pos[i].y, (sp90 * temp_f20) + spA4.y, 1.0f, 20.0f); + Math_ApproachF(&pos[i].z, (sp8C * temp_f20) + spA4.z, 1.0f, 20.0f); + } + } + + for (i = temp_s2 + 1, k = 0; i < LINE_SEG_COUNT; i++, k++) { + temp_f18 = 2.0f * D_809101C4; + + dx = (pos + i)->x - (pos + i - 1)->x; + spD8 = (pos + i)->y; + + sqDistXZ = SQ((pos + i)->x) + SQ((pos + i)->z); + + if (sqDistXZ > SQ(920.0f)) { + phi_f12 = ((sqrtf(sqDistXZ) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + } else { + phi_f12 = WATER_SURFACE_Y(globalCtx); + } + + if (D_80917206 == 2) { + f32 phi_f2; + + if (spD8 < phi_f12) { + phi_f12 = ((sqrtf(sqDistXZ) - 920.0f) * 0.147f) + WATER_SURFACE_Y(globalCtx); + if (spD8 > phi_f12) { + u8 temp; + + phi_f2 = (spD8 - phi_f12) * 0.05f; + + if (phi_f2 > 0.29999998f) { + phi_f2 = 0.29999998f; + } + if (i >= 100) { + phi_f2 *= (i - 100) * 0.02f; + spD8 -= phi_f2; + } + } + } else { + spD8 -= temp_f18; + } + } else if (i > LINE_SEG_COUNT - 10) { + if (spD8 > phi_f12) { + f32 phi_f2 = (spD8 - phi_f12) * 0.2f; + + phi_f2 = CLAMP_MAX(phi_f2, temp_f18); + spD8 -= phi_f2; + } + } else { + if (spD8 > phi_f12) { + spD8 -= temp_f18; + } + } + + if (func_808FEF70(&pos[i])) { + spD8 = 42.0f; + } + + dy = spD8 - (pos + i - 1)->y; + dz = (pos + i)->z - (pos + i - 1)->z; + + ry = Math_Acot2F(dz, dx); + dist = sqrtf(SQ(dx) + SQ(dz)); + rx = -Math_Acot2F(dist, dy); + + (rot + i - 1)->y = ry; + (rot + i - 1)->x = rx; + + Matrix_InsertYRotation_f(ry, MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(rx); + Matrix_MultiplyVector3fByState(&posSrc, &posStep); + + (pos + i)->x = (pos + i - 1)->x + posStep.x; + (pos + i)->y = (pos + i - 1)->y + posStep.y; + (pos + i)->z = (pos + i - 1)->z + posStep.z; + } +} + +void EnFishing_UpdateLinePos(Vec3f* pos) { + s32 i; + f32 dx; + f32 dy; + f32 dz; + f32 rx; + f32 ry; + f32 dist; + Vec3f posSrc = { 0.0f, 0.0f, 0.0f }; + Vec3f posStep; + s32 min = D_809101C0; + + posSrc.z = 5.0f; + + for (i = LINE_SEG_COUNT - 2; i > min; i--) { + dx = (pos + i)->x - (pos + i + 1)->x; + dy = (pos + i)->y - (pos + i + 1)->y; + dz = (pos + i)->z - (pos + i + 1)->z; + + ry = Math_Acot2F(dz, dx); + dist = sqrtf(SQ(dx) + SQ(dz)); + rx = -Math_Acot2F(dist, dy); + + Matrix_InsertYRotation_f(ry, MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(rx); + Matrix_MultiplyVector3fByState(&posSrc, &posStep); + + (pos + i)->x = (pos + i + 1)->x + posStep.x; + (pos + i)->y = (pos + i + 1)->y + posStep.y; + (pos + i)->z = (pos + i + 1)->z + posStep.z; + } +} + +void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, u8 hookIndex) { + f32 dx; + f32 dy; + f32 dz; + f32 rx; + f32 ry; + f32 dist; + f32 offsetY; + Vec3f posSrc = { 0.0f, 0.0f, 1.0f }; + Vec3f posStep; + Player* player = GET_PLAYER(globalCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + if ((D_8090CD14 == 3) && ((pos->y > WATER_SURFACE_Y(globalCtx)) || ((D_8090CD0C != 0) && hookIndex))) { + offsetY = 0.0f; + } else if (pos->y < WATER_SURFACE_Y(globalCtx)) { + offsetY = -1.0f; + } else { + offsetY = -3.0f; + } + + dx = refPos->x - pos->x; + dy = refPos->y - pos->y + offsetY; + dz = refPos->z - pos->z; + + ry = Math_Acot2F(dz, dx); + dist = sqrtf(SQ(dx) + SQ(dz)); + rx = -Math_Acot2F(dist, dy); + + Matrix_InsertYRotation_f(ry, MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(rx); + Matrix_MultiplyVector3fByState(&posSrc, &posStep); + + refPos->x = pos->x + posStep.x; + refPos->y = pos->y + posStep.y; + refPos->z = pos->z + posStep.z; + + Matrix_InsertTranslation(pos->x, pos->y, pos->z, MTXMODE_NEW); + + if ((player->actor.speedXZ == 0.0f) && (D_809101B4 == 0.0f)) { + Math_ApproachF(&sLureHookRotY[hookIndex], ry, 0.1f, 0.3f); + } else { + sLureHookRotY[hookIndex] = ry; + } + + Matrix_InsertYRotation_f(sLureHookRotY[hookIndex], MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(rx); + Matrix_Scale(0.0039999997f, 0.0039999997f, 0.005f, MTXMODE_APPLY); + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingLureHookDL); + + Matrix_InsertZRotation_f(M_PI / 2, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingLureHookDL); + + if ((hookIndex == 1) && (D_8090CD0C != 0)) { + Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(250.0f, 0.0f, -1400.0f, MTXMODE_APPLY); + Matrix_StatePush(); + + if (D_8090CD10 != 0) { + FishingEffect* effect = globalCtx->specialEffects; + MtxF mf; + + Matrix_MultiplyVector3fByState(&sZeroVec, &effect->pos); + Matrix_CopyCurrentState(&mf); + func_8018219C(&mf, &sEffOwnerHatRot, 0); + + D_8090CD10 = 0; + D_8090CD0C = 0; + + effect->type = FS_EFF_OWNER_HAT; + effect->unk_2C = 0; + effect->vel = sZeroVec; + effect->accel = sZeroVec; + } + + Matrix_StatePop(); + Matrix_InsertTranslation(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(M_PI / 2); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); + } + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { + s32 i; + f32 dx; + f32 dy; + f32 dz; + f32 rx; + f32 ry; + f32 dist; + f32 offsetY; + Vec3f posSrc = { 0.0f, 0.0f, 0.0f }; + Vec3f posStep; + Vec3f sp94; + Vec3f sp88; + f32 offsetX; + f32 offsetZ; + Player* player = GET_PLAYER(globalCtx); + Vec3f* pos; + s32 pad; + + posSrc.z = 0.85f; + + sSinkingLurePos[0] = sLurePos; + + if (D_8090CD54 != 0) { + offsetY = -1.0f; + } else if (sLurePos.y < WATER_SURFACE_Y(globalCtx)) { + offsetY = 0.5f; + } else { + offsetY = -5.0f; + } + + if (D_8090CD14 == 5) { + Matrix_InsertYRotation_f(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); + sp94.x = 5.0f; + sp94.y = 0.0f; + sp94.z = 3.0f; + Matrix_MultiplyVector3fByState(&sp94, &sp88); + } + + for (i = 1; i < SINKING_LURE_SEG_COUNT; i++) { + pos = sSinkingLurePos; + + if ((i < 10) && (D_8090CD14 == 5)) { + offsetX = (10 - i) * sp88.x * 0.1f; + offsetZ = (10 - i) * sp88.z * 0.1f; + } else { + offsetX = offsetZ = 0.0f; + } + + dx = (pos + i)->x - (pos + i - 1)->x + offsetX; + dy = (pos + i)->y - (pos + i - 1)->y + offsetY; + dz = (pos + i)->z - (pos + i - 1)->z + offsetZ; + + ry = Math_Acot2F(dz, dx); + dist = sqrtf(SQ(dx) + SQ(dz)); + rx = -Math_Acot2F(dist, dy); + + Matrix_InsertYRotation_f(ry, MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(rx); + Matrix_MultiplyVector3fByState(&posSrc, &posStep); + + (pos + i)->x = (pos + i - 1)->x + posStep.x; + (pos + i)->y = (pos + i - 1)->y + posStep.y; + (pos + i)->z = (pos + i - 1)->z + posStep.z; + } +} + +static f32 sSinkingLureSizes[] = { + 1.0f, 1.5f, 1.8f, 2.0f, 1.8f, 1.6f, 1.4f, 1.2f, 1.0f, 1.0f, + 0.9f, 0.85f, 0.8f, 0.7f, 0.8f, 1.0f, 1.2f, 1.1f, 1.0f, 0.8f, +}; + +void EnFishing_DrawSinkingLure(GlobalContext* globalCtx) { + s16 i; + f32 scale; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + EnFishing_UpdateSinkingLure(globalCtx); + + if (sLurePos.y < WATER_SURFACE_Y(globalCtx)) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, gFishingSinkingLureSegmentSetupDL); + + for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { + if ((i + D_80911F20) < SINKING_LURE_SEG_COUNT) { + Matrix_InsertTranslation(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); + scale = sSinkingLureSizes[i + D_80911F20] * 0.04f; + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingSinkingLureSegmentVtxDL); + } + } + } else { + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_XLU_DISP++, gFishingSinkingLureSegmentSetupDL); + + for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { + if ((i + D_80911F20) < SINKING_LURE_SEG_COUNT) { + Matrix_InsertTranslation(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); + scale = sSinkingLureSizes[i + D_80911F20] * 0.04f; + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingSinkingLureSegmentVtxDL); + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* lineRot) { + Vec3f posSrc; + Vec3f posStep; + Vec3f hookPos[2]; + s32 i; + s32 spB4 = D_809101C0; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_StatePush(); + + if (D_8090CD54 != 0) { + Vec3f posTemp = sLurePos; + + sLurePos = sSinkingLureBasePos; + EnFishing_DrawSinkingLure(globalCtx); + sLurePos = posTemp; + } + + if ((D_8090CD14 == 4) || (D_8090CD14 == 5)) { + sLurePos = sFishingHookedFish->fishMouthPos; + + if ((D_8090CD14 == 5) && (D_80917206 == 2)) { + Matrix_InsertYRotation_f(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); + posSrc.x = 2.0f; + posSrc.y = 0.0f; + posSrc.z = 0.0f; + Matrix_MultiplyVector3fByState(&posSrc, &posStep); + sLurePos.x += posStep.x; + sLurePos.z += posStep.z; + } + } else if (D_8090CD14 == 0) { + sLurePos = sReelLinePos[LINE_SEG_COUNT - 1]; + sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; + + if ((player->actor.speedXZ == 0.0f) && (D_80917200 == 0)) { + Math_ApproachF(&sLureRot.y, sReelLineRot[LINE_SEG_COUNT - 2].y, 0.1f, 0.2f); + } else { + sLureRot.y = sReelLineRot[LINE_SEG_COUNT - 2].y; + } + } + + if (D_80917206 != 2) { + Matrix_InsertTranslation(sLurePos.x, sLurePos.y, sLurePos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(sLureRot.y + D_80917254, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(sLureRot.x); + Matrix_Scale(0.0039999997f, 0.0039999997f, 0.0039999997f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, D_80917258, MTXMODE_APPLY); + Matrix_InsertZRotation_f(M_PI / 2, MTXMODE_APPLY); + Matrix_InsertYRotation_f(M_PI / 2, MTXMODE_APPLY); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingLureFloatDL); + + posSrc.x = -850.0f; + posSrc.y = 0.0f; + posSrc.z = 0.0f; + Matrix_MultiplyVector3fByState(&posSrc, &D_80917218); + + posSrc.x = 500.0f; + posSrc.z = -300.0f; + Matrix_MultiplyVector3fByState(&posSrc, &hookPos[0]); + EnFishing_DrawLureHook(globalCtx, &hookPos[0], &sLureHookRefPos[0], 0); + + posSrc.x = 2100.0f; + posSrc.z = -50.0f; + Matrix_MultiplyVector3fByState(&posSrc, &hookPos[1]); + EnFishing_DrawLureHook(globalCtx, &hookPos[1], &sLureHookRefPos[1], 1); + } + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); + + gDPSetCombineMode(POLY_XLU_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 55); + + if ((D_8090CD14 == 4) && ((D_80917274 != 0) || (D_80917206 != 2))) { + f32 rx; + f32 ry; + f32 dist; + f32 dx; + f32 dy; + f32 dz; + + dx = sLurePos.x - sRodTipPos.x; + dy = sLurePos.y - sRodTipPos.y; + dz = sLurePos.z - sRodTipPos.z; + + ry = func_80086B30(dx, dz); + dist = sqrtf(SQ(dx) + SQ(dz)); + rx = -func_80086B30(dy, dist); + + dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) * 0.001f; + + Matrix_InsertTranslation(sRodTipPos.x, sRodTipPos.y, sRodTipPos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(ry, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(rx); + Matrix_Scale(D_809101C8, 1.0f, dist, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingLineVtxDL); + } else { + for (i = spB4; i < LINE_SEG_COUNT - 1; i++) { + if ((i == LINE_SEG_COUNT - 3) && (D_80917206 == 0) && (D_8090CD14 == 3)) { + f32 rx; + f32 ry; + f32 dist; + f32 dx; + f32 dy; + f32 dz; + + dx = D_80917218.x - (linePos + i)->x; + dy = D_80917218.y - (linePos + i)->y; + dz = D_80917218.z - (linePos + i)->z; + + ry = func_80086B30(dx, dz); + dist = sqrtf(SQ(dx) + SQ(dz)); + rx = -func_80086B30(dy, dist); + + dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) * 0.001f; + + Matrix_InsertTranslation((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); + Matrix_InsertYRotation_f(ry, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(rx); + Matrix_Scale(D_809101C8, 1.0f, dist, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingLineVtxDL); + break; + } + + Matrix_InsertTranslation((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); + Matrix_InsertYRotation_f((lineRot + i)->y, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis((lineRot + i)->x); + Matrix_Scale(D_809101C8, 1.0f, 0.005f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingLineVtxDL); + } + } + + Matrix_StatePop(); + func_8012C2DC(globalCtx->state.gfxCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +static f32 sRodScales[22] = { + 1.0f, 1.0f, 1.0f, 0.9625f, 0.925f, 0.8875f, 0.85f, 0.8125f, + 0.775f, 0.73749995f, 0.7f, 0.6625f, 0.625f, 0.5875f, 0.54999995f, 0.5125f, + 0.47499996f, 0.4375f, 0.39999998f, 0.36249995f, 0.325f, 0.28749996f, +}; + +static f32 sRodBendRatios[22] = { + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.06f, 0.12f, 0.18f, 0.24f, 0.30f, 0.36f, + 0.42f, 0.48f, 0.54f, 0.60f, 0.60f, 0.5142f, 0.4285f, 0.3428f, 0.2571f, 0.1714f, 0.0857f, +}; + +static Vec3f sRodTipOffset = { 0.0f, 0.0f, 0.0f }; + +void EnFishing_DrawRod(GlobalContext* globalCtx) { + s16 i; + f32 spC8; + f32 spC4; + f32 spC0; + Input* input = CONTROLLER1(globalCtx); + Player* player = GET_PLAYER(globalCtx); + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (D_80911E28 != 0) { + D_80911E28--; + + Math_ApproachF(&D_8090CD40, 35.0f, 1.0f, 100.0f); + Math_ApproachF(&D_8090CD3C, -0.8f, 1.0f, 0.4f); + Math_ApproachS(&player->actor.shape.rot.x, -4000, 2, 15000); + } else { + s16 target = 0; + + if ((D_8090CD14 == 4) && (D_80917274 != 0)) { + target = Math_SinS(D_809171FE * 25600) * 1500.0f; + } else { + Math_ApproachZeroF(&D_8090CD40, 0.1f, 10.0f); + Math_ApproachZeroF(&D_8090CD3C, 1.0f, 0.05f); + } + + Math_ApproachS(&player->actor.shape.rot.x, target, 5, 1000); + } + + if ((D_8090CD14 == 3) || (D_8090CD14 == 4)) { + if ((input->rel.stick_x == 0) && (D_8090CD44 != 0)) { + D_8090CD30 = 0.0f; + } + if ((input->rel.stick_y == 0) && (D_8090CD48 != 0)) { + D_8090CD34 = 0.0f; + } + + spC8 = player->unk_B08[1]; + Math_SmoothStepToF(&player->unk_B08[1], input->rel.stick_y * 0.02f, 0.3f, 5.0f, 0.0f); + spC8 = player->unk_B08[1] - spC8; + + spC4 = player->unk_B08[0]; + Math_SmoothStepToF(&player->unk_B08[0], input->rel.stick_x * 0.02f, 0.3f, 5.0f, 0.0f); + spC4 = player->unk_B08[0] - spC4; + + if (player->unk_B08[0] > 1.0f) { + player->unk_B08[0] = 1.0f; + } + if (player->unk_B08[1] > 1.0f) { + player->unk_B08[1] = 1.0f; + } + if (player->unk_B08[0] < -1.0f) { + player->unk_B08[0] = -1.0f; + } + if (player->unk_B08[1] < -1.0f) { + player->unk_B08[1] = -1.0f; + } + + Math_ApproachF(&D_8090CD28, spC4 * 70.0f * -0.01f, 1.0f, D_8090CD30); + Math_ApproachF(&D_8090CD30, 1.0f, 1.0f, 0.1f); + Math_ApproachF(&D_8090CD2C, spC8 * 70.0f * 0.01f, 1.0f, D_8090CD34); + Math_ApproachF(&D_8090CD34, 1.0f, 1.0f, 0.1f); + Math_ApproachZeroF(&D_8090CD38, 1.0f, 0.05f); + } else { + Math_ApproachZeroF(&player->unk_B08[1], 1.0f, 0.1f); + Math_ApproachZeroF(&player->unk_B08[0], 1.0f, 0.1f); + Math_ApproachF(&D_8090CD2C, (Math_SinS(D_809171FE * 3000) * 0.025f) + -0.03f, 1.0f, 0.05f); + Math_ApproachZeroF(&D_8090CD28, 1.0f, 0.05f); + + if ((D_80917204 >= 19) && (D_80917204 <= 24)) { + Math_ApproachF(&D_8090CD38, 0.8f, 1.0f, 0.2f); + } else { + Math_ApproachF(&D_8090CD38, 0.0f, 1.0f, 0.4f); + } + } + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, gFishingRodSetupDL); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 155, 0, 255); + + Matrix_InsertMatrix(&player->mf_CC4, MTXMODE_NEW); + + if (sLinkAge != 1) { + Matrix_InsertTranslation(0.0f, 400.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_InsertTranslation(0.0f, 230.0f, 0.0f, MTXMODE_APPLY); + } + + if (D_8090CD14 == 5) { + Matrix_InsertYRotation_f(1.7592919f, MTXMODE_APPLY); + } else { + Matrix_InsertYRotation_f(1.288053f, MTXMODE_APPLY); + } + + Matrix_RotateStateAroundXAxis(-0.6283185f); + Matrix_InsertZRotation_f((player->unk_B08[0] * 0.5f) + 0.4712389f, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis((D_8090CD40 + 20.0f) * 0.01f * M_PI); + Matrix_Scale(0.70000005f, 0.70000005f, 0.70000005f, MTXMODE_APPLY); + + spC0 = (D_8090CD3C * (((player->unk_B08[1] - 1.0f) * -0.25f) + 0.5f)) + (D_8090CD2C + D_8090CD38); + + Matrix_InsertTranslation(0.0f, 0.0f, -1300.0f, MTXMODE_APPLY); + + for (i = 0; i < 22; i++) { + Matrix_InsertYRotation_f(sRodBendRatios[i] * D_8090CD28 * 0.5f, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(sRodBendRatios[i] * spC0 * 0.5f); + + Matrix_StatePush(); + Matrix_Scale(sRodScales[i], sRodScales[i], 0.52f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (i < 5) { + gDPLoadTextureBlock(POLY_OPA_DISP++, &gFishingRodSegmentBlackTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 8, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, 3, G_TX_NOLOD, G_TX_NOLOD); + } else if ((i < 8) || ((i % 2) == 0)) { + gDPLoadTextureBlock(POLY_OPA_DISP++, &gFishingRodSegmentWhiteTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 8, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, 3, G_TX_NOLOD, G_TX_NOLOD); + } else { + gDPLoadTextureBlock(POLY_OPA_DISP++, &gFishingRodSegmentStripTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 8, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, 3, G_TX_NOLOD, G_TX_NOLOD); + } + + gSPDisplayList(POLY_OPA_DISP++, gFishingRodSegmentDL); + + Matrix_StatePop(); + Matrix_InsertTranslation(0.0f, 0.0f, 500.0f, MTXMODE_APPLY); + + if (i == 21) { + Matrix_MultiplyVector3fByState(&sRodTipOffset, &sRodTipPos); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +static Vec3f D_8090D614 = { 0.0f, 0.0f, 0.0f }; + +#ifdef NON_MATCHING +// Stack memes, the pad on line ~2410 makes stack too big, but needed for ordering +void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { + f32 spE4; + f32 spE0; + s16 phi_v0; + s16 spDC; + f32 spD8; + f32 spD4; + f32 spD0; + f32 phi_f16; + f32 spC8; + s16 i; + Player* player = GET_PLAYER(globalCtx); + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + Vec3f spA8; + Vec3f sp9C; + Vec3f sp90; + Input* input = CONTROLLER1(globalCtx); + // Vec3f sp80; + + f32 phi_f0; + // f32 sp70; + // Vec3f sp64; + // Vec3f sp58; + // s32 pad; + + D_809171FE++; + + if (D_80917200 != 0) { + D_80917200--; + } + + if (D_80917202 != 0) { + D_80917202--; + } + + if (D_80917204 != 0) { + D_80917204--; + } + + if (D_80917272 != 0) { + D_80917272--; + } + + if (D_809101CC != 0) { + D_809101CC--; + } + + if (D_8090CD24 != 0) { + D_8090CD24--; + } + + if (D_809171F4 != 0) { + D_809171F4--; + } + + if (D_80917264 != 0) { + D_80917264--; + } + + if (D_809171FC == 1) { + D_809171FC = 2; + D_809171D8 = 0; + D_809171D6 = 0; + D_80917206 = 0; + + // Age and high score check removed in MM + sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; + + D_809101C4 = 520.0f; + D_809101C0 = 195.0f; + + D_8090CD14 = 0; + D_80917206 = 0; + D_809171FE = 0; + D_80917200 = 0; + D_80917202 = 0; + D_80917204 = 0; + D_80917270 = 0; + D_80917264 = 0; + D_809101CC = 0; + + D_80917254 = D_809101D0 = D_80917258 = 0.0f; + + D_80917278 = zeroVec; + + for (i = 0; i < LINE_SEG_COUNT; i++) { + sReelLinePos[i] = zeroVec; + sReelLineRot[i] = zeroVec; + sReelLineUnk[i] = zeroVec; + } + } + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sLurePos, &D_8090D614, &sProjectedW); + + if (D_8090CD14 == 0) { + Math_ApproachF(&D_80917258, -800.0f, 1.0f, 20.0f); + } else { + Math_ApproachF(&D_80917258, 300.0f, 1.0f, 20.0f); + } + + switch (D_8090CD14) { + case 0: + D_80911F20 = 0; + + Math_ApproachF(&D_809101C0, 195.0f, 1.0f, 1.0f); + + if (player->stateFlags1 & 0x8000000) { + D_80917204 = 0; + player->unk_B28 = 0; + } + + if (D_80917204 == 0) { + if ((D_80917200 == 0) && (player->unk_B28 == 1)) { + D_80917204 = 37; + func_801477B4(globalCtx); + } + } else { + sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; + sLureRot.y = sReelLineRot[LINE_SEG_COUNT - 2].y; + + if (D_80917204 == 18) { + D_8090CD14 = 1; + sLurePos = sRodTipPos; + Matrix_InsertYRotation_f(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); + sp90.x = 0.0f; + sp90.y = 0.0f; + sp90.z = 25.0f; + Matrix_MultiplyVector3fByState(&sp90, &D_80917238); + D_80917238.y = 15.0f; + D_80917248.x = D_80917248.z = 0.0f; + D_80917248.y = -1.0f; + D_809101C4 = 0.0f; + D_80917202 = 5; + D_8091726C = 0.5f; + D_80917268 = Rand_ZeroFloat(1.9f); + sFishMouthOffset.y = 500.0f; + Audio_PlaySfxAtPos(&D_8090D614, NA_SE_IT_SWORD_SWING_HARD); + } + } + break; + + case 1: + spE0 = sLurePos.y; + + sLurePos.x += D_80917238.x; + sLurePos.y += D_80917238.y; + sLurePos.z += D_80917238.z; + + D_80917238.x += D_80917248.x; + D_80917238.y += D_80917248.y; + D_80917238.z += D_80917248.z; + + if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_8090CD0C != 0)) { + D_80917238.x *= 0.9f; + D_80917238.z *= 0.9f; + if (D_8090CD0C == 0) { + play_sound(NA_SE_IT_FISHING_REEL_HIGH - SFX_FLAG); + } + } + + spD8 = sLurePos.x - sRodTipPos.x; + spD4 = sLurePos.y - sRodTipPos.y; + spD0 = sLurePos.z - sRodTipPos.z; + + if (D_80917202 != 0) { + sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; + sLureRot.y = sReelLineRot[LINE_SEG_COUNT - 2].y; + } else { + sLureRot.x = 0.0f; + sLureRot.y = Math_Acot2F(spD0, spD8) + M_PI; + } + + phi_f16 = sqrtf(SQ(spD8) + SQ(spD4) + SQ(spD0)); + if (phi_f16 > 1000.0f) { + phi_f16 = 1000.0f; + } + D_809101C0 = 200.0f - (phi_f16 * 200.0f * 0.001f); + + spC8 = SQ(sLurePos.x) + SQ(sLurePos.z); + if (spC8 > SQ(920.0f)) { + f32 temp; + + if ((sLurePos.y > 160.0f) || (sLurePos.x < 80.0f) || (sLurePos.x > 180.0f) || (sLurePos.z > 1350.0f) || + (sLurePos.z < 1100.0f) || (sLurePos.y < 45.0f)) { + Vec3f sp80 = this->actor.world.pos; + + this->actor.prevPos = this->actor.world.pos = sLurePos; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 30.0f, 0x43); + this->actor.world.pos = sp80; + + if (this->actor.bgCheckFlags & 0x10) { + D_80917238.y = -0.5f; + } + if (this->actor.bgCheckFlags & 8) { + if (D_80917238.y > 0.0f) { + D_80917238.y = 0.0f; + } + D_80917238.x = D_80917238.z = 0.0f; + } + } else { + if (func_808FEF70(&sLurePos)) { + D_8090CD14 = 3; + D_809101D0 = 0.0f; + } + } + + temp = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + // spE4 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + if (sLurePos.y <= temp) { + sLurePos.y = temp; + D_80917238.x = D_80917238.y = D_80917238.z = 0.0f; + D_8090CD14 = 3; + D_809101D0 = 0.0; + } else { + Math_ApproachF(&D_809101C4, 0.0f, 1.0f, 0.05f); + Audio_PlaySfxAtPos(&D_8090D614, + NA_SE_EN_WIZ_UNARI - SFX_FLAG); // changed from NA_SE_EN_FANTOM_FLOAT in OoT + } + } else { + f32 sp7C = WATER_SURFACE_Y(globalCtx); + f32 sp78; + // spE4 = WATER_SURFACE_Y(globalCtx); + + if (sLurePos.y <= sp7C) { + D_8090CD14 = 2; + D_809101D0 = 0.0f; + D_80917238.x = D_80917238.z = 0.0f; + + if (D_80917206 == 2) { + D_809171F2 = 0; + } else { + D_809171F2 = 10; + } + + if ((sLurePos.y <= sp7C) && (sp7C < spE0) && (sp7C == WATER_SURFACE_Y(globalCtx))) { + D_80917264 = 10; + Audio_PlaySfxAtPos(&D_8090D614, NA_SE_EV_BOMB_DROP_WATER); + D_80917248.y = 0.0f; + D_80917238.y *= 0.2f; + + for (i = 0; i < 50; i++) { + sp7C = Rand_ZeroFloat(1.5f) + 0.5f; + sp78 = Rand_ZeroFloat(6.28f); + + sp9C.x = __sinf(sp78) * sp7C; + sp9C.z = __cosf(sp78) * sp7C; + sp9C.y = Rand_ZeroFloat(3.0f) + 3.0f; + + spA8 = sLurePos; + spA8.x += (sp9C.x * 3.0f); + spA8.y = WATER_SURFACE_Y(globalCtx); + spA8.z += (sp9C.z * 3.0f); + EnFishing_SpawnDustSplash(NULL, globalCtx->specialEffects, &spA8, &sp9C, + Rand_ZeroFloat(0.02f) + 0.025f); + } + + spA8 = sLurePos; + spA8.y = WATER_SURFACE_Y(globalCtx); + EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &spA8, 100.0f, 800.0f, 150, 90); + } + } else { + Math_ApproachZeroF(&D_809101C4, 1.0f, 0.05f); + Audio_PlaySfxAtPos(&D_8090D614, + NA_SE_EN_WIZ_UNARI - SFX_FLAG); // changed from NA_SE_EN_FANTOM_FLOAT in OoT + } + } + + sReelLinePos[LINE_SEG_COUNT - 1].x = sLurePos.x; + sReelLinePos[LINE_SEG_COUNT - 1].y = sLurePos.y; + sReelLinePos[LINE_SEG_COUNT - 1].z = sLurePos.z; + + D_809101BC = 1.0f; + D_8091725C = 0.5f; + break; + + case 2: + if (sLurePos.y <= WATER_SURFACE_Y(globalCtx)) { + sLurePos.y += D_80917238.y; + + Math_ApproachZeroF(&D_80917238.y, 1.0f, 1.0f); + + if (D_80917206 != 2) { + Math_ApproachF(&sLurePos.y, WATER_SURFACE_Y(globalCtx), 0.5f, 1.0f); + } + } + + Math_ApproachF(&D_809101C4, 2.0f, 1.0f, 0.1f); + + if (D_809171F2 == 0) { + D_8090CD14 = 3; + } else { + D_809171F2--; + } + break; + + case 3: { + f32 sp70; + + D_80911F20 = 0; + + if ((D_8090CD0C != 0) && ((SQ(sLurePos.x) + SQ(sLurePos.z)) < SQ(500.0f))) { + D_8090CD10 = 1; + } + + player->unk_B28 = 2; + + if (D_809101B4 < 3.0f) { + spD0 = D_8091725C * Math_SinS(D_809171FE * 0x1060); + Math_ApproachF(&sLureRot.x, -0.5235988f + spD0, 0.3f, D_80917260); + Math_ApproachF(&D_80917260, 0.5f, 1.0f, 0.02f); + Math_ApproachZeroF(&D_8091725C, 1.0f, 0.02f); + } else { + D_80917260 = 0.0f; + } + + spDC = 0x4000; + spE4 = WATER_SURFACE_Y(globalCtx); + + spC8 = SQ(sLurePos.x) + SQ(sLurePos.z); + if (spC8 < SQ(920.0f)) { + if (sLurePos.y <= (spE4 + 4.0f)) { + sp70 = 0.0f; + + if (D_809101CC == 0) { + if (fabsf(input->rel.stick_x) > 30.0f) { + sp70 = fabsf((input->rel.stick_x - D_8090CD44) * (1.0f / 60.0f)); + } else if (fabsf(input->rel.stick_y) > 30.0f) { + sp70 = fabsf((input->rel.stick_y - D_8090CD48) * (1.0f / 60.0f)); + } + } + + if (sp70 > 1.0f) { + sp70 = 1.0f; + } + if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + sp70 = 0.5f; + } + + if (D_8090CD0C != 0) { + if (sp70 > 0.3f) { + sp70 = 0.3f; + } + } + + if ((sp70 > 0.2f) && (D_809101B4 < 4.0f)) { + D_809101CC = 5; + + if (sp70 > 0.8f) { + D_80917270 = 2; + } else { + D_80917270 = 1; + } + + sp90.x = player->actor.world.pos.x - sLurePos.x; + sp90.z = player->actor.world.pos.z - sLurePos.z; + sp90.y = Math_Acot2F(sp90.z, sp90.x); + + D_809101B0 = (sp70 * D_809101BC) + sp90.y; + D_809101BC *= -1.0f; + D_809101B4 = fabsf(sp70) * 6.0f; + sLureRot.x = 0.0f; + D_8091725C = 0.5f; + D_809101C0 += (fabsf(sp70) * 7.5f); + + func_8019FAD8(&D_8090D614, NA_SE_EV_LURE_MOVE_W, (sp70 * 1.999f * 0.25f) + 0.75f); + + if (D_80917206 == 2) { + D_80917278.y = 5.0f * sp70; + sReelLinePos[LINE_SEG_COUNT - 1].y += D_80917278.y; + sLurePos.y += D_80917278.y; + } + } else if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { + s32 pad; + + spDC = 0x500; + D_809101B0 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + sLureRot.x = 0.0f; + D_8091725C = 0.5f; + if (D_80917206 == 2) { + D_80917278.y = 0.2f; + sReelLinePos[LINE_SEG_COUNT - 1].y += D_80917278.y; + sLurePos.y += D_80917278.y; + } + } + } else { + if (D_809101C0 > 150.0f) { + sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; + D_809101B0 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + D_809101C0 += 2.0f; + } + } + } else { + spE4 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + if (sLurePos.y <= spE4) { + sLurePos.y = spE4; + spDC = 0x500; + D_809101B0 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + sLureRot.x = 0.0f; + if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + D_809101C0 += 6.0f; + Audio_PlaySfxAtPos(&D_8090D614, NA_SE_PL_WALK_SAND); + } + } else { + if (D_809101C0 > 150.0f) { + sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; + D_809101B0 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + D_809101C0 += 2.0f; + } + } + } + + Math_ApproachZeroF(&D_809101B4, 1.0f, 0.3f); + Math_ApproachS(&D_809101B8, (D_809101B0 * 32768.0f) / M_PI, 3, spDC); + + sLureRot.y = (D_809101B8 / 32768.0f) * M_PI; + + sp90.x = 0.0f; + sp90.y = 0.0f; + sp90.z = D_809101B4; + + Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); + + if (D_80917206 == 2) { + Vec3f sp64; + + Matrix_MultiplyVector3fByState(&sp90, &sp64); + D_80917278.x = sp64.x; + D_80917278.z = sp64.z; + phi_f0 = 10.0f; + } else { + Matrix_MultiplyVector3fByState(&sp90, &D_80917278); + phi_f0 = 0.0f; + } + + D_80917254 = 0.0f; + + if ((D_80917206 == 1) && CHECK_BTN_ALL(input->cur.button, BTN_A)) { + D_80917278.y = -2.0f; + + if (D_809171FE & 1) { + D_80917254 = 0.5f; + } else { + D_80917254 = -0.5f; + } + } else if (sReelLinePos[LINE_SEG_COUNT - 1].y < (WATER_SURFACE_Y(globalCtx) + phi_f0)) { + if (D_80917206 == 2) { + Vec3f sp58 = this->actor.world.pos; + this->actor.prevPos = this->actor.world.pos = sLurePos; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 30.0f, 0x44); + this->actor.world.pos = sp58; + + D_80917278.y += -0.5f; + if (D_80917278.y < -1.0f) { + D_80917278.y = -1.0f; + } + + if (sLurePos.y < (this->actor.floorHeight + 5.0f)) { + sReelLinePos[LINE_SEG_COUNT - 1].y = sLurePos.y = this->actor.floorHeight + 5.0f; + D_80917278.y = 0.0f; + } else { + D_80917270 = 1; + } + } else { + D_80917278.y = fabsf(sReelLinePos[LINE_SEG_COUNT - 1].y - WATER_SURFACE_Y(globalCtx)) * 0.2f; + if (D_80917278.y > 1.5f) { + D_80917278.y = 1.5f; + } + } + } + + sReelLinePos[LINE_SEG_COUNT - 1].x += D_80917278.x; + sReelLinePos[LINE_SEG_COUNT - 1].y += D_80917278.y; + sReelLinePos[LINE_SEG_COUNT - 1].z += D_80917278.z; + + if (sReelLinePos[LINE_SEG_COUNT - 1].y > (spE4 + 6.0f)) { + sReelLinePos[LINE_SEG_COUNT - 1].y -= 5.0f; + } + + D_80917238.x = D_80917238.y = D_80917238.z = D_80917248.y = 0.0f; + + if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { + if (CHECK_BTN_ALL(input->cur.button, BTN_R)) { + D_809101C0 += 1.5f; + play_sound(NA_SE_IT_FISHING_REEL_HIGH - SFX_FLAG); + Math_ApproachF(&D_809101D0, 1000.0f, 1.0f, 2.0f); + } else { + D_809101C0 += D_8091726C; + play_sound(NA_SE_IT_FISHING_REEL_SLOW - SFX_FLAG); + Math_ApproachF(&D_809101D0, 1000.0f, 1.0f, 0.2f); + } + + if (sReelLinePos[LINE_SEG_COUNT - 1].y > (WATER_SURFACE_Y(globalCtx) + 4.0f)) { + Math_ApproachF(&D_809101C4, 3.0f, 1.0f, 0.2f); + } else { + Math_ApproachF(&D_809101C4, 1.0f, 1.0f, 0.2f); + } + } else { + Math_ApproachF(&D_809101C4, 2.0f, 1.0f, 0.2f); + } + + Math_ApproachF(&sLurePos.x, sReelLinePos[LINE_SEG_COUNT - 1].x, 1.0f, D_809101D0); + Math_ApproachF(&sLurePos.y, sReelLinePos[LINE_SEG_COUNT - 1].y, 1.0f, D_809101D0); + Math_ApproachF(&sLurePos.z, sReelLinePos[LINE_SEG_COUNT - 1].z, 1.0f, D_809101D0); + + if (D_809101B4 > 1.0f) { + Math_ApproachF(&D_809101D0, 1000.0f, 1.0f, 1.0f); + } + + Math_ApproachF(&D_809101D0, 1000.0f, 1.0f, 0.1f); + + if (D_809101C0 >= 195.0f) { + D_809101C0 = 195.0f; + D_8090CD14 = 0; + D_809101C4 = 520.0f; + D_8090CD4C = 3; + } + + if ((sLurePos.y <= (WATER_SURFACE_Y(globalCtx) + 4.0f)) && + (sLurePos.y >= (WATER_SURFACE_Y(globalCtx) - 4.0f))) { + phi_v0 = 63; + if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_809101B4 > 1.0f)) { + phi_v0 = 1; + } + + if ((D_809171FE & phi_v0) == 0) { + spA8 = sLurePos; + spA8.y = WATER_SURFACE_Y(globalCtx); + EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &spA8, 30.0f, 300.0f, 150, 90); + } + } + break; + } + + case 4: + if (this->unk_14F != 0) { + this->unk_14F--; + D_809101C0 += D_8091726C; + } + + if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { + if ((SQ(sLurePos.x) + SQ(sLurePos.z)) > SQ(920.0f)) { + D_809101C0 += 1.0f; + } else { + D_809101C0 += D_8091726C; + } + play_sound(NA_SE_IT_FISHING_REEL_SLOW - SFX_FLAG); + } + + if ((D_809171FE & 0x1F) == 0) { + if ((D_80917274 != 0) || (D_80917206 != 2)) { + D_8090CD24 = 5; + } + } + + Math_ApproachF(&D_809101C4, 0.0f, 1.0f, 0.2f); + break; + + case 5: + D_809101C8 = 0.0005000001f; + sReelLinePos[LINE_SEG_COUNT - 1].x = sLurePos.x; + sReelLinePos[LINE_SEG_COUNT - 1].y = sLurePos.y; + sReelLinePos[LINE_SEG_COUNT - 1].z = sLurePos.z; + D_809101C4 = 2.0f; + break; + } +} +#else +static Vec3f D_8090D620 = { 0.0f, 0.0f, 0.0f }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateLure.s") #endif -extern ColliderJntSphElementInit D_8090CD58[12]; -extern ColliderJntSphInit D_8090CF08; -extern InitChainEntry D_8090D4D0[]; +s32 func_809033F0(EnFishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) { + s16 i; + s16 count; + f32 scale; + Vec3f pos; + Vec3f vel; + f32 speedXZ; + f32 angle; -extern UNK_TYPE D_0600007C; -extern UNK_TYPE D_06003230; -extern UNK_TYPE D_0600453C; -extern UNK_TYPE D_060074C8; -extern UNK_TYPE D_06008678; -extern UNK_TYPE D_0600B950; -extern UNK_TYPE D_0600C220; -extern UNK_TYPE D_060113D0; -extern UNK_TYPE D_06012160; -extern UNK_TYPE D_060121F0; -extern UNK_TYPE D_06014030; -extern UNK_TYPE D_060153D0; + if ((this->actor.world.pos.y < (WATER_SURFACE_Y(globalCtx) - 10.0f)) && !ignorePosCheck) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FC6C0.s") + // Necessary to match + if (this->unk_1A4) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FC770.s") + if (this->unk_1A4 >= 40.0f) { + count = 40; + scale = 1.2f; + } else { + count = 30; + scale = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FC790.s") + for (i = 0; i < count; i++) { + speedXZ = (Rand_ZeroFloat(1.5f) + 0.5f) * scale; + angle = Rand_ZeroFloat(6.28f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FC8B8.s") + vel.x = __sinf(angle) * speedXZ; + vel.z = __cosf(angle) * speedXZ; + vel.y = (Rand_ZeroFloat(3.0f) + 3.0f) * scale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FC964.s") + pos = this->actor.world.pos; + pos.x += vel.x * 3.0f; + pos.y = WATER_SURFACE_Y(globalCtx); + pos.z += vel.z * 3.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FCABC.s") + EnFishing_SpawnDustSplash(&this->actor.projectedPos, globalCtx->specialEffects, &pos, &vel, + (Rand_ZeroFloat(0.02f) + 0.025f) * scale); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FCC0C.s") + pos = this->actor.world.pos; + pos.y = WATER_SURFACE_Y(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FCDBC.s") + EnFishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &pos, 100.0f, 800.0f, 150, 90); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FCF60.s") + this->unk_149 = 30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FD054.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_Init.s") +void func_809036BC(EnFishing* this, GlobalContext* globalCtx) { + s16 count; + s16 i; + f32 scale; + Vec3f pos; + Vec3f vel; + f32 speedXZ; + f32 angle; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_Destroy.s") + // Necessary to match + if (this->unk_1A4) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FDCDC.s") + if (this->unk_1A4 >= 45.0f) { + count = 30; + scale = 0.5f; + } else { + count = 20; + scale = 0.3f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FE3F8.s") + for (i = 0; i < count; i++) { + speedXZ = (Rand_ZeroFloat(1.5f) + 0.5f) * scale; + angle = Rand_ZeroFloat(6.28f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FEE1C.s") + vel.x = __sinf(angle) * speedXZ; + vel.z = __cosf(angle) * speedXZ; + vel.y = Rand_ZeroFloat(2.0f) + 2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FEF70.s") + pos = this->actor.world.pos; + pos.x += (vel.x * 3.0f); + pos.y += (vel.y * 3.0f); + pos.z += (vel.z * 3.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FF064.s") + EnFishing_SpawnDustSplash(&this->actor.projectedPos, globalCtx->specialEffects, &pos, &vel, + (Rand_ZeroFloat(0.02f) + 0.025f) * scale); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FF5E0.s") +void func_809038A4(EnFishing* this, Input* input) { + Vec3f sp34; + Vec3f sp28; + f32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FF750.s") + sp34.x = sLurePos.x - this->actor.world.pos.x; + sp34.y = sLurePos.y - this->actor.world.pos.y; + sp34.z = sLurePos.z - this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FFC44.s") + sp24 = SQ(sp34.x) + SQ(sp34.y) + SQ(sp34.z); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FFF3C.s") + if ((D_8090CD14 == 3) && (this->unk_19A == 0) && (D_8090CD0C == 0)) { + Matrix_InsertYRotation_f((-this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp34, &sp28); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80900228.s") + if ((sp28.z > 0.0f) || (this->unk_1A4 < 40.0f)) { + if ((this->unk_150 == 7) && (sp24 < SQ(200.0f))) { + this->unk_150 = 4; + this->unk_1AC = sLurePos; + this->unk_1A8 = 28672.0f; + this->unk_180 = 5.0f; + } else { + if ((CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_809101B4 > 1.0f)) && (sp24 < SQ(120.0f))) { + this->unk_150 = 2; + this->unk_156 = 0; + this->unk_172[0] = 0; + this->unk_172[2] = Rand_ZeroFloat(100.0f) + 100.0f; + this->unk_1A0 = sFishInits[this->actor.params - 100].unk_0C; + this->unk_1A8 = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80900A04.s") + if ((this->unk_172[1] == 0) && (sp24 < SQ(70.0f))) { + this->unk_150 = 2; + this->unk_156 = 0; + this->unk_172[0] = 0; + this->unk_172[2] = Rand_ZeroFloat(100.0f) + 100.0f; + this->unk_1A0 = sFishInits[this->actor.params - 100].unk_0C; + this->unk_1A8 = 0.0f; + } + } + } + } else if ((D_8090CD14 == 4) && (D_80917274 != 0) && (sp24 < SQ(100.0f)) && (this->unk_150 >= 10)) { + this->unk_152 = 0; + this->unk_150 = 1; + this->unk_19C = 1000; + this->unk_19A = 100; + this->unk_172[1] = 50; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80901480.s") + if ((D_80917206 != 2) && (D_80917264 != 0) && (this->unk_1A4 > 60.0f) && (sp24 < SQ(30.0f)) && + (this->unk_150 >= 10)) { + this->unk_152 = 0; + this->unk_150 = 1; + this->unk_19C = 1000; + this->unk_19A = 100; + this->unk_172[1] = 50; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_809033F0.s") +void func_80903C60(EnFishing* this, u8 arg1) { + u16 sfxId; + u8 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_809036BC.s") + if (this->unk_148 == 0) { + temp = this->unk_1A4; + } else { + temp = 2.0f * this->unk_1A4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_809038A4.s") + if (arg1 == 0) { + if (temp >= 50) { + sfxId = NA_SE_EV_DIVE_INTO_WATER; + } else if (temp >= 40) { + sfxId = NA_SE_EV_BOMB_DROP_WATER; + } else { + sfxId = NA_SE_EV_BOMB_DROP_WATER; + } + } else { + if (temp >= 50) { + sfxId = NA_SE_EV_JUMP_OUT_WATER; + } else if (temp >= 40) { + sfxId = NA_SE_EV_OUT_OF_WATER; + } else { + sfxId = NA_SE_EV_OUT_OF_WATER; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80903C60.s") + Actor_PlaySfxAtPos(&this->actor, sfxId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80903E20.s") +void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { + if (sLinkAge == 1) { + if (gSaveContext.roomInf[127][2] & 0x7F) { + if (gSaveContext.roomInf[127][2] & 0x80) { + this->actor.textId = 0x40B1; + } else { + this->actor.textId = 0x4089; + } + } else { + this->actor.textId = 0x40AE; + } + } else if (gSaveContext.roomInf[127][2] & 0x7F000000) { + if (gSaveContext.roomInf[127][2] & 0x80000000) { + this->actor.textId = 0x40B1; + } else { + this->actor.textId = 0x4089; + } + } else { + this->actor.textId = 0x40AE; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_Update.s") + if (this->unk_1CB == 0) { + if (this->unk_1CC == 0) { + this->actor.flags |= 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80908554.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + D_8090CCF8 = D_809171CC; + this->unk_1CB = 1; + } else { + func_800B863C(&this->actor, globalCtx); + } + } else { + this->unk_1CC--; + this->actor.flags &= ~1; + } + } else if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + this->unk_1CB = 0; + this->unk_1CC = 20; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80908674.s") +#ifdef NON_MATCHING +// D_80917266 in case 5 around the large branching +void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { + s16 i; + s16 sp134 = 10; + f32 sp130; + f32 sp12C; + f32 sp128; + f32 sp124; + f32 multiplier; + f32 sp11C; + f32 sp118; + Vec3f sp10C; + Vec3f sp100; + s16 spFE; + s16 spFC; + s16 spFA; + s16 phi_v0; + s16 spF6; + s16 spF4; + s16 spF2; + s16 spF0; + s16 spEE; + EnFishing* this = THIS; + GlobalContext* globalCtx = globalCtx2; + Player* player = GET_PLAYER(globalCtx); + Input* input = CONTROLLER1(globalCtx); + f32 spD8; + f32 phi_f0; + f32 phi_f2; + Vec3f spC4; + Vec3f spB8; + u8 phi_v0_2; + f32 temp_f0; + f32 temp; + s32 pad; + f32 spA4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_809086B4.s") + this->actor.uncullZoneForward = 700.0f; + this->actor.uncullZoneScale = 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80908734.s") + if (this->unk_148 == 0) { + sp118 = (player->actor.speedXZ * 0.15f) + 0.25f; + } else { + sp118 = (player->actor.speedXZ * 0.3f) + 0.25f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_Draw.s") + if ((D_80917200 != 0) || (sCameraId != MAIN_CAM) || + ((player->actor.world.pos.z > 1150.0f) && (this->unk_150 != 100))) { + this->actor.flags &= ~1; + } else { + this->actor.flags |= 1; + if (D_8090CD14 != 0) { + if (D_80917202 == 0) { + this->actor.focus.pos = sLurePos; + } else if (D_80917202 == 1) { + D_8090CD4C = 1; + D_80911F50 = 0.0f; + D_809171DC = 2; + } + } + this->actor.focus.pos = this->actor.world.pos; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_809089B8.s") + this->unk_154++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80908A64.s") + for (i = 0; i < ARRAY_COUNT(this->unk_172); i++) { + if (this->unk_172[i] != 0) { + this->unk_172[i]--; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80908B4C.s") + if (this->unk_19C != 0) { + this->unk_19C--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80908E08.s") + if (this->unk_19A != 0) { + this->unk_19A--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80909234.s") + if (this->unk_198 != 0) { + this->unk_198--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80909AD0.s") + if (this->unk_149 != 0) { + this->unk_149--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80909CC0.s") + Math_ApproachF(&this->unk_190, this->unk_188, 1.0f, 0.2f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_8090AB6C.s") + if (this->unk_150 == 6) { + Math_ApproachF(&this->unk_194, this->unk_18C, 0.2f, 200.0f); + } else { + phi_f0 = 1.0f; + phi_f2 = 1.0f; + if (this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { + phi_f0 = 1.5f; + phi_f2 = 3.0f; + } + Math_ApproachF(&this->unk_194, this->unk_18C * phi_f0, 1.0f, 500.0f * phi_f2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_8090C884.s") + Math_ApproachS(&this->unk_168, 0, 5, 500); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_8090C8BC.s") + if (this->unk_148 == 0) { + Actor_SetScale(&this->actor, this->unk_1A4 * 15.0f * 0.00001f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_8090C96C.s") + this->unk_184 += this->unk_190; + + temp = __cosf(this->unk_184); + this->unk_164 = this->unk_166 + (temp * this->unk_194); + + temp = __cosf(this->unk_184 + -1.2f); + this->unk_16E = this->unk_166 + (temp * this->unk_194 * 1.6f); + } else { + Actor_SetScale(&this->actor, this->unk_1A4 * 65.0f * 0.000001f); + + this->actor.scale.x = this->actor.scale.z * 1.1f; + this->actor.scale.y = this->actor.scale.z * 1.1f; + + this->unk_184 += this->unk_190 * 0.8f; + + for (i = 0; i < 3; i++) { + temp = __cosf(this->unk_184 + (i * 2.1f)); + this->unk_1C4[i] = this->unk_166 + (temp * this->unk_194 * 2.0f); + } + + temp = __cosf(this->unk_184 + 0.4f); + this->unk_164 = (this->unk_194 * temp * 2.0f) * 0.6f; + } + + sp130 = this->unk_1AC.x - this->actor.world.pos.x; + sp12C = this->unk_1AC.y - this->actor.world.pos.y; + sp128 = this->unk_1AC.z - this->actor.world.pos.z; + + spFC = Math_FAtan2F(sp128, sp130); + sp124 = sqrtf(SQ(sp130) + SQ(sp128)); + + spFE = Math_FAtan2F(sp124, sp12C); + sp124 = sqrtf(SQ(sp130) + SQ(sp128) + SQ(sp12C)); + + if ((this->unk_198 != 0) && (this->unk_150 != 2) && (this->unk_150 != 3) && (this->unk_150 != 4)) { + if (this->unk_154 & 0x40) { + spFC += 0x4000; + } else { + spFC -= 0x4000; + } + if ((this->unk_154 + 0x20) & 0x40) { + spFE += 0x2000; + } else { + spFE -= 0x2000; + } + } + + switch (this->unk_150) { + case 100: + EnFishing_HandleAquariumDialog(this, globalCtx); + + this->actor.uncullZoneForward = 500.0f; + this->actor.uncullZoneScale = 300.0f; + + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y + 20.0f, + this->actor.world.pos.z - 50.0f, 255, 255, 255, 255); + + this->unk_1A4 = D_809171CC; + sp100.y = Math_SinS(globalCtx->gameplayFrames * 300); + sp100.z = Math_SinS(globalCtx->gameplayFrames * 230) * 2.0f; + this->actor.world.pos.x = 130.0f; + this->actor.world.pos.y = 55.0f + sp100.y; + this->actor.world.pos.z = 1300.0f + sp100.z; + this->actor.shape.rot.y = -0x8000; + + if ((this->actor.projectedPos.z < 200.0f) && (this->actor.projectedPos.z > 0.0f)) { + spC4.x = randPlusMinusPoint5Scaled(5.0f) + 130.0f; + spC4.y = 40.0f; + spC4.z = randPlusMinusPoint5Scaled(5.0f) + 1280.0f; + EnFishing_SpawnBubble(NULL, globalCtx->specialEffects, &spC4, Rand_ZeroFloat(0.02f) + 0.03f, 1); + } + + Math_ApproachS(&this->unk_16A, (Math_SinS(this->unk_154 * 0x800) * 2500.0f) + 2500.0f, 2, 0x7D0); + Math_ApproachS(&this->unk_16C, Math_SinS(this->unk_154 * 0xA00) * 1500.0f, 2, 0x7D0); + + this->unk_188 = 0.3f; + this->unk_18C = 333.33334f; + return; + + case 10: + this->unk_1AC = this->actor.home.pos; + + Math_ApproachF(&this->actor.speedXZ, 2.0f, 1.0f, 0.5f); + Math_ApproachF(&this->unk_1A8, 4096.0f, 1.0f, 256.0f); + + if (sp124 < 40.0f) { + this->unk_150 = 11; + this->unk_188 = 0.4f; + this->unk_18C = 500.0f; + } + + func_809038A4(this, input); + + if (this->actor.xzDistToPlayer < (250.0f * sp118)) { + this->unk_152 = this->unk_150 = 0; + this->unk_19C = 1000; + this->unk_19A = 200; + this->unk_172[1] = 50; + } + break; + + case 11: + this->unk_1AC = this->actor.home.pos; + + Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 0.05f); + Math_ApproachF(&this->unk_1A8, 0.0f, 1.0f, 256.0f); + + if (sp124 >= 40.0f) { + this->unk_150 = 10; + this->unk_188 = 1.0f; + this->unk_18C = 2000.0f; + } + func_809038A4(this, input); + + if (this->actor.xzDistToPlayer < (250.0f * sp118)) { + this->unk_152 = this->unk_150 = 0; + this->unk_19C = 1000; + this->unk_19A = 200; + this->unk_172[1] = 50; + } + + if (!Message_GetState(&globalCtx->msgCtx)) { + if ((gSaveContext.time >= 0xC000) && (gSaveContext.time <= 0xC01B)) { + this->unk_150 = 7; + this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; + } + if ((gSaveContext.time >= 0x3AAA) && (gSaveContext.time <= 0x3AC5)) { + this->unk_150 = 7; + this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; + } + } + break; + + case 0: + Math_ApproachF(&this->actor.speedXZ, 1.0f, 1.0f, 0.05f); + Math_ApproachF(&this->unk_1A8, 0.0f, 1.0f, 256.0f); + + if (this->unk_172[0] == 0) { + if (this->unk_19C == 0) { + this->unk_150 = this->unk_152 = 10; + } else { + this->unk_150 = 1; + this->unk_172[0] = Rand_ZeroFloat(30.0f) + 10.0f; + this->unk_1AC.x = randPlusMinusPoint5Scaled(300.0f); + this->unk_1AC.y = (WATER_SURFACE_Y(globalCtx) - 50.0f) - Rand_ZeroFloat(50.0f); + this->unk_1AC.z = randPlusMinusPoint5Scaled(300.0f); + this->unk_188 = 1.0f; + this->unk_18C = 2000.0f; + } + } + + if (D_80917206 == 2) { + func_809038A4(this, input); + } else { + this->actor.flags &= ~1; + } + break; + + case 1: + if (this->unk_148 == 1) { + this->unk_150 = -1; + this->unk_19C = 20000; + this->unk_19A = 20000; + this->unk_1AC.x = 0.0f; + this->unk_1AC.y = -140.0f; + this->unk_1AC.z = 0.0f; + } else { + Math_ApproachF(&this->unk_1A8, 4096.0f, 1.0f, 256.0f); + + if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_172[1] != 0)) { + Math_ApproachF(&this->unk_1A8, 8192.0f, 1.0f, 768.0f); + Math_ApproachF(&this->actor.speedXZ, 4.2f, 1.0f, 0.75); + this->unk_188 = 1.2f; + this->unk_18C = 4000.0f; + this->unk_172[0] = 20; + } else { + this->unk_188 = 1.0f; + this->unk_18C = 2000.0f; + Math_ApproachF(&this->actor.speedXZ, 1.5f, 1.0f, 0.1f); + } + + if ((this->unk_172[0] == 0) || (sp124 < 50.0f)) { + this->unk_150 = 0; + this->unk_172[0] = Rand_ZeroFloat(30.0f) + 3.0f; + this->unk_188 = 1.0f; + this->unk_18C = 500.0f; + } + + if (D_80917206 == 2) { + func_809038A4(this, input); + } else { + this->actor.flags &= ~1; + } + } + break; + + case -1: + Math_ApproachS(&this->unk_15E, 0, 0x14, 0x20); + + if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_172[1] != 0)) { + Math_ApproachF(&this->actor.speedXZ, 3.0f, 1.0f, 0.75); + this->unk_188 = 1.0f; + this->unk_172[0] = 20; + this->unk_18C = 4000.0f; + Math_ApproachF(&this->unk_1A8, 4096.0f, 1.0f, 256.0f); + + if ((globalCtx->gameplayFrames % 32) == 0) { + this->unk_1AC.x = randPlusMinusPoint5Scaled(600.0f); + this->unk_1AC.z = randPlusMinusPoint5Scaled(600.0f); + this->unk_1AC.y = -120.0f; + } + } else if (sp124 > 50.0f) { + this->unk_188 = 0.8f; + this->unk_18C = 1500.0f; + Math_ApproachF(&this->actor.speedXZ, 1.0f, 1.0f, 0.1f); + Math_ApproachF(&this->unk_1A8, 2048.0f, 1.0f, 128.0f); + } else { + this->unk_188 = 0.4f; + this->unk_18C = 500.0f; + Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.02f); + Math_ApproachF(&this->unk_1A8, 0.0f, 1.0f, 256.0f); + } + + if (this->unk_19C == 0) { + this->unk_150 = 10; + this->unk_152 = 10; + } else if (((this->unk_19C & 0x7FF) == 0) && (this->unk_19C < 15000)) { + this->unk_150 = -2; + this->actor.world.rot.x = this->actor.shape.rot.x = 0; + this->unk_1AC.y = WATER_SURFACE_Y(globalCtx) + 10.0f; + this->unk_1AC.x = Rand_ZeroFloat(50.0f); + this->unk_1AC.z = Rand_ZeroFloat(50.0f); + } + + this->actor.flags &= ~1; + break; + + case -2: + if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_172[1] != 0)) { + this->unk_150 = -1; + this->unk_1AC.y = -120.0f; + } else { + this->unk_188 = 0.6f; + this->unk_18C = 1000.0f; + + Math_ApproachS(&this->unk_15E, -0x1000, 0x14, 0x100); + + if (this->actor.world.pos.y < (WATER_SURFACE_Y(globalCtx) - 20.0f)) { + Math_ApproachF(&this->actor.speedXZ, 0.5f, 1.0f, 0.1f); + } else { + Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.01f); + + if ((this->actor.speedXZ == 0.0f) || + (this->actor.world.pos.y > (WATER_SURFACE_Y(globalCtx) - 5.0f))) { + this->unk_1AC.x = Rand_ZeroFloat(300.0f); + this->unk_1AC.z = Rand_ZeroFloat(300.0f); + this->unk_1AC.y = this->actor.floorHeight + 10.0f; + this->unk_150 = -25; + this->unk_1A8 = 0.0f; + + spB8 = this->fishMouthPos; + spB8.y = WATER_SURFACE_Y(globalCtx); + EnFishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &spB8, 10.0f, + 300.0f, 150, 90); + EnFishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &spB8, 30.0f, + 400.0f, 150, 90); + + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_CATCH_BOOMERANG); + break; + } + } + + Math_ApproachF(&this->unk_1A8, 2048.0f, 1.0f, 128.0f); + this->actor.flags &= ~1; + } + break; + + case -25: + if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_172[1] != 0)) { + this->unk_150 = -1; + this->unk_1AC.y = -120.0f; + } else { + Math_ApproachS(&this->unk_15E, 0x1000, 0x14, 0x6A); + + if (sp124 > 40.0f) { + this->unk_188 = 0.7f; + this->unk_18C = 1200.0f; + Math_ApproachF(&this->actor.speedXZ, 0.5f, 1.0f, 0.01f); + Math_ApproachF(&this->unk_1A8, 2048.0f, 1.0f, 128.0f); + } else { + this->unk_150 = -1; + } + } + break; + + case 2: + if ((this->actor.params + D_80917268) & 1) { + sp10C.x = 10.0f; + } else { + sp10C.x = -10.0f; + } + sp10C.y = 0.0f; + sp10C.z = 0.0f; + Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp10C, &sp100); + + this->unk_1AC.x = sLurePos.x + sp100.x; + this->unk_1AC.z = sLurePos.z + sp100.z; + + if (D_80917206 == 2) { + this->unk_1AC.y = sLurePos.y; + } else if (this->unk_148 == 0) { + this->unk_1AC.y = sLurePos.y - 15.0f; + } else { + this->unk_1AC.y = sLurePos.y - 5.0f; + } + + if (this->unk_1AC.y <= this->actor.floorHeight) { + this->unk_1AC.y = this->actor.floorHeight + 3.0f; + } + + if ((D_80917206 != 2) && (this->unk_1AC.y < this->actor.world.pos.y)) { + Math_ApproachF(&this->actor.world.pos.y, this->unk_1AC.y, 0.1f, + (this->actor.world.pos.y - this->unk_1AC.y) * 0.1f); + } + + Math_ApproachF(&this->unk_1A8, 8192.0f, 1.0f, 384.0f); + if (CHECK_BTN_ALL(input->press.button, BTN_A)) { + this->unk_1A0 += 0.005f; + } + + if (D_80917270 != 0) { + if (D_80917270 == 1) { + this->unk_1A0 += 0.01f; + } else { + this->unk_1A0 += 0.05f; + } + D_80917270 = 0; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + this->unk_1A0 += 0.008f; + } + + if (sp124 < ((this->unk_1A4 * 0.5f) + 20.0f)) { + if (this->unk_156 == 0) { + this->unk_188 = 1.0f; + this->unk_18C = 500.0f; + this->unk_172[0] = Rand_ZeroFloat(10.0f) + 2.0f; + } + Math_ApproachF(&this->actor.speedXZ, -0.2f, 1.0f, 0.1f); + this->unk_156 = 1; + } else { + if (this->unk_156 != 0) { + this->unk_188 = 1.0f; + this->unk_1A8 = 0.0f; + this->unk_18C = 3000.0f; + } + Math_ApproachF(&this->actor.speedXZ, 3.0f, 1.0f, 0.15f); + this->unk_156 = 0; + } + + if (this->unk_1A4 >= 60.0f) { + multiplier = 0.3f; + } else if (this->unk_1A4 >= 45.0f) { + multiplier = 0.6f; + } else { + multiplier = 1.0f; + } + + if ((gSaveContext.time >= 0xB555) && (gSaveContext.time <= 0xCAAA)) { + multiplier *= 1.75f; + } else if ((gSaveContext.time >= 0x3555) && (gSaveContext.time <= 0x4AAA)) { + multiplier *= 1.5f; + } else if (D_809171CA != 0) { + multiplier *= 1.5f; + } else if ((u8)D_8090CCD0 != 0) { + multiplier *= 3.0f; + } + + sp11C = 0.03f * multiplier; + if (D_80917206 == 2) { + sp11C *= 5.0f; + } + + if (((this->unk_172[0] == 1) || (Rand_ZeroOne() < sp11C)) && + (Rand_ZeroOne() < (this->unk_1A0 * multiplier))) { + if (this->unk_148 == 0) { + this->unk_150 = 3; + this->unk_188 = 1.2f; + this->unk_18C = 5000.0f; + this->unk_172[0] = Rand_ZeroFloat(10.0f); + } else { + this->unk_150 = -3; + this->unk_188 = 1.0f; + this->unk_18C = 3000.0f; + this->unk_172[0] = 40; + } + if (D_80917206 == 2) { + this->unk_180 = Rand_ZeroFloat(1.5f) + 3.0f; + } else { + this->unk_180 = Rand_ZeroFloat(1.5f) + 4.5f; + } + } + + if ((D_8090CD14 != 3) || (this->unk_172[2] == 0) || + (sqrtf(SQ(this->actor.world.pos.x) + SQ(this->actor.world.pos.z)) > 800.0f)) { + this->unk_150 = this->unk_152; + this->unk_172[1] = Rand_ZeroFloat(30.0f) + 50.0f; + this->unk_172[0] = Rand_ZeroFloat(10.0f) + 5.0f; + this->unk_188 = 1.0f; + this->unk_1A8 = 0.0f; + this->unk_18C = 2000.0f; + } + + if (this->actor.xzDistToPlayer < (100.0f * sp118)) { + this->unk_152 = this->unk_150 = 0; + this->unk_19C = 1000; + this->unk_19A = 200; + this->unk_172[1] = 50; + } + break; + + case 3: + this->unk_149 = 6; + sp134 = 2; + + if (((s16)player->actor.world.pos.x + D_80917268) & 1) { + sp10C.x = 30.0f; + } else { + sp10C.x = -30.0f; + } + sp10C.y = 0.0f; + sp10C.z = 30.0f; + + Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp10C, &sp100); + + this->unk_1AC.x = sLurePos.x + sp100.x; + this->unk_1AC.z = sLurePos.z + sp100.z; + this->unk_1AC.y = sLurePos.y - 10.0f; + this->unk_1A8 = 4096.0f; + Math_ApproachF(&this->actor.speedXZ, this->unk_180 * 0.8f, 1.0f, 1.0f); + + if ((D_8090CD14 != 3) || (sLurePos.y > (WATER_SURFACE_Y(globalCtx) + 5.0f)) || + (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { + this->unk_150 = this->unk_152; + this->unk_172[0] = 0; + this->unk_188 = 1.0f; + this->unk_18C = 2000.0f; + } else if ((this->unk_172[0] == 0) || (sp124 < 30.0f)) { + this->unk_150 = 4; + this->unk_1AC = sLurePos; + this->unk_1A8 = 16384.0f; + this->unk_188 = 1.2f; + this->unk_18C = 5000.0f; + this->unk_172[0] = 20; + } + break; + + case 4: + Math_ApproachF(&this->unk_1A8, 16384.0f, 1.0f, 4096.0f); + Math_ApproachS(&this->unk_168, 0x4E20, 4, 0x1388); + + this->unk_149 = 50; + sp134 = 2; + this->unk_1AC = sLurePos; + Math_ApproachF(&this->actor.speedXZ, this->unk_180, 1.0f, 1.0f); + + if ((D_8090CD14 != 3) || (this->unk_172[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(globalCtx) + 5.0f)) || + (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { + + this->unk_172[0] = 0; + this->unk_150 = this->unk_152; + this->unk_188 = 1.0f; + this->unk_18C = 2000.0f; + } else if (sp124 < 10.0f) { + if (func_809033F0(this, globalCtx, false)) { + func_80903C60(this, 0); + } + + this->unk_150 = 5; + this->unk_188 = 1.2f; + this->unk_18C = 5000.0f; + this->unk_172[1] = 150; + this->unk_172[0] = 0; + this->unk_172[2] = 0; + this->unk_172[3] = 120; + + D_8090CD14 = 4; + sFishingHookedFish = this; + sFishMouthOffset.y = 500.0f - Rand_ZeroFloat(400.0f); + + if (D_80917206 == 2) { + if (this->unk_1A4 > 70.0f) { + phi_v0 = Rand_ZeroFloat(20.0f) + 10.0f; + } else if (this->unk_1A4 > 60.0f) { + phi_v0 = Rand_ZeroFloat(30.0f) + 20.0f; + } else if (this->unk_1A4 > 50.0f) { + phi_v0 = Rand_ZeroFloat(30.0f) + 30.0f; + } else { + phi_v0 = Rand_ZeroFloat(40.0f) + 40.0f; + } + D_80917272 = phi_v0; + D_809171F4 = phi_v0; + func_8013EC44(0.0f, 60, phi_v0 * 3, 10); + } else { + if (this->unk_1A4 > 70.0f) { + phi_v0 = Rand_ZeroFloat(5.0f) + 10.0f; + } else if (this->unk_1A4 > 60.0f) { + phi_v0 = Rand_ZeroFloat(5.0f) + 15.0f; + } else if (this->unk_1A4 > 50.0f) { + phi_v0 = Rand_ZeroFloat(5.0f) + 17.0f; + } else { + phi_v0 = Rand_ZeroFloat(5.0f) + 25.0f; + } + D_80917272 = phi_v0; + D_809171F4 = phi_v0; + func_8013EC44(0.0f, 180, phi_v0 * 3, 10); + } + + D_80917274 = 0; + D_80917266 = 100; + D_809171D4 = 0; + } + break; + + case -3: + this->unk_149 = 50; + this->unk_1AC = sLurePos; + Math_ApproachF(&this->actor.speedXZ, 2.0f, 1.0f, 1.0f); + + if ((D_8090CD14 != 3) || (this->unk_172[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(globalCtx) + 5.0f)) || + (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { + + this->unk_172[0] = 0; + this->unk_188 = 1.0f; + this->unk_150 = this->unk_152; + this->unk_18C = 2000.0f; + } else if (sp124 < 10.0f) { + if (sLurePos.y > (WATER_SURFACE_Y(globalCtx) - 10.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_JUMP_OUT_WATER); + play_sound(NA_SE_PL_CATCH_BOOMERANG); + } + + func_809033F0(this, globalCtx, false); + this->unk_150 = 5; + this->unk_188 = 1.2f; + this->unk_18C = 5000.0f; + this->unk_172[1] = 150; + this->unk_172[0] = 0; + this->unk_172[2] = 0; + this->unk_172[3] = 120; + + D_8090CD14 = 4; + sFishingHookedFish = this; + + if (D_80917206 == 2) { + D_80917272 = 30; + D_809171F4 = 100; + func_8013EC44(0.0f, 60, 90, 10); + } else { + D_80917272 = 30; + D_809171F4 = 40; + func_8013EC44(0.0f, 180, 90, 10); + } + + D_80917274 = 0; + D_80917266 = 100; + D_809171D4 = 0; + } + break; + + case 5: + this->actor.uncullZoneForward = 1200.0f; + this->actor.uncullZoneScale = 200.0f; + + D_809171D4++; + + Math_ApproachS(&this->unk_168, 0x2AF8, 4, 0xBB8); + sFishingHookedFish = this; + Math_ApproachS(&player->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 5, 0x500); + + if (D_80917274 == 0) { + if ((D_80911F20 < 20) && ((D_809171FE & 3) == 0)) { + D_80911F20++; + } + } + + if ((D_80917272 != 0) && (D_80917274 == 0)) { + if (((input->rel.stick_y < -50) && (D_8090CD48 > -40)) || CHECK_BTN_ALL(input->press.button, BTN_A)) { + if (input->rel.stick_y < -50) { + temp_f0 = 40.0f - ((this->unk_1A4 - 30.0f) * 1.333333f); + if (temp_f0 > 0.0f) { + this->unk_14A = temp_f0; + this->unk_14C = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + this->unk_14E = 1; + } + } + + this->unk_190 = 1.7f; + this->unk_194 = 7000.0f; + D_80917274 = 1; + Audio_QueueSeqCmd(0x881A); // Changed from 0x81A in OoT + D_809171F6 = 0; + + if (this->unk_148 == 1) { + spA4 = (this->unk_1A4 * 3.0f) + 120.0f; + } else { + spA4 = (2.0f * this->unk_1A4) + 120.0f; + } + if (spA4 > 255.0f) { + spA4 = 255.0f; + } + + func_8013EC44(0.0f, spA4, 120, 5); + D_809171F4 = 40; + D_80911E28 = 10; + play_sound(NA_SE_IT_FISHING_HIT); + } + } + + if (this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) { + if (this->unk_172[1] > 30) { + phi_v0_2 = 7; + } else { + phi_v0_2 = 0xF; + } + + if (((this->unk_154 & phi_v0_2) == 0) && (Rand_ZeroOne() < 0.75f) && (D_809171F4 == 0)) { + if (this->unk_1A4 >= 70.0f) { + spA4 = 255.0f; + } else if (this->unk_1A4 >= 60.0f) { + spA4 = 230.0f; + } else if (this->unk_1A4 >= 50.0f) { + spA4 = 200.0f; + } else if (this->unk_1A4 >= 40.0f) { + spA4 = 170.0f; + } else { + spA4 = 140.0f; + } + + if (phi_v0_2 == 0xF) { + spA4 *= 3.0f / 4.0f; + } + + func_8013EC44(0.0f, spA4, Rand_ZeroFloat(5.0f) + 10.0f, 5); + } + + if (this->unk_172[1] > 30) { + if (this->unk_172[0] == 0) { + u16 spA2; + + sp10C.x = 0.0f; + sp10C.y = 0.0f; + sp10C.z = 200.0f; + + for (spA2 = 0; spA2 < 100; spA2++) { + + Matrix_InsertYRotation_f(randPlusMinusPoint5Scaled(2.3561945f) + + (((this->actor.yawTowardsPlayer + 0x8000) / 32768.0f) * M_PI), + MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp10C, &sp100); + + this->unk_1AC.x = this->actor.world.pos.x + sp100.x; + this->unk_1AC.z = this->actor.world.pos.z + sp100.z; + + if ((SQ(this->unk_1AC.x) + SQ(this->unk_1AC.z)) < SQ(750.0f)) { + break; + } + } + + if ((Rand_ZeroOne() < 0.1f) && (this->unk_172[3] == 0)) { + u8 phi_a1; + + if (this->unk_1A4 >= 60.0f) { + phi_a1 = 255; + } else if (this->unk_1A4 >= 50.0f) { + phi_a1 = 200; + } else { + phi_a1 = 180; + } + func_8013EC44(0.0f, phi_a1, 90, 2); + this->unk_172[0] = 20; + this->unk_172[1] = 100; + this->unk_172[2] = 20; + this->unk_172[3] = 100; + this->unk_1AC.y = 300.0f; + D_809171F4 = 0x28; + D_80917266 = Rand_ZeroFloat(30.0f) + 20.0f; + } else { + this->unk_172[0] = Rand_ZeroFloat(10.0f) + 3.0f; + this->unk_172[2] = 0; + this->unk_1AC.y = -70.0f - Rand_ZeroFloat(150.0f); + } + } + + if (this->unk_172[2] != 0) { + D_8091726C = 0.0f; + this->unk_188 = 1.6f; + this->unk_18C = 6000.0f; + Math_ApproachF(&this->actor.speedXZ, 7.5f, 1.0f, 1.0f); + Math_ApproachS(&this->unk_168, 0x4E20, 2, 0xFA0); + } else { + if ((D_80917274 == 0) && (D_80917206 == 2)) { + this->unk_188 = 1.0f; + this->unk_18C = 2000.0f; + Math_ApproachF(&this->actor.speedXZ, 3.0f, 1.0f, 0.2f); + } else { + this->unk_188 = 1.4f; + this->unk_18C = 5000.0f; + Math_ApproachF(&this->actor.speedXZ, 5.0f, 1.0f, 0.5f); + } + + if (this->unk_148 == 0) { + D_8091726C = 1.0f - (this->unk_1A4 * 0.00899f); + } else { + D_8091726C = 1.0f - (this->unk_1A4 * 0.00899f * 1.4f); + } + } + } else { + if (((this->unk_172[1] & 0xF) == 0) && CHECK_BTN_ALL(input->cur.button, BTN_A) && + (!(this->unk_1A4 >= 60.0f) || (D_809171D4 >= 2000))) { + this->unk_14A = Rand_ZeroFloat(30.0f) + 15.0f; + this->unk_14C = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + } + + this->unk_188 = 1.0f; + this->unk_18C = 4500.0f; + + if (this->unk_148 == 0) { + D_8091726C = 1.3f - (this->unk_1A4 * 0.00899f); + } else { + D_8091726C = 1.3f - (this->unk_1A4 * 0.00899f * 1.4f); + } + + Math_ApproachF(&this->actor.speedXZ, 2.0f, 1.0f, 0.5f); + + if (this->unk_172[1] == 0) { + this->unk_14A = 0; + + if (D_809171D4 < 2000) { + this->unk_172[1] = Rand_ZeroFloat(50.0f) + 50.0f; + } else if (D_809171D4 < 3000) { + this->unk_172[1] = Rand_ZeroFloat(20.0f) + 30.0f; + } else { + this->unk_172[1] = Rand_ZeroFloat(10.0f) + 25.0f; + } + } + } + } + + if (D_809171C8 != 0) { + D_8091726C = 0.0f; + } + + if (D_80917274 || (D_80917206 != 2)) { + if (this->actor.speedXZ < 3.0f) { + if (D_809171FE & 8) { + sp100.x = -0.8f; + } else { + sp100.x = -0.75f; + } + } else if (D_809171FE & 4) { + sp100.x = -0.9f; + } else { + sp100.x = -0.85f; + } + + Math_ApproachF(&D_8090CD40, 35.0f, 0.1f, 3.5f); + Math_ApproachF(&D_8090CD3C, sp100.x, 0.3f, 0.1f); + } + + sReelLinePos[LINE_SEG_COUNT - 1] = this->fishMouthPos; + sp10C.x = sReelLinePos[LINE_SEG_COUNT - 1].x - sReelLinePos[LINE_SEG_COUNT - 2].x; + sp10C.y = sReelLinePos[LINE_SEG_COUNT - 1].y - sReelLinePos[LINE_SEG_COUNT - 2].y; + sp10C.z = sReelLinePos[LINE_SEG_COUNT - 1].z - sReelLinePos[LINE_SEG_COUNT - 2].z; + + if ((SQ(sp10C.x) + SQ(sp10C.y) + SQ(sp10C.z)) > SQ(20.0f)) { + Math_ApproachF(&this->actor.world.pos.x, sReelLinePos[LINE_SEG_COUNT - 2].x, 0.2f, + 2.0f * (this->actor.speedXZ * 1.5f)); + Math_ApproachF(&this->actor.world.pos.y, sReelLinePos[LINE_SEG_COUNT - 2].y, 0.2f, + 2.0f * (this->actor.speedXZ * 1.5f) * 5.0f * 0.1f); + Math_ApproachF(&this->actor.world.pos.z, sReelLinePos[LINE_SEG_COUNT - 2].z, 0.2f, + 2.0f * (this->actor.speedXZ * 1.5f)); + } + + if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (input->rel.stick_y < -30)) { + if (D_80917266 < 100) { + D_80917266++; + } + } else { + if (D_80917266 != 0) { + D_80917266--; + } + } + + if ((D_8090CD14 < 3) || ((D_809171C8 != 0) && (D_809171D4 > 50)) || (D_809171D4 >= 6000) || + ((D_80917272 == 0) && (D_80917274 == 0)) || (D_80917266 == 0) || + (((D_809171FE & 0x7F) == 0) && (Rand_ZeroOne() < 0.05f) && (D_80917206 != 2))) { + // Assignment of OoT's D_80B7A67C here removed in MM + + if ((D_80917272 == 0) && (D_80917274 == 0)) { + // Assignment of OoT's D_80B7E086 here removed in MM + if (((sLinkAge == 1) && (gSaveContext.roomInf[127][2] & 0x400)) || + ((sLinkAge != 1) && (gSaveContext.roomInf[127][2] & 0x800))) { + // Assignment of OoT's D_80B7A67C here removed in MM, this is now an empty branch + } + } else { + // Assignment of OoT's D_80B7E086 here removed in MM + func_8013EC44(0.0f, 1, 3, 1); + Audio_QueueSeqCmd(0x100A00FF); + } + + this->unk_150 = this->unk_152 = 0; + this->unk_19C = 10000; + this->unk_19A = 500; + this->unk_172[1] = 50; + this->unk_172[0] = 0; + this->unk_188 = 1.0f; + this->unk_18C = 3000.0f; + + if (D_8090CD14 == 4) { + D_8090CD14 = 3; + } + + D_809171F6 = 50; + D_8091726C = 0.5f; + this->unk_14A = 0; + } else if (this->actor.xzDistToPlayer < 50.0f) { + this->unk_150 = 6; + this->unk_172[0] = 100; + player->unk_B28 = 3; + func_8013EC44(0.0f, 1, 3, 1); + D_809171D8++; + func_800EA0D4(globalCtx, &globalCtx->csCtx); + D_8090CD4C = 100; + D_80911F48 = 45.0f; + D_8090CD14 = 5; + this->unk_188 = 1.0f; + this->unk_18C = 500.0f; + this->unk_194 = 5000.0f; + + if (this->actor.world.pos.y <= WATER_SURFACE_Y(globalCtx)) { + func_80903C60(this, 1); + func_809033F0(this, globalCtx, true); + } + goto case_6; + } + break; + + case_6: + case 6: + Math_ApproachS(&this->unk_168, 0x2AF8, 2, 0xFA0); + Math_ApproachF(&D_80911F48, 15.0f, 0.05f, 0.75f); + + sp10C.x = D_80911F48; + if (sLinkAge != 1) { + sp10C.y = 30.0f; + sp10C.z = 55.0f; + } else { + sp10C.y = 10.0f; + sp10C.z = 50.0f; + } + Matrix_InsertYRotation_f((player->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp10C, &sCameraEye); + + sCameraEye.x += player->actor.world.pos.x; + sCameraEye.y += player->actor.world.pos.y; + sCameraEye.z += player->actor.world.pos.z; + + sCameraAt = player->actor.world.pos; + if (sLinkAge != 1) { + sCameraAt.y += 40.0f; + } else { + sCameraAt.y += 25.0f; + } + + if (this->unk_172[0] == 90) { + Audio_QueueSeqCmd(0x8924); // changed from 0x924 in OoT + D_8090CCFC = 40; + + if (this->unk_148 == 0) { + D_8090CCF8 = this->unk_1A4; + + if (D_8090CCF8 >= 75) { + D_809171DA = 0x409F; + } else if (D_8090CCF8 >= 50) { + D_809171DA = 0x4091; + } else { + D_809171DA = 0x4083; + } + } else { + D_8090CCF8 = 2.0f * this->unk_1A4; + D_809171DA = 0x4099; + } + + this->unk_1CD = 0; + } + + this->unk_158 = -0x4000; + this->actor.shape.rot.y = player->actor.shape.rot.y + 0x5000; + this->actor.shape.rot.x = this->actor.shape.rot.z = this->unk_15A = this->unk_15C = this->unk_166 = 0; + + sp10C.x = 4.0f; + sp10C.y = -10.0f; + sp10C.z = 5.0f; + Matrix_MultiplyVector3fByState(&sp10C, &sp100); + Math_ApproachF(&this->actor.world.pos.x, player->bodyPartsPos[15].x + sp100.x, 1.0f, 6.0f); + Math_ApproachF(&this->actor.world.pos.y, player->bodyPartsPos[15].y + sp100.y, 1.0f, 6.0f); + Math_ApproachF(&this->actor.world.pos.z, player->bodyPartsPos[15].z + sp100.z, 1.0f, 6.0f); + + D_809101C0 = 188.0f; + + if (this->unk_172[0] <= 50) { + switch (this->unk_1CD) { + case 0: + if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { + if (func_80147624(globalCtx)) { + func_801477B4(globalCtx); + if (globalCtx->msgCtx.choiceIndex == 0) { + if (D_8090CCF0 == 0.0f) { + D_8090CCF0 = this->unk_1A4; + D_809171D0 = this->unk_148; + D_809171D2 = D_80917206; + Actor_MarkForDeath(&this->actor); + } else if ((this->unk_148 == 0) && (D_809171D0 == 0) && + ((s16)this->unk_1A4 < (s16)D_8090CCF0)) { + this->unk_1CD = 1; + this->unk_172[0] = 0x3C; + func_801518B0(globalCtx, 0x4098, NULL); + } else { + f32 temp1 = D_8090CCF0; + s16 temp2 = D_809171D0; + D_8090CCF0 = this->unk_1A4; + D_809171D0 = this->unk_148; + D_809171D2 = D_80917206; + this->unk_1A4 = temp1; + this->unk_148 = temp2; + } + } + if (this->unk_1CD == 0) { + D_8090CD14 = 0; + } + } + } + break; + case 1: + if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { + if (func_80147624(globalCtx)) { + func_801477B4(globalCtx); + if (globalCtx->msgCtx.choiceIndex != 0) { + f32 temp1 = D_8090CCF0; + s16 temp2 = D_809171D0; + D_8090CCF0 = this->unk_1A4; + D_809171D2 = D_80917206; + this->unk_1A4 = temp1; + this->unk_148 = temp2; + } + D_8090CD14 = 0; + } + } + break; + } + } + + if (D_8090CD14 == 0) { + if (this->actor.update != NULL) { + this->unk_150 = this->unk_152 = 0; + this->unk_19C = 10000; + this->unk_19A = 500; + this->unk_172[1] = 50; + this->unk_172[0] = 0; + this->unk_188 = 1.0f; + this->unk_18C = 2000.0f; + SkelAnime_Free(&this->skelAnime, globalCtx); + + if (this->unk_148 == 0) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, 0, 0, 0); + Animation_MorphToLoop(&this->skelAnime, &gFishingFishAnim, 0.0f); + } else { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingLoachSkel, &gFishingLoachAnim, 0, 0, + 0); + Animation_MorphToLoop(&this->skelAnime, &gFishingLoachAnim, 0.0f); + } + } + + D_809101C4 = 520.0f; + D_809101C0 = 195.0f; + Audio_QueueSeqCmd(0x100A00FF); + D_809171F6 = 20; + D_8090CD4C = 3; + } + break; + + case 7: + this->unk_149 = 50; + sp134 = 5; + this->unk_1A8 = 12288.0f; + + if (this->actor.params < 104) { + this->unk_1AC = sGroupFishes[this->actor.params - 100].pos; + D_8090CF18 = 1; + } else if (this->actor.params < 108) { + this->unk_1AC = sGroupFishes[this->actor.params - 100 + 16].pos; + D_8090CF18 = 2; + } else { + this->unk_1AC = sGroupFishes[this->actor.params - 100 + 32].pos; + D_8090CF18 = 3; + } + + Math_ApproachF(&this->actor.speedXZ, 5.0f, 1.0f, 1.0f); + + if (sp124 < 20.0f) { + Math_ApproachS(&this->unk_168, 0x4E20, 2, 0xFA0); + + if ((this->unk_172[2] == 0) && func_809033F0(this, globalCtx, false)) { + func_80903C60(this, Rand_ZeroFloat(1.99f)); + this->unk_172[2] = Rand_ZeroFloat(20.0f) + 20.0f; + } + } + + if (this->unk_172[3] == 0) { + this->unk_150 = 10; + this->unk_152 = 10; + } else { + func_809038A4(this, input); + if (this->actor.xzDistToPlayer < (100.0f * sp118)) { + this->unk_152 = this->unk_150 = 0; + this->unk_19C = 500; + this->unk_19A = 200; + this->unk_172[1] = 50; + } + } + break; + } + + Math_ApproachS(&this->unk_16A, (Math_SinS(this->unk_154 * 0x1000) * 5000.0f) + 5000.0f, 2, 0x7D0); + + if (this->unk_150 != 6) { + if (this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { + this->unk_188 = 1.5f; + this->unk_18C = 5000.0f; + + Math_ApproachS(&this->unk_166, 0, 5, 0x7D0); + + spF4 = spF0 = spFA = 3; + spF2 = spEE = 0x2000; + + this->unk_172[2] = 0; + this->unk_17C -= 1.0f; + } else { + Math_ApproachZeroF(&this->unk_17C, 1.0f, 2.0f); + if ((this->unk_150 != -1) && (this->unk_150 != -2) && (this->unk_150 != -25)) { + this->unk_15E = 0; + } + + this->unk_160 = this->unk_162 = 0; + spF4 = spF0 = spFA = 4; + spF2 = spEE = 0x2000; + + spF6 = EnFishing_SmoothStepToS(&this->actor.world.rot.y, spFC, sp134, this->unk_1A8) * 3.0f; + Math_ApproachS(&this->actor.world.rot.x, spFE, sp134, this->unk_1A8 * 0.5f); + + if (spF6 > 0x1F40) { + spF6 = 0x1F40; + } else if (spF6 < -0x1F40) { + spF6 = -0x1F40; + } + + if (this->actor.speedXZ >= 3.2f) { + Math_ApproachS(&this->unk_166, spF6, 2, 0x4E20); + } else { + Math_ApproachS(&this->unk_166, spF6, 3, 0xBB8); + } + + Actor_UpdateVelocityWithoutGravity(&this->actor); + } + + Actor_UpdatePos(&this->actor); + + this->actor.world.pos.y += (this->unk_17C * 1.5f); + + if (1) {} + + if (this->unk_14A != 0) { + this->unk_160 = this->unk_14C; + this->unk_14A--; + if (this->unk_14E != 0) { + spF0 = 5; + spEE = 0x4000; + } else { + spF0 = 10; + spEE = 0x800; + } + this->unk_15E = -0x500 - this->actor.shape.rot.x; + spF4 = 5; + spF2 = 0x4000; + } else { + this->unk_14E = 0; + } + + Math_ApproachS(&this->unk_158, this->unk_15E, spF4, spF2); + Math_ApproachS(&this->unk_15A, this->unk_160, spF0, spEE); + Math_ApproachS(&this->unk_15C, this->unk_162, spFA, 0x2000); + + if (this->actor.speedXZ <= 0.5f) { + Math_ApproachS(&this->actor.shape.rot.x, 0, 10, this->unk_170); + Math_ApproachS(&this->unk_170, 0x500, 1, 0x20); + } else { + Math_ApproachS(&this->actor.shape.rot.x, -this->actor.world.rot.x, 10, 0x1000); + this->unk_170 = 0; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + + if ((this->unk_150 != -1) && (this->unk_150 != -2) && (this->unk_150 != -25)) { + if ((this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) && + (this->actor.prevPos.y <= WATER_SURFACE_Y(globalCtx))) { + func_809033F0(this, globalCtx, true); + func_80903C60(this, 1); + this->unk_17C = this->actor.velocity.y; + this->actor.velocity.y = 0.0f; + this->unk_162 = randPlusMinusPoint5Scaled(32768.0f); + } else if ((this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) && + (this->actor.prevPos.y >= WATER_SURFACE_Y(globalCtx))) { + if (this->unk_17C < -5.0f) { + this->unk_17C = -5.0f; + } + this->actor.world.rot.x = -0xFA0; + func_809033F0(this, globalCtx, true); + this->unk_1CA = 20; + func_80903C60(this, 0); + } + } + + if ((this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) && + (this->actor.world.pos.y > (WATER_SURFACE_Y(globalCtx) - 10.0f)) && !(this->unk_154 & 1) && + (this->actor.speedXZ > 0.0f)) { + Vec3f pos = this->actor.world.pos; + + pos.y = WATER_SURFACE_Y(globalCtx); + EnFishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &pos, 80.0f, 500.0f, 150, 90); + } + + if ((this->actor.speedXZ > 0.0f) || (this->unk_150 == 5)) { + f32 velocityY = this->actor.velocity.y; + + spD8 = this->unk_1A4 * 0.1f; + + this->actor.world.pos.y -= spD8; + this->actor.prevPos.y -= spD8; + this->actor.velocity.y = -1.0f; + if (KREG(90) == 0) { // Check added in MM + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 30.0f, 100.0f, 0x45); + } + this->actor.world.pos.y += spD8; + this->actor.prevPos.y += spD8; + + this->actor.velocity.y = velocityY; + + if (this->actor.bgCheckFlags & 8) { + this->unk_198 = 20; + } + + if (this->actor.bgCheckFlags & 1) { + if (this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { + this->unk_17C = Rand_ZeroFloat(3.0f) + 3.0f; + this->actor.velocity.x = this->actor.world.pos.x * -0.003f; + this->actor.velocity.z = this->actor.world.pos.z * -0.003f; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FISH_LEAP); + func_809036BC(this, globalCtx); + + if (Rand_ZeroOne() < 0.5f) { + this->unk_162 = 0x4000; + } else { + this->unk_162 = -0x4000; + } + + if (Rand_ZeroOne() < 0.5f) { + this->unk_15E = 0; + } else { + this->unk_15E = (s16)randPlusMinusPoint5Scaled(32.0f) + 0x8000; + } + + this->unk_160 = (s16)randPlusMinusPoint5Scaled(16384.0f); + this->unk_188 = 1.0f; + this->unk_18C = 5000.0f; + this->unk_194 = 5000.0f; + } else { + this->unk_17C = 0.0f; + + if ((this->unk_150 == 5) && !(this->unk_154 & 1)) { + Vec3f pos; + + pos.x = randPlusMinusPoint5Scaled(10.0f) + this->actor.world.pos.x; + pos.z = randPlusMinusPoint5Scaled(10.0f) + this->actor.world.pos.z; + pos.y = this->actor.floorHeight + 5.0f; + EnFishing_SpawnWaterDust(&this->actor.projectedPos, globalCtx->specialEffects, &pos, + (this->unk_1A4 * 0.005f) + 0.15f); + } + } + } + } + } + + if (this->unk_1CA != 0) { + s16 i; + Vec3f pos; + f32 range = (this->unk_1A4 * 0.075f) + 10.0f; + + this->unk_1CA--; + + for (i = 0; i < 2; i++) { + pos.x = randPlusMinusPoint5Scaled(range) + this->actor.world.pos.x; + pos.y = randPlusMinusPoint5Scaled(range) + this->actor.world.pos.y; + pos.z = randPlusMinusPoint5Scaled(range) + this->actor.world.pos.z; + EnFishing_SpawnBubble(&this->actor.projectedPos, globalCtx->specialEffects, &pos, + Rand_ZeroFloat(0.035f) + 0.04f, 0); + } + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateFish.s") +#endif + +s32 EnFishing_FishOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnFishing* this = THIS; + + if (limbIndex == 13) { + rot->z -= this->unk_168 - 11000; + } else if ((limbIndex == 2) || (limbIndex == 3)) { + rot->y += this->unk_164; + } else if (limbIndex == 4) { + rot->y += this->unk_16E; + } else if (limbIndex == 0xE) { + rot->y -= this->unk_16A; + } else if (limbIndex == 0xF) { + rot->y += this->unk_16A; + } else if (limbIndex == 8) { + rot->y += this->unk_16C; + } else if (limbIndex == 9) { + rot->y -= this->unk_16C; + } + + return false; +} + +void EnFishing_FishPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnFishing* this = THIS; + + if (limbIndex == 13) { + Matrix_MultiplyVector3fByState(&sFishMouthOffset, &this->fishMouthPos); + } +} + +s32 EnFishing_LoachOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnFishing* this = THIS; + + if (limbIndex == 3) { + rot->y += this->unk_1C4[0]; + } else if (limbIndex == 4) { + rot->y += this->unk_1C4[1]; + } else if (limbIndex == 5) { + rot->y += this->unk_1C4[2]; + } + + return 0; +} + +void EnFishing_LoachPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f sLoachMouthOffset = { 500.0f, 500.0f, 0.0f }; + EnFishing* this = THIS; + + if (limbIndex == 11) { + Matrix_MultiplyVector3fByState(&sLoachMouthOffset, &this->fishMouthPos); + } +} + +void EnFishing_DrawFish(Actor* thisx, GlobalContext* globalCtx) { + EnFishing* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(((this->unk_15A + this->actor.shape.rot.y) / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(((this->unk_158 + this->actor.shape.rot.x) / 32768.0f) * M_PI); + Matrix_InsertZRotation_f(((this->unk_15C + this->actor.shape.rot.z) / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + + if (this->unk_148 == 0) { + Matrix_InsertYRotation_f((this->unk_164 * (M_PI / 32768)) - (M_PI / 2), MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, this->unk_164 * 10.0f * 0.01f, MTXMODE_APPLY); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnFishing_FishOverrideLimbDraw, EnFishing_FishPostLimbDraw, + &this->actor); + } else { + Matrix_InsertTranslation(0.0f, 0.0f, 3000.0f, MTXMODE_APPLY); + Matrix_InsertYRotation_f(this->unk_164 * (M_PI / 32768), MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, -3000.0f, MTXMODE_APPLY); + Matrix_InsertYRotation_f(-(M_PI / 2), MTXMODE_APPLY); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnFishing_LoachOverrideLimbDraw, EnFishing_LoachPostLimbDraw, + &this->actor); + } +} + +void EnFishing_HandleReedContact(FishingProp* prop, Vec3f* entityPos) { + f32 dx = prop->pos.x - entityPos->x; + f32 dz = prop->pos.z - entityPos->z; + f32 distXZ = sqrtf(SQ(dx) + SQ(dz)); + + if (distXZ <= 20.0f) { + prop->rotY = Math_Acot2F(dz, dx); + + Math_ApproachF(&prop->rotX, (20.0f - distXZ) * 0.03f, 0.2f, 0.2f); + } +} + +void EnFishing_HandleLilyPadContact(FishingProp* prop, Vec3f* entityPos, u8 fishTimer) { + f32 dx = prop->pos.x - entityPos->x; + f32 dz = prop->pos.z - entityPos->z; + f32 distXZ = sqrtf(SQ(dx) + SQ(dz)); + + if (distXZ <= 40.0f) { + Math_ApproachS(&prop->lilyPadAngle, Math_FAtan2F(dz, dx), 10, 0x300); + } + + if (fishTimer && (distXZ <= 60.0f)) { + f32 heightTarget = 1.0f; + + if (fishTimer >= 21) { + heightTarget = 1.5f; + } + + Math_ApproachF(&prop->lilyPadOffset, heightTarget, 0.1f, 0.2f); + } +} + +void EnFishing_UpdatePondProps(GlobalContext* globalCtx) { + FishingProp* prop = &sPondProps[0]; + Player* player = GET_PLAYER(globalCtx); + Actor* actor; + s16 i; + + for (i = 0; i < POND_PROP_COUNT; i++) { + if (prop->type != FS_PROP_NONE) { + prop->shouldDraw = false; + prop->timer++; + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &prop->pos, &prop->projectedPos, &sProjectedW); + + if ((prop->projectedPos.z < prop->drawDistance) && + (fabsf(prop->projectedPos.x) < (100.0f + prop->projectedPos.z))) { + prop->shouldDraw = true; + } + + if ((prop->projectedPos.z < 500.0f) && (fabsf(prop->projectedPos.x) < (100.0f + prop->projectedPos.z))) { + if (prop->type == FS_PROP_REED) { + EnFishing_HandleReedContact(prop, &player->actor.world.pos); + + actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + while (actor != NULL) { + if (!((actor->id == ACTOR_EN_FISHING) && (actor->params >= 100))) { + actor = actor->next; + } else { + EnFishing_HandleReedContact(prop, &actor->world.pos); + actor = actor->next; + } + } + + Math_ApproachZeroF(&prop->rotX, 0.05f, 0.05f); + } else if (prop->type == FS_PROP_LILY_PAD) { + EnFishing_HandleLilyPadContact(prop, &player->actor.world.pos, 0); + + actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + while (actor != NULL) { + if (!((actor->id == ACTOR_EN_FISHING) && (actor->params >= 100))) { + actor = actor->next; + } else { + EnFishing_HandleLilyPadContact(prop, &actor->world.pos, ((EnFishing*)actor)->unk_149); + actor = actor->next; + } + } + + Math_ApproachS(&prop->lilyPadAngle, 0, 20, 80); + prop->pos.y = + (Math_SinS(prop->timer * 0x1000) * prop->lilyPadOffset) + (WATER_SURFACE_Y(globalCtx) + 2.0f); + Math_ApproachZeroF(&prop->lilyPadOffset, 0.1f, 0.02f); + } + } + } + + prop++; + } + + if (sCameraId == MAIN_CAM) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &sFishingMain->collider.base); + } +} + +void EnFishing_DrawPondProps(GlobalContext* globalCtx) { + u8 flag = 0; + FishingProp* prop = &sPondProps[0]; + s16 i; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + for (i = 0; i < POND_PROP_COUNT; i++) { + if (prop->type == FS_PROP_REED) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gFishingReedSetupDL); + flag++; + } + + if (prop->shouldDraw) { + Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); + Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(prop->rotX); + Matrix_InsertYRotation_f(prop->reedAngle, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingReedVtxDL); + } + } + + prop++; + } + + prop = &sPondProps[0]; + flag = 0; + for (i = 0; i < POND_PROP_COUNT; i++) { + if (prop->type == FS_PROP_WOOD_POST) { + if (flag == 0) { + gSPDisplayList(POLY_OPA_DISP++, gFishingWoodPostSetupDL); + flag++; + } + + if (prop->shouldDraw) { + Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingWoodPostVtxDL); + } + } + + prop++; + } + + prop = &sPondProps[0]; + flag = 0; + for (i = 0; i < POND_PROP_COUNT; i++) { + if (prop->type == FS_PROP_LILY_PAD) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gFishingLilyPadSetupDL); + flag++; + } + + if (prop->shouldDraw) { + Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Scale(prop->scale, 1.0f, prop->scale, MTXMODE_APPLY); + Matrix_InsertYRotation_f(prop->lilyPadAngle * (M_PI / 32768), MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 20.0f, MTXMODE_APPLY); + Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingLilyPadVtxDL); + } + } + + prop++; + } + + prop = &sPondProps[0]; + flag = 0; + for (i = 0; i < POND_PROP_COUNT; i++) { + if (prop->type == FS_PROP_ROCK) { + if (flag == 0) { + gSPDisplayList(POLY_OPA_DISP++, gFishingRockSetupDL); + flag++; + } + + if (prop->shouldDraw) { + Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); + Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingRockVtxDL); + } + } + + prop++; + } + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { + s16 groupContactFlags = 0; + Player* player = GET_PLAYER(globalCtx); + FishingGroupFish* fish = &sGroupFishes[0]; + f32 dy; + f32 dx; + f32 dist; + f32 dz; + f32 offset; + s16 groupIndex; + s16 groupFlag; + f32 spD8; + s16 spD6; + s16 spD4; + s16 target; + s16 i; + Vec3f basePos[3]; + Vec3f ripplePos; + Vec3f* refPos; + f32 temp1; + f32 temp2; + + if ((D_80917264 != 0) || (D_8090CD14 == 4)) { + refPos = &sLurePos; + } else { + refPos = &player->actor.world.pos; + } + + basePos[0].x = __sinf(sFishGroupAngle1) * 720.0f; + basePos[0].y = -35.0f; + basePos[0].z = __cosf(sFishGroupAngle1) * 720.0f; + + temp1 = refPos->x - basePos[0].x; + temp2 = refPos->z - basePos[0].z; + + if ((SQ(temp1) + SQ(temp2)) < SQ(50.0f)) { + sFishGroupAngle1 += 0.3f; + groupContactFlags |= 1; + } else if (D_8090CF18 != 0) { + sFishGroupAngle1 += 0.05f; + basePos[0].y = WATER_SURFACE_Y(globalCtx) - 5.0f; + } else { + Math_ApproachF(&sFishGroupAngle1, 0.7f, 1.0f, 0.001f); + } + + basePos[1].x = __sinf(sFishGroupAngle2) * 720.0f; + basePos[1].y = -35.0f; + basePos[1].z = __cosf(sFishGroupAngle2) * 720.0f; + + temp1 = refPos->x - basePos[1].x; + temp2 = refPos->z - basePos[1].z; + + if ((SQ(temp1) + SQ(temp2)) < SQ(50.0f)) { + sFishGroupAngle2 -= 0.3f; + groupContactFlags |= 2; + } else if (D_8090CF18 != 0) { + sFishGroupAngle2 -= 0.05f; + basePos[1].y = WATER_SURFACE_Y(globalCtx) - 5.0f; + } else { + Math_ApproachF(&sFishGroupAngle2, 2.3f, 1.0f, 0.001f); + } + + basePos[2].x = __sinf(sFishGroupAngle3) * 720.0f; + basePos[2].y = -35.0f; + basePos[2].z = __cosf(sFishGroupAngle3) * 720.0f; + + temp1 = refPos->x - basePos[2].x; + temp2 = refPos->z - basePos[2].z; + + if ((SQ(temp1) + SQ(temp2)) < SQ(50.0f)) { + sFishGroupAngle3 -= 0.3f; + groupContactFlags |= 4; + } else if (D_8090CF18 != 0) { + sFishGroupAngle3 -= 0.05f; + basePos[2].y = WATER_SURFACE_Y(globalCtx) - 5.0f; + } else { + Math_ApproachF(&sFishGroupAngle3, 4.6f, 1.0f, 0.001f); + } + + if (sLinkAge == 1) { + spD8 = 0.8f; + } else { + spD8 = 1.0f; + } + + for (i = 0; i < GROUP_FISH_COUNT; i++) { + if (fish->type != FS_GROUP_FISH_NONE) { + fish->timer++; + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &fish->pos, &fish->projectedPos, &sProjectedW); + + if ((fish->projectedPos.z < 400.0f) && (fabsf(fish->projectedPos.x) < (100.0f + fish->projectedPos.z))) { + fish->shouldDraw = true; + } else { + fish->shouldDraw = false; + } + + if (i <= 20) { + groupIndex = 0; + groupFlag = 1; + } else if (i <= 40) { + groupIndex = 1; + groupFlag = 2; + } else { + groupIndex = 2; + groupFlag = 4; + } + + dx = fish->unk_10.x - fish->pos.x; + dy = fish->unk_10.y - fish->pos.y; + dz = fish->unk_10.z - fish->pos.z; + spD4 = Math_FAtan2F(dz, dx); + dist = sqrtf(SQ(dx) + SQ(dz)); + spD6 = Math_FAtan2F(dist, dy); + + if ((dist < 10.0f) || (((fish->timer % 32) == 0) && (Rand_ZeroOne() > 0.5f))) { + fish->unk_10.y = basePos[groupIndex].y + randPlusMinusPoint5Scaled(10.0f); + + if (D_8090CF18 != 0) { + fish->unk_10.x = basePos[groupIndex].x + randPlusMinusPoint5Scaled(200.0f); + fish->unk_10.z = basePos[groupIndex].z + randPlusMinusPoint5Scaled(200.0f); + } else { + fish->unk_10.x = basePos[groupIndex].x + randPlusMinusPoint5Scaled(100.0f); + fish->unk_10.z = basePos[groupIndex].z + randPlusMinusPoint5Scaled(100.0f); + } + + ripplePos = fish->pos; + ripplePos.y = WATER_SURFACE_Y(globalCtx); + EnFishing_SpawnRipple(&fish->projectedPos, globalCtx->specialEffects, &ripplePos, 20.0f, + Rand_ZeroFloat(50.0f) + 100.0f, 150, 90); + + if (fish->unk_28 < 1.5f) { + fish->unk_28 = 1.5f; + } + + fish->unk_34 = 1.5f; + fish->unk_38 = 1.0f; + } + + target = EnFishing_SmoothStepToS(&fish->unk_3E, spD4, 5, 0x4000) * 3.0f; + if (target > 0x1F40) { + target = 0x1F40; + } else if (target < -0x1F40) { + target = -0x1F40; + } + + Math_ApproachS(&fish->unk_42, target, 3, 0x1388); + + offset = fish->unk_42 * -0.0001f; + Math_ApproachS(&fish->unk_3C, spD6, 5, 0x4000); + + if (groupContactFlags & groupFlag) { + fish->unk_38 = 1.0f; + fish->unk_28 = 6.0f; + fish->unk_34 = 2.0f; + } + + if (D_8090CF18 != 0) { + fish->unk_38 = 1.0f; + fish->unk_28 = 4.0f; + fish->unk_34 = 2.0f; + } + + Math_ApproachF(&fish->unk_28, 0.75f, 1.0f, 0.05f); + + temp1 = fish->unk_28 * spD8; + temp2 = Math_CosS(fish->unk_3C) * temp1; + + fish->pos.x += temp2 * Math_SinS(fish->unk_3E); + fish->pos.y += temp1 * Math_SinS(fish->unk_3C); + fish->pos.z += temp2 * Math_CosS(fish->unk_3E); + + if (fish->shouldDraw) { + Math_ApproachF(&fish->unk_34, 1.0f, 1.0f, 0.1f); + Math_ApproachF(&fish->unk_38, 0.4f, 1.0f, 0.04f); + fish->unk_30 += fish->unk_34; + fish->unk_2C = (__cosf(fish->unk_30) * fish->unk_38) + offset; + } + } + + fish++; + } + + D_8090CF18 = 0; +} + +void EnFishing_DrawGroupFishes(GlobalContext* globalCtx) { + u8 flag = 0; + FishingGroupFish* fish = &sGroupFishes[0]; + f32 scale; + s16 i; + s32 pad; + + if (sLinkAge == 1) { + scale = 0.003325f; + } else { + scale = 0.00475f; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + for (i = 0; i < GROUP_FISH_COUNT; i++) { + if (fish->type != FS_GROUP_FISH_NONE) { + if (flag == 0) { + gSPDisplayList(POLY_OPA_DISP++, gFishingGroupFishSetupDL); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 155, 155, 155, 255); + flag++; + } + + if (fish->shouldDraw) { + Matrix_InsertTranslation(fish->pos.x, fish->pos.y, fish->pos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(((f32)fish->unk_3E * M_PI) / 32768.0f, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis((-(f32)fish->unk_3C * M_PI) / 32768.0f); + Matrix_Scale(fish->unk_2C * scale, scale, scale, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingGroupFishVtxDL); + } + } + fish++; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +static u16 D_8090D638[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; + +void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { + switch (this->unk_154) { + case 0: + if (D_809171FC == 0) { + if (sLinkAge != 1) { + if ((gSaveContext.roomInf[127][2] & 0x100) && !(gSaveContext.roomInf[127][2] & 0x200)) { + this->actor.textId = 0x4093; + } else { + this->actor.textId = 0x407B; + } + } else { + this->actor.textId = 0x407B; + } + } else if (D_8090CD0C == 0) { + this->actor.textId = 0x4084; + } else { + this->actor.textId = 0x4097; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (D_809171FC == 0) { + this->unk_154 = 1; + if (sLinkAge != 1) { + gSaveContext.roomInf[127][2] |= 0x200; + } else { + gSaveContext.roomInf[127][2] |= 0x100; + } + } else { + this->unk_154 = 10; + } + } else { + func_800B8614(&this->actor, globalCtx, 100.0f); + } + break; + + case 1: + if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (gSaveContext.rupees >= 20) { + func_801159EC(-20); + if (func_8013EE04() == 0) { + this->actor.textId = 0x407C; + } else { + this->actor.textId = 0x407D; + } + func_80151938(globalCtx, this->actor.textId); + this->unk_154 = 2; + } else { + func_80151938(globalCtx, 0x407E); + this->unk_154 = 3; + } + break; + case 1: + func_80151938(globalCtx, 0x2D); + this->unk_154 = 3; + break; + } + } + break; + + case 2: + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + func_80151938(globalCtx, 0x407F); + this->unk_154 = 4; + } + break; + + case 3: + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + this->unk_154 = 0; + } + if (Message_GetState(&globalCtx->msgCtx) == 6) { + this->unk_154 = 0; + } + break; + + case 4: + if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + D_8090CCF8 = D_809171CC; + func_80151938(globalCtx, 0x4080); + this->unk_154 = 5; + break; + case 1: + func_80151938(globalCtx, 0x407F); + break; + } + } + break; + + case 5: + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + + globalCtx->interfaceCtx.unk_27E = 1; + globalCtx->startPlayerFishing(globalCtx); + D_809171FC = 1; + D_8090CD04 = 20; + this->unk_154 = 0; + + if ((gSaveContext.roomInf[127][2] & 0xFF0000) < 0xFF0000) { + gSaveContext.roomInf[127][2] += 0x10000; + } + } + break; + + case 10: + if (D_8090CD0C != 0) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_80151938(globalCtx, 0x40B2); + D_8090CD08 = 1; + D_8090CD0C = 0; + this->unk_154 = 20; + break; + case 1: + this->unk_154 = 0; + break; + } + } + } else { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (D_8090CCF0 == 0.0f) { + this->actor.textId = 0x408C; + this->unk_154 = 20; + } else if (D_809171D0 == 0) { + D_8090CCF8 = D_8090CCF0; + if ((s16)D_809171CC < (s16)D_8090CCF0) { + if (D_809171D2 == 2) { + this->actor.textId = 0x40B0; + } else { + this->actor.textId = 0x4086; + } + this->unk_154 = 11; + } else { + this->actor.textId = 0x408B; + this->unk_154 = 20; + } + } else { + this->actor.textId = 0x409B; + this->unk_154 = 11; + } + func_80151938(globalCtx, this->actor.textId); + break; + case 1: + if (D_8090CD00 > 36000) { + D_8090CD00 = 30000; + func_80151938(globalCtx, 0x4088); + } else { + if (D_809171CA == 0) { + if (D_809171D6 == 0) { + D_809171D6++; + } + } + + if ((D_80917206 == 2) && (D_8090D638[D_809171D6] == 0x408D)) { + func_80151938(globalCtx, 0x40AF); + } else { + func_80151938(globalCtx, D_8090D638[D_809171D6]); + } + + D_809171D6++; + + if (sLinkAge != 1) { + if (D_809171D6 >= 6) { + D_809171D6 = 0; + } + } else { + if (D_809171D6 >= 4) { + D_809171D6 = 0; + } + } + } + this->unk_154 = 0; + break; + case 2: + if (D_809171D8 == 0) { + func_80151938(globalCtx, 0x4085); + } else if (sLinkAge == 1) { + func_80151938(globalCtx, 0x4092); + } + this->unk_154 = 22; + break; + } + } + } + break; + + case 11: + if (((Message_GetState(&globalCtx->msgCtx) == 5) || !Message_GetState(&globalCtx->msgCtx)) && + func_80147624(globalCtx)) { + s32 getItemId; + + func_801477B4(globalCtx); + + if (D_809171D0 == 0) { + D_809171CC = D_8090CCF0; + D_8090CCF0 = 0.0f; + + if (sLinkAge == 1) { + f32 temp; + + gSaveContext.roomInf[127][2] &= 0xFFFFFF00; + gSaveContext.roomInf[127][2] |= ((s16)D_809171CC & 0x7F); + + temp = (gSaveContext.roomInf[127][2] & 0x7F000000) >> 0x18; + if (temp < D_809171CC) { + gSaveContext.roomInf[127][2] &= 0xFFFFFF; + gSaveContext.roomInf[127][2] |= ((s16)D_809171CC & 0x7F) << 0x18; + + if (D_809171D2 == 2) { + gSaveContext.roomInf[127][2] |= 0x80000000; + } + } + + if (D_809171D2 == 2) { + gSaveContext.roomInf[127][2] |= 0x80; + this->unk_154 = 0; + break; + } + } else { + gSaveContext.roomInf[127][2] &= 0xFFFFFF; + gSaveContext.roomInf[127][2] |= ((s16)D_809171CC & 0x7F) << 0x18; + + if (D_809171D2 == 2) { + gSaveContext.roomInf[127][2] |= 0x80000000; + this->unk_154 = 0; + break; + } + } + + if (D_809171CC >= 60.0f) { + getItemId = GI_RUPEE_PURPLE; + } else if (D_809171CC >= 50.0f) { + getItemId = GI_RUPEE_10; + } else if (D_809171CC >= 40.0f) { + getItemId = GI_RUPEE_BLUE; + } else { + getItemId = GI_RUPEE_GREEN; + } + + if (sLinkAge == 1) { + if ((D_809171CC >= 50.0f) && !(gSaveContext.roomInf[127][2] & 0x400)) { + gSaveContext.roomInf[127][2] |= 0x400; + getItemId = GI_HEART_PIECE; + sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; + } + } else { + if ((D_809171CC >= 60.0f) && !(gSaveContext.roomInf[127][2] & 0x800)) { + gSaveContext.roomInf[127][2] |= 0x800; + getItemId = GI_SCALE_GOLD; + sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; + } + } + } else { + getItemId = GI_RUPEE_PURPLE; + D_8090CCF0 = 0.0f; + } + + this->actor.parent = NULL; + Actor_PickUp(&this->actor, globalCtx, getItemId, 2000.0f, 1000.0f); + this->unk_154 = 23; + } + break; + + case 20: + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + this->unk_154 = 0; + } + break; + + case 21: + if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + this->unk_154 = 0; + break; + case 1: + if (D_809171D8 == 0) { + func_80151938(globalCtx, 0x4085); + } else if (sLinkAge == 1) { + func_80151938(globalCtx, 0x4092); + } + this->unk_154 = 22; + break; + } + } + break; + + case 22: + if (!Message_GetState(&globalCtx->msgCtx)) { + this->unk_154 = 0; + if (D_8090CD0C != 0) { + D_8090CD08 = 1; + D_8090CD0C = 0; + } + D_809171FC = 0; + globalCtx->interfaceCtx.unk_27E = 0; + } + break; + + case 23: + D_8090CCF4 = false; + if (Actor_HasParent(&this->actor, globalCtx)) { + this->unk_154 = 24; + } else { + Actor_PickUp(&this->actor, globalCtx, GI_SCALE_GOLD, 2000.0f, 1000.0f); + } + break; + + case 24: + D_8090CCF4 = false; + if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if (D_809171D0 == 0) { + this->unk_154 = 0; + } else { + func_801518B0(globalCtx, 0x409C, NULL); + this->unk_154 = 20; + } + } + break; + } +} + +static s16 D_8090D644[] = { 0, 1, 2, 2, 1 }; + +static Vec3f sStreamSoundPos = { 670.0f, 0.0f, -600.0f }; + +static Vec3s sSinkingLureLocationPos[] = { + { -364, -30, -269 }, + { 1129, 3, -855 }, + { -480, 0, -1055 }, + { 553, -48, -508 }, +}; + +#ifdef NON_MATCHING +// Register flip around target near the end of the function +void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnFishing* this = THIS; + Vec3f sp114; + Vec3f sp108; + Vec3f spFC; + s16 headRotTarget; + s16 playerShadowAlpha; + f32 target; + f32 camAtFraction; + f32 lureDistXZ; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Input* input = CONTROLLER1(globalCtx); + Camera* camera; + + playerShadowAlpha = player->actor.shape.shadowAlpha; + + if ((SQ(player->actor.world.pos.x) + SQ(player->actor.world.pos.z)) < SQ(920.0f)) { + Math_ApproachS(&playerShadowAlpha, 0, 1, 40); + } else { + Math_ApproachS(&playerShadowAlpha, 200, 1, 40); + } + + player->actor.shape.shadowAlpha = playerShadowAlpha; + + SkelAnime_Update(&this->skelAnime); + + if ((D_8090CD04 != 0) || Message_GetState(&globalCtx->msgCtx)) { + this->actor.flags &= ~1; + } else { + this->actor.flags |= 0x21; + } + + if ((this->actor.xzDistToPlayer < 120.0f) || Message_GetState(&globalCtx->msgCtx)) { + headRotTarget = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; + } else { + headRotTarget = 0; + } + + if (headRotTarget > 0x2710) { + headRotTarget = 0x2710; + } else if (headRotTarget < -0x2710) { + headRotTarget = -0x2710; + } + + Math_ApproachS(&this->unk_15C, headRotTarget, 3, 0x1388); + + if (((globalCtx->gameplayFrames % 32) == 0) && (Rand_ZeroOne() < 0.3f)) { + this->unk_15A = 4; + } + + this->unk_158 = D_8090D644[this->unk_15A]; + + if (this->unk_15A != 0) { + this->unk_15A--; + } + + if (D_8090CD04 != 0) { + D_8090CD04--; + } + + if ((D_8090CD0C == 0) && (D_80917206 != 2) && (D_8090CD14 > 0) && (D_8090CD08 == 1) && (D_8090CD04 == 0)) { + f32 dx = sOwnerHeadPos.x - sLurePos.x; + f32 dy = sOwnerHeadPos.y - sLurePos.y; + f32 dz = sOwnerHeadPos.z - sLurePos.z; + + if ((sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 25.0f)) { + D_8090CD08 = 0; + D_8090CD0C = 1; + func_801518B0(globalCtx, 0x4087, NULL); + } + } + + if (D_8090CD08 == 0) { + gSaveContext.roomInf[127][2] |= 0x1000; + } else if (D_8090CD08 == 1) { + gSaveContext.roomInf[127][2] &= ~0x1000; + } + + if (D_8090CCFC != 0) { + D_8090CCFC--; + if (D_8090CCFC == 0) { + func_801518B0(globalCtx, D_809171DA, NULL); + } + } + + EnFishing_HandleOwnerDialog(this, globalCtx); + + D_809101C8 = 0.0015f; + D_8090CD00++; + + if ((D_809171FC != 0) && D_8090CCF4) { + EnFishing_UpdateLure(this, globalCtx); + } + + EnFishing_UpdateEffects(globalCtx->specialEffects, globalCtx); + EnFishing_UpdatePondProps(globalCtx); + EnFishing_UpdateGroupFishes(globalCtx); + + if ((D_809171FC != 0) && (D_8090CD4C == 0) && (player->actor.world.pos.z > 1360.0f) && + (fabsf(player->actor.world.pos.x) < 25.0f)) { + player->actor.world.pos.z = 1360.0f; + player->actor.speedXZ = 0.0f; + + if (D_8090CD50 == 0) { + D_8090CD4C = 10; + } + } + + if ((sSinkingLureLocation != 0) && + (fabsf(player->actor.world.pos.x - sSinkingLureLocationPos[sSinkingLureLocation - 1].x) < 25.0f) && + (fabsf(player->actor.world.pos.y - sSinkingLureLocationPos[sSinkingLureLocation - 1].y) < 10.0f) && + (fabsf(player->actor.world.pos.z - sSinkingLureLocationPos[sSinkingLureLocation - 1].z) < 25.0f)) { + sSinkingLureLocation = 0; + D_8090CD4C = 20; + func_8013EC44(0.0f, 150, 10, 10); + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + Audio_QueueSeqCmd(0x101400FF); + } + + if (D_8090CD50 != 0) { + D_8090CD50--; + } + + switch (D_8090CD4C) { + case 0: + break; + + case 1: + sCameraId = func_801694DC(globalCtx); + func_80169590(globalCtx, MAIN_CAM, 1); + func_80169590(globalCtx, sCameraId, 7); + camera = Play_GetCamera(globalCtx, MAIN_CAM); + sCameraEye.x = camera->eye.x; + sCameraEye.y = camera->eye.y; + sCameraEye.z = camera->eye.z; + sCameraAt.x = camera->at.x; + sCameraAt.y = camera->at.y; + sCameraAt.z = camera->at.z; + D_8090CD4C = 2; + Interface_ChangeAlpha(12); + D_80911F4C = 0.0f; + // fallthrough + + case 2: + ShrinkWindow_SetLetterboxTarget(0x1B); + + spFC.x = sLurePos.x - player->actor.world.pos.x; + spFC.z = sLurePos.z - player->actor.world.pos.z; + lureDistXZ = sqrtf(SQ(spFC.x) + SQ(spFC.z)); + Matrix_InsertYRotation_f(Math_Acot2F(spFC.z, spFC.x), MTXMODE_NEW); + + sp114.x = 0.0f; + sp114.y = 0.0f; + sp114.z = 100.0f; + Matrix_MultiplyVector3fByState(&sp114, &spFC); + + if (D_8090CD14 == 1) { + camAtFraction = 0.2f; + } else { + camAtFraction = 0.1f; + } + + Math_ApproachF(&sCameraAt.x, sLurePos.x, camAtFraction, fabsf(spFC.x) * D_80911F4C); + Math_ApproachF(&sCameraAt.y, sLurePos.y, camAtFraction, 50.0f * D_80911F4C); + Math_ApproachF(&sCameraAt.z, sLurePos.z, camAtFraction, fabsf(spFC.z) * D_80911F4C); + + sp114.x = 0.0f - D_80911F50; + if (sLinkAge != 1) { + sp114.y = 80.0f; + } else { + sp114.y = 55.0f; + } + sp114.z = -80.0f; + + Matrix_MultiplyVector3fByState(&sp114, &sp108); + sp108.x += player->actor.world.pos.x; + sp108.y += player->actor.world.pos.y; + sp108.z += player->actor.world.pos.z; + + Math_ApproachF(&D_80911F50, 30.0f, 0.1f, 0.4f); + + if (CHECK_BTN_ALL(input->press.button, BTN_Z)) { + if ((D_809171DC >= 0) && (D_80917272 == 0)) { + D_809171DC++; + + if (D_809171DC >= 4) { + D_809171DC = 0; + } + + if ((D_809171DC == 0) || (D_809171DC == 3)) { + play_sound(NA_SE_SY_CAMERA_ZOOM_DOWN); + } else { + play_sound(NA_SE_SY_CAMERA_ZOOM_UP); + } + } + } + + if (D_8090CD14 >= 3) { + if (lureDistXZ < 110.0f) { + D_809171DC = -1; + } else if ((lureDistXZ > 300.0f) && (D_809171DC < 0)) { + D_809171DC = 0; + } + } + + if (D_809171DC > 0) { + f32 dist; + f32 offset; + f32 factor; + + dist = sqrtf(SQ(spFC.x) + SQ(spFC.z)) * 0.001f; + if (dist > 1.0f) { + dist = 1.0f; + } + if (D_809171DC == 2) { + offset = 0.3f; + } else { + offset = 0.1f; + } + factor = 0.4f + offset + (dist * 0.4f); + + sp108.x += (sLurePos.x - sp108.x) * factor; + sp108.y += ((sLurePos.y - sp108.y) * factor) + 20.0f; + sp108.z += (sLurePos.z - sp108.z) * factor; + D_809101C8 = 0.0005000001f; + } + + sp114.x = 0.0f; + sp114.y = 0.0f; + sp114.z = 100.0f; + Matrix_MultiplyVector3fByState(&sp114, &spFC); + + Math_ApproachF(&sCameraEye.x, sp108.x, 0.3f, fabsf(spFC.x) * D_80911F4C); + Math_ApproachF(&sCameraEye.y, sp108.y, 0.3f, 20.0f * D_80911F4C); + Math_ApproachF(&sCameraEye.z, sp108.z, 0.3f, fabsf(spFC.z) * D_80911F4C); + break; + + case 3: { + Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); + + camera->eye = sCameraEye; + camera->eyeNext = sCameraEye; + camera->at = sCameraAt; + } + func_80169AFC(globalCtx, sCameraId, 0); + func_800EA0EC(globalCtx, &globalCtx->csCtx); + D_8090CD4C = 0; + sCameraId = MAIN_CAM; + func_800F6834(globalCtx, 0); + globalCtx->envCtx.unk_8C.fogNear = 0; + player->unk_B28 = -5; + D_80917200 = 5; + break; + + case 10: + func_800EA0D4(globalCtx, &globalCtx->csCtx); + sCameraId = func_801694DC(globalCtx); + func_80169590(globalCtx, MAIN_CAM, 1); + func_80169590(globalCtx, sCameraId, 7); + func_800B7298(globalCtx, &this->actor, 4); + camera = Play_GetCamera(globalCtx, MAIN_CAM); + sCameraEye.x = camera->eye.x; + sCameraEye.y = camera->eye.y; + sCameraEye.z = camera->eye.z; + sCameraAt.x = camera->at.x; + sCameraAt.y = camera->at.y; + sCameraAt.z = camera->at.z; + func_801518B0(globalCtx, 0x409E, NULL); + D_8090CD4C = 11; + func_8013EC44(0.0f, 150, 10, 10); + // fallthrough + + case 11: + player->actor.world.pos.z = 1360.0f; + player->actor.speedXZ = 0.0f; + + if (!Message_GetState(&globalCtx->msgCtx)) { + camera = Play_GetCamera(globalCtx, MAIN_CAM); + + camera->eye = sCameraEye; + camera->eyeNext = sCameraEye; + camera->at = sCameraAt; + func_80169AFC(globalCtx, sCameraId, 0); + func_800EA0EC(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + D_8090CD4C = 0; + sCameraId = MAIN_CAM; + D_8090CD50 = 30; + func_800F6834(globalCtx, 0); + globalCtx->envCtx.unk_8C.fogNear = 0; + } + break; + + case 20: + func_800EA0D4(globalCtx, &globalCtx->csCtx); + sCameraId = func_801694DC(globalCtx); + func_80169590(globalCtx, MAIN_CAM, 1); + func_80169590(globalCtx, sCameraId, 7); + func_800B7298(globalCtx, &this->actor, 4); + camera = Play_GetCamera(globalCtx, MAIN_CAM); + sCameraEye.x = camera->eye.x; + sCameraEye.y = camera->eye.y; + sCameraEye.z = camera->eye.z; + sCameraAt.x = camera->at.x; + sCameraAt.y = camera->at.y; + sCameraAt.z = camera->at.z; + func_801518B0(globalCtx, 0x409A, NULL); + D_8090CD4C = 21; + D_80911F48 = 45.0f; + D_8090CD50 = 10; + // fallthrough + + case 21: + if ((D_8090CD50 == 0) && func_80147624(globalCtx)) { + D_8090CD4C = 22; + D_8090CD50 = 40; + // func_800B7298 call removed in MM + D_80911F64 = 0.0f; + } + break; + + case 22: + if (D_8090CD50 == 30) { + Audio_QueueSeqCmd(0x8922); // changed from 0x922 to 0x8922 in MM + } + + D_8090CD54 = 1; + + Math_ApproachF(&D_80911F64, 71.0f, 0.5f, 3.0f); + Matrix_InsertYRotation_f(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); + + sp114.x = Math_SinS(globalCtx->gameplayFrames * 0x1000); + sp114.y = D_80911F64; + sp114.z = -5.0f; + if (sLinkAge == 1) { + sp114.y -= 20.0f; + } + + Matrix_MultiplyVector3fByState(&sp114, &sp108); + + sSinkingLureBasePos.x = player->actor.world.pos.x + sp108.x; + sSinkingLureBasePos.y = player->actor.world.pos.y + sp108.y; + sSinkingLureBasePos.z = player->actor.world.pos.z + sp108.z; + + Math_ApproachF(&D_80911F48, 15.0f, 0.1f, 0.75f); + + sp114.x = D_80911F48 - 15.0f; + + if (sLinkAge != 1) { + sp114.y = 60.0f; + sp114.z = -30.0f; + } else { + sp114.y = 40.0f; + sp114.z = -35.0f; + } + + Matrix_MultiplyVector3fByState(&sp114, &sCameraEye); + sCameraEye.x += player->actor.world.pos.x; + sCameraEye.y += player->actor.world.pos.y; + sCameraEye.z += player->actor.world.pos.z; + + sCameraAt = player->actor.world.pos; + if (sLinkAge != 1) { + sCameraAt.y += 62.0f; + } else { + sCameraAt.y += 40.0f; + } + + if (D_8090CD50 == 0) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { + if (func_80147624(globalCtx)) { + Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); + + func_801477B4(globalCtx); + if (globalCtx->msgCtx.choiceIndex == 0) { + D_80917206 = 2; + D_809171D6 = 0; + } + + camera->eye = sCameraEye; + camera->eyeNext = sCameraEye; + camera->at = sCameraAt; + func_80169AFC(globalCtx, sCameraId, 0); + func_800EA0EC(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); // arg2 changed from 7 to 6 in MM + D_8090CD4C = 0; + sCameraId = MAIN_CAM; + player->unk_B28 = -5; + D_80917200 = 5; + D_8090CD54 = 0; + D_809171F6 = 20; + func_800F6834(globalCtx, 0); + globalCtx->envCtx.unk_8C.fogNear = 0; + } + } + } + break; + + case 100: + break; + } + + if (sCameraId != MAIN_CAM) { + Play_CameraSetAtEye(globalCtx, sCameraId, &sCameraAt, &sCameraEye); + Math_ApproachF(&D_80911F4C, 1.0f, 1.0f, 0.02f); + + if (sCameraEye.y <= (WATER_SURFACE_Y(globalCtx) + 1.0f)) { + func_800F6834(globalCtx, 1); + if (D_809171CA != 0) { + globalCtx->envCtx.unk_8C.fogNear = -0xB2; + } else { + globalCtx->envCtx.unk_8C.fogNear = -0x2E; + } + } else { + func_800F6834(globalCtx, 0); + globalCtx->envCtx.unk_8C.fogNear = 0; + } + } + + if ((player->actor.floorHeight < (WATER_SURFACE_Y(globalCtx) - 3.0f)) && + (player->actor.world.pos.y < (player->actor.floorHeight + 3.0f)) && (player->actor.speedXZ > 1.0f) && + ((globalCtx->gameplayFrames % 2) == 0)) { + Vec3f pos; + + pos.x = randPlusMinusPoint5Scaled(20.0f) + player->actor.world.pos.x; + pos.z = randPlusMinusPoint5Scaled(20.0f) + player->actor.world.pos.z; + pos.y = player->actor.floorHeight + 5.0f; + EnFishing_SpawnWaterDust(NULL, globalCtx->specialEffects, &pos, 0.5f); + } + + if ((player->actor.floorHeight < WATER_SURFACE_Y(globalCtx)) && + (player->actor.floorHeight > (WATER_SURFACE_Y(globalCtx) - 10.0f)) && (player->actor.speedXZ >= 4.0f) && + ((globalCtx->gameplayFrames % 4) == 0)) { + s16 i; + + for (i = 0; i < 10; i++) { + Vec3f pos; + Vec3f vel; + f32 speedXZ; + f32 angle; + + speedXZ = Rand_ZeroFloat(1.5f) + 1.5f; + angle = Rand_ZeroFloat(6.28f); + + vel.x = __sinf(angle) * speedXZ; + vel.z = __cosf(angle) * speedXZ; + vel.y = Rand_ZeroFloat(3.0f) + 2.0f; + + pos = player->actor.world.pos; + pos.x += 2.0f * vel.x; + pos.y = WATER_SURFACE_Y(globalCtx); + pos.z += 2.0f * vel.z; + EnFishing_SpawnDustSplash(NULL, globalCtx->specialEffects, &pos, &vel, + Rand_ZeroFloat(0.01f) + 0.020000001f); + } + } + + if (D_809171CB >= 2) { + D_809171CB--; + } + + if ((D_809171CB == 1) && !Message_GetState(&globalCtx->msgCtx) && ((D_8090CD00 & 0xFFF) == 0xFFF)) { + D_809171CB = 200; + + if (Rand_ZeroOne() < 0.5f) { + D_8090CCD4 = Rand_ZeroFloat(10.0f) + 5.0f; + globalCtx->envCtx.unk_E1 = 1; + } else { + D_8090CCD4 = 0; + globalCtx->envCtx.unk_E1 = 2; + } + } + + Math_ApproachF(&D_8090CCD0, D_8090CCD4, 1.0f, 0.05f); + + if (D_8090CCD0 > 0.0f) { + target = (D_8090CCD0 * 0.03f) + 0.8f; + if (target > 1.2f) { + target = 1.2f; + } + Math_ApproachF(&D_8090CCE8, target, 1.0f, 0.01f); + } + + target = (10.0f - D_8090CCD0) * 150.1f; + if (target < 0.0f) { + target = 0.0f; + } + Math_ApproachF(&D_8090CCDC.z, target, 1.0f, 5.0f); + + if (D_8090CCDC.z < 1500.0f) { + func_8019FAD8(&D_8090CCDC, NA_SE_EV_RAIN - SFX_FLAG, D_8090CCE8); + } + + if (D_8090CCD4 != 0) { + Math_ApproachF(&D_8090CCD8, -200.0f, 1.0f, 2.0f); + } else { + Math_ApproachZeroF(&D_8090CCD8, 1.0f, 2.0f); + } + + globalCtx->envCtx.unk_8C.diffuseColor1[0] = globalCtx->envCtx.unk_8C.diffuseColor1[1] = + globalCtx->envCtx.unk_8C.diffuseColor1[2] = D_8090CCD8; + + if ((u8)D_8090CCD0 > 0) { + s32 pad; + Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); + s16 i; + s32 pad1; + Vec3f pos; + Vec3f rot; + Vec3f projectedPos; + s32 pad2; + + rot.x = 1.6707964f; + rot.y = 1.0f; + rot.z = (func_800DFC68(camera) * -(M_PI / 32768)) + rot.y; + + for (i = 0; i < (u8)D_8090CCD0; i++) { + pos.x = randPlusMinusPoint5Scaled(700.0f) + globalCtx->view.eye.x; + pos.y = (Rand_ZeroFloat(100.0f) + 150.0f) - 170.0f; + pos.z = randPlusMinusPoint5Scaled(700.0f) + globalCtx->view.eye.z; + + if (pos.z < 1160.0f) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pos, &projectedPos, &sProjectedW); + + if (projectedPos.z < 0.0f) { + i--; + } else { + EnFishing_SpawnRainDrop(globalCtx->specialEffects, &pos, &rot); + } + } + } + } + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sStreamSoundPos, &sStreamSoundProjectedPos, + &sProjectedW); + + Audio_PlaySfxAtPos(&sStreamSoundProjectedPos, NA_SE_EV_WATER_WALL - SFX_FLAG); + + if (gSaveContext.language == 0) { // Added in MM + gSaveContext.minigameScore = D_8090CCF8; + } else { + gSaveContext.minigameScore = (SQ((f32)D_8090CCF8) * 0.0036f) + 0.5f; + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateOwner.s") +#endif + +s32 EnFishing_OwnerOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnFishing* this = THIS; + + if (limbIndex == 8) { // Head + rot->x -= this->unk_15C; + } + + return false; +} + +void EnFishing_OwnerPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == 8) { // Head + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_MultiplyVector3fByState(&sZeroVec, &sOwnerHeadPos); + + if (D_8090CD08 == 1) { + gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); + } else if (D_8090CD08 == 2) { + gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHairDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +static UNK_TYPE sFishingOwnerEyeTexs[] = { + &gFishingOwnerEyeOpenTex, + &gFishingOwnerEyeHalfTex, + &gFishingOwnerEyeClosedTex, +}; + +void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFishing* this = THIS; + Input* input = CONTROLLER1(globalCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + if ((this->actor.projectedPos.z < 1500.0f) && + (fabsf(this->actor.projectedPos.x) < (100.0f + this->actor.projectedPos.z))) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sFishingOwnerEyeTexs[this->unk_158])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnFishing_OwnerOverrideLimbDraw, EnFishing_OwnerPostLimbDraw, + &this->actor); + } + + EnFishing_DrawPondProps(globalCtx); + EnFishing_DrawEffects(globalCtx->specialEffects, globalCtx); + EnFishing_DrawGroupFishes(globalCtx); + EnFishing_DrawStreamSplash(globalCtx); + + if (D_809171F6 != 0) { + D_809171F6--; + + if (D_809171F6 == 0) { + if (sLinkAge != 1) { + Audio_QueueSeqCmd(0x8019); // Changed from 0x19 in OoT + } else { + Audio_QueueSeqCmd(0x8027); // Changed from 0x27 in OoT + } + + if (sLinkAge != 1) { + Audio_QueueSeqCmd(0x8019); // Changed from 0x19 in OoT + } else { + Audio_QueueSeqCmd(0x8027); // Changed from 0x27 in OoT + } + } + } + + if ((D_809171FC != 0) && D_8090CCF4) { + EnFishing_DrawRod(globalCtx); + EnFishing_UpdateLinePos(sReelLinePos); + EnFishing_UpdateLine(globalCtx, &sRodTipPos, sReelLinePos, sReelLineRot, sReelLineUnk); + EnFishing_DrawLureAndLine(globalCtx, sReelLinePos, sReelLineRot); + + D_8090CD44 = input->rel.stick_x; + D_8090CD48 = input->rel.stick_y; + } + + D_8090CCF4 = true; + + Matrix_InsertTranslation(130.0f, 40.0f, 1300.0f, MTXMODE_NEW); + Matrix_Scale(0.08f, 0.12f, 0.14f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gFishingAquariumBottomDL); + gSPDisplayList(POLY_XLU_DISP++, gFishingAquariumContainerDL); + + if ((D_809171FC != 0) && (D_80917206 == 2)) { + EnFishing_DrawSinkingLure(globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h index d954b4cf88..3cd594b384 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h @@ -9,7 +9,56 @@ typedef void (*EnFishingActionFunc)(struct EnFishing*, GlobalContext*); typedef struct EnFishing { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x404]; + /* 0x0144 */ UNK_TYPE1 unk_144[0x004]; + /* 0x0148 */ u8 unk_148; + /* 0x0149 */ u8 unk_149; + /* 0x014A */ u8 unk_14A; + /* 0x014C */ s16 unk_14C; + /* 0x014E */ u8 unk_14E; + /* 0x014F */ u8 unk_14F; + /* 0x0150 */ s16 unk_150; + /* 0x0152 */ s16 unk_152; + /* 0x0154 */ s16 unk_154; + /* 0x0156 */ s16 unk_156; + /* 0x0158 */ s16 unk_158; + /* 0x015A */ s16 unk_15A; + /* 0x015C */ s16 unk_15C; + /* 0x015E */ s16 unk_15E; + /* 0x0160 */ s16 unk_160; + /* 0x0162 */ s16 unk_162; + /* 0x0164 */ s16 unk_164; + /* 0x0166 */ s16 unk_166; + /* 0x0168 */ s16 unk_168; + /* 0x016A */ s16 unk_16A; + /* 0x016C */ s16 unk_16C; + /* 0x016E */ s16 unk_16E; + /* 0x0170 */ s16 unk_170; + /* 0x0172 */ s16 unk_172[4]; + /* 0x017C */ f32 unk_17C; + /* 0x0180 */ f32 unk_180; + /* 0x0184 */ f32 unk_184; + /* 0x0188 */ f32 unk_188; + /* 0x018C */ f32 unk_18C; + /* 0x0190 */ f32 unk_190; + /* 0x0194 */ f32 unk_194; + /* 0x0198 */ s16 unk_198; + /* 0x019A */ s16 unk_19A; + /* 0x019C */ s16 unk_19C; + /* 0x01A0 */ f32 unk_1A0; + /* 0x01A4 */ f32 unk_1A4; + /* 0x01A8 */ f32 unk_1A8; + /* 0x01AC */ Vec3f unk_1AC; + /* 0x01B8 */ Vec3f fishMouthPos; + /* 0x01C4 */ s16 unk_1C4[3]; + /* 0x01CA */ u8 unk_1CA; + /* 0x01CB */ u8 unk_1CB; + /* 0x01CC */ u8 unk_1CC; + /* 0x01CD */ u8 unk_1CD; + /* 0x01D0 */ SkelAnime skelAnime; + /* 0x0214 */ LightNode* lightNode; + /* 0x0218 */ LightInfo lightInfo; + /* 0x0228 */ ColliderJntSph collider; + /* 0x0248 */ ColliderJntSphElement colliderElements[12]; } EnFishing; // size = 0x548 extern const ActorInit En_Fishing_InitVars; diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index a1818b0950..fe74226102 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -165,7 +165,7 @@ void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { s32 params; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 50.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06008FB0, &D_06009DB0, this->jointTable, this->morphTable, 25); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -236,7 +236,7 @@ void func_808D0930(EnFloormas* this, GlobalContext* globalCtx) { func_808D19D4((EnFloormas*)this->actor.child); func_808D19D4((EnFloormas*)this->actor.parent); func_808D19D4(this); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KUSAMUSHI_HIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_HIDE); } else { Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); func_808D1ED4(this, globalCtx); @@ -251,7 +251,7 @@ void func_808D09CC(EnFloormas* this) { this->collider.base.colType = COLTYPE_HIT3; this->unk_18E = 80; this->actor.flags &= ~(0x400 | 0x200); - func_800BCB70(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808D0A48(EnFloormas* this, GlobalContext* globalCtx) { @@ -259,8 +259,8 @@ void func_808D0A48(EnFloormas* this, GlobalContext* globalCtx) { this->unk_18C = 0; this->collider.base.colType = COLTYPE_HIT0; this->unk_2C4 = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), 2, - this->actor.scale.x * 30.000002f, this->actor.scale.x * 20.0f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), 2, + this->actor.scale.x * 30.000002f, this->actor.scale.x * 20.0f); if (this->actor.scale.x > 0.009f) { this->actor.flags |= 0x400; } else { @@ -277,10 +277,10 @@ void func_808D0B08(EnFloormas* this) { void func_808D0B50(EnFloormas* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { - if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsActorFacingLink(&this->actor, 0x4000)) { + if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsFacingPlayer(&this->actor, 0x4000)) { this->unk_190 = this->actor.yawTowardsPlayer; func_808D108C(this); - } else if ((this->actor.xzDistToPlayer < 280.0f) && Actor_IsActorFacingLink(&this->actor, 0x2000)) { + } else if ((this->actor.xzDistToPlayer < 280.0f) && Actor_IsFacingPlayer(&this->actor, 0x2000)) { func_808D1380(this, globalCtx); } else { func_808D0C14(this); @@ -328,15 +328,15 @@ void func_808D0D70(EnFloormas* this, GlobalContext* globalCtx) { if ((temp_v0 != 0) || Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 24.0f) || Animation_OnFrame(&this->skelAnime, 36.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_WALK); } - if ((this->actor.xzDistToPlayer < 320.0f) && Actor_IsActorFacingLink(&this->actor, 0x4000)) { + if ((this->actor.xzDistToPlayer < 320.0f) && Actor_IsFacingPlayer(&this->actor, 0x4000)) { func_808D0F50(this); } else if (this->actor.bgCheckFlags & 8) { this->unk_190 = this->actor.wallYaw; func_808D108C(this); - } else if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsActorFacingLink(&this->actor, 0x4000)) { + } else if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsFacingPlayer(&this->actor, 0x4000)) { this->unk_190 = this->actor.yawTowardsPlayer; func_808D108C(this); } else if (this->unk_18E == 0) { @@ -367,11 +367,11 @@ void func_808D0F80(EnFloormas* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 24.0f) || Animation_OnFrame(&this->skelAnime, 36.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_WALK); } Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x71C); - if ((this->actor.xzDistToPlayer < 280.0f) && Actor_IsActorFacingLink(&this->actor, 0x2000) && + if ((this->actor.xzDistToPlayer < 280.0f) && Actor_IsFacingPlayer(&this->actor, 0x2000) && !(this->actor.bgCheckFlags & 8)) { func_808D1380(this, globalCtx); } else if (this->actor.xzDistToPlayer > 400.0f) { @@ -412,9 +412,9 @@ void func_808D11BC(EnFloormas* this, GlobalContext* globalCtx) { if (((this->skelAnime.playSpeed > 0.0f) && Animation_OnFrame(&this->skelAnime, 21.0f)) || ((this->skelAnime.playSpeed < 0.0f) && Animation_OnFrame(&this->skelAnime, 6.0f))) { if (this->actor.scale.x > 0.009f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_WALK); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); } } @@ -433,8 +433,8 @@ void func_808D1380(EnFloormas* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; this->actor.gravity = 0.0f; func_808D08D0(this); - func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_ATTACK); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, 1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_ATTACK); this->actionFunc = func_808D1458; } @@ -461,10 +461,10 @@ void func_808D14DC(EnFloormas* this, GlobalContext* globalCtx) { sp28.x = Math_SinS(this->actor.shape.rot.y + 0x6000) * 7.0f; sp28.z = Math_CosS(this->actor.shape.rot.y + 0x6000) * 7.0f; - func_800B1210(globalCtx, &sp34, &sp28, &D_801D15B0, 0x1C2, 0x64); + func_800B1210(globalCtx, &sp34, &sp28, &gZeroVec3f, 0x1C2, 0x64); sp28.x = Math_SinS(this->actor.shape.rot.y - 0x6000) * 7.0f; sp28.z = Math_CosS(this->actor.shape.rot.y - 0x6000) * 7.0f; - func_800B1210(globalCtx, &sp34, &sp28, &D_801D15B0, 0x1C2, 0x64); + func_800B1210(globalCtx, &sp34, &sp28, &gZeroVec3f, 0x1C2, 0x64); func_800B9010(&this->actor, NA_SE_EN_FLOORMASTER_SLIDING - SFX_FLAG); } @@ -522,9 +522,9 @@ void func_808D17EC(EnFloormas* this, GlobalContext* globalCtx) { if (this->actor.velocity.y < -4.0f) { if (this->actor.scale.x > 0.009f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_LAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_LAND); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); } } } @@ -600,7 +600,7 @@ void func_808D1B44(EnFloormas* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); } if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); } } @@ -617,7 +617,7 @@ void func_808D1C1C(EnFloormas* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); } if (this->unk_194 == 0) { @@ -644,7 +644,7 @@ void func_808D1D6C(EnFloormas* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); } flags = this->actor.bgCheckFlags & 8; @@ -682,8 +682,8 @@ void func_808D1ED4(EnFloormas* this, GlobalContext* globalCtx) { sp34.x = this->actor.world.pos.x; sp34.y = this->actor.world.pos.y + 15.0f; sp34.z = this->actor.world.pos.z; - func_800B3030(globalCtx, &sp34, &D_801D15B0, &D_801D15B0, 150, -10, 2); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + func_800B3030(globalCtx, &sp34, &gZeroVec3f, &gZeroVec3f, 150, -10, 2); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); this->actionFunc = func_808D1F7C; } @@ -712,7 +712,7 @@ void func_808D2040(EnFloormas* this, GlobalContext* globalCtx) { } else if (this->actor.bgCheckFlags & 2) { this->unk_18E = 50; this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); func_808D1740(this); } else if ((this->actor.playerHeightRel < -10.0f) && (this->collider.base.ocFlags1 & OC1_HIT) && (&player->actor == this->collider.base.oc)) { @@ -774,10 +774,10 @@ void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { this->actor.speedXZ = -3.0f; func_808D1740(this); } else if ((this->unk_190 % 20) == 0) { - func_800B8E58(&player->actor, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); + func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); globalCtx->damagePlayer(globalCtx, -4); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_STICK - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_STICK - SFX_FLAG); } void func_808D2484(EnFloormas* this) { @@ -814,7 +814,7 @@ void func_808D24F0(EnFloormas* this, GlobalContext* globalCtx) { this->collider.base.ocFlags1 |= OC1_ON; } else if (this->actor.bgCheckFlags & 2) { this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); func_808D1740(this); } @@ -874,7 +874,7 @@ void func_808D2764(EnFloormas* this, GlobalContext* globalCtx) { this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; if (((temp_f2 == 0.007f) || (temp_f2 == 0.004f)) && (temp_f2 != this->actor.scale.x)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_EXPAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_EXPAND); } this->collider.dim.radius = sCylinderInit.dim.radius * 100.0f * this->actor.scale.x; @@ -935,7 +935,7 @@ void func_808D2AF4(EnFloormas* this, GlobalContext* globalCtx) { void func_808D2B18(EnFloormas* this) { Animation_MorphToPlayOnce(&this->skelAnime, &D_06000590, -3.0f); func_800BE504(&this->actor, &this->collider); - func_800BCB70(&this->actor, 0x4000, 255, 0, 20); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); this->actor.speedXZ = 5.0f; this->actor.velocity.y = 5.5f; if (this->actor.params == ENFLOORMAS_GET_7FFF_40) { @@ -966,9 +966,9 @@ void func_808D2C08(EnFloormas* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 13.0f)) { if (this->actor.scale.x > 0.009f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } } @@ -1017,7 +1017,7 @@ void func_808D2DC0(EnFloormas* this, GlobalContext* globalCtx) { void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - func_800BE258(&this->actor, &this->collider.info); + Actor_SetDropFlag(&this->actor, &this->collider.info); if ((this->unk_18C != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (this->actor.colChkInfo.damageEffect == 0xE) { func_808D0908(this); @@ -1033,14 +1033,14 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { if (this->collider.base.colType != COLTYPE_HARD) { if (!Actor_ApplyDamage(&this->actor)) { if (this->actor.scale.x > 0.009f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIOCTA_REVERSE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_REVERSE); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_DEAD); } Enemy_StartFinishingBlow(globalCtx, &this->actor); this->actor.flags &= ~1; } else if (this->actor.colChkInfo.damage != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_DAMAGE); } func_808D0A48(this, globalCtx); @@ -1055,13 +1055,13 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { func_808D2D6C(this); } else if (this->actor.colChkInfo.damageEffect == 1) { this->unk_18E = 40; - func_800BCB70(&this->actor, 0, 255, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_808D2D6C(this); } else if (this->actor.colChkInfo.damageEffect == 5) { this->unk_18E = 40; - func_800BCB70(&this->actor, 0, 255, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->unk_2C8 = 0.55f; this->unk_2C4 = 2.0f; this->unk_18C = 31; @@ -1110,7 +1110,7 @@ void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->actionFunc != func_808D22C8) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->actor.scale.x * 3000.0f, 0.0f, 0x1D); @@ -1131,7 +1131,7 @@ void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_SetHeight(&this->actor, this->actor.scale.x * 2500.0f); + Actor_SetFocus(&this->actor, this->actor.scale.x * 2500.0f); if (this->collider.base.colType == COLTYPE_HARD) { if (this->unk_190 != 0) { this->unk_190--; diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index bf159f7de6..7e43657c09 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -196,9 +196,9 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_HandleSetupResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx) && this->cutsceneState == 0) { - func_800B84D0(&this->actor, globalCtx); - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx) && this->cutsceneState == 0) { + Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); if (ENFSN_IS_SHOP(&this->actor)) { this->actor.textId = 0; } @@ -376,7 +376,7 @@ void EnFsn_EndInteraction(EnFsn* this, GlobalContext* globalCtx) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = 0; } - func_800B84D0(&this->actor, globalCtx); + Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; Interface_ChangeAlpha(50); @@ -415,7 +415,7 @@ void EnFsn_UpdateCursorPos(EnFsn* this, GlobalContext* globalCtx) { f32 xOffset = 0.0f; f32 yOffset = 17.0f; - func_800B8898(globalCtx, &this->items[this->cursorIdx]->actor, &sp2E, &sp2C); + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &sp2E, &sp2C); this->cursorPos.x = sp2E + xOffset; this->cursorPos.y = sp2C + yOffset; this->cursorPos.z = 1.2f; @@ -722,7 +722,7 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { this->actionFunc = EnFsn_Haggle; } else { dummy2:; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->cutsceneState == 0) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -754,7 +754,7 @@ void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); } else { if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } if (this->flags & ENFSN_CALM_DOWN) { this->flags &= ~ENFSN_CALM_DOWN; @@ -771,7 +771,7 @@ void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); } else { if (Animation_OnFrame(&this->skelAnime, 28.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } return; } @@ -806,7 +806,7 @@ void EnFsn_BeginInteraction(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_StartBuying(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); EnFsn_HandleLookToShopkeeperBuyingCutscene(this); @@ -827,7 +827,7 @@ void EnFsn_StartBuying(EnFsn* this, GlobalContext* globalCtx) { this->actionFunc = EnFsn_DeterminePrice; break; case 0x29CF: - player->unk_A87 = PLAYER_AP_NONE; + player->exchangeItemId = EXCH_ITEM_NONE; this->actionFunc = EnFsn_SetupDeterminePrice; break; } @@ -835,7 +835,7 @@ void EnFsn_StartBuying(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { if (func_80147624(globalCtx)) { @@ -895,7 +895,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_SetupDeterminePrice(EnFsn* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.textId = 0xFF; func_801518B0(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_DeterminePrice; @@ -907,7 +907,7 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { s32 itemActionParam; u8 buttonItem; - if (func_80152498(&globalCtx->msgCtx) == 16) { + if (Message_GetState(&globalCtx->msgCtx) == 16) { itemActionParam = func_80123810(globalCtx); if (itemActionParam > PLAYER_AP_NONE) { if (player->heldItemButton == 0) { @@ -918,8 +918,7 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { this->price = (buttonItem < ITEM_MOON_TEAR) ? gItemPrices[buttonItem] : 0; if (this->price > 0) { player->actor.textId = 0x29EF; - // player->unk_A87 should be set to itemActionParam? - player->unk_A87 = buttonItem; + player->exchangeItemId = buttonItem; this->actionFunc = EnFsn_MakeOffer; } else { player->actor.textId = 0x29CF; @@ -941,7 +940,7 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); if (talkState == 4 && func_80147624(globalCtx)) { @@ -975,7 +974,7 @@ void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { break; case 1: func_8019F230(); - player->unk_A87 = PLAYER_AP_NONE; + player->exchangeItemId = EXCH_ITEM_NONE; this->actionFunc = EnFsn_SetupDeterminePrice; break; } @@ -994,9 +993,9 @@ void EnFsn_GiveItem(EnFsn* this, GlobalContext* globalCtx) { } this->actionFunc = EnFsn_SetupResumeInteraction; } else if (this->isSelling == true) { - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); } else { - func_800B8A1C(&this->actor, globalCtx, this->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->getItemId, 300.0f, 300.0f); } } @@ -1011,7 +1010,7 @@ void EnFsn_SetupResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_ResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (ENFSN_IS_SHOP(&this->actor)) { if (!this->isSelling) { this->cutscene = this->lookToShopkeeperBuyingCutscene; @@ -1031,7 +1030,7 @@ void EnFsn_ResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { this->actionFunc = EnFsn_ConverseBackroom; } } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); } } @@ -1083,7 +1082,7 @@ void EnFsn_LookToShelf(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_BrowseShelf(EnFsn* this, GlobalContext* globalCtx) { - u8 talkstate = func_80152498(&globalCtx->msgCtx); + u8 talkstate = Message_GetState(&globalCtx->msgCtx); s32 pad; u8 prevCursorIdx = this->cursorIdx; @@ -1147,7 +1146,7 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { func_8019F208(); item = this->items[this->cursorIdx]; item->buyFanfareFunc(globalCtx, item); - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; Interface_ChangeAlpha(50); @@ -1178,7 +1177,7 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_SetupEndInteraction(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { @@ -1195,7 +1194,7 @@ void EnFsn_SetupEndInteraction(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (EnFsn_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); @@ -1214,14 +1213,14 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } } void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (this->cutsceneState == 0) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -1267,7 +1266,7 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (this->cutsceneState == 0) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -1314,7 +1313,7 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) } void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); u8 cursorIdx; if (talkState == 4) { @@ -1339,13 +1338,13 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_SetupEndInteractionImmediately(EnFsn* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { EnFsn_EndInteraction(this, globalCtx); } } void EnFsn_IdleBackroom(EnFsn* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->textId = 0; EnFsn_HandleConversationBackroom(this, globalCtx); this->actionFunc = EnFsn_ConverseBackroom; @@ -1355,7 +1354,7 @@ void EnFsn_IdleBackroom(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_ConverseBackroom(EnFsn* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { if (this->flags & ENFSN_END_CONVERSATION) { this->flags &= ~ENFSN_END_CONVERSATION; globalCtx->msgCtx.unk11F22 = 0x43; @@ -1398,7 +1397,7 @@ void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { EnFsn* this = THIS; s32 pad; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013320, &D_06012C34, this->jointTable, this->morphTable, 19); if (ENFSN_IS_SHOP(&this->actor)) { this->actor.shape.rot.y = BINANG_ROT180(this->actor.shape.rot.y); @@ -1432,7 +1431,7 @@ void EnFsn_Update(Actor* thisx, GlobalContext* globalCtx) { EnFsn* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk27A, this->actor.focus.pos); func_8013D9C8(globalCtx, this->limbRotYTable, this->limbRotZTable, 19); EnFsn_Blink(this); diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 7dcf097d79..c7eebb281b 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -188,7 +188,7 @@ void func_809619D0(EnFu* this, GlobalContext* globalCtx) { void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnFu* this = THIS; - Actor* fuKaiten = globalCtx->actorCtx.actorList[ACTORCAT_BG].first; + Actor* fuKaiten = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; while (fuKaiten != NULL) { if (fuKaiten->id == ACTOR_BG_FU_KAITEN) { @@ -199,7 +199,7 @@ void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { } if (fuKaiten != NULL) { - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 36.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B2B0, &D_06001F74, this->jointTable, this->morphTable, 21); Collider_InitCylinder(globalCtx, &this->collider); @@ -257,7 +257,7 @@ s32 func_80961D10(EnFu* this) { } void func_80961D7C(GlobalContext* globalCtx) { - Actor* explosive = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; + Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (explosive != NULL) { if ((explosive->id == ACTOR_EN_BOM) && (explosive->bgCheckFlags & 1)) { @@ -277,7 +277,7 @@ void func_80961D7C(GlobalContext* globalCtx) { } void func_80961E88(GlobalContext* globalCtx) { - Actor* explosive = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; + Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (explosive != NULL) { Actor_MarkForDeath(explosive); @@ -286,7 +286,7 @@ void func_80961E88(GlobalContext* globalCtx) { } void func_80961EC8(GlobalContext* globalCtx) { - Actor* fuMato = globalCtx->actorCtx.actorList[ACTORCAT_BG].first; + Actor* fuMato = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; while (fuMato != NULL) { if (fuMato->id == ACTOR_EN_FU_MATO) { @@ -297,7 +297,7 @@ void func_80961EC8(GlobalContext* globalCtx) { } void func_80961F00(GlobalContext* globalCtx) { - Actor* fuKago = globalCtx->actorCtx.actorList[ACTORCAT_BG].first; + Actor* fuKago = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; while (fuKago != NULL) { if (fuKago->id == ACTOR_EN_FU_KAGO) { @@ -377,7 +377,7 @@ void func_8096209C(EnFu* this, GlobalContext* globalCtx) { } void func_809622FC(EnFu* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80962340; } @@ -388,7 +388,7 @@ void func_80962340(EnFu* this, GlobalContext* globalCtx) { this->actor.flags |= 0x10000; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->unk_54A == 2) { if (this->unk_552 == 0x287D) { if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { @@ -542,7 +542,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { func_801477B4(globalCtx); player->stateFlags1 |= 0x20; this->unk_53C = 0; - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); func_801A2BB8(NA_BGM_MINI_GAME_2); if (this->unk_542 == 0) { if (this->unk_546 == 1) { @@ -583,7 +583,7 @@ void func_809628BC(EnFu* this) { } void func_809628D0(EnFu* this, GlobalContext* globalCtx) { - u8 sp27 = func_80152498(&globalCtx->msgCtx); + u8 sp27 = Message_GetState(&globalCtx->msgCtx); switch (sp27) { case 0: @@ -846,8 +846,8 @@ void func_80963350(EnFu* this, GlobalContext* globalCtx) { static s32 D_80964C24 = 0; BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; - if ((this->unk_54A == 0) && (((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) || - ((func_80152498(&globalCtx->msgCtx) == 2) && (globalCtx->msgCtx.unk12023 == 1)))) { + if ((this->unk_54A == 0) && (((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) || + ((Message_GetState(&globalCtx->msgCtx) == 2) && (globalCtx->msgCtx.unk12023 == 1)))) { func_801477B4(globalCtx); this->unk_54A = 2; D_80964C24 = 1; @@ -884,9 +884,9 @@ void func_80963560(EnFu* this, GlobalContext* globalCtx) { this->actor.parent = NULL; func_80963610(this); } else if ((this->unk_552 == 0x2880) && !(gSaveContext.weekEventReg[22] & 0x80)) { - func_800B8A1C(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); } this->actor.child->freezeTimer = 10; } @@ -899,7 +899,7 @@ void func_80963610(EnFu* this) { void func_80963630(EnFu* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20) && (CURRENT_DAY == 3) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { if (gSaveContext.weekEventReg[22] & 0x40) { @@ -940,7 +940,7 @@ void func_80963630(EnFu* this, GlobalContext* globalCtx) { player->stateFlags1 &= ~0x20; } else { this->actor.child->freezeTimer = 10; - func_800B85E0(&this->actor, globalCtx, 500.0f, -1); + func_800B85E0(&this->actor, globalCtx, 500.0f, EXCH_ITEM_MINUS1); } } @@ -962,7 +962,7 @@ s32 func_80963810(GlobalContext* globalCtx, Vec3f pos) { } globalCtx->actorCtx.unk268 = 1; - func_800B6F20(globalCtx, globalCtx->actorCtx.pad26C, phi_f0, sp22); + func_800B6F20(globalCtx, &globalCtx->actorCtx.unk_26C, phi_f0, sp22); if (sp28 < 80.0f) { return true; @@ -1181,7 +1181,7 @@ void func_80963FF8(EnFu* this, GlobalContext* globalCtx) { if (player->stateFlags1 & 0x100000) { globalCtx->actorCtx.unk268 = 1; - globalCtx->actorCtx.unk278 = 0x8000; + globalCtx->actorCtx.unk_26C.press.button = 0x8000; } else { globalCtx->actorCtx.unk268 = 1; } @@ -1219,7 +1219,7 @@ void func_80964190(EnFu* this, GlobalContext* globalCtx) { case 0x2842: case 0x2844: case 0x2848: - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); break; case 0x2840: @@ -1245,21 +1245,21 @@ void func_80964190(EnFu* this, GlobalContext* globalCtx) { case 0x286B: case 0x286D: case 0x2871: - func_800BDC5C(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); break; case 0x2860: - func_800BDC5C(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); break; case 0x285F: - func_800BDC5C(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); break; case 0x287E: case 0x2880: case 0x2883: - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); break; } } @@ -1340,7 +1340,7 @@ void EnFu_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); func_809642E0(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_8096209C(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); SkelAnime_Update(&this->skelAnime); diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c index e48b3d1696..1efcd42e7e 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -5,6 +5,9 @@ */ #include "z_en_fz.h" +#include "overlays/actors/ovl_En_Wiz/z_en_wiz.h" +#include "objects/object_fz/object_fz.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000015 @@ -15,7 +18,37 @@ void EnFz_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFz_Update(Actor* thisx, GlobalContext* globalCtx); void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80932784(EnFz* this, GlobalContext* globalCtx); +void func_80932AE8(EnFz* this); +void func_80932AF4(EnFz* this); +void func_80932BD4(EnFz* this); +void func_809330D4(EnFz* this); +void func_80933104(EnFz* this, GlobalContext* globalCtx); +void func_80933184(EnFz* this); +void func_809331F8(EnFz* this, GlobalContext* globalCtx); +void func_80933248(EnFz* this); +void func_80933274(EnFz* this, GlobalContext* globalCtx); +void func_80933324(EnFz* this); +void func_80933368(EnFz* this, GlobalContext* globalCtx); +void func_809333A4(EnFz* this); +void func_809333D8(EnFz* this, GlobalContext* globalCtx); +void func_80933414(EnFz* this); +void func_80933444(EnFz* this, GlobalContext* globalCtx); +void func_80933480(EnFz* this, GlobalContext* globalCtx); +void func_809334B8(EnFz* this, GlobalContext* globalCtx); +void func_809336C0(EnFz* this, GlobalContext* globalCtx); +void func_80933760(EnFz* this, GlobalContext* globalCtx); +void func_80933790(EnFz* this); +void func_809337D4(EnFz* this, GlobalContext* globalCtx); +void func_8093389C(EnFz* this); +void func_809338E0(EnFz* this, GlobalContext* globalCtx); +void func_80933AF4(EnFz* this); +void func_80933B38(EnFz* this, GlobalContext* globalCtx); +void func_80934018(EnFz* this, Vec3f* a, Vec3f* b, Vec3f* c, f32 arg4); +void func_809340BC(EnFz* this, Vec3f* a, Vec3f* b, Vec3f* c, f32 arg4, f32 arg5, s16 arg6, u8 arg7); +void func_80934178(EnFz* this, GlobalContext* globalCtx); +void func_80934464(EnFz* this, GlobalContext* globalCtx); + const ActorInit En_Fz_InitVars = { ACTOR_EN_FZ, ACTORCAT_ENEMY, @@ -28,29 +61,66 @@ const ActorInit En_Fz_InitVars = { (ActorFunc)EnFz_Draw, }; -// static ColliderCylinderInitType1 sCylinderInit = { -static ColliderCylinderInitType1 D_809346F8 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFEFDD, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static s16 D_809346F0[] = { 0, 0x2000, 0x4000, 0 }; + +static ColliderCylinderInitType1 sCylinderInit1 = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFEFDD, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 30, 80, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInitType1 sCylinderInit = { -static ColliderCylinderInitType1 D_80934724 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00001022, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInitType1 sCylinderInit2 = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00001022, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 35, 80, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInitType1 sCylinderInit = { -static ColliderCylinderInitType1 D_80934750 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x02, 0x04 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, +static ColliderCylinderInitType1 sCylinderInit3 = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x02, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 20, 30, -15, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_8093477C = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0xD), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -85,96 +155,871 @@ static DamageTable D_8093477C = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8093479C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 59, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1400, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), }; -#endif +void EnFz_Init(Actor* thisx, GlobalContext* globalCtx) { + EnFz* this = THIS; -extern ColliderCylinderInit D_809346F8; -extern ColliderCylinderInit D_80934724; -extern ColliderCylinderInit D_80934750; -extern DamageTable D_8093477C; -extern InitChainEntry D_8093479C[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.colChkInfo.health = 3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/EnFz_Init.s") + Collider_InitCylinder(globalCtx, &this->collider1); + Collider_SetCylinderType1(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitCylinder(globalCtx, &this->collider2); + Collider_SetCylinderType1(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); + Collider_InitCylinder(globalCtx, &this->collider3); + Collider_SetCylinderType1(globalCtx, &this->collider3, &this->actor, &sCylinderInit3); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/EnFz_Destroy.s") + Actor_SetScale(&this->actor, 0.008f); + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.flags &= ~1; + this->unk_BC8 = 0; + this->unk_BCF = 0; + this->unk_BCC = 1; + this->unk_BCD = 0; + this->unk_BCE = 0; + this->unk_BD7 = 1; + this->unk_BD8 = 0; + this->actor.speedXZ = 0.0f; + this->actor.uncullZoneScale = 400.0f; + this->unk_BAC = this->actor.world.pos.y; + this->unk_BB4 = this->actor.world.pos.y; + this->unk_BA8 = this->actor.world.pos.x; + this->unk_BB0 = this->actor.world.pos.z; + this->actor.velocity.y = this->actor.gravity; + this->unk_BB8 = 135.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80932784.s") + if (ENFZ_GET_8000(&this->actor)) { + this->unk_BC0 = 0; + this->actor.scale.y = 0.0f; + func_80933184(this); + } else { + this->unk_BC0 = 255; + if (this->actor.shape.rot.z == 0) { + this->unk_BC6 = (s32)Rand_ZeroFloat(64.0f) + 192; + } else { + if (this->actor.shape.rot.z < 0) { + this->actor.shape.rot.z = 1; + } else if (this->actor.shape.rot.z > 0x10) { + this->actor.shape.rot.z = 0x10; + } + this->actor.shape.rot.z += -1; + this->unk_BC6 = this->actor.shape.rot.z * 0x10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_809328A4.s") + this->actor.shape.rot.z = 0; + if (ENFZ_GET_4000(&this->actor)) { + this->unk_BC0 = 0; + this->actor.scale.y = 0.0f; + func_80933184(this); + } else if (ENFZ_GET_F(&this->actor) == ENFZ_F_3) { + func_80933AF4(this); + } else { + func_8093389C(this); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_809328F4.s") + this->unk_BA4 = 0; + this->unk_BA0 = 0.0f; + this->unk_B9C = 0.0f; + func_80932784(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80932AE8.s") +void EnFz_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFz* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80932AF4.s") + Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); + Collider_DestroyCylinder(globalCtx, &this->collider3); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80932BD4.s") + if ((this->actor.parent != NULL) && (this->unk_BC4 == 0) && (this->actor.parent->id == ACTOR_EN_WIZ) && + (this->actor.parent->update != NULL) && (((EnWiz*)this->actor.parent)->unk_448 != 0)) { + EnWiz* wiz = (EnWiz*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80932C98.s") + wiz->unk_448 = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933014.s") +void func_80932784(EnFz* this, GlobalContext* globalCtx) { + Vec3f sp5C; + Vec3f sp50; + Vec3f sp44; + s32 sp40; + CollisionPoly* sp3C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_809330D4.s") + sp5C.x = this->actor.world.pos.x; + sp5C.y = this->actor.world.pos.y + 20.0f; + sp5C.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933104.s") + Matrix_InsertTranslation(sp5C.x, sp5C.y, sp5C.z, MTXMODE_NEW); + Matrix_InsertRotation(this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933184.s") + sp44.x = sp44.y = 0.0f; + sp44.z = 440.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_809331F8.s") + Matrix_MultiplyVector3fByState(&sp44, &this->unk_22C); + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp5C, &this->unk_22C, &sp50, &sp3C, 1, 0, 0, 1, &sp40)) { + Math_Vec3f_Copy(&this->unk_22C, &sp50); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933248.s") + sp5C.x = this->actor.world.pos.x - this->unk_22C.x; + sp5C.z = this->actor.world.pos.z - this->unk_22C.z; + this->unk_238 = SQ(sp5C.x) + SQ(sp5C.z); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933274.s") +s32 func_809328A4(EnFz* this, Vec3f* arg1) { + f32 temp_f0 = this->actor.world.pos.x - arg1->x; + f32 temp_f2 = this->actor.world.pos.z - arg1->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933324.s") + if (this->unk_238 <= (SQ(temp_f0) + SQ(temp_f2))) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933368.s") +void func_809328F4(EnFz* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3, f32 arg4) { + s32 i; + Vec3f spA8; + Vec3f sp9C; + Vec3f sp90; + Color_RGBA8 sp8C; + Color_RGBA8 sp88; + f32 temp_f24; + s32 temp_s1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_809333A4.s") + sp90.x = sp90.z = 0.0f; + sp90.y = -1.0f; + sp8C.r = 155; + sp8C.g = 255; + sp8C.b = 255; + sp8C.a = 255; + sp88.r = 200; + sp88.g = 200; + sp88.b = 200; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_809333D8.s") + for (i = 0; i < arg3; i++) { + temp_f24 = randPlusMinusPoint5Scaled(0.3f) + 0.6f; + temp_s1 = (s32)randPlusMinusPoint5Scaled(5.0f) + 12; + spA8.x = randPlusMinusPoint5Scaled(arg4) + arg2->x; + spA8.y = Rand_ZeroFloat(arg4) + arg2->y; + spA8.z = randPlusMinusPoint5Scaled(arg4) + arg2->z; + sp9C.x = randPlusMinusPoint5Scaled(10.0f); + sp9C.y = Rand_ZeroFloat(10.0f) + 2.0f; + sp9C.z = randPlusMinusPoint5Scaled(10.0f); + EffectSsEnIce_Spawn(globalCtx, &spA8, temp_f24, &sp9C, &sp90, &sp8C, &sp88, temp_s1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933414.s") + CollisionCheck_SpawnShieldParticles(globalCtx, arg2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933444.s") +void func_80932AE8(EnFz* this) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933480.s") +void func_80932AF4(EnFz* this) { + Vec3f sp44; + Vec3f sp38; + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_809334B8.s") + if (!(this->unk_BC6 & 0xF)) { + sp44.x = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.x; + sp44.y = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.y + 30.0f; + sp44.z = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.z; + sp2C.x = sp2C.z = 0.0f; + sp2C.y = 0.1f; + sp38.x = sp38.y = sp38.z = 0.0f; + func_80934018(this, &sp44, &sp38, &sp2C, Rand_ZeroFloat(7.5f) + 15.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_809336C0.s") +void func_80932BD4(EnFz* this) { + Vec3f sp44; + Vec3f sp38; + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933760.s") + if (!(this->unk_BC6 & 3)) { + sp44.x = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.x; + sp44.y = this->unk_BB4; + sp44.z = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.z; + sp2C.x = sp2C.z = 0.0f; + sp2C.y = 0.1f; + sp38.x = sp38.y = sp38.z = 0.0f; + func_80934018(this, &sp44, &sp38, &sp2C, Rand_ZeroFloat(7.5f) + 15.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933790.s") +void func_80932C98(EnFz* this, GlobalContext* globalCtx) { + Vec3f sp3C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_809337D4.s") + if (this->unk_BCD != 0) { + if ((this->actor.bgCheckFlags & 8) || + !Actor_TestFloorInDirection(&this->actor, globalCtx, 60.0f, this->actor.world.rot.y)) { + this->actor.bgCheckFlags &= ~0x8; + this->unk_BCD = 0; + this->unk_BBC = 0.0f; + this->actor.speedXZ = 0.0f; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_8093389C.s") + if (this->actor.parent != NULL) { + if ((this->unk_BC4 != 5) && (this->actor.parent->id == ACTOR_EN_WIZ)) { + Actor* parent = this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_809338E0.s") + if ((parent->update == NULL) || (parent->colChkInfo.health <= 0)) { + this->actor.colChkInfo.health = 0; + this->unk_BC4 = 5; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); + sp3C.x = this->actor.world.pos.x; + sp3C.y = this->actor.world.pos.y; + sp3C.z = this->actor.world.pos.z; + func_809328F4(this, globalCtx, &sp3C, 30, 10.0f); + func_809336C0(this, globalCtx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933AF4.s") + if ((this->actor.colChkInfo.health != 0) && (this->unk_BC4 == 1)) { + this->actor.colChkInfo.health = 0; + this->unk_BC4 = 5; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); + sp3C.x = this->actor.world.pos.x; + sp3C.y = this->actor.world.pos.y; + sp3C.z = this->actor.world.pos.z; + func_809328F4(this, globalCtx, &sp3C, 30, 10.0f); + func_809336C0(this, globalCtx); + return; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933B38.s") + if (this->unk_BCE != 0) { + if (ENFZ_GET_8000(&this->actor) && (this->collider1.base.atFlags & AC_HIT)) { + this->unk_BCD = 0; + this->unk_BBC = 0.0f; + this->collider1.base.acFlags &= ~AC_HIT; + this->actor.speedXZ = 0.0f; + this->unk_BCA = 10; + func_809330D4(this); + } else if (this->collider2.base.acFlags & AC_BOUNCED) { + this->collider2.base.acFlags &= ~AC_BOUNCED; + this->collider1.base.acFlags &= ~AC_HIT; + } else if (this->collider1.base.acFlags & AC_HIT) { + this->collider1.base.acFlags &= ~AC_HIT; + switch (this->actor.colChkInfo.damageEffect) { + case 4: + this->unk_BA4 = 0x28; + this->unk_B9C = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80933B48.s") + case 15: + Actor_ApplyDamage(&this->actor); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 8); + if (this->actor.colChkInfo.health != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DAMAGE); + sp3C.x = this->actor.world.pos.x; + sp3C.y = this->actor.world.pos.y; + sp3C.z = this->actor.world.pos.z; + func_809328F4(this, globalCtx, &sp3C, 10, 0.0f); + this->unk_BCF++; + break; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); + sp3C.x = this->actor.world.pos.x; + sp3C.y = this->actor.world.pos.y; + sp3C.z = this->actor.world.pos.z; + func_809328F4(this, globalCtx, &sp3C, 30, 10.0f); + func_809336C0(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/EnFz_Update.s") + case 2: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DEAD); + func_80933790(this); + break; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/EnFz_Draw.s") +void func_80933014(EnFz* this) { + s16 temp_a1 = this->actor.yawTowardsPlayer; + s32 temp_a2 = ENFZ_GET_3000(&this->actor); + s16 temp; + s16 temp2; + s32 temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80934018.s") + if (!ENFZ_GET_8000(&this->actor)) { + temp_v1 = this->actor.home.rot.y; + if (temp_a2 != 3) { + temp2 = temp_a1 - temp_v1; + if (D_809346F0[temp_a2] < ABS_ALT(temp2)) { + temp = (temp2 > 0) ? D_809346F0[temp_a2] : -D_809346F0[temp_a2]; + temp_a1 = this->actor.home.rot.y + temp; + } + } + } + Math_SmoothStepToS(&this->actor.shape.rot.y, temp_a1, 10, 2000, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_809340BC.s") +void func_809330D4(EnFz* this) { + this->unk_BD6 = 2; + this->unk_BCE = 0; + this->actor.flags &= ~1; + this->actionFunc = func_80933104; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80934178.s") +void func_80933104(EnFz* this, GlobalContext* globalCtx) { + this->unk_BC0 -= 16; + if (this->unk_BC0 > 255) { + this->unk_BC0 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fz/func_80934464.s") + if (Math_SmoothStepToF(&this->actor.scale.y, 0, 1.0f, 0.0005f, 0.0f) == 0.0f) { + func_80933184(this); + } +} + +void func_80933184(EnFz* this) { + this->unk_BD6 = 0; + this->unk_BD2 = 0; + this->unk_BD0 = 0; + this->unk_BCA = 100; + + this->actor.world.pos.x = this->unk_BA8; + this->actor.world.pos.y = this->unk_BAC; + this->actor.world.pos.z = this->unk_BB0; + + if (ENFZ_GET_4000(&this->actor)) { + this->unk_BD6 = 2; + this->unk_BCA = 10; + this->unk_BD2 = 4000; + this->actionFunc = func_80933274; + } else { + this->actionFunc = func_809331F8; + } +} + +void func_809331F8(EnFz* this, GlobalContext* globalCtx) { + if ((this->unk_BCA == 0) && (this->actor.xzDistToPlayer < 400.0f)) { + func_80933248(this); + } +} + +void func_80933248(EnFz* this) { + this->unk_BD6 = 2; + this->unk_BCA = 20; + this->unk_BD2 = 4000; + this->actionFunc = func_80933274; +} + +void func_80933274(EnFz* this, GlobalContext* globalCtx) { + if (this->unk_BCA == 0) { + + this->unk_BC0 += 8; + if (this->unk_BC0 > 255) { + this->unk_BC0 = 255; + } + + if (Math_SmoothStepToF(&this->actor.scale.y, 0.008f, 1.0f, 0.0005f, 0.0f) == 0.0f) { + if (ENFZ_GET_4000(&this->actor)) { + func_8093389C(this); + } else { + func_80933324(this); + } + } + } +} + +void func_80933324(EnFz* this) { + this->unk_BD6 = 1; + this->unk_BCA = 40; + this->unk_BCC = 1; + this->unk_BCE = 1; + this->actor.flags |= 1; + this->actor.gravity = -1.0f; + this->actionFunc = func_80933368; +} + +void func_80933368(EnFz* this, GlobalContext* globalCtx) { + func_80933014(this); + if (this->unk_BCA == 0) { + func_809333A4(this); + } +} + +void func_809333A4(EnFz* this) { + this->unk_BD6 = 1; + this->unk_BCD = 1; + this->unk_BCA = 100; + this->unk_BBC = 4.0f; + this->actionFunc = func_809333D8; +} + +void func_809333D8(EnFz* this, GlobalContext* globalCtx) { + if ((this->unk_BCA == 0) || (this->unk_BCD == 0)) { + func_80933414(this); + } +} + +void func_80933414(EnFz* this) { + this->unk_BD6 = 1; + this->unk_BBC = 0.0f; + this->actor.speedXZ = 0.0f; + this->unk_BCA = 40; + this->actionFunc = func_80933444; +} + +void func_80933444(EnFz* this, GlobalContext* globalCtx) { + func_80933014(this); + if (this->unk_BCA == 0) { + func_80933480(this, globalCtx); + } +} + +void func_80933480(EnFz* this, GlobalContext* globalCtx) { + this->unk_BD6 = 1; + this->unk_BCA = 80; + this->actionFunc = func_809334B8; + func_80932784(this, globalCtx); +} + +void func_809334B8(EnFz* this, GlobalContext* globalCtx) { + Vec3f sp64; + Vec3f sp58; + Vec3f sp4C; + Vec3f sp40; + u8 sp3F; + s16 sp3C; + + if (this->unk_BCA == 0) { + func_809330D4(this); + return; + } + + if (this->unk_BCA > 10) { + sp3F = 0; + sp3C = 150; + func_800B9010(&this->actor, NA_SE_EN_FREEZAD_BREATH - SFX_FLAG); + if ((this->unk_BCA - 10) < 16) { + sp3C = (this->unk_BCA * 10) - 100; + } + + sp40.x = sp40.z = 0.0f; + sp40.y = 0.6f; + + sp58.x = this->actor.world.pos.x; + sp58.y = this->actor.world.pos.y + 20.0f; + sp58.z = this->actor.world.pos.z; + + Matrix_RotateY(this->actor.shape.rot.y, 0); + + sp64.x = 0.0f; + sp64.y = -2.0f; + sp64.z = ((ENFZ_GET_F(&this->actor) == ENFZ_F_1) ? 10.0f + : (ENFZ_GET_F(&this->actor) == ENFZ_F_2) ? 20.0f + : 0.0f) + + 20; + + Matrix_MultiplyVector3fByState(&sp64, &sp4C); + + if ((this->unk_BCA & 7) == 0) { + sp3F = 1; + } + + func_809340BC(this, &sp58, &sp4C, &sp40, 2.0f, 25.0f, sp3C, sp3F); + + sp58.x += sp4C.x * 0.5f; + sp58.y += sp4C.y * 0.5f; + sp58.z += sp4C.z * 0.5f; + + func_809340BC(this, &sp58, &sp4C, &sp40, 2.0f, 25.0f, sp3C, 0); + } +} + +void func_809336C0(EnFz* this, GlobalContext* globalCtx) { + this->unk_BD6 = 0; + this->unk_BBC = 0.0f; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->unk_BCC = 1; + this->unk_BCE = 0; + this->unk_BD8 = 1; + this->actor.flags &= ~1; + this->unk_BD7 = 0; + this->unk_BCA = 60; + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xA0); + this->actionFunc = func_80933760; +} + +void func_80933760(EnFz* this, GlobalContext* globalCtx) { + if (this->unk_BCA == 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80933790(EnFz* this) { + this->unk_BD6 = 3; + this->unk_BCE = 0; + this->unk_BD8 = 1; + this->actor.flags &= ~1; + this->actor.speedXZ = 0.0f; + this->unk_BBC = 0.0f; + this->actionFunc = func_809337D4; +} + +void func_809337D4(EnFz* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.scale.y, 0.0006f, 0.0006f); + + if (this->actor.scale.y < 0.006f) { + this->actor.scale.x += 0.001f; + this->actor.scale.z += 0.001f; + } + + if (this->actor.scale.y < 0.004f) { + this->unk_BC0 -= 20; + if (this->unk_BC0 > 255) { + this->unk_BC0 = 0; + } + } + + if (this->unk_BC0 == 0) { + func_809336C0(this, globalCtx); + } +} + +void func_8093389C(EnFz* this) { + this->unk_BD6 = 1; + this->unk_BCA = 40; + this->unk_BCC = 1; + this->unk_BCE = 1; + this->actor.flags |= 1; + this->actor.gravity = -1.0f; + this->actionFunc = func_809338E0; +} + +void func_809338E0(EnFz* this, GlobalContext* globalCtx) { + Vec3f sp64; + Vec3f sp58; + Vec3f sp4C; + Vec3f sp40; + u8 sp3F; + s16 sp3C; + + if (this->unk_BC6 & (0x80 | 0x40)) { + func_80933014(this); + func_80932784(this, globalCtx); + return; + } + + sp3F = 0; + sp3C = 150; + func_800B9010(&this->actor, NA_SE_EN_FREEZAD_BREATH - SFX_FLAG); + + if ((this->unk_BC6 & 0x3F) >= 0x30) { + sp3C = 630 - ((this->unk_BC6 & 0x3F) * 10); + } + + sp40.x = sp40.z = 0.0f; + sp40.y = 0.6f; + + sp58.x = this->actor.world.pos.x; + sp58.y = this->actor.world.pos.y + 20.0f; + sp58.z = this->actor.world.pos.z; + + Matrix_RotateY(this->actor.shape.rot.y, 0); + + sp64.x = 0.0f; + sp64.y = -2.0f; + sp64.z = ((ENFZ_GET_F(&this->actor) == ENFZ_F_1) ? 10.0f + : (ENFZ_GET_F(&this->actor) == ENFZ_F_2) ? 20.0f + : 0.0f) + + 20; + + Matrix_MultiplyVector3fByState(&sp64, &sp4C); + + if (!(this->unk_BC6 & 7)) { + sp3F = 1; + } + + func_809340BC(this, &sp58, &sp4C, &sp40, 2.0f, 25.0f, sp3C, sp3F); + sp58.x += sp4C.x * 0.5f; + sp58.y += sp4C.y * 0.5f; + sp58.z += sp4C.z * 0.5f; + func_809340BC(this, &sp58, &sp4C, &sp40, 2.0f, 25.0f, sp3C, 0); +} + +void func_80933AF4(EnFz* this) { + this->unk_BD6 = 1; + this->unk_BCA = 40; + this->unk_BCC = 1; + this->unk_BCE = 1; + this->actor.flags |= 1; + this->actor.gravity = -1.0f; + this->actionFunc = func_80933B38; +} + +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->unk_BA4 < 20) { + Math_SmoothStepToF(&this->unk_BA0, 0.0f, 0.5f, 0.03f, 0.0f); + this->unk_B9C = this->unk_BA4 * 0.05f; + } else { + Math_SmoothStepToF(&this->unk_BA0, 0.5f, 0.1f, 0.02f, 0.0f); + } + } +} + +void EnFz_Update(Actor* thisx, GlobalContext* globalCtx) { + static EnFzUnkFunc D_809347AC[] = { func_80932AE8, func_80932AF4, func_80932BD4, func_80932BD4 }; + s32 pad; + EnFz* this = THIS; + + this->unk_BC6++; + if (this->unk_BC8 != 0) { + this->unk_BC8--; + } + + if (this->unk_BCA != 0) { + this->unk_BCA--; + } + + if (this->unk_BD9 != 0) { + this->unk_BD9--; + } + + Actor_SetFocus(&this->actor, 50.0f); + func_80932C98(this, globalCtx); + + this->actionFunc(this, globalCtx); + + if (this->unk_BD8 == 0) { + Collider_UpdateCylinder(&this->actor, &this->collider1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + if (this->unk_BCE != 0) { + if (this->actor.colorFilterTimer == 0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } + } + + Math_StepToF(&this->actor.speedXZ, this->unk_BBC, 0.2f); + Actor_MoveWithGravity(&this->actor); + if (this->unk_BCC != 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 20.0f, 5); + } + + D_809347AC[this->unk_BD6](this); + func_80933B48(this, globalCtx); + func_80934178(this, globalCtx); +} + +void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* D_809347BC[] = { object_fz_DL_001130, object_fz_DL_0021A0, object_fz_DL_002CA0 }; + s32 pad; + EnFz* this = THIS; + s32 sp9C = 3 - this->actor.colChkInfo.health; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->actor.colChkInfo.health == 0) { + sp9C = 2; + } + + if (this->unk_BD7 != 0) { + func_800B8118(&this->actor, globalCtx, 0); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, globalCtx->state.frames % 128, 0x20, 0x20, 1, 0, + (globalCtx->state.frames * 2) % 128, 0x20, 0x20)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetCombineLERP(POLY_XLU_DISP++, TEXEL1, PRIMITIVE, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIMITIVE, TEXEL0, + PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, COMBINED, 0, ENVIRONMENT, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 155, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, this->unk_BC0); + gSPDisplayList(POLY_XLU_DISP++, D_809347BC[sp9C]); + } + + func_80934464(this, globalCtx); + + if (this->unk_BA4 > 0) { + s32 pad2[6]; + Vec3f sp58; + Vec3f sp4C; + 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); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80934018(EnFz* this, Vec3f* a, Vec3f* b, Vec3f* c, f32 arg4) { + s16 i; + EnFzStruct* ptr = &this->unk_23C[0]; + + for (i = 0; i < ARRAY_COUNT(this->unk_23C); i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 1; + ptr->unk_04 = *a; + ptr->unk_10 = *b; + ptr->unk_1C = *c; + ptr->unk_2E = 0; + ptr->unk_30 = arg4 / 1000.0f; + ptr->unk_2C = 0; + ptr->unk_01 = 0; + break; + } + } +} + +void func_809340BC(EnFz* this, Vec3f* a, Vec3f* b, Vec3f* c, f32 arg4, f32 arg5, s16 arg6, u8 arg7) { + s16 i; + EnFzStruct* ptr = &this->unk_23C[0]; + + for (i = 0; i < ARRAY_COUNT(this->unk_23C); i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 2; + ptr->unk_04 = *a; + ptr->unk_10 = *b; + ptr->unk_1C = *c; + ptr->unk_2E = 0; + ptr->unk_30 = arg4 / 1000.0f; + ptr->unk_34 = arg5 / 1000.0f; + ptr->unk_2C = arg6; + ptr->unk_01 = 0; + ptr->unk_38 = arg7; + break; + } + } +} + +void func_80934178(EnFz* this, GlobalContext* globalCtx) { + s16 i; + EnFzStruct* ptr = this->unk_23C; + Vec3f sp64; + + for (i = 0; i < ARRAY_COUNT(this->unk_23C); i++, ptr++) { + if (ptr->unk_00 != 0) { + ptr->unk_04.x += ptr->unk_10.x; + ptr->unk_04.y += ptr->unk_10.y; + ptr->unk_04.z += ptr->unk_10.z; + + ptr->unk_01++; + + ptr->unk_10.x += ptr->unk_1C.x; + ptr->unk_10.y += ptr->unk_1C.y; + ptr->unk_10.z += ptr->unk_1C.z; + + if (ptr->unk_00 == 1) { + if (ptr->unk_2E == 0) { + ptr->unk_2C += 10; + if (ptr->unk_2C >= 100) { + ptr->unk_2E++; + } + } else { + ptr->unk_2C -= 3; + if (ptr->unk_2C <= 0) { + ptr->unk_2C = 0; + ptr->unk_00 = 0; + } + } + } else if (ptr->unk_00 == 2) { + Math_ApproachF(&ptr->unk_30, ptr->unk_34, 0.1f, ptr->unk_34 / 10.0f); + if (ptr->unk_2E == 0) { + if (ptr->unk_01 >= 7) { + ptr->unk_2E++; + } + } else { + ptr->unk_10.x *= 0.75f; + ptr->unk_1C.y = 2.0f; + ptr->unk_10.z *= 0.75f; + ptr->unk_2C -= 17; + if (ptr->unk_2C <= 0) { + ptr->unk_2C = 0; + ptr->unk_00 = 0; + } + } + + if ((this->unk_BD9 == 0) && (ptr->unk_2C > 100) && (ptr->unk_38 != 0)) { + this->collider3.dim.pos.x = ptr->unk_04.x; + this->collider3.dim.pos.y = ptr->unk_04.y; + this->collider3.dim.pos.z = ptr->unk_04.z; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); + } + + sp64.x = ptr->unk_04.x; + sp64.y = ptr->unk_04.y + 10.0f; + sp64.z = ptr->unk_04.z; + + if ((ptr->unk_2E != 2) && func_809328A4(this, &sp64)) { + ptr->unk_2E = 2; + ptr->unk_10.x = 0.0f; + ptr->unk_10.z = 0.0f; + } + } + } + } +} + +void func_80934464(EnFz* this, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s16 i; + u8 flag = 0; + EnFzStruct* ptr = this->unk_23C; + + OPEN_DISPS(gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetColorDither(POLY_XLU_DISP++, G_CD_BAYER); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_PATTERN); + + for (i = 0; i < ARRAY_COUNT(this->unk_23C); i++, ptr++) { + if (ptr->unk_00 > 0) { + gDPPipeSync(POLY_XLU_DISP++); + + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051180); + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, ptr->unk_2C); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_01 + (i * 3)) * 3, + (ptr->unk_01 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + + Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + 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); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 7eb989cf36..5e76eadf9f 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.h +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.h @@ -5,10 +5,70 @@ struct EnFz; +typedef void (*EnFzActionFunc)(struct EnFz*, GlobalContext*); +typedef void (*EnFzUnkFunc)(struct EnFz*); + +#define ENFZ_GET_F(thisx) ((thisx)->params & 0xF) +#define ENFZ_GET_3000(thisx) (((thisx)->params & 0x3000) >> 0xC) +#define ENFZ_GET_4000(thisx) ((thisx)->params & 0x4000) +#define ENFZ_GET_8000(thisx) ((thisx)->params & 0x8000) + +enum { + /* 0 */ ENFZ_F_0, + /* 1 */ ENFZ_F_1, + /* 2 */ ENFZ_F_2, + /* 3 */ ENFZ_F_3, +}; + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; + /* 0x04 */ Vec3f unk_04; + /* 0x10 */ Vec3f unk_10; + /* 0x1C */ Vec3f unk_1C; + /* 0x28 */ UNK_TYPE1 unk_28[0x4]; + /* 0x2C */ s16 unk_2C; + /* 0x2E */ s16 unk_2E; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ u8 unk_38; +} EnFzStruct; // size = 0x3C + typedef struct EnFz { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xA98]; -} EnFz; // size = 0xBDC + /* 0x144 */ EnFzActionFunc actionFunc; + /* 0x148 */ ColliderCylinder collider1; + /* 0x194 */ ColliderCylinder collider2; + /* 0x1E0 */ ColliderCylinder collider3; + /* 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; + /* 0xBA8 */ f32 unk_BA8; + /* 0xBAC */ f32 unk_BAC; + /* 0xBB0 */ f32 unk_BB0; + /* 0xBB4 */ f32 unk_BB4; + /* 0xBB8 */ f32 unk_BB8; + /* 0xBBC */ f32 unk_BBC; + /* 0xBC0 */ u32 unk_BC0; + /* 0xBC4 */ s16 unk_BC4; + /* 0xBC6 */ s16 unk_BC6; + /* 0xBC8 */ s16 unk_BC8; + /* 0xBCA */ s16 unk_BCA; + /* 0xBCC */ u8 unk_BCC; + /* 0xBCD */ u8 unk_BCD; + /* 0xBCE */ u8 unk_BCE; + /* 0xBCF */ u8 unk_BCF; + /* 0xBD0 */ s16 unk_BD0; + /* 0xBD2 */ s16 unk_BD2; + /* 0xBD4 */ UNK_TYPE1 unkBD4[2]; + /* 0xBD6 */ u8 unk_BD6; + /* 0xBD7 */ u8 unk_BD7; + /* 0xBD8 */ u8 unk_BD8; + /* 0xBD9 */ u8 unk_BD9; +} EnFz; /* size = 0xBDC */ extern const ActorInit En_Fz_InitVars; diff --git a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c index 6d78480e77..90880e2618 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -5,6 +5,7 @@ */ #include "z_en_gb2.h" +#include "objects/object_ps/object_ps.h" #define FLAGS 0x00000039 @@ -15,6 +16,7 @@ void EnGb2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGb2_Update(Actor* thisx, GlobalContext* globalCtx); void EnGb2_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B0FBF0(EnGb2* this, GlobalContext* globalCtx); void func_80B0FEBC(EnGb2* this, GlobalContext* globalCtx); void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx); void func_80B10240(EnGb2* this, GlobalContext* globalCtx); @@ -29,11 +31,11 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx); void func_80B10DAC(EnGb2* this, GlobalContext* globalCtx); void func_80B10E98(EnGb2* this, GlobalContext* globalCtx); void func_80B11048(EnGb2* this, GlobalContext* globalCtx); +void func_80B110F8(EnGb2* this, GlobalContext* globalCtx); void func_80B111AC(EnGb2* this, GlobalContext* globalCtx); void func_80B11268(EnGb2* this, GlobalContext* globalCtx); void func_80B11344(EnGb2* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Gb2_InitVars = { ACTOR_EN_GB2, ACTORCAT_NPC, @@ -46,98 +48,984 @@ const ActorInit En_Gb2_InitVars = { (ActorFunc)EnGb2_Draw, }; -// static ColliderCylinderInitType1 sCylinderInit = { -static ColliderCylinderInitType1 D_80B11A40 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x04 */ Vec3f unk_04; + /* 0x10 */ s16 unk_10; +} EnGbStruct; // size = 0x14 + +static EnGbStruct D_80B119B0[] = { + { ACTOR_EN_PO_SISTERS, { 0.0f, 0.0f, 0.0f }, 0x300 }, + { ACTOR_EN_PO_SISTERS, { 100.0f, 0.0f, 0.0f }, 0x200 }, + { ACTOR_EN_PO_SISTERS, { -100.0f, 0.0f, 0.0f }, 0x100 }, + { ACTOR_EN_PO_SISTERS, { 0.0f, 0.0f, 0.0f }, 0 }, +}; + +static f32 D_80B11A00[][4] = { + { 0.0f, -13.0f, 549.0f, 0.0f }, + { -242.0f, -13.0f, 390.0f, -90.0f }, + { 0.0f, -13.0f, 148.0f, 180.0f }, + { 244.0f, -13.0f, 390.0f, 90.0f }, +}; + +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 40, 75, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B11AC4[] = { +void func_80B0F5E0(EnGb2* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 func_80B0F660(EnGb2* this, GlobalContext* globalCtx) { + Actor* temp_v0; + Actor* phi_s0 = NULL; + + while (true) { + temp_v0 = SubS_FindActor(globalCtx, phi_s0, ACTORCAT_NPC, ACTOR_EN_GB2); + if (temp_v0 == NULL) { + break; + } + + if ((EnGb2*)temp_v0 != this) { + return true; + } + + temp_v0 = temp_v0->next; + if (temp_v0 == NULL) { + break; + } + phi_s0 = temp_v0; + }; + + return false; +} + +void func_80B0F6DC(EnGb2* this) { + if (!(gSaveContext.weekEventReg[54] & 0x20)) { + gSaveContext.weekEventReg[54] |= 0x20; + this->unk_26E = 0x14D0; + } else { + this->unk_26E = 0x14D1; + } + this->unk_288 = 30; + this->actionFunc = func_80B0FEBC; +} + +void func_80B0F728(EnGb2* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[4] & 0x10) { + func_80B0FBF0(this, globalCtx); + this->unk_26E = 0x14E1; + if (gSaveContext.eventInf[4] & 0x80) { + this->unk_288 = 10; + } else { + this->unk_288 = 30; + } + } else if (gSaveContext.eventInf[4] & 0x20) { + func_80B0FBF0(this, globalCtx); + this->unk_26E = 0x14E0; + this->unk_26C |= 2; + } else { + this->unk_26E = 0x14DC; + } + + gSaveContext.eventInf[4] &= (u8)~0x10; + gSaveContext.eventInf[4] &= (u8)~0x20; + gSaveContext.eventInf[4] &= (u8)~0x40; + this->actionFunc = func_80B10584; +} + +u16 func_80B0F7FC(EnGb2* this) { + switch (this->unk_26E) { + case 0x14D0: + return 0x14D1; + + case 0x14D1: + if (gSaveContext.eventInf[4] & 0x80) { + return 0x14E4; + } + + if (gSaveContext.health > 48) { + return 0x14D2; + } + + this->unk_26C |= 2; + return 0x14D3; + + case 0x14E4: + if (gSaveContext.health > 48) { + return 0x14D2; + } + + this->unk_26C |= 2; + return 0x14D3; + + case 0x14D2: + if (gSaveContext.eventInf[4] & 0x80) { + return 0x14E5; + } + return 0x14D4; + + case 0x14D4: + case 0x14E5: + return 0x14D5; + + case 0x14D8: + return 0x14D9; + + case 0x14D9: + return 0x14DA; + } + return 0; +} + +u16 func_80B0F8F8(EnGb2* this) { + switch (this->unk_26E) { + case 0x14DC: + this->unk_26C |= 2; + return 0x14DD; + + case 0x14DD: + return 0x14DE; + + case 0x14DE: + this->unk_26C |= 2; + gSaveContext.weekEventReg[54] |= 0x80; + return 0x14DF; + + case 0x14E1: + return 0x14E2; + } + return 0; +} + +u16 func_80B0F97C(EnGb2* this) { + switch (this->unk_26E) { + case 0x14F5: + return 0x14F6; + + case 0x14F6: + return 0x14F7; + + case 0x14F7: + gSaveContext.weekEventReg[76] |= 0x80; + this->unk_26C |= 2; + return 0x14F8; + + case 0x14F9: + return 0x14FA; + + case 0x14FA: + this->unk_26C |= 2; + return 0x14FB; + } + return 0; +} + +void func_80B0FA04(EnGb2* this) { + this->unk_282[0] = this->actor.cutscene; + this->unk_282[1] = ActorCutscene_GetAdditionalCutscene(this->unk_282[0]); + this->unk_282[2] = ActorCutscene_GetAdditionalCutscene(this->unk_282[1]); +} + +s32 func_80B0FA48(EnGb2* this, GlobalContext* globalCtx) { + switch (Player_GetMask(globalCtx)) { + case PLAYER_MASK_GIBDO: + this->unk_26C |= 4; + this->unk_26E = 0x14E6; + return false; + + case PLAYER_MASK_GARO: + this->unk_26C |= 8; + this->unk_26E = 0x14E6; + return false; + + case PLAYER_MASK_CAPTAIN: + if (!(gSaveContext.weekEventReg[80] & 0x40)) { + this->unk_26E = 0x14EB; + return false; + } + this->unk_26E = 0x14EE; + return true; + } + + if (!(gSaveContext.weekEventReg[80] & 0x20)) { + this->unk_26E = 0x14EF; + return false; + } else { + this->unk_26E = 0x14F4; + return true; + } +} + +u16 func_80B0FB24(EnGb2* this) { + switch (this->unk_26E) { + case 0x14E6: + if (this->unk_26C & 4) { + return 0x14E7; + } + + if (this->unk_26C & 8) { + return 0x14E9; + } + + case 0x14E7: + this->unk_26C |= 2; + return 0x14E8; + + case 0x14E9: + this->unk_26C |= 2; + return 0x14EA; + + case 0x14EB: + return 0x14EC; + + case 0x14EC: + this->unk_26C |= 2; + return 0x14ED; + + case 0x14EF: + return 0x14F0; + + case 0x14F0: + return 0x14F1; + + case 0x14F1: + return 0x14F2; + + case 0x14F2: + this->unk_26C |= 2; + return 0x14F3; + } + return 0; +} + +void func_80B0FBF0(EnGb2* this, GlobalContext* globalCtx) { + Vec3f sp90[4] = { + { 120.0f, 0.0f, 800.0f }, + { -120.0f, 0.0f, 750.0f }, + { 60.0f, 0.0f, 750.0f }, + { -60.0f, 0.0f, 800.0f }, + }; + Vec3s sp78[] = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + }; + s32 sp68[] = { + 0x1000, + 0x1100, + 0x1200, + 0x1300, + }; + s16 i; + s16 end = ARRAY_COUNT(sp90); + + for (i = 0; i < end; i++) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PO_SISTERS, sp90[i].x, sp90[i].y, + sp90[i].z, sp78[i].x, sp78[i].y, sp78[i].z, sp68[i]); + } +} + +void func_80B0FD8C(EnGb2* this, GlobalContext* globalCtx) { + this->unk_280++; + this->unk_268 = this->actor.child; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PO_SISTERS, + D_80B119B0[this->unk_280].unk_04.x, D_80B119B0[this->unk_280].unk_04.y, + D_80B119B0[this->unk_280].unk_04.z, 0, 0, 0, D_80B119B0[this->unk_280].unk_10); +} + +void func_80B0FE18(GlobalContext* globalCtx) { + func_800FD750(0x38); + globalCtx->nextEntranceIndex = 0x9C10; + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 0x40; + globalCtx->sceneLoadFlag = 0x14; +} + +void func_80B0FE7C(GlobalContext* globalCtx) { + globalCtx->nextEntranceIndex = 0x9C20; + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 0x40; + globalCtx->sceneLoadFlag = 0x14; +} + +void func_80B0FEBC(EnGb2* this, GlobalContext* globalCtx) { + if ((globalCtx->msgCtx.unk1202A == 3) && (globalCtx->msgCtx.unk1202E == 7)) { + globalCtx->msgCtx.unk1202A = 4; + gSaveContext.eventInf[4] |= 0x80; + this->unk_26E = 0x14D1; + this->unk_288 = 10; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_801518B0(globalCtx, this->unk_26E, &this->actor); + this->actionFunc = func_80B0FFA8; + } else if ((this->actor.xzDistToPlayer < 300.0f) || this->actor.isTargeted) { + func_800B863C(&this->actor, globalCtx); + } +} + +void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (temp_v0 == 5) { + if (func_80147624(globalCtx)) { + if (this->unk_26C & 2) { + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_26E = 0x14D1; + this->unk_288 = 30; + gSaveContext.eventInf[4] &= (u8)~0x80; + this->unk_26C &= ~2; + this->actionFunc = func_80B0FEBC; + } else { + this->unk_26E = func_80B0F7FC(this); + func_801518B0(globalCtx, this->unk_26E, &this->actor); + } + } + } else if ((temp_v0 == 4) && func_80147624(globalCtx)) { + if (this->unk_26E == 0x14D5) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (gSaveContext.rupees < this->unk_288) { + play_sound(NA_SE_SY_ERROR); + this->unk_26E = 0x14D7; + this->unk_26C |= 2; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + } else { + func_8019F208(); + this->unk_26E = 0x14D8; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + } + break; + + case 1: + func_8019F230(); + this->unk_26E = 0x14D6; + this->unk_26C |= 2; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + break; + } + } else if (this->unk_26E == 0x14DA) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + func_801159EC(-this->unk_288); + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + func_800B7298(globalCtx, NULL, 7); + this->actionFunc = func_80B11344; + break; + + case 1: + func_8019F230(); + this->unk_26E = 0x14DB; + this->unk_26C |= 2; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + break; + } + } + } +} + +void func_80B10240(EnGb2* this, GlobalContext* globalCtx) { + this->unk_27C = D_80B119B0[this->unk_280].unk_00; + this->unk_27E = D_80B119B0[this->unk_280].unk_10; + this->unk_282[0] = this->actor.cutscene; + this->unk_268 = NULL; + if (ActorCutscene_GetCanPlayNext(this->unk_282[0])) { + ActorCutscene_Start(this->unk_282[0], &this->actor); + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, this->unk_27C, + D_80B119B0[this->unk_280].unk_04.x, D_80B119B0[this->unk_280].unk_04.y, + D_80B119B0[this->unk_280].unk_04.z, 0, 0, 0, this->unk_27E); + if (this->unk_280 == 0) { + func_8010E9F0(1, 180); + } + this->actionFunc = func_80B10344; + } else { + ActorCutscene_SetIntentToPlay(this->unk_282[0]); + } +} + +void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { + if (this->unk_280 == 1) { + func_80B0FD8C(this, globalCtx); + } + + if (this->unk_280 == 2) { + if ((this->unk_268 != NULL) && (this->unk_268->update == NULL)) { + this->unk_268 = NULL; + this->unk_26C |= 0x400; + } + } + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL)) { + this->actor.child = NULL; + this->unk_26C |= 0x200; + } + + if (this->unk_26C & 0x200) { + if (this->unk_280 == 3) { + this->unk_26C &= ~0x200; + gSaveContext.unk_3DD0[1] = 5; + func_800FE498(); + gSaveContext.eventInf[4] |= 0x40; + func_80B0FE7C(globalCtx); + } else if (this->unk_280 == 2) { + if (this->unk_26C & 0x400) { + this->unk_280++; + this->unk_26C &= ~0x200; + this->unk_26C &= ~0x400; + this->actionFunc = func_80B10240; + } + } else { + this->unk_280++; + this->unk_26C &= ~0x200; + this->actionFunc = func_80B10240; + } + } + + if (gSaveContext.health < 49) { + gSaveContext.unk_3DD0[1] = 5; + gSaveContext.eventInf[4] |= 0x40; + gSaveContext.eventInf[4] |= 0x20; + + if ((this->unk_268 != NULL) && (this->unk_268->update == NULL)) { + this->unk_268 = NULL; + } + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL)) { + this->actor.child = NULL; + } + + func_80B0FE7C(globalCtx); + } else if (gSaveContext.unk_3DE0[1] == 0) { + gSaveContext.unk_3DD0[1] = 5; + gSaveContext.eventInf[4] |= 0x40; + gSaveContext.eventInf[4] |= 0x10; + + if ((this->unk_268 != NULL) && (this->unk_268->update == NULL)) { + this->unk_268 = NULL; + } + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL)) { + this->actor.child = NULL; + } + + func_80B0FE7C(globalCtx); + } +} + +void func_80B10584(EnGb2* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_801518B0(globalCtx, this->unk_26E, &this->actor); + this->actor.flags &= ~0x10000; + this->actionFunc = func_80B10634; + } else if (this->actor.xzDistToPlayer < 300.0f) { + this->actor.flags |= 0x10000; + func_800B8614(&this->actor, globalCtx, 300.0f); + } +} + +void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (temp_v0 == 5) { + if (func_80147624(globalCtx)) { + if (this->unk_26C & 2) { + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_26C &= ~2; + if (this->unk_26E == 0x14DD) { + this->unk_26E = 0x14DE; + this->actionFunc = func_80B10924; + } else if (this->unk_26E == 0x14DF) { + this->actionFunc = func_80B10A48; + } else { + this->unk_26E = 0x14D1; + this->unk_288 = 30; + gSaveContext.eventInf[4] &= (u8)~0x80; + this->actionFunc = func_80B0FEBC; + } + } else { + this->unk_26E = func_80B0F8F8(this); + func_801518B0(globalCtx, this->unk_26E, &this->actor); + } + } + } else if ((temp_v0 == 4) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (gSaveContext.rupees < this->unk_288) { + play_sound(NA_SE_SY_ERROR); + this->unk_26E = 0x14D7; + this->unk_26C |= 2; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + } else { + func_8019F208(); + func_801159EC(-this->unk_288); + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + func_800B7298(globalCtx, NULL, 7); + this->actionFunc = func_80B11344; + } + break; + + case 1: + func_8019F230(); + this->unk_26E = 0x14E3; + this->unk_26C |= 2; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + break; + } + } +} + +void func_80B10868(EnGb2* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->unk_282[2]) { + if (ActorCutscene_GetCanPlayNext(this->unk_282[this->unk_290])) { + this->actionFunc = func_80B10A48; + ActorCutscene_StartAndSetFlag(this->unk_282[this->unk_290], &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->unk_282[this->unk_290]); + } + } else { + this->unk_290 = 1; + ActorCutscene_SetIntentToPlay(this->unk_282[this->unk_290]); + } +} + +void func_80B10924(EnGb2* this, GlobalContext* globalCtx) { + s32 sp24; + + if (gSaveContext.weekEventReg[54] & 0x40) { + sp24 = 5; + } else { + sp24 = 12; + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + if (sp24 == 12) { + gSaveContext.weekEventReg[54] |= 0x40; + } else { + func_801159EC(50); + } + this->actionFunc = func_80B109DC; + } else { + Actor_PickUp(&this->actor, globalCtx, sp24, 300.0f, 300.0f); + } +} + +void func_80B109DC(EnGb2* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_801518B0(globalCtx, this->unk_26E, &this->actor); + this->actionFunc = func_80B10634; + } else { + func_800B85E0(&this->actor, globalCtx, 300.0f, -1); + } +} + +void func_80B10A48(EnGb2* this, GlobalContext* globalCtx) { + this->unk_28A -= 5; + if (this->unk_28A < 5) { + this->unk_28A = 0; + + switch (ENGB2_GET_7(&this->actor)) { + case ENGB2_7_0: + Actor_MarkForDeath(&this->actor); + break; + + case ENGB2_7_1: + ActorCutscene_Stop(this->unk_282[this->unk_290]); + Actor_MarkForDeath(&this->actor); + break; + + case ENGB2_7_2: + ActorCutscene_Stop(this->unk_282[this->unk_290]); + if (this->unk_26E == 0x14FB) { + Flags_SetSwitch(globalCtx, ENGB2_GET_7F8(&this->actor)); + Actor_MarkForDeath(&this->actor); + } else { + this->actor.draw = NULL; + this->unk_26C |= 0x100; + this->actor.flags &= ~1; + this->actionFunc = func_80B111AC; + } + break; + } + } +} + +void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { + s32 mask = Player_GetMask(globalCtx); + + if (this->unk_28C != mask) { + this->unk_28C = Player_GetMask(globalCtx); + this->unk_26C &= ~0x80; + this->unk_26C &= ~0x20; + this->unk_26C &= ~0x40; + } + + if (func_80B0FA48(this, globalCtx)) { + this->unk_26C &= ~0x20; + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_26C & 0x40)) { + if ((this->unk_26E == 0x14EE) || (this->unk_26E == 0x14F4)) { + this->unk_26C |= 2; + } + func_801518B0(globalCtx, this->unk_26E, &this->actor); + this->unk_290 = 1; + this->unk_26C &= ~0x40; + this->actionFunc = func_80B10DAC; + } else if ((this->actor.xzDistToPlayer < 300.0f) && this->actor.isTargeted) { + this->unk_26C |= 0x40; + func_800B8614(&this->actor, globalCtx, 300.0f); + } + } else { + this->unk_26C &= ~0x40; + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_26C & 0x20)) { + this->actor.flags &= ~0x10000; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + if (this->unk_26E == 0x14EB) { + gSaveContext.weekEventReg[80] |= 0x40; + } else if (this->unk_26E == 0x14EF) { + gSaveContext.weekEventReg[80] |= 0x20; + } + this->unk_26C &= ~0x20; + this->unk_290 = 0; + this->unk_26C |= 0x80; + this->actionFunc = func_80B10DAC; + } else if (this->actor.xzDistToPlayer < 300.0f) { + if (!(this->unk_26C & 0x80)) { + this->actor.flags |= 0x10000; + this->unk_26C |= 0x20; + func_800B8614(&this->actor, globalCtx, 300.0f); + } + } + } +} + +void func_80B10DAC(EnGb2* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->unk_282[this->unk_290])) { + if (ENGB2_GET_7(&this->actor) == ENGB2_7_1) { + if (this->unk_290 != 2) { + this->actionFunc = func_80B10E98; + } else { + Flags_SetSwitch(globalCtx, ENGB2_GET_7F8(&this->actor)); + this->actionFunc = func_80B10868; + } + } else { + this->actionFunc = func_80B110F8; + } + ActorCutscene_StartAndSetFlag(this->unk_282[this->unk_290], &this->actor); + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->unk_282[this->unk_290]); + } +} + +void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if (this->unk_26C & 2) { + this->unk_26C &= ~2; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + if ((this->unk_26E != 0x14E8) && (this->unk_26E != 0x14EA)) { + ActorCutscene_Stop(this->unk_282[this->unk_290]); + this->actionFunc = func_80B10B5C; + } else if (Flags_GetSwitch(globalCtx, ENGB2_GET_7F8(&this->actor))) { + this->actionFunc = func_80B10A48; + } else { + ActorCutscene_Stop(this->unk_282[this->unk_290]); + this->unk_290 = 2; + ActorCutscene_SetIntentToPlay(this->unk_282[this->unk_290]); + this->actionFunc = func_80B10DAC; + } + } else { + s32 temp; + + this->unk_26E = func_80B0FB24(this); + func_801518B0(globalCtx, this->unk_26E, &this->actor); + temp = this->unk_26E; + if ((temp == 0x14E7) || (temp == 0x14E9) || (temp == 0x14EC) || (temp == 0x14F0)) { + ActorCutscene_Stop(this->unk_282[this->unk_290]); + this->unk_290 = 1; + ActorCutscene_SetIntentToPlay(this->unk_282[this->unk_290]); + this->actionFunc = func_80B10DAC; + } + } + } +} + +void func_80B11048(EnGb2* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~0x10000; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + this->actionFunc = func_80B10DAC; + } else if (this->actor.xzDistToPlayer < 300.0f) { + this->actor.flags |= 0x10000; + func_800B8614(&this->actor, globalCtx, 200.0f); + } +} + +void func_80B110F8(EnGb2* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if (this->unk_26C & 2) { + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_26C &= ~2; + this->actionFunc = func_80B10A48; + } else { + this->unk_26E = func_80B0F97C(this); + func_801518B0(globalCtx, this->unk_26E, &this->actor); + } + } +} + +void func_80B111AC(EnGb2* this, GlobalContext* globalCtx) { + s32 index; + + if (globalCtx->roomCtx.currRoom.num == 1) { + return; + } + + switch (globalCtx->roomCtx.currRoom.num) { + case 2: + index = 1; + break; + + case 3: + case 4: + index = 2; + break; + + case 5: + index = 3; + break; + + default: + index = 0; + } + + this->actor.world.pos.x = D_80B11A00[index][0]; + this->actor.world.pos.y = D_80B11A00[index][1]; + this->actor.world.pos.z = D_80B11A00[index][2]; + this->actor.world.rot.y = D_80B11A00[index][3] * 182.04445f; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = func_80B11268; +} + +void func_80B11268(EnGb2* this, GlobalContext* globalCtx) { + if (globalCtx->roomCtx.currRoom.num == 1) { + this->unk_290 = 0; + this->unk_282[0] = this->actor.cutscene; + if (Flags_GetClear(globalCtx, 2) && Flags_GetClear(globalCtx, 3) && Flags_GetClear(globalCtx, 4) && + Flags_GetClear(globalCtx, 5)) { + this->unk_28A = 0xFF; + this->unk_26C &= ~0x100; + this->actor.flags |= 1; + this->actor.draw = EnGb2_Draw; + this->unk_26E = 0x14F9; + this->actionFunc = func_80B11048; + } else { + this->actionFunc = func_80B111AC; + } + } +} + +void func_80B11344(EnGb2* this, GlobalContext* globalCtx) { + if (gSaveContext.rupeeAccumulator == 0) { + func_80B0FE18(globalCtx); + } +} + +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 4, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2200, ICHAIN_STOP), }; -#endif +void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGb2* this = THIS; -extern ColliderCylinderInit D_80B11A40; -extern InitChainEntry D_80B11AC4[]; + if (func_80B0F660(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } -extern UNK_TYPE D_0600049C; + this->actor.room = -1; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ps_Skel_007230, &object_ps_Anim_00049C, this->jointTable, + this->morphTable, 12); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0F5E0.s") + switch (ENGB2_GET_7(&this->actor)) { + case ENGB2_7_0: + if (gSaveContext.weekEventReg[54] & 0x80) { + Actor_MarkForDeath(&this->actor); + } else if (gSaveContext.weekEventReg[52] & 0x20) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0F660.s") + if (gSaveContext.entranceIndex == 0x9C10) { + func_800FE484(); + this->actionFunc = func_80B10240; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0F6DC.s") + this->unk_28A = 255; + this->actor.flags |= 0x10; + this->actor.flags |= 0x2000000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0F728.s") + if (gSaveContext.eventInf[4] & 0x40) { + func_80B0F728(this, globalCtx); + } else { + func_80B0FBF0(this, globalCtx); + func_80B0F6DC(this); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0F7FC.s") + case ENGB2_7_1: + if ((globalCtx->curSpawn == 1) || (gSaveContext.weekEventReg[80] & 0x80)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0F8F8.s") + if (Flags_GetSwitch(globalCtx, ENGB2_GET_7F8(thisx))) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0F97C.s") + this->unk_28A = 255; + func_80B0FA04(this); + this->unk_28C = Player_GetMask(globalCtx); + this->actionFunc = func_80B10B5C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FA04.s") + case ENGB2_7_2: + this->unk_290 = 0; + this->unk_282[0] = this->actor.cutscene; + if (Flags_GetSwitch(globalCtx, ENGB2_GET_7F8(thisx))) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FA48.s") + if (Flags_GetClear(globalCtx, 2) && Flags_GetClear(globalCtx, 3) && Flags_GetClear(globalCtx, 4) && + Flags_GetClear(globalCtx, 5)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FB24.s") + if (gSaveContext.weekEventReg[76] & 0x80) { + this->actor.draw = NULL; + this->unk_26C |= 0x100; + this->actor.flags &= ~1; + this->actionFunc = func_80B111AC; + } else { + this->unk_28A = 255; + this->unk_26E = 0x14F5; + this->actionFunc = func_80B11048; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FBF0.s") + default: + Actor_MarkForDeath(&this->actor); + return; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FD8C.s") +void EnGb2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGb2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FE18.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FE7C.s") +void EnGb2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGb2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FEBC.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FFA8.s") + this->actionFunc(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10240.s") + if (!(this->unk_26C & 0x100)) { + func_80B0F5E0(this, globalCtx); + } + func_800E9250(globalCtx, &this->actor, &this->unk_270, &this->unk_276, this->actor.focus.pos); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10344.s") +s32 EnGb2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnGb2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10584.s") + if (limbIndex == 7) { + limbIndex = limbIndex; + Matrix_RotateY(this->unk_270.y, MTXMODE_APPLY); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10634.s") + if (limbIndex == 1) { + *dList = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10868.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10924.s") +void EnGb2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnGb2* this = THIS; + Vec3f sp18 = { 2400.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B109DC.s") + if (limbIndex == 7) { + Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10A48.s") +void EnGb2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnGb2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10B5C.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10DAC.s") + if (this->unk_28A == 255) { + func_8012C28C(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10E98.s") + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B11048.s") + Scene_SetRenderModeXlu(globalCtx, 0, 1); + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnGb2_OverrideLimbDraw, EnGb2_PostLimbDraw, + &this->actor, POLY_OPA_DISP); + } else { + func_8012C2DC(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B110F8.s") + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, this->unk_28A); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B111AC.s") + Scene_SetRenderModeXlu(globalCtx, 1, 2); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnGb2_OverrideLimbDraw, EnGb2_PostLimbDraw, + &this->actor, POLY_XLU_DISP); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B11268.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B11344.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/EnGb2_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/EnGb2_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/EnGb2_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B1179C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B117FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/EnGb2_Draw.s") + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h index 17274b82f1..c054c4ed24 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h @@ -7,11 +7,35 @@ struct EnGb2; typedef void (*EnGb2ActionFunc)(struct EnGb2*, GlobalContext*); +#define ENGB2_GET_7(thisx) ((thisx)->params & 7) +#define ENGB2_GET_7F8(thisx) (((thisx)->params & 0x7F8) >> 3) + +enum { + /* 0 */ ENGB2_7_0, + /* 1 */ ENGB2_7_1, + /* 2 */ ENGB2_7_2, +}; + typedef struct EnGb2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xD4]; - /* 0x0218 */ EnGb2ActionFunc actionFunc; - /* 0x021C */ char unk_21C[0x78]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[12]; + /* 0x1D0 */ Vec3s morphTable[12]; + /* 0x218 */ EnGb2ActionFunc actionFunc; + /* 0x21C */ ColliderCylinder collider; + /* 0x268 */ Actor* unk_268; + /* 0x26C */ u16 unk_26C; + /* 0x26E */ u16 unk_26E; + /* 0x270 */ Vec3s unk_270; + /* 0x276 */ Vec3s unk_276; + /* 0x27C */ s16 unk_27C; + /* 0x27E */ s16 unk_27E; + /* 0x280 */ s16 unk_280; + /* 0x282 */ s16 unk_282[3]; + /* 0x288 */ s16 unk_288; + /* 0x28A */ u8 unk_28A; + /* 0x28C */ s32 unk_28C; + /* 0x290 */ s16 unk_290; } EnGb2; // size = 0x294 extern const ActorInit En_Gb2_InitVars; diff --git a/src/overlays/actors/ovl_En_Geg/z_en_geg.c b/src/overlays/actors/ovl_En_Geg/z_en_geg.c index 260f3d74e3..4209efe3fe 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -5,6 +5,11 @@ */ #include "z_en_geg.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/object_oF1d_map/object_oF1d_map.h" +#include "objects/object_taisou/object_taisou.h" +#include "objects/object_hakugin_demo/object_hakugin_demo.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000019 @@ -31,7 +36,6 @@ void func_80BB32AC(EnGeg* this, GlobalContext* globalCtx); void func_80BB3318(EnGeg* this, GlobalContext* globalCtx); void func_80BB347C(EnGeg* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Geg_InitVars = { ACTOR_EN_GEG, ACTORCAT_NPC, @@ -44,25 +48,49 @@ const ActorInit En_Geg_InitVars = { (ActorFunc)EnGeg_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80BB3E70 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 0 }, 100 }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BB3E9C = { - { COLTYPE_HIT1, 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_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + 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_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, 0, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BB3EC8 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80BB3ED4 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -97,87 +125,953 @@ static DamageTable D_80BB3ED4 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -#endif +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 }, +}; -extern ColliderSphereInit D_80BB3E70; -extern ColliderCylinderInit D_80BB3E9C; -extern CollisionCheckInfoInit2 D_80BB3EC8; -extern DamageTable D_80BB3ED4; +u16 func_80BB16D0(EnGeg* this) { + switch (this->unk_496) { + case 0xD5E: + return 0xD5F; + case 0xD5F: + return 0xD60; + case 0xD60: + return 0xD61; + case 0xD62: + return 0xD63; + case 0xD64: + return 0xD65; + case 0xD66: + return 0xD67; + case 0xD67: + return 0xD68; + case 0xD68: + return 0xD69; + case 0xD6A: + return 0xD6B; + case 0xD6B: + return 0xD6C; + case 0xD6C: + return 0xD6D; + case 0xD6E: + return 0xD6F; + case 0xD70: + return 0xD71; + case 0xD71: + return 0xD72; + case 0xD73: + return 0xD74; + case 0xD74: + return 0xD75; + case 0xD89: + return 0xD8A; + } + return 0; +} -extern UNK_TYPE D_06004DB0; -extern UNK_TYPE D_060091A8; -extern UNK_TYPE D_06012DE0; +void func_80BB178C(EnGeg* this, GlobalContext* globalCtx) { + Vec3f sp34 = this->actor.world.pos; + Collider* collider; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB16D0.s") + if (this->unk_230 & 1) { + this->colliderSphere.dim.worldSphere.center.x = sp34.x; + this->colliderSphere.dim.worldSphere.center.y = sp34.y; + this->colliderSphere.dim.worldSphere.center.y += (s16)this->actor.shape.yOffset; + this->colliderSphere.dim.worldSphere.center.z = sp34.z; + this->colliderSphere.dim.modelSphere.radius = 20; + this->colliderSphere.dim.worldSphere.radius = + this->colliderSphere.dim.modelSphere.radius * this->colliderSphere.dim.scale; + collider = &this->colliderSphere.base; + } else { + f32 radius = 24.0f; + f32 height = 62.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB178C.s") + this->colliderCylinder.dim.pos.x = sp34.x; + this->colliderCylinder.dim.pos.y = sp34.y; + this->colliderCylinder.dim.pos.z = sp34.z; + this->colliderCylinder.dim.radius = radius; + this->colliderCylinder.dim.height = height; + collider = &this->colliderCylinder.base; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB18FC.s") + if (collider != NULL) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, collider); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 5); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB19C0.s") +s32 func_80BB18FC(EnGeg* this, Actor* actor) { + if (actor->bgCheckFlags & 1) { + f32 sp24 = Math_Vec3f_DistXZ(&this->actor.world.pos, &actor->world.pos); + f32 sp20 = Math_Vec3f_DiffY(&this->actor.world.pos, &actor->world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB1B14.s") + if ((sp24 < 150.0f) && (fabsf(sp20) < 5.0f)) { + this->unk_230 |= 0x20; + actor->speedXZ = 0.0f; + actor->velocity.y = 0.0f; + this->actor.child = actor; + actor->parent = &this->actor; + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB1C1C.s") +Vec3f* func_80BB19C0(Vec3f* arg0, EnGeg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; + s16 sp32 = player->actor.world.rot.y + 0x4000; + s16 sp30; + f32 sp2C; + f32 sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB1C8C.s") + sp40.x = (Math_SinS(sp32) * 50.0f) + player->actor.world.pos.x; + sp40.y = player->actor.world.pos.y; + sp40.z = (Math_CosS(sp32) * 50.0f) + player->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB1D04.s") + sp2C = Math_Vec3f_DistXZ(&this->actor.world.pos, &sp40); + sp30 = player->actor.world.rot.y - 0x4000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB1D64.s") + sp34.x = (Math_SinS(sp30) * 50.0f) + player->actor.world.pos.x; + sp34.y = player->actor.world.pos.y; + sp34.z = (Math_CosS(sp30) * 50.0f) + player->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB1FCC.s") + if (Math_Vec3f_DistXZ(&this->actor.world.pos, &sp34) < sp2C) { + // clang-format off + *arg0 = sp40; return arg0; + // clang-format on + } else { + *arg0 = sp34; + } + return arg0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB2020.s") +u8 func_80BB1B14(EnGeg* this, GlobalContext* globalCtx) { + Actor* explosive; + Actor* mm = SubS_FindActor(globalCtx, NULL, ACTORCAT_ITEMACTION, ACTOR_EN_MM); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB2088.s") + if (mm != NULL) { + this->unk_4B0 = Math_Vec3f_Yaw(&this->actor.world.pos, &mm->world.pos); + if (func_80BB18FC(this, mm)) { + return 1; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB217C.s") + explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB221C.s") + while (explosive != NULL) { + if ((explosive->id == ACTOR_EN_BOM) && func_80BB18FC(this, explosive)) { + this->unk_4B0 = Math_Vec3f_Yaw(&this->actor.world.pos, &explosive->world.pos); + if (this->unk_230 & 0x200) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB2520.s") + if (((EnBom*)explosive)->unk_1F9 == 0) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB26EC.s") + return 3; + } + explosive = explosive->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB27D4.s") + this->unk_230 &= ~0x200; + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB2944.s") +void func_80BB1C1C(EnGeg* this) { + u16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB2A54.s") + this->unk_49C[0] = this->actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB2B1C.s") + for (i = 1; i < ARRAY_COUNT(this->unk_49C); i++) { + this->unk_49C[i] = ActorCutscene_GetAdditionalCutscene(this->unk_49C[i - 1]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB2E00.s") +void func_80BB1C8C(EnGeg* this) { + if (DECR(this->unk_240) == 0) { + this->unk_23E++; + if (this->unk_23E >= 3) { + this->unk_240 = Rand_S16Offset(30, 30); + this->unk_23E = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB2F7C.s") +void func_80BB1D04(EnGeg* this) { + f32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB30B4.s") + if (this->unk_230 & 1) { + temp = this->actor.shape.yOffset; + } else { + temp = 58.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB31B8.s") + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.y = temp + this->actor.world.pos.y; + this->actor.focus.pos.z = this->actor.world.pos.z; + 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_Geg/func_80BB32AC.s") +s32 func_80BB1D64(EnGeg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; + s16 yaw = (this->actor.yawTowardsPlayer - this->unk_46E) - this->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB3318.s") + Math_SmoothStepToS(&this->unk_46A, yaw, 4, 0x2AA8, 1); + this->unk_46A = CLAMP(this->unk_46A, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB347C.s") + yaw = (this->actor.yawTowardsPlayer - this->unk_46A) - this->actor.shape.rot.y; + Math_SmoothStepToS(&this->unk_46E, yaw, 4, 0x2AA8, 1); + this->unk_46E = CLAMP(this->unk_46E, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/EnGeg_Init.s") + if (this->unk_230 & 0x20) { + sp40 = player->actor.world.pos; + } else { + sp40 = player->actor.world.pos; + sp40.y = player->bodyPartsPos[7].y + 3.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/EnGeg_Destroy.s") + sp34 = this->actor.world.pos; + sp34.y += 70.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/EnGeg_Update.s") + yaw = Math_Vec3f_Pitch(&sp34, &sp40); + Math_SmoothStepToS(&this->unk_468, yaw - this->unk_46C, 4, 0x2AA8, 1); + this->unk_468 = CLAMP(this->unk_468, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB3728.s") + yaw = Math_Vec3f_Pitch(&sp34, &sp40); + Math_SmoothStepToS(&this->unk_46C, yaw - this->unk_468, 4, 0x2AA8, 1); + this->unk_46C = CLAMP(this->unk_46C, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB3860.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB387C.s") +void func_80BB1FCC(EnGeg* this, GlobalContext* globalCtx) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[this->unk_248].segment); + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB39F8.s") +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); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB3BE0.s") +s32 func_80BB2088(EnGeg* this, GlobalContext* globalCtx) { + if (DECR(this->unk_242) != 0) { + this->unk_468 = 0; + this->unk_46A = 0; + this->unk_230 &= ~2; + this->unk_46C = 0; + this->unk_46E = 0; + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/func_80BB3CB4.s") + if (Actor_IsFacingAndNearPlayer(&this->actor, 300.0f, 0x7FF8) && + ((this->unk_4AC == 5) || ((this->unk_4AC == 13) && (this->unk_496 == 0xD69)))) { + this->unk_230 |= 2; + func_80BB1D64(this, globalCtx); + } else { + if (this->unk_230 & 2) { + this->unk_242 = 20; + } + this->unk_230 &= ~2; + this->unk_468 = 0; + this->unk_46A = 0; + this->unk_46C = 0; + this->unk_46E = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Geg/EnGeg_Draw.s") + return true; +} + +void func_80BB217C(EnGeg* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_248)) { + this->unk_4AC = 5; + func_80BB2020(this, globalCtx); + Actor_SetScale(&this->actor, 0.01f); + this->unk_230 = 0; + this->actor.shape.shadowScale = 20.0f; + this->actor.gravity = -1.0f; + func_80BB1C1C(this); + this->actionFunc = func_80BB221C; + this->actor.targetMode = 3; + } +} + +void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { + u8 sp27 = func_80BB1B14(this, globalCtx); + + if (sp27 != 0) { + this->unk_230 &= ~8; + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 4)) { + if (sp27 == 1) { + this->unk_496 = 0xD66; + this->unk_49A = this->unk_49C[3]; + } else if (sp27 == 2) { + this->unk_496 = 0xD64; + this->unk_49A = this->unk_49C[2]; + this->unk_230 &= ~4; + } else if (sp27 == 3) { + this->unk_230 |= 0x200; + this->unk_496 = 0xD64; + this->unk_49A = this->unk_49C[2]; + this->unk_230 &= ~4; + } + func_801518B0(globalCtx, this->unk_496, &this->actor); + this->actionFunc = func_80BB2520; + this->actor.flags &= ~0x10000; + } else if (this->actor.xzDistToPlayer < 300.0f) { + this->unk_230 |= 4; + this->actor.flags |= 0x10000; + func_800B8614(&this->actor, globalCtx, 300.0f); + } + } else { + this->unk_230 &= ~4; + if (gSaveContext.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); + this->unk_230 &= ~8; + this->actionFunc = func_80BB27D4; + } else if ((this->actor.xzDistToPlayer < 300.0f) && this->actor.isTargeted) { + func_800B8614(&this->actor, globalCtx, 300.0f); + this->unk_230 |= 8; + } + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 8)) { + gSaveContext.weekEventReg[35] |= 0x40; + this->unk_496 = 0xD5E; + this->unk_49A = this->unk_49C[0]; + func_801518B0(globalCtx, this->unk_496, &this->actor); + this->actionFunc = func_80BB2520; + this->unk_230 &= ~8; + this->actor.flags &= ~0x10000; + } else if (this->actor.xzDistToPlayer < 300.0f) { + this->actor.flags |= 0x10000; + func_800B8614(&this->actor, globalCtx, 300.0f); + this->unk_230 |= 8; + } + } +} + +void func_80BB2520(EnGeg* this, GlobalContext* globalCtx) { + if (this->unk_230 & 0x10) { + ActorCutscene_Stop(this->unk_498); + this->unk_230 &= ~0x10; + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + this->unk_498 = this->unk_49A; + ActorCutscene_SetIntentToPlay(this->unk_498); + return; + } + + if (ActorCutscene_GetCanPlayNext(this->unk_498)) { + ActorCutscene_StartAndSetFlag(this->unk_498, &this->actor); + this->unk_230 |= 0x10; + + switch (this->unk_496) { + case 0xD5E: + case 0xD5F: + this->actionFunc = func_80BB26EC; + break; + + case 0xD64: + this->unk_230 &= ~0x20; + this->actionFunc = func_80BB2A54; + break; + + case 0xD66: + this->unk_248 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_OF1D_MAP); + if (this->unk_248 >= 0) { + this->unk_4AC = 19; + func_80BB2020(this, globalCtx); + } + this->unk_230 |= 0x20; + this->actionFunc = func_80BB2944; + break; + + case 0xD67: + this->unk_498 = this->unk_49C[5]; + this->actionFunc = func_80BB2B1C; + break; + + case 0xD69: + case 0xD72: + case 0xD75: + case 0xD8B: + this->unk_248 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_OF1D_MAP); + if (this->unk_248 >= 0) { + this->unk_4AC = 4; + func_80BB2020(this, globalCtx); + } + this->actionFunc = func_80BB2E00; + break; + } + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + this->unk_498 = this->unk_49A; + ActorCutscene_SetIntentToPlay(this->unk_498); + } +} + +void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (this->unk_496) { + case 0xD5E: + this->unk_49A = this->unk_49C[1]; + this->actionFunc = func_80BB2520; + break; + + case 0xD61: + ActorCutscene_Stop(this->unk_498); + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_230 &= ~0x10; + this->actionFunc = func_80BB221C; + return; + } + + this->unk_496 = func_80BB16D0(this); + func_801518B0(globalCtx, this->unk_496, &this->actor); + } +} + +void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (this->unk_496) { + case 0xD63: + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80BB221C; + break; + + case 0xD69: + this->unk_49A = this->unk_49C[6]; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80BB2520; + break; + + case 0xD6D: + case 0xD6F: + case 0xD8A: + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80BB31B8; + break; + + case 0xD72: + case 0xD75: + case 0xD8B: + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_230 &= ~0x10; + this->unk_49A = this->unk_49C[7]; + this->actionFunc = func_80BB2520; + break; + + default: + this->unk_496 = func_80BB16D0(this); + func_801518B0(globalCtx, this->unk_496, &this->actor); + break; + } + } +} + +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); + + if (this->unk_4AC == 19) { + if (curFrame == lastFrame) { + this->unk_4AC = 6; + func_80BB2020(this, globalCtx); + } + } else if ((sp27 == 5) && func_80147624(globalCtx)) { + if (this->unk_496 == 0xD67) { + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_49A = this->unk_49C[4]; + this->actionFunc = func_80BB2520; + } else { + this->unk_496 = func_80BB16D0(this); + func_80151938(globalCtx, this->unk_496); + } + } +} + +void func_80BB2A54(EnGeg* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if (this->unk_496 == 0xD65) { + ActorCutscene_Stop(this->unk_498); + this->unk_230 &= ~0x10; + this->unk_244 = 65; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80BB347C; + } else { + this->unk_496 = func_80BB16D0(this); + func_801518B0(globalCtx, this->unk_496, &this->actor); + } + } +} + +void func_80BB2B1C(EnGeg* this, GlobalContext* globalCtx) { + Vec3f sp74; + f32 temp_f20; + s16 i; + f32 sp68; + + this->actor.child->world.pos = this->unk_4B4; + this->actor.child->shape.rot = this->actor.shape.rot; + + if (ActorCutscene_GetCurrentIndex() != this->unk_49C[4]) { + if (ActorCutscene_GetCanPlayNext(this->unk_498)) { + gSaveContext.weekEventReg[37] |= 8; + if (this->actor.child != NULL) { + Actor_MarkForDeath(this->actor.child); + } + this->unk_230 |= 0x10; + ActorCutscene_StartAndSetFlag(this->unk_498, &this->actor); + this->unk_496 = 0xD68; + func_80151938(globalCtx, this->unk_496); + this->unk_248 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_TAISOU); + if (this->unk_248 >= 0) { + this->unk_4AC = 13; + func_80BB2020(this, globalCtx); + } + this->actionFunc = func_80BB27D4; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->unk_498); + } + } else { + temp_f20 = this->unk_4E0 * 0.005f; + sp68 = this->unk_4E0 * 0.07f; + + sp74.x = Rand_Centered() * temp_f20; + sp74.y = Rand_Centered() * temp_f20; + sp74.z = Rand_Centered() * temp_f20; + + this->actor.child->scale.x *= 0.98f; + this->actor.child->scale.y *= 0.98f; + this->actor.child->scale.z *= 0.98f; + + if (this->unk_4E0 > 70) { + for (i = 0; i < ARRAY_COUNT(this->unk_4C0); i++) { + this->unk_4C0[i].x *= temp_f20; + this->unk_4C0[i].y *= temp_f20; + this->unk_4C0[i].z *= temp_f20; + EffectSsHahen_Spawn(globalCtx, &this->unk_4B4, &this->unk_4C0[i], &sp74, 1, sp68, 1, 15, + gameplay_keep_DL_06AB30); + } + } + this->unk_4E0--; + } + func_8019F570(&this->actor.projectedPos, 1); + func_8019F4AC(&this->actor.projectedPos, NA_SE_EN_GOLON_SIRLOIN_EAT - SFX_FLAG); +} + +void func_80BB2E00(EnGeg* this, GlobalContext* globalCtx) { + s16 sp2E = this->skelAnime.curFrame; + s16 sp2C = Animation_GetLastFrame(sAnimations[this->unk_4AC].animationSeg); + + if (this->unk_4AC == 2) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (sp2E == sp2C) { + ActorCutscene_Stop(this->unk_498); + this->unk_4AC = 20; + func_80BB2020(this, globalCtx); + this->actionFunc = func_80BB30B4; + } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_STAND_IMT); + } + } else if (this->unk_4AC == 4) { + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + this->unk_230 |= 1; + this->actor.shape.yOffset = 14.0f; + if (this->unk_496 == 0xD69) { + func_80BB19C0(&this->unk_4E4, this, globalCtx); + this->actionFunc = func_80BB2F7C; + } else { + this->actionFunc = func_80BB3318; + } + } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SIT_IMT); + } + } +} + +void func_80BB2F7C(EnGeg* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_4E4), 4, 1000, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + + if ((this->actor.xzDistToPlayer < 150.0f) && (fabsf(this->actor.playerHeightRel) < 10.0f) && + (this->actor.bgCheckFlags & 1)) { + this->unk_4AC = 2; + this->actor.speedXZ = 0.0f; + this->unk_230 &= ~1; + this->actor.shape.yOffset = 0.0f; + func_80BB2020(this, globalCtx); + this->actionFunc = func_80BB2E00; + } else { + this->actor.speedXZ = 5.0f; + Actor_MoveWithGravity(&this->actor); + } + + if (this->actor.bgCheckFlags & 1) { + if (this->unk_230 & 0x80) { + func_800B9010(&this->actor, NA_SE_EN_GOLON_SIRLOIN_ROLL - SFX_FLAG); + } else { + this->unk_230 |= 0x80; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + } + } +} + +void func_80BB30B4(EnGeg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (player->transformation == PLAYER_FORM_GORON) { + this->unk_496 = 0xD6A; + } else if (Player_GetMask(globalCtx) == PLAYER_MASK_DON_GERO) { + this->unk_496 = 0xD89; + } else { + this->unk_496 = 0xD6E; + } + func_801518B0(globalCtx, this->unk_496, &this->actor); + this->actionFunc = func_80BB27D4; + this->actor.flags &= ~0x10000; + } else if (this->actor.xzDistToPlayer < 150.0f) { + this->actor.flags |= 0x10000; + func_800B8614(&this->actor, globalCtx, 150.0f); + } +} + +void func_80BB31B8(EnGeg* this, GlobalContext* globalCtx) { + s32 getItemId = GI_MASK_DON_GERO; + + if (INV_CONTENT(ITEM_MASK_DON_GERO) == ITEM_MASK_DON_GERO) { + if (Player_GetMask(globalCtx) == PLAYER_MASK_DON_GERO) { + this->unk_496 = 0xD8B; + getItemId = GI_RUPEE_PURPLE; + } else { + this->unk_496 = 0xD73; + getItemId = GI_RUPEE_PURPLE; + } + } else { + this->unk_496 = 0xD70; + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + gSaveContext.weekEventReg[61] |= 1; + if (getItemId == GI_MASK_DON_GERO) { + this->unk_230 |= 0x40; + } + this->actionFunc = func_80BB32AC; + } else { + Actor_PickUp(&this->actor, globalCtx, getItemId, 300.0f, 300.0f); + } +} + +void func_80BB32AC(EnGeg* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_801518B0(globalCtx, this->unk_496, &this->actor); + this->actionFunc = func_80BB27D4; + } else { + func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + } +} + +void func_80BB3318(EnGeg* this, GlobalContext* globalCtx) { + static Vec3f D_80BB4044[] = { + { -550.0f, 8.0f, 550.0f }, + { 220.0f, 43.0f, 525.0f }, + }; + s16 sp46; + f32 sp40; + + if (this->unk_4D8 < 2) { + sp46 = Math_Vec3f_Yaw(&this->actor.world.pos, &D_80BB4044[this->unk_4D8]); + sp40 = Math_Vec3f_DistXZ(&this->actor.world.pos, &D_80BB4044[this->unk_4D8]); + Math_SmoothStepToS(&this->actor.world.rot.y, sp46, 4, 1000, 1); + if (sp40 < 20.0f) { + this->unk_4D8++; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + func_800AE930(&globalCtx->colCtx, Effect_GetByIndex(this->unk_4DC), &this->actor.world.pos, 18.0f, + this->actor.shape.rot.y, this->actor.floorPoly, this->actor.floorBgId); + } + + if (ActorCutscene_GetCurrentIndex() != this->unk_49C[7]) { + func_800AEF44(Effect_GetByIndex(this->unk_4DC)); + Actor_MarkForDeath(&this->actor); + } else { + Math_ApproachF(&this->actor.speedXZ, 10.0f, 0.2f, 1.0f); + Actor_MoveWithGravity(&this->actor); + } + + func_800B9010(&this->actor, NA_SE_EN_GOLON_SIRLOIN_ROLL - SFX_FLAG); +} + +void func_80BB347C(EnGeg* this, GlobalContext* globalCtx) { + if (DECR(this->unk_244) == 0) { + this->unk_244 = 65; + this->actionFunc = func_80BB221C; + } +} + +void EnGeg_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGeg* this = THIS; + s32 pad2; + s32 sp34[] = { 0x3E, 0xF64 }; + + if (gSaveContext.weekEventReg[61] & 1) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, &object_oF1d_map_Anim_012DE0, + this->jointTable, this->morphTable, 18); + + Collider_InitCylinder(globalCtx, &this->colliderCylinder); + Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_InitSphere(globalCtx, &this->colliderSphere); + Collider_SetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + if (this->actor.update != NULL) { + this->unk_248 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_OF1D_MAP); + if (this->unk_248 < 0) { + Actor_MarkForDeath(&this->actor); + } + } + + Effect_Add(globalCtx, &this->unk_4DC, 4, 0, 0, &sp34); + thisx->draw = NULL; + this->unk_4E0 = 100; + this->actor.draw = EnGeg_Draw; + this->actionFunc = func_80BB217C; +} + +void EnGeg_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGeg* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroySphere(globalCtx, &this->colliderSphere); + Effect_Destroy(globalCtx, this->unk_4DC); +} + +void EnGeg_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGeg* this = THIS; + + this->actionFunc(this, globalCtx); + func_80BB1FCC(this, globalCtx); + func_80BB2088(this, globalCtx); + func_80BB1C8C(this); + func_8013D9C8(globalCtx, &this->unk_238, &this->unk_232, 3); + func_80BB1D04(this); + func_80BB178C(this, globalCtx); +} + +s32 func_80BB3728(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5) { + 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 && !arg5) { + arg3->x = sp68.x; + arg3->y = sp68.y; + arg3->z = sp68.z; + return true; + } + + if (arg5) { + sp68.z = arg0; + sp68.y = arg1; + } + 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); + + return true; +} + +s32 EnGeg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void EnGeg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80BB407C = { -1500.0f, 1500.0f, 0.0f }; + EnGeg* this = THIS; + Vec3f sp38 = { 1.0f, 5.0f, -0.5f }; + Vec3f sp2C = { -1.0f, 5.0f, -0.5f }; + + if (limbIndex == 17) { + if (!(this->unk_230 & 0x40)) { + func_8012C28C(globalCtx->state.gfxCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_004DB0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + sp38.x += Rand_Centered(); + sp38.y += 2.0f * Rand_Centered(); + sp38.z += Rand_Centered(); + + sp2C.x += Rand_Centered(); + sp2C.y += 2.0f * Rand_Centered(); + sp2C.z += Rand_Centered(); + + Matrix_MultiplyVector3fByState(&D_80BB407C, &this->unk_4B4); + Matrix_StatePush(); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp38, &this->unk_4C0[0]); + Matrix_MultiplyVector3fByState(&sp2C, &this->unk_4C0[1]); + Matrix_StatePop(); + } +} + +void EnGeg_UnkDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnGeg* this = THIS; + s32 phi_v0; + s32 phi_v1; + + switch (limbIndex) { + case 17: + if (this->unk_230 & 2) { + phi_v1 = true; + } else { + phi_v1 = false; + } + + if (this->unk_242 != 0) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + func_80BB3728(this->unk_468 + this->unk_46C + 0x4000, + this->unk_46A + this->unk_46E + this->actor.shape.rot.y + 0x4000, &this->unk_470, + &this->unk_47C, phi_v0, phi_v1); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_470.x, this->unk_470.y, this->unk_470.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_47C.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_47C.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_47C.z, MTXMODE_APPLY); + Matrix_StatePush(); + break; + + case 10: + if (this->unk_230 & 2) { + phi_v1 = true; + } else { + phi_v1 = false; + } + + if (this->unk_242 != 0) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + func_80BB3728(this->unk_46C + 0x4000, this->unk_46E + this->actor.shape.rot.y + 0x4000, &this->unk_484, + &this->unk_490, phi_v0, phi_v1); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_484.x, this->unk_484.y, this->unk_484.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_490.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_490.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_490.z, MTXMODE_APPLY); + Matrix_StatePush(); + break; + } +} + +void func_80BB3BE0(EnGeg* this, GlobalContext* globalCtx) { + static TexturePtr D_80BB4088[] = { + &object_oF1d_map_Tex_010438, + &object_oF1d_map_Tex_010C38, + &object_oF1d_map_Tex_011038, + &object_oF1d_map_Tex_010838, + }; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BB4088[this->unk_23E])); + gDPPipeSync(POLY_OPA_DISP++); + + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnGeg_OverrideLimbDraw, EnGeg_PostLimbDraw, EnGeg_UnkDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80BB3CB4(EnGeg* this, GlobalContext* globalCtx) { + f32 sp24 = globalCtx->state.frames * this->actor.speedXZ * 1400.0f; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_InsertXRotation_s(sp24, 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_oF1d_map_DL_0091A8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnGeg_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnGeg* this = THIS; + + if (this->unk_230 & 1) { + func_80BB3CB4(this, globalCtx); + } else { + func_80BB3BE0(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 1bd18cc05d..c846f447b7 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.h +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.h @@ -8,10 +8,44 @@ struct EnGeg; typedef void (*EnGegActionFunc)(struct EnGeg*, GlobalContext*); typedef struct EnGeg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnGegActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x364]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnGegActionFunc actionFunc; + /* 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]; + /* 0x23E */ s16 unk_23E; + /* 0x240 */ s16 unk_240; + /* 0x242 */ s16 unk_242; + /* 0x244 */ s16 unk_244; + /* 0x248 */ s32 unk_248; + /* 0x24C */ Vec3s jointTable[18]; + /* 0x2B8 */ Vec3s morphTable[18]; + /* 0x324 */ UNK_TYPE1 unk324[0x144]; + /* 0x468 */ s16 unk_468; + /* 0x46A */ s16 unk_46A; + /* 0x46C */ s16 unk_46C; + /* 0x46E */ s16 unk_46E; + /* 0x470 */ Vec3f unk_470; + /* 0x47C */ Vec3s unk_47C; + /* 0x484 */ Vec3f unk_484; + /* 0x490 */ Vec3s unk_490; + /* 0x496 */ u16 unk_496; + /* 0x498 */ s16 unk_498; + /* 0x49A */ s16 unk_49A; + /* 0x49C */ s16 unk_49C[8]; + /* 0x4AC */ s32 unk_4AC; + /* 0x4B0 */ s16 unk_4B0; + /* 0x4B4 */ Vec3f unk_4B4; + /* 0x4C0 */ Vec3f unk_4C0[2]; + /* 0x4D8 */ s16 unk_4D8; + /* 0x4DC */ s32 unk_4DC; + /* 0x4E0 */ s16 unk_4E0; + /* 0x4E4 */ Vec3f unk_4E4; } EnGeg; // size = 0x4F0 extern const ActorInit En_Geg_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 ec6d56ef6d..85f1798e3e 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -5,6 +5,7 @@ */ #include "z_en_giant.h" +#include "objects/object_giant/object_giant.h" #define FLAGS 0x00000030 @@ -31,41 +32,21 @@ const ActorInit En_Giant_InitVars = { (ActorFunc)EnGiant_Draw, }; -extern AnimationHeader D_06002168; -extern Gfx D_06005A80[]; -extern Gfx D_06006280[]; -extern Gfx D_06007610[]; -extern Gfx D_06006A80[]; -extern FlexSkeletonHeader D_060079B0; -extern AnimationHeader D_06008394; -extern AnimationHeader D_060096E4; -extern AnimationHeader D_0600A1C4; -extern AnimationHeader D_0600ACA4; -extern AnimationHeader D_0600B784; -extern AnimationHeader D_0600C5D4; -extern AnimationHeader D_0600D040; -extern AnimationHeader D_0600DE84; -extern AnimationHeader D_060102A4; -extern AnimationHeader D_060116E4; -extern AnimationHeader D_06012A38; -extern AnimationHeader D_06013004; -extern AnimationHeader D_06013FE8; -extern AnimationHeader D_06015334; -extern AnimationHeader D_06017944; - -static AnimationHeader* sAnimationTable[] = { - &D_06008394, &D_060096E4, &D_060102A4, &D_060116E4, &D_06012A38, &D_06013004, &D_06013FE8, &D_06015334, - &D_06017944, &D_0600A1C4, &D_0600D040, &D_0600DE84, &D_0600ACA4, &D_0600B784, &D_0600C5D4, +static AnimationHeader* sAnimations[] = { + &gGiantLookUpStartAnim, &gGiantLookUpLoopAnim, &gGiantFallingOverAnim, &gGiantRaisedArmsStartAnim, + &gGiantRaisedArmsLoopAnim, &gGiantStruggleStartAnim, &gGiantStruggleLoopAnim, &gGiantIdleAnim, + &gGiantWalkingAnim, &gGiantBigCallStartAnim, &gGiantBigCallLoopAnim, &gGiantBigCallEndAnim, + &gGiantSmallCallStartAnim, &gGiantSmallCallLoopAnim, &gGiantSmallCallEndAnim, }; void EnGiant_ChangeAnimation(EnGiant* this, s16 newAnimationId) { if (newAnimationId >= GIANT_ANIMATION_LOOK_UP_START && newAnimationId < GIANT_ANIMATION_MAX) { if ((this->animationId == GIANT_ANIMATION_WALKING_LOOP && newAnimationId != GIANT_ANIMATION_WALKING_LOOP) || (newAnimationId == GIANT_ANIMATION_WALKING_LOOP && this->animationId != GIANT_ANIMATION_WALKING_LOOP)) { - Animation_Change(&this->skelAnime, sAnimationTable[newAnimationId], 1.0f, 0.0f, - Animation_GetLastFrame(&sAnimationTable[newAnimationId]->common), 2, 10.0f); + Animation_Change(&this->skelAnime, sAnimations[newAnimationId], 1.0f, 0.0f, + Animation_GetLastFrame(&sAnimations[newAnimationId]->common), 2, 10.0f); } else { - Animation_PlayOnce(&this->skelAnime, sAnimationTable[newAnimationId]); + Animation_PlayOnce(&this->skelAnime, sAnimations[newAnimationId]); } this->animationId = newAnimationId; } @@ -118,33 +99,34 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.uncullZoneScale = 2000.0f; this->actor.uncullZoneDownward = 2400.0f; Actor_SetScale(&this->actor, 0.32f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060079B0, &D_06002168, this->jointTable, this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGiantSkel, &gGiantLargeStrideAnim, this->jointTable, + this->morphTable, GIANT_LIMB_MAX); EnGiant_ChangeAnimation(this, GIANT_ANIMATION_IDLE_LOOP); this->csAction = GIANT_CS_ACTION_NONE; this->actionFunc = EnGiant_PerformCutsceneActions; this->actor.draw = NULL; this->alpha = 0; this->actor.velocity.y = -10.0f; - this->actor.minVelocityY = -10.0f; + this->actor.terminalVelocity = -10.0f; this->actor.gravity = -5.0f; switch (type) { case GIANT_TYPE_CANYON_TERMINA_FIELD: case GIANT_TYPE_CANYON_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_CANYON_GIANTS_CHAMBER_AND_ENDING: - this->unk_24A = 0x1C6; + this->actorActionCommand = 0x1C6; break; case GIANT_TYPE_SWAMP_TERMINA_FIELD: case GIANT_TYPE_SWAMP_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_SWAMP_GIANTS_CHAMBER_AND_ENDING: - this->unk_24A = 0x1C7; + this->actorActionCommand = 0x1C7; break; case GIANT_TYPE_OCEAN_TERMINA_FIELD: case GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING: - this->unk_24A = 0x1C8; + this->actorActionCommand = 0x1C8; break; default: - this->unk_24A = 0x1C5; + this->actorActionCommand = 0x1C5; break; } @@ -153,24 +135,26 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - this->unk_24A = 0x1C5; + this->actorActionCommand = 0x1C5; Actor_SetScale(&this->actor, 0.32f); this->actionFunc = EnGiant_PerformClockTowerSuccessActions; - Animation_Change(&this->skelAnime, &D_060116E4, 0.0f, Animation_GetLastFrame(&D_060116E4) - 1.0f, - Animation_GetLastFrame(&D_060116E4), 2, 0.0f); + Animation_Change(&this->skelAnime, &gGiantRaisedArmsStartAnim, 0.0f, + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim) - 1.0f, + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), 2, 0.0f); this->actor.draw = EnGiant_Draw; this->actor.velocity.y = 0.0f; - this->actor.minVelocityY = 0.0f; + this->actor.terminalVelocity = 0.0f; this->actor.gravity = 0.0f; } if (GIANT_TYPE_IS_CLOCK_TOWER_FAILURE(type)) { Actor_SetScale(&this->actor, 0.32f); this->actionFunc = EnGiant_PlayClockTowerFailureAnimation; - Animation_Change(&this->skelAnime, &D_06013FE8, 1.0f, 0.0f, Animation_GetLastFrame(&D_06013004), 0, 0.0f); + Animation_Change(&this->skelAnime, &gGiantStruggleLoopAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGiantStruggleStartAnim), 0, 0.0f); this->actor.draw = EnGiant_Draw; this->actor.velocity.y = 0.0f; - this->actor.minVelocityY = 0.0f; + this->actor.terminalVelocity = 0.0f; this->actor.gravity = 0.0f; if (EnGiant_IsImprisoned(this)) { Actor_MarkForDeath(&this->actor); @@ -204,7 +188,7 @@ void EnGiant_Destroy(Actor* thisx, GlobalContext* globalCtx) { } /** - * The animations in sAnimationTable are organized such that looping animations + * The animations in sAnimations are organized such that looping animations * appear immediately after their respective starting animations. The point of * this function is to play the requested start animation if it has not been * played yet and play the respetive looping animation otherwise. @@ -266,8 +250,9 @@ void EnGiant_ChangeAnimationBasedOnCsAction(EnGiant* this) { } break; case GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER: - Animation_Change(&this->skelAnime, &D_060116E4, 0.0f, Animation_GetLastFrame(&D_060116E4) - 1.0f, - Animation_GetLastFrame(&D_060116E4), 2, 0.0f); + Animation_Change(&this->skelAnime, &gGiantRaisedArmsStartAnim, 0.0f, + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim) - 1.0f, + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), 2, 0.0f); break; } } @@ -333,10 +318,10 @@ void EnGiant_PlaySound(EnGiant* this) { if (this->actor.draw != NULL && this->alpha > 0) { if (this->animationId == GIANT_ANIMATION_WALKING_LOOP && (Animation_OnFrame(&this->skelAnime, 40.0f) || Animation_OnFrame(&this->skelAnime, 100.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KYOJIN_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_WALK); } if (this->animationId == GIANT_ANIMATION_FALLING_OVER && Animation_OnFrame(&this->skelAnime, 40.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KYOJIN_VOICE_FAIL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_VOICE_FAIL); } if (this->sfxId != 0xFFFF && ((this->animationId == GIANT_ANIMATION_BIG_CALL_START && this->skelAnime.curFrame >= 18.0f) || @@ -352,20 +337,19 @@ void EnGiant_PlaySound(EnGiant* this) { void EnGiant_UpdatePosition(EnGiant* this, GlobalContext* globalCtx, u32 actionIndex) { CsCmdActorAction* actorAction = globalCtx->csCtx.npcActions[actionIndex]; - f32 floatUnk10 = actorAction->unk10; + f32 startPosY = actorAction->unk0C.y; s32 pad[2]; - f32 floatUnk1C = actorAction->unk1C; - f32 functionTemp; + f32 endPosY = actorAction->unk18.y; + f32 scale = func_800F5A8C(actorAction->endFrame, actorAction->startFrame, globalCtx->csCtx.frames, globalCtx); - functionTemp = func_800F5A8C(actorAction->endFrame, actorAction->startFrame, globalCtx->csCtx.frames, globalCtx); - this->actor.world.pos.y = ((floatUnk1C - floatUnk10) * functionTemp) + floatUnk10; + this->actor.world.pos.y = ((endPosY - startPosY) * scale) + startPosY; } void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, this->unk_24A)) { - EnGiant_UpdatePosition(this, globalCtx, func_800EE200(globalCtx, this->unk_24A)); - if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0) { - this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0; + if (func_800EE29C(globalCtx, this->actorActionCommand)) { + EnGiant_UpdatePosition(this, globalCtx, func_800EE200(globalCtx, this->actorActionCommand)); + if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0) { + this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0; EnGiant_ChangeAnimationBasedOnCsAction(this); } EnGiant_UpdateAlpha(this); @@ -385,10 +369,10 @@ void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, GlobalContext* global void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx) { this->actor.draw = EnGiant_Draw; - if (func_800EE29C(globalCtx, this->unk_24A)) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->unk_24A)); - if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0) { - this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0; + if (func_800EE29C(globalCtx, this->actorActionCommand)) { + func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->actorActionCommand)); + if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0) { + this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0; EnGiant_ChangeAnimationBasedOnCsAction(this); } EnGiant_UpdateAlpha(this); @@ -407,7 +391,7 @@ void EnGiant_Update(Actor* thisx, GlobalContext* globalCtx) { s32 blinkTimerTemp; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (this->blinkTimer == 0) { @@ -427,10 +411,10 @@ void EnGiant_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnGiant_PostLimbDrawOpa(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - if (limbIndex == 1) { + if (limbIndex == GIANT_LIMB_HEAD) { OPEN_DISPS(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, D_06007610); + gSPDisplayList(POLY_OPA_DISP++, gGiantBeardDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -440,21 +424,15 @@ void EnGiant_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Gfx** gfx) { EnGiant* this = THIS; - if (limbIndex == 1) { - Matrix_CopyCurrentState(&this->unk_254); + if (limbIndex == GIANT_LIMB_HEAD) { + Matrix_CopyCurrentState(&this->headDrawMtxF); } } void EnGiant_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnGiant* this = THIS; - - /** - * 0 = eyes fully open face - * 1 = eyes half-closed face - * 2 = eyes fully closed face - */ - static TexturePtr sFaceTextures[] = { D_06005A80, D_06006280, D_06006A80 }; + static TexturePtr sFaceTextures[] = { gGiantFaceEyeOpenTex, gGiantFaceEyeHalfTex, gGiantFaceEyeClosedTex }; if (this->alpha > 0) { OPEN_DISPS(globalCtx->state.gfxCtx); @@ -479,10 +457,10 @@ void EnGiant_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnGiant_PostLimbDrawXlu, thisx, POLY_XLU_DISP); - Matrix_InsertMatrix(&this->unk_254, MTXMODE_NEW); + Matrix_InsertMatrix(&this->headDrawMtxF, MTXMODE_NEW); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_06007610); + gSPDisplayList(POLY_XLU_DISP++, gGiantBeardDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.h b/src/overlays/actors/ovl_En_Giant/z_en_giant.h index 6f50370f7b..e28aa2a32a 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.h +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.h @@ -86,6 +86,26 @@ typedef enum { /* 15 */ GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER } GiantCsActionIndex; +typedef enum { + /* 0 */ GIANT_LIMB_NONE, + /* 1 */ GIANT_LIMB_HEAD, + /* 2 */ GIANT_LIMB_LEFT_THIGH, + /* 3 */ GIANT_LIMB_LEFT_LOWER_LEG, + /* 4 */ GIANT_LIMB_LEFT_FOOT, + /* 5 */ GIANT_LIMB_RIGHT_THIGH, + /* 6 */ GIANT_LIMB_RIGHT_LOWER_LEG, + /* 7 */ GIANT_LIMB_RIGHT_FOOT, + /* 8 */ GIANT_LIMB_LEFT_SHOULDER, + /* 9 */ GIANT_LIMB_LEFT_UPPER_ARM, + /* 10 */ GIANT_LIMB_LEFT_FOREARM, + /* 11 */ GIANT_LIMB_LEFT_HAND, + /* 12 */ GIANT_LIMB_RIGHT_SHOULDER, + /* 13 */ GIANT_LIMB_RIGHT_UPPER_ARM, + /* 14 */ GIANT_LIMB_RIGHT_FOREARM, + /* 15 */ GIANT_LIMB_RIGHT_HAND, + /* 16 */ GIANT_LIMB_MAX, +} EnGiantLimbs; + struct EnGiant; typedef void (*EnGiantActionFunc)(struct EnGiant*, GlobalContext*); @@ -93,14 +113,14 @@ typedef void (*EnGiantActionFunc)(struct EnGiant*, GlobalContext*); typedef struct EnGiant { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[16]; - /* 0x1E8 */ Vec3s morphTable[16]; + /* 0x188 */ Vec3s jointTable[GIANT_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[GIANT_LIMB_MAX]; /* 0x248 */ s16 animationId; - /* 0x24A */ u16 unk_24A; + /* 0x24A */ u16 actorActionCommand; /* 0x24C */ u16 csAction; /* 0x24E */ s16 alpha; /* 0x250 */ u16 sfxId; - /* 0x254 */ MtxF unk_254; + /* 0x254 */ MtxF headDrawMtxF; /* 0x294 */ s16 faceIndex; /* 0x296 */ s16 blinkTimer; /* 0x298 */ EnGiantActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c index 6946f58ec6..a58710030b 100644 --- a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c +++ b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c @@ -78,7 +78,7 @@ void EnGinkoMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnGinkoMan_SetupIdle(EnGinkoMan* this) { this->actor.flags |= 1; // targetable - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); this->actionFunc = EnGinkoMan_Idle; } @@ -86,13 +86,13 @@ void EnGinkoMan_Idle(EnGinkoMan* this, GlobalContext* globalCtx) { s32 yaw = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; EnGinkoMan_SwitchAnimation(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { // Listen for dialogue start? + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if ((gSaveContext.roomInf[127][0] & 0xFFFF) == 0) { - func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x44C, &this->actor); this->curTextId = 0x44C; // would you like to make an account } else { - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { func_801518B0(globalCtx, 0x467, &this->actor); this->curTextId = 0x467; // "What's this? You need somethin' on a day like this? @@ -115,7 +115,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { switch (this->curTextId) { case 0x44C: // "Hey there, little guy! Won't you deposit some Rupees? (first dialogue) - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); if (gSaveContext.weekEventReg[10] & 8) { func_801518B0(globalCtx, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" @@ -130,7 +130,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" break; case 0x44F: // "...So, what'll it be? Deposit Rupees Don't deposit Rupees" - func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x450, &this->actor); this->curTextId = 0x450; // "How much? How much? [rupee prompt] break; @@ -141,14 +141,14 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { if (this->isNewAccount == true) { this->isNewAccount = false; if (this->curTextId != 0x453) { // "That's it? That ain't nothing at all, big spender! - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); } func_801518B0(globalCtx, 0x461, &this->actor); this->curTextId = 0x461; // So, little guy, what's your name? } else { if (this->curTextId == 0x453) { // "That's it? That ain't nothing at all, big spender! - func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); } globalCtx->msgCtx.bankRupees = gSaveContext.roomInf[127][0] & 0xFFFF; @@ -178,17 +178,17 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, 0x45D, &this->actor); this->curTextId = 0x45D; // "What's this? You've already saved up 5000 Rupees?! } else if (this->previousBankValue < (s16)(gSaveContext.roomInf[127][0] & 0xFFFF)) { - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); func_801518B0(globalCtx, 0x45E, &this->actor); this->curTextId = 0x45E; // "...Hang on there, little guy. I can't take any more deposits. Sorry..." } else { - func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x460, &this->actor); this->curTextId = 0x460; // "Come back and deposit some after you save up a bunch!" } } else { - func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x460, &this->actor); this->curTextId = 0x460; // "Come back and deposit some after you save up a bunch!" } @@ -218,7 +218,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SetupStamp(this); // stamp player break; case 0x465: // "There! Now I'll know you when I see you!" - func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); globalCtx->msgCtx.bankRupees = gSaveContext.roomInf[127][0] & 0xFFFF; func_801518B0(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" @@ -275,7 +275,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { break; case 0x476: // "...You haven't deposited that many Rupees, so that much isn't available for withdrawal. Do the // math! - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); case 0x475: // "What's this? Look, little guy, you can't hold this many rupees! You got that?" case 0x47C: // "Is that so? Think it over, little guy! So what are you gonna do?" case 0x47D: // duplicate of 48 @@ -342,7 +342,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { if (gSaveContext.rupees < globalCtx->msgCtx.bankRupeesSelected) { play_sound(NA_SE_SY_ERROR); - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); func_801518B0(globalCtx, 0x459, &this->actor); this->curTextId = 0x459; // HEY you dont have that much } else { @@ -354,7 +354,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) func_801518B0(globalCtx, 0x454, &this->actor); this->curTextId = 0x454; // Seriously? that's a lot. A lot! } else { - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); func_801518B0(globalCtx, 0x453, &this->actor); this->curTextId = 0x453; // That's it? That aint nothing at all } @@ -372,7 +372,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) } } else { // GINKOMAN_CHOICE_NO func_8019F230(); - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); if ((gSaveContext.roomInf[127][0] & 0xFFFF) == 0) { func_801518B0(globalCtx, 0x456, &this->actor); this->curTextId = 0x456; // Is that so? think about it @@ -405,7 +405,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) if ((s32)((gSaveContext.roomInf[127][0] & 0xFFFF)) < ((s32)(globalCtx->msgCtx.bankRupeesSelected + this->serviceFee))) { play_sound(NA_SE_SY_ERROR); - func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x476, &this->actor); this->curTextId = 0x476; // you dont have enough deposited to withdrawl } else if (CUR_CAPACITY(UPG_WALLET) < (globalCtx->msgCtx.bankRupeesSelected + gSaveContext.rupees)) { @@ -447,7 +447,7 @@ void EnGinkoMan_WaitForRupeeCount(EnGinkoMan* this, GlobalContext* globalCtx) { switch (this->curTextId) { case 0x450: // "How much? How much?" [rupee prompt] Set the amount with [Control Stick] and if (globalCtx->msgCtx.bankRupeesSelected == 0) { - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); func_801518B0(globalCtx, 0x457, &this->actor); this->curTextId = 0x457; // Zero Rupees? Cruel joke! } else { @@ -477,7 +477,7 @@ void EnGinkoMan_SetupDialogue(EnGinkoMan* this) { } void EnGinkoMan_Dialogue(EnGinkoMan* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { // get dialogue state? + switch (Message_GetState(&globalCtx->msgCtx)) { case 2: EnGinkoMan_SetupIdle(this); break; @@ -502,7 +502,7 @@ void EnGinkoMan_Dialogue(EnGinkoMan* this, GlobalContext* globalCtx) { } if ((this->skelAnime.animation == &D_060008C0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BANK_MAN_HAND_HIT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BANK_MAN_HAND_HIT); } } @@ -517,16 +517,16 @@ void EnGinkoMan_BankAward(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SetupBankAward2(this); } else if (this->curTextId == 0x45B) { // "Whats this, you already saved up 200?" if (!(gSaveContext.weekEventReg[10] & 8)) { - func_800B8A1C(&this->actor, globalCtx, GI_WALLET_ADULT + CUR_UPG_VALUE(UPG_WALLET), 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_WALLET_ADULT + CUR_UPG_VALUE(UPG_WALLET), 500.0f, 100.0f); } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); } } else if (this->curTextId == 0x45C) { // "Whats this, you already saved up 5000?" - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); } else if (!(gSaveContext.weekEventReg[59] & 8)) { - func_800B8A1C(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); } } @@ -537,7 +537,7 @@ void EnGinkoMan_SetupBankAward2(EnGinkoMan* this) { // separate function to handle bank rewards... if the bank has a parent actor? might be unused void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (!(gSaveContext.weekEventReg[10] & 8) && (this->curTextId == 0x45B)) { // "What's this? You've already saved up 200 Rupees!?! Well, little guy, here's your special gift. Take // it!" @@ -545,44 +545,44 @@ void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, 0x47A, &this->actor); this->curTextId = 0x47A; // "See! Doesn't it hold more than your old one? } else { - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); func_801518B0(globalCtx, 0x47B, &this->actor); this->curTextId = 0x47B; // "Is that so? Think it over, little guy! So what are you gonna do?" } EnGinkoMan_SetupDialogue(this); } else if (this->curTextId == 0x45D) { // saved up 5000 rupees for HP - if ((func_80152498(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { if (!(gSaveContext.weekEventReg[59] & 8)) { gSaveContext.weekEventReg[59] |= 8; } EnGinkoMan_SetupIdle(this); } } else { - func_800B85E0(&this->actor, globalCtx, 500.0f, -1); + func_800B85E0(&this->actor, globalCtx, 500.0f, EXCH_ITEM_MINUS1); } } void EnGinkoMan_SetupStamp(EnGinkoMan* this) { - func_800BDC5C(&this->skelAnime, animations, GINKO_REACHING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_REACHING); this->actionFunc = EnGinkoMan_Stamp; } void EnGinkoMan_Stamp(EnGinkoMan* this, GlobalContext* globalCtx) { if ((this->curTextId == 0x464) // "Hey, relax! It doesn't leave any marks, and it's not gonna hurt." && (Animation_OnFrame(&this->skelAnime, 10.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); // "stamp" + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); // "stamp" } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { switch (this->curTextId) { case 0x464: // "Hey, relax! It doesn't leave any marks, and it's not gonna hurt." - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); func_801518B0(globalCtx, 0x465, &this->actor); this->curTextId = 0x465; // "There! Now I'll know you when I see you!" break; case 0x469: // "Excuse me, but let me take a look at you..." - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); globalCtx->msgCtx.bankRupees = (gSaveContext.roomInf[127][0] & 0xFFFF); if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { func_801518B0(globalCtx, 0x46C, &this->actor); @@ -603,12 +603,12 @@ void EnGinkoMan_SwitchAnimation(EnGinkoMan* this, GlobalContext* globalCtx) { if (this->animTimer == 0) { if (this->skelAnime.animation != &D_06004A7C) { this->animTimer = 40; - func_800BDC5C(&this->skelAnime, animations, GINKO_ADVERTISING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_ADVERTISING); } } } else if ((this->animTimer == 0) && (this->skelAnime.animation != &D_06000AC4)) { this->animTimer = 40; - func_800BDC5C(&this->skelAnime, animations, GINKO_AMAZED); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_AMAZED); } DECR(this->animTimer); diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index ad39a682a2..91ae3270fa 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -579,7 +579,7 @@ void EnGirlA_Update2(EnGirlA* this, GlobalContext* globalCtx) { this->actor.shape.shadowScale = 4.0f; EnGirlA_TrySetMaskItemDescription(this, globalCtx); this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, 5.0f); + Actor_SetFocus(&this->actor, 5.0f); this->actor.shape.rot.x = 0; if (this->isSelected) { this->rotY += 0x1F4; diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index 412bf7381a..aee390e8dc 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -159,7 +159,7 @@ Actor* func_8094DEE0(EnGm* this, GlobalContext* globalCtx, u8 arg2, s16 arg3) { Actor* actor; while (true) { - actor = func_ActorCategoryIterateById(globalCtx, foundActor, arg2, arg3); + actor = SubS_FindActor(globalCtx, foundActor, arg2, arg3); foundActor = actor; if (actor == NULL) { break; @@ -212,7 +212,7 @@ EnDoor* func_8094DF90(GlobalContext* globalCtx, s32 arg1) { phi_a1 = -1; } - return (EnDoor*)func_8013A7C0(globalCtx, phi_a1); + return SubS_FindDoor(globalCtx, phi_a1); } s32 func_8094DFF8(EnGm* this, GlobalContext* globalCtx) { @@ -429,7 +429,7 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { switch (this->unk_3E0) { case 0: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); func_8094E054(this, globalCtx, 2); this->unk_3E2 = 0; this->unk_3E0++; @@ -481,7 +481,7 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { break; case 8: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); ActorCutscene_Stop(sp4A); this->unk_3E2 = 0; this->unk_3E0++; @@ -566,7 +566,7 @@ s32 func_8094EB1C(EnGm* this, GlobalContext* globalCtx) { ret = true; break; } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); func_8094E054(this, globalCtx, 2); this->unk_3E2 = 0; this->unk_3E0++; @@ -586,7 +586,7 @@ s32 func_8094EB1C(EnGm* this, GlobalContext* globalCtx) { break; case 2: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); this->unk_3E2 = 0; this->unk_3E0++; @@ -661,7 +661,7 @@ s32 func_8094EE84(EnGm* this, GlobalContext* globalCtx) { s32 ret = false; if (this->unk_3A4 & 7) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_8013AED4(&this->unk_3A4, 0, 7); this->unk_3E0 = 0; this->unk_3E4 = NULL; @@ -786,7 +786,7 @@ void func_8094F2E8(EnGm* this) { void func_8094F3D0(EnGm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s32 sp28 = func_80152498(&globalCtx->msgCtx); + s32 sp28 = Message_GetState(&globalCtx->msgCtx); s32 var = globalCtx->msgCtx.unk11F04; if ((&this->actor == player->targetActor) && ((var < 0xFF) || (var > 0x200)) && (sp28 == 3) && @@ -892,7 +892,7 @@ s32 func_8094F53C(EnGm* this, GlobalContext* globalCtx) { } if ((this->unk_3E8 == 6) && !(globalCtx->actorCtx.unk5 & 0x20) && Animation_OnFrame(&this->skelAnime, 20.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } return false; @@ -1260,7 +1260,7 @@ s32 func_809503F8(EnGm* this, GlobalContext* globalCtx) { if (this->unk_3E8 == 9) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; func_8013AED4(&this->unk_3A4, 3, 7); func_8094E054(this, globalCtx, 0); } else { @@ -1292,7 +1292,7 @@ s32 func_80950490(EnGm* this, GlobalContext* globalCtx) { switch (this->unk_3E8) { case 9: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; func_8013AED4(&this->unk_3A4, 3, 7); this->unk_3C8 = 4; this->unk_3CA = 4; @@ -1351,7 +1351,7 @@ s32 func_80950690(EnGm* this, GlobalContext* globalCtx) { case 7: this->unk_3D0 += 992; if (DECR(this->unk_3B8) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_GO_SLEEP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_GO_SLEEP); this->unk_3B8 = 30; } break; @@ -1389,7 +1389,7 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { Lib_Vec3f_TranslateAndRotateY(&this->unk_278, this->actor.world.rot.y, &sp38, &this->actor.world.pos); this->unk_3BA += this->unk_3C4; if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PIRATE_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } } @@ -1408,7 +1408,7 @@ s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { func_8013AF00(sp7C, 3, this->unk_234->count + 3); if (!(this->unk_3A4 & 8)) { - sp58 = D_801D15B0; + sp58 = gZeroVec3f; func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, &sp58, this->unk_3C4); func_8013B878(globalCtx, this->unk_234, this->unk_250, &sp58); @@ -1427,7 +1427,7 @@ s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { sp58 = this->actor.world.pos; } - this->unk_238 = D_801D15B0; + this->unk_238 = gZeroVec3f; if (func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, &this->unk_238, this->unk_3C4)) { @@ -1443,7 +1443,7 @@ s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { this->unk_250 = sp50; this->unk_238 = sp58; } else if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PIRATE_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } return false; } @@ -1513,7 +1513,7 @@ void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { this->actor.flags &= ~1; sp20.unk0 = 0; } else { - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= 1; } this->unk_258 = sp20.unk0; @@ -1569,7 +1569,7 @@ void func_80950F2C(EnGm* this, GlobalContext* globalCtx) { sp2C = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x20E)]->unk0; if (this->unk_259 != (sp2C & 0xFF)) { if (sp2C == 3) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); } this->unk_259 = sp2C; func_8094E054(this, globalCtx, sp50[sp2C]); @@ -1597,7 +1597,7 @@ void EnGm_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 22.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 22.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060078B0, NULL, this->jointTable, this->morphTable, 20); this->unk_3E8 = -1; func_8094E054(this, globalCtx, 0); @@ -1641,7 +1641,7 @@ void EnGm_Update(Actor* thisx, GlobalContext* globalCtx) { func_8094F2E8(this); func_8013C964(&this->actor, globalCtx, this->unk_3B4, 30.0f, 0, this->unk_3A4 & 7); if ((this->unk_258 != 3) && (this->unk_258 != 5) && (this->unk_258 != 8)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); } func_8094E1DC(this, globalCtx); @@ -1705,7 +1705,7 @@ void func_809514BC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* CLOSE_DISPS(globalCtx->state.gfxCtx); if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_801D15B0, &sp30); + Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp30); Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); } } diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index a79aef7ea5..15e0b7622a 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -5,6 +5,10 @@ */ #include "z_en_go.h" +#include "objects/object_oF1d_map/object_oF1d_map.h" +#include "objects/object_hakugin_demo/object_hakugin_demo.h" +#include "objects/object_taisou/object_taisou.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x02000019 @@ -23,8 +27,56 @@ void func_80A14EB0(EnGo* this, GlobalContext* globalCtx); void func_80A14FC8(EnGo* this, GlobalContext* globalCtx); void func_80A153FC(EnGo* this, GlobalContext* globalCtx); void func_80A157C4(EnGo* this, GlobalContext* globalCtx); +void func_80A15FEC(Actor* thisx, GlobalContext* globalCtx); + +static s32 D_80A16100[] = { + 0x00150800, 0x40010022, 0x00150200, 0x180E0E10, 0x0C0F0E11, 0x0C0F0E12, 0x0C0F0E13, 0x0C0F0E14, 0x0C111502, + 0x100E0E15, 0x0C100015, 0x0400110E, 0x0E160C0F, 0x0E170C0F, 0x0E180C11, 0x15041610, 0x0E0E190C, 0x10001504, + 0x000D0100, 0x050E0E31, 0x0C100E0E, 0x2F0C1001, 0x00050E0E, 0x2D0C100E, 0x0E2B0C10, +}; + +static s32 D_80A16164[] = { + 0x00150800, 0x7E01004D, 0x00150400, 0x180E0E1A, 0x0C170F0E, 0x230C180F, 0x0E240C0F, 0x0E250C12, 0x16111508, + 0x100E0E1A, 0x0C170F0E, 0x230C180F, 0x0E240C0F, 0x0E250C17, 0x0F0E260C, 0x180F0E27, 0x0C170F0E, 0x280C180F, + 0x0E290C17, 0x0F0E2A0C, 0x16111508, 0x100E0E1A, 0x0C170F0E, 0x1B0C180F, 0x0E1C0C0F, 0x0E1D0C0F, 0x0E1E0C17, + 0x0F0E1F0C, 0x180F0E20, 0x0C170F0E, 0x210C0F0E, 0x220C1611, 0x15081000, 0x1504000D, 0x0100050E, 0x0E320C10, + 0x0E0E300C, 0x10010005, 0x0E0E2E0C, 0x100E0E2C, 0x0C100000, +}; + +static s32 D_80A16208[2] = { 0xE0E520C, 0x10000000 }; + +static s32 D_80A16210[17] = { + 0x160400, 0x38010010, 0xE0E430C, 0xF0E440C, 0xF0E450C, 0x11188010, 0x160800, 0x1B0E0E46, 0xC0F0E47, + 0xC0F0E48, 0xC0F0E49, 0xC0F0E4A, 0xC111608, 0x11188010, 0xE0E4B0C, 0x100E0E42, 0xC100000, +}; + +static s32 D_80A16254[11] = { + 0x160400, 0x22010009, 0xE0E4D0C, 0xF0E4E0C, 0x10001701, 0xC0E0E, + 0x4F0C0F0E, 0x500C1117, 0x1100E0E, 0x510C100E, 0xE4C0C10, +}; + +static s32 D_80A16280[52] = { + 0x1001200, 0x12200008, 0xE0C8E0C, 0x11122010, 0xE0C8F0C, 0x10001240, 0x1D0E0C, 0x800C1112, 0x40001280, + 0x742500, 0xC006F00, 0x13010045, 0xF0C810C, 0x19001300, 0x1280005E, 0x25000C00, 0x59001301, 0x2F0E0C, + 0x810C0F0C, 0x820C0500, 0x1A00, 0x1A300E0C, 0x830C1209, 0x700, 0xE0C84, 0x160C1113, 0x1100E0C, + 0x840C1031, 0xE0C850C, 0x1029FFF2, 0x130200, 0xF0E0C88, 0xC0F0C89, 0xC05000A, 0xFFE3FFE3, 0xE0C860C, + 0x11128019, 0x213019, 0xFFC02900, 0x2C0E0C8C, 0xC050000, 0x50000, 0x8006400, 0x6320E0C, 0x8D0C1030, + 0x14FF9C12, 0x6003400, 0x130034, 0x700000E, 0xC870C16, 0x100E0C8B, 0xC100000, +}; + +static s32 D_80A16350[27] = { + 0x584000, 0x2903000E, 0x2001301, 0x180058, 0x80005119, 0x1E0059, 0x1004919, 0x160059, 0x2004119, + 0xE0059, 0x4003919, 0x2F0E0D, 0x4D0C1210, 0xE0D480C, 0xF0D490C, 0xF0D4A0C, 0x5000000, 0xF000F30, + 0xE0D4B0C, 0x15090000, 0xE0D4D0C, 0x1210310E, 0xD4C0C12, 0x100E0D4E, 0xC19FFD8, 0xE0D4F0C, 0x19FFD500, +}; + +static s32 D_80A163BC[4] = { 0x100060E, 0xDFE0C12, 0x100E0DFF, 0xC121000 }; +static s32 D_80A163CC[4] = { 0x100060E, 0xE000C12, 0x100E0E01, 0xC121000 }; +static s32 D_80A163DC[4] = { 0x100060E, 0xE020C12, 0x100E0E03, 0xC121000 }; +static s32 D_80A163EC[4] = { 0x100060E, 0xE040C12, 0x100E0E05, 0xC121000 }; +static s32 D_80A163FC[4] = { 0x100060E, 0xE060C12, 0x100E0E07, 0xC121000 }; +static s32 D_80A1640C[2] = { 0xE023A0C, 0x12100000 }; -#if 0 const ActorInit En_Go_InitVars = { ACTOR_EN_GO, ACTORCAT_NPC, @@ -37,32 +89,69 @@ const ActorInit En_Go_InitVars = { (ActorFunc)NULL, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80A16434 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 0 }, 100 }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A16460 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x02, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x02, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, 0, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A1648C = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, 0, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80A164B8 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80A164C4 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -97,156 +186,1887 @@ static DamageTable D_80A164C4 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; +static ActorAnimationEntryS sAnimations[] = { + { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, 0 }, { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, -4 }, + { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, 0 }, { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, -4 }, + { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, 2, 0 }, { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, 0 }, + { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, -4 }, { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, 2, -4 }, + { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, 0, 0 }, { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, 2, -4 }, + + { &object_taisou_Anim_004DD4, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_0016C8, 1.0f, 0, -1, 0, 0 }, + { &object_taisou_Anim_00283C, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_007764, 1.0f, 0, -1, 0, 0 }, + { &object_taisou_Anim_005EE0, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_002C48, 1.0f, 0, -1, 0, 0 }, + { &object_taisou_Anim_0031D8, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_005790, 1.0f, 0, -1, 0, 0 }, + + { &object_hakugin_demo_Anim_001420, 1.0f, 0, -1, 2, 0 }, { &object_hakugin_demo_Anim_001A4C, 1.0f, 0, -1, 0, -4 }, + { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, 2, 0 }, { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, 0, -4 }, +}; + +EnGoStruct* func_80A10FD0(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { + s32 i; + + for (i = 16; i < 32; i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 7; + ptr->unk_01 = (Rand_ZeroOne() * (2.0f * (arg6 / 3.0f))) + (arg6 / 3.0f); + ptr->unk_02 = ptr->unk_01; + ptr->unk_10 = arg1; + ptr->unk_1C = arg2; + ptr->unk_28 = arg3; + ptr->unk_34 = arg4; + ptr->unk_38 = arg5; + break; + } + } + + return ptr; +} + +void func_80A11144(EnGoStruct ptr[], GlobalContext* globalCtx) { + s32 pad; + s32 i; + s32 flag = false; + f32 temp; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < 32; i++, ptr++) { + + if (ptr->unk_00 == 7) { + gDPPipeSync(POLY_XLU_DISP++); + + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_0031A0); + flag = true; + } + + Matrix_StatePush(); + + temp = ((f32)ptr->unk_02 / ptr->unk_01); + temp *= 255; + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (u8)temp); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_02 + (i * 3)) * 3, + (ptr->unk_02 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + + Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(ptr->unk_34, ptr->unk_34, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_003258); + + Matrix_StatePop(); + if (globalCtx->state.gfxCtx) {} + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A1143C(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6, s32 arg7) { + s32 i; + + for (i = 16; i < 32; i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = arg7 + 4; + + ptr->unk_01 = (Rand_ZeroOne() * (2.0f * (arg6 / 3.0f))) + (arg6 / 3.0f); + ptr->unk_02 = ptr->unk_01; + + ptr->unk_10 = arg1; + ptr->unk_1C = arg2; + ptr->unk_28 = arg3; + ptr->unk_34 = arg4; + ptr->unk_38 = arg5; + break; + } + } +} + +void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { + static TexturePtr D_80A16644[] = { + &gameplay_keep_Tex_08F7E0, &gameplay_keep_Tex_08F3E0, &gameplay_keep_Tex_08EFE0, &gameplay_keep_Tex_08EBE0, + &gameplay_keep_Tex_08E7E0, &gameplay_keep_Tex_08E3E0, &gameplay_keep_Tex_08DFE0, &gameplay_keep_Tex_08DBE0, + }; + static Color_RGBA8 D_80A16664[] = { + { 255, 255, 255, 0 }, + { 170, 130, 90, 0 }, + { 0, 0, 0, 0 }, + }; + static Color_RGBA8 D_80A16670[] = { + { 255, 255, 255, 0 }, + { 100, 60, 20, 0 }, + { 0, 0, 0, 0 }, + }; + s32 i; + u8 flag = false; + f32 temp; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < 32; i++, ptr++) { + if ((ptr->unk_00 >= 4) && (ptr->unk_00 < 7)) { + if (!flag) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014CF0); + flag = true; + } + Matrix_StatePush(); + + temp = (f32)ptr->unk_02 / ptr->unk_01; + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80A16664[(s32)ptr->unk_00 - 4].r, + D_80A16664[(s32)ptr->unk_00 - 4].g, D_80A16664[(s32)ptr->unk_00 - 4].b, (u8)(temp * 255)); + gDPSetEnvColor(POLY_XLU_DISP++, D_80A16670[(s32)ptr->unk_00 - 4].r, D_80A16670[(s32)ptr->unk_00 - 4].g, + D_80A16670[(s32)ptr->unk_00 - 4].b, 0); + + Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_34, ptr->unk_34, 1.0f, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A16644[(s32)(temp * 7.0f)])); + gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014D00); + + Matrix_StatePop(); + } + if (globalCtx->state.gfxCtx) {} + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +#ifdef NON_MATCHING +void func_80A118F8(EnGoStruct ptr[32], Vec3f arg1) { + static u8 D_80A1667C[] = { + 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, + }; + EnGoStruct* ptr2 = &ptr[16]; + s32 i; + Vec3f spB4; + Vec3f spA8; + f32 temp_f20; + + for (i = 0; i < 16; i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_10 = arg1; + ptr->unk_10.y += 56.0f; + + ptr->unk_04.x = (Rand_ZeroOne() - 0.5f) * 5460.0f; + ptr->unk_04.y = (Rand_ZeroOne() - 0.5f) * 5460.0f; + ptr->unk_04.z = (Rand_ZeroOne() - 0.5f) * 5460.0f; + + temp_f20 = (Rand_ZeroOne() * 4.0f) + 6.0f; + ptr->unk_28.x = Math_SinS(i * 0x1000) * temp_f20; + ptr->unk_28.z = Math_CosS(i * 0x1000) * temp_f20; + ptr->unk_28.y = (Rand_ZeroOne() * 3.0f) + 6.0f; + + ptr->unk_1C = gZeroVec3f; + ptr->unk_1C.y = -0.8f; + + ptr->unk_01 = ptr->unk_02 = 1; + ptr->unk_00 = D_80A1667C[i]; + + spB4.x = ((Rand_ZeroOne() - 0.5f) * 80.0f) + ptr->unk_10.x; + spB4.y = ((Rand_ZeroOne() - 0.5f) * 40.0f) + ptr->unk_10.y; + spB4.z = ((Rand_ZeroOne() - 0.5f) * 80.0f) + ptr->unk_10.z; + + spA8 = gZeroVec3f; + spA8.y = (Rand_ZeroOne() * 3.0f) + 1.0f; + + func_80A1143C(ptr2, spB4, gZeroVec3f, spA8, 0.6f, 0.2f, 16, 0); + } + } +} +#else +static u8 D_80A1667C[] = { + 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, +}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A118F8.s") #endif -extern ColliderSphereInit D_80A16434; -extern ColliderCylinderInit D_80A16460; -extern ColliderCylinderInit D_80A1648C; -extern CollisionCheckInfoInit2 D_80A164B8; -extern DamageTable D_80A164C4; +void func_80A11BF8(EnGoStruct ptr[], f32 arg1) { + f32 test; + f32 test2; + f32 x; + f32 z; -extern UNK_TYPE D_06000458; -extern UNK_TYPE D_06003258; -extern UNK_TYPE D_060091A8; -extern UNK_TYPE D_06011AC8; -extern UNK_TYPE D_06014D00; + ptr->unk_10.x += ptr->unk_28.x; + ptr->unk_10.y += ptr->unk_28.y; + ptr->unk_10.z += ptr->unk_28.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A10FD0.s") + ptr->unk_28.y += ptr->unk_1C.y; + ptr->unk_34 += ptr->unk_38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A11144.s") + if (ptr->unk_10.y < arg1) { + ptr->unk_10.y = arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A1143C.s") + ptr->unk_00 = 4; + ptr->unk_01 = (Rand_ZeroOne() * 8.0f) + 4.0f; + ptr->unk_02 = ptr->unk_01; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A115B4.s") + ptr->unk_28 = gZeroVec3f; + ptr->unk_28.y = (Rand_ZeroOne() * 3.0f) + 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A118F8.s") + ptr->unk_34 = 0.4f; + ptr->unk_38 = 0.1f; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A11BF8.s") + if (ptr->unk_28.x != 0.0f) { + x = ptr->unk_28.x / fabsf(ptr->unk_28.x); + x *= ((sREG(13) + 140) * 0.01f); + Math_StepToF(&ptr->unk_28.x, x, (sREG(14) + 40) * 0.01f); + } + if (ptr->unk_28.z != 0.0f) { + z = ptr->unk_28.z / fabsf(ptr->unk_28.z); + z *= ((sREG(13) + 140) * 0.01f); + Math_StepToF(&ptr->unk_28.z, z, (sREG(14) + 40) * 0.01f); + } + + ptr->unk_0A.x += ptr->unk_04.x; + ptr->unk_0A.y += ptr->unk_04.y; + ptr->unk_0A.z += ptr->unk_04.z; +} + +#ifdef NON_MATCHING +void func_80A11EC0(EnGoStruct ptr[], GlobalContext* globalCtx, Gfx arg2[], Gfx arg3[], u8 arg4) { + s32 i; + u8 flag = false; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < 16; i++, ptr++) { + if (ptr->unk_00 == arg4) { + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, arg2); + flag = true; + } + + Matrix_StatePush(); + Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Scale(0.08f, 0.08f, 0.08f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(ptr->unk_0A.z, MTXMODE_APPLY); + Matrix_InsertXRotation_s(ptr->unk_0A.x, MTXMODE_APPLY); + Matrix_RotateY(ptr->unk_0A.y, MTXMODE_APPLY); + + if (1) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, arg3); + } + + Matrix_StatePop(); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A11EC0.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A1203C.s") +void func_80A1203C(EnGo* this) { + EnGoStruct* ptr = this->unk_3F8; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A1213C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_3F8); i++, ptr++) { + if (ptr->unk_00 != 0) { + if (ptr->unk_02 == 0) { + ptr->unk_00 = 0; + } else if ((ptr->unk_00 > 0) && (ptr->unk_00 < 4)) { + func_80A11BF8(ptr, this->actor.world.pos.y); + } else { + ptr->unk_10.x += ptr->unk_28.x; + ptr->unk_10.y += ptr->unk_28.y; + ptr->unk_10.z += ptr->unk_28.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A121F4.s") + ptr->unk_28.x += ptr->unk_1C.x; + ptr->unk_28.y += ptr->unk_1C.y; + ptr->unk_28.z += ptr->unk_1C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A1222C.s") + ptr->unk_34 += ptr->unk_38; + ptr->unk_02--; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A122EC.s") +void func_80A1213C(EnGo* this, GlobalContext* globalCtx) { + func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_0003D0, object_oF1d_map_DL_000458, 1); + func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_0008C0, object_oF1d_map_DL_000948, 2); + func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_000D50, object_oF1d_map_DL_000DD8, 3); + func_80A11144(this->unk_3F8, globalCtx); + func_80A115B4(this->unk_3F8, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A123A0.s") +s32 func_80A121F4(GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A124A0.s") + if ((player->transformation == PLAYER_FORM_GORON) && (player->stateFlags3 & 0x2000000)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A124FC.s") +s32 func_80A1222C(EnGo* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A125BC.s") + if (((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.unk1202A == 3) && + (globalCtx->msgCtx.unk1202E == 1) && (this->unk_3EC == 0) && (this->actor.xzDistToPlayer < 400.0f)) || + (!(gSaveContext.weekEventReg[22] & 4) && (globalCtx->sceneNum == SCENE_16GORON_HOUSE) && + (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (globalCtx->csCtx.unk_12 == 1))) { + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12660.s") +s32 func_80A122EC(EnGo* this) { + static Vec3f D_80A1668C = { 0.0f, 100.0f, 160.0f }; + s32 pad; + f32 sp20 = 58.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A126BC.s") + if (ENGO_GET_F(&this->actor) == ENGO_F_8) { + Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80A1668C, + &this->actor.focus.pos); + } else { + if ((this->unk_390 & 0x200) || (this->unk_390 & 0x100)) { + sp20 = this->actor.shape.yOffset; + } + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); + this->actor.focus.pos.y += sp20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12774.s") + this->actor.focus.rot.x = this->actor.world.rot.x; + this->actor.focus.rot.y = this->actor.world.rot.y; + this->actor.focus.rot.z = this->actor.world.rot.z; + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12868.s") +void func_80A123A0(EnGo* this, GlobalContext* globalCtx) { + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12954.s") + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12A64.s") + this->colliderSphere.dim.worldSphere.center.x = sp2C.x; + this->colliderSphere.dim.worldSphere.center.y = sp2C.y; + this->colliderSphere.dim.worldSphere.center.y += (s16)this->actor.shape.yOffset; + this->colliderSphere.dim.worldSphere.center.z = sp2C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12B78.s") + this->colliderSphere.dim.modelSphere.radius = 48; + this->colliderSphere.dim.worldSphere.radius = + this->colliderSphere.dim.modelSphere.radius * this->colliderSphere.dim.scale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12C48.s") + if (func_80A121F4(globalCtx)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12D6C.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12DF4.s") +void func_80A124A0(EnGo* this, GlobalContext* globalCtx) { + this->colliderSphere.dim.worldSphere.radius = + this->colliderSphere.dim.modelSphere.radius * this->colliderSphere.dim.scale; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12E80.s") +void func_80A124FC(EnGo* this, GlobalContext* globalCtx) { + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12FE8.s") + Math_Vec3f_Copy(&sp1C, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A131F8.s") + this->colliderSphere.dim.worldSphere.center.x = sp1C.x; + this->colliderSphere.dim.worldSphere.center.y = sp1C.y; + this->colliderSphere.dim.worldSphere.center.y += (s16)this->actor.shape.yOffset; + this->colliderSphere.dim.worldSphere.center.z = sp1C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A132C8.s") + this->colliderSphere.dim.modelSphere.radius = 20; + this->colliderSphere.dim.worldSphere.radius = + this->colliderSphere.dim.modelSphere.radius * this->colliderSphere.dim.scale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A133A8.s") + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A13400.s") +void func_80A125BC(EnGo* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A134B0.s") + Math_Vec3f_ToVec3s(&this->colliderCylinder.dim.pos, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A134F4.s") + this->colliderCylinder.dim.radius = 46; + this->colliderCylinder.dim.height = 78; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A13564.s") + if (this->unk_3C6 == 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A136B8.s") +void func_80A12660(EnGo* this, GlobalContext* globalCtx) { + Math_Vec3f_ToVec3s(&this->colliderCylinder.dim.pos, &this->actor.world.pos); + this->colliderCylinder.dim.radius = 24; + this->colliderCylinder.dim.height = 62; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A13728.s") +void func_80A126BC(EnGo* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A137C0.s") + if (!(player->stateFlags2 & 0x4000)) { + if (this->unk_3C6 != 0) { + this->unk_3C6--; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A139E4.s") + if (ENGO_GET_F(&this->actor) == ENGO_F_8) { + func_80A124A0(this, globalCtx); + } else if (this->unk_390 & 0x100) { + func_80A123A0(this, globalCtx); + } else if (this->unk_390 & 0x200) { + func_80A124FC(this, globalCtx); + } else if (this->unk_390 & 0x400) { + func_80A125BC(this, globalCtx); + } else { + func_80A12660(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A13B1C.s") +s32 func_80A12774(EnGo* this, GlobalContext* globalCtx) { + if (!(this->unk_390 & 7) || !Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A13E80.s") + if ((ENGO_GET_F(&this->actor) != ENGO_F_8) && (ENGO_GET_F(&this->actor) != ENGO_F_1)) { + if (!(this->unk_390 & 0x200)) { + this->unk_390 |= 8; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14018.s") + if ((ENGO_GET_F(&this->actor) == ENGO_F_5) || (ENGO_GET_F(&this->actor) == ENGO_F_6) || + (ENGO_GET_F(&this->actor) == ENGO_F_7)) { + this->unk_3BC = 0; + this->unk_3BE = 0; + this->unk_390 |= 0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14104.s") + func_8013AED4(&this->unk_390, 0, 7); + this->unk_3C0 = 0; + this->unk_3C4 = 0; + this->unk_18C = this->actionFunc; + this->actionFunc = func_80A157C4; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A141D4.s") +s32 func_80A12868(EnGo* this, GlobalContext* globalCtx) { + this->unk_390 &= ~0x800; + this->unk_390 &= ~0x1000; + this->unk_390 &= ~0x2000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A1428C.s") + if ((this->colliderCylinder.base.atFlags & AT_HIT) || (this->colliderSphere.base.atFlags & AT_HIT)) { + this->colliderCylinder.base.atFlags &= ~AT_HIT; + this->colliderSphere.base.atFlags &= ~AT_HIT; + this->unk_390 |= 0x800; + this->unk_3C6 = 0x28; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14324.s") + if ((this->colliderCylinder.base.acFlags & AC_HIT) || (this->colliderSphere.base.acFlags & AC_HIT)) { + this->colliderCylinder.base.acFlags &= ~AC_HIT; + this->colliderSphere.base.acFlags &= ~AC_HIT; + this->unk_390 |= 0x1000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A143A8.s") + if ((this->colliderCylinder.base.ocFlags1 & OC1_HIT) || (this->colliderSphere.base.ocFlags1 & OC1_HIT)) { + this->colliderCylinder.base.ocFlags1 &= ~OC1_HIT; + this->colliderSphere.base.ocFlags1 &= ~OC1_HIT; + this->unk_390 |= 0x2000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14430.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A1449C.s") +s32 func_80A12954(EnGo* this, GlobalContext* globalCtx) { + if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (globalCtx->csCtx.state != 0) && (this->actor.draw != NULL) && + (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && + (globalCtx->csCtx.unk_12 == 0)) { + if (this->unk_3F0 == 0) { + this->actor.flags &= ~1; + this->unk_394 = 255; + this->unk_3F0 = 1; + this->unk_18C = this->actionFunc; + } + func_8013AED4(&this->unk_390, 0, 7); + this->actionFunc = func_80A14FC8; + } else if (this->unk_3F0 != 0) { + this->actor.flags |= 1; + this->unk_394 = 255; + this->unk_3F0 = 0; + func_8013AED4(&this->unk_390, 3, 7); + this->actionFunc = this->unk_18C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A144F4.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A145AC.s") +s32 func_80A12A64(EnGo* this, GlobalContext* globalCtx) { + s8 objIdx = this->actor.objBankIndex; + s8 objIdx2 = -1; + s32 ret = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14668.s") + if ((this->unk_3DC >= 18) && (this->unk_289 >= 0)) { + objIdx2 = this->unk_289; + } else if ((this->unk_3DC >= 10) && (this->unk_288 >= 0)) { + objIdx2 = this->unk_288; + } else if (this->unk_3DC < 10) { + objIdx2 = this->actor.objBankIndex; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A146CC.s") + if (objIdx2 >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx2].segment); + this->skelAnime.playSpeed = this->unk_398; + ret = SkelAnime_Update(&this->skelAnime); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx].segment); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14798.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A149B0.s") +s32 func_80A12B78(EnGo* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state == 0) { + if (this->unk_3DC == 4) { + if (Animation_OnFrame(&this->skelAnime, 2.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_CIRCLE); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14B30.s") + if (Animation_OnFrame(&this->skelAnime, 22.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SIT_IMT); + } + } else if ((this->unk_3DC == 2) || (this->unk_3DC == 3)) { + if (Animation_OnFrame(&this->skelAnime, 2.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_CIRCLE_OFF); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14E14.s") + if (Animation_OnFrame(&this->skelAnime, 24.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_STAND_IMT); + } + } + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14E74.s") +s32 func_80A12C48(EnGo* this, GlobalContext* globalCtx, s32 arg2) { + s8 objIdx = this->actor.objBankIndex; + s8 objIdx2 = -1; + s32 ret = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14EB0.s") + if ((arg2 >= 18) && (this->unk_289 >= 0)) { + objIdx2 = this->unk_289; + } else if ((arg2 >= 10) && (this->unk_288 >= 0)) { + objIdx2 = this->unk_288; + } else if (arg2 < 10) { + objIdx2 = this->actor.objBankIndex; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14FC8.s") + if (objIdx2 >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx2].segment); + this->unk_3DC = arg2; + ret = func_8013BC6C(&this->skelAnime, sAnimations, arg2); + this->unk_398 = this->skelAnime.playSpeed; + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx].segment); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A153FC.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A15684.s") +void func_80A12D6C(EnGo* this) { + if ((this->unk_390 & 0x20) && (DECR(this->unk_3BC) == 0)) { + this->unk_3BE++; + if (this->unk_3BE >= 4) { + this->unk_3BC = Rand_S16Offset(30, 30); + this->unk_3BE = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A157C4.s") +void func_80A12DF4(EnGo* this, GlobalContext* globalCtx) { + if (this->unk_3D4 == 0) { + func_80A12C48(this, globalCtx, 9); + this->unk_3D4++; + } else if ((this->unk_3D4 == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A12C48(this, globalCtx, 6); + this->unk_3D4++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/EnGo_Init.s") +s32 func_80A12E80(EnGo* this, GlobalContext* globalCtx) { + u16 temp = globalCtx->msgCtx.unk11F04; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/EnGo_Destroy.s") + if (ENGO_GET_F(&this->actor) != ENGO_F_4) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/EnGo_Update.s") + if (player->stateFlags1 & 0x40) { + if (this->unk_392 != temp) { + switch (temp) { + case 0xE1A: + this->unk_390 |= 8; + this->unk_38C = this->actor.child; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A15B80.s") + case 0xE1D: + case 0xE25: + if (ENGO_GET_70(&this->actor) == ENGO_70_1) { + this->unk_38C = &GET_PLAYER(globalCtx)->actor; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A15D04.s") + case 0xE27: + if (ENGO_GET_70(&this->actor) == ENGO_70_1) { + this->unk_38C = this->actor.child; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A15E38.s") + case 0xE16: + case 0xE1E: + this->unk_190 = func_80A12DF4; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A15FEC.s") + case 0xE1F: + if (ENGO_GET_70(&this->actor) == ENGO_70_0) { + this->unk_38C = &GET_PLAYER(globalCtx)->actor; + } + break; + } + } + this->unk_3F4 = 1; + this->unk_392 = temp; + } else if (this->unk_3F4 != 0) { + this->unk_3F4 = 0; + this->unk_190 = NULL; + this->unk_392 = 0; + func_80A12C48(this, globalCtx, 5); + this->unk_390 &= ~8; + } + + if (this->unk_190 != NULL) { + this->unk_190(this, globalCtx); + } + + return false; +} + +s32 func_80A12FE8(EnGo* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; + + Math_Vec3f_Copy(&sp40, &this->unk_38C->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); + + Math_ApproachS(&this->unk_3B2, (sp32 - this->unk_3B6) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_3B2 = CLAMP(this->unk_3B2, -0x1FFE, 0x1FFE); + + Math_ApproachS(&this->unk_3B6, (sp32 - this->unk_3B2) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_3B6 = CLAMP(this->unk_3B6, -0x1C70, 0x1C70); + + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + + if (this->unk_38C->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_38C)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_38C->focus.pos); + } + + Math_ApproachS(&this->unk_3B0, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_3B4, 4, 0x2AA8); + this->unk_3B0 = CLAMP(this->unk_3B0, -0x1554, 0x1554); + + Math_ApproachS(&this->unk_3B4, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_3B0, 4, 0x2AA8); + this->unk_3B4 = CLAMP(this->unk_3B4, -0xE38, 0xE38); + + return false; +} + +s32 func_80A131F8(EnGo* this, GlobalContext* globalCtx) { + if (this->unk_3F4 == 0) { + this->unk_38C = &GET_PLAYER(globalCtx)->actor; + } + + func_80A12E80(this, globalCtx); + + if (this->unk_390 & 8) { + this->unk_390 &= ~0x40; + this->unk_390 |= 0x10; + func_80A12FE8(this, globalCtx); + } else if (this->unk_390 & 0x10) { + this->unk_390 &= ~0x10; + this->unk_3B0 = 0; + this->unk_3B2 = 0; + this->unk_3B4 = 0; + this->unk_3B6 = 0; + this->unk_3BA = 0x14; + } else if (DECR(this->unk_3BA) == 0) { + this->unk_390 |= 0x40; + this->unk_3BA = 0x14; + } + + return true; +} + +void func_80A132C8(EnGo* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); + + if ((fabsf(this->actor.playerHeightRel) > 20.0f) || (this->actor.xzDistToPlayer > 300.0f)) { + func_8013AED4(&this->unk_390, 3, 7); + } else if ((player->transformation != PLAYER_FORM_GORON) || (ABS_ALT(temp_v1) >= 0x1C70) || + (gSaveContext.weekEventReg[21] & 4) || (gSaveContext.weekEventReg[21] & 8)) { + func_8013AED4(&this->unk_390, 3, 7); + } else { + func_8013AED4(&this->unk_390, 4, 7); + } +} + +void func_80A133A8(EnGo* this, GlobalContext* globalCtx) { + if (gSaveContext.weekEventReg[21] & 8) { + func_8013AED4(&this->unk_390, 3, 7); + } else { + func_8013AED4(&this->unk_390, 4, 7); + } +} + +Actor* func_80A13400(EnGo* this, GlobalContext* globalCtx) { + Actor* actor; + Actor* retActor = NULL; + + while (true) { + actor = SubS_FindActor(globalCtx, retActor, ACTORCAT_NPC, ACTOR_EN_GO); + retActor = actor; + + if ((actor != NULL) && ((EnGo*)actor != this) && (ENGO_GET_F(actor) == ENGO_F_4) && + (ENGO_GET_70(actor) == ENGO_70_0)) { + return retActor; + } + + if (actor == NULL) { + break; + } + + actor = actor->next; + if (actor == NULL) { + break; + } + retActor = actor; + } + + return NULL; +} + +void func_80A134B0(EnGo* this, GlobalContext* globalCtx, s32 arg2) { + if ((gSaveContext.weekEventReg[18] & 0x80) || (globalCtx->actorCtx.unk5 & 1) || arg2) { + this->colliderSphere.dim.modelSphere.radius = 300; + } else { + this->colliderSphere.dim.modelSphere.radius = 380; + } +} + +s32 func_80A134F4(EnGo* this, s16 arg1) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } else if (ActorCutscene_GetCanPlayNext(arg1)) { + ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); + return true; + } + ActorCutscene_SetIntentToPlay(arg1); + return false; +} + +s32 func_80A13564(EnGo* this, f32 arg1, f32 arg2, s32 arg3) { + s32 pad; + f32 temp_f0 = 1.0f; + f32 temp_f14 = this->actor.velocity.y + this->actor.gravity; + s32 ret; + + if (this->actor.bgCheckFlags & 2) { + ret = true; + } else { + if (temp_f14 > 0.0f) { + temp_f0 = temp_f14 / arg1; + this->actor.shape.rot.x += (s16)(9100.0f * temp_f0); + this->unk_3AE = 0; + } else if ((s32)this->actor.velocity.y == 0) { + if (arg3 >= this->unk_3AE) { + temp_f0 = (f32)this->unk_3AE / arg3; + } else { + this->actor.gravity = -6.0f; + } + this->unk_3AE++; + } else if (this->unk_3AE == 0) { + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + temp_f0 = temp_f14 / arg1; + } + ret = false; + } + + this->unk_3A8 = (1.0f - temp_f0) * arg2; + this->actor.scale.x = this->unk_3A4 - this->unk_3A8; + this->actor.scale.y = this->unk_3A4 + this->unk_3A8; + + if (this->actor.scale.y < this->actor.scale.x) { + this->actor.scale.z = this->actor.scale.x; + } else { + this->actor.scale.z = this->actor.scale.y; + } + return ret; +} + +void func_80A136B8(GlobalContext* globalCtx, s16 arg1, s16 arg2, s16 arg3) { + s16 sp26 = Quake_Add(Play_GetCamera(globalCtx, MAIN_CAM), 3); + + Quake_SetCountdown(sp26, arg3); + Quake_SetSpeed(sp26, arg1); + Quake_SetQuakeValues(sp26, arg2, 0, 0, 0); +} + +void func_80A13728(EnGo* this, GlobalContext* globalCtx) { + func_80A136B8(globalCtx, 0x6C77, 7, 20); + globalCtx->actorCtx.unk2 = 4; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 0); + EffectSsBlast_SpawnWhiteShockwave(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f); +} + +void func_80A137C0(EnGo* this, GlobalContext* globalCtx, f32 arg2, f32 arg3) { + u32 frames1; + u32 frames2; + + if (this->unk_390 & 0x400) { + Matrix_StatePush(); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_Scale(arg2 * 0.7f, arg2 * 0.8f, arg2, MTXMODE_APPLY); + func_800B8118(&this->actor, globalCtx, 0); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + frames1 = globalCtx->gameplayFrames % 256; + frames2 = (globalCtx->gameplayFrames * 2) % 256; + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, frames1, 0x20, 0x10, 1, 0, frames2, 0x40, 0x20)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, (u8)arg3); + gSPDisplayList(POLY_XLU_DISP++, &gameplay_keep_DL_050D10); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePop(); + } +} + +void func_80A139E4(EnGo* this) { + static Vec3f D_80A16698 = { 0.0f, 0.06f, 0.0f }; + Vec3f sp54; + Vec3f sp48; + s16 sp46 = Rand_ZeroOne() * 360.0f * 182.0f; + + Math_Vec3f_Copy(&sp54, &gZeroVec3f); + sp54.z = 28.0f; + Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, sp46, &sp54, &sp48); + sp48.y = (Rand_ZeroOne() * 10.0f) + 4.0f; + sp48.y += this->actor.floorHeight; + func_80A10FD0(&this->unk_3F8[16], sp48, D_80A16698, gZeroVec3f, 0.01f, 0.002f, 16); +} + +s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s32 ret = false; + + switch (this->unk_3C0) { + case 0: + this->unk_3B8 = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + if (func_80A134F4(this, this->unk_3B8)) { + this->unk_3C4 = 1; + this->unk_3C0 = 1; + } else { + break; + } + + case 1: + if (ActorCutscene_GetCurrentIndex() != this->unk_3B8) { + this->unk_3B8 = ActorCutscene_GetAdditionalCutscene(this->unk_3B8); + this->unk_3C0 = 2; + } else { + break; + } + + case 2: + if (func_80A134F4(this, this->unk_3B8)) { + this->unk_3C0 = 3; + } else { + break; + } + + case 3: + if (ActorCutscene_GetCanPlayNext(0x7C)) { + ActorCutscene_StartAndSetUnkLinkFields(0x7C, NULL); + this->unk_3C0 = 4; + } else if (ActorCutscene_GetCurrentIndex() == this->unk_3B8) { + ActorCutscene_SetIntentToPlay(0x7C); + } + } + + switch (this->unk_3C4) { + case 1: + func_80A12C48(this, globalCtx, 4); + this->unk_390 |= 0x4000; + this->unk_3C4++; + break; + + case 2: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_390 &= ~0x4000; + this->unk_390 &= ~0x80; + this->unk_390 |= 0x200; + this->unk_3C4++; + this->unk_3C2 = 0; + this->actor.shape.yOffset = 14.0f; + } + break; + + case 3: + this->unk_3C2++; + if (this->unk_3C2 >= 10) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_JUMP); + this->actor.velocity.y = 10.0f; + this->actor.gravity = -1.0f; + this->unk_3C4++; + } + break; + + case 4: + if (func_80A13564(this, 10.0f, 0.004f, 6)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_LAND_BIG); + func_80A13728(this, globalCtx); + this->unk_3C4++; + this->unk_3C2 = 0; + gSaveContext.weekEventReg[88] |= 0x40; + } + break; + + case 5: + this->unk_3C2++; + if (this->unk_3C2 >= 10) { + func_80A12C48(this, globalCtx, 5); + this->actor.shape.rot.x = 0; + this->unk_390 &= ~0x200; + this->unk_390 |= 0x80; + this->unk_3C4++; + } + break; + + case 6: + this->unk_3C0++; + if (this->unk_3C0 >= 65) { + switch (player->transformation) { + case 4: + gSaveContext.weekEventReg[88] |= 0x80; + break; + + case 1: + gSaveContext.weekEventReg[89] |= 4; + break; + + case 2: + gSaveContext.weekEventReg[89] |= 2; + break; + + case 3: + gSaveContext.weekEventReg[89] |= 1; + break; + } + ret = true; + } + break; + } + + Actor_MoveWithGravity(&this->actor); + return ret; +} + +s32 func_80A13E80(EnGo* this, GlobalContext* globalCtx) { + static Vec3f D_80A166A4 = { 0.0f, 200.0f, 280.0f }; + s32 pad; + Vec3f sp48; + s32 ret = false; + + switch (this->unk_3C0) { + case 0: + this->unk_3B8 = this->actor.cutscene; + if (func_80A134F4(this, this->unk_3B8)) { + this->unk_3C0++; + } + break; + + case 1: + func_80A12C48(this, globalCtx, 7); + this->unk_3C0++; + + case 2: + if (Animation_OnFrame(&this->skelAnime, 16.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_HAND_HIT); + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A12C48(this, globalCtx, 1); + Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80A166A4, &sp48); + gSaveContext.powderKegTimer = 2400; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, sp48.x, sp48.y, sp48.z, 1, 0, 0, 0); + func_80A134B0(this, globalCtx, 1); + this->unk_3C2 = 0; + this->unk_3C0++; + } + break; + + case 3: + if (this->unk_3C2 >= 60) { + ActorCutscene_Stop(this->unk_3B8); + this->unk_3C2 = 0; + this->unk_3C0 = 0; + ret = true; + } else { + this->unk_3C2++; + } + break; + } + + return ret; +} + +void func_80A14018(EnGo* this, GlobalContext* globalCtx) { + static Vec3f D_80A166B0 = { 0.0f, 0.0f, 40.0f }; + static s32 D_80A166BC[] = { 11, 10, 12, 13, 14, 17 }; + Vec3f sp2C; + s32 phi_v0 = ENGO_GET_70(&this->actor) % 6; + + if (phi_v0 < 4) { + phi_v0 = ((gSaveContext.eventInf[2] & 0xF) + phi_v0) % 4; + } + + func_80A12C48(this, globalCtx, D_80A166BC[phi_v0]); + + if (this->unk_3DC == 14) { + Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80A166B0, &sp2C); + Math_Vec3f_Copy(&this->actor.world.pos, &sp2C); + } + this->actor.flags &= ~1; + Actor_SetScale(&this->actor, this->unk_3A4); + this->unk_3EC = 0; + this->unk_390 = 0; + this->unk_390 |= (0x40 | 0x20); + this->actor.gravity = 0.0f; +} + +void func_80A14104(EnGo* this, GlobalContext* globalCtx) { + static s32 D_80A166D4[] = { 15, 16 }; + s16 temp; + + func_80A12C48(this, globalCtx, D_80A166D4[ENGO_GET_70(&this->actor) % 2]); + temp = Rand_ZeroOne() * this->skelAnime.endFrame; + this->skelAnime.curFrame = temp; + this->actor.flags &= ~1; + Actor_SetScale(&this->actor, this->unk_3A4); + this->unk_3EC = 0; + this->unk_390 = 0; + this->unk_390 |= 0x40; + this->unk_390 |= 0x20; + this->actor.gravity = 0.0f; +} + +void func_80A141D4(EnGo* this, GlobalContext* globalCtx) { + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit1); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->unk_3DC = -1; + func_80A12C48(this, globalCtx, 5); + this->unk_3EC = 0; + this->unk_39C = (this->unk_3A4 / 0.01f) * 0.9f; + this->unk_3BE = 2; + this->unk_390 = 0; + this->unk_390 |= 0x40; + this->unk_390 |= 0x400; + this->unk_3A0 = 100.0f; +} + +void func_80A1428C(EnGo* this, GlobalContext* globalCtx) { + s16 temp; + Vec3f sp30; + Vec3f sp24; + + Math_Vec3f_Copy(&sp30, &this->actor.world.pos); + if (this->unk_284 != NULL) { + this->actor.flags &= ~0x2000000; + func_8013C8B8(this->unk_284, 0, &sp24); + temp = Math_Vec3f_Yaw(&sp30, &sp24); + this->actor.shape.rot.y = temp; + this->actor.world.rot.y = temp; + } + this->unk_390 = 0; + this->unk_390 |= 0x100; + this->actor.shape.yOffset = 46.0f; + this->actor.gravity = -1.0f; +} + +void func_80A14324(EnGo* this, GlobalContext* globalCtx) { + func_80A12C48(this, globalCtx, 8); + Actor_SetScale(&this->actor, this->unk_3A4); + this->unk_390 = 0; + this->actor.gravity = -1.0f; + func_8013AED4(&this->unk_390, 3, 7); + this->unk_3EC = 0; + this->unk_390 |= 0x40; + this->unk_3BC = 0; + this->unk_3BE = 4; + this->unk_39C = 0.0f; + this->unk_3A0 = 0.0f; +} + +void func_80A143A8(EnGo* this, GlobalContext* globalCtx) { + func_80A12C48(this, globalCtx, 5); + Actor_SetScale(&this->actor, this->unk_3A4); + this->unk_390 = 0; + this->actor.gravity = -1.0f; + func_8013AED4(&this->unk_390, 3, 7); + this->unk_3EC = 0; + this->unk_390 |= 0x40; + this->unk_390 |= 0x20; + this->unk_3BC = 0; + this->unk_3BE = 0; + this->unk_39C = 0.0f; + this->unk_3A0 = 0.0f; +} + +void func_80A14430(EnGo* this, GlobalContext* globalCtx) { + if (((gSaveContext.entranceIndex == 0xD000) || (gSaveContext.entranceIndex == 0xD020)) && + (gSaveContext.weekEventReg[33] & 0x80)) { + func_80A14018(this, globalCtx); + this->actionFunc = func_80A149B0; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80A1449C(EnGo* this, GlobalContext* globalCtx) { + if ((gSaveContext.entranceIndex == 0xD010) || (gSaveContext.entranceIndex == 0x1C00)) { + func_80A14104(this, globalCtx); + this->actionFunc = func_80A149B0; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80A144F4(EnGo* this, GlobalContext* globalCtx) { + if (gSaveContext.day >= 2) { + this->unk_284 = func_8013BEDC(globalCtx, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); + if (this->unk_284 != NULL) { + this->unk_3E4 = 1; + } + func_80A1428C(this, globalCtx); + this->actionFunc = func_80A153FC; + this->unk_3D8 = func_80A13B1C; + } else { + func_80A143A8(this, globalCtx); + this->actionFunc = func_80A149B0; + this->unk_3D8 = func_80A13B1C; + } +} + +void func_80A145AC(EnGo* this, GlobalContext* globalCtx) { + if ((ENGO_GET_70(&this->actor) == ENGO_70_1) && + (((globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && + (globalCtx->csCtx.unk_12 == 0)) || + !(gSaveContext.weekEventReg[21] & 8))) { + this->actor.child = func_80A13400(this, globalCtx); + this->actor.child->child = &this->actor; + func_80A141D4(this, globalCtx); + this->actionFunc = func_80A14E14; + } else { + func_80A143A8(this, globalCtx); + this->actionFunc = func_80A149B0; + } +} + +void func_80A14668(EnGo* this, GlobalContext* globalCtx) { + if (!(gSaveContext.weekEventReg[22] & 4)) { + func_80A14324(this, globalCtx); + this->actionFunc = func_80A149B0; + } else { + func_80A143A8(this, globalCtx); + this->actionFunc = func_80A149B0; + } +} + +void func_80A146CC(EnGo* this, GlobalContext* globalCtx) { + func_80A134B0(this, globalCtx, 0); + func_80A12C48(this, globalCtx, 0); + this->unk_3A4 *= 5.0f; + Actor_SetScale(&this->actor, this->unk_3A4); + this->actor.flags &= ~1; + this->actor.targetMode = 3; + this->unk_390 = 0; + this->actor.gravity = -1.0f; + func_8013AED4(&this->unk_390, 3, 7); + this->unk_390 |= 0x40; + this->unk_390 |= 0x20; + this->unk_3D8 = func_80A13E80; + this->actionFunc = func_80A149B0; +} + +void func_80A14798(EnGo* this, GlobalContext* globalCtx) { + s32 sp38[2] = { 0x0000003E, 0x00000F64 }; + + if ((this->unk_288 < 0) || func_8013D8DC(this->unk_288, globalCtx) || (this->unk_289 < 0) || + func_8013D8DC(this->unk_289, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, + this->morphTable, 18); + + this->unk_3DC = -1; + func_80A12C48(this, globalCtx, 2); + this->actor.draw = func_80A15FEC; + + Collider_InitAndSetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit2); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Effect_Add(globalCtx, &this->unk_3E8, 4, 0, 0, &sp38); + + this->actor.targetMode = 1; + this->unk_3A4 = 0.01f; + this->unk_3D8 = NULL; + + switch (ENGO_GET_F(&this->actor)) { + case ENGO_F_1: + func_80A14430(this, globalCtx); + break; + + case ENGO_F_2: + func_80A1449C(this, globalCtx); + break; + + case ENGO_F_3: + func_80A144F4(this, globalCtx); + break; + + case ENGO_F_4: + func_80A145AC(this, globalCtx); + break; + + case ENGO_F_5: + case ENGO_F_6: + case ENGO_F_7: + func_80A14668(this, globalCtx); + break; + + case ENGO_F_8: + func_80A146CC(this, globalCtx); + break; + + default: + Actor_MarkForDeath(&this->actor); + break; + } + } +} + +void func_80A149B0(EnGo* this, GlobalContext* globalCtx) { + s16 sp26 = this->actor.world.rot.y; + + if ((ENGO_GET_F(&this->actor) == ENGO_F_2) && (gSaveContext.entranceIndex == 0xD010)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_CHEER - SFX_FLAG); + } else if (ENGO_GET_F(&this->actor) != ENGO_F_8) { + if (func_80A1222C(this, globalCtx)) { + func_8013AED4(&this->unk_390, 0, 7); + this->unk_3EC = 1; + this->actionFunc = func_80A14B30; + } else if (ENGO_GET_F(&this->actor) == ENGO_F_4) { + switch (ENGO_GET_70(&this->actor)) { + case ENGO_70_0: + func_80A132C8(this, globalCtx); + break; + + case ENGO_70_1: + func_80A133A8(this, globalCtx); + break; + } + } else if (ENGO_GET_F(&this->actor) == ENGO_F_1) { + if (ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)) < 0x3FFC) { + func_8013AED4(&this->unk_390, 3, 7); + } else { + func_8013AED4(&this->unk_390, 0, 7); + } + } + } + Math_ApproachS(&this->actor.shape.rot.y, sp26, 4, 0x2AA8); +} + +void func_80A14B30(EnGo* this, GlobalContext* globalCtx) { + s16 sp26 = this->actor.world.rot.y; + u16 sfxId; + + if (func_80A1222C(this, globalCtx)) { + this->unk_3EC = 1; + } + + if (this->unk_390 & 0x4000) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_390 &= ~0x4000; + this->unk_390 |= 0x200; + if (this->unk_3EC != 0) { + this->unk_3AE = 0; + } + this->actor.shape.yOffset = 14.0f; + } + } else if (this->unk_390 & 0x8000) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_390 |= 0x80; + this->unk_390 &= ~0x8000; + } + } else if (this->unk_390 & 0x200) { + if ((this->actor.xzDistToPlayer < 160.0f) && (this->actor.playerHeightRel < 20.0f) && (this->unk_3EC == 0)) { + func_80A12C48(this, globalCtx, 3); + this->unk_390 &= ~0x80; + this->unk_390 &= ~0x200; + this->unk_390 |= 0x8000; + this->actor.shape.yOffset = 0.0f; + } else if ((this->unk_3EC != 0) && (gSaveContext.weekEventReg[22] & 4)) { + this->actor.scale.x = this->unk_3A4 - (Math_SinS(this->unk_3AE) * 0.001f); + this->actor.scale.y = (Math_SinS(this->unk_3AE) * 0.001f) + this->unk_3A4; + this->actor.scale.z = (Math_SinS(this->unk_3AE) * 0.001f) + this->unk_3A4; + if (this->unk_3AE == 0) { + this->unk_3EC = -this->unk_3EC; + if (this->unk_3EC > 0) { + sfxId = NA_SE_EN_GOLON_SNORE1; + } else { + sfxId = NA_SE_EN_GOLON_SNORE2; + } + Actor_PlaySfxAtPos(&this->actor, sfxId); + } + this->unk_3AE += 0x400; + this->actor.shape.yOffset = (this->actor.scale.y / this->unk_3A4) * 14.0f; + func_8013AED4(&this->unk_390, 3, 7); + } + } else if ((this->actor.xzDistToPlayer >= 240.0f) || (this->actor.playerHeightRel >= 20.0f) || + (this->unk_3EC != 0)) { + func_80A12C48(this, globalCtx, 4); + this->unk_390 &= ~0x80; + this->unk_390 &= ~0x200; + this->unk_390 |= 0x4000; + this->actor.shape.yOffset = 0.0f; + } + + func_8013D9C8(globalCtx, &this->unk_3CE[0], &this->unk_3C8[0], 3); + Math_ApproachS(&this->actor.shape.rot.y, sp26, 4, 0x2AA8); +} + +void func_80A14E14(EnGo* this, GlobalContext* globalCtx) { + Actor* actor = this->colliderCylinder.base.ac; + + if ((this->unk_390 & 0x1000) && (((actor != NULL) && (actor->id == ACTOR_OBJ_AQUA) && (actor->params & 1)) || + (this->actor.colChkInfo.damageEffect == 2))) { + this->actionFunc = func_80A14E74; + } +} + +void func_80A14E74(EnGo* this, GlobalContext* globalCtx) { + if (func_80A134F4(this, this->actor.cutscene)) { + this->actionFunc = func_80A14EB0; + } +} + +void func_80A14EB0(EnGo* this, GlobalContext* globalCtx) { + EnGo* sp24 = (EnGo*)this->actor.child; + + if ((s32)(this->unk_39C * 3.0f) != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); + Math_ApproachF(&this->unk_39C, 0.0f, 0.02f, 1.0f); + this->unk_3A0 = (this->unk_39C / 0.9f) * 100.0f; + func_80A139E4(this); + } else { + ActorCutscene_Stop(this->actor.cutscene); + func_80A143A8(this, globalCtx); + if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (ENGO_GET_70(&this->actor) == ENGO_70_1)) { + func_8013AED4(&this->unk_390, 4, 7); + func_80A143A8(sp24, globalCtx); + sp24->actionFunc = func_80A149B0; + } + this->actionFunc = func_80A149B0; + } +} + +void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { + s32 sp38[] = { + 0, 2, 6, 20, 18, 5, 5, 15, + }; + u16 sp36 = 0; + s32 sp30; + u32 sp2C; + + switch (ENGO_GET_70(&this->actor)) { + case ENGO_70_0: + sp36 = 0x80; + break; + + case ENGO_70_1: + sp36 = 0x81; + break; + } + + if ((sp36 == 0x80) || (sp36 == 0x81)) { + if (func_800EE29C(globalCtx, sp36)) { + sp2C = func_800EE200(globalCtx, sp36); + sp30 = globalCtx->csCtx.npcActions[sp2C]->unk0; + + if (this->unk_394 != (u8)sp30) { + this->unk_394 = sp30; + func_80A12C48(this, globalCtx, sp38[sp30]); + this->unk_390 = 0; + this->unk_390 |= 0x20; + this->unk_3BE = 0; + this->unk_39C = 0.0f; + this->unk_3A0 = 0.0f; + + switch (sp30) { + case 1: + this->unk_390 |= 0x80; + this->skelAnime.curFrame = this->skelAnime.endFrame; + break; + + case 5: + case 6: + func_80A141D4(this, globalCtx); + break; + } + } + + switch (this->unk_394) { + case 3: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (this->unk_3DC == 20)) { + func_80A12C48(this, globalCtx, 21); + } + break; + + case 4: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (this->unk_3DC == 18)) { + func_80A12C48(this, globalCtx, 19); + } + break; + + case 6: + if ((s32)(this->unk_39C * 3.0f) != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); + Math_ApproachF(&this->unk_39C, 0.0f, 0.02f, 1.0f); + this->unk_3A0 = (this->unk_39C / 0.9f) * 100.0f; + func_80A139E4(this); + } else if (this->unk_390 & 0x400) { + func_80A143A8(this, globalCtx); + } + break; + } + + if (sp36 == 0x80) { + switch (globalCtx->csCtx.frames) { + case 55: + case 100: + case 130: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_COLD); + break; + + case 185: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_WAKE_UP); + break; + + case 250: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_EYE_BIG); + break; + + case 465: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IWAIGORON_SOLO); + break; + + case 490: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_VOICE_EATFULL); + break; + } + } else if (sp36 == 0x81) { + switch (globalCtx->csCtx.frames) { + case 360: + case 390: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_COLD); + break; + + case 430: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_WAKE_UP); + break; + + case 450: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_EYE_BIG); + break; + + case 480: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_VOICE_EATFULL); + break; + } + } + + func_8013D9C8(globalCtx, this->unk_3CE, this->unk_3C8, 3); + func_800EDF24(&this->actor, globalCtx, sp2C); + } + } +} + +void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { + Vec3s* sp5C; + Vec3f sp50; + Vec3f sp44; + + if ((this->unk_390 & 0x1000) && (this->actor.colChkInfo.damageEffect == 0xF)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SNOWBALL_BROKEN); + + this->actor.flags &= ~0x10; + this->actor.flags |= 0x2000000; + + func_80A118F8(this->unk_3F8, this->actor.world.pos); + this->actor.shape.rot.x = 0; + this->actor.speedXZ = 0.0f; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_COLD); + + if (gSaveContext.day == 3) { + func_80A141D4(this, globalCtx); + this->actionFunc = func_80A14E14; + } else { + func_80A143A8(this, globalCtx); + this->actionFunc = func_80A149B0; + } + } else if (this->unk_284 != NULL) { + if (this->unk_390 & 0x800) { + func_800B8E58(GET_PLAYER(globalCtx), NA_SE_PL_BODY_HIT); + func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); + } + + sp5C = Lib_SegmentedToVirtual(this->unk_284->points); + if (func_8013BD40(&this->actor, this->unk_284, this->unk_3E4)) { + if (this->unk_3E4 >= (this->unk_284->count - 1)) { + this->unk_3E4 = 0; + } else { + this->unk_3E4++; + } + } + + Math_Vec3s_ToVec3f(&sp44, &sp5C[this->unk_3E4]); + Math_Vec3f_Copy(&sp50, &this->actor.world.pos); + Math_ApproachS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&sp50, &sp44), 4, 0x38E); + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (this->actor.bgCheckFlags & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BIGBALL_ROLL - SFX_FLAG); + func_800AE930(&globalCtx->colCtx, Effect_GetByIndex(this->unk_3E8), &this->actor.world.pos, 18.0f, + this->actor.shape.rot.y, this->actor.floorPoly, this->actor.floorBgId); + } else { + func_800AEF44(Effect_GetByIndex(this->unk_3E8)); + } + + this->actor.speedXZ = 4.0f; + this->actor.shape.rot.x += (s16)(this->actor.speedXZ * 546.0f); + Actor_MoveWithGravity(&this->actor); + } +} + +s32* func_80A15684(EnGo* this, GlobalContext* globalCtx) { + static s32 D_80A16704[] = { + D_80A16100, + D_80A16164, + }; + + if (this->unk_3EC != 0) { + return D_80A1640C; + } + + if (ENGO_GET_F(&this->actor) == ENGO_F_1) { + switch (ENGO_GET_70(&this->actor) % 6) { + case ENGO_70_0: + return D_80A163BC; + case ENGO_70_1: + return D_80A163CC; + case ENGO_70_2: + return D_80A163DC; + case ENGO_70_3: + return D_80A163EC; + case ENGO_70_4: + return D_80A163FC; + case ENGO_70_5: + return D_80A163FC; + } + } + + switch (ENGO_GET_F(&this->actor)) { + case ENGO_F_3: + return D_80A16350; + case ENGO_F_4: + return D_80A16704[ENGO_GET_70(&this->actor)]; + case ENGO_F_5: + return D_80A16208; + case ENGO_F_6: + return D_80A16254; + case ENGO_F_7: + return D_80A16210; + case ENGO_F_8: + return D_80A16280; + default: + return D_80A16208; + } +} + +void func_80A157C4(EnGo* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + + if (!func_8010BF58(&this->actor, globalCtx, func_80A15684(this, globalCtx), this->unk_3D8, &this->unk_28C)) { + if ((ENGO_GET_F(&this->actor) != ENGO_F_1) && !(this->unk_390 & 0x200)) { + Math_Vec3f_Copy(&sp40, &this->unk_38C->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); + } + func_8013D9C8(globalCtx, this->unk_3CE, this->unk_3C8, 3); + return; + } + + if ((ENGO_GET_F(&this->actor) == ENGO_F_5) || (ENGO_GET_F(&this->actor) == ENGO_F_6) || + (ENGO_GET_F(&this->actor) == ENGO_F_7)) { + this->unk_3BC = 0; + this->unk_390 &= ~0x20; + this->unk_3BE = 4; + } + + this->unk_390 &= ~0x8; + func_8013AED4(&this->unk_390, 3, 7); + this->unk_28C = 0; + this->unk_390 |= 0x40; + this->actionFunc = this->unk_18C; +} + +void EnGo_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGo* this = THIS; + + this->unk_288 = func_8013D924(OBJECT_TAISOU, globalCtx); + this->unk_289 = func_8013D924(OBJECT_HAKUGIN_DEMO, globalCtx); + this->actionFunc = func_80A14798; +} + +void EnGo_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGo* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroySphere(globalCtx, &this->colliderSphere); + Effect_Destroy(globalCtx, this->unk_3E8); +} + +void EnGo_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGo* this = THIS; + f32 phi_f0; + + func_80A12868(this, globalCtx); + if (!func_80A12774(this, globalCtx)) { + func_80A12954(this, globalCtx); + } + + this->actionFunc(this, globalCtx); + + if (!(this->unk_390 & 0x400)) { + func_80A12D6C(this); + func_80A12A64(this, globalCtx); + func_80A131F8(this, globalCtx); + func_80A12B78(this, globalCtx); + } + + if (!(this->unk_390 & 0x100) && !(this->unk_390 & 0x200) && !(this->unk_390 & 0x400)) { + if (ENGO_GET_F(&this->actor) == ENGO_F_8) { + phi_f0 = this->colliderSphere.dim.worldSphere.radius + 60; + } else { + phi_f0 = this->colliderCylinder.dim.radius + 40; + } + func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, 0, this->unk_390 & 7); + } else if ((this->unk_390 & 0x200) && (this->unk_3EC != 0)) { + phi_f0 = this->colliderCylinder.dim.radius + 40; + func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, 0, this->unk_390 & 7); + } + + if ((ENGO_GET_F(&this->actor) != ENGO_F_8) && (ENGO_GET_F(&this->actor) != ENGO_F_2) && + (ENGO_GET_F(&this->actor) != ENGO_F_1)) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + } + + func_80A122EC(this); + func_80A126BC(this, globalCtx); + func_80A1203C(this); +} + +void func_80A15B80(EnGo* this, GlobalContext* globalCtx) { + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + + if (this->unk_390 & 0x100) { + Matrix_Scale(this->actor.scale.x * 8.0f, this->actor.scale.y * 8.0f, this->actor.scale.z * 8.0f, MTXMODE_APPLY); + } else { + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + } + + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, (this->unk_390 & 0x100) ? object_oF1d_map_DL_001560 : object_oF1d_map_DL_0091A8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnGo* this = THIS; + Vec3f sp30; + s32 idx; + + if ((ENGO_GET_F(&this->actor) == ENGO_F_8) && (limbIndex == 10)) { + limbIndex = limbIndex; + Matrix_GetStateTranslation(&sp30); + sp30.y = this->actor.world.pos.y; + Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); + } + + switch (limbIndex) { + case 10: + idx = 0; + break; + + case 11: + idx = 1; + break; + + case 14: + idx = 2; + break; + + default: + idx = 9; + break; + } + + if ((this->unk_390 & 0x80) && (idx < 9)) { + rot->y += (s16)(Math_SinS(this->unk_3CE[idx]) * 200.0f); + rot->z += (s16)(Math_CosS(this->unk_3C8[idx]) * 200.0f); + } + return false; +} + +void EnGo_UnkDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnGo* this = THIS; + u16 temp_v0; + s32 phi_v1; + s32 phi_v0; + + if (this->unk_390 & 0x40) { + phi_v1 = false; + } else { + phi_v1 = true; + } + + if (this->unk_390 & 0x10) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (!phi_v1) { + phi_v0 = false; + } + + switch (limbIndex) { + case 17: + func_8013AD9C(this->unk_3B0 + this->unk_3B4 + 0x4000, + this->unk_3B2 + this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_290, + &this->unk_2A8, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_2A8.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_2A8.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_2A8.z, MTXMODE_APPLY); + Matrix_StatePush(); + break; + + case 10: + func_8013AD9C(this->unk_3B4 + 0x4000, this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_29C, + &this->unk_2AE, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_2AE.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_2AE.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_2AE.z, MTXMODE_APPLY); + Matrix_StatePush(); + break; + } +} + +void func_80A15FEC(Actor* thisx, GlobalContext* globalCtx) { + static UNK_TYPE D_80A1670C[] = { + &object_oF1d_map_Tex_010438, &object_oF1d_map_Tex_010C38, &object_oF1d_map_Tex_011038, + &object_oF1d_map_Tex_010C38, &object_oF1d_map_Tex_010838, + }; + EnGo* this = THIS; + + if (!(this->unk_390 & 0x300)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A1670C[this->unk_3BE])); + + if (this->unk_3DC == 14) { + Matrix_InsertTranslation(0.0f, 0.0f, -4000.0f, MTXMODE_APPLY); + } + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnGo_OverrideLimbDraw, NULL, EnGo_UnkDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + func_80A15B80(this, globalCtx); + } + func_80A137C0(this, globalCtx, this->unk_39C, this->unk_3A0); + func_80A1213C(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.h b/src/overlays/actors/ovl_En_Go/z_en_go.h index 08363e8221..ab7f068e15 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.h +++ b/src/overlays/actors/ovl_En_Go/z_en_go.h @@ -7,11 +7,98 @@ struct EnGo; typedef void (*EnGoActionFunc)(struct EnGo*, GlobalContext*); +#define ENGO_GET_F(thisx) (((thisx)->params & 0xF) & 0xFF) +#define ENGO_GET_70(thisx) ((((thisx)->params & 0x70) >> 4) & 0xFF) +#define ENGO_GET_7F80(thisx) ((((thisx)->params & 0x7F80) >> 7) & 0xFF) + +enum { + /* 0 */ ENGO_F_0, + /* 1 */ ENGO_F_1, + /* 2 */ ENGO_F_2, + /* 3 */ ENGO_F_3, + /* 4 */ ENGO_F_4, + /* 5 */ ENGO_F_5, + /* 6 */ ENGO_F_6, + /* 7 */ ENGO_F_7, + /* 8 */ ENGO_F_8, +}; + +enum { + /* 0 */ ENGO_70_0, + /* 1 */ ENGO_70_1, + /* 2 */ ENGO_70_2, + /* 3 */ ENGO_70_3, + /* 4 */ ENGO_70_4, + /* 5 */ ENGO_70_5, +}; + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; + /* 0x02 */ u8 unk_02; + /* 0x04 */ Vec3s unk_04; + /* 0x0A */ Vec3s unk_0A; + /* 0x10 */ Vec3f unk_10; + /* 0x1C */ Vec3f unk_1C; + /* 0x28 */ Vec3f unk_28; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; +} EnGoStruct; // size = 0x3C; + typedef struct EnGo { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnGoActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x9EC]; + /* 0x018C */ EnGoActionFunc unk_18C; + /* 0x0190 */ EnGoActionFunc unk_190; + /* 0x0194 */ ColliderCylinder colliderCylinder; + /* 0x01E0 */ UNK_TYPE1 unk1E0[0x4C]; + /* 0x022C */ ColliderSphere colliderSphere; + /* 0x0284 */ Path* unk_284; + /* 0x0288 */ s8 unk_288; + /* 0x0289 */ s8 unk_289; + /* 0x028C */ s32 unk_28C; + /* 0x0290 */ Vec3f unk_290; + /* 0x029C */ Vec3f unk_29C; + /* 0x02A8 */ Vec3s unk_2A8; + /* 0x02AE */ Vec3s unk_2AE; + /* 0x02B4 */ Vec3s jointTable[18]; + /* 0x0320 */ Vec3s morphTable[18]; + /* 0x038C */ Actor* unk_38C; + /* 0x0390 */ u16 unk_390; + /* 0x0392 */ u16 unk_392; + /* 0x0394 */ u8 unk_394; + /* 0x0398 */ f32 unk_398; + /* 0x039C */ f32 unk_39C; + /* 0x03A0 */ f32 unk_3A0; + /* 0x03A4 */ f32 unk_3A4; + /* 0x03A8 */ f32 unk_3A8; + /* 0x03AC */ UNK_TYPE1 unk3AC[0x2]; + /* 0x03AE */ s16 unk_3AE; + /* 0x03B0 */ s16 unk_3B0; + /* 0x03B2 */ s16 unk_3B2; + /* 0x03B4 */ s16 unk_3B4; + /* 0x03B6 */ s16 unk_3B6; + /* 0x03B8 */ s16 unk_3B8; + /* 0x03BA */ s16 unk_3BA; + /* 0x03BC */ s16 unk_3BC; + /* 0x03BE */ s16 unk_3BE; + /* 0x03C0 */ s16 unk_3C0; + /* 0x03C2 */ s16 unk_3C2; + /* 0x03C4 */ s16 unk_3C4; + /* 0x03C6 */ s16 unk_3C6; + /* 0x03C8 */ s16 unk_3C8[3]; + /* 0x03CE */ s16 unk_3CE[3]; + /* 0x03D4 */ s16 unk_3D4; + /* 0x03D8 */ void* unk_3D8; + /* 0x03DC */ s32 unk_3DC; + /* 0x03E0 */ UNK_TYPE1 unk3E0[0x4]; + /* 0x03E4 */ s32 unk_3E4; + /* 0x03E8 */ s32 unk_3E8; + /* 0x03EC */ s32 unk_3EC; + /* 0x03F0 */ s32 unk_3F0; + /* 0x03F4 */ s32 unk_3F4; + /* 0x03F8 */ EnGoStruct unk_3F8[32]; } EnGo; // size = 0xB78 extern const ActorInit En_Go_InitVars; diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index 92a2270197..7fbf4213f6 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -119,7 +119,7 @@ static Vec3f D_80942E60 = { 0.0f, 1.0f, 0.0f }; static Vec3f D_80942E6C = { 0.0f, 0.0f, 1.0f }; static InitChainEntry sInitChain[] = { - ICHAIN_F32_DIV1000(gravity, -900, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -26000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -900, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -26000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 160, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 350, ICHAIN_STOP), }; @@ -371,7 +371,7 @@ s32 func_8093F34C(EnGoroiwa* this) { f32 z; Math_StepToF(&this->actor.speedXZ, D_80942DFC[this->unk_1E4], 0.3f); - Actor_SetVelocityYRotationAndGravity(&this->actor); + Actor_UpdateVelocityWithGravity(&this->actor); temp_v0 = &this->unk_1D0[this->unk_1D8]; this->actor.velocity.y *= 0.97f; x = temp_v0->x; @@ -495,7 +495,7 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { func_8093EF54(globalCtx, &sp48, &D_80942E30[ENGOROIWA_GET_C000(&this->actor)], &D_80942E3C[ENGOROIWA_GET_C000(&this->actor)], this->actor.scale.x); } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BIGBALL_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BIGBALL_BOUND); } } } @@ -965,7 +965,7 @@ void func_80941060(EnGoroiwa* this, GlobalContext* globalCtx) { } void func_80941274(EnGoroiwa* this, GlobalContext* globalCtx) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_SNOWBALL_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_SNOWBALL_BROKEN); } void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -1001,7 +1001,7 @@ void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { } CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - ActorShape_Init(&this->actor.shape, 595.0f, func_800B3FC0, 9.4f); + ActorShape_Init(&this->actor.shape, 595.0f, ActorShadow_DrawCircle, 9.4f); this->actor.shape.shadowAlpha = 200; func_8093EB58(this, globalCtx); @@ -1190,7 +1190,7 @@ void func_80941A10(EnGoroiwa* this, GlobalContext* globalCtx) { func_80941DB4(this); } - func_800B8E58(&player->actor, NA_SE_PL_BODY_HIT); + func_800B8E58(player, NA_SE_PL_BODY_HIT); if ((sp34 == 1) || (sp34 == 2)) { this->unk_1CC = 50; @@ -1230,7 +1230,7 @@ void func_80941A10(EnGoroiwa* this, GlobalContext* globalCtx) { } if (this->actor.bgCheckFlags & 1) { - Audio_PlayActorSound2(&this->actor, D_80942E9C[this->unk_1E4][this->actor.home.rot.x & 1]); + Actor_PlaySfxAtPos(&this->actor, D_80942E9C[this->unk_1E4][this->actor.home.rot.x & 1]); } } } @@ -1239,7 +1239,7 @@ void func_80941DB4(EnGoroiwa* this) { this->actionFunc = func_80941E28; func_8093EAB0(this, 6); this->actor.gravity = -0.86f; - this->actor.minVelocityY = -15.0f; + this->actor.terminalVelocity = -15.0f; this->actor.speedXZ *= 0.15f; this->actor.velocity.y = 5.0f; this->unk_1C4 = 1.0f; @@ -1288,7 +1288,7 @@ void func_80941FA4(EnGoroiwa* this, GlobalContext* globalCtx) { if (func_8094156C(this, globalCtx) == 0) { if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & 0x80000)) { func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); - func_800B8E58(&player->actor, NA_SE_PL_BODY_HIT); + func_800B8E58(player, NA_SE_PL_BODY_HIT); if (((this->actor.home.rot.z & 3) == 1) || ((this->actor.home.rot.z & 3) == 2)) { this->unk_1CC = 50; } @@ -1316,7 +1316,7 @@ void func_809420F0(EnGoroiwa* this, GlobalContext* globalCtx) { if (func_8094156C(this, globalCtx) == 0) { if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & 0x80000)) { func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); - func_800B8E58(&player->actor, NA_SE_PL_BODY_HIT); + func_800B8E58(player, NA_SE_PL_BODY_HIT); if (((this->actor.home.rot.z & 3) == 1) || ((this->actor.home.rot.z & 3) == 2)) { this->unk_1CC = 50; } @@ -1481,7 +1481,7 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { sp50.y = this->actor.floorHeight; sp50.z = this->actor.world.pos.z; sp4C = (((Rand_ZeroOne() * 36.0f) + 250.0f) * this->actor.scale.x) + 10.0f; - func_800AE930(&globalCtx->colCtx, Effect_GetParams(this->unk_248), &sp50, sp4C, + func_800AE930(&globalCtx->colCtx, Effect_GetByIndex(this->unk_248), &sp50, sp4C, this->actor.world.rot.y, this->actor.floorPoly, this->actor.floorBgId); } sp48 = false; @@ -1491,7 +1491,7 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { } if (sp48) { - func_800AEF44(Effect_GetParams(this->unk_248)); + func_800AEF44(Effect_GetByIndex(this->unk_248)); } this->actionFunc(this, globalCtx); @@ -1592,7 +1592,7 @@ void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - func_800BDFC0(globalCtx, phi_fp); + Gfx_DrawDListOpa(globalCtx, phi_fp); if ((ptr->unk_28 != 0) && (ptr->unk_2C > 0)) { OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1629,6 +1629,6 @@ void EnGoroiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->actionFunc == func_8094220C) { func_80942B1C(this, globalCtx); } else if (this->actionFunc != func_80942604) { - func_800BDFC0(globalCtx, D_80942EB4[params]); + Gfx_DrawDListOpa(globalCtx, D_80942EB4[params]); } } diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/src/overlays/actors/ovl_En_Gs/z_en_gs.c index 8e50b07947..615d228599 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -5,6 +5,7 @@ */ #include "z_en_gs.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x02000019 @@ -35,7 +36,6 @@ s32 func_809995A4(EnGs* this, GlobalContext* globalCtx); void func_80999A8C(EnGs* this, GlobalContext* globalCtx); void func_80999AC0(EnGs* this); -extern Gfx D_0407D590[]; extern Gfx D_06000950[]; extern Gfx D_060009D0[]; extern Gfx D_06000A60[]; @@ -184,7 +184,7 @@ void func_80997D14(EnGs* this, GlobalContext* globalCtx) { void func_80997D38(EnGs* this, GlobalContext* globalCtx) { static f32 D_8099A408[] = { 40.0f, 60.0f, 40.0f, 40.0f }; - if (!func_80152498(&globalCtx->msgCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 0) { if (this->actor.xzDistToPlayer <= D_8099A408[this->actor.params]) { func_8013E8F8(&this->actor, globalCtx, D_8099A408[this->actor.params], D_8099A408[this->actor.params], 0, 0x2000, 0x2000); @@ -207,7 +207,7 @@ void func_80997DEC(EnGs* this, GlobalContext* globalCtx) { } void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: func_801518B0(globalCtx, this->unk_210, &this->actor); break; @@ -284,8 +284,8 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { if (!Flags_GetSwitch(globalCtx, this->unk_196)) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, 2); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); - Actor_SetSwitchFlag(globalCtx, this->unk_196); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); + Flags_SetSwitch(globalCtx, this->unk_196); } break; @@ -293,8 +293,8 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { if (!Flags_GetSwitch(globalCtx, this->unk_196)) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, 7); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); - Actor_SetSwitchFlag(globalCtx, this->unk_196); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); + Flags_SetSwitch(globalCtx, this->unk_196); } break; @@ -363,7 +363,7 @@ void func_809984F4(EnGs* this, GlobalContext* globalCtx) { EnGs* gossipStone = NULL; do { - gossipStone = (EnGs*)func_ActorCategoryIterateById(globalCtx, &gossipStone->actor, ACTORCAT_PROP, ACTOR_EN_GS); + gossipStone = (EnGs*)SubS_FindActor(globalCtx, &gossipStone->actor, ACTORCAT_PROP, ACTOR_EN_GS); if (gossipStone != NULL) { if ((this != gossipStone) && (this->unk_194 == gossipStone->unk_194)) { gossipStone->unk_19A |= 1; @@ -396,8 +396,7 @@ void func_809985B8(EnGs* this, GlobalContext* globalCtx) { gossipStone = NULL; do { - gossipStone = - (EnGs*)func_ActorCategoryIterateById(globalCtx, &gossipStone->actor, ACTORCAT_PROP, ACTOR_EN_GS); + gossipStone = (EnGs*)SubS_FindActor(globalCtx, &gossipStone->actor, ACTORCAT_PROP, ACTOR_EN_GS); if (gossipStone != NULL) { if ((gossipStone != this) && (gossipStone->actor.params == ENGS_2) && (gossipStone->unk_198 == this->unk_198)) { @@ -415,7 +414,7 @@ void func_809985B8(EnGs* this, GlobalContext* globalCtx) { void func_80998704(EnGs* this, GlobalContext* globalCtx) { this->unk_19D = 0; this->unk_19A &= ~(0x100 | 0x4); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_G_STONE_CHANGE_COLOR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_G_STONE_CHANGE_COLOR); this->actionFunc = func_8099874C; } @@ -504,7 +503,7 @@ void func_8099874C(EnGs* this, GlobalContext* globalCtx) { } void func_809989B4(EnGs* this, GlobalContext* globalCtx) { - func_800B8A1C(&this->actor, globalCtx, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809989F4; } @@ -513,7 +512,7 @@ void func_809989F4(EnGs* this, GlobalContext* globalCtx) { this->actor.parent = NULL; func_80997D14(this, globalCtx); } else { - func_800B8A1C(&this->actor, globalCtx, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } @@ -522,7 +521,7 @@ s32 func_80998A48(EnGs* this, GlobalContext* globalCtx) { if (this->unk_19D == 0) { this->unk_216 = 200; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_1D4 = 0; this->unk_19A |= 1; @@ -537,9 +536,9 @@ s32 func_80998A48(EnGs* this, GlobalContext* globalCtx) { } else if (this->unk_19D == 1) { if (func_80998334(this, globalCtx, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, 0.8f, 0.007f, 0.001f, 7, 0) == 0.0f) { - if ((this->actor.params != ENGS_0) && !func_801690CC(globalCtx) && !func_80152498(&globalCtx->msgCtx)) { + if ((this->actor.params != ENGS_0) && !func_801690CC(globalCtx) && !Message_GetState(&globalCtx->msgCtx)) { this->unk_216 = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FAIVE_LUPY_COUNT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIVE_LUPY_COUNT); func_801518B0(globalCtx, 0x20D2, NULL); } this->unk_19A &= ~1; @@ -554,7 +553,7 @@ s32 func_80998BBC(EnGs* this, GlobalContext* globalCtx) { if (this->unk_19D == 0) { this->unk_216 = 200; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_1DC = 0.3f; this->unk_1E0 = 0.0f; @@ -585,7 +584,7 @@ s32 func_80998D44(EnGs* this, GlobalContext* globalCtx) { this->unk_216 = 200; this->unk_1DC = this->unk_1B0[0].y - 1.0f; this->unk_1E0 = -0.8f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_G_STONE_CRUSH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_G_STONE_CRUSH); this->unk_19A |= 1; this->unk_21C = 40; this->unk_21E = 11; @@ -616,7 +615,7 @@ s32 func_80998D44(EnGs* this, GlobalContext* globalCtx) { this->unk_21C = 10; this->unk_21E = 10; this->unk_1DC = 0.5f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_19D += 1; } } else if ((this->unk_19D == 4) && (func_80998334(this, globalCtx, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, @@ -665,7 +664,7 @@ s32 func_80998F9C(EnGs* this, GlobalContext* globalCtx) { this->unk_1E0 = 1.5f; this->unk_1E4 = this->unk_1B0[1].y - 1.0f; this->unk_1E8 = -0.3f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_STONE_GROW_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_STONE_GROW_UP); this->unk_19D = 3; } } @@ -715,7 +714,7 @@ s32 func_80998F9C(EnGs* this, GlobalContext* globalCtx) { this->unk_1E8 = 0.0f; this->unk_1F0 = 0.0f; this->unk_1EC = 0.5f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_21C = 20; this->unk_21E = 2; this->unk_19D = 6; @@ -738,7 +737,7 @@ s32 func_80998F9C(EnGs* this, GlobalContext* globalCtx) { } if ((u16)this->unk_19E[0].y < sp3A) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_STONE_ROLLING); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_STONE_ROLLING); } return sp4C; @@ -853,7 +852,7 @@ s32 func_809995A4(EnGs* this, GlobalContext* globalCtx) { sp54.x = this->actor.world.pos.x; sp54.y = this->actor.world.pos.y; sp54.z = this->actor.world.pos.z; - Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); EffectSsBomb2_SpawnLayered(globalCtx, &sp54, &bomb2Velocity, &bomb2Accel, 100, 20); this->unk_1D4 = 10; this->unk_19A |= 8; @@ -863,7 +862,7 @@ s32 func_809995A4(EnGs* this, GlobalContext* globalCtx) { func_800B9010(&this->actor, NA_SE_EV_STONE_LAUNCH - SFX_FLAG); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Math_SmoothStepToF(&this->unk_1DC, this->unk_1E0, 0.5f, 364.0f, 0.0f); this->unk_19E[1].y += (s16)this->unk_1DC; @@ -935,9 +934,9 @@ void func_80999BC8(Actor* thisx, GlobalContext* globalCtx2) { } if (this->actor.params == ENGS_1) { - Actor_SetHeight(&this->actor, 34.5f); + Actor_SetFocus(&this->actor, 34.5f); } else { - Actor_SetHeight(&this->actor, 23.0f); + Actor_SetFocus(&this->actor, 23.0f); } if (this->unk_21A > 0) { @@ -1008,12 +1007,12 @@ void EnGs_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnGs* this = THIS; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.unk11F22 = 0; globalCtx->msgCtx.unk11F10 = 0; this->collider.base.acFlags &= ~AC_HIT; func_80997DEC(this, globalCtx); - } else if (func_800B8718(&this->actor, globalCtx)) { + } else if (func_800B8718(&this->actor, &globalCtx->state)) { this->unk_19A |= 0x200; this->collider.base.acFlags &= ~AC_HIT; if (this->actor.cutscene != -1) { @@ -1027,7 +1026,7 @@ void EnGs_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.flags & 0x40) || (this->unk_19A & 0x100) || (this->unk_19A & 0x200)) { func_80999BC8(&this->actor, globalCtx); - func_800B8898(globalCtx, &this->actor, &sp2E, &sp2C); + Actor_GetScreenPos(globalCtx, &this->actor, &sp2E, &sp2C); if ((this->actor.xyzDistToPlayerSq > SQ(400.0f)) || (sp2E < 0) || (sp2E > 320) || (sp2C < 0) || (sp2C > 240)) { this->unk_216 = 0; @@ -1103,7 +1102,7 @@ void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, -frames * 20, 0x20, 0x80)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - gSPDisplayList(POLY_XLU_DISP++, D_0407D590); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index 14a2ac839e..b93a1befee 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -79,7 +79,7 @@ void EnGuruguru_Init(Actor* thisx, GlobalContext* globalCtx) { EnGuruguru* this = THIS; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 19.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06006C90, &D_06000B04, this->jointTable, this->morphTable, 16); this->actor.targetMode = 0; if (this->actor.params != 2) { @@ -170,7 +170,7 @@ void func_80BC6F14(EnGuruguru* this, GlobalContext* globalCtx) { yawTemp = this->actor.yawTowardsPlayer - this->actor.world.rot.y; yaw = ABS_ALT(yawTemp); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80BC701C(this, globalCtx); } else if (yaw <= 0x2890) { func_800B8614(&this->actor, globalCtx, 60.0f); @@ -197,7 +197,7 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } else if (this->unusedTimer == 0) { this->unusedTimer = 6; - if (func_80152498(&globalCtx->msgCtx) != 5) { + if (Message_GetState(&globalCtx->msgCtx) != 5) { if (this->unk266 == 0) { if (this->headZRotTarget != 0) { this->headZRotTarget = 0; @@ -213,7 +213,7 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { } } } - if ((func_80152498(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { func_801477B4(globalCtx); this->headZRotTarget = 0; if ((this->textIdIndex == 13) || (this->textIdIndex == 14)) { @@ -301,21 +301,21 @@ void func_80BC7440(EnGuruguru* this, GlobalContext* globalCtx) { this->textIdIndex++; this->actor.textId = textIDs[this->textIdIndex]; func_801A3B48(1); - func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, -1); + func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, EXCH_ITEM_MINUS1); this->unk268 = 0; gSaveContext.weekEventReg[38] |= 0x40; this->actionFunc = func_80BC7520; } else { - func_800B8A1C(&this->actor, globalCtx, GI_MASK_BREMEN, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MASK_BREMEN, 300.0f, 300.0f); } } void func_80BC7520(EnGuruguru* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80BC7068; } else { - func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, -1); + func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, EXCH_ITEM_MINUS1); } } @@ -365,8 +365,8 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { } } Actor_SetScale(&this->actor, 0.01f); - Actor_SetHeight(&this->actor, 50.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_SetFocus(&this->actor, 50.0f); + Actor_MoveWithGravity(&this->actor); Math_SmoothStepToS(&this->headXRot, this->headXRotTarget, 1, 3000, 0); Math_SmoothStepToS(&this->headZRot, this->headZRotTarget, 1, 1000, 0); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index 0a0dccef71..416ab1140a 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -72,14 +72,14 @@ extern Gfx D_06011178[]; void EnHakurock_Init(Actor* thisx, GlobalContext* globalCtx) { EnHakurock* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 52.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 52.0f); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); if (this->actor.params == EN_HAKUROCK_TYPE_BOULDER) { this->actor.gravity = -1.5f; } else { this->collider.base.ocFlags1 &= ~OC1_NO_PUSH; - this->actor.minVelocityY = -100.0f; + this->actor.terminalVelocity = -100.0f; this->actor.gravity = -7.0f; } func_80B21FFC(this); @@ -212,7 +212,7 @@ void func_80B221E8(EnHakurock* this, GlobalContext* globalCtx) { if (this->collider.base.atFlags & AT_HIT || ((this->counter == 0) && (this->collider.base.ocFlags1 & OC1_HIT)) || ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROCK_BROKEN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROCK_BROKEN); func_80B21EA4(this, 0); func_80B21FFC(this); } @@ -247,7 +247,7 @@ void func_80B2242C(EnHakurock* this, GlobalContext* globalCtx) { func_80B21FFC(this); } else if ((this->actor.bgCheckFlags & 1)) { func_80B21EA4(this, 2); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_OBJECT_STICK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OBJECT_STICK); func_80B224C0(this); } } @@ -322,7 +322,7 @@ void EnHakurock_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); rockParams = this->actor.params; if ((rockParams == EN_HAKUROCK_TYPE_BOULDER) || (rockParams == EN_HAKUROCK_TYPE_UNK_2)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, this->collider.dim.radius, 0.0f, 0x85); if (this->actor.floorHeight == BGCHECK_Y_MIN) { func_80B21FFC(this); diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index d7eec060d9..c02ab0eaf2 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -155,7 +155,7 @@ void EnHg_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80BCF354(EnHg* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BCF398; } @@ -167,13 +167,13 @@ void func_80BCF398(EnHg* this, GlobalContext* globalCtx) { } if ((gSaveContext.sceneSetupIndex == 0 && globalCtx->csCtx.unk_12 == 0) && (globalCtx->csCtx.frames == 20 || globalCtx->csCtx.frames == 60)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_HALF_REDEAD_SURPRISE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HALF_REDEAD_SURPRISE); } } } void func_80BCF468(EnHg* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BCF4AC; } @@ -182,10 +182,10 @@ void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { s32 pad; this->actor.speedXZ = 1.6f; - if (!(player->stateFlags2 & 0x08000000) && !func_80152498(&globalCtx->msgCtx)) { + if (!(player->stateFlags2 & 0x08000000) && !Message_GetState(&globalCtx->msgCtx)) { if (((this->skelAnime.curFrame > 9.0f) && (this->skelAnime.curFrame < 16.0f)) || ((this->skelAnime.curFrame > 44.0f) && (this->skelAnime.curFrame < 51.0f))) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x3E8, 0x14); this->actor.world.rot.y = this->actor.shape.rot.y; } @@ -197,7 +197,7 @@ void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF5F0(EnHg* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BCF634; } @@ -210,7 +210,7 @@ void func_80BCF634(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF68C(EnHg* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80BCF6D0; } @@ -221,8 +221,8 @@ void func_80BCF6D0(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF710(EnHg* this, GlobalContext* globalCtx) { - if (!func_80152498(&globalCtx->msgCtx)) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, 0x24F, &this->actor); } else { func_800B8614(&this->actor, globalCtx, 80.0f); @@ -284,17 +284,17 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { case 1: this->currentAnimation = 0; - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); break; case 2: this->cutscenes[2] = 0; this->currentAnimation = 3; - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); break; case 3: this->cutscenes[2] = 0; this->currentAnimation = 5; - func_800BDC5C(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); break; case 4: this->cutscenes[2] = 0; @@ -302,11 +302,11 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { if ((this->unk218 == 1) || (this->unk218 == 3)) { func_8019F128(NA_SE_EN_HALF_REDEAD_TRANS); } - func_800BDC5C(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); break; case 5: this->currentAnimation = 1; - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); break; case 6: gSaveContext.weekEventReg[0x4B] |= 0x20; @@ -318,11 +318,11 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { switch (this->currentAnimation) { case 3: this->currentAnimation = 4; - func_800BDC5C(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); break; case 5: this->currentAnimation = 6; - func_800BDC5C(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); break; } } diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.c b/src/overlays/actors/ovl_En_Holl/z_en_holl.c index 65f5e4d555..ff418b5797 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -108,7 +108,7 @@ void EnHoll_SetupAction(EnHoll* this) { void EnHoll_SetPlayerSide(GlobalContext* globalCtx, EnHoll* this, Vec3f* transformedPlayerPos) { Player* player = GET_PLAYER(globalCtx); - Actor_CalcOffsetOrientedToDrawRotation(&this->actor, transformedPlayerPos, &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->actor, transformedPlayerPos, &player->actor.world.pos); this->playerSide = (transformedPlayerPos->z < 0.0f) ? EN_HOLL_BEHIND : EN_HOLL_BEFORE; } @@ -223,8 +223,8 @@ void EnHoll_TransparentIdle(EnHoll* this, GlobalContext* globalCtx) { f32 enHollTop; f32 playerDistFromCentralPlane; - Actor_CalcOffsetOrientedToDrawRotation(&this->actor, &transformedPlayerPos, - useViewEye ? &globalCtx->view.eye : &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->actor, &transformedPlayerPos, + useViewEye ? &globalCtx->view.eye : &player->actor.world.pos); enHollTop = (globalCtx->sceneNum == SCENE_PIRATE) ? EN_HOLL_TOP_PIRATE : EN_HOLL_TOP_DEFAULT; if ((transformedPlayerPos.y > EN_HOLL_BOTTOM_DEFAULT) && (transformedPlayerPos.y < enHollTop) && diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.h b/src/overlays/actors/ovl_En_Horse/z_en_horse.h index 7efae12fc7..787fd8b579 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.h +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.h @@ -7,9 +7,11 @@ struct EnHorse; typedef struct EnHorse { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x00C]; + /* 0x144 */ char unk_144[0xC]; /* 0x150 */ s32 unk_150; - /* 0x154 */ char unk_154[0x440]; + /* 0x154 */ char unk_154[0x98]; + /* 0x1EC */ UNK_TYPE4 unk_1EC; + /* 0x1F0 */ char unk_1F0[0x3A4]; } EnHorse; // size = 0x594 extern const ActorInit En_Horse_InitVars; diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index 800e44c6fb..66300dda5f 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -215,12 +215,13 @@ s32 func_808F3178(EnIn* this, GlobalContext* globalCtx) { this->unk260 = tmp = func_8013DB90(globalCtx, &this->unk248, -6.0f); if (this->unk260 != 0 && prevUnk260 == 0 && tmp) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_CONCRETE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } this->unk261 = tmp = func_8013DB90(globalCtx, &this->unk254, -6.0f); if (this->unk261 != 0 && prevUnk261 == 0 && tmp) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_CONCRETE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } + return 0; } @@ -258,7 +259,7 @@ s32 func_808F3334(EnIn* this, GlobalContext* globalCtx) { if (this->colliderJntSph.base.atFlags & AT_BOUNCED) { return 0; } - Audio_PlayActorSound2(&player->actor, 0x83E); + Actor_PlaySfxAtPos(&player->actor, 0x83E); func_800B8D98(globalCtx, &this->actor, 3.0f, this->actor.yawTowardsPlayer, 6.0f); } return 1; @@ -350,13 +351,13 @@ void func_808F374C(EnIn* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 8.0f)) { func_8019F88C(&this->actor.projectedPos, NA_SE_VO_IN_LASH_0, 2); if (Rand_ZeroOne() < 0.3f) { - func_8019F1C0(&this->actor.projectedPos, NA_SE_IT_INGO_HORSE_NEIGH); + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_IT_INGO_HORSE_NEIGH); } - func_8019F1C0(&this->actor.projectedPos, NA_SE_IT_LASH); + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_IT_LASH); } } if (this->skelAnime.animation == &D_060198A8 && Animation_OnFrame(&this->skelAnime, 20.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_CRY_0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_CRY_0); } if (SkelAnime_Update(&this->skelAnime)) { this->unk486 = this->unk488 %= 8; @@ -369,7 +370,7 @@ void func_808F38F8(EnIn* this, GlobalContext* globalCtx) { this->unk4A4 = NULL; while (true) { //! @bug: Infinite loop if there is only one ACTOR_EN_IN - this->unk4A4 = (EnIn*)func_ActorCategoryIterateById(globalCtx, &this->unk4A4->actor, ACTORCAT_NPC, ACTOR_EN_IN); + this->unk4A4 = (EnIn*)SubS_FindActor(globalCtx, &this->unk4A4->actor, ACTORCAT_NPC, ACTOR_EN_IN); if (this->unk4A4 != NULL && this->unk4A4 != this) { break; } @@ -381,7 +382,7 @@ void func_808F395C(EnIn* this, GlobalContext* globalCtx) { if (this->unk4B0 == 0) { this->actionFunc = func_808F5A94; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; this->actionFunc = func_808F5A34; this->unk48C = 1; @@ -418,19 +419,19 @@ void func_808F39DC(EnIn* this, GlobalContext* globalCtx) { this->actor.textId = textId; this->actionFunc = func_808F395C; if (this->unk4B0 == 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_LOST); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_JOY0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); } } void func_808F3AD4(EnIn* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } } @@ -444,17 +445,17 @@ void func_808F3B40(EnIn* this, GlobalContext* globalCtx) { textId = gSaveContext.day != 3 ? 0x3481 : 0x34A4; this->actor.textId = textId; } else { - func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); } } void func_808F3BD4(EnIn* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } } @@ -468,17 +469,17 @@ void func_808F3C40(EnIn* this, GlobalContext* globalCtx) { textId = gSaveContext.day != 3 ? 0x346A : 0x3492; this->actor.textId = textId; } else { - func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); } } void func_808F3CD4(EnIn* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } } @@ -492,7 +493,7 @@ void func_808F3D40(EnIn* this, GlobalContext* globalCtx) { this->actor.textId = textId; this->actor.flags |= 0x10000; } else { - func_800B8A1C(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); } } @@ -606,7 +607,7 @@ void func_808F4054(GlobalContext* globalCtx, EnIn* this, s32 arg2, u16 textId) { } void func_808F4108(EnIn* this, GlobalContext* globalCtx, u16 textId) { - func_800B86C8(&this->actor, globalCtx, &this->unk4A4->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk4A4->actor); this->actor.textId = 0; this->unk4A4->actor.textId = textId; this->unk4A4->unk48C = 2; @@ -792,7 +793,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { if (func_80114E90()) { this->actionFunc = func_808F3C40; - func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); func_801159EC(-globalCtx->msgCtx.unk1206C); ret = true; } else { @@ -938,7 +939,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_808F35D8(this, globalCtx); if (func_80114E90()) { this->actionFunc = func_808F3B40; - func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); ret = true; } else { func_800E8EA0(globalCtx, &this->actor, 0x347F); @@ -962,7 +963,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x347C: this->actionFunc = func_808F3D40; - func_800B8A1C(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); func_808F35D8(this, globalCtx); ret = true; break; @@ -1044,7 +1045,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { if (func_80114E90()) { this->actionFunc = func_808F3C40; - func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); func_801159EC(-globalCtx->msgCtx.unk1206C); ret = true; } else { @@ -1127,7 +1128,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x349F: this->actionFunc = func_808F3D40; - func_800B8A1C(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); func_808F35D8(this, globalCtx); ret = true; break; @@ -1142,7 +1143,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_808F35D8(this, globalCtx); if (func_80114E90()) { this->actionFunc = func_808F3B40; - func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); ret = true; } else { func_800E8EA0(globalCtx, &this->actor, 0x34A2); @@ -1222,7 +1223,7 @@ s32 func_808F5674(GlobalContext* globalCtx, EnIn* this, s32 arg2) { s32 pad; s32 ret = false; - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 2: func_808F4054(globalCtx, this, arg2, this->actor.textId); ret = true; @@ -1257,7 +1258,7 @@ s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { *arg3 = 1; return 0; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { *arg3 = 1; return 1; } @@ -1379,9 +1380,9 @@ void func_808F5C98(EnIn* this, GlobalContext* globalCtx) { } if (this->unk4A8 == 2) { if (this->unk4B0 == 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_LOST); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_JOY0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); } this->unk4A8 = 3; } else if (this->unk4A8 < 3) { @@ -1400,7 +1401,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { s16 type; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06014EA8, NULL, this->jointTable, this->morphTable, 20); func_808F30B0(&this->skelAnime, 0); Collider_InitCylinder(globalCtx, &this->colliderCylinder); @@ -1519,7 +1520,7 @@ void func_808F6334(EnIn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 newUnk4C8; - newUnk4C8 = func_80152498(&globalCtx->msgCtx); + newUnk4C8 = Message_GetState(&globalCtx->msgCtx); this->unk4C4 += this->unk4C0 != 0.0f ? 40.0f : -40.0f; this->unk4C4 = CLAMP(this->unk4C4, 0.0f, 80.0f); diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index b71a44a342..f6b2438d48 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -221,7 +221,6 @@ extern Gfx D_06000720[]; extern Gfx D_06000080[]; extern s32 D_801BDA9C; -extern Vec3s D_801D15BC; const ActorInit En_Invadepoh_InitVars = { ACTOR_EN_INVADEPOH, @@ -562,7 +561,7 @@ static InitChainEntry sInitChainRomani[] = { static InitChainEntry D_80B4EC68[] = { ICHAIN_F32(uncullZoneForward, 20000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_CONTINUE), ICHAIN_VEC3S(shape.rot, 0, ICHAIN_CONTINUE), - ICHAIN_F32(minVelocityY, -100, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), + ICHAIN_F32(terminalVelocity, -100, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; static InitChainEntry sInitChainDog[] = { @@ -1132,7 +1131,7 @@ void func_80B44A90(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.velocity.y *= 0.8f; this->actor.speedXZ *= 0.8f; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 40.0f, 0.0f, 5); } @@ -1208,7 +1207,7 @@ s32 func_80B44C80(EnInvadepoh* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(((sp60.z + temp_f0_2) * 0.9f) + sp6C.z, ((sp60.x + temp_f0_3) * 0.9f) + sp6C.x), 4, 0xFA0, 0x64); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (func_80B440B8(this, 50.0f, 15.0f)) { phi_v0 = 4; } else { @@ -1221,7 +1220,7 @@ s32 func_80B44C80(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B44E90(EnInvadepoh* this, GlobalContext* globalCtx) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 15.0f, 0.0f, 5); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x1F40, 0x64); } @@ -1378,7 +1377,7 @@ void EnInvadepoh_SetSysMatrix(Vec3f* vec) { s32 func_80B45550(EnInvadepoh* this, GlobalContext* globalCtx, f32 range, s32 arg3) { s32 pad; - Actor* actorIterator = globalCtx->actorCtx.actorList[ACTORCAT_DOOR].first; + Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; s32 retVal = false; while (actorIterator != NULL) { @@ -1413,7 +1412,7 @@ s32 func_80B456A8(GlobalContext* globalCtx, Vec3f* vec) { Vec3f multDest; f32 wDest; - func_800B4EDC(globalCtx, vec, &multDest, &wDest); + Actor_GetProjectedPos(globalCtx, vec, &multDest, &wDest); if (((multDest.z > 1.0f) && (fabsf(multDest.x * wDest) < 1.0f)) && (fabsf(multDest.y * wDest) < 1.0f)) { s32 wX = (multDest.x * wDest * 160.0f) + 160.0f; s32 wY = (multDest.y * wDest * -120.0f) + 120.0f; @@ -1721,7 +1720,7 @@ void EnInvadepoh_InitAlien(EnInvadepoh* this, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, D_80B4EC24); Collider_InitCylinder(globalCtx, &this->collider); - ActorShape_Init(&this->actor.shape, 6800.0f, func_800B4088, 150.0f); + ActorShape_Init(&this->actor.shape, 6800.0f, ActorShadow_DrawWhiteCircle, 150.0f); this->actor.shape.shadowAlpha = 140; this->actor.flags = 0x80001010; if (INVADEPOH_TYPE(this) == TYPE_ALIEN1) { @@ -1769,7 +1768,7 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_NPC); Collider_InitCylinder(globalCtx, &this->collider); if (temp != 4) { - ActorShape_Init(&this->actor.shape, 0, func_800B3FC0, 18.0f); + ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 18.0f); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitRomaniAndCremia); this->actor.colChkInfo.mass = MASS_IMMOVABLE; } @@ -1843,7 +1842,7 @@ void EnInvadepoh_InitDog(EnInvadepoh* this, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitDog); this->actor.colChkInfo.mass = 0x50; - ActorShape_Init(&this->actor.shape, 0, func_800B3FC0, 24.0f); + ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 24.0f); this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_DOG); if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); @@ -1859,7 +1858,7 @@ void EnInvadepoh_InitCremia(EnInvadepoh* this, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitRomaniAndCremia); this->actor.colChkInfo.mass = MASS_HEAVY; - ActorShape_Init(&this->actor.shape, 0, func_800B3FC0, 18.0f); + ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 18.0f); this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MA2); if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); @@ -2232,7 +2231,7 @@ void func_80B47830(EnInvadepoh* this) { this->collider.base.acFlags &= ~1; this->collider.base.ocFlags1 |= 1; Animation_PlayLoop(&this->skelAnime, &D_060006C8); - func_800BCB70(&this->actor, 0x4000, 255, 0, 16); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); this->alienAlpha = 255; this->actor.draw = func_80B4DB14; this->drawAlien = true; @@ -2324,7 +2323,7 @@ void func_80B47BAC(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B45080(); this->actor.update = func_80B47D30; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004E50, &D_06001D80, this->jointTable, this->morphTable, @@ -2372,7 +2371,7 @@ void func_80B47D30(Actor* thisx, GlobalContext* globalCtx) { thisx->gravity = 0.0f; thisx->velocity.y = acAttached->velocity.y * 0.5f; thisx->velocity.y = CLAMP(thisx->velocity.y, -30.0f, 30.0f); - Audio_PlaySoundAtPosition(globalCtx, &thisx->world.pos, 50, NA_SE_EN_INVADER_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &thisx->world.pos, 50, NA_SE_EN_INVADER_DEAD); func_80B47830(this); } @@ -2407,7 +2406,7 @@ void func_80B47FA8(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, thisx); + Actor_SetObjectDependency(globalCtx, thisx); this->actor.update = func_80B48060; this->actor.draw = func_80B4E158; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004010, NULL, this->jointTable, this->morphTable, 6); @@ -2450,7 +2449,7 @@ void func_80B481C4(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); this->actor.update = func_80B4827C; this->actor.draw = func_80B4E1B0; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004C30, NULL, this->jointTable, this->morphTable, 6); @@ -2563,12 +2562,12 @@ void func_80B48620(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); this->actor.update = func_80B4873C; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06009E58, this->jointTable, this->morphTable, 23); - func_80B45C04(&this->behaviorInfo, D_80B4EA90, 6, D_80B4EB00, 2, &D_801D15BC, 5000, 0.05f, 0.3f, 0.12f); + func_80B45C04(&this->behaviorInfo, D_80B4EA90, 6, D_80B4EB00, 2, &gZeroVec3s, 5000, 0.05f, 0.3f, 0.12f); Animation_PlayLoop(&this->skelAnime, &D_06009E58); func_80B482D4(this); } @@ -2620,7 +2619,7 @@ void func_80B48848(EnInvadepoh* this, GlobalContext* globalCtx) { func_80B43E6C(this, 6, this->behaviorInfo.unk4C, 0x46); if (((this->actor.flags & 0x40) == 0x40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } if (this->actionTimer > 0) { this->actionTimer--; @@ -2636,7 +2635,7 @@ void func_80B48948(EnInvadepoh* this) { this->actionTimer = Rand_S16Offset(150, 150); if (rand < 0.5f) { this->rand = 0; - Math_Vec3s_Copy(&substruct->unk26, &D_801D15BC); + Math_Vec3s_Copy(&substruct->unk26, &gZeroVec3s); substruct->unk30 = 0.1f; substruct->unk2C = 1000; } else if (rand < 0.75f) { @@ -2702,7 +2701,7 @@ void func_80B48AD4(EnInvadepoh* this, GlobalContext* globalCtx) { if (temp_v1_3 != this->rand) { this->rand = temp_v1_3; if (this->rand == 0) { - Math_Vec3s_Copy(&substruct->unk26, &D_801D15BC); + Math_Vec3s_Copy(&substruct->unk26, &gZeroVec3s); substruct->unk30 = 0.07f; } else if (this->rand == 1) { substruct->unk26.x = Rand_S16Offset(1000, 1000); @@ -2755,7 +2754,7 @@ void func_80B48E4C(EnInvadepoh* this, GlobalContext* globalCtx) { diff = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); temp_v1 = diff * 0.7f; substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { func_80B48948(this); } } @@ -2765,14 +2764,14 @@ void func_80B48FB0(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); this->actor.update = func_80B490F0; this->actor.draw = func_80B4E324; this->actor.textId = 0x3330; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06009E58, this->jointTable, this->morphTable, 23); - func_80B45C04(&this->behaviorInfo, D_80B4EA90, 6, D_80B4EB00, 2, &D_801D15BC, 100, 0.03, 0.3, 0.03); + func_80B45C04(&this->behaviorInfo, D_80B4EA90, 6, D_80B4EB00, 2, &gZeroVec3s, 100, 0.03, 0.3, 0.03); func_80B444F4(this, globalCtx); EnInvadepoh_SetPathPointToWorldPos(this, 0); func_800B4AEC(globalCtx, &this->actor, 50.0f); @@ -2785,7 +2784,7 @@ void func_80B490F0(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = (this->actor.flags & 0x40) == 0x40; - s32 isTalking = func_800B84D0(&this->actor, globalCtx); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { func_80151BB4(globalCtx, 5); @@ -2816,7 +2815,7 @@ void func_80B49228(EnInvadepoh* this, GlobalContext* globalCtx) { s32 pad; f32 temp_f0; - Actor_SetVelocityYRotationAndGravity(&this->actor); + Actor_UpdateVelocityWithGravity(&this->actor); this->actor.velocity.y *= 0.97f; temp_f0 = Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + D_80B4E934.y + 300.0f, 0.7f, fabsf(this->actor.velocity.y), 1.0f); @@ -2845,7 +2844,7 @@ void func_80B4934C(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.gravity = -2.0f; } this->actor.velocity.y *= 0.96f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_800B9010(&this->actor, NA_SE_EV_UFO_APPEAR - SFX_FLAG); this->actionTimer--; if (this->actionTimer <= 0) { @@ -2932,7 +2931,7 @@ void func_80B49670(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.gravity = 2.0f; } this->actor.velocity.y *= 0.97f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (D_80B4E940 == 3) { func_80B499BC(this); } @@ -2962,7 +2961,7 @@ void func_80B497EC(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.gravity = 2.0f; } this->actor.velocity.y *= 0.97f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (this->actionTimer > 0) { this->actionTimer--; } else { @@ -2982,7 +2981,7 @@ void func_80B49904(EnInvadepoh* this) { void func_80B4994C(EnInvadepoh* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 150.0f, 4.0f); this->actor.velocity.y *= 0.95f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (this->actionTimer > 0) { this->actionTimer--; } else { @@ -3014,7 +3013,7 @@ void func_80B49A00(EnInvadepoh* this, GlobalContext* globalCtx) { } else { this->actor.gravity = 2.0f; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (this->actionTimer > 0) { this->actionTimer--; @@ -3073,7 +3072,7 @@ void func_80B49C38(EnInvadepoh* this, GlobalContext* globalCtx) { if (((this->actor.flags & 0x40) == 0x40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } if (this->clockTime >= 0.9999f) { Actor_MarkForDeath(&this->actor); @@ -3103,7 +3102,7 @@ void func_80B49DFC(EnInvadepoh* this, GlobalContext* globalCtx) { temp_v1 = diff; temp_v1 *= 0.7f; substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { if (this->actor.textId == 0x332D) { gSaveContext.weekEventReg[54] |= 0x10; this->actor.textId = 0x332E; @@ -3120,11 +3119,11 @@ void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { sp38 = gSaveContext.time; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->jointTable, this->morphTable, 23); - func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 1, &D_801D15BC, 100, 0.03, 0.3, 0.03); + func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 1, &gZeroVec3s, 100, 0.03, 0.3, 0.03); func_80B44540(this, globalCtx); func_80B44570(this); func_80B44C24(this, globalCtx); @@ -3168,7 +3167,7 @@ void func_80B4A1B8(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = (this->actor.flags & 0x40) == 0x40; - s32 isTalking = func_800B84D0(&this->actor, globalCtx); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { func_80151BB4(globalCtx, 5); @@ -3299,7 +3298,7 @@ void func_80B4A67C(EnInvadepoh* this, GlobalContext* globalCtx) { } if (((this->actor.flags & 0x40) == 0x40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } if (this->pathIndex == this->endPoint) { func_80B4A2C0(this); @@ -3330,7 +3329,7 @@ void func_80B4A81C(EnInvadepoh* this, GlobalContext* globalCtx) { temp_v1 *= 0.7f; substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { if (this->actor.textId == 0x332D) { gSaveContext.weekEventReg[54] |= 0x10; this->actor.textId = 0x332E; @@ -3351,11 +3350,11 @@ void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { sp38 = gSaveContext.time; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->jointTable, this->morphTable, 23); - func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 1, &D_801D15BC, 100, 0.03f, 0.3f, 0.03f); + func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 1, &gZeroVec3s, 100, 0.03f, 0.3f, 0.03f); func_80B44620(this, globalCtx); if ((sp38 < CLOCK_TIME(2, 15)) || (sp38 >= CLOCK_TIME(6, 0))) { this->pathIndex = 0; @@ -3397,7 +3396,7 @@ void func_80B4ABDC(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = (this->actor.flags & 0x40) == 0x40; - s32 isTalking = func_800B84D0(&this->actor, globalCtx); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { func_80151BB4(globalCtx, 5); @@ -3433,7 +3432,7 @@ void func_80B4AD3C(EnInvadepoh* this) { } void func_80B4AD60(EnInvadepoh* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { EnInvadepoh_SetTextID(this, globalCtx, 0x3331); func_80B4ADB8(this); } else { @@ -3446,7 +3445,7 @@ void func_80B4ADB8(EnInvadepoh* this) { } void func_80B4ADCC(EnInvadepoh* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { if (this->textId == 0x3331) { if (gSaveContext.weekEventReg[22] & 2) { EnInvadepoh_SetTextID(this, globalCtx, 0x3334); @@ -3483,7 +3482,7 @@ void func_80B4AEDC(EnInvadepoh* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[22] |= 2; func_80B4AF80(this); } else { - func_800B8A1C(&this->actor, globalCtx, GI_MILK_BOTTLE, 2000.0f, 2000.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK_BOTTLE, 2000.0f, 2000.0f); } } @@ -3492,14 +3491,14 @@ void func_80B4AF80(EnInvadepoh* this) { } void func_80B4AF94(EnInvadepoh* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { EnInvadepoh_SetTextID(this, globalCtx, 0x3334); func_80151BB4(globalCtx, 0x1E); func_80151BB4(globalCtx, 0x1D); func_80151BB4(globalCtx, 5); func_80B4ADB8(this); } else { - func_800B85E0(&this->actor, globalCtx, 2000.0f, -1); + func_800B85E0(&this->actor, globalCtx, 2000.0f, EXCH_ITEM_MINUS1); } } @@ -3512,7 +3511,7 @@ void func_80B4B048(EnInvadepoh* this, GlobalContext* globalCtx) { if (globalCtx->msgCtx.unk120B1 == 0) { if (globalCtx->msgCtx.unk11F22 == 0) { D_80B4E998 = 1; - } else if ((func_80152498(&globalCtx->msgCtx) == 6) || (func_80152498(&globalCtx->msgCtx) == 5)) { + } else if ((Message_GetState(&globalCtx->msgCtx) == 6) || (Message_GetState(&globalCtx->msgCtx) == 5)) { D_80B4E998 = 1; } } @@ -3525,14 +3524,14 @@ void func_80B4B0C4(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); this->actor.update = func_80B4B218; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->jointTable, this->morphTable, 23); Animation_MorphToLoop(&this->skelAnime, &D_06009E58, 0.0f); substruct = &this->behaviorInfo; - func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 3, &D_801D15BC, 2000, 0.08f, 0.3f, 0.03f); + func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 3, &gZeroVec3s, 2000, 0.08f, 0.3f, 0.03f); substruct->unk30 = 0.08f; substruct->unk2C = 0x7D0; func_800B4AEC(globalCtx, &this->actor, 50.0f); @@ -3572,7 +3571,7 @@ void func_80B4B3DC(EnInvadepoh* this) { s32 pad; if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 7.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_MONKEY_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); } } @@ -3635,7 +3634,7 @@ void func_80B4B564(EnInvadepoh* this, GlobalContext* globalCtx) { this->actionTimer--; } else if (this->unk3BC >= 0) { if ((D_80B50348 == 0) && (Rand_ZeroOne() < 0.4f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); } func_80B4B724(this); } else { @@ -3656,7 +3655,7 @@ void func_80B4B768(EnInvadepoh* this, GlobalContext* globalCtx) { 0x64); func_80B44E90(this, globalCtx); if (Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 19.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); } if (this->animPlayFlag) { func_80B4B510(this); @@ -3682,10 +3681,10 @@ void func_80B4B8BC(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060080F0, &D_060021C8, this->jointTable, this->morphTable, 13); - func_80B45C04(&this->behaviorInfo, 0, 0, 0, 0, &D_801D15BC, 3000, 0.1f, 0.0f, 0.0f); + func_80B45C04(&this->behaviorInfo, 0, 0, 0, 0, &gZeroVec3s, 3000, 0.1f, 0.0f, 0.0f); func_80B44664(this, globalCtx); EnInvadepoh_SetPathPointToWorldPos(this, 0); func_800B4AEC(globalCtx, &this->actor, 50.0f); @@ -3833,7 +3832,7 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { if (((this->actor.flags & 0x40) == 0x40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } if (gSaveContext.time > CLOCK_TIME(20, 15)) { Actor_MarkForDeath(&this->actor); @@ -3869,7 +3868,7 @@ void func_80B4C058(EnInvadepoh* this, GlobalContext* globalCtx) { substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { func_80B4BBE0(this); } } @@ -3915,11 +3914,11 @@ void func_80B4C3A0(Actor* thisx, GlobalContext* globalCtx) { s32 currentTime = gSaveContext.time; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44FEC(); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06015C28, &D_06016720, this->jointTable, this->morphTable, 22); - func_80B45C04(&this->behaviorInfo, D_80B4EBDC, 1, D_80B4EC08, 0, &D_801D15BC, 100, 0.03f, 0.3f, 0.03f); + func_80B45C04(&this->behaviorInfo, D_80B4EBDC, 1, D_80B4EC08, 0, &gZeroVec3s, 100, 0.03f, 0.3f, 0.03f); this->actor.textId = 0x33CD; if (currentTime < 0xD5A0) { this->unk304 = -0x8000; @@ -3959,7 +3958,7 @@ void func_80B4C5C0(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = (this->actor.flags & 0x40) == 0x40; - s32 isTalking = func_800B84D0(&this->actor, globalCtx); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { func_80151BB4(globalCtx, 6); @@ -4054,7 +4053,7 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { if (((this->actor.flags & 0x40) == 0x40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } if (this->clockTime >= 0.9999f) { @@ -4091,7 +4090,7 @@ void func_80B4CB0C(EnInvadepoh* this, GlobalContext* globalCtx) { temp_v1 = diff; temp_v1 *= 0.7f; substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { func_80B4C6C8(this); } } @@ -4136,11 +4135,11 @@ void func_80B4CE54(Actor* thisx, GlobalContext* globalCtx) { sp38 = gSaveContext.time; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->jointTable, this->morphTable, 23); - func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 3, &D_801D15BC, 100, 0.03f, 0.3f, 0.03f); + func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 3, &gZeroVec3s, 100, 0.03f, 0.3f, 0.03f); func_80B446D0(this, globalCtx); this->actor.world.rot.y = this->actor.shape.rot.y; func_80B44700(this); @@ -4175,7 +4174,7 @@ void func_80B4D054(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = (this->actor.flags & 0x40) == 0x40; - s32 isTalking = func_800B84D0(&this->actor, globalCtx); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { func_80151BB4(globalCtx, 5); @@ -4324,7 +4323,7 @@ void func_80B4D670(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { invadepohType = this->actor.params & 7; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B45080(); this->actor.update = func_80B4D760; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004E50, &D_06001674, this->jointTable, this->morphTable, diff --git a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c index 603420f76f..ff1f9b6cac 100644 --- a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c +++ b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c @@ -68,7 +68,7 @@ static InitChainEntry D_80C1AAB0[] = { ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_CONTINUE), ICHAIN_VEC3S(shape.rot, 0, ICHAIN_CONTINUE), - ICHAIN_F32(minVelocityY, -100, ICHAIN_CONTINUE), + ICHAIN_F32(terminalVelocity, -100, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 800, ICHAIN_STOP), }; diff --git a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c index f459fbf53a..3609275335 100644 --- a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c +++ b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c @@ -78,7 +78,7 @@ void func_80C2590C(EnInvisibleRuppe* this, GlobalContext* globalCtx) { } if (this->unk_190 >= 0) { - Actor_SetSwitchFlag(globalCtx, this->unk_190); + Flags_SetSwitch(globalCtx, this->unk_190); } this->actionFunc = func_80C259E8; diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index a7ed2025a7..f4bef28664 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -5,6 +5,9 @@ */ #include "z_en_ishi.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_ishi/object_ishi.h" #define FLAGS 0x00800010 @@ -14,14 +17,31 @@ void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx); void EnIshi_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnIshi_Update(Actor* thisx, GlobalContext* globalCtx); +void func_8095D804(Actor* thisx, GlobalContext* globalCtx); +void func_8095DABC(Actor* thisx, GlobalContext* globalCtx); +void func_8095DDA8(EnIshi* this, GlobalContext* globalCtx); +void func_8095DE9C(EnIshi* this, GlobalContext* globalCtx); +void func_8095E5AC(EnIshi* this); void func_8095E5C0(EnIshi* this, GlobalContext* globalCtx); +void func_8095E64C(EnIshi* this); void func_8095E660(EnIshi* this, GlobalContext* globalCtx); +void func_8095E934(EnIshi* this); void func_8095E95C(EnIshi* this, GlobalContext* globalCtx); +void func_8095EA70(EnIshi* this); void func_8095EBDC(EnIshi* this, GlobalContext* globalCtx); +void func_8095F060(EnIshi* this); void func_8095F0A4(EnIshi* this, GlobalContext* globalCtx); +void func_8095F180(EnIshi* this); void func_8095F194(EnIshi* this, GlobalContext* globalCtx); +void func_8095F210(EnIshi* this, GlobalContext* globalCtx); +void func_8095F36C(EnIshi* this, GlobalContext* globalCtx); +void func_8095F61C(Actor* thisx, GlobalContext* globalCtx); +void func_8095F654(Actor* thisx, GlobalContext* globalCtx); + +static s16 D_8095F690 = 0; + +static s16 D_8095F694 = 0; -#if 0 const ActorInit En_Ishi_InitVars = { ACTOR_EN_ISHI, ACTORCAT_PROP, @@ -34,109 +54,702 @@ const ActorInit En_Ishi_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8095F6EC = { - { COLTYPE_HARD, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x01C37FBE, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 10, 18, -2, { 0, 0, 0 } }, +static f32 D_8095F6B8[] = { 0.1f, 0.4f }; + +static f32 D_8095F6C0[] = { 58.0f, 80.0f }; + +static f32 D_8095F6C8[] = { 0.0f, 0.005f }; + +static u16 D_8095F6D0[] = { NA_SE_EV_ROCK_BROKEN, NA_SE_EV_WALL_BROKEN }; + +static u8 D_8095F6D4[] = { 25, 40 }; + +static EnIshiUnkFunc2 D_8095F6D8[] = { func_8095D804, func_8095DABC }; + +static EnIshiUnkFunc D_8095F6E0[] = { func_8095DDA8, func_8095DE9C }; + +static s16 D_8095F6E8[] = { GAMEPLAY_FIELD_KEEP, OBJECT_ISHI }; + +static ColliderCylinderInit sCylinderInit[] = { + { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x01C37FBE, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 10, 18, -2, { 0, 0, 0 } }, + }, + { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 55, 70, 0, { 0, 0, 0 } }, + }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8095F718 = { - { COLTYPE_HARD, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 55, 70, 0, { 0, 0, 0 } }, +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; + +static s16 D_8095F74C[] = { 16, 13, 11, 9, 7, 5 }; + +static s16 D_8095F758[] = { 145, 135, 120, 100, 70, 50, 45, 40, 35 }; + +static s16 D_8095F76C[] = { -1, 1, 2, 20, 8, 0 }; + +static Vec3f D_8095F778 = { 0.0f, 1.0f, 0.0f }; + +static InitChainEntry sInitChain[][5] = { + { + ICHAIN_F32_DIV1000(gravity, -1200, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), + }, + { + ICHAIN_F32_DIV1000(gravity, -2500, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 250, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), + }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8095F744 = { 0, 12, 60, MASS_IMMOVABLE }; +static u16 D_8095F7AC[] = { NA_SE_PL_PULL_UP_ROCK, NA_SE_PL_PULL_UP_BIGROCK }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8095F784[] = { - ICHAIN_F32_DIV1000(gravity, -1200, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), -}; +static EnIshiUnkFunc D_8095F7B0[] = { func_8095F210, func_8095F36C }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8095F798[] = { - ICHAIN_F32_DIV1000(gravity, -2500, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 250, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), -}; +void func_8095D6E0(Actor* thisx, GlobalContext* globalCtx) { + EnIshi* this = THIS; -#endif + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit[ENISHI_GET_1(&this->actor)]); + Collider_UpdateCylinder(&this->actor, &this->collider); +} -extern ColliderCylinderInit D_8095F6EC; -extern ColliderCylinderInit D_8095F718; -extern CollisionCheckInfoInit D_8095F744; -extern InitChainEntry D_8095F784[]; -extern InitChainEntry D_8095F798[]; +s32 func_8095D758(EnIshi* this, GlobalContext* globalCtx, f32 arg2) { + Vec3f sp24; + s32 sp20; -extern UNK_TYPE D_060009B0; + sp24.x = this->actor.world.pos.x; + sp24.y = this->actor.world.pos.y + 30.0f; + sp24.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp20, &this->actor, &sp24); + if (this->actor.floorHeight > BGCHECK_Y_MIN) { + this->actor.world.pos.y = this->actor.floorHeight + arg2; + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095D6E0.s") +void func_8095D804(Actor* thisx, GlobalContext* globalCtx) { + EnIshi* this = THIS; + s32 i; + s16 temp; + Gfx* phi_s4; + Vec3f spC4; + Vec3f spB8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095D758.s") + if (!ENISHI_GET_8(&this->actor)) { + phi_s4 = gameplay_field_keep_DL_0066B0; + } else { + phi_s4 = object_ishi_DL_0009B0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095D804.s") + temp = D_8095F6E8[ENISHI_GET_8(&this->actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095DABC.s") + for (i = 0; i < ARRAY_COUNT(D_8095F74C); i++) { + spB8.x = ((Rand_ZeroOne() - 0.5f) * 8.0f) + this->actor.world.pos.x; + spB8.y = (Rand_ZeroOne() * 5.0f) + this->actor.world.pos.y + 5.0f; + spB8.z = ((Rand_ZeroOne() - 0.5f) * 8.0f) + this->actor.world.pos.z; + Math_Vec3f_Copy(&spC4, &this->actor.velocity); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095DDA8.s") + if (this->actor.bgCheckFlags & 1) { + spC4.x *= 0.6f; + spC4.y *= -0.3f; + spC4.z *= 0.6f; + } else if (this->actor.bgCheckFlags & 8) { + spC4.x *= -0.5f; + spC4.y *= 0.5f; + spC4.z *= -0.5f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095DE9C.s") + spC4.x += (Rand_ZeroOne() - 0.5f) * 11.0f; + spC4.y += (Rand_ZeroOne() * 7.0f) + 6.0f; + spC4.z += (Rand_ZeroOne() - 0.5f) * 11.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095DF90.s") + EffectSsKakera_Spawn(globalCtx, &spB8, &spC4, &spB8, -420, (Rand_Next() > 0) ? 65 : 33, 30, 5, 0, D_8095F74C[i], + 3, 10, 40, -1, temp, phi_s4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095DFF0.s") +void func_8095DABC(Actor* thisx, GlobalContext* globalCtx) { + EnIshi* this = THIS; + Vec3f spD8; + Vec3f spCC; + f32 temp_f20; + s16 temp_s1 = 0x1000; + s32 i; + s16 phi_v0; + s16 phi_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E14C.s") + for (i = 0; i < ARRAY_COUNT(D_8095F758); i++) { + temp_s1 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E180.s") + spCC.x = (Math_SinS(temp_s1) * temp_f20) + this->actor.world.pos.x; + spCC.y = (Rand_ZeroOne() * 40.0f) + this->actor.world.pos.y + 5.0f; + spCC.z = (Math_CosS(temp_s1) * temp_f20) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E204.s") + Math_Vec3f_Copy(&spD8, &this->actor.velocity); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E2B0.s") + if (this->actor.bgCheckFlags & 1) { + spD8.x *= 0.9f; + spD8.y *= -0.8f; + spD8.z *= 0.9f; + } else if (this->actor.bgCheckFlags & 8) { + spD8.x *= -0.9f; + spD8.y *= 0.8f; + spD8.z *= -0.9f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/EnIshi_Init.s") + temp_f20 = Rand_ZeroOne() * 10.0f; + spD8.x += temp_f20 * Math_SinS(temp_s1); + spD8.y += (Rand_ZeroOne() * 4.0f) + (Rand_ZeroOne() * i * 0.7f); + spD8.z += temp_f20 * Math_CosS(temp_s1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/EnIshi_Destroy.s") + if (i == 0) { + phi_v0 = 41; + phi_v1 = -450; + } else if (i < 4) { + phi_v0 = 37; + phi_v1 = -380; + } else { + phi_v0 = 69; + phi_v1 = -320; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E5AC.s") + EffectSsKakera_Spawn(globalCtx, &spCC, &spD8, &this->actor.world.pos, phi_v1, phi_v0, 30, 5, 0, D_8095F758[i], + 5, 2, 70, 0, 2, gameplay_field_keep_DL_006420); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E5C0.s") +void func_8095DDA8(EnIshi* this, GlobalContext* globalCtx) { + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E64C.s") + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + if (this->actor.bgCheckFlags & 1) { + sp2C.x += 2.0f * this->actor.velocity.x; + sp2C.y -= 2.0f * this->actor.velocity.y; + sp2C.z += 2.0f * this->actor.velocity.z; + } else if (this->actor.bgCheckFlags & 8) { + sp2C.x -= 2.0f * this->actor.velocity.x; + sp2C.y += 2.0f * this->actor.velocity.y; + sp2C.z -= 2.0f * this->actor.velocity.z; + } + func_800BBFB0(globalCtx, &sp2C, 60.0f, 3, 80, 60, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E660.s") +void func_8095DE9C(EnIshi* this, GlobalContext* globalCtx) { + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E934.s") + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + if (this->actor.bgCheckFlags & 1) { + sp2C.x += 2.0f * this->actor.velocity.x; + sp2C.y -= 2.0f * this->actor.velocity.y; + sp2C.z += 2.0f * this->actor.velocity.z; + } else if (this->actor.bgCheckFlags & 8) { + sp2C.x -= 2.0f * this->actor.velocity.x; + sp2C.y += 2.0f * this->actor.velocity.y; + sp2C.z -= 2.0f * this->actor.velocity.z; + } + func_800BBFB0(globalCtx, &sp2C, 140.0f, 10, 180, 90, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E95C.s") +void func_8095DF90(EnIshi* this, GlobalContext* globalCtx) { + if (!ENISHI_GET_1(&this->actor) && !ENISHI_GET_100(&this->actor)) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, ENISHI_GET_F0(&this->actor) * 0x10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095EA70.s") +void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + s32 temp = D_8095F76C[ENISHI_GET_70(&this->actor)]; + Actor* sp3C; + Vec3f sp30; + f32 sp2C; + f32 temp_f2; + s16 temp_v1_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095EBDC.s") + if (temp >= 0) { + sp3C = Item_DropCollectible(globalCtx, &this->actor.world.pos, temp | (ENISHI_GET_FE00(&this->actor) << 8)); + if (sp3C != NULL) { + Matrix_StatePush(); + Matrix_RotateY(this->actor.shape.rot.y, 0); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, 1); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, 1); + Matrix_GetStateTranslationAndScaledY(1.0f, &sp30); + sp2C = Math3D_Parallel(&sp30, &D_8095F778); + if (sp2C < 0.707f) { + temp_v1_2 = Math_FAtan2F(sp30.z, sp30.x) - sp3C->world.rot.y; + if (ABS_ALT(temp_v1_2) > 0x4000) { + sp3C->world.rot.y = BINANG_ROT180(sp3C->world.rot.y); + } + temp_f2 = sp2C + 0.5f; + if (temp_f2 < 0.5f) { + temp_f2 = 0.5f; + } + sp3C->velocity.y *= temp_f2; + } + Matrix_StatePop(); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F060.s") +void func_8095E14C(EnIshi* this) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F0A4.s") +void func_8095E180(Vec3f* arg0, f32 arg1) { + arg1 += ((Rand_ZeroOne() * 0.2f) - 0.1f) * arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F180.s") + arg0->x -= arg0->x * arg1; + arg0->y -= arg0->y * arg1; + arg0->z -= arg0->z * arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F194.s") +void func_8095E204(EnIshi* this, GlobalContext* globalCtx) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/EnIshi_Update.s") + for (i = 0; i < 3; i++) { + if (Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_INSECT, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 1, + this->actor.cutscene, this->actor.unk20, NULL) == NULL) { + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F210.s") +s32 func_8095E2B0(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp30; + f32 sp2C; + s32 sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F36C.s") + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, + &sp30, &sp28) && + (this->actor.world.pos.y < sp2C)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F61C.s") +void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnIshi* this = THIS; + s32 sp34 = ENISHI_GET_1(&this->actor); + s32 sp30 = ENISHI_GET_4(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F654.s") + if ((sp34 == 0) && (sp30 != 0)) { + this->unk_197 |= 2; + } + + Actor_ProcessInitChain(&this->actor, sInitChain[sp34]); + + if (globalCtx->csCtx.state != 0) { + this->actor.uncullZoneForward += 1000.0f; + } + + if ((this->actor.shape.rot.y == 0) && !(this->unk_197 & 2)) { + this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + } + + Actor_SetScale(&this->actor, D_8095F6B8[sp34]); + func_8095D6E0(&this->actor, globalCtx); + + if ((sp34 == 1) && Flags_GetSwitch(globalCtx, ENISHI_GET_FE00(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } + + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + + if (sp34 == 1) { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.shape.shadowScale = 2.3f; + } else { + this->actor.shape.shadowScale = 2.4f; + this->actor.shape.shadowAlpha = 160; + } + + this->actor.shape.yOffset = D_8095F6C0[sp34]; + + if ((sp30 == 0) && !func_8095D758(this, globalCtx, 0)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_8095E2B0(this, globalCtx)) { + this->unk_197 |= 1; + } + + this->unk_196 = Object_GetIndex(&globalCtx->objectCtx, D_8095F6E8[ENISHI_GET_8(&this->actor)]); + if (this->unk_196 < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + func_8095E5AC(this); +} + +void EnIshi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyCylinder(globalCtx, &THIS->collider); +} + +void func_8095E5AC(EnIshi* this) { + this->actionFunc = func_8095E5C0; +} + +void func_8095E5C0(EnIshi* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_196)) { + this->actor.objBankIndex = this->unk_196; + this->actor.flags &= ~0x10; + if (!ENISHI_GET_8(&this->actor)) { + this->actor.draw = func_8095F61C; + } else { + this->actor.draw = func_8095F654; + } + func_8095E64C(this); + } +} + +void func_8095E64C(EnIshi* this) { + this->actionFunc = func_8095E660; +} + +void func_8095E660(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp38 = ENISHI_GET_1(&this->actor); + s32 sp34 = (this->collider.base.acFlags & AC_HIT) != 0; + s32 sp30 = this->unk_197 & 2; + + if (sp34) { + this->collider.base.acFlags &= ~AC_HIT; + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + func_8095E934(this); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, D_8095F7AC[sp38]); + if (ENISHI_GET_2(&this->actor)) { + func_8095E204(this, globalCtx); + } + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + return; + } + + if (sp34 && (sp38 == 0) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x508)) { + if (sp30 != 0) { + func_8095DFF0(this, globalCtx); + func_8095F060(this); + return; + } + func_8095DF90(this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, D_8095F6D4[sp38], D_8095F6D0[sp38]); + D_8095F6D8[sp38](&this->actor, globalCtx); + D_8095F6E0[sp38](this, globalCtx); + Actor_MarkForDeath(&this->actor); + return; + } + + if (sp34) { + this->unk_195 = 5; + } + + if ((this->actor.xzDistToPlayer < 600.0f) || (sp30 != 0)) { + if (this->unk_195 > 0) { + this->unk_195--; + if (this->unk_195 == 0) { + this->collider.base.colType = sCylinderInit[sp38].base.colType; + } else { + this->collider.base.colType = COLTYPE_NONE; + } + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if ((this->actor.xzDistToPlayer < 90.0f) && (sp30 == 0)) { + if (sp38 == 1) { + Actor_PickUp(&this->actor, globalCtx, 0, 80.0f, 20.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, 0, 50.0f, 10.0f); + } + } + } +} + +void func_8095E934(EnIshi* this) { + this->actionFunc = func_8095E95C; + this->actor.room = -1; + this->actor.flags |= 0x10; +} + +void func_8095E95C(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + s32 sp2C; + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + this->actor.room = globalCtx->roomCtx.currRoom.num; + if (ENISHI_GET_1(&this->actor) == 1) { + Flags_SetSwitch(globalCtx, ENISHI_GET_FE00(&this->actor)); + } + func_8095EA70(this); + func_8095E14C(this); + func_8095E180(&this->actor.velocity, D_8095F6C8[ENISHI_GET_1(&this->actor)]); + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + } else { + sp30.x = this->actor.world.pos.x; + sp30.y = this->actor.world.pos.y + 20.0f; + sp30.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); + } +} + +void func_8095EA70(EnIshi* this) { + f32 sp24; + + this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; + this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; + if (!ENISHI_GET_1(&this->actor)) { + sp24 = Rand_ZeroOne() - 0.9f; + D_8095F690 = sp24 * 11000.0f; + D_8095F694 = ((Rand_ZeroOne() - 0.5f) * 3000.0f) * (fabsf(sp24) + 0.1f); + } else { + sp24 = Rand_ZeroOne() - 0.5f; + D_8095F690 = sp24 * 6000.0f; + D_8095F694 = ((Rand_ZeroOne() - 0.5f) * 1200.0f) * (fabsf(sp24) + 0.5f); + } + this->actor.colChkInfo.mass = 200; + this->unk_194 = 100; + this->actionFunc = func_8095EBDC; +} + +void func_8095EBDC(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp70 = ENISHI_GET_1(&this->actor); + s16 temp_s0; + s32 i; + s16 phi_s0; + Vec3f sp58; + s32 temp_v0 = (this->collider.base.atFlags & AT_HIT) != 0; + + if (temp_v0) { + this->collider.base.atFlags &= ~AT_HIT; + } + + this->unk_194--; + + if ((this->actor.bgCheckFlags & 9) || temp_v0 || (this->unk_194 <= 0)) { + func_8095DF90(this, globalCtx); + D_8095F6D8[sp70](&this->actor, globalCtx); + + if (!(this->actor.bgCheckFlags & 0x20)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, D_8095F6D4[sp70], D_8095F6D0[sp70]); + D_8095F6E0[sp70](this, globalCtx); + } + + if (sp70 == 1) { + s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + + Quake_SetSpeed(quake, 0x4350); + Quake_SetQuakeValues(quake, 3, 0, 0, 0); + Quake_SetCountdown(quake, 7); + func_8013ECE0(this->actor.xyzDistToPlayerSq, 255, 20, 150); + } + + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->actor.bgCheckFlags & 0x40) { + if (sp70 == 0) { + sp58.x = this->actor.world.pos.x; + sp58.y = this->actor.world.pos.y + this->actor.depthInWater; + sp58.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 350); + EffectSsGRipple_Spawn(globalCtx, &sp58, 150, 650, 0); + } else { + sp58.y = this->actor.world.pos.y + this->actor.depthInWater; + + for (phi_s0 = 0, i = 0; i < 11; i++, phi_s0 += 0x1746) { + sp58.x = (Math_SinS((s32)(Rand_ZeroOne() * 2000.0f) + phi_s0) * 50.0f) + this->actor.world.pos.x; + sp58.z = (Math_CosS((s32)(Rand_ZeroOne() * 2000.0f) + phi_s0) * 50.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 350); + } + + sp58.x = this->actor.world.pos.x; + sp58.z = this->actor.world.pos.z; + EffectSsGRipple_Spawn(globalCtx, &sp58, 500, 900, 4); + } + + this->actor.terminalVelocity = -6.0f; + this->actor.velocity.x *= 0.12f; + this->actor.velocity.y *= 0.4f; + this->actor.velocity.z *= 0.12f; + this->actor.gravity *= 0.5f; + + D_8095F690 >>= 2; + D_8095F694 >>= 2; + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + this->actor.bgCheckFlags &= ~0x40; + } + + Math_StepToF(&this->actor.shape.yOffset, 0.0f, 2.0f); + func_8095E14C(this); + func_8095E180(&this->actor.velocity, D_8095F6C8[sp70]); + Actor_UpdatePos(&this->actor); + this->actor.shape.rot.x += D_8095F690; + this->actor.shape.rot.y += D_8095F694; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_8095F060(EnIshi* this) { + this->actor.flags |= 0x10; + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_8095F0A4; +} + +void func_8095F0A4(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp28 = ENISHI_GET_1(&this->actor); + + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, D_8095F6D4[sp28], D_8095F6D0[sp28]); + D_8095F6D8[sp28](&this->actor, globalCtx); + D_8095F6E0[sp28](this, globalCtx); + this->actor.draw = NULL; + func_8095F180(this); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_8095F180(EnIshi* this) { + this->actionFunc = func_8095F194; +} + +void func_8095F194(EnIshi* this, GlobalContext* globalCtx) { + if (this->actor.cutscene < 0) { + Actor_MarkForDeath(&this->actor); + } else if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnIshi_Update(Actor* thisx, GlobalContext* globalCtx) { + EnIshi* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_8095F210(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp28; + + if ((this->actor.projectedPos.z <= 1200.0f) || ((this->unk_197 & 1) && (this->actor.projectedPos.z < 1300.0f))) { + Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0066B0); + return; + } + + if (this->actor.projectedPos.z < 1300.0f) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + sp28 = (1300.0f - this->actor.projectedPos.z) * 2.55f; + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s32)sp28); + gSPDisplayList(POLY_XLU_DISP++, gameplay_field_keep_DL_006760); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_8095F36C(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->actor.projectedPos.z <= 2150.0f) || ((this->unk_197 & 1) && (this->actor.projectedPos.z < 2250.0f))) { + this->actor.shape.shadowAlpha = 160; + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_field_keep_DL_0061E8); + } else if (this->actor.projectedPos.z < 2250.0f) { + f32 sp20 = (2250.0f - this->actor.projectedPos.z) * 2.55f; + + this->actor.shape.shadowAlpha = sp20 * 0.627451f; + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s32)sp20); + gSPDisplayList(POLY_XLU_DISP++, gameplay_field_keep_DL_0061E8); + } else { + this->actor.shape.shadowAlpha = 0; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_8095F61C(Actor* thisx, GlobalContext* globalCtx) { + EnIshi* this = THIS; + + D_8095F7B0[ENISHI_GET_1(&this->actor)](this, globalCtx); +} + +void func_8095F654(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_ishi_DL_0009B0); +} diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.h b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.h index f68667c7d3..404fec2b1b 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.h +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.h @@ -6,12 +6,26 @@ struct EnIshi; typedef void (*EnIshiActionFunc)(struct EnIshi*, GlobalContext*); +typedef void (*EnIshiUnkFunc)(struct EnIshi*, GlobalContext*); +typedef void (*EnIshiUnkFunc2)(Actor*, GlobalContext*); + +#define ENISHI_GET_1(thisx) ((thisx)->params & 1) +#define ENISHI_GET_2(thisx) (((thisx)->params >> 1) & 1) +#define ENISHI_GET_4(thisx) (((thisx)->params >> 2) & 1) +#define ENISHI_GET_8(thisx) (((thisx)->params >> 3) & 1) +#define ENISHI_GET_70(thisx) (((thisx)->params >> 4) & 7) +#define ENISHI_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) +#define ENISHI_GET_100(thisx) (((thisx)->params >> 8) & 1) +#define ENISHI_GET_FE00(thisx) (((thisx)->params >> 9) & 0x7F) typedef struct EnIshi { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; + /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ EnIshiActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x4]; + /* 0x0194 */ s8 unk_194; + /* 0x0195 */ s8 unk_195; + /* 0x0196 */ s8 unk_196; + /* 0x0197 */ u8 unk_197; } EnIshi; // size = 0x198 extern const ActorInit En_Ishi_InitVars; diff --git a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c index 7390d9f7c9..c1b5d13277 100644 --- a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c +++ b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c @@ -94,7 +94,7 @@ s32 EnJcMato_CheckForHit(EnJcMato* this, GlobalContext* globalCtx) { this->collider.dim.worldSphere.center.z = this->pos.z; if ((this->collider.base.acFlags & AC_HIT) && !this->hitFlag && (this->actor.colChkInfo.damageEffect == 0xF)) { this->collider.base.acFlags &= ~AC_HIT; - Audio_PlayActorSound2(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); globalCtx->interfaceCtx.unk_25C = 1; this->hitFlag = 1; return 1; @@ -128,7 +128,7 @@ void EnJcMato_Idle(EnJcMato* this, GlobalContext* globalCtx) { void EnJcMato_Init(Actor* thisx, GlobalContext* globalCtx) { EnJcMato* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); Collider_InitSphere(globalCtx, &this->collider); Collider_SetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); this->collider.dim.worldSphere.radius = 0xF; diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 631fc26e59..0ccec50154 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -190,7 +190,7 @@ void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { this->songSummonDist = 80.0f; EnKakasi_SetupIdleUnderground(this); } else { - Actor_SetHeight(&this->actor, 60.0f); + Actor_SetFocus(&this->actor, 60.0f); this->unkFunc = EnKakasi_8096F88C; if (gSaveContext.weekEventReg[83] & 0x1) { EnKakasi_InitTimeSkipDialogue(this); @@ -221,24 +221,24 @@ void EnKakasi_8096F88C(GlobalContext* globalCtx, EnKakasi* this) { void EnKakasi_CheckAnimationSfx(EnKakasi* this) { if (this->animIndex == ENKAKASI_ANIM_SIDEWAYS_SHAKING || this->animIndex == ENKAKASI_ANIM_ARMS_CROSSED_STILL) { if (Animation_OnFrame(&this->skelanime, 1.0f) || Animation_OnFrame(&this->skelanime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_SWING); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KAKASHI_SWING); } } if (this->animIndex == ENKAKASI_ANIM_HOPPING_REGULAR || this->animIndex == ENKAKASI_ANIM_SLOWROLL) { if (Animation_OnFrame(&this->skelanime, 4.0f) || Animation_OnFrame(&this->skelanime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_SWING); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KAKASHI_SWING); } if (Animation_OnFrame(&this->skelanime, 1.0f) || Animation_OnFrame(&this->skelanime, 9.0f) || Animation_OnFrame(&this->skelanime, 16.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_KAKASHI_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_KAKASHI_JUMP); } if (Animation_OnFrame(&this->skelanime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KAKASHI_ROLL); } } if (this->animIndex == ENKAKASI_ANIM_SPIN_REACH_OFFER || this->animIndex == ENKAKASI_ANIM_TWIRL) { if (Animation_OnFrame(&this->skelanime, 1.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASH_LONGI_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KAKASH_LONGI_ROLL); } } } @@ -323,7 +323,7 @@ void EnKakasi_TimeSkipDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->actor.flags |= 0x10000; } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->stateFlags1 &= ~0x20; this->unkState196 = 2; this->actor.flags &= ~0x10000; @@ -347,18 +347,18 @@ void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { // first talk to scarecrow dialogue this->actor.textId = 0x1644; - if (func_800B8718(&this->actor, globalCtx) != 0) { + if (func_800B8718(&this->actor, &globalCtx->state)) { this->skelanime.playSpeed = 1.0f; EnKakasi_SetupSongTeach(this, globalCtx); return; } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->skelanime.playSpeed = 1.0f; EnKakasi_SetupDialogue(this); return; } if (globalCtx->actorCtx.unk5 & 0x4) { - func_800B8898(globalCtx, &this->actor, &passedValue1, &passedValue2); + Actor_GetScreenPos(globalCtx, &this->actor, &passedValue1, &passedValue2); if (this->actor.projectedPos.z > -20.0f && passedValue1 > 0 && passedValue1 < 0x140 && passedValue2 > 0 && passedValue2 < 0xF0 && this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { // faster shaking @@ -424,7 +424,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->unkState1A8 = 0; } - if (this->unkMsgState1AC == func_80152498(&globalCtx->msgCtx) && func_80147624(globalCtx) != 0) { + if (this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx) && func_80147624(globalCtx) != 0) { func_801477B4(globalCtx); if (this->unkMsgState1AC == 5) { // bad song input @@ -569,7 +569,7 @@ void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { * before actually teaching */ void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { func_80152434(globalCtx, 0x35); this->unkState1A8 = 0; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -631,7 +631,7 @@ void EnKakasi_TeachingSong(EnKakasi* this, GlobalContext* globalCtx) { this->unk190 = 0; this->unkCounter1A4 = 0; ActorCutscene_Stop(this->actorCutscenes[0]); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_YASE_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YASE_DEAD); if (this) {} this->unkState196 = 2; this->cutsceneCamId = MAIN_CAM; @@ -743,7 +743,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { func_8096FAAC(this, globalCtx); - if (this->unkState1A8 != 0 && func_80152498(&globalCtx->msgCtx) == this->unkMsgState1AC && + if (this->unkState1A8 != 0 && Message_GetState(&globalCtx->msgCtx) == this->unkMsgState1AC && func_80147624(globalCtx) != 0) { func_801477B4(globalCtx); @@ -1011,12 +1011,12 @@ void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { if (globalCtx->sceneNum == SCENE_8ITEMSHOP) { EffectSsGSplash_Spawn(globalCtx, &tempWorldPos, 0, 0, 0, randPlusMinusPoint5Scaled(100.0f) + 200.0f); - Audio_PlaySoundAtPosition(globalCtx, &tempWorldPos, 0x32, NA_SE_EV_BOMB_DROP_WATER); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &tempWorldPos, 0x32, NA_SE_EV_BOMB_DROP_WATER); } else { - func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 5, - 4.0f, 200, 10, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, + this->actor.shape.shadowScale - 20.0f, 5, 4.0f, 200, 10, 1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); } } @@ -1065,7 +1065,7 @@ void EnKakasi_SetupRiseOutOfGround(EnKakasi* this, GlobalContext* globalCtx) { } else { ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[cutsceneIndex], &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actor.draw = EnKakasi_Draw; this->unkState196 = 6; this->actionFunc = EnKakasi_RisingOutOfGround; @@ -1080,9 +1080,9 @@ void EnKakasi_RisingOutOfGround(EnKakasi* this, GlobalContext* globalCtx) { } if (this->actor.shape.yOffset < -10.0f) { if ((globalCtx->gameplayFrames % 8) == 0) { - func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 10, - 8.0f, 500, 10, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, + this->actor.shape.shadowScale - 20.0f, 10, 8.0f, 500, 10, 1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); } Math_ApproachF(&this->actor.shape.yOffset, 0.0f, 0.5f, 200.0f); } else { @@ -1100,7 +1100,7 @@ void EnKakasi_SetupIdleRisen(EnKakasi* this) { void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnKakasi_RisenDialogue; } else { func_800B8614(&this->actor, globalCtx, 70.0f); @@ -1110,7 +1110,7 @@ void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_RisenDialogue(EnKakasi* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { func_801477B4(globalCtx); EnKakasi_SetupIdleRisen(this); } @@ -1140,11 +1140,11 @@ void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx) { } } } else { - Actor_SetHeight(&this->actor, this->unkHeight); + Actor_SetFocus(&this->actor, this->unkHeight); } this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 0x1C); if (this->actor.draw != NULL) { Collider_UpdateCylinder(&this->actor, &this->collider); @@ -1157,8 +1157,7 @@ void EnKakasi_LimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnKakasi* this = (EnKakasi*)actor; if (limbIndex == 4) { - // what is D_801D15B0 ? we didn't have to define it, we store the output though - Matrix_MultiplyVector3fByState(&D_801D15B0, &this->unk1BC); + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk1BC); } } diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.c b/src/overlays/actors/ovl_En_Kame/z_en_kame.c index c8cceba619..86c9242989 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -5,6 +5,7 @@ */ #include "z_en_kame.h" +#include "objects/object_tl/object_tl.h" #define FLAGS 0x00000405 @@ -15,21 +16,31 @@ void EnKame_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKame_Update(Actor* thisx, GlobalContext* globalCtx); void EnKame_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80AD70A0(EnKame* this); void func_80AD70EC(EnKame* this, GlobalContext* globalCtx); +void func_80AD71B4(EnKame* this); void func_80AD7254(EnKame* this, GlobalContext* globalCtx); +void func_80AD73A8(EnKame* this); void func_80AD7424(EnKame* this, GlobalContext* globalCtx); +void func_80AD76CC(EnKame* this); void func_80AD7798(EnKame* this, GlobalContext* globalCtx); +void func_80AD792C(EnKame* this); void func_80AD7948(EnKame* this, GlobalContext* globalCtx); +void func_80AD7B18(EnKame* this); void func_80AD7B90(EnKame* this, GlobalContext* globalCtx); void func_80AD7D40(EnKame* this, GlobalContext* globalCtx); +void func_80AD7DA4(EnKame* this); void func_80AD7E0C(EnKame* this, GlobalContext* globalCtx); +void func_80AD7EC0(EnKame* this); void func_80AD7F10(EnKame* this, GlobalContext* globalCtx); void func_80AD7FF8(EnKame* this, GlobalContext* globalCtx); void func_80AD810C(EnKame* this, GlobalContext* globalCtx); +void func_80AD8148(EnKame* this, GlobalContext* globalCtx); void func_80AD825C(EnKame* this, GlobalContext* globalCtx); +void func_80AD8364(EnKame* this); void func_80AD8388(EnKame* this, GlobalContext* globalCtx); +void func_80AD8D64(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Kame_InitVars = { ACTOR_EN_KAME, ACTORCAT_ENEMY, @@ -42,18 +53,29 @@ const ActorInit En_Kame_InitVars = { (ActorFunc)EnKame_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AD8DE0 = { - { COLTYPE_HARD, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7CF7FFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7CF7FFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 35, 40, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80AD8E0C = { 3, 15, 30, 80 }; +static CollisionCheckInfoInit sColChkInfoInit = { 3, 15, 30, 80 }; -// static DamageTable sDamageTable = { -static DamageTable D_80AD8E14 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -88,107 +110,734 @@ static DamageTable D_80AD8E14 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AD8E44[] = { +static TexturePtr D_80AD8E34[] = { object_tl_Tex_0055A0, object_tl_Tex_0057A0, object_tl_Tex_0059A0, + object_tl_Tex_0057A0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 1, ICHAIN_CONTINUE), ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3500, ICHAIN_STOP), }; -#endif +static s32 D_80AD8E50 = false; -extern ColliderCylinderInit D_80AD8DE0; -extern CollisionCheckInfoInit D_80AD8E0C; -extern DamageTable D_80AD8E14; -extern InitChainEntry D_80AD8E44[]; +void EnKame_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKame* this = THIS; -extern UNK_TYPE D_060008B4; -extern UNK_TYPE D_06000AF4; -extern UNK_TYPE D_06001C68; -extern UNK_TYPE D_06002510; -extern UNK_TYPE D_060027D8; -extern UNK_TYPE D_06002F88; -extern UNK_TYPE D_060031DC; -extern UNK_TYPE D_060035EC; -extern UNK_TYPE D_06004210; -extern UNK_TYPE D_0600823C; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime1, &object_tl_Skel_007C70, &object_tl_Anim_004210, this->jointTable1, + this->morphTable1, 13); + SkelAnime_InitFlex(globalCtx, &this->skelAnime2, &object_tl_Skel_001A50, &object_tl_Anim_000B30, this->jointTable2, + this->morphTable2, 4); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 55.0f); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/EnKame_Init.s") + if (!D_80AD8E50) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/EnKame_Destroy.s") + for (i = 0; i < ARRAY_COUNT(D_80AD8E34); i++) { + D_80AD8E34[i] = Lib_SegmentedToVirtual(D_80AD8E34[i]); + } + D_80AD8E50 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD6F34.s") + func_80AD70A0(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD6F9C.s") +void EnKame_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKame* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7018.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD70A0.s") +void func_80AD6F34(EnKame* this) { + if (this->unk_29C != 0) { + this->unk_29C++; + if (this->unk_29C == 4) { + this->unk_29C = 0; + } + } else if (Rand_ZeroOne() < 0.05f) { + this->unk_29C = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD70EC.s") +void func_80AD6F9C(EnKame* this) { + this->unk_29D = 10; + this->unk_2B4 = 0.6f; + this->unk_2B8 = 0.90000004f; + this->unk_2B0 = 1.0f; + this->collider.base.colType = COLTYPE_HIT3; + this->unk_2A2 = 80; + this->actor.flags &= ~0x400; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD71B4.s") +void func_80AD7018(EnKame* this, GlobalContext* globalCtx) { + if (this->unk_29D == 10) { + this->unk_29D = 0; + this->collider.base.colType = COLTYPE_HIT6; + this->unk_2B0 = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2C8, 10, 2, 0.3f, 0.2f); + this->actor.flags |= 0x400; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7254.s") +void func_80AD70A0(EnKame* this) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_004210, -5.0f); + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80AD70EC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD73A8.s") +void func_80AD70EC(EnKame* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7424.s") + if (Animation_OnFrame(&this->skelAnime1, 10.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_VOICE); + this->unk_2A0 = 40; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7568.s") + if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && + (this->actor.xzDistToPlayer < 240.0f)) { + func_80AD73A8(this); + } else if (SkelAnime_Update(&this->skelAnime1)) { + func_80AD71B4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD75A8.s") +void func_80AD71B4(EnKame* this) { + Animation_MorphToLoop(&this->skelAnime1, &object_tl_Anim_00823C, -5.0f); + this->actor.speedXZ = 0.5f; + this->unk_29E = Animation_GetLastFrame(&object_tl_Anim_00823C) * ((s32)Rand_ZeroFloat(5.0f) + 3); + this->unk_2A4 = this->actor.shape.rot.y; + this->collider.base.acFlags |= (AC_HARD | AC_ON); + this->collider.base.colType = COLTYPE_HARD; + this->actionFunc = func_80AD7254; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD76CC.s") +void func_80AD7254(EnKame* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7798.s") + if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && + (this->actor.xzDistToPlayer < 240.0f)) { + func_80AD73A8(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD792C.s") + SkelAnime_Update(&this->skelAnime1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7948.s") + if (this->unk_2A4 != this->actor.shape.rot.y) { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk_2A4, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 40.0f) { + this->unk_2A4 = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + (Rand_Next() >> 0x14); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7B18.s") + this->unk_29E--; + if (this->unk_29E == 0) { + func_80AD70A0(this); + } else if (Animation_OnFrame(&this->skelAnime1, 0.0f) || Animation_OnFrame(&this->skelAnime1, 15.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_WALK); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7B90.s") +void func_80AD73A8(EnKame* this) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_001C68, -3.0f); + this->unk_29E = 0; + this->unk_2AC = 1.0f; + this->unk_2A8 = 1.0f; + this->actor.speedXZ = 0.0f; + if (this->unk_2A0 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_VOICE); + } + this->actionFunc = func_80AD7424; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7C54.s") +void func_80AD7424(EnKame* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7D40.s") + if (SkelAnime_Update(&this->skelAnime1)) { + if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && + ((this->unk_29E == 0) || (this->actor.xzDistToPlayer < 120.0f))) { + func_80AD76CC(this); + } else { + this->unk_29E--; + if (this->unk_29E == 0) { + func_80AD7B18(this); + } + } + } else if (this->skelAnime1.curFrame > 2.0f) { + this->unk_2AC = 1.5f - ((this->skelAnime1.curFrame - 2.0f) * (7.0f / 30)); + this->unk_2A8 = 1.5f - ((this->skelAnime1.curFrame - 2.0f) * (1.0f / 12)); + } else { + f32 frame = this->skelAnime1.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7DA4.s") + this->unk_2AC = (0.25f * frame) + 1.0f; + this->unk_2A8 = (0.25f * frame) + 1.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7E0C.s") +void func_80AD7568(EnKame* this) { + this->actor.speedXZ = this->unk_2A6 * (5.0f / 7552); + this->actor.shape.rot.z = this->unk_2A6 * 0.11016949f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7EC0.s") +void func_80AD75A8(EnKame* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_80AD8E54 = { 250, 250, 250, 255 }; + static Color_RGBA8 D_80AD8E58 = { 180, 180, 180, 255 }; + static Vec3f D_80AD8E5C = { 0.0f, 0.75f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7F10.s") + if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ >= 3.0f)) { + if ((globalCtx->gameplayFrames % 2) == 0) { + u32 temp_v0 = func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7FA4.s") + if ((temp_v0 == 0) || (temp_v0 == 1)) { + func_800B1210(globalCtx, &this->actor.world.pos, &D_80AD8E5C, &gZeroVec3f, 550, 100); + } else if (temp_v0 == 14) { + func_800B0DE0(globalCtx, &this->actor.world.pos, &D_80AD8E5C, &gZeroVec3f, &D_80AD8E54, &D_80AD8E58, + 550, 100); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7FF8.s") + if (this->unk_2A6 > 0x1200) { + func_800B9010(&this->actor, NA_SE_EN_PAMET_ROLL - SFX_FLAG); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8060.s") +void func_80AD76CC(EnKame* this) { + if (this->actor.draw == EnKame_Draw) { + this->actor.draw = func_80AD8D64; + this->unk_2A6 = 0x3B00; + this->unk_2AC = 0.5f; + func_80AD7568(this); + this->unk_29E = 15; + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_CUTTER_ON); + this->unk_2BC.y = this->actor.home.pos.y - 100.0f; + } else { + this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + Math_Vec3f_Copy(&this->unk_2BC, &this->actor.home.pos); + this->unk_29E = 0; + } + this->actor.flags |= 0x10; + this->actionFunc = func_80AD7798; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD810C.s") +void func_80AD7798(EnKame* this, GlobalContext* globalCtx) { + if (this->unk_29E == 15) { + this->unk_2AC += 0.2f; + if (this->unk_2AC > 1.1f) { + this->unk_29E--; + this->collider.base.atFlags |= AT_ON; + this->unk_2AC = 1.0f; + } + } else if (this->unk_29E > 0) { + this->unk_29E--; + } else if (Math_ScaledStepToS(&this->unk_2A6, 0x3B00, (s32)(this->unk_2A6 * 0.09f) + 45)) { + if (this->unk_2BC.y < this->actor.home.pos.y) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->unk_2BC.x = (Math_SinS(this->actor.world.rot.y) * 360.0f) + this->actor.world.pos.x; + this->unk_2BC.z = (Math_CosS(this->actor.world.rot.y) * 360.0f) + this->actor.world.pos.z; + } + func_80AD792C(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8148.s") + this->actor.shape.rot.y += this->unk_2A6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD825C.s") + if (!(this->unk_2BC.y < this->actor.home.pos.y) || (this->actionFunc != func_80AD7798)) { + func_80AD7568(this); + } + func_80AD75A8(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8364.s") +void func_80AD792C(EnKame* this) { + this->unk_29E = -1; + this->actionFunc = func_80AD7948; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8388.s") +void func_80AD7948(EnKame* this, GlobalContext* globalCtx) { + s32 temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD84C0.s") + this->actor.shape.rot.y += this->unk_2A6; + func_80AD75A8(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/EnKame_Update.s") + if (this->unk_29E == -1) { + s16 temp_v0 = Actor_YawToPoint(&this->actor, &this->unk_2BC) - this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8A48.s") + temp_v1 = ABS_ALT(temp_v0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8AF8.s") + if ((this->actor.bgCheckFlags & 8) || (temp_v1 > 0x3000) || + (Actor_XZDistanceToPoint(&this->actor, &this->unk_2BC) < 50.0f)) { + s8 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/EnKame_Draw.s") + if (this->unk_2BC.y < this->actor.home.pos.y) { + this->unk_29E = 0x300; + } else { + this->unk_29E = 0; + } + } + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8CEC.s") + if (Math_ScaledStepToS(&this->unk_2A6, this->unk_29E, (s32)(this->unk_2A6 * 0.09f) + 45)) { + if (this->unk_29E == 0) { + if (this->unk_2AC >= 1.0f) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_CUTTER_OFF); + } + this->unk_2AC -= 0.1f; + this->collider.base.atFlags &= ~AT_ON; + if (this->unk_2AC < 0.5f) { + this->actor.flags &= ~0x10; + func_80AD7B18(this); + } + } else { + func_80AD76CC(this); + } + } + func_80AD7568(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8D64.s") +void func_80AD7B18(EnKame* this) { + this->actor.draw = EnKame_Draw; + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_0031DC, -3.0f); + this->actor.speedXZ = 0.0f; + this->unk_2AC = 0.1f; + this->unk_2A8 = 1.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_80AD7B90; +} + +void func_80AD7B90(EnKame* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime1)) { + func_80AD71B4(this); + } else if (this->skelAnime1.curFrame > 7.0f) { + this->unk_2AC = 1.5f - ((this->skelAnime1.curFrame - 7.0f) * (1.0f / 6)); + this->unk_2A8 = 1.5f - ((this->skelAnime1.curFrame - 7.0f) * (1.0f / 6)); + } else { + f32 frame = this->skelAnime1.curFrame; + + this->unk_2AC = (0.2f * frame) + 0.1f; + this->unk_2A8 = ((1.0f / 14) * frame) + 1.0f; + } +} + +void func_80AD7C54(EnKame* this) { + if (this->actionFunc == func_80AD7E0C) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_0035EC, -3.0f); + this->unk_29E = 1; + this->collider.info.bumper.dmgFlags &= ~0x8000; + } else { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_0039C0, -3.0f); + this->unk_29E = 0; + this->collider.info.bumper.dmgFlags |= 0x8000; + } + + this->actor.draw = EnKame_Draw; + this->actor.speedXZ = 0.0f; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); + this->actor.flags &= ~0x10; + this->actor.shape.rot.z = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_REVERSE); + this->actionFunc = func_80AD7D40; +} + +void func_80AD7D40(EnKame* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime1)) { + if (this->unk_29E == 1) { + func_80AD71B4(this); + } else { + this->unk_29E = 200; + func_80AD7DA4(this); + } + } +} + +void func_80AD7DA4(EnKame* this) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_0027D8, -3.0f); + this->collider.base.acFlags |= AC_ON; + this->collider.base.acFlags &= ~AC_HARD; + this->collider.base.colType = COLTYPE_HIT6; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80AD7E0C; +} + +void func_80AD7E0C(EnKame* this, GlobalContext* globalCtx) { + if (this->unk_29E > 0) { + this->unk_29E--; + if (SkelAnime_Update(&this->skelAnime1)) { + if (Rand_ZeroOne() > 0.5f) { + Animation_PlayOnce(&this->skelAnime1, &object_tl_Anim_0027D8); + } else { + Animation_PlayOnce(&this->skelAnime1, &object_tl_Anim_002F88); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_ROAR); + } + } + } else { + func_80AD7EC0(this); + } +} + +void func_80AD7EC0(EnKame* this) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_002510, -3.0f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_WAKEUP); + this->actionFunc = func_80AD7F10; +} + +void func_80AD7F10(EnKame* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime1)) { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + func_80AD71B4(this); + } else if (this->skelAnime1.curFrame >= 10.0f) { + this->actor.shape.shadowDraw = NULL; + this->collider.base.acFlags &= ~AC_ON; + this->collider.info.bumper.dmgFlags &= ~0x8000; + } +} + +void func_80AD7FA4(EnKame* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + func_800BE504(&this->actor, &this->collider); + this->actionFunc = func_80AD7FF8; +} + +void func_80AD7FF8(EnKame* this, GlobalContext* globalCtx) { + if (this->unk_2A2 != 0) { + this->unk_2A2--; + } + + if (this->unk_2A2 == 0) { + func_80AD7018(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + func_80AD8148(this, NULL); + } else { + this->actor.world.rot.y = this->actor.shape.rot.y; + func_80AD7DA4(this); + } + } +} + +void func_80AD8060(EnKame* this) { + s16 sp36 = Animation_GetLastFrame(&object_tl_Anim_0008B4); + + Animation_Change(&this->skelAnime1, &object_tl_Anim_0008B4, 1.0f, 0.0f, sp36, 2, -3.0f); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, sp36); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_DAMAGE); + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = func_80AD810C; +} + +void func_80AD810C(EnKame* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime1)) { + func_80AD7DA4(this); + } +} + +void func_80AD8148(EnKame* this, GlobalContext* globalCtx) { + Animation_PlayLoop(&this->skelAnime1, &object_tl_Anim_000AF4); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.atFlags &= ~(AC_HARD | AC_HIT); + this->actor.velocity.y = 15.0f; + this->actor.speedXZ = 1.5f; + if (globalCtx != NULL) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + if (this->actor.draw == func_80AD8D64) { + this->actor.draw = EnKame_Draw; + } else { + func_800BE504(&this->actor, &this->collider); + } + } + this->actor.bgCheckFlags &= ~0x1; + this->actor.flags &= ~0x1; + this->actor.flags |= 0x10; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_DEAD); + this->unk_29E = 0; + this->actionFunc = func_80AD825C; +} + +void func_80AD825C(EnKame* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime1); + if ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_LAND); + func_80AD8364(this); + } else { + if (this->unk_29E == 1) { + this->actor.colorFilterTimer = 100; + } else if (this->actor.colorFilterTimer == 0) { + Actor_SetColorFilter(&this->actor, 0xC000, 255, 0, 100); + } + this->actor.shape.rot.x += Rand_S16Offset(0x700, 0x1400); + this->actor.shape.rot.y += (s16)Rand_ZeroFloat(5120.0f); + this->actor.shape.rot.z += Rand_S16Offset(0x700, 0x1400); + } +} + +void func_80AD8364(EnKame* this) { + this->unk_29E = 20; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80AD8388; +} + +void func_80AD8388(EnKame* this, GlobalContext* globalCtx) { + Vec3f sp34; + + SkelAnime_Update(&this->skelAnime1); + this->actor.colorFilterTimer = 100; + if (this->unk_29E > 0) { + this->unk_29E--; + if (this->unk_29E == 0) { + SoundSource_PlaySfxEachFrameAtFixedWorldPos(globalCtx, &this->actor.world.pos, 21, + NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } + } else { + this->actor.scale.x -= 0.001f; + if (this->actor.scale.x <= 0.0f) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + Actor_MarkForDeath(&this->actor); + } else { + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + } + sp34.x = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.x; + sp34.y = this->actor.world.pos.y + 15.0f; + sp34.z = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.z; + func_800B3030(globalCtx, &sp34, &gZeroVec3f, &gZeroVec3f, 100, 0, 2); + } +} + +void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + + Actor_SetDropFlag(&this->actor, &this->collider.info); + if ((this->unk_29D == 10) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + return; + } + + func_80AD7018(this, globalCtx); + if (this->actor.colChkInfo.damageEffect == 13) { + return; + } + + if (this->actor.colChkInfo.damageEffect == 14) { + func_80AD8148(this, globalCtx); + } else if (this->actor.colChkInfo.damageEffect == 15) { + if (this->collider.base.acFlags & AC_HARD) { + func_80AD7C54(this); + } else if (!Actor_ApplyDamage(&this->actor)) { + func_80AD8148(this, globalCtx); + } else { + func_80AD8060(this); + } + } else if ((this->actionFunc == func_80AD70EC) || (this->actionFunc == func_80AD7254)) { + func_80AD73A8(this); + this->unk_29E = 21; + } else if (!(this->collider.base.acFlags & AC_HARD)) { + if (this->actor.colChkInfo.damageEffect == 5) { + this->unk_2A2 = 40; + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->unk_2B4 = 0.6f; + this->unk_2B0 = 2.0f; + this->unk_29D = 30; + func_80AD7FA4(this); + } else if (this->actor.colChkInfo.damageEffect == 1) { + this->unk_2A2 = 40; + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + func_80AD7FA4(this); + } else if (this->actor.colChkInfo.damageEffect == 3) { + func_80AD6F9C(this); + if (!Actor_ApplyDamage(&this->actor)) { + this->unk_2A2 = 3; + this->collider.base.acFlags &= ~AC_ON; + } + func_80AD7FA4(this); + } else { + if (this->actor.colChkInfo.damageEffect == 2) { + this->unk_2B4 = 0.6f; + this->unk_2B0 = 4.0f; + this->unk_29D = 0; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_2B4 = 0.6f; + this->unk_2B0 = 4.0f; + this->unk_29D = 20; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, + this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + + if (!Actor_ApplyDamage(&this->actor)) { + func_80AD8148(this, globalCtx); + } else { + func_80AD8060(this); + } + } + } + } + + if ((globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < 40000.0f) && + (this->collider.base.acFlags & AC_ON)) { + func_80AD7018(this, globalCtx); + func_80AD7C54(this); + } +} + +void EnKame_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnKame* this = THIS; + + func_80AD6F34(this); + + if (this->unk_2A0 != 0) { + this->unk_2A0--; + } + + func_80AD84C0(this, globalCtx); + + if ((this->collider.base.atFlags & AT_HIT) && (this->collider.base.atFlags & AT_BOUNCED)) { + this->collider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); + func_80AD76CC(this); + if (Actor_XZDistanceToPoint(&this->actor, &this->unk_2BC) < 50.0f) { + this->collider.base.atFlags &= ~AT_ON; + } + this->unk_2A6 = 0x3B00; + func_80AD7568(this); + } + + this->actionFunc(this, globalCtx); + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 60.0f, 40.0f, 0x1F); + + if (this->actor.shape.shadowDraw != NULL) { + Actor_SetFocus(&this->actor, 25.0f); + Collider_UpdateCylinder(&this->actor, &this->collider); + } + + if (this->collider.base.atFlags & AT_ON) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->unk_2B0 > 0.0f) { + if (this->unk_29D != 10) { + Math_StepToF(&this->unk_2B0, 0.0f, 0.05f); + this->unk_2B4 = (this->unk_2B0 + 1.0f) * 0.3f; + if (this->unk_2B4 > 0.6f) { + this->unk_2B4 = 0.6f; + } else { + this->unk_2B4 = this->unk_2B4; + } + } else if (!Math_StepToF(&this->unk_2B8, 0.6f, 0.015000001f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +s32 func_80AD8A48(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnKame* this = THIS; + + if ((this->actionFunc == func_80AD7424) || (this->actionFunc == func_80AD7B90)) { + if (limbIndex == 2) { + Matrix_Scale(this->unk_2A8, this->unk_2AC, this->unk_2A8, MTXMODE_APPLY); + } else if ((limbIndex == 11) || (limbIndex == 9) || (limbIndex == 7) || (limbIndex == 5)) { + Matrix_Scale(this->unk_2A8, this->unk_2AC, this->unk_2AC, MTXMODE_APPLY); + } + } + return false; +} + +void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80AD8E68[] = { + { 1500.0f, 0.0f, -2000.0f }, { 1500.0f, 0.0f, 2000.0f }, { 1500.0f, 2000.0f, 0.0f }, + { 1500.0f, -2000.0f, 0.0f }, { 2500.0f, 0.0f, 0.0f }, + }; + static s8 D_80AD8EA4[] = { -1, -1, -1, 0, -1, -1, 1, -1, 2, -1, 3, -1, 4 }; + EnKame* this = THIS; + + if (D_80AD8EA4[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->unk_2C8[D_80AD8EA4[limbIndex]]); + } + + if (limbIndex == 1) { + s32 i; + Vec3f* ptr; + Vec3f* ptr2; + + if (this->actor.shape.shadowDraw == NULL) { + Matrix_GetStateTranslation(&this->actor.world.pos); + } + + ptr2 = D_80AD8E68; + ptr = &this->unk_2C8[5]; + for (i = 0; i < ARRAY_COUNT(D_80AD8E68); i++) { + Matrix_MultiplyVector3fByState(ptr2, ptr); + ptr2++; + ptr++; + } + } +} + +void EnKame_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKame* this = THIS; + Vec3f sp40; + + if (this->actor.shape.shadowDraw == 0) { + Math_Vec3f_Copy(&sp40, &this->actor.world.pos); + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_80AD8E34[this->unk_29C]); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime1.skeleton, this->skelAnime1.jointTable, + this->skelAnime1.dListCount, func_80AD8A48, func_80AD8AF8, &this->actor); + func_800BE680(globalCtx, &this->actor, this->unk_2C8, 10, this->unk_2B4, this->unk_2B8, this->unk_2B0, + this->unk_29D); + + if (this->actor.shape.shadowDraw == NULL) { + ActorShadow_DrawCircle(&this->actor, NULL, globalCtx); + Actor_SetFocus(&this->actor, 25.0f); + Collider_UpdateCylinder(&this->actor, &this->collider); + Math_Vec3f_Copy(&this->actor.world.pos, &sp40); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 Enkame_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnKame* this = THIS; + + if (limbIndex == 1) { + pos->y -= 700.0f; + } + + if ((this->unk_2AC != 1.0f) && (limbIndex == 3)) { + Matrix_Scale(1.0f, this->unk_2AC, this->unk_2AC, MTXMODE_APPLY); + } + return false; +} + +void func_80AD8D64(Actor* thisx, GlobalContext* globalCtx) { + EnKame* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime2.skeleton, this->skelAnime2.jointTable, + this->skelAnime2.dListCount, Enkame_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.h b/src/overlays/actors/ovl_En_Kame/z_en_kame.h index efdff38123..115bf137fd 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.h +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.h @@ -9,9 +9,28 @@ typedef void (*EnKameActionFunc)(struct EnKame*, GlobalContext*); typedef struct EnKame { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x154]; + /* 0x0144 */ SkelAnime skelAnime1; + /* 0x0188 */ Vec3s jointTable1[13]; + /* 0x01D6 */ Vec3s morphTable1[13]; + /* 0x0224 */ SkelAnime skelAnime2; + /* 0x0268 */ Vec3s jointTable2[4]; + /* 0x0280 */ Vec3s morphTable2[4]; /* 0x0298 */ EnKameActionFunc actionFunc; - /* 0x029C */ char unk_29C[0xF0]; + /* 0x029C */ u8 unk_29C; + /* 0x029D */ u8 unk_29D; + /* 0x029E */ s16 unk_29E; + /* 0x02A0 */ s16 unk_2A0; + /* 0x02A2 */ s16 unk_2A2; + /* 0x02A4 */ s16 unk_2A4; + /* 0x02A6 */ s16 unk_2A6; + /* 0x02A8 */ f32 unk_2A8; + /* 0x02AC */ f32 unk_2AC; + /* 0x02B0 */ f32 unk_2B0; + /* 0x02B4 */ f32 unk_2B4; + /* 0x02B8 */ f32 unk_2B8; + /* 0x02BC */ Vec3f unk_2BC; + /* 0x02C8 */ Vec3f unk_2C8[10]; + /* 0x0340 */ ColliderCylinder collider; } EnKame; // size = 0x38C extern const ActorInit En_Kame_InitVars; diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index 63c5854ea0..fdf1c3e48d 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -5,6 +5,8 @@ */ #include "z_en_kanban.h" +#include "objects/object_kanban/object_kanban.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000019 @@ -15,7 +17,6 @@ void EnKanban_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx); void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Kanban_InitVars = { ACTOR_EN_KANBAN, ACTORCAT_PROP, @@ -28,27 +29,1016 @@ const ActorInit En_Kanban_InitVars = { (ActorFunc)EnKanban_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80957300 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF3CFFFFF, 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_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF3CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 50, 5, { 0, 0, 0 } }, }; +static u16 sPartFlags[] = { + PART_UPPER_LEFT, PART_LEFT_UPPER, PART_LEFT_LOWER, PART_RIGHT_UPPER, PART_RIGHT_LOWER, PART_LOWER_LEFT, + PART_UPPER_RIGHT, PART_LOWER_RIGHT, PART_POST_UPPER, PART_POST_LOWER, PART_POST_STAND, +}; + +static Vec3f sPieceOffsets[] = { + /* WHOLE_SIGN */ { 0.0f, 44.0f, 0.0f }, + /* UPPER_HALF */ { 0.0f, 50.0f, 0.0f }, + /* LOWER_HALF */ { 0.0f, 38.0f, 0.0f }, + /* RIGHT_HALF */ { 10.0f, 44.0f, 0.0f }, + /* LEFT_HALF */ { -10.0f, 44.0f, 0.0f }, + /* 2ND_QUAD */ { -10.0f, 50.0f, 0.0f }, + /* 1ST_QUAD */ { 10.0f, 50.0f, 0.0f }, + /* 3RD_QUAD */ { -10.0f, 38.0f, 0.0f }, + /* 4TH_QUAD */ { 10.0f, 38.0f, 0.0f }, + /* UPPER_LEFT */ { -7.5f, 51.0f, 0.0f }, + /* LEFT_UPPER */ { -12.5f, 48.0f, 0.0f }, + /* LEFT_LOWER */ { -12.5f, 40.0f, 0.0f }, + /* LOWER_LEFT */ { -7.5f, 37.0f, 0.0f }, + /* UPPER_RIGHT */ { 7.5f, 51.0f, 0.0f }, + /* RIGHT_UPPER */ { 12.5f, 48.0f, 0.0f }, + /* RIGHT_LOWER */ { 12.5f, 40.0f, 0.0f }, + /* LOWER_RIGHT */ { 7.5f, 37.0f, 0.0f }, + /* POST_UPPER */ { 0.0f, 50.0f, 0.0f }, + /* POST_LOWER */ { 0.0f, 38.0f, 0.0f }, +}; + +static Vec3f sPieceSizes[] = { + /* WHOLE_SIGN */ { 1500.0f, 1000.0f, 0.0f }, + /* UPPER_HALF */ { 1500.0f, 500.0f, 0.0f }, + /* LOWER_HALF */ { 1500.0f, 500.0f, 0.0f }, + /* RIGHT_HALF */ { 700.0f, 1000.0f, 0.0f }, + /* LEFT_HALF */ { 700.0f, 1000.0f, 0.0f }, + /* 2ND_QUAD */ { 700.0f, 500.0f, 0.0f }, + /* 1ST_QUAD */ { 700.0f, 500.0f, 0.0f }, + /* 3RD_QUAD */ { 700.0f, 500.0f, 0.0f }, + /* 4TH_QUAD */ { 700.0f, 500.0f, 0.0f }, + /* UPPER_LEFT */ { 700.0f, 500.0f, 0.0f }, + /* LEFT_UPPER */ { 700.0f, 500.0f, 0.0f }, + /* LEFT_LOWER */ { 700.0f, 500.0f, 0.0f }, + /* LOWER_LEFT */ { 700.0f, 500.0f, 0.0f }, + /* UPPER_RIGHT */ { 700.0f, 500.0f, 0.0f }, + /* RIGHT_UPPER */ { 700.0f, 500.0f, 0.0f }, + /* RIGHT_LOWER */ { 700.0f, 500.0f, 0.0f }, + /* LOWER_RIGHT */ { 700.0f, 500.0f, 0.0f }, + /* POST_UPPER */ { 200.0f, 500.0f, 0.0f }, + /* POST_LOWER */ { 200.0f, 500.0f, 0.0f }, +}; + +static u8 sCutTypes[] = { + /* 1H_OVER */ CUT_VERT_L, /* 2H_OVER */ CUT_VERT_L, + /* 1H_COMBO */ CUT_DIAG_R, /* 2H_COMBO */ CUT_DIAG_R, + /* 1H_LEFT */ CUT_HORIZ, /* 2H_LEFT */ CUT_HORIZ, + /* 1H_COMBO */ CUT_HORIZ, /* 2H_COMBO */ CUT_HORIZ, + /* 1H_RIGHT */ CUT_HORIZ, /* 2H_RIGHT */ CUT_HORIZ, + /* 1H_COMBO */ CUT_HORIZ, /* 2H_COMBO */ CUT_HORIZ, + /* 1H_STAB */ CUT_POST, /* 2H_STAB */ CUT_POST, + /* 1H_COMBO */ CUT_POST, /* 2H_COMBO */ CUT_POST, + /* FLIP_START */ CUT_VERT_L, /* JUMP_START */ CUT_VERT_L, + /* FLIP_END */ CUT_VERT_L, /* JUMP_END */ CUT_VERT_L, + /* */ CUT_VERT_L, /* */ CUT_VERT_L, + /* */ CUT_HORIZ, /* */ CUT_HORIZ, + /* */ CUT_HORIZ, /* */ CUT_HORIZ, + /* */ CUT_HORIZ, /* */ CUT_HORIZ, + /* BACK_LEFT */ CUT_HORIZ, /* BACK_RIGHT */ CUT_HORIZ, + /* OVER_HAMMER */ CUT_POST, /* SIDE_HAMMER */ CUT_POST, + /* 1H_SPIN_ATK */ CUT_POST, /* 2H_SPIN_ATK */ CUT_POST, + /* 1H_BIG_SPIN */ CUT_POST, /* 2H_BIG_SPIN */ CUT_POST, +}; + +static u16 sCutFlags[] = { + /* CUT_POST */ ALL_PARTS, /* CUT_VERT_L */ LEFT_HALF, + /* CUT_HORIZ */ UPPER_HALF, /* CUT_DIAG_L */ UPPERLEFT_HALF, + /* CUT_DIAG_R */ UPPERRIGHT_HALF, /* CUT_VERT_R */ RIGHT_HALF, +}; + +void func_80954960(EnKanban* this) { + f32 nx; + f32 ny; + f32 nz; + + 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); + + this->floorRot.x = -func_80086B30(-nz * ny, 1.0f); + this->floorRot.z = func_80086B30(-nx * ny, 1.0f); + } +} + +void EnKanban_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKanban* this = THIS; + + Actor_SetScale(&this->actor, 0.01f); + if (this->actor.params != ENKANBAN_PIECE) { + this->actor.targetMode = 0; + this->actor.flags |= 1; + this->unk_19A = Rand_ZeroFloat(1.9f); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + + if (this->actor.params == ENKANBAN_FISHING) { + if (LINK_IS_CHILD) { + this->actor.textId = 0x409D; + } else { + this->actor.textId = 0x4090; + } + } else { + this->actor.textId = this->actor.params | ENKANBAN_FISHING; + } + + this->bounceX = 1; + this->partFlags = 0xFFFF; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 50.0f, 4); + func_80954960(this); + } +} + +void EnKanban_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKanban* this = THIS; + + if (this->actionState == ENKANBAN_SIGN) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } +} + +void func_80954BE8(EnKanban* this, GlobalContext* globalCtx) { + s16 yaw; + + if (!this->msgFlag) { + if (this->msgTimer == 0) { + yaw = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (ABS_ALT(yaw) < 0x2800) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->msgFlag = true; + } else { + func_800B8614(&this->actor, globalCtx, 68.0f); + } + } + } else { + this->msgTimer--; + } + } else if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + this->msgFlag = false; + this->msgTimer = 20; + } +} + +#ifdef NON_MATCHING +// Lots of branch likely stuff +void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { + // GlobalContext* globalCtx = globalCtx2; + u8 bounced = false; + s32 pad; + EnKanban* this = THIS; + Player* player = GET_PLAYER(globalCtx); + Vec3f offset; + EnKanban* piece; + EnKanban* signpost; + s32 temp_v0_18; + f32 phi_f0; + s32 pad2; + + this->frameCount++; + + switch (this->actionState) { + case ENKANBAN_SIGN: + if (this->invincibilityTimer != 0) { + this->invincibilityTimer--; + } + + if (this->zTargetTimer != 0) { + this->zTargetTimer--; + } + + if (DECR(this->unk_1A0) == 0) { + this->unk_19C = NULL; + } + + if (this->zTargetTimer == 1) { + this->actor.flags &= ~1; + } + + if (this->partFlags == 0xFFFF) { + func_80954BE8(this, globalCtx); + } + + if ((this->invincibilityTimer == 0) && (this->collider.base.acFlags & AC_HIT)) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->unk_19C != this->collider.base.ac) { + this->unk_19C = this->collider.base.ac; + this->unk_1A0 = 3; + this->invincibilityTimer = 6; + + piece = (EnKanban*)Actor_SpawnAsChild( + &globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_KANBAN, 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, ENKANBAN_PIECE); + if (piece != NULL) { + ColliderInfo* hitItem = this->collider.info.acHitInfo; + s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + u8 i; + + if (hitItem->toucher.dmgFlags & 0x200) { + this->cutType = sCutTypes[player->swordAnimation]; + } else if (hitItem->toucher.dmgFlags & 0x10) { + this->invincibilityTimer = 0; + this->cutType = this->unk_19A + 3; + this->unk_19A = 1 - this->unk_19A; + if (this->unk_199 == 0) { + this->unk_199++; + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.focus.pos, 0x60); + } + } else { + this->cutType = 0; + } + + if ((ABS_ALT(yawDiff) > 0x4000) && !(hitItem->toucher.dmgFlags & 0x10)) { + if (this->cutType == 4) { + this->cutType = 3; + } else if (this->cutType == 1) { + this->cutType = 5; + } + } + + piece->partFlags = sCutFlags[this->cutType] & this->partFlags; + if (piece->partFlags == 0) { + Actor_MarkForDeath(&piece->actor); + return; + } + + piece->partCount = 0; + for (i = 0; i < 11; i++) { + if (sPartFlags[i] & piece->partFlags) { + piece->partCount++; + } + } + + this->partFlags &= ~sCutFlags[this->cutType]; + if ((this->partFlags & 0x3FF) == 0) { + this->zTargetTimer = 10; + } + + if ((piece->partFlags & PART_UPPER_LEFT) && (piece->partFlags & PART_LOWER_RIGHT)) { + piece->pieceType = PIECE_WHOLE_SIGN; + } else if ((piece->partFlags & PART_LEFT_UPPER) && (piece->partFlags & PART_RIGHT_UPPER)) { + piece->pieceType = PIECE_UPPER_HALF; + } else if ((piece->partFlags & PART_LEFT_LOWER) && (piece->partFlags & PART_RIGHT_LOWER)) { + piece->pieceType = PIECE_LOWER_HALF; + } else if ((piece->partFlags & PART_UPPER_RIGHT) && (piece->partFlags & PART_LOWER_RIGHT)) { + piece->pieceType = PIECE_RIGHT_HALF; + } else if ((piece->partFlags & PART_UPPER_LEFT) && (piece->partFlags & PART_LOWER_LEFT)) { + piece->pieceType = PIECE_LEFT_HALF; + } else if ((piece->partFlags & PART_UPPER_LEFT) && (piece->partFlags & PART_LEFT_UPPER)) { + piece->pieceType = PIECE_2ND_QUAD; + } else if ((piece->partFlags & PART_UPPER_RIGHT) && (piece->partFlags & PART_RIGHT_UPPER)) { + piece->pieceType = PIECE_1ST_QUAD; + } else if ((piece->partFlags & PART_LEFT_LOWER) && (piece->partFlags & PART_LOWER_LEFT)) { + piece->pieceType = PIECE_3RD_QUAD; + } else if ((piece->partFlags & PART_RIGHT_LOWER) && (piece->partFlags & PART_LOWER_RIGHT)) { + piece->pieceType = PIECE_4TH_QUAD; + } else if (piece->partFlags & PART_UPPER_LEFT) { + piece->pieceType = PIECE_UPPER_LEFT; + } else if (piece->partFlags & PART_LEFT_UPPER) { + piece->pieceType = PIECE_LEFT_UPPER; + } else if (piece->partFlags & PART_LEFT_LOWER) { + piece->pieceType = PIECE_LEFT_LOWER; + } else if (piece->partFlags & PART_LOWER_LEFT) { + piece->pieceType = PIECE_LOWER_LEFT; + } else if (piece->partFlags & PART_UPPER_RIGHT) { + piece->pieceType = PIECE_UPPER_RIGHT; + } else if (piece->partFlags & PART_RIGHT_UPPER) { + piece->pieceType = PIECE_RIGHT_UPPER; + } else if (piece->partFlags & PART_RIGHT_LOWER) { + piece->pieceType = PIECE_RIGHT_LOWER; + } else if (piece->partFlags & PART_LOWER_RIGHT) { + piece->pieceType = PIECE_LOWER_RIGHT; + } else if (piece->partFlags & PART_POST_UPPER) { + piece->pieceType = PIECE_POST_UPPER; + } else if (piece->partFlags & PART_POST_LOWER) { + piece->pieceType = PIECE_POST_LOWER; + } else { + piece->pieceType = PIECE_OTHER; + } + + if (piece->pieceType == PIECE_OTHER) { + piece->pieceType = PIECE_WHOLE_SIGN; + } + + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sPieceOffsets[piece->pieceType], &offset); + piece->actor.world.pos.x += offset.x; + piece->actor.world.pos.y += offset.y; + piece->actor.world.pos.z += offset.z; + + piece->offset.x = -sPieceOffsets[piece->pieceType].x / this->actor.scale.x; + piece->offset.y = -sPieceOffsets[piece->pieceType].y / this->actor.scale.x; + piece->offset.z = -sPieceOffsets[piece->pieceType].z / this->actor.scale.x; + + piece->pieceWidth = sPieceSizes[piece->pieceType].x; + piece->pieceHeight = sPieceSizes[piece->pieceType].y; + piece->actionState = ENKANBAN_AIR; + piece->actor.gravity = -1.0f; + piece->actor.world.rot.y = + BINANG_ROT180((s32)randPlusMinusPoint5Scaled(0x4000) + this->actor.yawTowardsPlayer); + + if ((hitItem->toucher.dmgFlags & 0x10) || (hitItem->toucher.dmgFlags & 8) || + (hitItem->toucher.dmgFlags & 0x80000000)) { + piece->actor.velocity.y = Rand_ZeroFloat(3.0f) + 6.0f; + piece->actor.speedXZ = Rand_ZeroFloat(4.0f) + 6.0f; + } else { + piece->actor.velocity.y = Rand_ZeroFloat(2.0f) + 3.0f; + piece->actor.speedXZ = Rand_ZeroFloat(2.0f) + 3.0f; + } + + if (piece->partCount >= 4) { + piece->bounceX = Rand_ZeroFloat(10.0f) + 6.0f; + piece->bounceZ = Rand_ZeroFloat(10.0f) + 6.0f; + } else { + piece->bounceX = Rand_ZeroFloat(7.0f) + 3.0f; + piece->bounceZ = Rand_ZeroFloat(7.0f) + 3.0f; + } + + piece->spinVel.y = randPlusMinusPoint5Scaled(0x1800); + + if (Rand_ZeroOne() < 0.5f) { + piece->direction = 1; + } else { + piece->direction = -1; + } + piece->airTimer = 100; + piece->actor.flags &= ~1; + piece->actor.flags |= 0x2000000; + this->cutMarkTimer = 5; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SWORD_STRIKE); + } + } + } + + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 44.0f; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actor.xzDistToPlayer > 500.0f) { + this->actor.flags |= 1; + this->partFlags = 0xFFFF; + } + + if (this->cutMarkTimer != 0) { + if (this->cutMarkTimer >= 5) { + this->cutMarkAlpha += 255; + if (this->cutMarkAlpha > 255) { + this->cutMarkAlpha = 255; + } + } else { + this->cutMarkAlpha -= 65; + if (this->cutMarkAlpha < 0) { + this->cutMarkAlpha = 0; + } + } + this->cutMarkTimer--; + } + break; + + case ENKANBAN_AIR: + case ENKANBAN_UNUSED: { + f32 tempX; + f32 tempY; + f32 tempZ; + f32 tempWaterDepth; + u16 tempBgFlags; + u8 onGround; + + if (this->unk_198 != 0) { + this->actor.velocity.y = -2.0f; + Actor_UpdatePos(&this->actor); + } else { + Actor_MoveWithGravity(&this->actor); + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 10.0f, 50.0f, 5); + + tempX = this->actor.world.pos.x; + tempY = this->actor.world.pos.y; + tempZ = this->actor.world.pos.z; + tempBgFlags = this->actor.bgCheckFlags; + tempWaterDepth = this->actor.depthInWater; + this->actor.world.pos.z += ((this->actor.world.pos.y - this->actor.floorHeight) * -50.0f) / 100.0f; + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 50.0f, 4); + func_80954960(this); + + this->actor.world.pos.x = tempX; + this->actor.world.pos.y = tempY; + this->actor.world.pos.z = tempZ; + this->actor.bgCheckFlags = tempBgFlags; + this->actor.depthInWater = tempWaterDepth; + + if (1) {} + + onGround = (this->actor.bgCheckFlags & 1); + + if (this->spinXFlag != 0) { + this->spinRot.x += this->spinVel.x; + this->spinVel.x -= 0x800; + if ((this->spinRot.x <= 0) && onGround) { + this->spinRot.x = 0; + this->spinVel.x = 0; + } + } else { + this->spinRot.x -= this->spinVel.x; + this->spinVel.x -= 0x800; + if ((this->spinRot.x >= 0) && onGround) { + this->spinRot.x = 0; + this->spinVel.x = 0; + } + } + + if (this->spinVel.x < -0xC00) { + this->spinVel.x = -0xC00; + } + + if (this->spinZFlag != 0) { + this->spinRot.z += this->spinVel.z; + this->spinVel.z -= 0x800; + if ((this->spinRot.z <= 0) && onGround) { + this->spinRot.z = 0; + this->spinVel.z = 0; + } + } else { + this->spinRot.z -= this->spinVel.z; + this->spinVel.z -= 0x800; + if ((this->spinRot.z >= 0) && onGround) { + this->spinRot.z = 0; + this->spinVel.z = 0; + } + } + + if (this->spinVel.z < -0xC00) { + this->spinVel.z = -0xC00; + } + + if (this->actor.bgCheckFlags & 8) { + if (!(this->actor.bgCheckFlags & 1)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + } + this->actor.speedXZ *= -0.5f; + } + + if (this->actor.bgCheckFlags & 0x40) { + this->actionState = ENKANBAN_WATER; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); + this->bounceX = this->bounceZ = 0; + this->actor.world.pos.y += this->actor.depthInWater; + EffectSsGSplash_Spawn(globalCtx, &this->actor.world.pos, NULL, NULL, 0, (this->partCount * 20) + 300); + EffectSsGRipple_Spawn(globalCtx, &this->actor.world.pos, 150, 650, 0); + EffectSsGRipple_Spawn(globalCtx, &this->actor.world.pos, 300, 800, 5); + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + break; + } + + if (onGround) { + temp_v0_18 = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + + if ((temp_v0_18 == 15) || (temp_v0_18 == 14)) { + this->unk_197 = 1; + } else if (temp_v0_18 == 5) { + this->unk_197 = -1; + } + + if (this->bounceCount <= 0) { + this->bounceCount++; + if (this->unk_197 != 0) { + this->actor.velocity.y = 0.0f; + } else { + this->actor.velocity.y *= -0.3f; + this->actor.world.rot.y += (s16)randPlusMinusPoint5Scaled(0x4000); + } + bounced = true; + } else { + this->actor.velocity.y = 0.0f; + } + + if (this->unk_197 != 0) { + if (this->unk_197 > 0) { + this->actor.speedXZ = 0.0f; + } else if ((this->floorRot.x > 0.1f) || (this->floorRot.z > 0.1f)) { + this->airTimer = 10; + if (this->actor.bgCheckFlags & 8) { + this->actionState = ENKANBAN_GROUND; + this->actor.speedXZ = 0.0f; + goto nextCase; + } else { + Vec3f spC8; + + Matrix_SetStateXRotation(this->floorRot.x); + Matrix_InsertZRotation_f(this->floorRot.z, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledY(KREG(20) + 10.0f, &spC8); + Math_ApproachF(&this->actor.velocity.x, spC8.x, 0.5f, (KREG(21) * 0.01f) + 0.1f); + Math_ApproachF(&this->actor.velocity.z, spC8.z, 0.5f, (KREG(21) * 0.01f) + 0.3f); + this->actor.world.rot.y = Math_Atan2S(spC8.x, spC8.z); + this->unk_198 = 1; + this->actor.speedXZ = sqrtf(SQXZ(this->actor.velocity)); + } + } else { + this->unk_198 = 0; + Math_ApproachZeroF(&this->actor.speedXZ, 1, 0.1f); + } + } else { + this->actor.speedXZ *= 0.7f; + } + + if (this->spinRot.x == 0) { + if (this->bounceX != 0) { + bounced = true; + if (this->unk_197 != 0) { + this->spinRot.x = 0; + this->bounceX = 0; + } else { + this->spinVel.x = this->bounceX << 9; + if (this->bounceX != 0) { + this->bounceX -= 5; + if (this->bounceX <= 0) { + this->bounceX = 0; + } + } + + if (Rand_ZeroOne() < 0.5f) { + this->spinXFlag = 1; + } else { + this->spinXFlag = 0; + } + } + } + } + + if (this->spinRot.z == 0) { + if (this->bounceZ != 0) { + bounced = 1; + if (this->unk_197 != 0) { + this->spinRot.z = 0; + this->bounceZ = 0; + } else { + this->spinVel.z = this->bounceZ << 9; + if (this->bounceZ != 0) { + this->bounceZ -= 5; + if (this->bounceZ <= 0) { + this->bounceZ = 0; + } + } + + if (Rand_ZeroOne() < 0.5f) { + this->spinZFlag = 1; + } else { + this->spinZFlag = 0; + } + } + } + } + + Math_ApproachS(&this->actor.shape.rot.x, this->direction << 0xE, 1, 0x2000); + } else { + this->actor.shape.rot.y += this->spinVel.y; + this->actor.shape.rot.x += this->direction * 0x7D0; + } + + if (bounced) { + if (this->unk_197 > 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_SNOW); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + } + } + + if (bounced && (this->unk_197 >= 0)) { + s16 dustCount; + s16 j; + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + static Color_RGBA8 D_80957548 = { 185, 140, 70, 255 }; + static Color_RGBA8 D_8095754C = { 255, 255, 255, 255 }; + Vec3f accel; + Vec3f pos; + Color_RGBA8 primColor; + Color_RGBA8 envColor; + + if (this->unk_197 != 0) { + primColor = D_8095754C; + envColor = D_8095754C; + } else { + primColor = D_80957548; + envColor = D_80957548; + } + + accel.x = 0.0f; + accel.y = 0.1f; + accel.z = 0.0f; + + pos.y = this->actor.floorHeight + 3.0f; + dustCount = this->partCount * 0.5f; + + for (j = 0; j < dustCount + 3; j++) { + pos.x = randPlusMinusPoint5Scaled((this->partCount * 0.5f) + 20.0f) + this->actor.world.pos.x; + pos.z = randPlusMinusPoint5Scaled((this->partCount * 0.5f) + 20.0f) + this->actor.world.pos.z; + func_800B0F18(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, 100, 5, + Rand_ZeroFloat(5.0f) + 14.0f); + } + } + + if (DECR(this->airTimer) == 0) { + this->actionState = ENKANBAN_GROUND; + } + } + + case ENKANBAN_GROUND: + case ENKANBAN_WATER: + nextCase: + signpost = (EnKanban*)this->actor.parent; + + if (signpost->partFlags == 0xFFFF) { + Actor_MarkForDeath(&this->actor); + } + + phi_f0 = 0.0f; + if (this->unk_197 > 0) { + phi_f0 = -150.0f; + } + + Math_ApproachF(&this->actor.shape.yOffset, 100.0f + phi_f0, 1.0f, 5.0f); + + if (this->actionState == ENKANBAN_WATER) { + s16 rippleDelay; + s32 rippleScale; + + if ((player->actor.speedXZ > 0.0f) && (player->actor.world.pos.y < this->actor.world.pos.y) && + (this->actor.xyzDistToPlayerSq < SQ(50.0f))) { + Math_ApproachF(&this->actor.speedXZ, player->actor.speedXZ, 1.0f, 0.2f); + if (this->actor.speedXZ > 1.0f) { + this->actor.speedXZ = 1.0f; + } + + if (Math_SmoothStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 1, + 0x1000, 0) > 0) { + this->spinVel.y = this->actor.speedXZ * 1000.0f; + } else { + this->spinVel.y = this->actor.speedXZ * -1000.0f; + } + } + + if (this->actor.bgCheckFlags & 1) { + this->actor.speedXZ = 0.0f; + } + + Actor_MoveWithGravity(&this->actor); + + if (this->actor.speedXZ != 0.0f) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 50.0f, 5); + if (this->actor.bgCheckFlags & 8) { + this->actor.speedXZ *= -0.5f; + if (this->spinVel.y > 0) { + this->spinVel.y = -2000; + } else { + this->spinVel.y = 2000; + } + } + Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.15f); + } + this->actor.shape.rot.y += this->spinVel.y; + Math_ApproachS(&this->spinVel.y, 0, 1, 0x3A); + Math_ApproachS(&this->actor.shape.rot.x, this->direction * 0x4000, 2, 0x1000); + Math_ApproachS(&this->spinRot.x, Math_SinS(this->frameCount * 2500) * 500.0f, 2, 0x1000); + Math_ApproachS(&this->spinRot.z, Math_CosS(this->frameCount * 3000) * 500.0f, 2, 0x1000); + Math_ApproachZeroF(&this->floorRot.x, 0.5f, 0.2f); + Math_ApproachZeroF(&this->floorRot.z, 0.5f, 0.2f); + + if (fabsf(this->actor.speedXZ) > 1.0f) { + rippleDelay = 0; + } else if (fabsf(this->actor.speedXZ) > 0.5f) { + rippleDelay = 3; + } else { + rippleDelay = 7; + } + + if (!(this->frameCount & rippleDelay)) { + if (this->partCount < 3) { + rippleScale = 0; + } else if (this->partCount < 6) { + rippleScale = 100; + } else { + rippleScale = 200; + } + EffectSsGRipple_Spawn(globalCtx, &this->actor.world.pos, rippleScale, rippleScale + 500, 0); + } + } else if ((globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(100.0f))) { + f32 hammerStrength = (100.0f - sqrtf(this->actor.xyzDistToPlayerSq)) * 0.05f; + + this->actionState = ENKANBAN_AIR; + this->actor.gravity = -1.0f; + this->actor.world.rot.y = randPlusMinusPoint5Scaled(0x10000); + if (this->partCount >= 4) { + this->bounceX = Rand_ZeroFloat(10.0f) + 6.0f; + this->bounceZ = Rand_ZeroFloat(10.0f) + 6.0f; + this->actor.velocity.y = 2.0f + hammerStrength; + this->actor.speedXZ = Rand_ZeroFloat(1.0f); + } else { + this->bounceX = Rand_ZeroFloat(7.0f) + 3.0f; + this->bounceZ = Rand_ZeroFloat(7.0f) + 3.0f; + this->actor.velocity.y = 3.0f + hammerStrength; + this->actor.speedXZ = Rand_ZeroFloat(1.5f); + } + + this->spinVel.y = randPlusMinusPoint5Scaled(0x1800); + + if (Rand_ZeroOne() < 0.5f) { + this->direction = 1; + } else { + this->direction = -1; + } + this->airTimer = 70; + } + + if (this->bounceX == 0) { + Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + f32 dx; + f32 dy; + f32 dz; + + while (explosive != NULL) { + if (explosive->params != 1) { + explosive = explosive->next; + continue; + } + + dx = this->actor.world.pos.x - explosive->world.pos.x; + dy = this->actor.world.pos.y - explosive->world.pos.y; + dz = this->actor.world.pos.z - explosive->world.pos.z; + + if (sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 100.0f) { + f32 bombStrength = (100.0f - sqrtf(SQ(dx) + SQ(dy) + SQ(dz))) * 0.05f; + + this->actionState = ENKANBAN_AIR; + this->actor.gravity = -1.0f; + this->actor.world.rot.y = Math_Atan2S(dx, dz); + + if (this->partCount >= 4) { + this->bounceX = Rand_ZeroFloat(10.0f) + 6.0f; + this->bounceZ = Rand_ZeroFloat(10.0f) + 6.0f; + this->actor.velocity.y = 2.5f + bombStrength; + this->actor.speedXZ = 3.0f + bombStrength; + } else { + this->bounceX = Rand_ZeroFloat(7.0f) + 3.0f; + this->bounceZ = Rand_ZeroFloat(7.0f) + 3.0f; + this->actor.velocity.y = 5.0f + bombStrength; + this->actor.speedXZ = 4.0f + bombStrength; + } + + this->spinVel.y = randPlusMinusPoint5Scaled(0x1800); + + if (Rand_ZeroOne() < 0.5f) { + this->direction = 1; + } else { + this->direction = -1; + } + this->airTimer = 70; + } + + explosive = explosive->next; + } + } + + switch (this->ocarinaFlag) { + case 0: + if (globalCtx->msgCtx.unk1202A == 1) { + this->ocarinaFlag = 1; + } + break; + + case 1: + if ((globalCtx->msgCtx.unk1202A == 4) && (globalCtx->msgCtx.unk1202E == 7)) { + this->actionState = ENKANBAN_REPAIR; + this->bounceX = 1; + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + break; + } + break; + + case ENKANBAN_REPAIR: { + f32 distX; + f32 distY; + f32 distZ; + s16 pDiff; + s16 yDiff; + s16 rDiff; + + signpost = (EnKanban*)this->actor.parent; + signpost->invincibilityTimer = 5; + + if (signpost->partFlags == 0xFFFF) { + Actor_MarkForDeath(&this->actor); + } + + Matrix_RotateY(signpost->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sPieceOffsets[this->pieceType], &offset); + distX = + Math_SmoothStepToF(&this->actor.world.pos.x, signpost->actor.world.pos.x + offset.x, 1.0f, 3.0f, 0.0f); + distY = + Math_SmoothStepToF(&this->actor.world.pos.y, signpost->actor.world.pos.y + offset.y, 1.0f, 3.0f, 0.0f); + distZ = + Math_SmoothStepToF(&this->actor.world.pos.z, signpost->actor.world.pos.z + offset.z, 1.0f, 3.0f, 0.0f); + pDiff = Math_SmoothStepToS(&this->actor.shape.rot.x, signpost->actor.shape.rot.x, 1, 0x200, 0); + yDiff = Math_SmoothStepToS(&this->actor.shape.rot.y, signpost->actor.shape.rot.y, 1, 0x200, 0); + rDiff = Math_SmoothStepToS(&this->actor.shape.rot.z, signpost->actor.shape.rot.z, 1, 0x200, 0); + Math_ApproachS(&this->spinRot.x, 0, 1, 0x200); + Math_ApproachS(&this->spinRot.z, 0, 1, 0x200); + Math_ApproachZeroF(&this->floorRot.x, 1.0f, 0.05f); + Math_ApproachZeroF(&this->floorRot.z, 1.0f, 0.05f); + Math_ApproachZeroF(&this->actor.shape.yOffset, 1.0f, 2.0f); + if (((distX + distY + distZ) == 0.0f) && + ((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; + Actor_MarkForDeath(&this->actor); + return; + } + break; + } + } +} +#else +static Vec3f D_8095753C = { 0.0f, 0.0f, 0.0f }; +static Color_RGBA8 D_80957548 = { 185, 140, 70, 255 }; +static Color_RGBA8 D_8095754C = { 255, 255, 255, 255 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kanban/EnKanban_Update.s") #endif -extern ColliderCylinderInit D_80957300; +static Gfx* sDisplayLists[] = { + object_kanban_DL_000CB0, object_kanban_DL_000DB8, object_kanban_DL_000E78, object_kanban_DL_000F38, + object_kanban_DL_000FF8, object_kanban_DL_0010B8, object_kanban_DL_0011C0, object_kanban_DL_0012C8, + object_kanban_DL_0013D0, object_kanban_DL_001488, object_kanban_DL_001540, +}; -extern UNK_TYPE D_06000C30; +#include "z_en_kanban_gfx.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kanban/func_80954960.s") +static f32 sCutAngles[] = { + /* CUT_POST */ 0.50f * M_PI, + /* CUT_VERT_L */ 0.00f * M_PI, + /* CUT_HORIZ */ 0.50f * M_PI, + /* CUT_DIAG_L */ 0.66f * M_PI, + /* CUT_DIAG_R */ 0.34f * M_PI, + /* CUT_VERT_R */ 0.00f * M_PI, + /* */ 0.00f * M_PI, + /* */ 0.00f * M_PI, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kanban/EnKanban_Init.s") +#include "overlays/ovl_En_Kanban/ovl_En_Kanban.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kanban/EnKanban_Destroy.s") +void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKanban* this = THIS; + f32 zShift; + f32 zShift2; + s32 i; + Player* player = GET_PLAYER(globalCtx); + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, ARRAY_COUNT(sShadowTexFlags)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kanban/func_80954BE8.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kanban/EnKanban_Update.s") + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kanban/EnKanban_Draw.s") + gSPDisplayList(POLY_OPA_DISP++, object_kanban_DL_000C30); + + if (this->actionState != ENKANBAN_SIGN) { + 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_RotateStateAroundXAxis(this->floorRot.x); + Matrix_InsertZRotation_f(this->floorRot.z, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + + zShift = fabsf(Math_SinS(this->spinRot.x) * this->pieceHeight); + zShift2 = fabsf(Math_SinS(this->spinRot.z) * this->pieceWidth); + zShift = CLAMP_MIN(zShift, zShift2); + zShift *= -(f32)this->direction; + + Matrix_InsertTranslation(0.0f, 0.0f, zShift, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->spinRot.x, MTXMODE_APPLY); + Matrix_RotateY(this->spinRot.z, MTXMODE_APPLY); + Matrix_InsertTranslation(this->offset.x, this->offset.y, this->offset.z - 100.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + for (i = 0; i < ARRAY_COUNT(sPartFlags); i++) { + if (sPartFlags[i] & this->partFlags) { + gSPDisplayList(POLY_OPA_DISP++, sDisplayLists[i]); + } + } + } else { + f32 phi_f0 = 0.0f; + + if ((player->transformation == PLAYER_FORM_HUMAN) || (player->transformation == PLAYER_FORM_DEKU)) { + phi_f0 = -15.0f; + } + this->actor.world.pos.y = this->actor.home.pos.y + phi_f0; + Matrix_InsertTranslation(0.0f, 0.0f, -100.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->partFlags == 0xFFFF) { + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05AED0); + } else { + for (i = 0; i < ARRAY_COUNT(sPartFlags); i++) { + if (sPartFlags[i] & this->partFlags) { + gSPDisplayList(POLY_OPA_DISP++, sDisplayLists[i]); + } + } + } + + if (this->cutMarkAlpha != 0) { + f32 cutOffset = (this->cutType == CUT_POST) ? -1200.0f : 0.0f; + + Matrix_InsertTranslation(0.0f, 4400.0f + cutOffset, 200.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_f(sCutAngles[this->cutType], MTXMODE_APPLY); + Matrix_Scale(0.0f, 10.0f, 2.0f, MTXMODE_APPLY); + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 255, 255, 255, this->cutMarkAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 150, 0); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_kanban_DL_001630); + } + } + + if ((this->actor.projectedPos.z <= 400.0f) && (this->actor.projectedPos.z > 0.0f) && + (this->actor.floorHeight > -3000.0f) && ((this->bounceX != 0) || (this->bounceZ != 0))) { + u16 dayTime = gSaveContext.time; + f32 shadowAlpha; + + if (dayTime >= CLOCK_TIME(12, 0)) { + dayTime = (0xFFFF - dayTime) & 0xFFFF; + } + + shadowAlpha = (dayTime * 0.00275f) + 10.0f; + if (this->actor.projectedPos.z > 300.0f) { + shadowAlpha *= (400.0f - this->actor.projectedPos.z) * 0.01f; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 0, 0, 0, (s8)shadowAlpha); + + if ((player->transformation == PLAYER_FORM_HUMAN) || (player->transformation == PLAYER_FORM_DEKU)) { + zShift = 0.0f; + } else { + zShift = ((this->actor.world.pos.y - this->actor.floorHeight) * -50.0f) / 100.0f; + } + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z + zShift, + MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(this->floorRot.x); + Matrix_InsertZRotation_f(this->floorRot.z, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, 0.0f, this->actor.scale.z, MTXMODE_APPLY); + + if (this->actionState == ENKANBAN_SIGN) { + Matrix_RotateStateAroundXAxis(-M_PI / 5); + } + + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->spinRot.x, MTXMODE_APPLY); + Matrix_RotateY(this->spinRot.z, MTXMODE_APPLY); + Matrix_InsertTranslation(this->offset.x, this->offset.y, this->offset.z, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + for (i = 0; i < ARRAY_COUNT(sShadowTexFlags); i++) { + if (sShadowTexFlags[i] & this->partFlags) { + shadowTex[i] = 0xFF; + } else { + shadowTex[i] = 0; + } + } + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(shadowTex)); + gSPDisplayList(POLY_XLU_DISP++, gEnKanban_D_80957DE0); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h index 1ac4367046..b667bd9e8c 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h @@ -5,11 +5,106 @@ struct EnKanban; +#define PART_UPPER_LEFT (1 << 0) +#define PART_LEFT_UPPER (1 << 1) +#define PART_LEFT_LOWER (1 << 2) +#define PART_RIGHT_UPPER (1 << 3) +#define PART_RIGHT_LOWER (1 << 4) +#define PART_LOWER_LEFT (1 << 5) +#define PART_UPPER_RIGHT (1 << 6) +#define PART_LOWER_RIGHT (1 << 7) +#define PART_POST_UPPER (1 << 8) +#define PART_POST_LOWER (1 << 9) +#define PART_POST_STAND (1 << 10) +#define LEFT_HALF (PART_UPPER_LEFT | PART_LEFT_UPPER | PART_LEFT_LOWER | PART_LOWER_LEFT) +#define RIGHT_HALF (PART_UPPER_RIGHT | PART_RIGHT_UPPER | PART_RIGHT_LOWER | PART_LOWER_RIGHT) +#define UPPER_HALF (PART_POST_UPPER | PART_UPPER_RIGHT | PART_RIGHT_UPPER | PART_UPPER_LEFT | PART_LEFT_UPPER) +#define UPPERLEFT_HALF (PART_POST_UPPER | PART_UPPER_RIGHT | PART_LEFT_LOWER | PART_UPPER_LEFT | PART_LEFT_UPPER) +#define UPPERRIGHT_HALF (PART_POST_UPPER | PART_UPPER_RIGHT | PART_RIGHT_UPPER | PART_UPPER_LEFT | PART_RIGHT_LOWER) +#define ALL_PARTS (LEFT_HALF | RIGHT_HALF | PART_POST_UPPER | PART_POST_LOWER) + +typedef enum { + /* 0 */ ENKANBAN_SIGN, + /* 1 */ ENKANBAN_AIR, + /* 2 */ ENKANBAN_UNUSED, + /* 3 */ ENKANBAN_GROUND, + /* 4 */ ENKANBAN_WATER, + /* 5 */ ENKANBAN_REPAIR +} EnKanbanActionState; + +typedef enum { + /* 0 */ PIECE_WHOLE_SIGN, + /* 1 */ PIECE_UPPER_HALF, + /* 2 */ PIECE_LOWER_HALF, + /* 3 */ PIECE_RIGHT_HALF, + /* 4 */ PIECE_LEFT_HALF, + /* 5 */ PIECE_2ND_QUAD, + /* 6 */ PIECE_1ST_QUAD, + /* 7 */ PIECE_3RD_QUAD, + /* 8 */ PIECE_4TH_QUAD, + /* 9 */ PIECE_UPPER_LEFT, + /* 10 */ PIECE_LEFT_UPPER, + /* 11 */ PIECE_LEFT_LOWER, + /* 12 */ PIECE_LOWER_LEFT, + /* 13 */ PIECE_UPPER_RIGHT, + /* 14 */ PIECE_RIGHT_UPPER, + /* 15 */ PIECE_RIGHT_LOWER, + /* 16 */ PIECE_LOWER_RIGHT, + /* 17 */ PIECE_POST_UPPER, + /* 18 */ PIECE_POST_LOWER, + /* 100 */ PIECE_OTHER = 100 +} EnKanbanPiece; + +typedef enum { + /* 0 */ CUT_POST, + /* 1 */ CUT_VERT_L, + /* 2 */ CUT_HORIZ, + /* 3 */ CUT_DIAG_L, // lower left to upper right + /* 4 */ CUT_DIAG_R, // upper left to lower right + /* 5 */ CUT_VERT_R +} EnKanbanCutType; + typedef struct EnKanban { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xAC]; + /* 0x144 */ UNK_TYPE1 unk144[4]; // actionFunc? + /* 0x148 */ u8 frameCount; + /* 0x14A */ s16 airTimer; + /* 0x14C */ u8 actionState; + /* 0x14E */ u16 partFlags; + /* 0x150 */ u8 partCount; + /* 0x152 */ s16 invincibilityTimer; + /* 0x154 */ Vec3f offset; + /* 0x160 */ Vec3s spinRot; + /* 0x166 */ Vec3s spinVel; + /* 0x16C */ s8 spinXFlag; + /* 0x16D */ s8 spinZFlag; + /* 0x16E */ s16 bounceX; + /* 0x170 */ s16 bounceZ; + /* 0x172 */ u8 bounceCount; + /* 0x174 */ f32 pieceWidth; + /* 0x178 */ f32 pieceHeight; + /* 0x17C */ s16 direction; + /* 0x180 */ Vec3f floorRot; + /* 0x18C */ u8 cutType; + /* 0x18D */ u8 pieceType; + /* 0x18E */ s16 cutMarkTimer; + /* 0x190 */ s16 cutMarkAlpha; + /* 0x192 */ s16 zTargetTimer; + /* 0x194 */ u8 msgFlag; + /* 0x195 */ u8 msgTimer; + /* 0x196 */ u8 ocarinaFlag; + /* 0x197 */ s8 unk_197; + /* 0x198 */ s8 unk_198; + /* 0x199 */ u8 unk_199; + /* 0x19A */ u8 unk_19A; + /* 0x19C */ Actor* unk_19C; + /* 0x1A0 */ s16 unk_1A0; + /* 0x1A4 */ ColliderCylinder collider; } EnKanban; // size = 0x1F0 +#define ENKANBAN_PIECE ((s16)0xFFDD) +#define ENKANBAN_FISHING 0x300 + extern const ActorInit En_Kanban_InitVars; #endif // Z_EN_KANBAN_H diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban_gfx.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban_gfx.c new file mode 100644 index 0000000000..c38e9df942 --- /dev/null +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban_gfx.c @@ -0,0 +1,68 @@ +#include "z_en_kanban.h" + +static u16 sShadowTexFlags[] = { + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x100, + 0x100, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x100, 0x100, + 0x100, 0x100, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x100, 0x100, + 0x100, 0x100, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x100, 0x100, + 0x100, 0x100, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x101, 0x101, + 0x140, 0x140, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, + 0x002, 0x002, 0x002, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x101, 0x101, + 0x140, 0x140, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x008, 0x008, 0x008, + 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x001, 0x101, 0x101, + 0x140, 0x140, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x040, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, + 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x001, 0x001, 0x001, 0x001, 0x001, 0x101, 0x101, + 0x140, 0x140, 0x040, 0x040, 0x040, 0x040, 0x040, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, + 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x001, 0x001, 0x101, 0x101, + 0x140, 0x140, 0x040, 0x040, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, + 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x002, 0x102, 0x301, + 0x340, 0x108, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, 0x008, + 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x204, 0x220, + 0x280, 0x210, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, + 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x020, 0x020, 0x220, 0x220, + 0x280, 0x280, 0x080, 0x080, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, + 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x020, 0x020, 0x020, 0x020, 0x020, 0x220, 0x220, + 0x280, 0x280, 0x080, 0x080, 0x080, 0x080, 0x080, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, + 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x220, 0x220, + 0x280, 0x280, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x010, 0x010, 0x010, 0x010, 0x010, 0x010, + 0x004, 0x004, 0x004, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x220, 0x220, + 0x280, 0x280, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x010, 0x010, 0x010, + 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x020, 0x220, 0x620, + 0x680, 0x280, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, 0x080, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x400, 0x400, + 0x400, 0x400, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, +}; 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 be9d78aed2..4d0e7f9fe1 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -74,9 +74,9 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2E2 = -1; this->zubora = EnKgy_FindZubora(globalCtx); this->iceBlock = EnKgy_FindIceBlock(globalCtx); - Actor_UnsetSwitchFlag(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); + Flags_UnsetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor)) || (gSaveContext.weekEventReg[33] & 0x80)) { - Actor_SetSwitchFlag(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); + Flags_SetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); globalCtx->envCtx.unk_C3 = 1; gSaveContext.weekEventReg[21] |= 1; if (!func_80B40D64(globalCtx)) { @@ -143,7 +143,7 @@ void func_80B40BC0(EnKgy* this, s16 arg1) { } EnKbt* EnKgy_FindZubora(GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (actor != NULL) { if (actor->id == ACTOR_EN_KBT) { @@ -155,7 +155,7 @@ EnKbt* EnKgy_FindZubora(GlobalContext* globalCtx) { } ObjIcePoly* EnKgy_FindIceBlock(GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_ITEMACTION].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (actor != NULL) { if (actor->id == ACTOR_OBJ_ICE_POLY) { @@ -258,7 +258,7 @@ void func_80B40EE8(EnKgy* this, GlobalContext* globalCtx) { f32 sp34; f32 temp_f0; - func_800B4EDC(globalCtx, &this->unk_2B4, &sp38, &sp34); + Actor_GetProjectedPos(globalCtx, &this->unk_2B4, &sp38, &sp34); temp_f0 = sp38.x * sp34; if (this->unk_2E6 > 0) { this->unk_2E6--; @@ -401,7 +401,7 @@ s32 func_80B41528(GlobalContext* globalCtx) { } void func_80B415A8(GlobalContext* globalCtx, Vec3f* arg1) { - static EffShieldParticleInit D_80B43298 = { + static EffectShieldParticleInit D_80B43298 = { 16, { 0, 0, 0 }, { 0, 200, 255, 255 }, @@ -426,7 +426,7 @@ void func_80B415A8(GlobalContext* globalCtx, Vec3f* arg1) { D_80B43298.lightPoint.y = D_80B43298.position.y; D_80B43298.lightPoint.z = D_80B43298.position.z; - Effect_Add(globalCtx, &effectIndex, 3, 0, 1, &D_80B43298); + Effect_Add(globalCtx, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &D_80B43298); } void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { @@ -458,7 +458,7 @@ void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { this->lightInfo.params.point.y = this->unk_2C0.y; this->lightInfo.params.point.z = this->unk_2C0.z; this->unk_300 = 200; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SWORD_FORGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SWORD_FORGE); break; } @@ -470,7 +470,7 @@ void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { void func_80B417B8(EnKgy* this, GlobalContext* globalCtx) { func_80B4163C(this, globalCtx); - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); func_80B413C8(this); this->actor.flags &= ~0x100; @@ -494,7 +494,7 @@ void func_80B41858(EnKgy* this, GlobalContext* globalCtx) { void func_80B418C4(EnKgy* this, GlobalContext* globalCtx) { func_80B4163C(this, globalCtx); if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx) && + (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx) && ((globalCtx->msgCtx.unk11F04 == 0xC4E) || (globalCtx->msgCtx.unk11F04 == 0xC4F))) { func_801477B4(globalCtx); this->actor.textId = 0xC4F; @@ -511,7 +511,7 @@ void func_80B419B0(EnKgy* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); func_80B4163C(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx) || (&this->actor == player->targetActor)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) || (&this->actor == player->targetActor)) { func_80B411DC(this, globalCtx, 4); func_80B40E18(this, this->actor.textId); if (this->actor.textId == 0xC37) { @@ -537,7 +537,7 @@ void func_80B41ACC(EnKgy* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); SkelAnime_Update(&this->skelAnime); - if (func_80152498(&globalCtx->msgCtx) == 0x10) { + if (Message_GetState(&globalCtx->msgCtx) == 0x10) { itemActionParam = func_80123810(globalCtx); if (itemActionParam != PLAYER_AP_NONE) { this->actionFunc = func_80B41E18; @@ -586,7 +586,7 @@ void func_80B41C30(EnKgy* this, GlobalContext* globalCtx) { void func_80B41C54(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actionFunc = func_80B41C30; this->actor.flags &= ~0x100; } @@ -595,13 +595,13 @@ void func_80B41C54(EnKgy* this, GlobalContext* globalCtx) { void func_80B41CBC(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; func_80B40E18(this, this->actor.textId); this->actionFunc = func_80B41E18; func_80B411DC(this, globalCtx, 4); } else { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } } @@ -610,9 +610,9 @@ void func_80B41D64(EnKgy* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actionFunc = func_80B41CBC; this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } else { - func_800B8A1C(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); + Actor_PickUp(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); } func_80B40EE8(this, globalCtx); } @@ -627,7 +627,7 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && func_80B40E54(this) == 0) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 4: if (func_80147624(globalCtx)) { temp = globalCtx->msgCtx.unk11F04; @@ -759,7 +759,7 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { case 0xC46: case 0xC55: func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); - player->unk_A87 = PLAYER_AP_NONE; + player->exchangeItemId = EXCH_ITEM_NONE; this->unk_29C &= ~0x8; globalCtx->msgCtx.unk11F10 = 0; func_80B41368(this, globalCtx, 4); @@ -774,7 +774,7 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { case 0xC47: func_80B40BC0(this, 1); if (this->unk_29C & 8) { - player->unk_A87 = PLAYER_AP_NONE; + player->exchangeItemId = EXCH_ITEM_NONE; this->unk_29C &= ~8; } func_80B40EBC(this, globalCtx, temp); @@ -813,7 +813,7 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { func_801477B4(globalCtx); this->actionFunc = func_80B41D64; func_80B413C8(this); - func_800B8A1C(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); + Actor_PickUp(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); break; case 0xC51: @@ -846,7 +846,7 @@ void func_80B42508(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if (func_800B84D0(&this->actor, globalCtx) || (&this->actor == player->targetActor)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) || (&this->actor == player->targetActor)) { this->actionFunc = func_80B41E18; func_80B411DC(this, globalCtx, 4); func_80B40E18(this, this->actor.textId); @@ -856,7 +856,7 @@ void func_80B42508(EnKgy* this, GlobalContext* globalCtx) { void func_80B425A0(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B41E18; func_80B40BC0(this, 1); func_80B411DC(this, globalCtx, 0); @@ -869,7 +869,7 @@ void func_80B425A0(EnKgy* this, GlobalContext* globalCtx) { void func_80B42660(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); func_80B413C8(this); this->actor.flags &= ~0x100; @@ -885,7 +885,7 @@ void func_80B42714(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if (func_800B84D0(&this->actor, globalCtx) || (&this->actor == player->targetActor)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) || (&this->actor == player->targetActor)) { func_80B411DC(this, globalCtx, 4); func_80B40E18(this, this->actor.textId); if (this->actor.textId == 0xC37) { @@ -910,7 +910,7 @@ void func_80B427C8(EnKgy* this, GlobalContext* globalCtx) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { temp_a2 = globalCtx->msgCtx.unk11F04; switch (temp_a2) { @@ -951,7 +951,7 @@ void func_80B4296C(EnKgy* this, GlobalContext* globalCtx) { } this->actor.focus.pos = this->unk_2A8; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B427C8; if (this->unk_2D2 == 4) { func_80B40BC0(this, 7); @@ -963,7 +963,7 @@ void func_80B4296C(EnKgy* this, GlobalContext* globalCtx) { this->actor.flags &= ~0x10000; } else { this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, 0); + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_NONE); } } @@ -982,7 +982,7 @@ void func_80B42A8C(EnKgy* this, GlobalContext* globalCtx) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { temp_a2 = globalCtx->msgCtx.unk11F04; switch (temp_a2) { case 0xC1D: @@ -1063,7 +1063,7 @@ void func_80B42D28(EnKgy* this, GlobalContext* globalCtx) { } this->actor.focus.pos = this->unk_2A8; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B42A8C; if (this->actor.textId == 0xC2D) { func_80B40BC0(this, 1); diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index 3a2f74983d..194b99b7a1 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -49,7 +49,7 @@ static CollisionCheckInfoInit D_8093670C = { 0, 12, 30, MASS_IMMOVABLE }; static InitChainEntry D_80936754[] = { ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -17000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index 1b4d04e426..d32735035d 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -15,18 +15,42 @@ void EnKusa2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKusa2_Update(Actor* thisx, GlobalContext* globalCtx); void EnKusa2_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A5C70C(EnKusa2UnkBssSubStruct* arg0); +void func_80A5CF44(EnKusa2* this); +void func_80A5D5E0(EnKusa2* this); void func_80A5D5F4(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5D618(EnKusa2* this); void func_80A5D62C(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5D6B0(EnKusa2* this); void func_80A5D6C4(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5D754(EnKusa2* this); void func_80A5D794(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5D7A4(EnKusa2* this); void func_80A5D7C4(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5D964(EnKusa2* this); void func_80A5D9C8(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5DC70(EnKusa2* this); void func_80A5DC98(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5DE18(EnKusa2* this); void func_80A5DEB4(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5E1D8(EnKusa2* this); void func_80A5E210(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5E418(EnKusa2* this); void func_80A5E4BC(EnKusa2* this, GlobalContext* globalCtx); +void func_80A5E604(Actor* thisx, GlobalContext* globalCtx); +void func_80A5E6F0(Actor* thisx, GlobalContext* globalCtx); +void func_80A5E9B4(Actor* thisx, GlobalContext* globalCtx); +void func_80A5EA48(Actor* thisx, GlobalContext* globalCtx); + +static EnKusa2UnkBssStruct D_80A5F1C0; +static u32 D_80A60900; +static MtxF D_80A60908[8]; +static s16 D_80A60B08; +static s16 D_80A60B0A; +static s16 D_80A60B0C; +static s16 D_80A60B0E; +static s16 D_80A60B10; -#if 0 const ActorInit En_Kusa2_InitVars = { ACTOR_EN_KUSA2, ACTORCAT_PROP, @@ -39,146 +63,1320 @@ const ActorInit En_Kusa2_InitVars = { (ActorFunc)EnKusa2_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A5EAC0 = { - { 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 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A5EB50[] = { - ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -17000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), +static u8 D_80A5EAEC = 1; +static s16 D_80A5EAF0 = 0; +static Vec3s D_80A5EAF4 = { 0, 0, 0 }; +static Vec3s D_80A5EAFC = { 0, 0, 0 }; +static Vec3s D_80A5EB04 = { 0, 0, 0 }; + +void func_80A5B160(EnKusa2* this, GlobalContext* globalCtx) { + s32 i; + s16 temp_s1; + EnKusa2** ptr; + EnKusa2* actor; + + if (this->unk_194[0] == NULL) { + ptr = this->unk_194; + actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_KUSA2, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, (u32)Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); + *ptr = actor; + + if (*ptr != NULL) { + (*ptr)->actor.room = this->actor.room; + (*ptr)->unk_1C0 = this; + } + } + + for (i = 1; i < ARRAY_COUNT(this->unk_194); i++) { + temp_s1 = (i << 0xD) - 0x2000; + if (this->unk_194[i] == NULL) { + ptr = &this->unk_194[i]; + actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_KUSA2, (Math_SinS(temp_s1) * 80.0f) + this->actor.world.pos.x, + this->actor.world.pos.y, (Math_CosS(temp_s1) * 80.0f) + this->actor.world.pos.z, 0, + (u32)Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); + *ptr = actor; + if (*ptr != NULL) { + (*ptr)->actor.room = this->actor.room; + (*ptr)->unk_1C0 = this; + } + } + } +} + +void func_80A5B334(EnKusa2* this, GlobalContext* globalCtx) { + s32 i; + EnKusa2** ptr; + + for (i = 0; i < ARRAY_COUNT(this->unk_194); i++) { + ptr = &this->unk_194[i]; + + if (*ptr != NULL) { + if (!Actor_HasParent(&(*ptr)->actor, globalCtx)) { + Actor_MarkForDeath(&(*ptr)->actor); + } + *ptr = NULL; + } + } +} + +void func_80A5B3BC(EnKusa2* this) { + s32 i; + EnKusa2** ptr; + + for (i = 0; i < ARRAY_COUNT(this->unk_194); i++) { + ptr = &this->unk_194[i]; + if ((*ptr != NULL) && ((*ptr)->actor.update == NULL)) { + *ptr = NULL; + } + } +} + +void func_80A5B490(EnKusa2* this, GlobalContext* globalCtx) { + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_KITAN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, + ENKUSA2_GET_7F00(&this->actor) << 9, this->actor.cutscene, this->actor.unk20, NULL); +} + +void func_80A5B508(void) { + s32 i; + s32 pad; + f32 spB4; + f32* ptr; + f32 spAC; + f32 spA8; + f32 tempf1; + f32 tempf2; + f32 tempf3; + f32 tempf4; + f32 tempf5; + f32 sp74[8]; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + f32 temp_f28; + f32 temp_f2; + f32 temp_f30; + + D_80A60B08 += 70; + D_80A60B0A += 300; + D_80A60B0C += 700; + D_80A60B0E += 1300; + D_80A60B10 += 8900; + temp_f28 = Math_SinS(D_80A60B08); + spB4 = Math_SinS(D_80A60B0A); + temp_f30 = Math_SinS(D_80A60B0C); + spAC = Math_SinS(D_80A60B0E) * 1.2f; + spA8 = Math_SinS(D_80A60B10) * 1.5f; + temp_f26 = Math_CosS(D_80A60B08); + temp_f20 = Math_CosS(D_80A60B0A); + temp_f22 = Math_CosS(D_80A60B0C); + temp_f24 = Math_CosS(D_80A60B0E) * 1.3f; + temp_f2 = Math_CosS(D_80A60B10) * 1.7f; + + sp74[0] = (temp_f28 - temp_f20) * temp_f30 * temp_f26 * temp_f28; + sp74[1] = (spB4 - temp_f22) * spAC * temp_f20 * temp_f28; + sp74[2] = (temp_f30 - temp_f24) * temp_f22 * temp_f28 * temp_f26; + sp74[3] = (spAC - temp_f20) * temp_f24 * spB4 * temp_f26; + sp74[4] = (temp_f28 - temp_f22) * temp_f28 * spB4 * spA8; + sp74[5] = (spB4 - temp_f24) * temp_f30 * spAC * spA8; + sp74[6] = (temp_f30 - temp_f26) * temp_f26 * temp_f20 * temp_f2; + sp74[7] = (spAC - temp_f20) * temp_f22 * temp_f24 * temp_f2; + + for (i = 0; i < ARRAY_COUNT(D_80A60908); i++) { + ptr = (f32*)&D_80A60908[i].mf[0]; + + tempf1 = sp74[(i + 0) & 7]; + tempf2 = sp74[(i + 1) & 7]; + tempf3 = sp74[(i + 2) & 7]; + tempf4 = sp74[(i + 3) & 7]; + tempf5 = sp74[(i + 4) & 7]; + + ptr[0] = sp74[1] * 0.2f; + ptr[1] = tempf1; + ptr[2] = tempf2; + ptr[3] = 0.0f; + + ptr[4] = tempf3; + ptr[5] = sp74[0]; + ptr[6] = tempf3; + ptr[7] = 0.0f; + + ptr[8] = tempf4; + ptr[9] = tempf5; + ptr[10] = sp74[3] * 0.2f; + ptr[11] = 0.0f; + + ptr[12] = 0.0f; + ptr[13] = 0.0f; + ptr[14] = 0.0f; + ptr[15] = 0.0f; + } +} + +void func_80A5B954(MtxF* matrix, f32 arg1) { + s32 i; + MtxF* temp = Matrix_GetCurrentState(); + f32* tmp = (f32*)&temp->mf[0]; + f32* tmp2 = (f32*)&matrix->mf[0]; + + for (i = 0; i < 16; i++) { + *tmp++ += *tmp2++ * arg1; + } +} + +s32 func_80A5BA58(EnKusa2* this, GlobalContext* globalCtx) { + Vec3f sp24; + s32 sp20; + + sp24.x = this->actor.world.pos.x; + sp24.y = this->actor.world.pos.y + 30.0f; + sp24.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp20, &this->actor, &sp24); + if (this->actor.floorHeight > BGCHECK_Y_MIN) { + this->actor.floorBgId = sp20; + this->actor.world.pos.y = this->actor.floorHeight; + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); + return true; + } + return false; +} + +void func_80A5BAFC(EnKusa2* this, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 35.0f, 0.0f, 0x45); +} + +void func_80A5BB40(EnKusa2* this, GlobalContext* globalCtx, s32 arg2) { + static Vec3f D_80A5EB0C = { 0.0f, 0.3f, 0.0f }; + static Vec3f D_80A5EB18 = { 0.0f, 0.0f, 0.0f }; + s32 pad; + s32 i; + Vec3f sp84; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + s16 temp_s0; + + if (this->actor.flags & 0x40) { + for (i = 0; i <= arg2; i++) { + temp_s0 = Rand_S16Offset(-16000, 32000) + this->actor.world.rot.y; + temp_f20 = Math_SinS(temp_s0); + temp_f22 = Math_CosS(temp_s0); + temp_f24 = Rand_ZeroOne() * -12.0f; + + sp84.x = (temp_f20 * temp_f24) + this->actor.world.pos.x; + sp84.y = (Rand_ZeroOne() * 8.0f) + 2.0f + this->actor.world.pos.y; + sp84.z = (temp_f22 * temp_f24) + this->actor.world.pos.z; + + D_80A5EB18.x = temp_f20 * -0.9f; + D_80A5EB18.z = temp_f22 * -0.9f; + + D_80A5EB0C.x = D_80A5EB18.x * -0.09f; + D_80A5EB0C.z = D_80A5EB18.z * -0.09f; + + func_800B1210(globalCtx, &sp84, &D_80A5EB18, &D_80A5EB0C, 10, 50); + } + } +} + +void func_80A5BD14(EnKusa2* this, GlobalContext* globalCtx, s32 arg2) { + static s32 D_80A5EB24[] = { + ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, + ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_RED, + }; + EnKusa2* kusa2 = this->unk_1C0; + + if (kusa2 != NULL) { + if (kusa2->unk_1BC > 8) { + kusa2->unk_1BC = 8; + } + Item_DropCollectible(globalCtx, &this->actor.world.pos, D_80A5EB24[kusa2->unk_1BC]); + kusa2->unk_1BC += arg2; + } +} + +void func_80A5BD94(EnKusa2* this) { + if (this->unk_1C0 != NULL) { + this->unk_1C0->unk_1BE = 1; + } +} + +void func_80A5BDB0(EnKusa2* this, GlobalContext* globalCtx) { + s32 pad[2]; + s32 i; + Vec3f sp50; + s16 phi_s0; + + sp50.y = this->actor.world.pos.y + this->actor.depthInWater; + + for (phi_s0 = 0, i = 0; i < 4; i++, phi_s0 += 0x4000) { + sp50.x = (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.x; + sp50.z = (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp50, NULL, NULL, 0, 190); + } + + sp50.x = this->actor.world.pos.x; + sp50.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp50, NULL, NULL, 0, 280); + EffectSsGRipple_Spawn(globalCtx, &sp50, 300, 700, 0); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); +} + +void func_80A5BF38(EnKusa2* this, s32 arg1) { + this->actor.shape.shadowAlpha += (u8)arg1; + if (this->actor.shape.shadowAlpha > 60) { + this->actor.shape.shadowAlpha = 60; + } +} + +void func_80A5BF60(EnKusa2* this, s32 arg1) { + s32 alpha = this->actor.shape.shadowAlpha; + + alpha -= arg1; + if (alpha > 0) { + this->actor.shape.shadowAlpha = alpha; + } else { + this->actor.shape.shadowAlpha = 0; + } +} + +void func_80A5BF84(EnKusa2* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 func_80A5BFD8(EnKusa2* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & 2) { + s32 pad; + + func_80A5CF44(this); + func_80A5BD14(this, globalCtx, (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1000000) ? 1 : 0); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + func_80A5BD94(this); + Actor_MarkForDeath(&this->actor); + return true; + } + return false; +} + +EnKusa2UnkBssSubStruct* func_80A5C074(EnKusa2UnkBssStruct* arg0) { + s32 i; + EnKusa2UnkBssSubStruct* phi_v1 = &arg0->unk_0000[0]; + + for (i = 1; i < ARRAY_COUNT(D_80A5F1C0.unk_0000); i++) { + if (!(phi_v1->unk_26 <= arg0->unk_0000[i].unk_26)) { + phi_v1 = &arg0->unk_0000[i]; + if (phi_v1->unk_26 <= 0) { + break; + } + } + } + + return phi_v1; +} + +EnKusa2UnkBssSubStruct2* func_80A5C0B8(EnKusa2UnkBssStruct* arg0) { + s32 i; + EnKusa2UnkBssSubStruct2* phi_v1 = &arg0->unk_0480[0]; + + for (i = 1; i < ARRAY_COUNT(D_80A5F1C0.unk_0480); i++) { + if (!(phi_v1->unk_2C <= arg0->unk_0480[i].unk_2C)) { + phi_v1 = &arg0->unk_0480[i]; + if (1) {} + if (phi_v1->unk_2C <= 0) { + break; + } + } + } + + return phi_v1; +} + +EnKusa2UnkBssSubStruct* func_80A5C104(EnKusa2UnkBssStruct* arg0, Vec3f* arg1, f32 arg2, f32 arg3, s16 arg4, s16 arg5) { + static s32 D_80A5EB48 = 0; + EnKusa2UnkBssSubStruct* ptr = func_80A5C074(arg0); + f32 sp20; + f32 temp_f6; + + Math_Vec3f_Copy(&ptr->unk_00, arg1); + Math_Vec3f_Copy(&ptr->unk_0C, &gZeroVec3f); + + ptr->unk_18 = arg2; + ptr->unk_1C = arg3; + ptr->unk_20 = arg4; + ptr->unk_22 = arg5; + + D_80A5EB48++; + if (D_80A5EB48 >= 3) { + D_80A5EB48 = 0; + ptr->unk_26 = Rand_S16Offset(40, 40); + } else { + ptr->unk_26 = Rand_S16Offset(30, 20); + } + + ptr->unk_24 = ptr->unk_26 - 20; + sp20 = 1.0f / ptr->unk_24; + ptr->unk_28 = func_80A5C70C; + ptr->unk_2C = 0.0f; + ptr->unk_30 = 0.0f; + temp_f6 = Rand_ZeroOne() * 60.0f; + ptr->unk_34 = (temp_f6 + 20.0f) * 0.05f; + ptr->unk_38 = (temp_f6 + 20.0f) * sp20; + ptr->unk_3C = 40.0f; + ptr->unk_40 = -1.5f; + ptr->unk_44 = -50.0f * sp20; + ptr->unk_48 = 140.0f; + ptr->unk_4C = SQ(140.0f); + ptr->unk_50 = 819.2f; + ptr->unk_54 = 327.68f; + ptr->unk_58 = 2.5f; + ptr->unk_5C = 0.05f; + ptr->unk_60 = 3.5f * sp20; + ptr->unk_64 = 0.35f; + ptr->unk_68 = 0.0875f; + ptr->unk_6C = 160.0f; + ptr->unk_70 = SQ(160.0f); + ptr->unk_74 = 204.8f; + ptr->unk_78 = 100.0f; + ptr->unk_7C = 327.68f; + return ptr; +} + +EnKusa2UnkBssSubStruct2* func_80A5C2FC(EnKusa2UnkBssStruct* arg0, f32 arg1, Vec3f* arg2, Vec3f* arg3, Vec3s* arg4, + Vec3s* arg5) { + Vec3f* temp_a0; + EnKusa2UnkBssSubStruct2* temp_s0; + f32 phi_f8; + + temp_s0 = func_80A5C0B8(arg0); + temp_s0->unk_00 = arg1; + Math_Vec3f_Copy(&temp_s0->unk_04, arg2); + Math_Vec3f_Copy(&temp_s0->unk_10, arg3); + + if (arg1 >= 0.35f) { + temp_s0->unk_1C = (6.0f / 7); + } else if (arg1 <= 0.1f) { + temp_s0->unk_1C = 1.0f; + } else { + temp_s0->unk_1C = (0.02f / arg1) + 0.8f; + } + + temp_s0->unk_20 = *arg4; + temp_s0->unk_26 = *arg5; + temp_s0->unk_2C = Rand_S16Offset(65, 30); + + return temp_s0; +} + +void func_80A5C410(EnKusa2UnkBssStruct* arg0, EnKusa2UnkBssSubStruct2* arg1, Vec3f* arg2) { + s32 i; + Vec3f sp98; + EnKusa2UnkBssSubStruct* s; + s32 pad; + + Math_Vec3f_Copy(arg2, &gZeroVec3f); + + for (i = 0; i < ARRAY_COUNT(D_80A5F1C0.unk_0000); i++) { + s = &arg0->unk_0000[i]; + + if (s->unk_26 > 0) { + f32 temp_f0; + s32 phi_v0 = true; + s32 phi_s2 = true; + + Math_Vec3f_Diff(&arg1->unk_04, &s->unk_00, &sp98); + temp_f0 = Math3D_LengthSquared(&sp98); + + phi_v0 = false; + if (temp_f0 <= s->unk_4C) { + phi_v0 = true; + } + + phi_s2 = false; + if (temp_f0 <= s->unk_70) { + phi_s2 = true; + } + + if (phi_v0 || phi_s2) { + f32 phi_f22; + + if (temp_f0 < SQ(0.01f)) { + phi_f22 = 0.0f; + } else { + phi_f22 = sqrtf(temp_f0); + } + + if (phi_v0) { + f32 phi_f2; + f32 phi_f20; + + if (phi_f22 > 1.0f) { + phi_f20 = 1.0f / phi_f22; + } else { + phi_f20 = 1.0f; + } + + if (phi_f22 < s->unk_3C) { + phi_f2 = Math_SinS(s->unk_50 * phi_f22) * -s->unk_2C; + } else { + phi_f2 = (Math_CosS(s->unk_54 * (phi_f22 - s->unk_3C)) + 1.0f) * s->unk_30; + } + + arg2->x += sp98.x * -(phi_f20 * phi_f2); + arg2->z += sp98.z * -(phi_f20 * phi_f2); + + if (phi_s2) { + arg2->x += phi_f20 * sp98.z * s->unk_58; + arg2->z -= phi_f20 * sp98.x * s->unk_58; + } + } + + if (phi_s2 && (fabsf(sp98.y) < s->unk_78)) { + arg2->y += + s->unk_68 * (Math_CosS(s->unk_74 * phi_f22) + 1.0f) * (Math_CosS(s->unk_7C * sp98.y) + 1.0f); + } + } + } + } + + arg2->y -= 0.5f; +} + +void func_80A5C70C(EnKusa2UnkBssSubStruct* arg0) { +} + +void func_80A5C718(EnKusa2UnkBssSubStruct* arg0) { + Math_ScaledStepToS(&arg0->unk_20, arg0->unk_22, 1200); + + if ((arg0->unk_1C > 0.0f) && (Rand_ZeroOne() < 0.05f)) { + arg0->unk_1C = -arg0->unk_1C; + } + + arg0->unk_0C.x = Math_SinS(arg0->unk_22) * arg0->unk_18; + arg0->unk_0C.y += arg0->unk_1C; + arg0->unk_0C.z = Math_CosS(arg0->unk_22) * arg0->unk_18; + + arg0->unk_00.x += arg0->unk_0C.x; + arg0->unk_00.y += arg0->unk_0C.y; + arg0->unk_00.z += arg0->unk_0C.z; +} + +void func_80A5C7F0(EnKusa2UnkBssStruct* arg0, EnKusa2UnkBssSubStruct* arg1) { + if (arg1->unk_26 > 0) { + arg1->unk_26--; + arg1->unk_28(arg1); + if (arg1->unk_26 >= arg1->unk_24) { + arg1->unk_2C += arg1->unk_34; + arg1->unk_3C += arg1->unk_40; + arg1->unk_58 += arg1->unk_5C; + } else { + arg1->unk_2C -= arg1->unk_38; + if (arg1->unk_2C < 0.0f) { + arg1->unk_2C = 0.0f; + } + arg1->unk_3C -= arg1->unk_44; + arg1->unk_58 -= arg1->unk_60; + if (arg1->unk_58 < 0.0f) { + arg1->unk_58 = 0.0f; + } + } + arg1->unk_30 = arg1->unk_2C * 0.5f; + arg1->unk_50 = 0x8000 / arg1->unk_3C; + arg1->unk_54 = 0x8000 / (arg1->unk_48 - arg1->unk_3C); + } +} + +void func_80A5C918(EnKusa2UnkBssStruct* arg0, EnKusa2UnkBssSubStruct2* arg1) { + Vec3f sp4C; + s32 pad; + s32 pad2; + Vec3f sp38; + Vec3f sp2C; + f32 phi_f0; + + if (arg1->unk_2C > 0) { + arg1->unk_2C--; + + func_80A5C410(arg0, arg1, &sp4C); + + arg1->unk_10.x += sp4C.x; + arg1->unk_10.y += sp4C.y; + arg1->unk_10.z += sp4C.z; + + sp38.x = arg1->unk_10.x * (arg1->unk_1C * 0.06f); + sp38.x = arg1->unk_10.x * (arg1->unk_1C * 0.06f); + sp38.y = arg1->unk_10.y * (arg1->unk_1C * 0.06f); + sp38.z = arg1->unk_10.z * (arg1->unk_1C * 0.06f); + + sp2C.x = SQ(arg1->unk_10.x) * (arg1->unk_1C * 0.004f); + sp2C.y = SQ(arg1->unk_10.y) * (arg1->unk_1C * 0.004f); + sp2C.z = SQ(arg1->unk_10.z) * (arg1->unk_1C * 0.004f); + + if (arg1->unk_10.x > 0.0f) { + phi_f0 = sp2C.x; + } else { + phi_f0 = -sp2C.x; + } + arg1->unk_10.x -= sp38.x + phi_f0; + + if (arg1->unk_10.y > 0.0f) { + phi_f0 = sp2C.y; + } else { + phi_f0 = -sp2C.y; + } + arg1->unk_10.y -= sp38.y + phi_f0; + + if (arg1->unk_10.z > 0.0f) { + phi_f0 = sp2C.z; + } else { + phi_f0 = -sp2C.z; + } + arg1->unk_10.z -= sp38.z + phi_f0; + + arg1->unk_04.x += arg1->unk_10.x; + arg1->unk_04.y += arg1->unk_10.y; + arg1->unk_04.z += arg1->unk_10.z; + arg1->unk_20.x += arg1->unk_26.x; + arg1->unk_20.y += arg1->unk_26.y; + arg1->unk_20.z += arg1->unk_26.z; + } +} + +void func_80A5CAD4(EnKusa2UnkBssStruct* arg0) { + bzero(arg0, sizeof(EnKusa2UnkBssStruct)); +} + +void func_80A5CAF4(EnKusa2UnkBssStruct* arg0) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_80A5F1C0.unk_0000); i++) { + func_80A5C7F0(arg0, &arg0->unk_0000[i]); + } + + for (i = 0; i < ARRAY_COUNT(D_80A5F1C0.unk_0480); i++) { + func_80A5C918(arg0, &arg0->unk_0480[i]); + } +} + +void func_80A5CB74(EnKusa2* this) { + static s8 D_80A5EB4C = 0; + s32 pad; + Vec3f sp40; + s16 sp3E; + s16 sp3C; + f32 sp38; + s16 sp36; + f32 temp_f0; + + sp40.x = this->actor.world.pos.x; + sp40.y = this->actor.world.pos.y + 20.0f; + sp40.z = this->actor.world.pos.z; + sp3E = Rand_S16Offset(-10000, 20000) + this->actor.world.rot.y; + + if (this->unk_1C0 != NULL) { + sp36 = Actor_YawBetweenActors(&this->actor, &this->unk_1C0->actor); + sp3C = Rand_S16Offset(-4000, 8000) + sp36; + } else { + sp3C = 0; + } + + D_80A5EB4C++; +label: + D_80A5EB4C &= 0x7; + + temp_f0 = Rand_ZeroOne(); + if (D_80A5EB4C == 0) { + sp38 = temp_f0 * 0.70000005f; + } else { + sp38 = SQ(temp_f0) * 0.4f; + } + this->unk_1B8 = func_80A5C104(&D_80A5F1C0, &sp40, (Rand_ZeroOne() * 3.5f) + 4.0f, sp38, sp3E, sp3C); +} + +void func_80A5CCD4(EnKusa2* this) { + if (this->unk_1B8 != NULL) { + EnKusa2UnkBssSubStruct* ptr = this->unk_1B8; + + ptr->unk_00.x = this->actor.world.pos.x; + ptr->unk_00.y = this->actor.world.pos.y + 20.0f; + ptr->unk_00.z = this->actor.world.pos.z; + } +} + +void func_80A5CD0C(EnKusa2* this) { + s32 i; + Vec3f spA8; + Vec3f sp9C; + Vec3s sp94; + Vec3s sp8C; + f32 temp_f20; + s16 temp_s0; + s32 pad; + + for (i = 0; i < 2; i++) { + temp_s0 = (u32)Rand_Next() & 0xFFFF; + temp_f20 = Rand_ZeroOne() * 30.0f; + + spA8.x = Math_SinS(temp_s0) * temp_f20; + spA8.y = Rand_ZeroOne() * 30.0f; + spA8.z = Math_CosS(temp_s0) * temp_f20; + + sp9C.x = ((Rand_ZeroOne() * 4.0f) - 2.0f) + (spA8.x * 0.18f); + sp9C.y = (Rand_ZeroOne() * 8.0f) + 3.0f; + sp9C.z = ((Rand_ZeroOne() * 4.0f) - 2.0f) + (spA8.z * 0.18f); + + spA8.x += this->actor.world.pos.x; + spA8.y += this->actor.world.pos.y; + spA8.z += this->actor.world.pos.z; + + sp94.x = (u32)Rand_Next() & 0xFFFF; + sp94.y = (u32)Rand_Next() & 0xFFFF; + sp94.z = (u32)Rand_Next() & 0xFFFF; + + sp8C.x = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp8C.y = ((u32)Rand_Next() % 0x2000) - 0xFFF; + sp8C.z = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + + func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.4f) + 0.02f, &spA8, &sp9C, &sp94, &sp8C); + } +} + +void func_80A5CF44(EnKusa2* this) { + s32 i; + Vec3f spA8; + Vec3f sp9C; + Vec3s sp94; + Vec3s sp8C; + f32 temp_f20; + s16 temp_s0; + s32 phi_s2; + + for (i = 0, phi_s2 = 0; i < 8; i++, phi_s2 += 0x2000) { + temp_s0 = ((u32)Rand_Next() % 0x2000) + phi_s2; + temp_f20 = Rand_ZeroOne() * 30.0f; + + spA8.x = Math_SinS(temp_s0) * temp_f20; + spA8.y = Rand_ZeroOne() * 30.0f; + spA8.z = Math_CosS(temp_s0) * temp_f20; + + sp9C.x = ((Rand_ZeroOne() * 6.0f) - 3.0f) + (spA8.x * 0.19f); + sp9C.y = (Rand_ZeroOne() * 9.0f) + 3.0f; + sp9C.z = ((Rand_ZeroOne() * 6.0f) - 3.0f) + (spA8.z * 0.19f); + + spA8.x += this->actor.world.pos.x; + spA8.y += this->actor.world.pos.y; + spA8.z += this->actor.world.pos.z; + + sp94.x = Rand_Next() & 0xFFFF; + sp94.y = Rand_Next() & 0xFFFF; + sp94.z = Rand_Next() & 0xFFFF; + + sp8C.x = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp8C.y = ((u32)Rand_Next() % 0x2000) - 0xFFF; + sp8C.z = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + + func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.45f) + 0.04f, &spA8, &sp9C, &sp94, &sp8C); + } +} + +void func_80A5D178(EnKusa2* this) { + s32 i; + Vec3f spB0; + Vec3f spA4; + Vec3s sp9C; + Vec3s sp94; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + s16 temp_s0; + s32 pad; + + for (i = 0; i < 8; i++) { + temp_s0 = (u32)Rand_Next(); + temp_f22 = Math_SinS(temp_s0); + temp_f20 = Math_CosS(temp_s0); + temp_f24 = (Rand_ZeroOne() * 40.0f) + 10.0f; + + spB0.x = temp_f24 * temp_f22; + spB0.y = Rand_ZeroOne() * 30.0f; + spB0.z = temp_f24 * temp_f20; + + spA4.x = ((Rand_ZeroOne() * 6.0f) - 3.0f) + ((temp_f20 * 6.0f) + (spB0.x * 0.1f)); + spA4.y = (Rand_ZeroOne() * 3.0f) + 1.0f; + spA4.z = ((Rand_ZeroOne() * 6.0f) - 3.0f) + ((temp_f22 * -6.0f) + (spB0.z * 0.1f)); + + spB0.x += this->actor.world.pos.x; + spB0.y += this->actor.world.pos.y; + spB0.z += this->actor.world.pos.z; + + sp9C.x = (u32)Rand_Next() & 0xFFFF; + sp9C.y = (u32)Rand_Next() & 0xFFFF; + sp9C.z = (u32)Rand_Next() & 0xFFFF; + + sp94.x = Rand_S16Offset(-12000, 24000); + sp94.y = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp94.z = Rand_S16Offset(-12000, 24000); + func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.38f) + 0.02f, &spB0, &spA4, &sp9C, &sp94); + } +} + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), }; -#endif +void EnKusa2_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnKusa2* this = THIS; -extern ColliderCylinderInit D_80A5EAC0; -extern InitChainEntry D_80A5EB50[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + if (!ENKUSA2_GET_1(&this->actor)) { + this->actor.update = func_80A5E604; + this->actor.draw = NULL; + this->actor.flags |= 0x20; + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 1); + this->unk_1BE = 0; + if (D_80A5EAEC != 0) { + D_80A5EAEC = 0; + D_80A60900 = globalCtx->gameplayFrames; + func_80A5CAD4(&D_80A5F1C0); + D_80A60B08 = (u32)Rand_Next() >> 0x10; + D_80A60B0A = (u32)Rand_Next() >> 0x10; + D_80A60B0C = (u32)Rand_Next() >> 0x10; + D_80A60B0E = (u32)Rand_Next() >> 0x10; + D_80A60B10 = (u32)Rand_Next() >> 0x10; + func_80A5B508(); + } + func_80A5D5E0(this); + } else { + Collider_InitCylinder(globalCtx, &this->collider); + if (!func_80A5BA58(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + } else { + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_1CE = D_80A5EAF0 & 7; + D_80A5EAF0++; + this->actor.shape.shadowAlpha = 0; + this->unk_1CF = 255; + this->actor.shape.shadowScale = 1.0f; + func_80A5D7A4(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5B160.s") +void EnKusa2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKusa2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5B334.s") + if (ENKUSA2_GET_1(&this->actor) == 1) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5B3BC.s") +void func_80A5D5E0(EnKusa2* this) { + this->actionFunc = func_80A5D5F4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5B490.s") +void func_80A5D5F4(EnKusa2* this, GlobalContext* globalCtx) { + func_80A5D618(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5B508.s") +void func_80A5D618(EnKusa2* this) { + this->actionFunc = func_80A5D62C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5B954.s") +void func_80A5D62C(EnKusa2* this, GlobalContext* globalCtx) { + if (this->unk_1BE != 0) { + func_80A5B490(this, globalCtx); + func_80A5D754(this); + } else if (Math3D_XZLengthSquared(this->actor.projectedPos.x, this->actor.projectedPos.z) < SQ(1600.0f)) { + func_80A5B160(this, globalCtx); + func_80A5D6B0(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5BA58.s") +void func_80A5D6B0(EnKusa2* this) { + this->actionFunc = func_80A5D6C4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5BAFC.s") +void func_80A5D6C4(EnKusa2* this, GlobalContext* globalCtx) { + func_80A5B3BC(this); + if (this->unk_1BE != 0) { + func_80A5B490(this, globalCtx); + func_80A5D754(this); + } else if (Math3D_XZLengthSquared(this->actor.projectedPos.x, this->actor.projectedPos.z) > SQ(1750.0f)) { + func_80A5B334(this, globalCtx); + func_80A5D618(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5BB40.s") +void func_80A5D754(EnKusa2* this) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5BD14.s") + for (i = 0; i < ARRAY_COUNT(this->unk_194); i++) { + this->unk_194[i] = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5BD94.s") + this->actionFunc = func_80A5D794; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5BDB0.s") +void func_80A5D794(EnKusa2* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5BF38.s") +void func_80A5D7A4(EnKusa2* this) { + this->actor.draw = EnKusa2_Draw; + this->actionFunc = func_80A5D7C4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5BF60.s") +void func_80A5D7C4(EnKusa2* this, GlobalContext* globalCtx) { + EnKusa2* this2 = this; + s16 sp2A; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5BF84.s") + if (Actor_HasParent(&this->actor, globalCtx)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.shape.shadowAlpha = 60; + this->actor.room = -1; + func_80A5BD94(this); + func_80A5D964(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5BFD8.s") + if (!func_80A5BFD8(this, globalCtx)) { + if ((this->unk_1C0 != NULL) && (this->unk_1C0->unk_1BE != 0)) { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + if (this2->unk_1C0 != NULL) { + sp2A = Actor_YawBetweenActors(&this->unk_1C0->actor, &this->actor); + this->actor.home.rot.y = Rand_S16Offset(-1500, 3000) + sp2A; + } + this->unk_1C8 = Rand_S16Offset(72, 16); + this->actor.velocity.y = 8.8f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + func_80A5DC70(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5C074.s") + if (this->actor.xzDistToPlayer < 600.0f) { + 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) { + Actor_LiftActor(&this->actor, globalCtx); + } + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5C0B8.s") +void func_80A5D964(EnKusa2* this) { + this->actor.draw = func_80A5E9B4; + this->actionFunc = func_80A5D9C8; + D_80A5EAF4.x = 0; + D_80A5EAF4.y = 0; + D_80A5EAF4.z = 0; + D_80A5EAFC.x = 0; + D_80A5EAFC.y = 0; + D_80A5EAFC.z = 0; + D_80A5EB04.x = 0; + D_80A5EB04.y = 0; + D_80A5EB04.z = 0; + this->unk_1D0 = 30; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5C104.s") +void func_80A5D9C8(EnKusa2* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + s32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5C2FC.s") + D_80A5EAF4.x += 11000; + D_80A5EAF4.y += 17000; + D_80A5EAF4.z += 9000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5C410.s") + this->actor.scale.x = (Math_SinS(D_80A5EAF4.x) * 0.020000001f) + 0.4f; + this->actor.scale.y = (Math_SinS(D_80A5EAF4.y) * 0.020000001f) + 0.4f; + this->actor.scale.z = (Math_SinS(D_80A5EAF4.z) * 0.020000001f) + 0.4f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5C70C.s") + D_80A5EB04.x += 18000; + D_80A5EB04.y += 17000; + D_80A5EB04.z += 16000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5C718.s") + D_80A5EAFC.x = Math_SinS(D_80A5EB04.x) * 1000.0f; + D_80A5EAFC.y = Math_SinS(D_80A5EB04.y) * 1000.0f; + D_80A5EAFC.z = Math_SinS(D_80A5EB04.z) * 1000.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5C7F0.s") + if (Actor_HasNoParent(&this->actor, globalCtx)) { + this->actor.room = globalCtx->roomCtx.currRoom.num; + this->actor.colChkInfo.mass = 80; + this->actor.home.rot.y = this->actor.world.rot.y; + this->actor.velocity.y = 12.5f; + this->actor.speedXZ += 3.0f; + Actor_MoveWithGravity(&this->actor); + func_80A5BAFC(this, globalCtx); + func_80A5CD0C(this); + this->unk_1C8 = 30; + func_80A5DC70(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; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5C918.s") + if ((u32)Rand_Next() < 0xFFFFFFF) { + func_80A5CD0C(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5CAD4.s") + this->unk_1D0--; + if (this->unk_1D0 <= 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + this->unk_1D0 = ((u32)Rand_Next() >> 0x1D) + 14; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5CAF4.s") + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5CB74.s") +void func_80A5DC70(EnKusa2* this) { + this->actionFunc = func_80A5DC98; + this->actor.draw = func_80A5EA48; + this->unk_1CA = 80; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5CCD4.s") +void func_80A5DC98(EnKusa2* this, GlobalContext* globalCtx) { + if (!func_80A5BFD8(this, globalCtx)) { + if (this->actor.velocity.y > 1.0f) { + Math_StepToF(&this->actor.scale.y, 0.3f, 0.060000002f); + Math_StepToF(&this->actor.scale.x, 0.328f, 0.040000003f); + } else { + Math_StepToF(&this->actor.scale.y, 0.48000002f, 0.080000006f); + Math_StepToF(&this->actor.scale.x, 0.28f, 0.032f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5CD0C.s") + this->actor.scale.z = this->actor.scale.x; + Math_StepToF(&this->actor.gravity, -7.0f, 1.8f); + Actor_MoveWithGravity(&this->actor); + func_80A5BAFC(this, globalCtx); + func_80A5BF38(this, 4); + func_80A5BF84(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5CF44.s") + if (this->actor.bgCheckFlags & 1) { + func_80A5CD0C(this); + func_80A5BB40(this, globalCtx, 1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + func_80A5DE18(this); + } else if (this->actor.bgCheckFlags & 0x20) { + func_80A5BDB0(this, globalCtx); + func_80A5E418(this); + } else if (this->unk_1CA > 0) { + this->unk_1CA--; + } else { + Actor_MarkForDeath(&this->actor); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5D178.s") +void func_80A5DE18(EnKusa2* this) { + this->actionFunc = func_80A5DEB4; + this->actor.draw = func_80A5EA48; + this->actor.gravity = -2.0f; + this->unk_1D0 = (s32)(Rand_ZeroOne() * 3.0f); + this->unk_1D1 = (s32)(Rand_ZeroOne() * 8.0f) + 7; + this->unk_1CA = Rand_S16Offset(19, 2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/EnKusa2_Init.s") +void func_80A5DEB4(EnKusa2* this, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + s16 sp24; + s32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/EnKusa2_Destroy.s") + if (!func_80A5BFD8(this, globalCtx)) { + if (this->unk_1D0 > 0) { + this->unk_1D0--; + if (this->unk_1D0 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5D5E0.s") + if (this->unk_1D1 > 0) { + this->unk_1D1--; + if (this->unk_1D1 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5D5F4.s") + Math_StepToF(&this->actor.scale.y, 0.4f, 0.032f); + Math_StepToF(&this->actor.scale.x, 0.4f, 0.032f); + this->unk_1C4 += 0x4650; + this->actor.scale.z = this->actor.scale.x; + this->actor.speedXZ = fabsf(Math_CosS(this->unk_1C4) + 0.5f) * 1.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5D618.s") + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5D62C.s") + Actor_MoveWithGravity(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5D6B0.s") + this->actor.world.rot.y = (s32)(Math_SinS(this->unk_1C4) * 3000.0f) + this->actor.home.rot.y; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.x = (s32)(fabsf(Math_SinS(this->unk_1C4)) * 4000.0f) - 0x6A4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5D6C4.s") + func_80A5BAFC(this, globalCtx); + func_80A5BF38(this, 4); + func_80A5BF84(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5D754.s") + if ((u32)Rand_Next() < 0xFFFFFFF) { + func_80A5CD0C(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5D794.s") + if (this->actor.bgCheckFlags & 0x20) { + func_80A5BDB0(this, globalCtx); + func_80A5E418(this); + } else { + this->unk_1C8--; + if (this->unk_1C8 <= 0) { + func_80A5CD0C(this); + func_80A5BB40(this, globalCtx, 4); + this->actor.speedXZ += 4.0f; + this->actor.velocity.y = (Rand_ZeroOne() * 4.0f) + 15.0f; + func_80A5E1D8(this); + } else if (this->actor.bgCheckFlags & 1) { + this->unk_1CA--; + if (this->unk_1CA <= 0) { + func_80A5CD0C(this); + func_80A5BB40(this, globalCtx, 2); + this->actor.velocity.y = (Rand_ZeroOne() * 6.0f) + 7.0f; + this->actor.speedXZ += 2.0f; + if (this->actor.yawTowardsPlayer < this->actor.world.rot.y) { + sp20 = 10000; + } else { + sp20 = -10000; + } + sp24 = sp20 + Rand_S16Offset(-3000, 6000); + this->actor.home.rot.y += sp24; + this->actor.world.rot.y = this->actor.home.rot.y; + func_80A5DC70(this); + } + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5D7A4.s") +void func_80A5E1D8(EnKusa2* this) { + this->actionFunc = func_80A5E210; + this->actor.draw = func_80A5EA48; + this->unk_1CC = 0; + func_80A5CB74(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5D7C4.s") +void func_80A5E210(EnKusa2* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.gravity, -4.0f, 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5D964.s") + if (this->actor.bgCheckFlags & 1) { + this->actor.speedXZ *= 0.4f; + if (this->actor.bgCheckFlags & 2) { + func_80A5D178(this); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_KUSAMUSHI_HIDE); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5D9C8.s") + Actor_MoveWithGravity(&this->actor); + func_80A5BAFC(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5DC70.s") + if (this->actor.velocity.y > 0.01f) { + func_80A5BF38(this, 4); + this->unk_1CC += 1000; + } else { + func_80A5BF60(this, 10); + this->unk_1CF -= 20; + this->unk_1CC += 5000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5DC98.s") + if (this->unk_1CC > 20000) { + this->unk_1CC = 20000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5DE18.s") + this->actor.shape.rot.y += this->unk_1CC; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5DEB4.s") + if (this->actor.velocity.y > 1.0f) { + Math_StepToF(&this->actor.scale.y, 0.24000001f, 0.080000006f); + Math_StepToF(&this->actor.scale.x, 0.32000002f, 0.040000003f); + } else if (this->actor.bgCheckFlags & 1) { + Math_StepToF(&this->actor.scale.y, 0.0f, 0.120000005f); + Math_StepToF(&this->actor.scale.x, 0.48000002f, 0.120000005f); + } else { + Math_StepToF(&this->actor.scale.y, 0.56f, 0.1f); + Math_StepToF(&this->actor.scale.x, 0.24000001f, 0.1f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5E1D8.s") + this->actor.scale.z = this->actor.scale.x; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5E210.s") + if (this->unk_1CF <= 20) { + if (this->unk_1B8 != NULL) { + this->unk_1B8->unk_28 = func_80A5C718; + } + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5E418.s") +void func_80A5E418(EnKusa2* this) { + this->actor.terminalVelocity = -4.0f; + this->actor.velocity.x *= 0.1f; + this->actor.velocity.y *= 0.25f; + this->actor.velocity.z *= 0.1f; + this->actor.draw = func_80A5EA48; + this->actor.speedXZ *= 0.1f; + this->actor.gravity *= 0.25f; + this->unk_1CC = Rand_S16Offset(-800, 1600); + this->actionFunc = func_80A5E4BC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5E4BC.s") +void func_80A5E4BC(EnKusa2* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.scale.y, 0.4f, 0.032f); + Math_StepToF(&this->actor.scale.x, 0.4f, 0.032f); + this->actor.scale.z = this->actor.scale.x; + Actor_MoveWithGravity(&this->actor); + func_80A5BAFC(this, globalCtx); + func_80A5BF60(this, 6); + this->actor.shape.rot.x -= 0x5DC; + this->actor.shape.rot.y += this->unk_1CC; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5E604.s") + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 5.0f) && (Rand_ZeroOne() < 0.8f)) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 20.0f, 10.0f, 20.0f, (Rand_ZeroOne() * 0.08f) + 0.04f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/EnKusa2_Update.s") + this->unk_1CF -= 15; + if (this->unk_1CF <= 15) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5E6F0.s") +void func_80A5E604(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnKusa2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5E80C.s") + this->actionFunc(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/EnKusa2_Draw.s") + if (D_80A60900 == globalCtx->gameplayFrames) { + this->actor.draw = NULL; + } else { + this->actor.draw = func_80A5E6F0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5E9B4.s") + if (globalCtx->roomCtx.currRoom.unk3 == 0) { + func_80A5B508(); + } + func_80A5CAF4(&D_80A5F1C0); + D_80A60900 = globalCtx->gameplayFrames; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa2/func_80A5EA48.s") +void EnKusa2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKusa2* this = THIS; + + if ((this->unk_1C0 != NULL) && (this->unk_1C0->actor.update == NULL)) { + this->unk_1C0 = NULL; + } + + this->actionFunc(this, globalCtx); + + func_80A5CCD4(this); +} + +void func_80A5E6F0(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* D_80A5EB68[] = { + D_040528B0, + D_040527F0, + }; + EnKusa2* this = THIS; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(D_80A5F1C0.unk_0480); i++) { + EnKusa2UnkBssSubStruct2* s = &D_80A5F1C0.unk_0480[i]; + + if (s->unk_2C > 0) { + Matrix_SetStateRotationAndTranslation(s->unk_04.x, s->unk_04.y, s->unk_04.z, &s->unk_20); + Matrix_Scale(s->unk_00, s->unk_00, s->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++, D_80A5EB68[i & 1]); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A5E80C(GlobalContext* globalCtx, s32 arg1) { + 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); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, arg1); + gSPDisplayList(POLY_XLU_DISP++, D_05007938); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnKusa2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKusa2* this = THIS; + + if (this->actor.projectedPos.z <= 1200.0f) { + if ((globalCtx->roomCtx.currRoom.unk3 == 0) && (this->actor.projectedPos.z > -150.0f) && + (this->actor.projectedPos.z < 400.0f)) { + func_80A5B954(&D_80A60908[this->unk_1CE], 0.0015f); + } + Gfx_DrawDListOpa(globalCtx, D_050078A0); + } else if (this->actor.projectedPos.z < 1300.0f) { + func_80A5E80C(globalCtx, (1300.0f - this->actor.projectedPos.z) * 2.55f); + } +} + +void func_80A5E9B4(Actor* thisx, GlobalContext* globalCtx) { + Vec3s sp18; + + sp18.x = thisx->shape.rot.x + D_80A5EAFC.x; + sp18.y = thisx->shape.rot.y + D_80A5EAFC.y; + 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, D_050078A0); +} + +void func_80A5EA48(Actor* thisx, GlobalContext* globalCtx) { + EnKusa2* this = THIS; + + if (this->unk_1CF == 0xFF) { + Gfx_DrawDListOpa(globalCtx, D_050078A0); + } else { + func_80A5E80C(globalCtx, this->unk_1CF); + } +} diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.h b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.h index 409c0c8130..f18c1a6a7a 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.h +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.h @@ -4,14 +4,81 @@ #include "global.h" struct EnKusa2; +struct EnKusa2UnkBssSubStruct; typedef void (*EnKusa2ActionFunc)(struct EnKusa2*, GlobalContext*); +typedef void (*EnKusa2BssFunc)(struct EnKusa2UnkBssSubStruct*); + +#define ENKUSA2_GET_1(thisx) (((thisx)->params) & 1) +#define ENKUSA2_GET_7F00(thisx) (u8)((((thisx)->params) >> 8) & 0x7F) + +typedef struct EnKusa2UnkBssSubStruct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ s16 unk_20; + /* 0x22 */ s16 unk_22; + /* 0x24 */ s16 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ EnKusa2BssFunc unk_28; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; + /* 0x3C */ f32 unk_3C; + /* 0x40 */ f32 unk_40; + /* 0x44 */ f32 unk_44; + /* 0x48 */ f32 unk_48; + /* 0x4C */ f32 unk_4C; + /* 0x50 */ f32 unk_50; + /* 0x54 */ f32 unk_54; + /* 0x58 */ f32 unk_58; + /* 0x5C */ f32 unk_5C; + /* 0x60 */ f32 unk_60; + /* 0x64 */ f32 unk_64; + /* 0x68 */ f32 unk_68; + /* 0x6C */ f32 unk_6C; + /* 0x70 */ f32 unk_70; + /* 0x74 */ f32 unk_74; + /* 0x78 */ f32 unk_78; + /* 0x7C */ f32 unk_7C; +} EnKusa2UnkBssSubStruct; // size = 0x80 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ Vec3f unk_04; + /* 0x10 */ Vec3f unk_10; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ Vec3s unk_20; + /* 0x26 */ Vec3s unk_26; + /* 0x2C */ s16 unk_2C; + /* 0x2C */ UNK_TYPE1 unk2E[0x2]; +} EnKusa2UnkBssSubStruct2; // size = 0x30 + +typedef struct { + /* 0x0000 */ EnKusa2UnkBssSubStruct unk_0000[9]; + /* 0x0480 */ EnKusa2UnkBssSubStruct2 unk_0480[100]; +} EnKusa2UnkBssStruct; // size = 0x1740 typedef struct EnKusa2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; + /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ EnKusa2ActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x40]; + /* 0x0194 */ struct EnKusa2* unk_194[9]; + /* 0x01B8 */ EnKusa2UnkBssSubStruct* unk_1B8; + /* 0x01BC */ s16 unk_1BC; + /* 0x01BE */ s8 unk_1BE; + /* 0x01C0 */ struct EnKusa2* unk_1C0; + /* 0x01C4 */ s16 unk_1C4; + /* 0x01C6 */ UNK_TYPE1 unk1C6[0x2]; + /* 0x01C8 */ s16 unk_1C8; + /* 0x01CA */ s16 unk_1CA; + /* 0x01CC */ s16 unk_1CC; + /* 0x01CE */ s8 unk_1CE; + /* 0x01CF */ u8 unk_1CF; + /* 0x01D0 */ s8 unk_1D0; + /* 0x01D1 */ s8 unk_1D1; } EnKusa2; // size = 0x1D4 extern const ActorInit En_Kusa2_InitVars; diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index 92908ac6d9..0901fd9b22 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -200,7 +200,7 @@ void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { EnMa4* this = THIS; s32 pad; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 18.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, NULL, this->jointTable, this->morphTable, MA1_LIMB_MAX); @@ -287,7 +287,7 @@ void EnMa4_RunInCircles(EnMa4* this, GlobalContext* globalCtx) { } if (sCurrentAnim == 13 && Animation_OnFrame(&this->skelAnime, 37.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROMANI_BOW_FLICK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROMANI_BOW_FLICK); } sp34.x = this->pathPoints[this->pathIndex].x; @@ -317,10 +317,10 @@ void EnMa4_RunInCircles(EnMa4* this, GlobalContext* globalCtx) { } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (this->skelAnime.animation == &D_06007328) { // Walking animation if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 4.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } } } @@ -363,7 +363,7 @@ void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { } } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { EnMa4_StartDialogue(this, globalCtx); EnMa4_SetupDialogueHandler(this); } else if (this->type != MA4_TYPE_ALIENS_WON || ABS_ALT(yaw) < 0x4000) { @@ -648,7 +648,7 @@ void EnMa4_SetupDialogueHandler(EnMa4* this) { void EnMa4_DialogueHandler(EnMa4* this, GlobalContext* globalCtx) { s32 temp_v0; - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { default: break; @@ -692,7 +692,7 @@ void EnMa4_BeginHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { } void EnMa4_HorsebackGameCheckPlayerInteractions(EnMa4* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { // "You're feeling confident" func_801518B0(globalCtx, 0x336E, &this->actor); this->actionFunc = EnMa4_HorsebackGameTalking; @@ -702,7 +702,7 @@ void EnMa4_HorsebackGameCheckPlayerInteractions(EnMa4* this, GlobalContext* glob } void EnMa4_HorsebackGameTalking(EnMa4* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actionFunc = EnMa4_HorsebackGameWait; } } @@ -760,7 +760,7 @@ void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { if (player->stateFlags1 & 0x100000) { globalCtx->actorCtx.unk268 = 1; - globalCtx->actorCtx.unk278 = 0x8000; + globalCtx->actorCtx.unk_26C.press.button = BTN_A; } else { globalCtx->actorCtx.unk268 = 1; } @@ -850,7 +850,7 @@ void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); player->stateFlags1 |= 0x20; - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); D_80AC0260 = 99; this->hasBow = true; EnMa4_SetupEndEponasSongCs(this); @@ -865,14 +865,14 @@ void EnMa4_EndEponasSongCs(EnMa4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); this->actor.flags |= 0x10000; - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { player->stateFlags1 &= ~0x20; func_801518B0(globalCtx, 0x334C, &this->actor); this->textId = 0x334C; this->actor.flags &= ~0x10000; EnMa4_SetupDialogueHandler(this); } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } } diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 6b55a48a74..92a56a4198 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -188,7 +188,7 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 18.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06015C28, NULL, this->jointTable, this->morphTable, MA2_LIMB_MAX); EnMaYto_InitAnimation(this, globalCtx); @@ -321,7 +321,7 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx) { } s32 EnMaYto_SearchRomani(EnMaYto* this, GlobalContext* globalCtx) { - Actor* npcActor = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* npcActor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (npcActor != NULL) { if (npcActor->id == ACTOR_EN_MA_YTS) { @@ -425,7 +425,7 @@ void EnMaYto_DefaultWait(EnMaYto* this, GlobalContext* globalCtx) { EnMaYto_ChangeAnim(this, 11); } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { EnMaYto_DefaultStartDialogue(this, globalCtx); EnMaYto_SetupDefaultDialogueHandler(this); } else if (ABS_ALT(direction) < 0x1555) { @@ -440,7 +440,7 @@ void EnMaYto_SetupDefaultDialogueHandler(EnMaYto* this) { } void EnMaYto_DefaultDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 4: EnMaYto_DefaultHandlePlayerChoice(this, globalCtx); break; @@ -535,14 +535,14 @@ void EnMaYto_SetupDinnerWait(EnMaYto* this) { void EnMaYto_DinnerWait(EnMaYto* this, GlobalContext* globalCtx) { s16 direction = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { EnMaYto_DinnerStartDialogue(this, globalCtx); EnMaYto_SetupDinnerDialogueHandler(this); } else { Actor* child = this->actor.child; - if (child != NULL && func_800B84D0(child, globalCtx)) { - func_800B86C8(&this->actor, globalCtx, &this->actor); + if (child != NULL && Actor_ProcessTalkRequest(child, &globalCtx->state)) { + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_DinnerStartDialogue(this, globalCtx); EnMaYto_SetupDinnerDialogueHandler(this); } else if (ABS_ALT(direction) < 0x4000) { @@ -572,7 +572,7 @@ void EnMaYto_SetupDinnerDialogueHandler(EnMaYto* this) { } void EnMaYto_DinnerDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 4: EnMaYto_DinnerHandlePlayerChoice(this, globalCtx); break; @@ -635,7 +635,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 0x339B: - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 0); EnMaYto_SetRomaniFaceExpression(this, 3, 3); func_801518B0(globalCtx, 0x339C, &this->actor); @@ -644,7 +644,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x339C: this->unk31E = 1; - func_800B86C8(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 0, 2); func_801518B0(globalCtx, 0x339D, &this->actor); this->textId = 0x339D; @@ -652,7 +652,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x339D: func_80B90E50(this, 1); - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 1); func_801518B0(globalCtx, 0x339E, &this->actor); this->textId = 0x339E; @@ -673,7 +673,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x33A1: func_80B90E50(this, 1); - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 2); func_801518B0(globalCtx, 0x33A2, &this->actor); this->textId = 0x33A2; @@ -681,7 +681,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x33A2: this->unk31E = 1; - func_800B86C8(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 4, 3); func_801518B0(globalCtx, 0x33A3, &this->actor); this->textId = 0x33A3; @@ -730,14 +730,14 @@ void EnMaYto_BarnWait(EnMaYto* this, GlobalContext* globalCtx) { s16 direction = this->actor.shape.rot.y + 0x471C; direction -= this->actor.yawTowardsPlayer; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { EnMaYto_BarnStartDialogue(this, globalCtx); EnMaYto_SetupBarnDialogueHandler(this); } else { Actor* child = this->actor.child; - if (child != NULL && func_800B84D0(child, globalCtx)) { - func_800B86C8(&this->actor, globalCtx, &this->actor); + if (child != NULL && Actor_ProcessTalkRequest(child, &globalCtx->state)) { + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_BarnStartDialogue(this, globalCtx); EnMaYto_SetupBarnDialogueHandler(this); } else if (!(gSaveContext.weekEventReg[0x16] & 1) || ABS_ALT(direction) < 0x2000) { @@ -762,7 +762,7 @@ void EnMaYto_SetupBarnDialogueHandler(EnMaYto* this) { } void EnMaYto_BarnDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 5: EnMaYto_BarnChooseNextDialogue(this, globalCtx); break; @@ -788,14 +788,14 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { switch (this->textId) { case 0x33A9: func_80B90E50(this, 0); - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 3); func_801518B0(globalCtx, 0x33AA, &this->actor); this->textId = 0x33AA; break; case 0x33AA: - func_800B86C8(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; func_801518B0(globalCtx, 0x33AB, &this->actor); this->textId = 0x33AB; @@ -803,7 +803,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x33AB: func_80B90E50(this, 1); - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 1); func_801518B0(globalCtx, 0x33AC, &this->actor); this->textId = 0x33AC; @@ -811,7 +811,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x33AC: this->unk31E = 0; - func_800B86C8(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); func_801518B0(globalCtx, 0x33AD, &this->actor); this->textId = 0x33AD; func_80151BB4(globalCtx, 6); @@ -820,7 +820,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x33AE: func_80B90E50(this, 1); - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 4, 2); func_801518B0(globalCtx, 0x33AF, &this->actor); this->textId = 0x33AF; @@ -828,7 +828,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x33AF: this->unk31E = 1; - func_800B86C8(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 4, 2); func_801518B0(globalCtx, 0x33B0, &this->actor); this->textId = 0x33B0; @@ -846,7 +846,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 0x33C6: - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); this->unk31E = 0; EnMaYto_SetFaceExpression(this, 0, 1); func_801518B0(globalCtx, 0x33C7, &this->actor); @@ -854,7 +854,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 0x33C7: - func_800B86C8(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; EnMaYto_SetFaceExpression(this, 0, 1); func_801518B0(globalCtx, 0x33C8, &this->actor); @@ -862,7 +862,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 0x33C8: - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 1); EnMaYto_SetRomaniFaceExpression(this, 0, 2); func_801518B0(globalCtx, 0x33C9, &this->actor); @@ -870,7 +870,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 0x33C9: - func_800B86C8(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; EnMaYto_SetFaceExpression(this, 3, 1); func_801518B0(globalCtx, 0x33CA, &this->actor); @@ -884,7 +884,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 0x33CB: - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 1); EnMaYto_SetRomaniFaceExpression(this, 3, 3); func_801518B0(globalCtx, 0x33CC, &this->actor); @@ -912,7 +912,7 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx) { this->actor.flags |= 0x10000; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; if (gSaveContext.weekEventReg[0x34] & 1) { // if (ProtectedCremia) @@ -942,7 +942,7 @@ void EnMaYto_SetupAfterMilkRunDialogueHandler(EnMaYto* this) { } void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: case 1: case 2: @@ -986,10 +986,10 @@ void EnMaYto_PostMilkRunGiveReward(EnMaYto* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { EnMaYto_SetupPostMilkRunExplainReward(this); } else if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_HUGE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_HUGE, 500.0f, 100.0f); this->unk310 = 2; } else { - func_800B8A1C(&this->actor, globalCtx, GI_MASK_ROMANI, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MASK_ROMANI, 500.0f, 100.0f); this->unk310 = 1; } } @@ -999,7 +999,7 @@ void EnMaYto_SetupPostMilkRunExplainReward(EnMaYto* this) { } void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->unk310 == 1) { // Romani's mask explanation EnMaYto_SetFaceExpression(this, 0, 1); @@ -1024,7 +1024,7 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); } } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } } @@ -1095,14 +1095,14 @@ void EnMaYto_SetupPostMilkRunWaitDialogueEnd(EnMaYto* this) { } void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 6 || func_80152498(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx) && func_80152498(&globalCtx->msgCtx) == 5) { + if (Message_GetState(&globalCtx->msgCtx) == 6 || Message_GetState(&globalCtx->msgCtx) == 5) { + if (func_80147624(globalCtx) && Message_GetState(&globalCtx->msgCtx) == 5) { func_800B7298(globalCtx, &this->actor, 7); func_801477B4(globalCtx); } } - if (func_80152498(&globalCtx->msgCtx) == 0 && globalCtx->msgCtx.unk120B1 == 0) { + if (Message_GetState(&globalCtx->msgCtx) == 0 && globalCtx->msgCtx.unk120B1 == 0) { EnMaYto_SetupPostMilkRunEnd(this); } } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index 266ba90e96..1ed32213a7 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -245,7 +245,8 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { if (!EnMaYts_CheckValidSpawn(this, globalCtx)) { Actor_MarkForDeath(&this->actor); } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 18.0f); + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, NULL, this->jointTable, this->morphTable, MA1_LIMB_MAX); EnMaYts_InitAnimation(this, globalCtx); @@ -317,7 +318,7 @@ void EnMaYts_SetupStartDialogue(EnMaYts* this) { void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { s16 sp26 = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; - if (func_800B84D0(&this->actor, globalCtx)) { // if (Actor_IsTalking) + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (!(gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { if (!(gSaveContext.weekEventReg[0x41] & 0x80)) { // Saying to non-human Link: "Cremia went to town." @@ -374,7 +375,7 @@ void EnMaYts_SetupDialogueHandler(EnMaYts* this) { } void EnMaYts_DialogueHandler(EnMaYts* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 5: // End message block EnMaYts_ChooseNextDialogue(this, globalCtx); break; diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 4b5585086d..eecc287908 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -91,7 +91,7 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { int i; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 15.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 15.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B538, &D_06001534, this->jointTable, this->morphTable, 24); CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -164,7 +164,7 @@ void EnMinifrog_Destroy(Actor* thisx, GlobalContext* globalCtx) { } EnMinifrog* EnMinifrog_GetFrog(GlobalContext* globalCtx) { - EnMinifrog* frog = (EnMinifrog*)globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + EnMinifrog* frog = (EnMinifrog*)globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (frog != NULL) { if ((frog->actor.id != ACTOR_EN_MINIFROG) || (frog->actor.params & 0xF)) { @@ -200,7 +200,7 @@ void EnMinifrog_Jump(EnMinifrog* this) { if (Animation_OnFrame(&this->skelAnime, 4.0f)) { this->actor.bgCheckFlags &= ~1; this->actor.velocity.y = 6.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_JUMP); this->jumpState = MINIFROG_STATE_AIR; } break; @@ -262,7 +262,7 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { EnMinifrog_SetJumpState(this); switch (globalCtx->msgCtx.unk11F04) { @@ -288,7 +288,7 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { default: func_801477B4(globalCtx); EnMinifrog_SetCamera(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_NPC_FADEAWAY); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_NPC_FADEAWAY); if (this->actor.cutscene != -1) { if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { ActorCutscene_Stop(this->actor.cutscene); @@ -329,12 +329,12 @@ void EnMinifrog_Idle(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); EnMinifrog_JumpTimer(this); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnMinifrog_ReturnFrogCutscene; if (this->actor.cutscene != -1) { this->flags |= 1; } - } else if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (Player_GetMask(globalCtx) == PLAYER_MASK_DON_GERO)) { func_800B8614(&this->actor, globalCtx, 110.0f); } @@ -473,11 +473,11 @@ void EnMinifrog_BeginChoirCutscene(EnMinifrog* this, GlobalContext* globalCtx) { void EnMinifrog_EndChoir(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, 0xD7E, &this->actor); // "Let us do it again sometime." this->actionFunc = EnMinifrog_YellowFrogDialog; } else { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } } @@ -488,16 +488,16 @@ void EnMinifrog_GetFrogHP(EnMinifrog* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = EnMinifrog_EndChoir; this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, 0); + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_NONE); } else { - func_800B8A1C(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); } } void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 4: if (func_80147624(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { @@ -565,7 +565,7 @@ void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); EnMinifrog_JumpTimer(this); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnMinifrog_YellowFrogDialog; if (!(gSaveContext.weekEventReg[34] & 1)) { // Not spoken with MINIFROG_YELLOW func_801518B0(globalCtx, 0xD76, @@ -575,8 +575,7 @@ void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx func_801518B0(globalCtx, 0xD7F, &this->actor); // "Well, if it isn't the great Don Gero." } } else if ((this->actor.xzDistToPlayer < 150.0f) && - (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) || - ((this->actor.flags & 0x10000) == 0x10000)) && + (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) || ((this->actor.flags & 0x10000) == 0x10000)) && Player_GetMask(globalCtx) == PLAYER_MASK_DON_GERO) { func_800B8614(&this->actor, globalCtx, 160.0f); } @@ -587,7 +586,7 @@ void EnMinifrog_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 12.0f, 0.0f, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index 831e6a4b91..b2b8dd5ba7 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -202,7 +202,7 @@ void EnMinislime_AddIceShardEffect(EnMinislime* this) { } this->frozenAlpha = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ICE_BROKEN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); } void EnMinislime_AddIceSmokeEffect(EnMinislime* this, GlobalContext* globalCtx) { @@ -215,7 +215,7 @@ void EnMinislime_AddIceSmokeEffect(EnMinislime* this, GlobalContext* globalCtx) vel.x = randPlusMinusPoint5Scaled(1.5f); vel.z = randPlusMinusPoint5Scaled(1.5f); vel.y = 2.0f; - EffectSsIceSmoke_Spawn(globalCtx, &pos, &vel, &D_801D15B0, 500); + EffectSsIceSmoke_Spawn(globalCtx, &pos, &vel, &gZeroVec3f, 500); } void EnMinislime_SetupDisappear(EnMinislime* this) { @@ -391,7 +391,7 @@ void EnMinislime_SetupGrowAndShrink(EnMinislime* this) { this->actor.scale.x = 0.19f; this->actor.scale.y = 0.044999998f; this->actor.scale.z = 0.19f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SLIME_JUMP2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SLIME_JUMP2); this->actionFunc = EnMinislime_GrowAndShrink; } @@ -453,7 +453,7 @@ void EnMinislime_Idle(EnMinislime* this, GlobalContext* globalCtx) { void EnMinislime_SetupBounce(EnMinislime* this) { this->actor.speedXZ = 0.0f; this->bounceTimer = (this->actionFunc == EnMinislime_GrowAndShrink) ? 1 : 4; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SLIME_JUMP1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SLIME_JUMP1); this->actionFunc = EnMinislime_Bounce; } @@ -736,9 +736,9 @@ void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->actionFunc != EnMinislime_Disappear) && (this->actionFunc != EnMinislime_Despawn)) { if (this->actionFunc == EnMinislime_MoveToBigslime) { - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); } else { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } EnMinislime_CheckBackgroundCollision(this); diff --git a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c index 1bedf7901f..019e7a848f 100644 --- a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c +++ b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c @@ -85,7 +85,7 @@ static DamageTable D_80A4F754 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_80A4F774[] = { ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), - ICHAIN_F32(minVelocityY, -5, ICHAIN_CONTINUE), + ICHAIN_F32(terminalVelocity, -5, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3000, ICHAIN_STOP), }; diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.c b/src/overlays/actors/ovl_En_Mm/z_en_mm.c index 00bf38f8ab..58de48dbd7 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -79,7 +79,7 @@ void EnMm_Init(Actor* thisx, GlobalContext* globalCtx) { return; } Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 50.0f, func_800B3FC0, 1.2f); + ActorShape_Init(&this->actor.shape, 50.0f, ActorShadow_DrawCircle, 1.2f); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); if (this->actor.parent != NULL) { @@ -123,7 +123,7 @@ void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { func_80965BBC(this); - Audio_PlayActorSound2(&this->actor, NA_SE_PL_PULL_UP_ROCK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PULL_UP_ROCK); } else { if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & 0x10)) { this->actor.velocity.y = 0.0f; @@ -134,7 +134,7 @@ void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { this->actor.world.rot.y += BINANG_SUB(0x8000, (s16)(angle * 2)); this->actor.speedXZ *= 0.5f; CollisionCheck_SpawnShieldParticles(globalCtx, &this->actor.world.pos); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HUMAN_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); } if (!(this->actor.bgCheckFlags & 1)) { @@ -168,13 +168,13 @@ void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { this->actor.bgCheckFlags &= ~1; } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HUMAN_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); } else { - func_800B8A1C(&this->actor, globalCtx, GI_NONE, 50.0f, 30.0f); + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 50.0f, 30.0f); } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } Collider_UpdateCylinder(&this->actor, &this->collider); @@ -200,7 +200,7 @@ void EnMm_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_ResetCylinderAC(globalCtx, &this->collider.base); this->actionFunc(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 10.0f, 20.0f, 31); - Actor_SetHeight(&this->actor, 20.0f); + Actor_SetFocus(&this->actor, 20.0f); } void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c index 69823ad0e1..94507b0014 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c @@ -15,10 +15,9 @@ void EnMm2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMm2_Update(Actor* thisx, GlobalContext* globalCtx); void EnMm2_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809A2080(EnMm2* this, GlobalContext* globalCtx); -void func_809A20FC(EnMm2* this, GlobalContext* globalCtx); +void EnMm2_Reading(EnMm2* this, GlobalContext* globalCtx); +void EnMm2_WaitForRead(EnMm2* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Mm2_InitVars = { ACTOR_EN_MM2, ACTORCAT_ITEMACTION, @@ -31,16 +30,59 @@ const ActorInit En_Mm2_InitVars = { (ActorFunc)EnMm2_Draw, }; -#endif +#include "overlays/ovl_En_Mm2/ovl_En_Mm2.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm2/EnMm2_Init.s") +void EnMm2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMm2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm2/EnMm2_Destroy.s") + Actor_SetScale(&this->actor, 0.015f); + this->actionFunc = EnMm2_WaitForRead; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm2/func_809A2080.s") +void EnMm2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm2/func_809A20FC.s") +/** + * Action function whilst Link is reading the letter. + */ +void EnMm2_Reading(EnMm2* this, GlobalContext* globalCtx) { + u8 talkState = Message_GetState(&globalCtx->msgCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm2/EnMm2_Update.s") + if (talkState != 2) { + if (talkState == 5 && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = EnMm2_WaitForRead; + } + } else { + this->actionFunc = EnMm2_WaitForRead; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm2/EnMm2_Draw.s") +/** + * Action function that awaits Link to read the letter, changing the A button to "Check" when he is within range to do + * so (and facing the letter). + */ +void EnMm2_WaitForRead(EnMm2* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_801518B0(globalCtx, 0x277B, &this->actor); + this->actionFunc = EnMm2_Reading; + } else if ((this->actor.xzDistToPlayer < 60.0f) && (Player_IsFacingActor(&this->actor, 0x3000, globalCtx))) { + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} + +void EnMm2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMm2* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void EnMm2_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sEnMm2DL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/src/overlays/actors/ovl_En_Ms/z_en_ms.c index efc0ea175b..77b3d70dda 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -66,7 +66,7 @@ void EnMs_Init(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06003DC0, &D_060005EC, this->jointTable, this->morphTable, 9); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 35.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); Actor_SetScale(&this->actor, 0.015f); this->actor.colChkInfo.mass = MASS_IMMOVABLE; // Eating Magic Beans all day will do that to you this->actionFunc = EnMs_Wait; @@ -90,7 +90,7 @@ void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { this->actor.textId = 0x932; // "[...] So you liked my Magic Beans [...]" } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnMs_Talk; } else if ((this->actor.xzDistToPlayer < 90.0f) && (ABS_ALT(yawDiff) < 0x2000)) { func_800B8614(&this->actor, globalCtx, 90.0f); @@ -98,7 +98,7 @@ void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { } void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 6: if (func_80147624(globalCtx) != 0) { this->actionFunc = EnMs_Wait; @@ -108,8 +108,8 @@ void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { case 5: if (func_80147624(globalCtx) != 0) { func_801477B4(globalCtx); - func_800B8A1C(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, - this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, + this->actor.playerHeightRel); this->actionFunc = EnMs_Sell; } break; @@ -127,7 +127,7 @@ void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { func_80151938(globalCtx, 0x937); // "[...] You can't carry anymore." } else { func_8019F208(); - func_800B8A1C(&this->actor, globalCtx, GI_MAGIC_BEANS, 90.0f, 10.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, 90.0f, 10.0f); func_801159EC(-10); this->actionFunc = EnMs_Sell; } @@ -152,12 +152,12 @@ void EnMs_Sell(EnMs* this, GlobalContext* globalCtx) { func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); this->actionFunc = EnMs_TalkAfterPurchase; } else { - func_800B8A1C(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } void EnMs_TalkAfterPurchase(EnMs* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80151938(globalCtx, 0x936); // "You can plant 'em whenever you want [...]" this->actionFunc = EnMs_Talk; } else { @@ -169,7 +169,7 @@ void EnMs_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnMs* this = THIS; - Actor_SetHeight(&this->actor, 20.0f); + Actor_SetFocus(&this->actor, 20.0f); this->actor.targetArrowOffset = 500.0f; Actor_SetScale(&this->actor, 0.015f); SkelAnime_Update(&this->skelAnime); diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index b2792ec129..ab94425ea8 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -138,7 +138,7 @@ s32 func_80A68860(EnMushi2* this, GlobalContext* globalCtx) { } s32 func_80A68910(EnMushi2* this, GlobalContext* globalCtx) { - Actor* bean = globalCtx->actorCtx.actorList[ACTORCAT_ITEMACTION].first; + Actor* bean = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; f32 minDistSq = SQ(100.0f); s32 ret = false; f32 temp_f0; @@ -206,7 +206,7 @@ void func_80A68BC8(EnMushi2* this) { if (this->unk_36C > 0) { this->unk_36C--; } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MUSI_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MUSI_WALK); this->unk_36C = 3.0f / CLAMP_MIN(this->skelAnime.playSpeed, 0.12f); if (this->unk_36C < 2) { @@ -219,7 +219,7 @@ s32 func_80A68C5C(Vec3f* arg0, Vec3f* arg1) { f32 temp_f0 = Math3D_Vec3fMagnitude(arg0); if (temp_f0 < 0.005f) { - Math_Vec3f_Copy(arg0, &D_801D15B0); + Math_Vec3f_Copy(arg0, &gZeroVec3f); return false; } else { arg1->x = arg0->x * (1.0f / temp_f0); @@ -280,7 +280,7 @@ void func_80A68ED8(EnMushi2* this) { this->actor.velocity.x = this->actor.speedXZ * this->unk_328.x; this->actor.velocity.y = this->actor.speedXZ * this->unk_328.y; this->actor.velocity.z = this->actor.speedXZ * this->unk_328.z; - Actor_ApplyMovement(&this->actor); + Actor_UpdatePos(&this->actor); } void func_80A68F24(EnMushi2* this) { @@ -789,7 +789,7 @@ void EnMushi2_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80A6A300(EnMushi2* this) { this->unk_368 = 100; this->actor.gravity = -0.25f; - this->actor.minVelocityY = -3.5f; + this->actor.terminalVelocity = -3.5f; this->unk_370 = Rand_S16Offset(-1000, 2000); this->skelAnime.playSpeed = 1.5f; this->actionFunc = func_80A6A36C; @@ -801,7 +801,7 @@ void func_80A6A36C(EnMushi2* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); this->actor.velocity.y -= this->actor.velocity.y * D_80A6BA14[ENMUSHI2_GET_3(&this->actor)]; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80A69424(this, globalCtx); this->actor.shape.rot.y += this->unk_370; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -822,7 +822,7 @@ void func_80A6A36C(EnMushi2* this, GlobalContext* globalCtx) { } else if (this->actor.bgCheckFlags & 0x20) { func_80A6AAA4(this); } else if (this->actor.bgCheckFlags & 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_WALK); func_80A68F24(this); func_80A691EC(this, this->actor.floorPoly, -1.0f); func_80A69388(this); @@ -949,7 +949,7 @@ void func_80A6A9E4(EnMushi2* this, GlobalContext* globalCtx) { void func_80A6AAA4(EnMushi2* this) { this->actor.velocity.y = -1.2f; - this->actor.minVelocityY = -1.2f; + this->actor.terminalVelocity = -1.2f; this->actor.gravity = -0.5f; this->unk_368 = Rand_S16Offset(120, 50); this->unk_36E = 0; @@ -967,7 +967,7 @@ void func_80A6AB08(EnMushi2* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.02f); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80A69424(this, globalCtx); Math_StepToF(&this->actor.world.pos.y, this->actor.world.pos.y + this->actor.depthInWater, 2.8f); this->skelAnime.playSpeed = this->unk_368 * 0.018f; @@ -1013,7 +1013,7 @@ void func_80A6AE14(EnMushi2* this) { this->unk_30C &= ~1; this->unk_368 = 100; this->actor.velocity.y = 0.0f; - this->actor.minVelocityY = -0.8f; + this->actor.terminalVelocity = -0.8f; this->actor.gravity = -0.04f; func_80A68B6C(this); this->actionFunc = func_80A6AE7C; @@ -1029,7 +1029,7 @@ void func_80A6AE7C(EnMushi2* this, GlobalContext* globalCtx) { this->actor.world.rot.y += (s16)((Rand_ZeroOne() - 0.5f) * 2000.0f); this->actor.gravity = -0.04f - (Rand_ZeroOne() * 0.02f); this->actor.velocity.y *= 0.95f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80A69424(this, globalCtx); temp_f2 = this->actor.scale.x - (1.0f / 20000.0f); Actor_SetScale(&this->actor, CLAMP_MIN(temp_f2, 0.001f)); @@ -1048,7 +1048,7 @@ void func_80A6B078(EnMushi2* this) { this->unk_30C &= ~1; this->unk_368 = 50; this->skelAnime.playSpeed = 1.9f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTURA_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); func_80A68B6C(this); this->actionFunc = func_80A6B0D8; } @@ -1095,7 +1095,7 @@ void func_80A6B0D8(EnMushi2* this, GlobalContext* globalCtx) { sp48.x = (this->unk_328.x * -0.6f) + (this->unk_31C.x * 0.1f); sp48.y = (this->unk_328.y * -0.6f) + (this->unk_31C.y * 0.1f); sp48.z = (this->unk_328.z * -0.6f) + (this->unk_31C.z * 0.1f); - func_800B0E48(globalCtx, &this->actor.world.pos, &sp48, &D_801D15B0, &D_80A6B984[sp44], &D_80A6B98C[sp44], + func_800B0E48(globalCtx, &this->actor.world.pos, &sp48, &gZeroVec3f, &D_80A6B984[sp44], &D_80A6B98C[sp44], (Rand_ZeroOne() * 5.0f) + 8.0f, (Rand_ZeroOne() * 5.0f) + 8.0f); } @@ -1224,7 +1224,7 @@ void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((this->unk_30C & 1) && func_80A68DD4(this, globalCtx)) { - func_800B8A1C(&this->actor, globalCtx, GI_MAX, 60.0f, 30.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 60.0f, 30.0f); } } } diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.c b/src/overlays/actors/ovl_En_Muto/z_en_muto.c index 131fbebcc3..00c3ed0c98 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -64,7 +64,7 @@ void EnMuto_Init(Actor* thisx, GlobalContext* globalCtx) { EnMuto* this = THIS; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 40.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06007150, &D_06000E50, this->jointTable, this->morphTable, 17); this->isInMayorsRoom = this->actor.params; @@ -148,7 +148,7 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { this->actor.textId = 0x2363; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { EnMuto_SetupDialogue(this, globalCtx); return; } @@ -186,7 +186,7 @@ void EnMuto_SetupDialogue(EnMuto* this, GlobalContext* globalCtx) { if (this->targetActor != NULL) { this->shouldSetHeadRotation = true; this->cutsceneState = 1; - func_800B86C8(this->targetActor, globalCtx, this->targetActor); + Actor_ChangeFocus(this->targetActor, globalCtx, this->targetActor); } this->isInDialogue = true; @@ -196,7 +196,7 @@ void EnMuto_SetupDialogue(EnMuto* this, GlobalContext* globalCtx) { void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { if (!this->isInMayorsRoom) { this->yawTowardsTarget = this->actor.yawTowardsPlayer; - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { func_801477B4(globalCtx); if (this->actor.textId == 0x62C) { @@ -263,8 +263,8 @@ void EnMuto_Update(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetScale(&this->actor, 0.01f); this->actor.shape.rot.y = this->actor.world.rot.y; - Actor_SetHeight(&this->actor, 60.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_SetFocus(&this->actor, 60.0f); + Actor_MoveWithGravity(&this->actor); Math_SmoothStepToS(&this->headRot.y, this->headRotTarget.y, 1, 0xBB8, 0); Math_SmoothStepToS(&this->headRot.x, this->headRotTarget.x, 1, 0x3E8, 0); diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index c65d794bb6..41730f4d44 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -124,7 +124,7 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags |= 0x1; // targetable ON - ActorShape_Init(&thisx->shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 25.0f); SkelAnime_InitFlex(globalCtx, &this->skelanime, &D_06002530, &D_060000E8, this->jointTable, this->morphTable, ENNIW_LIMBCOUNT); @@ -147,7 +147,7 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->niwType == ENNIW_TYPE_UNK2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unkTimer250 = 30; this->actor.flags &= ~0x1; // targetable OFF @@ -342,7 +342,7 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { if (this->niwType == ENNIW_TYPE_REGULAR) { if (Actor_HasParent(&this->actor, globalCtx)) { // picked up - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unkTimer250 = 30; this->actor.flags &= ~0x1; // targetable OFF @@ -351,7 +351,7 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { this->actionFunc = EnNiw_Held; return; } else { - func_800B8BB0(&this->actor, globalCtx); + Actor_LiftActor(&this->actor, globalCtx); } } else { this->unkTimer252 = 10; @@ -493,7 +493,7 @@ void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { // picked up again before could run off - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unk2EC = 0; this->unkTimer250 = 30; @@ -503,7 +503,7 @@ void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; } else { if (this->unkTimer252 > 5) { - func_800B8BB0(&this->actor, globalCtx); + Actor_LiftActor(&this->actor, globalCtx); } func_80891320(this, globalCtx, 2); } @@ -603,7 +603,7 @@ void EnNiw_SetupCuccoStorm(EnNiw* this, GlobalContext* globalCtx) { this->unk264[1] = 0.0f; this->unk264[2] = 0.0f; this->unkTimer24C = 10; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow } if (this->unkTimer252 == 0) { this->unkTimer252 = 10; @@ -685,7 +685,7 @@ void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx) { this->unkTimer260 = 10; this->sfxTimer1 = 30; this->unk29E = 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->unkTimer254 = 100; this->unk2EC = 0; EnNiw_SetupRunAway(this); @@ -722,7 +722,7 @@ void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx) { this->unkTimer260 = 10; this->sfxTimer1 = 30; this->unk29E = 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->unkTimer254 = 100; this->unk2EC = 0; EnNiw_SetupRunAway(this); @@ -805,8 +805,8 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.rot = this->actor.world.rot; this->actor.shape.shadowScale = 15.0f; this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, this->unk308); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_SetFocus(&this->actor, this->unk308); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1F); @@ -878,16 +878,16 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { EnNiw_CheckRage(this, globalCtx); if ((this->flutterSfxTimer == 0) && (this->unknownState28E == 4)) { this->flutterSfxTimer = 7; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); } if (this->sfxTimer1 == 0) { if (this->unknownState28E != 0) { this->sfxTimer1 = 30; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_A); // attack cluck + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); // attack cluck } else { this->sfxTimer1 = 300; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_N); // cluck + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_N); // cluck } } diff --git a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c index dc93bf7cdb..d106901045 100644 --- a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c +++ b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c @@ -77,7 +77,7 @@ void func_80C08828(EnNnh* this) { } void func_80C0883C(EnNnh* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, 0x228U, &this->actor); func_80C088A4(this); return; @@ -90,7 +90,7 @@ void func_80C088A4(EnNnh* this) { } void func_80C088B8(EnNnh* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { func_80C08828(this); } } diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c index 10f9a1783e..c99daf298b 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -53,7 +53,7 @@ static ColliderCylinderInit sCylinderInit = { void EnNutsball_Init(Actor* thisx, GlobalContext* globalCtx) { EnNutsball* this = THIS; - ActorShape_Init(&this->actor.shape, 400.0f, (ActorShadowFunc)func_800B3FC0, 13.0f); + ActorShape_Init(&this->actor.shape, 400.0f, ActorShadow_DrawCircle, 13.0f); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.shape.rot.y = 0; this->actor.speedXZ = 10.0f; @@ -121,9 +121,9 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx) { spawnBurstPos.z = this->actor.world.pos.z; EffectSsHahen_SpawnBurst(globalCtx, &spawnBurstPos, 6.0f, 0, 7, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); if (this->actor.params == 1) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_NUTS_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_NUTS_BROKEN); } else { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EN_OCTAROCK_ROCK); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EN_OCTAROCK_ROCK); } Actor_MarkForDeath(&this->actor); } @@ -133,7 +133,7 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); Math_Vec3f_Copy(&worldPos, &this->actor.world.pos); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 5.0f, 10.0f, 0x7); diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index be2c4b5706..9a1a076402 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -256,7 +256,7 @@ void EnOssan_UpdateCursorPos(GlobalContext* globalCtx, EnOssan* this) { s16 x; s16 y; - func_800B8898(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); this->cursorPos.x = x; this->cursorPos.y = y; } @@ -264,7 +264,7 @@ void EnOssan_UpdateCursorPos(GlobalContext* globalCtx, EnOssan* this) { void EnOssan_EndInteraction(GlobalContext* globalCtx, EnOssan* this) { Player* player = GET_PLAYER(globalCtx); - func_800B84D0(&this->actor, globalCtx); + Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; Interface_ChangeAlpha(50); @@ -330,7 +330,7 @@ void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); func_8013D9C8(globalCtx, this->limbRotTableY, this->limbRotTableZ, 19); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->stateFlags2 |= 0x20000000; EnOssan_SetupAction(this, EnOssan_BeginInteraction); if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { @@ -523,7 +523,7 @@ u8 EnOssan_CursorLeft(EnOssan* this, u8 cursorIdx, u8 shelfSlotMax) { void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { ActorAnimationEntryS* animations = sAnimations[this->actor.params]; - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; Player* player = GET_PLAYER(globalCtx); @@ -551,7 +551,7 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { func_8013BC6C(&this->skelAnime, animations, 9); } if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } } @@ -581,7 +581,7 @@ s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, GlobalContext* globalCtx } void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; Player* player = GET_PLAYER(globalCtx); u8 cursorIdx; @@ -630,7 +630,7 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_TalkToShopkeeper(EnOssan* this, GlobalContext* globalCtx) { ActorAnimationEntryS* animations = sAnimations[this->actor.params]; - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { if (this->animationIdx == 9 && this->actor.params == ENOSSAN_PART_TIME_WORKER) { this->animationIdx = 1; func_8013BC6C(&this->skelAnime, animations, 1); @@ -804,7 +804,7 @@ s32 EnOssan_HasPlayerSelectedItem(GlobalContext* globalCtx, EnOssan* this, Input } void EnOssan_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; u8 prevCursorIndex = this->cursorIdx; u8 cursorIdx; @@ -862,7 +862,7 @@ void EnOssan_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; u8 prevCursorIndex = this->cursorIdx; u8 cursorIdx; @@ -946,7 +946,7 @@ void EnOssan_LookToShopkeeperFromShelf(EnOssan* this, GlobalContext* globalCtx) void EnOssan_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnOssan* this) { Player* player = GET_PLAYER(globalCtx); - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; player->stateFlags2 &= ~0x20000000; @@ -1014,7 +1014,7 @@ void EnOssan_HandleCanBuyItem(GlobalContext* globalCtx, EnOssan* this) { } void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (EnOssan_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); @@ -1034,7 +1034,7 @@ void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_CannotBuy(EnOssan* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } @@ -1043,7 +1043,7 @@ void EnOssan_CannotBuy(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_CanBuy(EnOssan* this, GlobalContext* globalCtx) { EnGirlA* item; - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1058,12 +1058,12 @@ void EnOssan_BuyItemWithFanfare(EnOssan* this, GlobalContext* globalCtx) { this->actor.parent = NULL; EnOssan_SetupAction(this, EnOssan_SetupItemPurchased); } else { - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); } } void EnOssan_SetupItemPurchased(EnOssan* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; EnOssan_SetupAction(this, EnOssan_ItemPurchased); @@ -1074,12 +1074,12 @@ void EnOssan_SetupItemPurchased(EnOssan* this, GlobalContext* globalCtx) { this->cutscene = this->lookToShopkeeperCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); } - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); } } void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); EnGirlA* item; @@ -1097,7 +1097,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { player->stateFlags2 |= 0x20000000; func_801518B0(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, true); - func_800B85E0(&this->actor, globalCtx, 100.0f, -1); + func_800B85E0(&this->actor, globalCtx, 100.0f, EXCH_ITEM_MINUS1); break; case 1: default: @@ -1115,7 +1115,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { player->stateFlags2 |= 0x20000000; func_801518B0(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, true); - func_800B85E0(&this->actor, globalCtx, 100.0f, -1); + func_800B85E0(&this->actor, globalCtx, 100.0f, EXCH_ITEM_MINUS1); } } @@ -1136,10 +1136,10 @@ void EnOssan_ItemPurchased(EnOssan* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80151938(globalCtx, 0x642); } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); } } @@ -1429,9 +1429,9 @@ void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { this->actor.flags &= ~0x10; this->actor.objBankIndex = this->objIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); shopItems = sShops[this->actor.params]; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); sInitFuncs[this->actor.params](this, globalCtx); this->textId = sWelcomeHumanTextIds[this->actor.params]; EnOssan_GetCutscenes(this, globalCtx); @@ -1518,7 +1518,7 @@ void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx) { EnOssan_UpdateCursorAnim(this); func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk2CC, this->actor.focus.pos); this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, 90.0f); + Actor_SetFocus(&this->actor, 90.0f); SkelAnime_Update(&this->skelAnime); } else { this->actionFunc(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index 65fd93e867..24acaa6a1b 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -155,7 +155,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004800, &D_060008D8, this->jointTable, this->morphTable, 19); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); Animation_Change(&this->skelAnime, sAnimations[0].animationSeg, 1.0f, @@ -338,7 +338,7 @@ void func_80B5BED4(EnOt* this, GlobalContext* globalCtx) { 0x38E); this->actor.speedXZ = 3.5f; this->actor.world.pos.y = this->unk_360->actor.world.pos.y; - Actor_SetVelocityAndMoveXYRotationReverse(&this->actor); + Actor_MoveWithoutGravityReverse(&this->actor); } void func_80B5BF60(EnOt* this, GlobalContext* globalCtx) { @@ -377,7 +377,7 @@ void func_80B5BFB8(EnOt* this, GlobalContext* globalCtx) { func_80B5C684(this->unk_360, globalCtx); func_80B5C684(this, globalCtx); } else { - Actor_SetVelocityAndMoveXYRotationReverse(&this->actor); + Actor_MoveWithoutGravityReverse(&this->actor); } } @@ -388,7 +388,7 @@ void func_80B5C154(EnOt* this, GlobalContext* globalCtx) { this->unk_38C = GI_HEART_PIECE; gSaveContext.weekEventReg[32] |= 1; } - func_800B8A1C(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_80B5C1CC; } @@ -398,7 +398,7 @@ void func_80B5C1CC(EnOt* this, GlobalContext* globalCtx) { func_80B5C244(this, globalCtx); func_80B5C244(this->unk_360, globalCtx); } else { - func_800B8A1C(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } @@ -536,7 +536,7 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { if ((gSaveContext.weekEventReg[84] & 0x10) && (this->unk_33C == 1)) { this->actor.textId = 0; this->unk_384 = 1; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3A0 = BINANG_ADD(sp3E, 0x4000); this->unk_360->unk_3A0 = this->unk_3A0; func_80B5C9A8(this, globalCtx); @@ -561,7 +561,7 @@ void func_80B5C910(EnOt* this, GlobalContext* globalCtx) { void func_80B5C950(EnOt* this, GlobalContext* globalCtx) { if (this->unk_32C & 8) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); gSaveContext.weekEventReg[25] |= 4; func_80B5CAD0(this, globalCtx); } @@ -582,7 +582,7 @@ void func_80B5C9D0(EnOt* this, GlobalContext* globalCtx) { this->actor.world.rot.x = this->actor.world.rot.x; this->actor.world.rot.y = this->actor.world.rot.y; this->actor.world.rot.z = this->actor.world.rot.z; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); this->actionFunc = func_80B5CA30; } @@ -617,7 +617,7 @@ void func_80B5CBA0(EnOt* this, GlobalContext* globalCtx) { } void func_80B5CBEC(EnOt* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; func_80B5CC88(this, globalCtx); } else { @@ -649,7 +649,7 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 temp; - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: temp = Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), 3, 0xE38, 0x38E); @@ -691,7 +691,7 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { s32 pad; this->actor.textId = 0; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80B5D114(this, globalCtx); return; } @@ -745,7 +745,7 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { u16 phi_a1; s32 temp; - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: temp = Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); this->actor.world.rot.y = this->actor.shape.rot.y; @@ -900,7 +900,7 @@ void func_80B5D648(EnOt* this, GlobalContext* globalCtx) { func_8013E1C8(&this->skelAnime, sAnimations, 1, &this->animIdx); this->actor.flags |= 0x8000000; this->actor.flags &= ~(0x8 | 0x1); - Actor_SetSwitchFlag(globalCtx, ENOT_GET_3F80(&this->actor)); + Flags_SetSwitch(globalCtx, ENOT_GET_3F80(&this->actor)); this->actionFunc = func_80B5D750; } @@ -939,7 +939,7 @@ void EnOt_Update(Actor* thisx, GlobalContext* globalCtx) { EnOt* this = THIS; if ((this->animIdx == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SEAHORSE_SWIM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SEAHORSE_SWIM); } this->actionFunc(this, globalCtx); @@ -963,7 +963,7 @@ void EnOt_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.prevPos.y = this->actor.floorHeight + 50.0f; } - Actor_SetHeight(&this->actor, 12.0f); + Actor_SetFocus(&this->actor, 12.0f); SkelAnime_Update(&this->skelAnime); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); @@ -981,7 +981,7 @@ void func_80B5DAEC(Actor* thisx, GlobalContext* globalCtx) { EnOt* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, 12.0f); + Actor_SetFocus(&this->actor, 12.0f); SkelAnime_Update(&this->skelAnime); func_80B5BB38(&this->unk_747, &this->unk_744, 0.7f); if (this->unk_32C & 0x400) { diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index ab5e2520a1..5bf520f91b 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -138,14 +138,14 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 36.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime1, &D_0600C5F8, &D_06001ADC, this->jointTable1, this->morphTable1, 21); SkelAnime_InitFlex(globalCtx, &this->skelAnime2, &D_060105C0, &D_0600CDB0, this->jointTable2, this->morphTable2, 16); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.minVelocityY = -10.0f; + this->actor.terminalVelocity = -10.0f; this->actor.targetArrowOffset = 500.0f; EnOwl_ChangeMode(this, func_8095BF58, func_8095C484, &this->skelAnime2, &D_0600CDB0, 0.0f); @@ -233,27 +233,27 @@ void func_8095A920(EnOwl* this, GlobalContext* globalCtx) { } s32 func_8095A978(EnOwl* this, GlobalContext* globalCtx, u16 textId, f32 targetDist, f32 arg4) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { return true; } this->actor.textId = textId; if (this->actor.xzDistToPlayer < targetDist) { this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, targetDist, arg4, 0); + func_800B8500(&this->actor, globalCtx, targetDist, arg4, EXCH_ITEM_NONE); } return false; } s32 func_8095A9FC(EnOwl* this, GlobalContext* globalCtx, u16 textId) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { return true; } this->actor.textId = textId; if (this->actor.xzDistToPlayer < 120.0f) { - func_800B8500(&this->actor, globalCtx, 350.0f, 1000.0f, 0); + func_800B8500(&this->actor, globalCtx, 350.0f, 1000.0f, EXCH_ITEM_NONE); } return false; @@ -269,7 +269,7 @@ void func_8095AAD0(EnOwl* this, GlobalContext* globalCtx) { s32 switchFlag = ENOWL_GET_SWITCHFLAG(&this->actor); if (switchFlag < 0x7F) { - Actor_SetSwitchFlag(globalCtx, switchFlag); + Flags_SetSwitch(globalCtx, switchFlag); } func_8095AA70(this); @@ -302,7 +302,7 @@ void func_8095ABA8(EnOwl* this) { } void func_8095ABF0(EnOwl* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { Audio_QueueSeqCmd(0x110000FF); func_8095AAD0(this, globalCtx); this->actor.flags &= ~0x10000; @@ -311,7 +311,7 @@ void func_8095ABF0(EnOwl* this, GlobalContext* globalCtx) { // Unused? void func_8095AC50(EnOwl* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { Audio_QueueSeqCmd(0x110000FF); if ((this->unk_3DA % 64) == 0) { func_8095AAD0(this, globalCtx); @@ -335,7 +335,7 @@ void func_8095ACEC(EnOwl* this) { } void func_8095AD54(EnOwl* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case OWL_REPEAT: func_80151938(globalCtx, 0x7D1); @@ -351,14 +351,14 @@ void func_8095AD54(EnOwl* this, GlobalContext* globalCtx) { } void func_8095AE00(EnOwl* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_80151938(globalCtx, 0x7D2); this->actionFunc = func_8095AD54; } } void func_8095AE60(EnOwl* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_80151938(globalCtx, 0x7D1); this->actionFunc = func_8095AE00; } @@ -373,7 +373,7 @@ void func_8095AEC0(EnOwl* this, GlobalContext* globalCtx) { } void func_8095AF2C(EnOwl* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 5: if (func_80147624(globalCtx)) { if (globalCtx->msgCtx.unk11F04 == 0xBFE) { @@ -430,7 +430,7 @@ void func_8095B158(EnOwl* this) { if (Animation_OnFrame(&this->skelAnime1, 2.0f) || Animation_OnFrame(&this->skelAnime1, 9.0f) || Animation_OnFrame(&this->skelAnime1, 23.0f) || Animation_OnFrame(&this->skelAnime1, 40.0f) || Animation_OnFrame(&this->skelAnime1, 58.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OWL_FLUTTER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OWL_FLUTTER); } } @@ -509,14 +509,14 @@ void func_8095B480(EnOwl* this, GlobalContext* globalCtx) { void func_8095B574(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_8095BA84; func_801A3098(NA_BGM_OWL); this->actionFlags |= 0x40; this->unk_406 = 2; } else if (this->actor.xzDistToPlayer < 200.0f) { this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, 200.0f, 400.0f, 0); + func_800B8500(&this->actor, globalCtx, 200.0f, 400.0f, EXCH_ITEM_NONE); } else { this->actor.flags &= ~0x10000; } @@ -615,7 +615,7 @@ void func_8095B9FC(EnOwl* this, GlobalContext* globalCtx) { void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 4: if (func_80147624(globalCtx)) { switch (globalCtx->msgCtx.unk11F04) { @@ -719,18 +719,18 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { void func_8095BE0C(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_8095BA84; func_801A3098(NA_BGM_OWL); this->unk_406 = 1; this->actionFlags |= 0x40; } else if (this->actor.textId == 0xBF0) { if (this->actor.isTargeted) { - func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, 0); + func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, EXCH_ITEM_NONE); } } else if (this->actor.xzDistToPlayer < 200.0f) { this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, 0); + func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, EXCH_ITEM_NONE); } else { this->actor.flags &= ~0x10000; } @@ -891,7 +891,7 @@ void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx) { s16 sp36; if (this->actor.draw != NULL) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } if (this->unk_414 != NULL) { @@ -905,7 +905,7 @@ void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); if (this->actor.update != NULL) { if ((this->skelAnime1.animation == &D_06001ADC) && Animation_OnFrame(&this->skelAnime1, 4.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OWL_FLUTTER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OWL_FLUTTER); } if (this->actionFlags & 2) { diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 14ad82b2d7..525606bc38 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -151,7 +151,7 @@ void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { EnPamera* this = THIS; Vec3f sp44; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 15.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 15.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06008448, &D_060005BC, this->jointTable, this->morphTable, PAMERA_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); @@ -196,7 +196,7 @@ void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80BD84F0(EnPamera* this, GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_DOOR].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; while (actor != NULL) { if ((actor->id == ACTOR_EN_DOOR) && (Math_Vec3f_DistXZ(&this->actor.world.pos, &actor->world.pos) < 200.0f)) { @@ -249,7 +249,7 @@ void EnPamera_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80BD8700(EnPamera* this) { this->hideInisdeTimer = 0; this->actor.flags &= ~1; - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BD8758; } @@ -259,7 +259,7 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[0], &this->actor); func_800E02AC(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[0])), &this->actor); this->actor.speedXZ = 1.5f; - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; func_80BD9338(this, globalCtx); @@ -268,7 +268,7 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscenes[0]); } else { this->actor.speedXZ = 1.5f; - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; func_80BD9338(this, globalCtx); @@ -290,7 +290,7 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { void func_80BD8908(EnPamera* this) { this->actor.draw = EnPamera_Draw; this->actor.flags |= 1; - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BD8964; } @@ -303,14 +303,14 @@ void func_80BD8964(EnPamera* this, GlobalContext* globalCtx) { if (Math_Vec3f_StepTo(&this->actor.world.pos, &vec, 1.0f) < 5.0f) { this->actor.speedXZ = 1.5f; - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); gSaveContext.weekEventReg[59] |= 1; func_80BD8B50(this); } } void func_80BD8A38(EnPamera* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BD8A7C; } @@ -357,14 +357,14 @@ void func_80BD8B70(EnPamera* this, GlobalContext* globalCtx) { void func_80BD8CCC(EnPamera* this) { this->hideInisdeTimer = 0; this->actor.speedXZ = 0.0f; - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); this->actionFunc = func_80BD8D1C; } void func_80BD8D1C(EnPamera* this, GlobalContext* globalCtx) { if (this->hideInisdeTimer++ > 200) { this->actor.speedXZ = 1.5f; - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); func_80BD8D80(this); } } @@ -400,14 +400,14 @@ void func_80BD8DB0(EnPamera* this, GlobalContext* globalCtx) { void EnPamera_LookDownWell(EnPamera* this) { func_80BD93CC(this, 1, 1); - func_800BDC5C(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); this->actionFunc = func_80BD8F60; } void func_80BD8F60(EnPamera* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x3000, 0x1000); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); this->actor.speedXZ = 3.0f; func_80BD93CC(this, 0, 0); func_80BD8D80(this); @@ -424,7 +424,7 @@ void func_80BD8FF0(EnPamera* this) { pameraYaw = Math_Vec3f_Yaw(&pameraPos, &this->actor.world.pos); this->actor.shape.rot.y = pameraYaw; this->actor.world.rot.y = pameraYaw; - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); this->actionFunc = func_80BD909C; } @@ -454,7 +454,7 @@ void func_80BD90AC(EnPamera* this, GlobalContext* globalCtx) { } s32 func_80BD9234(EnPamera* this, GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (actor != NULL) { if ((actor->id == ACTOR_EN_BOM) && (Math_Vec3f_DistXZ(&this->actor.world.pos, &actor->world.pos) < 500.0f) && @@ -512,11 +512,11 @@ void func_80BD93F4(EnPamera* this, GlobalContext* globalCtx) { (this->actionFunc == func_80BD8964) || (this->actionFunc == func_80BD8A7C)) { if (this->skelAnime.animation == &D_06008AE0) { if (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } } else if ((this->skelAnime.animation == &D_06008E38) && (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } } } @@ -609,7 +609,7 @@ void func_80BD9938(EnPamera* this) { } void func_80BD994C(EnPamera* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { if (1) {} func_80BD93CC(this, 0, 1); @@ -642,7 +642,7 @@ void func_80BD9A9C(EnPamera* this) { } void EnPamera_HandleDialogue(EnPamera* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: case 1: case 2: @@ -760,7 +760,7 @@ void func_80BD9E78(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9E88(EnPamera* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); this->unk_31E = 0; this->setupFunc = func_80BD9ED0; } @@ -769,7 +769,7 @@ void func_80BD9ED0(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9EE0(EnPamera* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); func_80BD93CC(this, 1, 0); this->unk_31E = 1; this->setupFunc = func_80BD9F3C; @@ -781,19 +781,19 @@ void func_80BD9F3C(EnPamera* this, GlobalContext* globalCtx) { Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 14.0f) || Animation_OnFrame(&this->skelAnime, 18.0f) || Animation_OnFrame(&this->skelAnime, 22.0f) || Animation_OnFrame(&this->skelAnime, 25.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - func_800BDC5C(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); } } } void func_80BDA038(EnPamera* this) { func_80BD93CC(this, 0, 1); - func_800BDC5C(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); this->unk_31E = 0; this->setupFunc = func_80BDA090; } @@ -803,7 +803,7 @@ void func_80BDA090(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA0A0(EnPamera* this) { func_80BD93CC(this, 0, 1); - func_800BDC5C(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); this->unk_31E = 1; this->setupFunc = func_80BDA0FC; } @@ -813,7 +813,7 @@ void func_80BDA0FC(EnPamera* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - func_800BDC5C(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); } } } @@ -821,7 +821,7 @@ void func_80BDA0FC(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA170(EnPamera* this) { this->unk_31E = 1; func_80BD93CC(this, 0, 1); - func_800BDC5C(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); this->setupFunc = func_80BDA1C8; } @@ -829,12 +829,12 @@ void func_80BDA1C8(EnPamera* this, GlobalContext* globalCtx) { if (this->unk_31E == 1) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 14.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - func_800BDC5C(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); } } } @@ -842,7 +842,7 @@ void func_80BDA1C8(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA288(EnPamera* this) { this->unk_31E = 1; func_80BD93CC(this, 0, 0); - func_800BDC5C(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); this->setupFunc = func_80BDA2E0; } @@ -850,7 +850,7 @@ void func_80BDA2E0(EnPamera* this, GlobalContext* globalCtx) { if (this->unk_31E == 1) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; - func_800BDC5C(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); } } } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index 9d15d2df31..22f9693796 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -7,6 +7,7 @@ #include "z_en_pametfrog.h" #include "overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "objects/object_bigslime/object_bigslime.h" #define FLAGS 0x00000035 @@ -65,28 +66,6 @@ void EnPametfrog_SnapperSpawn(EnPametfrog* this, GlobalContext* globalCtx); void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, GlobalContext* globalCtx); void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, GlobalContext* globalCtx); -extern AnimationHeader D_06000994; // Begin Rear on Snapper -extern AnimationHeader D_06001B08; // Call Snapper -extern AnimationHeader D_06001E14; // Crawl on Wall -extern AnimationHeader D_06001F20; // Falling -extern AnimationHeader D_060030E4; // Get up from Back -extern AnimationHeader D_0600347C; // Jab Punch -extern AnimationHeader D_060039C4; // Jump on Ground -extern AnimationHeader D_06003F28; // Kick -extern AnimationHeader D_06004298; // Fall on Back -extern AnimationHeader D_06004680; // Idle -extern AnimationHeader D_06004894; // Jump on Snapper -extern AnimationHeader D_06004D50; // Continue Rear on Snapper -extern AnimationHeader D_060050B8; // Squeeze Body -extern AnimationHeader D_060052EC; // Land on Snapper -extern AnimationHeader D_06005694; // Wiggle -extern AnimationHeader D_06005D54; // Head Knockback -extern AnimationHeader D_060066B4; // Look Around -extern AnimationHeader D_060070C4; // Hook Punch -extern FlexSkeletonHeader D_0600DF98; -extern AnimationHeader D_0600F048; // Windup Punch -extern AnimationHeader D_0600F990; // Melee Ready Stance - const ActorInit En_Pametfrog_InitVars = { ACTOR_EN_PAMETFROG, ACTORCAT_BOSS, @@ -205,12 +184,13 @@ void EnPametfrog_Init(Actor* thisx, GlobalContext* globalCtx) { s32 i; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 55.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 55.0f); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInit); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600DF98, &D_0600F990, this->jointTable, this->morphTable, 24); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGekkoSkel, &gGekkoBoxingStanceAnim, this->jointTable, + this->morphTable, GEKKO_LIMB_MAX); Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colElement); this->params = CLAMP(this->actor.params, 1, 4); - if (Actor_GetRoomCleared(globalCtx, globalCtx->roomCtx.currRoom.num)) { + if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { Actor_MarkForDeath(&this->actor); if (!(gSaveContext.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & (u8)isFrogReturnedFlags[this->actor.params - 1])) { @@ -250,7 +230,7 @@ u8 EnPametfrog_Vec3fNormalize(Vec3f* vec) { } } -void EnPametfrog_ChangeColliderFreeze(EnPametfrog* this) { +void EnPametfrog_Freeze(EnPametfrog* this) { this->drawEffect = GEKKO_DRAW_EFFECT_FROZEN; this->collider.base.colType = COLTYPE_HIT3; this->collider.elements->info.elemType = ELEMTYPE_UNK0; @@ -259,14 +239,14 @@ void EnPametfrog_ChangeColliderFreeze(EnPametfrog* this) { this->unk_2C4 = 1.0f; } -void EnPametfrog_ChangeColliderThaw(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_Thaw(EnPametfrog* this, GlobalContext* globalCtx) { this->freezeTimer = 0; if (this->drawEffect == GEKKO_DRAW_EFFECT_FROZEN) { - this->drawEffect = GEKKO_DRAW_EFFECT_NONE; + this->drawEffect = GEKKO_DRAW_EFFECT_THAW; this->collider.base.colType = COLTYPE_HIT6; this->collider.elements->info.elemType = ELEMTYPE_UNK1; this->unk_2C4 = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->limbPos, 12, 2, 0.3f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); } } @@ -398,16 +378,16 @@ void EnPametfrog_PlaceSnapper(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_JumpOnGround(EnPametfrog* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_JUMP); } else if (Animation_OnFrame(&this->skelAnime, 11.0f)) { EnPametfrog_JumpWaterEffects(this, globalCtx); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WALK_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALK_WATER); } } void EnPametfrog_ApplyMagicArrowEffects(EnPametfrog* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_FIRE) { - this->drawEffect = GEKKO_DRAW_EFFECT_NONE; + this->drawEffect = GEKKO_DRAW_EFFECT_THAW; this->unk_2C4 = 3.0f; this->unk_2C8 = 0.75f; } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_LIGHT) { @@ -418,14 +398,14 @@ void EnPametfrog_ApplyMagicArrowEffects(EnPametfrog* this, GlobalContext* global 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); } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_ICE) { - EnPametfrog_ChangeColliderFreeze(this); + EnPametfrog_Freeze(this); } } void EnPametfrog_ApplyElectricStun(EnPametfrog* this) { this->freezeTimer = 40; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); - func_800BCB70(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); this->drawEffect = GEKKO_DRAW_EFFECT_ELECTRIC_STUN; this->unk_2C8 = 0.75f; this->unk_2C4 = 2.0f; @@ -433,17 +413,17 @@ void EnPametfrog_ApplyElectricStun(EnPametfrog* this) { void EnPametfrog_ApplyStun(EnPametfrog* this) { this->freezeTimer = 40; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); - func_800BCB70(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); } void EnPametfrog_SetupRearOnSnapper(EnPametfrog* this) { if (this->actionFunc == EnPametfrog_RearOnSnapperRise) { - Animation_PlayOnce(&this->skelAnime, &D_06005694); + Animation_PlayOnce(&this->skelAnime, &gGekkoWiggleAnim); } else if (this->actionFunc == EnPametfrog_RearOnSnapperWave) { - Animation_PlayOnce(&this->skelAnime, &D_060052EC); + Animation_PlayOnce(&this->skelAnime, &gGekkoLandOnSnapperAnim); } else { - Animation_PlayOnce(&this->skelAnime, &D_06004680); + Animation_PlayOnce(&this->skelAnime, &gGekkoStandingIdleAnim); } this->actor.flags &= ~1; @@ -458,9 +438,9 @@ void EnPametfrog_RearOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { if (Rand_ZeroOne() < 0.5f) { - Animation_PlayOnce(&this->skelAnime, &D_06004D50); + Animation_PlayOnce(&this->skelAnime, &gGekkoQuickFistPumpAnim); } else { - Animation_PlayOnce(&this->skelAnime, &D_06004680); + Animation_PlayOnce(&this->skelAnime, &gGekkoStandingIdleAnim); } } @@ -478,7 +458,7 @@ void EnPametfrog_RearOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupRearOnSnapperWave(EnPametfrog* this) { - Animation_PlayOnce(&this->skelAnime, &D_06004894); + Animation_PlayOnce(&this->skelAnime, &gGekkoJumpOnSnapperAnim); this->timer = 15; this->actionFunc = EnPametfrog_RearOnSnapperWave; } @@ -493,7 +473,7 @@ void EnPametfrog_RearOnSnapperWave(EnPametfrog* this, GlobalContext* globalCtx) } void EnPametfrog_SetupRearOnSnapperRise(EnPametfrog* this) { - Animation_PlayOnce(&this->skelAnime, &D_060050B8); + Animation_PlayOnce(&this->skelAnime, &gGekkoSqueezeAnim); this->timer = 10; this->actor.params = GEKKO_REAR_ON_SNAPPER; this->actor.shape.rot.x = 0; @@ -517,7 +497,7 @@ void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx Vec3f eye; s16 yaw; - Animation_PlayOnce(&this->skelAnime, &D_06001F20); + Animation_PlayOnce(&this->skelAnime, &gGekkoFallInAirAnim); this->actor.params = GEKKO_FALL_OFF_SNAPPER; this->actor.speedXZ = 7.0f; this->actor.velocity.y = 15.0f; @@ -531,7 +511,7 @@ void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx eye.y = this->actor.focus.pos.y + 100.0f; eye.z = (Math_CosS(yaw) * 300.0f) + this->actor.focus.pos.z; Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &eye); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DAMAGE); this->actionFunc = EnPametfrog_FallOffSnapper; } @@ -554,11 +534,11 @@ void EnPametfrog_FallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupJumpToWall(EnPametfrog* this) { - Animation_Change(&this->skelAnime, &D_060039C4, 2.0f, 0.0f, 0.0f, 0, -2.0f); + Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 2.0f, 0.0f, 0.0f, 0, -2.0f); this->actor.shape.rot.x = 0; this->actor.shape.rot.z = 0; this->actor.bgCheckFlags &= ~8; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_VOICE2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_VOICE2); this->actionFunc = EnPametfrog_JumpToWall; } @@ -578,14 +558,14 @@ void EnPametfrog_JumpToWall(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_SetupWallCrawl(EnPametfrog* this) { if (this->actionFunc == EnPametfrog_JumpToWall) { - Animation_PlayLoop(&this->skelAnime, &D_06001E14); + Animation_PlayLoop(&this->skelAnime, &gGekkoCrawlAnim); this->collider.base.acFlags |= AC_ON; this->unk_2D0.x = 0.0f; this->unk_2D0.z = 0.0f; this->actor.gravity = 0.0f; this->actor.world.pos.y = this->actor.focus.pos.y; this->unk_2D0.y = 1.0f; - Math_Vec3f_Copy(&this->actor.colChkInfo.displacement, &D_801D15B0); + Math_Vec3f_Copy(&this->actor.colChkInfo.displacement, &gZeroVec3f); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_2DC.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); this->unk_2DC.y = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y); @@ -601,7 +581,7 @@ void EnPametfrog_SetupWallCrawl(EnPametfrog* this) { this->skelAnime.playSpeed = 1.0f; } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_RUNAWAY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_RUNAWAY); this->actor.speedXZ = 8.0f; this->timer = Rand_S16Offset(35, 15); this->actionFunc = EnPametfrog_WallCrawl; @@ -659,11 +639,11 @@ void EnPametfrog_WallCrawl(EnPametfrog* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 15.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BOMCHU_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_WALK); } if (((globalCtx->gameplayFrames % 60) == 0) && (Rand_ZeroOne() < 0.8f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_REAL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_REAL); } if ((this->timer == 0) || @@ -691,7 +671,7 @@ void EnPametfrog_SetupWallPause(EnPametfrog* this) { this->wallRotation = (Rand_ZeroOne() < 0.5f ? -1 : 1) * (0x1000 + randFloat) * (M_PI / (15 * 0x8000)); } this->timer = 15; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_RUNAWAY2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_RUNAWAY2); this->actionFunc = EnPametfrog_WallPause; } @@ -709,7 +689,7 @@ void EnPametfrog_WallPause(EnPametfrog* this, GlobalContext* globalCtx) { Math3D_CrossProduct(&this->unk_2DC, &this->unk_2D0, &this->unk_2E8); func_8086A238(this); if (((globalCtx->gameplayFrames % 60) == 0) && (Rand_ZeroOne() < 0.8f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_REAL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_REAL); } if (this->timer == 0) { @@ -721,7 +701,8 @@ void EnPametfrog_WallPause(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_SetupClimbDownWall(EnPametfrog* this) { s16 yaw; - Animation_Change(&this->skelAnime, &D_060039C4, 0.0f, 0.0f, Animation_GetLastFrame(&D_060039C4), 2, 0.0f); + Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 0.0f, 0.0f, + Animation_GetLastFrame(&gGekkoJumpForwardAnim), 2, 0.0f); this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->actor.child); this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.shape.rot.x = 0; @@ -755,7 +736,7 @@ void EnPametfrog_ClimbDownWall(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupRunToSnapper(EnPametfrog* this) { - Animation_Change(&this->skelAnime, &D_060039C4, 2.0f, 0.0f, 0.0f, 0, -2.0f); + Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 2.0f, 0.0f, 0.0f, 0, -2.0f); this->actor.params = GEKKO_RETURN_TO_SNAPPER; this->actionFunc = EnPametfrog_RunToSnapper; } @@ -778,7 +759,7 @@ void EnPametfrog_RunToSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupJumpOnSnapper(EnPametfrog* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_06004680, 6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gGekkoStandingIdleAnim, 6.0f); this->timer = 6; this->collider.base.ocFlags1 &= ~OC1_ON; this->collider.base.acFlags &= ~AC_ON; @@ -787,7 +768,7 @@ void EnPametfrog_SetupJumpOnSnapper(EnPametfrog* this) { this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->actor.child); this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.params = GEKKO_JUMP_ON_SNAPPER; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_GREET); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_GREET); this->actionFunc = EnPametfrog_JumpOnSnapper; } @@ -810,7 +791,7 @@ void EnPametfrog_JumpOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupLandOnSnapper(EnPametfrog* this) { - Animation_PlayOnce(&this->skelAnime, &D_06000994); + Animation_PlayOnce(&this->skelAnime, &gGekkoFullFistPumpAnim); this->actor.shape.rot.y = this->actor.child->shape.rot.y; this->actor.params = GEKKO_ON_SNAPPER; this->actionFunc = EnPametfrog_LandOnSnapper; @@ -828,7 +809,7 @@ void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { Vec3f eye; f32 xzDist; - Animation_PlayOnce(&this->skelAnime, &D_06001F20); + Animation_PlayOnce(&this->skelAnime, &gGekkoFallInAirAnim); if (this->actor.colChkInfo.health > 0) { this->actor.params = GEKKO_RETURN_TO_SNAPPER; } @@ -838,12 +819,12 @@ void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_ON; this->timer = 10; if (this->actor.colChkInfo.health == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DEAD); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DAMAGE); } - func_800BCB70(&this->actor, 0x4000, 255, 0, 16); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); this->actor.world.pos.x += 30.0f * Math_SinS(yaw); this->actor.world.pos.z += 30.0f * Math_CosS(yaw); @@ -889,28 +870,28 @@ void EnPametfrog_FallInAir(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupFallOnGround(EnPametfrog* this, GlobalContext* globalCtx) { - Animation_PlayOnce(&this->skelAnime, &D_06004298); + Animation_PlayOnce(&this->skelAnime, &gGekkoFallOnGroundAnim); this->actor.shape.rot.x = 0; this->actor.shape.rot.y += this->spinYaw; this->actor.shape.rot.z = 0; this->spinYaw = 0; this->timer = 5; - EnPametfrog_ChangeColliderThaw(this, globalCtx); + EnPametfrog_Thaw(this, globalCtx); EnPametfrog_JumpWaterEffects(this, globalCtx); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WALK_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALK_WATER); this->actionFunc = EnPametfrog_FallOnGround; } void EnPametfrog_FallOnGround(EnPametfrog* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { - if (this->skelAnime.animation == &D_06004298) { + if (this->skelAnime.animation == &gGekkoFallOnGroundAnim) { if (this->actor.colChkInfo.health == 0) { this->timer--; if (this->timer == 0) { EnPametfrog_SetupDefeatGekko(this, globalCtx); } } else { - Animation_PlayOnce(&this->skelAnime, &D_060030E4); + Animation_PlayOnce(&this->skelAnime, &gGekkoRecoverAnim); } } else { EnPametfrog_SetupRunToSnapper(this); @@ -982,9 +963,9 @@ void EnPametfrog_SetupSpawnFrog(EnPametfrog* this, GlobalContext* globalCtx) { vec1.y = this->actor.world.pos.y + 25.0f; vec1.z = (Math_CosS(yaw) * 20.0f) + this->actor.world.pos.z; this->collider.base.ocFlags1 &= ~OC1_ON; - func_800B0DE0(globalCtx, &vec1, &D_801D15B0, &D_801D15B0, &primColor, &envColor, 800, 50); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_NPC_APPEAR); - Actor_SetRoomClearedTemp(globalCtx, globalCtx->roomCtx.currRoom.num); + func_800B0DE0(globalCtx, &vec1, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 800, 50); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_NPC_APPEAR); + Flags_SetClearTemp(globalCtx, globalCtx->roomCtx.currRoom.num); for (i = 0; i < 25; i++) { vel.x = randPlusMinusPoint5Scaled(5.0f); @@ -1043,7 +1024,7 @@ void EnPametfrog_PlayCutscene(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupLookAround(EnPametfrog* this) { - Animation_PlayOnce(&this->skelAnime, &D_060066B4); + Animation_PlayOnce(&this->skelAnime, &gGekkoLookAroundAnim); this->collider.base.atFlags &= ~AT_ON; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -1064,7 +1045,7 @@ void EnPametfrog_LookAround(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupJumpToLink(EnPametfrog* this) { - Animation_PlayLoop(&this->skelAnime, &D_060039C4); + Animation_PlayLoop(&this->skelAnime, &gGekkoJumpForwardAnim); this->collider.base.acFlags |= AC_ON; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnPametfrog_JumpToLink; @@ -1082,24 +1063,24 @@ void EnPametfrog_JumpToLink(EnPametfrog* this, GlobalContext* globalCtx) { } if ((this->collider.base.ocFlags1 & OC1_HIT) && (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) && - Actor_IsActorFacingLink(&this->actor, 0x3000) && + Actor_IsFacingPlayer(&this->actor, 0x3000) && (this->skelAnime.curFrame <= 2.0f || this->skelAnime.curFrame >= 11.0f)) { EnPametfrog_SetupMeleeAttack(this); } } void EnPametfrog_SetupMeleeAttack(EnPametfrog* this) { - Animation_PlayOnce(&this->skelAnime, &D_0600F990); + Animation_PlayOnce(&this->skelAnime, &gGekkoBoxingStanceAnim); this->timer = 7; this->actor.speedXZ = 0.0f; this->actionFunc = EnPametfrog_MeleeAttack; } static AnimationHeader* sAttackAnimations[] = { - &D_0600347C, // Jab Punch - &D_060070C4, // Hook Punch - &D_06003F28, // Kick - &D_0600F048, // Windup Punch + &gGekkoJabPunchAnim, + &gGekkoHookPunchAnim, + &gGekkoKickAnim, + &gGekkoWindupPunchAnim, }; void EnPametfrog_MeleeAttack(EnPametfrog* this, GlobalContext* globalCtx) { @@ -1109,21 +1090,21 @@ void EnPametfrog_MeleeAttack(EnPametfrog* this, GlobalContext* globalCtx) { if (this->timer == 0) { EnPametfrog_SetupLookAround(this); } else if (this->timer == 6) { - Animation_PlayOnce(&this->skelAnime, &D_0600F990); + Animation_PlayOnce(&this->skelAnime, &gGekkoBoxingStanceAnim); } else { Animation_PlayOnce(&this->skelAnime, sAttackAnimations[(s32)Rand_ZeroFloat(4.0f) % 4]); } } - if ((this->skelAnime.animation == &D_0600347C && Animation_OnFrame(&this->skelAnime, 2.0f)) || - (this->skelAnime.animation == &D_060070C4 && Animation_OnFrame(&this->skelAnime, 9.0f)) || - (this->skelAnime.animation == &D_06003F28 && Animation_OnFrame(&this->skelAnime, 2.0f)) || - ((this->skelAnime.animation == &D_0600F048) && Animation_OnFrame(&this->skelAnime, 27.0f))) { + if ((this->skelAnime.animation == &gGekkoJabPunchAnim && Animation_OnFrame(&this->skelAnime, 2.0f)) || + (this->skelAnime.animation == &gGekkoHookPunchAnim && Animation_OnFrame(&this->skelAnime, 9.0f)) || + (this->skelAnime.animation == &gGekkoKickAnim && Animation_OnFrame(&this->skelAnime, 2.0f)) || + ((this->skelAnime.animation == &gGekkoWindupPunchAnim) && Animation_OnFrame(&this->skelAnime, 27.0f))) { this->collider.base.atFlags |= AT_ON; - if (this->skelAnime.animation == &D_06003F28) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_KICK); + if (this->skelAnime.animation == &gGekkoKickAnim) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_KICK); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_PUNCH1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_PUNCH1); } } else { this->collider.base.atFlags &= ~AT_ON; @@ -1131,13 +1112,13 @@ void EnPametfrog_MeleeAttack(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupDamage(EnPametfrog* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_06005D54, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gGekkoKnockbackAnim, -3.0f); this->timer = 20; this->collider.base.atFlags &= ~AT_ON; this->collider.base.acFlags &= ~AC_ON; this->actor.speedXZ = 10.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_DAMAGE); - func_800BCB70(&this->actor, 0x4000, 255, 0, 20); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DAMAGE); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); func_800BE5CC(&this->actor, &this->collider, 0); this->actor.shape.rot.y = BINANG_ROT180(this->actor.world.rot.y); this->actionFunc = EnPametfrog_Damage; @@ -1157,7 +1138,7 @@ void EnPametfrog_Damage(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupStun(EnPametfrog* this) { - if (this->skelAnime.animation == &D_060039C4) { + if (this->skelAnime.animation == &gGekkoJumpForwardAnim) { this->skelAnime.curFrame = 0.0f; SkelAnime_Update(&this->skelAnime); } @@ -1175,10 +1156,10 @@ void EnPametfrog_SetupStun(EnPametfrog* this) { void EnPametfrog_Stun(EnPametfrog* this, GlobalContext* globalCtx) { this->freezeTimer--; if (this->freezeTimer == 0) { - EnPametfrog_ChangeColliderThaw(this, globalCtx); + EnPametfrog_Thaw(this, globalCtx); EnPametfrog_SetupJumpToLink(this); } else if (this->freezeTimer == 78) { - EnPametfrog_ChangeColliderThaw(this, globalCtx); + EnPametfrog_Thaw(this, globalCtx); this->actor.colorFilterTimer = 0; EnPametfrog_SetupCutscene(this); } @@ -1189,8 +1170,8 @@ void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { Vec3f at; s16 yawDiff; - Animation_MorphToPlayOnce(&this->skelAnime, &D_06001B08, 3.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_GREET); + Animation_MorphToPlayOnce(&this->skelAnime, &gGekkoCallAnim, 3.0f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_GREET); this->actor.flags &= ~1; this->actor.colChkInfo.health = 6; this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); @@ -1298,14 +1279,14 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) EnPametfrog_ApplyStun(this); EnPametfrog_SetupStun(this); } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_ICE) { - EnPametfrog_ChangeColliderFreeze(this); + EnPametfrog_Freeze(this); this->freezeTimer = 80; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 0x50); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0x50); EnPametfrog_SetupStun(this); } else { - EnPametfrog_ChangeColliderThaw(this, globalCtx); + EnPametfrog_Thaw(this, globalCtx); if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_FIRE) { - this->drawEffect = GEKKO_DRAW_EFFECT_NONE; + this->drawEffect = GEKKO_DRAW_EFFECT_THAW; this->unk_2C8 = 0.75f; this->unk_2C4 = 4.0f; } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_LIGHT) { @@ -1355,11 +1336,11 @@ void EnPametfrog_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if ((this->actionFunc != EnPametfrog_JumpOnSnapper) && (this->actionFunc != EnPametfrog_RearOnSnapperRise)) { if (this->actor.gravity < -0.1f) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); arg3 = this->actionFunc == EnPametfrog_FallInAir ? 3.0f : 15.0f; Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, arg3, 3.0f, 0x1F); } else if (this->freezeTimer == 0) { - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); this->actor.floorHeight = this->actor.world.pos.y; } } @@ -1388,19 +1369,19 @@ void EnPametfrog_Update(Actor* thisx, GlobalContext* globalCtx) { } } -/* index -1: Limb Not used - * index 0: GEKKO_LIMB_WAIST - * index 1: GEKKO_LIMB_L_SHIN - * index 2: GEKKO_LIMB_L_FOOT - * index 3: GEKKO_LIMB_R_SHIN - * index 4: GEKKO_LIMB_R_FOOT - * index 5: GEKKO_LIMB_L_UPPER_ARM - * index 6: GEKKO_LIMB_L_FOREARM - * index 7: GEKKO_LIMB_L_HAND - * index 8: GEKKO_LIMB_R_UPPER_ARM - * index 9: GEKKO_LIMB_R_FOREARM - * index 10: GEKKO_LIMB_R_HAND - * index 11: GEKKO_LIMB_JAW +/* value -1: Limb Not used + * value 0: GEKKO_LIMB_WAIST + * value 1: GEKKO_LIMB_L_SHIN + * value 2: GEKKO_LIMB_L_FOOT + * value 3: GEKKO_LIMB_R_SHIN + * value 4: GEKKO_LIMB_R_FOOT + * value 5: GEKKO_LIMB_L_UPPER_ARM + * value 6: GEKKO_LIMB_L_FOREARM + * value 7: GEKKO_LIMB_L_HAND + * value 8: GEKKO_LIMB_R_UPPER_ARM + * value 9: GEKKO_LIMB_R_FOREARM + * value 10: GEKKO_LIMB_R_HAND + * value 11: GEKKO_LIMB_JAW */ static s8 limbPosIndex[] = { -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, 6, -1, 7, 8, 9, -1, 10, -1, 11, -1, -1, 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 f00acecb5e..957a46cfc4 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h @@ -21,7 +21,7 @@ typedef enum { } EnPametfrogState; typedef enum { - /* 00 */ GEKKO_DRAW_EFFECT_NONE, // May be GEKKO_DRAW_EFFECT_THAW + /* 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, diff --git a/src/overlays/actors/ovl_En_Part/z_en_part.h b/src/overlays/actors/ovl_En_Part/z_en_part.h index be5c5b503a..fa3dd410f1 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.h +++ b/src/overlays/actors/ovl_En_Part/z_en_part.h @@ -7,7 +7,8 @@ struct EnPart; typedef struct EnPart { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x10]; + /* 0x144 */ char unk_144[0xC]; + /* 0x150 */ Gfx* unk_150; } EnPart; // size = 0x154 extern const ActorInit En_Part_InitVars; diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index 5f51217bb8..c47f67c278 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -5,6 +5,8 @@ */ #include "z_en_peehat.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/object_ph/object_ph.h" #define FLAGS 0x00000015 @@ -15,7 +17,26 @@ void EnPeehat_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx); void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80897498(EnPeehat* this); +void func_80897520(EnPeehat* this, GlobalContext* globalCtx); +void func_80897648(EnPeehat* this); +void func_808976DC(EnPeehat* this, GlobalContext* globalCtx); +void func_80897910(EnPeehat* this, GlobalContext* globalCtx); +void func_80897A34(EnPeehat* this); +void func_80897A94(EnPeehat* this, GlobalContext* globalCtx); +void func_80897D48(EnPeehat* this, GlobalContext* globalCtx); +void func_80897EAC(EnPeehat* this); +void func_80897F44(EnPeehat* this, GlobalContext* globalCtx); +void func_80898124(EnPeehat* this); +void func_80898144(EnPeehat* this, GlobalContext* globalCtx); +void func_808982E0(EnPeehat* this); +void func_80898338(EnPeehat* this, GlobalContext* globalCtx); +void func_80898454(EnPeehat* this, GlobalContext* globalCtx); +void func_808984E0(EnPeehat* this); +void func_80898594(EnPeehat* this, GlobalContext* globalCtx); +void func_80898654(EnPeehat* this); +void func_808986A4(EnPeehat* this, GlobalContext* globalCtx); + const ActorInit En_Peehat_InitVars = { ACTOR_EN_PEEHAT, ACTORCAT_ENEMY, @@ -28,40 +49,85 @@ const ActorInit En_Peehat_InitVars = { (ActorFunc)EnPeehat_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80899430 = { - { COLTYPE_WOOD, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_WOOD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 50, 120, -20, { 0, 0, 0 } }, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_8089945C = { - { COLTYPE_HIT6, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 40 }, 100 }, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_80899488[2] = { +static ColliderTrisElementInit sTrisElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80899500 = { - { COLTYPE_METAL, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_TRIS, }, - 2, D_80899488, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_METAL, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_80899510 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -96,98 +162,787 @@ static DamageTable D_80899510 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80899530 = { 15, 50, 120, -20, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit1 = { 15, 50, 120, -20, MASS_HEAVY }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_8089953C = { 1, 20, 15, -5, 30 }; +static CollisionCheckInfoInit2 sColChkInfoInit2 = { 1, 20, 15, -5, 30 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80899548[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1800, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 700, ICHAIN_STOP), }; -#endif +void EnPeehat_Init(Actor* thisx, GlobalContext* globalCtx) { + EnPeehat* this = THIS; -extern ColliderCylinderInit D_80899430; -extern ColliderSphereInit D_8089945C; -extern ColliderTrisElementInit D_80899488[2]; -extern ColliderTrisInit D_80899500; -extern DamageTable D_80899510; -extern CollisionCheckInfoInit2 D_80899530; -extern CollisionCheckInfoInit2 D_8089953C; -extern InitChainEntry D_80899548[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_ph_Skel_001C80, &object_ph_Anim_0009C4, this->jointTable, + this->morphTable, 24); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 27.0f); + this->unk_2B0 = 0; + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); + this->actor.floorHeight = this->actor.world.pos.y; + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_InitAndSetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); + Collider_InitAndSetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTriElements); -extern UNK_TYPE D_06000350; -extern UNK_TYPE D_060005C4; -extern UNK_TYPE D_06000844; -extern UNK_TYPE D_060009C4; + if (this->actor.params == 0) { + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit1); + if (gSaveContext.isNight) { + this->actor.shape.yOffset = -1000.0f; + } + Actor_SetScale(&this->actor, 0.036f); + this->actor.hintId = 0x48; + func_80897498(this); + } else { + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); + this->actor.scale.z = this->actor.scale.x = 0.006f; + this->actor.scale.y = 0.003f; + this->actor.velocity.y = 6.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/EnPeehat_Init.s") + this->colliderCylinder.dim.radius = 20; + this->colliderCylinder.dim.height = 15; + this->colliderCylinder.dim.yShift = -5; + this->actor.hintId = 0x49; + this->colliderCylinder.base.ocFlags1 &= ~OC1_ON; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/EnPeehat_Destroy.s") + func_80897A34(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897170.s") +void EnPeehat_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPeehat* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_808971DC.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroySphere(globalCtx, &this->colliderSphere); + Collider_DestroyTris(globalCtx, &this->colliderTris); + if (this->actor.params != 0) { + EnPeehat* parent = (EnPeehat*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897258.s") + if ((parent != NULL) && (parent->actor.update != NULL)) { + parent->unk_2AC--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897390.s") +void func_80897170(EnPeehat* this) { + this->unk_2AE = 10; + this->unk_2CC = 1.1f; + this->unk_2D0 = 1.6500001f; + this->unk_2C8 = 1.0f; + this->colliderSphere.base.colType = COLTYPE_HIT3; + this->unk_2B0 = 80; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897498.s") +void func_808971DC(EnPeehat* this, GlobalContext* globalCtx) { + if (this->unk_2AE == 10) { + this->unk_2AE = 0; + this->colliderSphere.base.colType = COLTYPE_HIT6; + this->unk_2C8 = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2EC, ARRAY_COUNT(this->unk_2EC), 2, 0.5f, 0.35f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897520.s") +void func_80897258(GlobalContext* globalCtx, EnPeehat* this, Vec3f* arg2, f32 arg3, f32 arg4) { + static Vec3f D_80899558 = { 0.0f, 8.0f, 0.0f }; + static Vec3f D_80899564 = { 0.0f, -1.5f, 0.0f }; + Vec3f sp44; + s16 sp42 = Rand_Next() >> 0x10; + s32 temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897648.s") + sp44.y = this->actor.floorHeight; + sp44.x = (Math_SinS(sp42) * arg3) + arg2->x; + sp44.z = (Math_CosS(sp42) * arg3) + arg2->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_808976DC.s") + D_80899564.x = randPlusMinusPoint5Scaled(1.05f); + D_80899564.z = randPlusMinusPoint5Scaled(1.05f); + D_80899558.y = randPlusMinusPoint5Scaled(4.0f) + 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897864.s") + EffectSsHahen_Spawn(globalCtx, &sp44, &D_80899558, &D_80899564, 0, (Rand_ZeroFloat(5.0f) + 12.0f) * arg4, -1, 10, + NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897910.s") +void func_80897390(EnPeehat* this, GlobalContext* globalCtx) { + s32 i; + s16 phi_s2 = BINANG_ROT180(this->actor.yawTowardsPlayer); + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897A34.s") + this->colliderCylinder.base.acFlags &= ~AC_HIT; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897A94.s") + for (i = 3 - this->unk_2AC; i > 0; i--) { + actor = + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PEEHAT, this->actor.world.pos.x, + this->actor.world.pos.y + 50.0f, this->actor.world.pos.z, 0, phi_s2, 0, 1); + phi_s2 += 0x5555; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897D00.s") + if (actor != NULL) { + this->unk_2AC++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897D48.s") + this->unk_2B0 = 8; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIHAT_DAMAGE); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897EAC.s") +void func_80897498(EnPeehat* this) { + Animation_Change(&this->skelAnime, &object_ph_Anim_0009C4, 0.0f, 3.0f, + Animation_GetLastFrame(&object_ph_Anim_0009C4), 2, 0.0f); + this->unk_2B0 = 0; + this->unk_2AD = 1; + this->colliderCylinder.base.acFlags &= ~AC_HIT; + this->actionFunc = func_80897520; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897F44.s") +void func_80897520(EnPeehat* this, GlobalContext* globalCtx) { + if (!gSaveContext.isNight) { + this->actor.flags |= 1; + this->colliderSphere.base.acFlags |= AC_ON; + if (this->actor.xzDistToPlayer < 740.0f) { + func_80897648(this); + } else { + Math_StepToF(&this->actor.shape.yOffset, -1000.0f, 10.0f); + } + } else { + this->actor.flags &= ~1; + this->colliderSphere.base.acFlags &= ~AC_ON; + Math_StepToF(&this->actor.shape.yOffset, -1000.0f, 50.0f); + if (this->unk_2B0 != 0) { + this->unk_2B0--; + if (this->unk_2B0 & 4) { + Math_StepToF(&this->unk_2C4, 0.205f, 0.235f); + } else { + Math_StepToF(&this->unk_2C4, 0.0f, 0.005f); + } + } else if (this->colliderCylinder.base.acFlags & AC_HIT) { + func_80897390(this, globalCtx); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898124.s") +void func_80897648(EnPeehat* this) { + if (this->actionFunc != func_80898454) { + Animation_Change(&this->skelAnime, &object_ph_Anim_0009C4, 0.0f, 3.0f, + Animation_GetLastFrame(&object_ph_Anim_0009C4), 2, 0.0f); + } + this->unk_2B0 = 16; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIHAT_UP); + this->actionFunc = func_808976DC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898144.s") +void func_808976DC(EnPeehat* this, GlobalContext* globalCtx) { + Vec3f sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_808982E0.s") + Math_StepToF(&this->actor.shape.yOffset, 0.0f, 50.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898338.s") + if (Math_ScaledStepToS(&this->unk_2B2, 4000, 800)) { + if (this->unk_2B0 != 0) { + this->unk_2B0--; + if ((this->unk_2B0 == 0) && (this->skelAnime.playSpeed < 0.5f)) { + this->unk_2B0 = -1; + this->skelAnime.playSpeed = 1.0f; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898414.s") + if (SkelAnime_Update(&this->skelAnime) || (this->unk_2B0 == 0)) { + func_80897EAC(this); + } else { + this->actor.world.pos.y += 6.5f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898454.s") + if ((this->actor.world.pos.y - this->actor.floorHeight) < 80.0f) { + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp34.y = this->actor.floorHeight; + func_800BBFB0(globalCtx, &sp34, 90.0f, 1, 150, 100, 1); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_808984E0.s") + func_80897258(globalCtx, this, &this->actor.world.pos, 75.0f, 2.0f); + Math_StepToF(&this->unk_2C4, 0.075f, 0.005f); + this->unk_2B4 += this->unk_2B2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898594.s") +void func_80897864(EnPeehat* this) { + Animation_PlayLoop(&this->skelAnime, &object_ph_Anim_0005C4); + this->unk_2B8 = 0.0f; + if (this->actionFunc == func_80898338) { + this->unk_2AD = -this->unk_2AD; + } else { + this->unk_2AD = (Rand_ZeroOne() < 0.5f) ? 1 : -1; + } + this->colliderTris.base.atFlags |= AT_ON; + this->actionFunc = func_80897910; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898654.s") +void func_80897910(EnPeehat* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_808986A4.s") + Math_StepToF(&this->actor.speedXZ, 3.0f, 0.25f); + Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 80.0f, 3.0f); + SkelAnime_Update(&this->skelAnime); + if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1000); + this->actor.shape.rot.y += (s16)(this->unk_2AD * 450); + } else { + func_80898124(this); + } + Math_ScaledStepToS(&this->unk_2B2, 4000, 500); + this->unk_2B4 += this->unk_2B2; + Math_StepToF(&this->unk_2C4, 0.075f, 0.005f); + func_800B9010(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_8089874C.s") +void func_80897A34(EnPeehat* this) { + Animation_PlayLoop(&this->skelAnime, &object_ph_Anim_0005C4); + this->unk_2B0 = 30; + this->actor.speedXZ = 5.3f; + this->colliderTris.base.atFlags |= AT_ON; + this->actionFunc = func_80897A94; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/EnPeehat_Update.s") +void func_80897A94(EnPeehat* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898E74.s") + if ((this->actor.parent != NULL) && (this->actor.parent->update == NULL)) { + this->actor.parent = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80899024.s") + if ((this->actor.world.pos.y - this->actor.floorHeight) >= 70.0f) { + Math_StepToF(&this->actor.velocity.y, -1.3f, 0.5f); + } else { + Math_StepToF(&this->actor.velocity.y, -0.135f, 0.05f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/EnPeehat_Draw.s") + if (this->unk_2B0 > 0) { + this->unk_2B0--; + } else { + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x33E); + this->colliderCylinder.base.ocFlags1 |= OC1_ON; + } + + this->actor.shape.rot.y += 0x15E; + SkelAnime_Update(&this->skelAnime); + Math_ScaledStepToS(&this->unk_2B2, 4000, 500); + this->unk_2B4 += this->unk_2B2; + Math_StepToF(&this->unk_2C4, 0.075f, 0.005f); + func_800B9010(&this->actor, NA_SE_EN_PIHAT_SM_FLY - SFX_FLAG); + + if (this->colliderTris.base.atFlags & AT_BOUNCED) { + this->colliderTris.base.atFlags &= ~(AT_BOUNCED | AT_ON); + this->actor.colChkInfo.health = 0; + func_808982E0(this); + } else if ((this->colliderCylinder.base.acFlags & AC_HIT) || (this->actor.bgCheckFlags & 1)) { + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 40, 7, 0); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + if (!(this->actor.bgCheckFlags & 1)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_PIHAT_SM_DEAD); + } + Actor_MarkForDeath(&this->actor); + } else if (this->colliderTris.base.atFlags & AT_HIT) { + this->colliderTris.base.atFlags &= ~AT_HIT; + if (BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.world.rot.y) > 0) { + this->actor.world.rot.y -= 0x2000; + } else { + this->actor.world.rot.y += 0x2000; + } + this->unk_2B0 = 40; + } else if (this->colliderCylinder.base.ocFlags1 & OC1_HIT) { + this->colliderCylinder.base.ocFlags1 &= ~OC1_HIT; + if ((BINANG_SUB(Actor_YawBetweenActors(&this->actor, this->colliderCylinder.base.oc), + this->actor.world.rot.y)) > 0) { + this->actor.world.rot.y -= 0x2000; + } else { + this->actor.world.rot.y += 0x2000; + } + this->unk_2B0 = 10; + } +} + +void func_80897D00(EnPeehat* this) { + Animation_PlayOnce(&this->skelAnime, &object_ph_Anim_000350); + this->colliderTris.base.atFlags &= ~AT_ON; + this->actionFunc = func_80897D48; +} + +void func_80897D48(EnPeehat* this, GlobalContext* globalCtx) { + Vec3f sp34; + + Math_StepToF(&this->actor.shape.yOffset, -1000.0f, 50.0f); + Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); + Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 50); + if (SkelAnime_Update(&this->skelAnime)) { + func_80897498(this); + this->actor.world.pos.y = this->actor.floorHeight; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIHAT_LAND); + } else if (this->actor.floorHeight < this->actor.world.pos.y) { + Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.floorHeight, 0.3f, 3.5f, 0.25f); + if ((this->actor.world.pos.y - this->actor.floorHeight) < 60.0f) { + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp34.y = this->actor.floorHeight; + func_800BBFB0(globalCtx, &sp34, 80.0f, 1, 150, 100, 1); + func_80897258(globalCtx, this, &sp34, 75.0f, 2.0f); + } + } + Math_ScaledStepToS(&this->unk_2B2, 0, 100); + this->unk_2B4 += this->unk_2B2; +} + +void func_80897EAC(EnPeehat* this) { + Animation_PlayLoop(&this->skelAnime, &object_ph_Anim_0005C4); + this->actor.speedXZ = Rand_ZeroFloat(0.5f) + 2.5f; + this->unk_2B0 = Rand_ZeroFloat(10.0f) + 10.0f; + this->colliderTris.base.atFlags |= AT_ON; + this->colliderSphere.base.acFlags |= AC_ON; + this->actionFunc = func_80897F44; +} + +void func_80897F44(EnPeehat* this, GlobalContext* globalCtx) { + s32 pad; + f32 cos; + Player* player = GET_PLAYER(globalCtx); + + if ((this->actor.world.pos.y - this->actor.floorHeight) > 75.0f) { + this->actor.world.pos.y -= 1.0f; + } + + cos = cos_rad(this->unk_2B8); + this->actor.world.pos.y += cos * 1.4f; + this->unk_2B8 += fabsf(cos * 0.18f) + 0.07f; + this->unk_2B0--; + + if (this->unk_2B0 <= 0) { + this->actor.speedXZ = Rand_ZeroFloat(0.5f) + 2.5f; + this->unk_2B0 = Rand_ZeroFloat(10.0f) + 10.0f; + this->unk_2B6 = randPlusMinusPoint5Scaled(1000.0f); + } + + SkelAnime_Update(&this->skelAnime); + this->actor.world.rot.y += this->unk_2B6; + this->actor.shape.rot.y += 0x15E; + + if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + func_80897864(this); + } else { + func_80898124(this); + } + + Math_ScaledStepToS(&this->unk_2B2, 4000, 500); + this->unk_2B4 += this->unk_2B2; + Math_StepToF(&this->unk_2C4, 0.075f, 0.005f); + func_800B9010(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); +} + +void func_80898124(EnPeehat* this) { + this->actionFunc = func_80898144; + this->actor.speedXZ = 2.5f; +} + +void func_80898144(EnPeehat* this, GlobalContext* globalCtx) { + s32 step; + f32 cos; + Player* player = GET_PLAYER(globalCtx); + + if ((this->actor.world.pos.y - this->actor.floorHeight) > 75.0f) { + this->actor.world.pos.y -= 1.0f; + } else { + this->actor.world.pos.y += 1.0f; + } + cos = cos_rad(this->unk_2B8); + this->actor.world.pos.y += cos * 1.4f; + + cos = cos_rad(this->unk_2B8); + this->unk_2B8 += fabsf(cos * 0.18f) + 0.07f; + + step = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); + Math_ScaledStepToS(&this->actor.world.rot.y, step, 0x258); + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x1194, 0x258); + + this->actor.shape.rot.y += 0x15E; + this->unk_2B4 += this->unk_2B2; + + if (Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) < 2.0f) { + func_80897D00(this); + } + + if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + func_80897864(this); + } + func_800B9010(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); +} + +void func_808982E0(EnPeehat* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_ph_Anim_000844, -4.0f); + this->actor.speedXZ = -9.0f; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actionFunc = func_80898338; +} + +void func_80898338(EnPeehat* this, GlobalContext* globalCtx) { + this->unk_2B4 += this->unk_2B2; + SkelAnime_Update(&this->skelAnime); + + if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f)) { + if (this->actor.params != 0) { + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 40, 7, 0); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_EXTINCT); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_PIHAT_SM_DEAD); + Actor_MarkForDeath(&this->actor); + } else { + func_80897864(this); + } + } + func_800B9010(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); +} + +void func_80898414(EnPeehat* this) { + func_800BE568(&this->actor, &this->colliderSphere); + this->unk_2B2 = 0; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80898454; +} + +void func_80898454(EnPeehat* this, GlobalContext* globalCtx) { + if (this->unk_2B0 != 0) { + this->unk_2B0--; + } + + Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight, 8.0f); + + if (this->unk_2B0 == 0) { + func_808971DC(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + func_808984E0(this); + } else { + func_80897648(this); + } + } +} + +void func_808984E0(EnPeehat* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_ph_Anim_000844, -4.0f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIHAT_DAMAGE); + this->unk_2B2 = 4000; + this->unk_2B0 = 14; + this->actor.speedXZ = 10.0f; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 14); + this->colliderSphere.base.acFlags &= ~AC_ON; + this->unk_2C4 = 0.0f; + if (this->actor.colChkInfo.health == 0) { + this->actor.velocity.y = 6.0f; + } + this->actionFunc = func_80898594; +} + +void func_80898594(EnPeehat* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + this->unk_2B4 += this->unk_2B2; + Math_ScaledStepToS(&this->unk_2B2, 4000, 250); + Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 88.5f, 3.0f); + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + this->unk_2B0--; + if (this->unk_2B0 <= 0) { + if (this->actor.colChkInfo.health == 0) { + func_80898654(this); + } else { + func_80897EAC(this); + } + } +} + +void func_80898654(EnPeehat* this) { + Animation_PlayLoop(&this->skelAnime, &object_ph_Anim_0005C4); + this->unk_2B0 = 5; + this->unk_2B8 = 0.0f; + this->actionFunc = func_808986A4; +} + +void func_808986A4(EnPeehat* this, GlobalContext* globalCtx) { + if (this->unk_2B0 == 5) { + EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0x602, 0); + + if (bomb != NULL) { + bomb->timer = 0; + } + } + + this->unk_2B0--; + + if (this->unk_2B0 == 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xE0); + Actor_MarkForDeath(&this->actor); + } +} + +void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { + if (this->colliderTris.base.acFlags & AC_BOUNCED) { + this->colliderTris.base.acFlags &= ~AC_BOUNCED; + this->colliderSphere.base.acFlags &= ~AC_HIT; + return; + } + + if (this->colliderSphere.base.acFlags & AC_HIT) { + this->colliderSphere.base.acFlags &= ~AC_HIT; + if ((this->unk_2AE != 10) || !(this->colliderSphere.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if (!Actor_ApplyDamage(&this->actor)) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + this->colliderTris.base.atFlags &= ~(AT_HIT | AT_ON); + Actor_SetDropFlag(&this->actor, &this->colliderSphere.info); + func_808971DC(this, globalCtx); + + if (this->actor.colChkInfo.damageEffect == 5) { + this->unk_2B0 = 40; + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->unk_2CC = 1.1f; + this->unk_2C8 = 2.0f; + this->unk_2AE = 32; + func_80898414(this); + } else if (this->actor.colChkInfo.damageEffect == 1) { + this->unk_2B0 = 40; + Actor_SetColorFilter(&this->actor, 0, 200, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + func_80898414(this); + } else if (this->actor.colChkInfo.damageEffect == 3) { + func_80897170(this); + if (this->actor.colChkInfo.health == 0) { + this->unk_2B0 = 3; + this->colliderSphere.base.acFlags &= ~AC_ON; + } + func_80898414(this); + } else { + if (this->actor.colChkInfo.damageEffect == 2) { + this->unk_2C8 = 4.0f; + this->unk_2CC = 2.1f; + this->unk_2AE = 0; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_2C8 = 4.0f; + this->unk_2CC = 1.1f; + this->unk_2AE = 20; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->colliderSphere.info.bumper.hitPos.x, this->colliderSphere.info.bumper.hitPos.y, + this->colliderSphere.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + func_800BE568(&this->actor, &this->colliderSphere); + func_808984E0(this); + } + } + } else if ((this->unk_2AE == 10) && (this->colliderCylinder.base.acFlags & AC_HIT) && + ((this->unk_2AE != 10) || !(this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + func_808971DC(this, globalCtx); + this->actor.colorFilterTimer = 0; + func_80897648(this); + } +} + +void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnPeehat* this = THIS; + + if (thisx->params == 0) { + func_8089874C(this, globalCtx); + } + Actor_MoveWithGravity(thisx); + Actor_UpdateBgCheckInfo(globalCtx, thisx, 25.0f, 30.0f, 30.0f, 5); + + this->actionFunc(this, globalCtx); + + if ((globalCtx->gameplayFrames % 128) == 0) { + this->unk_2C0 = Rand_ZeroFloat(0.25f) + 0.5f; + } + + this->unk_2BC += this->unk_2C0; + if (thisx->params == 0) { + if (this->actionFunc == func_80897910) { + Math_ScaledStepToS(&thisx->shape.rot.x, 6000, 300); + } else { + Math_ScaledStepToS(&thisx->shape.rot.x, 0, 300); + } + } else { + Actor_SetFocus(thisx, 0.0f); + } + + Collider_UpdateCylinder(thisx, &this->colliderCylinder); + this->colliderCylinder.dim.pos.y += (s16)(thisx->shape.yOffset * thisx->scale.y); + if (this->colliderCylinder.base.ocFlags1 & OC1_ON) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + + if (thisx->params == 0) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + if (this->colliderSphere.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + } + } + + if (this->colliderTris.base.atFlags & AT_HIT) { + this->colliderTris.base.atFlags &= ~AT_HIT; + func_808982E0(this); + } + + if (this->colliderTris.base.atFlags & AT_ON) { + thisx->flags |= 0x1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + if (thisx->params == 0) { + Vec3f sp74; + CollisionPoly* sp70; + s32 sp6C; + s32 i; + + sp70 = NULL; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + + for (i = 1; i >= 0; i--) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &thisx->world.pos, &this->unk_2D4[i], &sp74, &sp70, 1, + 1, 0, 1, &sp6C)) { + func_800BBFB0(globalCtx, &sp74, 0.0f, 1, 300, 150, 1); + func_80897258(globalCtx, this, &sp74, 0.0f, 1.5f); + } + } + } + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + + if (this->actionFunc != func_80898454) { + Math_StepToF(&this->unk_2C4, 0.0f, 0.001f); + } + + if (this->unk_2C8 > 0.0f) { + if (this->unk_2AE != 10) { + Math_StepToF(&this->unk_2C8, 0.0f, 0.05f); + if (this->unk_2AE == 0) { + this->unk_2CC = (this->unk_2C8 + 1.0f) * 1.05f; + this->unk_2CC = CLAMP_MAX(this->unk_2CC, 2.1f); + } else { + this->unk_2CC = (this->unk_2C8 + 1.0f) * 0.55f; + this->unk_2CC = CLAMP_MAX(this->unk_2CC, 1.1f); + } + } else if (!Math_StepToF(&this->unk_2D0, 1.1f, 0.0275f)) { + func_800B9010(thisx, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +s32 EnPeehat_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnPeehat* this = THIS; + s32 pad; + + if (limbIndex == 4) { + rot->x = -this->unk_2B4; + } else if ((limbIndex == 3) || + ((limbIndex == 23) && ((this->actionFunc == func_80898594) || (this->actionFunc == func_80897520)))) { + OPEN_DISPS(globalCtx->state.gfxCtx); + Gfx* gfx = POLY_OPA_DISP; + + Matrix_StatePush(); + Matrix_RotateStateAroundXAxis(this->unk_2BC * 0.115f); + Matrix_InsertYRotation_f(this->unk_2BC * 0.13f, MTXMODE_APPLY); + Matrix_InsertZRotation_f(this->unk_2BC * 0.1f, MTXMODE_APPLY); + Matrix_Scale(1.0f - this->unk_2C4, this->unk_2C4 + 1.0f, 1.0f - this->unk_2C4, MTXMODE_APPLY); + Matrix_InsertZRotation_f(-(this->unk_2BC * 0.1f), MTXMODE_APPLY); + Matrix_InsertYRotation_f(-(this->unk_2BC * 0.13f), MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(-(this->unk_2BC * 0.115f)); + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], *dList); + + Matrix_StatePop(); + + POLY_OPA_DISP = &gfx[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + return true; + } + return false; +} + +void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80899570[] = { + { 1300.0f, 1200.0f, 0.0f }, + { 1300.0f, -1200.0f, 0.0f }, + { 1300.0f, 0.0f, 1200.0f }, + { 1300.0f, 0.0f, -1200.0f }, + }; + static s8 D_808995A0[] = { + -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 2, -1, -1, 4, -1, -1, 6, -1, -1, 8, -1, -1, 10, -1, + }; + GlobalContext* globalCtx = globalCtx2; + EnPeehat* this = THIS; + s32 i; + s32 index = D_808995A0[limbIndex]; + Gfx* gfx; + + if (index != -1) { + Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_2EC[index]); + Matrix_GetStateTranslationAndScaledX(4000.0f, &this->unk_2EC[index + 1]); + } + + if (limbIndex == 4) { + Matrix_GetStateTranslationAndScaledZ(5500.0f, &this->unk_2D4[0]); + Matrix_GetStateTranslationAndScaledZ(-5500.0f, &this->unk_2D4[1]); + } else if ((limbIndex == 3) && (thisx->params == 0)) { + Vec3f* vec = &D_80899570[0]; + Vec3f* vec2 = &this->unk_2EC[12]; + + for (i = 0; i < ARRAY_COUNT(D_80899570); i++, vec++, vec2++) { + Matrix_MultiplyVector3fByState(vec, vec2); + } + + Matrix_GetStateTranslationAndScaledX(3000.0f, vec2++); + Matrix_GetStateTranslationAndScaledX(-400.0f, vec2); + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_OPA_DISP; + + Matrix_InsertTranslation(-1000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Collider_UpdateSphere(0, &this->colliderSphere); + Matrix_InsertTranslation(500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertYRotation_f(3.2f, MTXMODE_APPLY); + Matrix_Scale(0.3f, 0.2f, 0.2f, MTXMODE_APPLY); + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], *dList); + + POLY_OPA_DISP = &gfx[2]; + Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->colliderSphere.dim.worldSphere.center); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPeehat* this = THIS; + Vec3f sp58; + Vec3f sp4C; + Vec3f sp40; + s32 i; + + func_8012C28C(globalCtx->state.gfxCtx); + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnPeehat_OverrideLimbDraw, + (this->actor.params == 0) ? EnPeehat_PostLimbDraw : NULL, &this->actor); + + if ((this->actor.speedXZ != 0.0f) || (this->actor.velocity.y != 0.0f)) { + Matrix_GetStateTranslationAndScaledZ(4500.0f, &sp40); + Matrix_GetStateTranslationAndScaledZ(-4500.0f, &sp4C); + Matrix_GetStateTranslationAndScaledX(4500.0f, &sp58); + Collider_SetTrisVertices(&this->colliderTris, 0, &sp40, &sp4C, &sp58); + Matrix_GetStateTranslationAndScaledX(-4500.0f, &sp58); + Collider_SetTrisVertices(&this->colliderTris, 1, &sp40, &sp58, &sp4C); + } + + if (this->unk_2AE == 0) { + for (i = 0; i < ARRAY_COUNT(this->unk_2EC); i++) { + this->unk_2EC[i].y -= 50.0f; + } + } + + func_800BE680(globalCtx, &this->actor, this->unk_2EC, ARRAY_COUNT(this->unk_2EC), this->unk_2CC, this->unk_2D0, + this->unk_2C8, this->unk_2AE); +} diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h index c6303311a4..0aee3a7427 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h @@ -8,10 +8,31 @@ struct EnPeehat; typedef void (*EnPeehatActionFunc)(struct EnPeehat*, GlobalContext*); typedef struct EnPeehat { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x164]; - /* 0x02A8 */ EnPeehatActionFunc actionFunc; - /* 0x02AC */ char unk_2AC[0x294]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[24]; + /* 0x188 */ Vec3s morphTable[24]; + /* 0x2A8 */ EnPeehatActionFunc actionFunc; + /* 0x2AC */ u8 unk_2AC; + /* 0x2AD */ s8 unk_2AD; + /* 0x2AE */ u8 unk_2AE; + /* 0x2B0 */ s16 unk_2B0; + /* 0x2B2 */ s16 unk_2B2; + /* 0x2B4 */ s16 unk_2B4; + /* 0x2B6 */ s16 unk_2B6; + /* 0x2B8 */ f32 unk_2B8; + /* 0x2BC */ f32 unk_2BC; + /* 0x2C0 */ f32 unk_2C0; + /* 0x2C4 */ f32 unk_2C4; + /* 0x2C8 */ f32 unk_2C8; + /* 0x2CC */ f32 unk_2CC; + /* 0x2D0 */ f32 unk_2D0; + /* 0x2D4 */ Vec3f unk_2D4[2]; + /* 0x2EC */ Vec3f unk_2EC[18]; + /* 0x3C4 */ ColliderCylinder colliderCylinder; + /* 0x410 */ ColliderSphere colliderSphere; + /* 0x468 */ ColliderTris colliderTris; + /* 0x488 */ ColliderTrisElement colliderTriElements[2]; } EnPeehat; // size = 0x540 extern const ActorInit En_Peehat_InitVars; diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 5cb68e3df7..df73227a2b 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -315,7 +315,7 @@ Actor* func_80AF7CB0(EnPm* this, GlobalContext* globalCtx, u8 actorCat, s16 acto Actor* actor; while (true) { - actor = func_ActorCategoryIterateById(globalCtx, phi_s0, actorCat, actorId); + actor = SubS_FindActor(globalCtx, phi_s0, actorCat, actorId); phi_s0 = actor; if (actor == NULL) { @@ -338,7 +338,7 @@ Actor* func_80AF7CB0(EnPm* this, GlobalContext* globalCtx, u8 actorCat, s16 acto return phi_s0; } -Actor* func_80AF7D60(GlobalContext* globalCtx, s32 arg1) { +EnDoor* func_80AF7D60(GlobalContext* globalCtx, s32 arg1) { s32 phi_a1; switch (arg1) { @@ -367,7 +367,7 @@ Actor* func_80AF7D60(GlobalContext* globalCtx, s32 arg1) { return NULL; } - return func_8013A7C0(globalCtx, phi_a1); + return SubS_FindDoor(globalCtx, phi_a1); } Actor* func_80AF7DC4(EnPm* this, GlobalContext* globalCtx, s32 arg2) { @@ -375,7 +375,7 @@ Actor* func_80AF7DC4(EnPm* this, GlobalContext* globalCtx, s32 arg2) { Actor* actor; while (true) { - actor = func_ActorCategoryIterateById(globalCtx, phi_s0, ACTORCAT_PROP, ACTOR_EN_PST); + actor = SubS_FindActor(globalCtx, phi_s0, ACTORCAT_PROP, ACTOR_EN_PST); phi_s0 = actor; if (actor == NULL) { @@ -710,7 +710,7 @@ UNK_TYPE* func_80AF8540(EnPm* this, GlobalContext* globalCtx) { s32 func_80AF86F0(EnPm* this, GlobalContext* globalCtx) { s32 ret = false; - if ((this->unk_356 & 7) && func_800B84D0(&this->actor, globalCtx)) { + if ((this->unk_356 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_8013AED4(&this->unk_356, 0, 7); this->unk_398 = 0; this->unk_378 = 0; @@ -845,7 +845,7 @@ void func_80AF8BA8(s32 arg0) { void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s32 sp28 = func_80152498(&globalCtx->msgCtx); + s32 sp28 = Message_GetState(&globalCtx->msgCtx); u16 temp_a0 = globalCtx->msgCtx.unk11F04; if ((player->targetActor == &this->actor) && ((temp_a0 < 255) || (temp_a0 > 512)) && (sp28 == 3) && @@ -942,7 +942,7 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { u16 sp56 = gSaveContext.time - 0x3FFC; u8 sp55 = this->actor.params & 0xFF; - Actor* sp50; + EnDoor* sp50; Vec3s* sp4C; Vec3f sp40; Vec3f sp34; @@ -955,7 +955,7 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = func_8013BB34(globalCtx, sp55, D_80AFB430[arg2->unk0]); } - if ((sp50 != NULL) && (sp50->update != NULL)) { + if ((sp50 != NULL) && (sp50->actor.update != NULL)) { if (this->unk_234 != 0) { sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); @@ -964,7 +964,7 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->unk_278, &sp34); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); - temp = this->actor.world.rot.y - sp50->shape.rot.y; + temp = this->actor.world.rot.y - sp50->actor.shape.rot.y; if (ABS_ALT(temp) <= 0x4000) { this->unk_260 = -0x4B; } else { @@ -1024,8 +1024,8 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_356 &= ~8; this->unk_356 &= ~0x10; if (this->unk_258 == 27) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROOM_CARTAIN); - Actor_UnsetSwitchFlag(globalCtx, 0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); + Flags_UnsetSwitch(globalCtx, 0); } switch (arg2->unk0) { @@ -1089,8 +1089,8 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &sp40); Math_Vec3f_Copy(&this->actor.prevPos, &sp40); if (arg2->unk0 == 24) { - Actor_UnsetSwitchFlag(globalCtx, 0); - Actor_UnsetSwitchFlag(globalCtx, 1); + Flags_UnsetSwitch(globalCtx, 0); + Flags_UnsetSwitch(globalCtx, 1); this->unk_394 = 0; this->unk_368 = 60.0f; func_80AF7E98(this, 9); @@ -1144,8 +1144,8 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar switch (arg2->unk0) { case 27: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROOM_CARTAIN); - Actor_SetSwitchFlag(globalCtx, 0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); + Flags_SetSwitch(globalCtx, 0); this->unk_36C = 20; func_8013AED4(&this->unk_356, 3, 7); func_80AF7E98(this, 3); @@ -1409,7 +1409,7 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { - EnDoor* sp44 = (EnDoor*)func_80AF7D60(globalCtx, this->unk_258); + EnDoor* sp44 = func_80AF7D60(globalCtx, this->unk_258); Vec3f sp38; Vec3f* sp28; f32 temp; @@ -1430,7 +1430,7 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { Lib_Vec3f_TranslateAndRotateY(&this->unk_26C, this->actor.world.rot.y, &sp38, &this->actor.world.pos); this->unk_36E += this->unk_374; if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_POSTMAN_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); } } return false; @@ -1449,7 +1449,7 @@ s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { func_8013AF00(sp7C, 3, this->unk_234->count + 3); if (!(this->unk_356 & 8)) { - sp58 = D_801D15B0; + sp58 = gZeroVec3f; func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, &sp58, this->unk_374); func_8013B878(globalCtx, this->unk_234, this->unk_250, &sp58); @@ -1468,7 +1468,7 @@ s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { sp58 = this->actor.world.pos; } - this->unk_238 = D_801D15B0; + this->unk_238 = gZeroVec3f; if (func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, &this->unk_238, this->unk_374)) { @@ -1485,7 +1485,7 @@ s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { this->unk_238 = sp58; } else if ((this->unk_258 != 91) && (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_POSTMAN_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); } if ((this->unk_356 & 0x10) && (this->unk_258 == 90)) { @@ -1533,7 +1533,7 @@ s32 func_80AFA170(EnPm* this, GlobalContext* globalCtx) { } if ((this->unk_384 == 11) && Animation_OnFrame(&this->skelAnime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_POSTMACHINE_HIT_OPEN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMACHINE_HIT_OPEN); } if (this->unk_258 == 19) { @@ -1569,7 +1569,7 @@ s32 func_80AFA334(EnPm* this, GlobalContext* globalCtx) { case 27: if (DECR(this->unk_36C) == 0) { - Actor_SetSwitchFlag(globalCtx, 1); + Flags_SetSwitch(globalCtx, 1); } break; @@ -1578,7 +1578,7 @@ s32 func_80AFA334(EnPm* this, GlobalContext* globalCtx) { case 21: case 22: if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_NP_SLEEP_OUT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_NP_SLEEP_OUT); } break; @@ -1714,7 +1714,7 @@ void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { this->actor.flags &= ~1; sp2C.unk0 = 0; } else { - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= 1; } @@ -1755,10 +1755,10 @@ void func_80AFA5FC(EnPm* this, GlobalContext* globalCtx) { } void func_80AFA724(EnPm* this, GlobalContext* globalCtx) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_POSTMAN_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); } } @@ -1802,7 +1802,7 @@ void EnPm_Update(Actor* thisx, GlobalContext* globalCtx) { func_80AF7E6C(this); func_80AF8AC8(this); func_8013C964(&this->actor, globalCtx, this->unk_368, 30.0f, this->unk_394, this->unk_356 & 7); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); func_80AF7F68(this, globalCtx); } @@ -1827,7 +1827,7 @@ void func_80AFAA44(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* switch (limbIndex) { case 15: if (ActorCutscene_GetCurrentIndex() == -1) { - Matrix_MultiplyVector3fByState(&D_801D15B0, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } if ((this->unk_356 & 0x8000) && !(gSaveContext.weekEventReg[90] & 4)) { @@ -1843,10 +1843,10 @@ void func_80AFAA44(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* case 8: if ((this->unk_258 == 9) || (this->unk_258 == 20) || (this->unk_258 == 21) || (this->unk_258 == 22)) { - Matrix_MultiplyVector3fByState(&D_801D15B0, &sp2C); + Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp2C); Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp2C); } else if (this->unk_258 == 24) { - Matrix_MultiplyVector3fByState(&D_801D15B0, &sp2C); + Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp2C); Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp2C); } func_80AF8890(this, gfx, 2); diff --git a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c index c578e3d378..fe96f5a37f 100644 --- a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c +++ b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c @@ -112,7 +112,7 @@ void EnPoFusen_Init(Actor* thisx, GlobalContext* globalCtx) { if (0) {} this->collider.dim.worldSphere.radius = 40; SkelAnime_InitFlex(globalCtx, &this->anime, &D_060024F0, &D_06000040, this->jointTable, this->morphTable, 10); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); if (EnPoFusen_CheckParent(this, globalCtx) == 0) { @@ -150,7 +150,7 @@ void EnPoFusen_Destroy(Actor* thisx, GlobalContext* globalCtx) { u16 EnPoFusen_CheckParent(EnPoFusen* this, GlobalContext* globalCtx) { struct Actor* actorPtr; - actorPtr = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + actorPtr = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; if (GET_IS_FUSE_TYPE_PARAM(this)) { return 1; } @@ -243,7 +243,7 @@ void EnPoFusen_IncrementRomaniPop(EnPoFusen* this) { void EnPoFusen_Pop(EnPoFusen* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y + 20.0f, this->actor.world.pos.z, 255, 255, 200, CLEAR_TAG_POP); - Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index 1bb44aa022..a2e299290f 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -5,6 +5,7 @@ */ #include "z_en_po_sisters.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00005015 @@ -157,7 +158,7 @@ void EnPoSisters_Init(Actor* thisx, GlobalContext* globalCtx) { EnPoSisters* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 50.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &D_060065C8, &D_060014CC, this->jointTable, this->morphTable, 12); this->unk_226 = 255; this->unk_227 = 255; @@ -302,7 +303,7 @@ void func_80B1AAE8(EnPoSisters* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (DECR(this->unk_192) == 0) { this->unk_192 = Rand_S16Offset(100, 50); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); } } @@ -406,7 +407,7 @@ void func_80B1B020(EnPoSisters* this, GlobalContext* globalCtx) { this->actor.shape.rot.y += ((s32)((this->skelAnime.endFrame + 1.0f) * 3.0f) - this->unk_192) * 0x180; if ((this->unk_192 == 18) || (this->unk_192 == 7)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); } else if (this->unk_192 == 0) { func_80B1B0E0(this); } @@ -444,13 +445,13 @@ void func_80B1B168(EnPoSisters* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HARD; func_80B1AC40(this); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); func_80B1BE4C(this, globalCtx); } } } if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); } } @@ -472,7 +473,7 @@ void func_80B1B2F0(EnPoSisters* this, GlobalContext* globalCtx) { if (this->unk_18C != 0) { func_80B1AC40(this); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); func_80B1BE4C(this, globalCtx); } } @@ -489,7 +490,7 @@ void func_80B1B3A8(EnPoSisters* this) { } this->unk_191 &= ~(0x8 | 0x2 | 0x1); - func_800BCB70(&this->actor, 0x4000, 255, 0, 16); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); this->actionFunc = func_80B1B444; } @@ -556,8 +557,8 @@ void func_80B1B70C(EnPoSisters* this) { this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->unk_191 &= ~(0x4 | 0x1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DISAPPEAR); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DISAPPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); this->actionFunc = func_80B1B7BC; } @@ -587,7 +588,7 @@ void func_80B1B860(EnPoSisters* this, GlobalContext* globalCtx) { this->unk_192 = 15; this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); this->unk_191 &= ~0x1; this->actionFunc = func_80B1B940; } @@ -665,7 +666,7 @@ void func_80B1BA90(EnPoSisters* this, GlobalContext* globalCtx) { } if (this->unk_192 == 16) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); } } @@ -725,7 +726,7 @@ void func_80B1BE4C(EnPoSisters* this, s32 arg1) { sp34.x = this->actor.world.pos.x; sp34.y = this->actor.world.pos.y + 45.0f; sp34.z = this->actor.world.pos.z; - func_800B3030(arg1, &sp34, &D_801D15B0, &D_801D15B0, 150, 0, 3); + func_800B3030(arg1, &sp34, &gZeroVec3f, &gZeroVec3f, 150, 0, 3); } Lights_PointSetColorAndRadius(&this->lightInfo, 0, 0, 0, 0); this->actionFunc = func_80B1BF2C; @@ -825,7 +826,7 @@ void func_80B1C0A4(EnPoSisters* this, GlobalContext* globalCtx) { void func_80B1C2E8(EnPoSisters* this) { Animation_PlayOnce(&this->skelAnime, &D_0600119C); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); this->unk_229 = 0; this->unk_191 = 0x20; this->actionFunc = func_80B1C340; @@ -854,11 +855,11 @@ void func_80B1C408(EnPoSisters* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - func_800BE258(&this->actor, &this->collider.info); + Actor_SetDropFlag(&this->actor, &this->collider.info); if (this->unk_18D != 0) { ((EnPoSisters*)this->actor.parent)->unk_194--; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); func_80B1BE4C(this, globalCtx); if (Rand_ZeroOne() < 0.2f) { sp3C.x = this->actor.world.pos.x; @@ -878,10 +879,10 @@ void func_80B1C408(EnPoSisters* this, GlobalContext* globalCtx) { } } else { if (Actor_ApplyDamage(&this->actor)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DAMAGE); } else { Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_SISTER_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_SISTER_DEAD); } if (this->actor.colChkInfo.damageEffect == 4) { @@ -920,7 +921,7 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { func_80B1A894(this, globalCtx); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (this->unk_191 & 0x10) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 0.0f, 5); @@ -933,7 +934,7 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { } this->actor.shape.shadowAlpha = this->unk_229; - Actor_SetHeight(&this->actor, 40.0f); + Actor_SetFocus(&this->actor, 40.0f); if (this->unk_2F0 > 0.0f) { Math_StepToF(&this->unk_2F0, 0.0f, 0.05f); @@ -1189,7 +1190,7 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(phi_f20, phi_f20, phi_f20, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_0407D590); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); } func_800BE680(globalCtx, &this->actor, this->unk_28C, ARRAY_COUNT(this->unk_28C), 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 4042aecac7..aedd9efc18 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -162,7 +162,7 @@ void EnPoh_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); Collider_InitAndSetJntSph(globalCtx, &this->colliderSph, &this->actor, &sJntSphInit, this->colliderSphElements); this->colliderSph.elements[0].dim.worldSphere.radius = 0; this->colliderSph.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; @@ -203,7 +203,7 @@ void func_80B2C910(Vec3f* vec, GlobalContext* globalCtx) { } Math_Vec3f_ScaleAndStore(&sp20, temp_f0, vec); } else { - Math_Vec3f_Copy(vec, &D_801D15B0); + Math_Vec3f_Copy(vec, &gZeroVec3f); } } @@ -312,7 +312,7 @@ void func_80B2CD64(EnPoh* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer > 280.0f) { func_80B2CB60(this); } else if ((this->unk_18E == 0) && (this->actor.xzDistToPlayer < 140.0f) && - !Actor_IsLinkFacingActor(&this->actor, 0x2AAA, globalCtx)) { + !Player_IsFacingActor(&this->actor, 0x2AAA, globalCtx)) { func_80B2CEC8(this); } @@ -325,14 +325,14 @@ void func_80B2CEC8(EnPoh* this) { Animation_MorphToLoop(&this->skelAnime, &D_060001A8, -6.0f); this->unk_18E = 12; this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); this->actionFunc = func_80B2CF28; } void func_80B2CF28(EnPoh* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_KANTERA); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_KANTERA); if (this->unk_18E != 0) { this->unk_18E--; } @@ -355,7 +355,7 @@ void func_80B2CFF8(EnPoh* this) { func_800BE504(&this->actor, &this->colliderCylinder); this->colliderCylinder.base.acFlags &= ~AC_ON; this->actor.speedXZ = 5.0f; - func_800BCB70(&this->actor, 0x4000, 255, 0, 16); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); this->actionFunc = func_80B2D07C; } @@ -388,7 +388,7 @@ void func_80B2D140(EnPoh* this, GlobalContext* globalCtx) { } if ((this->skelAnime.playSpeed < 0.5f) && (this->actor.xzDistToPlayer < 280.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); this->skelAnime.playSpeed = 1.0f; } } @@ -426,13 +426,13 @@ void func_80B2D300(EnPoh* this, GlobalContext* globalCtx) { sp44.z = (Math_CosS(sp38) * 23.0f) + this->actor.world.pos.z; } sp36 = (this->unk_18E * 10) + 80; - func_800B3030(globalCtx, &sp44, &D_80B2F710, &D_801D15B0, sp36, 0, 2); + func_800B3030(globalCtx, &sp44, &D_80B2F710, &gZeroVec3f, sp36, 0, 2); sp44.x = (2.0f * this->actor.world.pos.x) - sp44.x; sp44.z = (2.0f * this->actor.world.pos.z) - sp44.z; - func_800B3030(globalCtx, &sp44, &D_80B2F710, &D_801D15B0, sp36, 0, 2); + func_800B3030(globalCtx, &sp44, &D_80B2F710, &gZeroVec3f, sp36, 0, 2); sp44.x = this->actor.world.pos.x; sp44.z = this->actor.world.pos.z; - func_800B3030(globalCtx, &sp44, &D_80B2F710, &D_801D15B0, sp36, 0, 2); + func_800B3030(globalCtx, &sp44, &D_80B2F710, &gZeroVec3f, sp36, 0, 2); } else if (this->unk_18E == 28) { func_80B2DC50(this, globalCtx); } else if (this->unk_18E > 18) { @@ -447,7 +447,7 @@ void func_80B2D300(EnPoh* this, GlobalContext* globalCtx) { } if (this->unk_18E == 18) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); } } @@ -493,8 +493,8 @@ void func_80B2D76C(EnPoh* this) { this->unk_192 = 0x2000; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DISAPPEAR); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DISAPPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); this->colliderCylinder.base.acFlags &= ~AC_ON; this->actionFunc = func_80B2D7D4; } @@ -523,8 +523,8 @@ void func_80B2D924(EnPoh* this) { this->unk_18C = 0; this->unk_192 = 0x2000; this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); this->colliderCylinder.base.acFlags &= ~AC_ON; this->actionFunc = func_80B2D980; } @@ -596,7 +596,7 @@ void func_80B2DD2C(EnPoh* this, GlobalContext* globalCtx) { func_80B2E0B0(this); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); } @@ -638,7 +638,7 @@ void func_80B2E0B0(EnPoh* this) { this->actor.home.pos.y = this->actor.world.pos.y; this->actor.scale.x = 0.0f; this->actor.scale.y = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_METAL_BOX_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_METAL_BOX_BOUND); this->actionFunc = func_80B2E180; } @@ -652,7 +652,7 @@ void func_80B2E180(EnPoh* this, GlobalContext* globalCtx) { void func_80B2E1D8(EnPoh* this) { this->actor.home.pos.y = this->actor.world.pos.y; - Actor_SetHeight(&this->actor, -10.0f); + Actor_SetFocus(&this->actor, -10.0f); this->unk_18E = 200; this->unk_18D = 32; this->actor.flags |= 1; @@ -672,7 +672,7 @@ void func_80B2E230(EnPoh* this, GlobalContext* globalCtx) { return; } - func_800B8A1C(&this->actor, globalCtx, GI_MAX, 35.0f, 60.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 35.0f, 60.0f); this->actor.world.pos.y = (Math_SinS(this->unk_18D * 0x800) * 5.0f) + this->actor.home.pos.y; if (this->unk_18D) { this->unk_18D--; @@ -682,14 +682,14 @@ void func_80B2E230(EnPoh* this, GlobalContext* globalCtx) { this->unk_18D = 32; } - Actor_SetHeight(&this->actor, -10.0f); + Actor_SetFocus(&this->actor, -10.0f); Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 100, 0, 150, this->unk_197 * (40.0f / 51.0f)); } void func_80B2E3B0(EnPoh* this) { func_801A7328(&this->actor.projectedPos, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); this->actionFunc = func_80B2E3F8; } @@ -705,9 +705,9 @@ void func_80B2E438(EnPoh* this, GlobalContext* globalCtx) { this->colliderCylinder.base.acFlags &= ~AC_HIT; if (!Actor_ApplyDamage(&this->actor)) { Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); } else if (this->actor.colChkInfo.damage != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DAMAGE); } if (this->actor.colChkInfo.damageEffect != 14) { @@ -817,7 +817,7 @@ void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { func_80B2E438(this, globalCtx); func_80B2E55C(this); this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if ((this->actionFunc == func_80B2CF28) && (this->unk_18E < 10)) { this->actor.flags |= 0x1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); @@ -830,7 +830,7 @@ void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); - Actor_SetHeight(&this->actor, 42.0f); + Actor_SetFocus(&this->actor, 42.0f); if ((this->actionFunc != func_80B2D07C) && (this->actionFunc != func_80B2D628)) { if (this->actionFunc == func_80B2DB44) { diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h index a4b721f5de..4008ba4e15 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h @@ -10,7 +10,14 @@ typedef void (*EnRacedogActionFunc)(struct EnRacedog*, GlobalContext*); typedef struct EnRacedog { /* 0x0000 */ Actor actor; /* 0x0144 */ EnRacedogActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x180]; + /* 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]; } EnRacedog; // size = 0x2C8 extern const ActorInit En_Racedog_InitVars; 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 a1a88ecbd1..8f15008106 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 @@ -4,7 +4,9 @@ * Description: Ikana Graveyard - Circle of Stalchildren */ +#include "overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h" #include "z_en_rail_skb.h" +#include "objects/object_skb/object_skb.h" #define FLAGS 0x00000015 @@ -15,23 +17,39 @@ void EnRailSkb_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRailSkb_Update(Actor* thisx, GlobalContext* globalCtx); void EnRailSkb_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B70FA0(EnRailSkb* this); void func_80B70FF8(EnRailSkb* this, GlobalContext* globalCtx); void func_80B710E4(EnRailSkb* this, GlobalContext* globalCtx); void func_80B7114C(EnRailSkb* this, GlobalContext* globalCtx); void func_80B7123C(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B712FC(EnRailSkb* this); void func_80B71314(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B71354(EnRailSkb* this); void func_80B713A4(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B71488(EnRailSkb* this); void func_80B714D8(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B7151C(EnRailSkb* this); void func_80B715AC(EnRailSkb* this, GlobalContext* globalCtx); void func_80B716A8(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B717C8(EnRailSkb* this); void func_80B717E0(EnRailSkb* this, GlobalContext* globalCtx); void func_80B718C4(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B71910(EnRailSkb* this); void func_80B71954(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B71A08(EnRailSkb* this); void func_80B71A58(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B71B6C(EnRailSkb* this); void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B71D8C(EnRailSkb* this, GlobalContext* globalCtx, EnRailSkbUnkFunc unkFunc); void func_80B71EA8(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B72100(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B723F8(EnRailSkb* this); +void func_80B72430(EnRailSkb* this, GlobalContext* globalCtx, s32 arg2); +void func_80B726B4(EnRailSkb* this, GlobalContext* globalCtx); +void func_80B72830(EnRailSkb* this, s16 arg1); +s32 func_80B7285C(EnRailSkb* this); -#if 0 const ActorInit En_Rail_Skb_InitVars = { ACTOR_EN_RAIL_SKB, ACTORCAT_ENEMY, @@ -44,29 +62,57 @@ const ActorInit En_Rail_Skb_InitVars = { (ActorFunc)EnRailSkb_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_80B73408[2] = { +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 ColliderJntSphElementInit sJntSphElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 15, { { 0, 0, 0 }, 10 }, 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, + }, { 1, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B73450 = { - { COLTYPE_HIT6, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_80B73408, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B73460 = { 2, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 2, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80B7346C = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0xD), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -101,122 +147,1004 @@ static DamageTable D_80B7346C = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B73490[] = { +void func_80B708C0(EnRailSkb* this, GlobalContext* globalCtx) { + static s32 D_80B7348C = 0; + Path* path = &globalCtx->setupPathList[ENRAILSKB_GET_FF00(&this->actor)]; + Vec3f sp70; + s32 phi_a3; + + this->unk_230 = Lib_SegmentedToVirtual(path->points); + this->unk_2E0 = D_80B7348C; + this->unk_2E8 = path->count; + + if (D_80B7348C == 0) { + s32 i; + + for (i = 1; (i < this->unk_2E8) && (i < 10); i++) { + D_80B7348C++; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_RAIL_SKB, 0.0f, 0.0f, 0.0f, 0, 0, + 0, this->actor.params); + } + D_80B7348C = 0; + } + + this->actor.world.pos.x = this->unk_230[this->unk_2E0].x; + this->actor.world.pos.y = this->unk_230[this->unk_2E0].y; + this->actor.world.pos.z = this->unk_230[this->unk_2E0].z; + + if (this->unk_2E0 < (this->unk_2E8 - 1)) { + phi_a3 = this->unk_2E0 + 1; + } else { + phi_a3 = 0; + } + + sp70.x = this->unk_230[phi_a3].x; + sp70.y = this->unk_230[phi_a3].y; + sp70.z = this->unk_230[phi_a3].z; + + this->actor.world.rot.y = this->actor.shape.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &sp70); +} + +s32 func_80B70AB4(Vec2f arg0, Vec2f arg1) { + s32 phi_v1; + + if ((arg1.x * arg0.y) < (arg0.x * arg1.y)) { + phi_v1 = 1; + } else { + phi_v1 = -1; + } + return phi_v1; +} + +s32 func_80B70B04(EnRailSkb* this, Vec3f pos) { + s32 pad; + s32 temp_s3; + Vec2f sp60; + Vec2f sp58; + s32 ret = true; + s32 pad2; + s32 i = 0; + s32 j; + + sp60.x = this->unk_230[0].z - pos.z; + sp60.y = 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; + j = 1; + temp_s3 = func_80B70AB4(sp60, sp58); + + while (j != 0) { + i++; + + if (j < (this->unk_2E8 - 1)) { + j++; + } else { + j = 0; + } + + sp60.x = this->unk_230[i].z - pos.z; + sp60.y = 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; + + if (func_80B70AB4(sp60, sp58) != temp_s3) { + ret = false; + break; + } + } + + return ret; +} + +void func_80B70D24(EnRailSkb* this, GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + + while (actor != NULL) { + if ((actor->id == ACTOR_OBJ_HAKAISI) && func_80B70B04(this, actor->world.pos)) { + if (Flags_GetSwitch(globalCtx, (actor->params & 0xFF00) >> 8)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->unk_22C = (ObjHakaisi*)actor; + return; + } + actor = actor->next; + } + Actor_MarkForDeath(&this->actor); +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_STOP), }; -#endif +void EnRailSkb_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRailSkb* this = THIS; -extern ColliderJntSphElementInit D_80B73408[2]; -extern ColliderJntSphInit D_80B73450; -extern CollisionCheckInfoInit2 D_80B73460; -extern DamageTable D_80B7346C; -extern InitChainEntry D_80B73490[]; + func_80B708C0(this, globalCtx); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_0064E0, this->jointTable, + this->morphTable, 20); + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -extern UNK_TYPE D_060064E0; + if (Flags_GetSwitch(globalCtx, ENRAILSKB_GET_FF(&this->actor))) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B708C0.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->actor.speedXZ = 1.6f; + this->actor.hintId = 0x55; + this->unk_3F2 = 0; + this->unk_2E4 = -1; + this->unk_3FC = 0; + this->unk_3FA = 0; + this->unk_403 = 0; + this->unk_3FE = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B70AB4.s") + if (this->actor.parent == NULL) { + this->unk_3F4 = 1; + this->unk_3F6 = 1; + this->unk_3F8 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B70B04.s") + if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.unk_12 == 0)) { + this->actor.flags |= 0x100000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B70D24.s") + func_80B70FA0(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/EnRailSkb_Init.s") +void EnRailSkb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRailSkb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/EnRailSkb_Destroy.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B70FA0.s") +void func_80B70FA0(EnRailSkb* this) { + this->unk_3F2 = 0; + if (this->actionFunc != func_80B716A8) { + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + } + this->actionFunc = func_80B70FF8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B70FF8.s") +void func_80B70FF8(EnRailSkb* this, GlobalContext* globalCtx) { + s16 temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B710AC.s") + if (this->actor.xzDistToPlayer < 65.0f) { + if ((ABS_ALT(temp_v0) < 0x2AAA) && (this->unk_3F2 >= 6)) { + func_80B71354(this); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B710E4.s") + if (this->unk_3F2 < 6) { + this->unk_3F2++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71114.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 1, 0x71C, 0xB6); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B7114C.s") +void func_80B710AC(EnRailSkb* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = func_80B710E4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71228.s") +void func_80B710E4(EnRailSkb* this, GlobalContext* globalCtx) { + if (this->actor.colorFilterTimer == 0) { + func_80B70FA0(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B7123C.s") +void func_80B71114(EnRailSkb* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = func_80B7114C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B712FC.s") +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->actor.colChkInfo.health != 0) { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + this->unk_402 |= 1; + func_80B712FC(this); + } else { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); + func_80B71488(this); + } + } else if (this->unk_3F0 == 1) { + func_80B726B4(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71314.s") +void func_80B71228(EnRailSkb* this) { + this->actionFunc = func_80B7123C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71354.s") +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->actor.colChkInfo.health != 0) { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + this->unk_402 |= 1; + func_80B712FC(this); + } else { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); + func_80B71488(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B713A4.s") +void func_80B712FC(EnRailSkb* this) { + this->unk_3F2 = 0; + this->actionFunc = func_80B71314; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71488.s") +void func_80B71314(EnRailSkb* this, GlobalContext* globalCtx) { + if (this->unk_3F2 >= 6) { + func_80B70FA0(this); + } else { + this->unk_3F2++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B714D8.s") +void func_80B71354(EnRailSkb* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80B713A4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B7151C.s") +void func_80B713A4(EnRailSkb* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if ((this->actor.xzDistToPlayer > 65.0f) || (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN)) { + func_80B70FA0(this); + } else { + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B715AC.s") + if (this->actor.xzDistToPlayer > 65.0f) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 1, 0x71C, 0xB6); + } else { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xAAA, 0xB6); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71650.s") +void func_80B71488(EnRailSkb* this) { + this->unk_402 |= 0x40; + this->actor.flags &= ~1; + if (this->unk_2E0 != 0) { + this->unk_2E4 = this->unk_2E0 - 1; + } else { + this->unk_2E4 = this->unk_2E8 - 1; + } + this->actionFunc = func_80B714D8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B716A8.s") +void func_80B714D8(EnRailSkb* this, GlobalContext* globalCtx) { + if (this->actor.draw != NULL) { + this->actor.draw = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B717C8.s") + if (this->unk_2E0 == this->unk_2E4) { + func_80B7151C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B717E0.s") +void func_80B7151C(EnRailSkb* this) { + this->actor.shape.yOffset = -5000.0f; + this->actor.colChkInfo.health = 2; + this->unk_402 = 0; + this->actor.flags |= 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); + this->actionFunc = func_80B715AC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B718B0.s") +void func_80B715AC(EnRailSkb* this, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 0.5f, 500.0f, 10.0f) == 0.0f) { + func_80B70FA0(this); + } else { + func_80B72430(this, globalCtx, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B718C4.s") + if (this->actor.shape.shadowAlpha != 255) { + if (this->actor.shape.shadowAlpha >= 235) { + this->actor.shape.shadowAlpha = 255; + } else { + this->actor.shape.shadowAlpha += 20; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71910.s") +void func_80B71650(EnRailSkb* this) { + this->unk_3FE = 0; + if (this->actionFunc != func_80B70FF8) { + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + } + this->actionFunc = func_80B716A8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71954.s") +void func_80B716A8(EnRailSkb* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_3FE = 1; + func_80B71D8C(this, globalCtx, func_80B723F8); + if (!func_80B7285C(this)) { + func_801518B0(globalCtx, 0x13EC, &this->actor); + this->unk_400 = 0x13EC; + func_80B72830(this, 1); + } else { + func_801518B0(globalCtx, 0x13F5, &this->actor); + this->unk_400 = 0x13F5; + } + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); + func_80B717C8(this); + } else if ((this->actor.xzDistToPlayer < 100.0f) && !(this->collider.base.acFlags & AC_HIT)) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 1, 0x71C, 0xB6); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71A08.s") +void func_80B717C8(EnRailSkb* this) { + this->unk_3F2 = 0; + this->actionFunc = func_80B717E0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71A58.s") +void func_80B717E0(EnRailSkb* this, GlobalContext* globalCtx) { + this->unk_3FA = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71B6C.s") + switch (Message_GetState(&globalCtx->msgCtx)) { + case 0: + case 1: + case 2: + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71BB8.s") + case 3: + if ((globalCtx->gameplayFrames % 2) != 0) { + this->unk_3FA = 1; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71D8C.s") + case 4: + func_80B72100(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71DF0.s") + case 5: + func_80B71F3C(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71EA8.s") + case 6: + if (func_80147624(globalCtx)) { + func_80B71650(this); + } + break; + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0x71C, 0xB6); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B71F3C.s") +void func_80B718B0(EnRailSkb* this) { + this->actionFunc = func_80B718C4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B72100.s") +void func_80B718C4(EnRailSkb* this, GlobalContext* globalCtx) { + func_80B70D24(this, globalCtx); + if (this->actor.parent == NULL) { + if (this->unk_22C != NULL) { + ObjHakaisi* hakasi = this->unk_22C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B72190.s") + hakasi->unk_198 = 1; + } + } + func_80B71910(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B723F8.s") +void func_80B71910(EnRailSkb* this) { + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80B71954; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B72430.s") +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); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B725C0.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, sp36, 1, 0x71C, 0xB6); + this->actor.world.rot = this->actor.shape.rot; + if (sp30 < 80.0f) { + func_80B71A08(this); + } + Actor_MoveWithGravity(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B726B4.s") +void func_80B71A08(EnRailSkb* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80B71A58; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B72830.s") +void func_80B71A58(EnRailSkb* this, GlobalContext* globalCtx) { + s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B7285C.s") + 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--; + } else { + this->unk_22C->actor.colChkInfo.health--; + func_80B71B6C(this); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B72880.s") + if (Animation_OnFrame(&this->skelAnime, 3.0f)) { + if (this->unk_2E8 < this->unk_22C->actor.colChkInfo.health) { + this->unk_22C->actor.colChkInfo.health--; + } else { + this->unk_22C->actor.colChkInfo.health--; + func_80B71B6C(this); + } + } + Math_SmoothStepToS(&this->actor.shape.rot.y, sp36, 1, 0x71C, 0xB6); + this->actor.world.rot = this->actor.shape.rot; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B72970.s") +void func_80B71B6C(EnRailSkb* this) { + this->unk_3F2 = 10; + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80B71BB8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/EnRailSkb_Update.s") +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); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B72E88.s") + if (this->unk_3F2 > 0) { + this->unk_3F2--; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/func_80B7302C.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, + Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->actor.world.pos), 1, 0x71C, 0xB6); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rail_Skb/EnRailSkb_Draw.s") + if ((this->actor.bgCheckFlags & 1) && (this->unk_22C->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); + } + + if (this->actor.bgCheckFlags & 2) { + Actor_MarkForDeath(&this->actor); + return; + } + + if ((sp34 < 50.0f) && (this->actor.bgCheckFlags & 1)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + this->actor.velocity.y = 10.0f; + + for (i = 0; i < 4; i++) { + func_80B72430(this, globalCtx, 0); + } + } +} + +void func_80B71D8C(EnRailSkb* this, GlobalContext* globalCtx, EnRailSkbUnkFunc unkFunc) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; + + while (actor != NULL) { + if (actor->id == ACTOR_EN_RAIL_SKB) { + unkFunc((EnRailSkb*)actor); + } + actor = actor->next; + } +} + +void func_80B71DF0(EnRailSkb* this) { + if (this->actionFunc == func_80B714D8) { + this->actor.shape.yOffset = -5000.0f; + this->actor.colChkInfo.health = 2; + this->unk_402 = 0; + this->actor.flags |= 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; + } + + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + this->actionFunc = func_80B71EA8; +} + +void func_80B71EA8(EnRailSkb* this, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 0.5f, 500.0f, 10.0f) != 0.0f) { + func_80B72430(this, globalCtx, 1); + } + + if (this->actor.shape.shadowAlpha != 255) { + if (this->actor.shape.shadowAlpha >= 235) { + this->actor.shape.shadowAlpha = 255; + } else { + this->actor.shape.shadowAlpha += 20; + } + } +} + +void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx) { + if (((this->unk_400 == 0x13ED) || (this->unk_400 == 0x13F5)) && (this->unk_3F2 != 1)) { + func_80B71D8C(this, globalCtx, func_80B71DF0); + func_80B717C8(this); + this->unk_3F2 = 1; + } + + if (func_80147624(globalCtx)) { + switch (this->unk_400) { + case 0x13EC: + func_801518B0(globalCtx, 0x13ED, &this->actor); + this->unk_400 = 0x13ED; + break; + + case 0x13ED: + func_801518B0(globalCtx, 0x13EE, &this->actor); + this->unk_400 = 0x13EE; + break; + + case 0x13EE: + func_801518B0(globalCtx, 0x13EF, &this->actor); + this->unk_400 = 0x13EF; + break; + + case 0x13EF: + case 0x13F5: + func_801518B0(globalCtx, 0x13F0, &this->actor); + this->unk_400 = 0x13F0; + break; + + case 0x13F1: + func_801518B0(globalCtx, 0x13F2, &this->actor); + this->unk_400 = 0x13F2; + break; + + case 0x13F2: + if (this->unk_3FC == 1) { + func_801518B0(globalCtx, 0x13F4, &this->actor); + this->unk_400 = 0x13F4; + } else { + func_801477B4(globalCtx); + func_80B71D8C(this, globalCtx, func_80B71650); + } + break; + + case 0x13F3: + func_801518B0(globalCtx, 0x13F2, &this->actor); + this->unk_400 = 0x13F2; + this->unk_3FC = 1; + break; + + case 0x13F4: + func_801477B4(globalCtx); + func_80B71D8C(this, globalCtx, func_80B718B0); + break; + } + } +} + +void func_80B72100(EnRailSkb* this, GlobalContext* globalCtx) { + if (func_80147624(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + func_801518B0(globalCtx, 0x13F1, &this->actor); + this->unk_400 = 0x13F1; + } else { + func_8019F208(); + func_801518B0(globalCtx, 0x13F3, &this->actor); + this->unk_400 = 0x13F3; + } + } +} + +void func_80B72190(EnRailSkb* this, GlobalContext* globalCtx) { + EnRailSkb* parent; + Vec3f sp38; + s32 pad; + s16 sp32; + + if ((this->actionFunc != func_80B714D8) && + (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 15.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_WALK); + } + + if (this->actor.parent == NULL) { + this->unk_3F4 = this->unk_3F6; + this->unk_3F6 = 1; + + if ((this->actionFunc == func_80B713A4) || (this->actionFunc == func_80B710E4) || + (this->actionFunc == func_80B7114C) || (this->actionFunc == func_80B7123C) || + (this->actionFunc == func_80B717E0)) { + this->unk_3F6 = 0; + } + + if (this->unk_3F4 == 0) { + return; + } + } else { + parent = (EnRailSkb*)this->actor.parent; + + if ((this->actionFunc == func_80B713A4) || (this->actionFunc == func_80B710E4) || + (this->actionFunc == func_80B7114C) || (this->actionFunc == func_80B7123C) || + (this->actionFunc == func_80B717E0)) { + parent->unk_3F6 = 0; + } + + if (parent->unk_3F4 == 0) { + return; + } + } + + if ((this->actionFunc != func_80B71EA8) && (this->actionFunc != func_80B71954) && + (this->actionFunc != func_80B71A58) && (this->actionFunc != func_80B71BB8)) { + sp38.x = this->unk_230[this->unk_2E0].x; + sp38.y = this->unk_230[this->unk_2E0].y; + sp38.z = this->unk_230[this->unk_2E0].z; + sp32 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp38); + + if (Math_Vec3f_DistXZ(&this->actor.world.pos, &sp38) > 100.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, sp32, 10, 0x3000, 0x100); + } else if (this->unk_2E0 < (this->unk_2E8 - 1)) { + this->unk_2E0++; + } else { + this->unk_2E0 = 0; + } + Actor_MoveWithGravity(&this->actor); + } +} + +void func_80B723F8(EnRailSkb* this) { + this->actor.flags &= ~(4 | 1); + this->actor.flags |= (8 | 1); + this->actor.flags |= 0x100000; + this->actor.hintId = 0xFF; + this->actor.textId = 0; +} + +void func_80B72430(EnRailSkb* 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 }; + s16 sp42; + s32 pad; + + if ((globalCtx->gameplayFrames & arg2) == 0) { + sp42 = Rand_Next(); + + sp5C.x += 15.0f * Math_SinS(sp42); + sp5C.y = this->actor.floorHeight; + sp5C.z += 15.0f * Math_CosS(sp42); + + 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_800BBFB0(globalCtx, &sp5C, 10.0f, 1, 150, 0, 1); + } +} + +void func_80B725C0(EnRailSkb* this, GlobalContext* globalCtx) { + if (this->unk_3F0 > 0) { + this->unk_3F0--; + } + + if (this->actionFunc != func_80B7114C) { + if (this->unk_3F0 < 20) { + if (this->actionFunc == func_80B7123C) { + Math_SmoothStepToF(&this->unk_2F0, 0.0f, 0.5f, 0.03f, 0.0f); + } else { + Math_SmoothStepToF(&this->unk_2F0, 0.0f, 0.5f, 0.01f, 0.0f); + } + this->unk_2EC = this->unk_3F0 * 0.05f; + } else { + Math_SmoothStepToF(&this->unk_2F0, 0.5f, 0.1f, 0.02f, 0.0f); + } + } +} + +void func_80B726B4(EnRailSkb* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_80B734B0 = { 170, 255, 255, 255 }; + static Color_RGBA8 D_80B734B4 = { 200, 200, 255, 255 }; + static Vec3f D_80B734B8 = { 0.0f, -1.0f, 0.0f }; + Vec3f sp84; + s32 i; + s32 end; + s16 yaw; + + if (this->unk_402 & 2) { + end = ARRAY_COUNT(this->unk_234) - 1; + } else { + end = ARRAY_COUNT(this->unk_234); + } + + 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]); + + 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); + } +} + +void func_80B72830(EnRailSkb* this, s16 arg1) { + if (this->actor.parent == NULL) { + this->unk_3F8 = arg1; + } else { + ((EnRailSkb*)this->actor.parent)->unk_3F8 = arg1; + } +} + +s32 func_80B7285C(EnRailSkb* this) { + s32 phi_v1; + + if (this->actor.parent == NULL) { + phi_v1 = this->unk_3F8; + } else { + phi_v1 = ((EnRailSkb*)this->actor.parent)->unk_3F8; + } + return phi_v1; +} + +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.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.hintId = 0x55; + this->actor.textId = 0; + func_80B70FA0(this); + } + } +} + +void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + + if ((this->actionFunc == func_80B714D8) || (this->actionFunc == func_80B7123C) || + (this->actionFunc == func_80B715AC) || (this->actionFunc == func_80B71954) || + (this->actionFunc == func_80B71A58) || (this->actionFunc == func_80B71BB8) || (this->unk_3FE == 1)) { + return; + } + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->actionFunc == func_80B7114C) { + switch (this->actor.colChkInfo.damageEffect) { + case 1: + case 3: + case 4: + case 12: + case 13: + return; + + default: + if (this->unk_3F0 >= 2) { + func_80B726B4(this, globalCtx); + } + this->unk_3F0 = 0; + break; + } + } + + if ((Actor_ApplyDamage(&this->actor) == 0) && (this->actor.colChkInfo.damageEffect != 3) && + (this->actor.colChkInfo.damageEffect != 4)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); + func_80B71488(this); + return; + } + + 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; + Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); + func_80B710AC(this); + break; + + case 1: + Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); + func_80B710AC(this); + break; + + case 2: + this->unk_3F0 = 80; + this->unk_403 = 0; + this->unk_2EC = 1.0f; + this->unk_2F0 = 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); + this->unk_402 |= 1; + func_80B712FC(this); + break; + + case 3: + if (this->actor.colChkInfo.health != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + this->unk_3F0 = 80; + } else { + this->unk_3F0 = 3; + } + this->unk_403 = 11; + this->unk_2EC = 1.0f; + this->unk_2F0 = 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; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + func_80B71228(this); + break; + + case 12: + case 14: + this->unk_402 |= 1; + + case 15: + if ((player->swordAnimation == 4) || (player->swordAnimation == 11) || (player->swordAnimation == 22) || + (player->swordAnimation == 23)) { + this->unk_402 |= 1; + } + + 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); + func_80B712FC(this); + break; + + default: + break; + } + } + + if (this->actionFunc == func_80B713A4) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->actionFunc != func_80B71314) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void EnRailSkb_Update(Actor* thisx, GlobalContext* globalCtx) { + EnRailSkb* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80B72190(this, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 60.0f, 5); + func_80B72970(this, globalCtx); + + if ((this->actionFunc != func_80B710E4) && (this->actionFunc != func_80B7114C) && + (this->actionFunc != func_80B7123C)) { + SkelAnime_Update(&this->skelAnime); + } + + func_80B72880(this, globalCtx); + func_80B725C0(this, globalCtx); +} + +s32 EnRailSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnRailSkb* this = THIS; + s16 abs; + + if (limbIndex == 11) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + abs = fabsf(Math_SinS(globalCtx->state.frames * 6000) * 95.0f) + 160.0f; + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, abs, abs, abs, 255); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else if (limbIndex == 10) { + Vec3f sp24 = { 0.0f, 1000.0f, 0.0f }; + + Matrix_MultiplyVector3fByState(&sp24, &this->actor.focus.pos); + } else if ((limbIndex == 12) && (this->unk_3FA == 1)) { + Matrix_InsertZRotation_s(1820, MTXMODE_APPLY); + } + + if (((limbIndex == 11) || (limbIndex == 12)) && (this->unk_402 & 2)) { + *dList = NULL; + } + + return false; +} + +void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80B734D0 = { 800.0f, 1200.0f, 0.0f }; + EnRailSkb* this = THIS; + + if (!(this->unk_402 & 0x80)) { + Collider_UpdateSpheres(limbIndex, &this->collider); + + if ((limbIndex == 11) && (this->unk_402 & 1) && !(this->unk_402 & 2)) { + Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); + this->unk_402 |= 2; + } else if ((this->unk_402 & 0x40) && ((limbIndex != 11) || !(this->unk_402 & 1)) && (limbIndex != 12)) { + Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); + } + + if (this->unk_3F0 != 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++; + } else if ((limbIndex == 11) && !(this->unk_402 & 2)) { + Matrix_MultiplyVector3fByState(&D_80B734D0, &this->unk_234[this->unk_2DC]); + this->unk_2DC++; + } + } + } +} + +void EnRailSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnRailSkb* this = THIS; + + this->unk_2DC = 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->unk_402 & 0x40) && !(this->unk_402 & 0x80)) { + 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 90569ea826..23202ef199 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 @@ -6,12 +6,40 @@ struct EnRailSkb; typedef void (*EnRailSkbActionFunc)(struct EnRailSkb*, GlobalContext*); +typedef void (*EnRailSkbUnkFunc)(struct EnRailSkb*); + +#define ENRAILSKB_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) +#define ENRAILSKB_GET_FF(thisx) ((thisx)->params & 0xFF) typedef struct EnRailSkb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xE4]; - /* 0x0228 */ EnRailSkbActionFunc actionFunc; - /* 0x022C */ char unk_22C[0x1D8]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElements[2]; + /* 0x1E4 */ SkelAnime skelAnime; + /* 0x228 */ EnRailSkbActionFunc actionFunc; + /* 0x22C */ ObjHakaisi* unk_22C; + /* 0x230 */ Vec3s* unk_230; + /* 0x234 */ Vec3f unk_234[14]; + /* 0x2DC */ s32 unk_2DC; + /* 0x2E0 */ s32 unk_2E0; + /* 0x2E4 */ s32 unk_2E4; + /* 0x2E8 */ s32 unk_2E8; + /* 0x2EC */ f32 unk_2EC; + /* 0x2F0 */ f32 unk_2F0; + /* 0x2F4 */ Vec3s jointTable[20]; + /* 0x36C */ Vec3s morphTable[20]; + /* 0x3E4 */ UNK_TYPE1 unk3E4[0xC]; + /* 0x3F0 */ s16 unk_3F0; + /* 0x3F2 */ s16 unk_3F2; + /* 0x3F4 */ s16 unk_3F4; + /* 0x3F6 */ s16 unk_3F6; + /* 0x3F8 */ s16 unk_3F8; + /* 0x3FA */ s16 unk_3FA; + /* 0x3FC */ s16 unk_3FC; + /* 0x3FE */ s16 unk_3FE; + /* 0x400 */ u16 unk_400; + /* 0x402 */ u8 unk_402; + /* 0x403 */ u8 unk_403; } 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 6b1d57ea80..16b8d4fe6d 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -212,14 +212,14 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_402 = gSaveContext.time; this->unk_404 = 0; this->unk_3F8 = 0; - this->unk_400 = 0; + this->textId = 0; this->unk_3FA = 0; if (this->actor.parent == NULL) { this->unk_3EC = 1; this->unk_3EE = 1; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 28.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060053E8, &D_0600ABE0, this->jointTable, this->morphTable, 26); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -239,7 +239,7 @@ void EnRailgibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80BA57A8(EnRailgibud* this) { this->actor.speedXZ = 0.6f; - func_800BDC5C(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); this->actionFunc = func_80BA57F8; } @@ -283,11 +283,11 @@ void func_80BA57F8(EnRailgibud* this, GlobalContext* globalCtx) { } else { this->unk_298 = 0; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80BA59F0(EnRailgibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); this->actionFunc = func_80BA5A34; } @@ -300,14 +300,14 @@ void func_80BA5A34(EnRailgibud* this, GlobalContext* globalCtx) { player->actor.freezeTimer = 60; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); func_80BA5AF0(this); } func_80BA6B9C(this, globalCtx); } void func_80BA5AF0(EnRailgibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); this->actor.speedXZ = 0.4f; if (this->actionFunc == func_80BA5A34) { this->unk_3F2 = 80; @@ -325,7 +325,7 @@ void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx) { this->actor.world.rot = this->actor.shape.rot; Math_SmoothStepToS(&this->unk_3E2, 0, 1, 0x64, 0); Math_SmoothStepToS(&this->unk_3E8, 0, 1, 0x64, 0); - if (func_80BA6D10(this, globalCtx) && Actor_IsActorFacingLink(&this->actor, 0x38E3)) { + if (func_80BA6D10(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { if ((this->unk_3F4 == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { player->actor.freezeTimer = 0; if ((gSaveContext.playerForm == PLAYER_FORM_GORON) || (gSaveContext.playerForm == PLAYER_FORM_DEKU)) { @@ -339,7 +339,7 @@ void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx) { this->unk_3F2 = 60; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); } else { this->unk_3F2--; } @@ -355,14 +355,14 @@ void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((globalCtx->gameplayFrames & 95) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } void func_80BA5DBC(EnRailgibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); this->actor.flags &= ~1; this->unk_3F2 = 0; this->unk_3F0 = 0; @@ -380,9 +380,9 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { sp34 = func_80BA7088(this, globalCtx); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (sp34 == 1)) { this->unk_3F0 = 1; - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); } else if (!(player->stateFlags2 & 0x80)) { - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actor.flags |= 1; this->unk_3F0 = 2; this->unk_3F2 = 0; @@ -395,7 +395,7 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { sp32 = player->ageProperties->unk_92 + 0x6805; globalCtx->damagePlayer(globalCtx, -8); - func_800B8E58(&player->actor, sp32); + func_800B8E58(player, sp32); func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); this->unk_3F2 = 0; } else { @@ -403,7 +403,7 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); } if (!(player->stateFlags2 & 0x80) || (player->unk_B62 != 0)) { @@ -411,7 +411,7 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actor.flags |= 1; this->unk_3F0 = 2; this->unk_3F2 = 0; @@ -431,8 +431,8 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA6054(EnRailgibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 7); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->actor.speedXZ = -2.0f; this->actionFunc = func_80BA60B0; } @@ -453,7 +453,7 @@ void func_80BA60B0(EnRailgibud* this, GlobalContext* globalCtx) { void func_80BA6158(EnRailgibud* this) { this->unk_3F2 = 0; - func_800BDC5C(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); this->actionFunc = func_80BA61A0; } @@ -470,7 +470,7 @@ void func_80BA61A0(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA6284(EnRailgibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); this->actor.speedXZ = 0.4f; this->actionFunc = func_80BA62D4; } @@ -495,15 +495,15 @@ void func_80BA62D4(EnRailgibud* this, GlobalContext* globalCtx) { } if (func_80BA6D10(this, globalCtx)) { if ((gSaveContext.playerForm != PLAYER_FORM_GORON) && (gSaveContext.playerForm != PLAYER_FORM_DEKU) && - Actor_IsActorFacingLink(&this->actor, 0x38E3)) { + Actor_IsFacingPlayer(&this->actor, 0x38E3)) { func_80BA5AF0(this); } } } void func_80BA6440(EnRailgibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 7); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->unk_3F2 = 0; this->unk_3F4 = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; @@ -532,9 +532,9 @@ void func_80BA6584(EnRailgibud* this) { this->actor.world.rot.y = this->actor.shape.rot.y; this->unk_3F2 = 10; if (this->unk_3F6 != 0) { - func_800BCB70(&this->actor, 0, 0xC8, 0, 0x28); + Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } else { - func_800BCB70(&this->actor, 0, 0xC8, 0, 0x28); + Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } this->actionFunc = func_80BA6604; } @@ -554,9 +554,9 @@ void func_80BA6604(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA6664(EnRailgibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); this->actor.flags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); this->unk_3F2 = 0; this->actionFunc = func_80BA66C8; } @@ -611,7 +611,7 @@ void func_80BA6800(EnRailgibud* this, GlobalContext* globalCtx, s32 arg2) { 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 = D_801D15B0; + Vec3f sp74 = gZeroVec3f; s32 i; s32 pad; @@ -699,7 +699,7 @@ void func_80BA6DF8(EnRailgibud* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 15: - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (player->unk_ADC != 0) { this->unk_405 = player->unk_ADD; } @@ -720,7 +720,7 @@ void func_80BA6DF8(EnRailgibud* this, GlobalContext* globalCtx) { break; case 2: - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { func_80BA6664(this); } else { @@ -732,7 +732,7 @@ void func_80BA6DF8(EnRailgibud* this, GlobalContext* globalCtx) { break; case 4: - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { func_80BA6664(this); } else { @@ -790,7 +790,7 @@ s32 func_80BA7088(EnRailgibud* this, GlobalContext* globalCtx) { void func_80BA71E4(EnRailgibud* this, GlobalContext* globalCtx) { if ((this->actionFunc == func_80BA5B64) || (this->actionFunc == func_80BA62D4) || (this->actionFunc == func_80BA64AC)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } } @@ -854,28 +854,28 @@ void func_80BA7434(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA7578(EnRailgibud* this, GlobalContext* globalCtx) { - if ((this->unk_400 == 0) && (this->unk_3F8 == 0)) { - if (func_800B84D0(&this->actor, globalCtx)) { + if ((this->textId == 0) && (this->unk_3F8 == 0)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3FA = 1; func_801518B0(globalCtx, 0x13B2, &this->actor); - this->unk_400 = 0x13B2; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + this->textId = 0x13B2; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); this->actor.speedXZ = 0.0f; } else if (((this->actor.flags & 9) == 9) && !(this->collider.base.acFlags & AC_HIT)) { func_800B8614(&this->actor, globalCtx, 100.0f); } } else { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 5: if (func_80147624(globalCtx)) { func_801518B0(globalCtx, 0x13B3, &this->actor); - this->unk_400 = 0x13B3; + this->textId = 0x13B3; } break; case 6: if (func_80147624(globalCtx)) { - this->unk_400 = 0; + this->textId = 0; this->unk_3FA = 0; this->actor.speedXZ = 0.6f; } @@ -995,7 +995,7 @@ void func_80BA7B6C(EnRailgibud* this, GlobalContext* globalCtx) { this->unk_3FE = 99; this->actor.flags |= 0x100000; this->actor.flags |= 0x10; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 28.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060053E8, &D_0600ABE0, this->jointTable, this->morphTable, 26); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -1067,37 +1067,37 @@ s32 func_80BA7DC8(EnRailgibud* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.npcActions[sp2C]->unk0) { case 1: this->unk_3F0 = 9; - func_800BDC5C(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); break; case 2: this->unk_3F0 = 15; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_WEAKENED2); - func_800BDC5C(&this->skelAnime, sAnimations, 15); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_WEAKENED2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 15); break; case 3: this->unk_3F0 = 17; - func_800BDC5C(&this->skelAnime, sAnimations, 17); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 17); break; case 4: this->unk_3F0 = 18; - func_800BDC5C(&this->skelAnime, sAnimations, 18); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 18); break; case 5: this->unk_3F0 = 10; - func_800BDC5C(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (this->unk_3F0 == 15) { this->unk_3F0 = 16; - func_800BDC5C(&this->skelAnime, sAnimations, 16); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 16); } else if (this->unk_3F0 == 18) { this->unk_3F0 = 19; - func_800BDC5C(&this->skelAnime, sAnimations, 19); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 19); func_80BA7D14(this); } } @@ -1115,9 +1115,9 @@ s32 func_80BA7DC8(EnRailgibud* this, GlobalContext* globalCtx) { case 5: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (globalCtx->csCtx.frames < 280) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_WEAKENED1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_WEAKENED1); } } break; diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h index 35cb83cd2d..546a885b5b 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h @@ -41,7 +41,7 @@ typedef struct EnRailgibud { /* 0x03FA */ s16 unk_3FA; /* 0x03FC */ u16 unk_3FC; /* 0x03FE */ u16 unk_3FE; - /* 0x0400 */ u16 unk_400; + /* 0x0400 */ u16 textId; /* 0x0402 */ s16 unk_402; /* 0x0404 */ u8 unk_404; /* 0x0405 */ s8 unk_405; diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index be62210ea0..766d03070d 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -244,7 +244,7 @@ void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_808D4190(GlobalContext* globalCtx, EnRd* this, s32 arg2) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_ENEMY].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; while (actor != NULL) { if ((actor->id != ACTOR_EN_RD) || (this == (EnRd*)actor) || (actor->params < ENRD_GET_0)) { @@ -338,7 +338,7 @@ void func_808D43AC(EnRd* this, GlobalContext* globalCtx) { } if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -381,7 +381,7 @@ void func_808D4660(EnRd* this, GlobalContext* globalCtx) { } if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -424,14 +424,14 @@ void func_808D4868(EnRd* this, GlobalContext* globalCtx) { } if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } void func_808D49E4(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } this->unk_3E4++; @@ -483,7 +483,7 @@ void func_808D4B20(EnRd* this, GlobalContext* globalCtx) { } if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -499,7 +499,7 @@ void func_808D4B20(EnRd* this, GlobalContext* globalCtx) { void func_808D4CA8(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } this->actor.world.rot.y -= this->unk_3E4; @@ -537,7 +537,7 @@ void func_808D4E60(EnRd* this, GlobalContext* globalCtx) { } } else { if (this->actor.world.pos.y == this->actor.home.pos.y) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 50.0f, 0.3f, 2.0f, 0.3f) == 0.0f) { @@ -587,7 +587,7 @@ void func_808D506C(EnRd* this, GlobalContext* globalCtx) { func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); } this->unk_3ED = 60; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); } } else { func_808D53C0(this, globalCtx); @@ -599,7 +599,7 @@ void func_808D506C(EnRd* this, GlobalContext* globalCtx) { } if (!this->unk_3EE && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 45.0f) && - Actor_IsActorFacingLink(&this->actor, 0x38E3)) { + Actor_IsFacingPlayer(&this->actor, 0x38E3)) { player->actor.freezeTimer = 0; if ((player->transformation == PLAYER_FORM_GORON) || (player->transformation == PLAYER_FORM_DEKU)) { if (Actor_DistanceToPoint(&this->actor, &this->actor.home.pos) < 150.0f) { @@ -620,9 +620,9 @@ void func_808D506C(EnRd* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -670,9 +670,9 @@ void func_808D5440(EnRd* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -715,9 +715,9 @@ void func_808D56E4(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -786,7 +786,7 @@ void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 6000, 0); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); } this->unk_3EA--; @@ -794,7 +794,7 @@ void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { globalCtx->damagePlayer(globalCtx, -8); func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); this->unk_3EA = 20; - func_800B8E58(&player->actor, player->ageProperties->unk_92 + 0x6805); + func_800B8E58(player, player->ageProperties->unk_92 + 0x6805); } break; @@ -833,7 +833,7 @@ void func_808D5CCC(EnRd* this, GlobalContext* globalCtx) { func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); func_808D4FE0(this, globalCtx); } } @@ -842,7 +842,7 @@ void func_808D5D88(EnRd* this) { this->unk_3EF = 8; Animation_MorphToPlayOnce(&this->skelAnime, &D_06009900, -6.0f); this->actor.speedXZ = -2.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->unk_3EF = 8; this->actionFunc = func_808D5DF4; } @@ -919,7 +919,7 @@ void func_808D616C(EnRd* this) { } this->actor.flags |= 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->unk_3EF = 11; this->actionFunc = func_808D6200; } @@ -954,7 +954,7 @@ void func_808D6310(EnRd* this) { this->unk_3D6 = 300; this->actor.flags &= ~1; this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); this->actionFunc = func_808D6388; } @@ -969,7 +969,7 @@ void func_808D6388(EnRd* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_3D6 == 0) { if (!Flags_GetSwitch(globalCtx, this->unk_3DC & 0x7F)) { - Actor_SetSwitchFlag(globalCtx, this->unk_3DC & 0x7F); + Flags_SetSwitch(globalCtx, this->unk_3DC & 0x7F); } if (this->unk_3DE != 0) { @@ -985,7 +985,7 @@ void func_808D6388(EnRd* this, GlobalContext* globalCtx) { this->unk_3D6--; } } else if (Animation_OnFrame(&this->skelAnime, 33.0f) || Animation_OnFrame(&this->skelAnime, 40.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } } @@ -997,12 +997,12 @@ void func_808D64D0(EnRd* this) { if (gSaveContext.unk_3F58 != 0) { this->unk_3E9 = 1; this->unk_3E0 = 600; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIGHT_ARROW_HIT); - func_800BCB70(&this->actor, 0x8000, 0x80C8, 0, 255); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIGHT_ARROW_HIT); + Actor_SetColorFilter(&this->actor, 0x8000, 0x80C8, 0, 255); } else if (this->unk_3F0 == 1) { - func_800BCB70(&this->actor, 0, 0xC8, 0, 40); + Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 40); } else if (this->unk_3F0 == 12) { - func_800BCB70(&this->actor, 0, 0xC8, 0, 40); + Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 40); } this->actionFunc = func_808D65BC; } @@ -1016,7 +1016,7 @@ void func_808D65BC(EnRd* this, GlobalContext* globalCtx) { if (this->unk_3E0 != 0) { this->unk_3E0--; if (this->unk_3E0 >= 255) { - func_800BCB70(&this->actor, 0x8000, 0x80C8, 0, 255); + Actor_SetColorFilter(&this->actor, 0x8000, 0x80C8, 0, 255); } if (this->unk_3E0 == 0) { @@ -1074,7 +1074,7 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { return; } - func_800BE258(&this->actor, &this->collider.info); + Actor_SetDropFlag(&this->actor, &this->collider.info); if (player->unk_ADC != 0) { this->unk_3F1 = player->unk_ADD; @@ -1096,7 +1096,7 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { return; case 2: - func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); this->unk_3E6 = 180; this->unk_3E8 = 0; this->unk_3E9 = 0; @@ -1105,7 +1105,7 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { break; case 4: - func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); this->unk_3E6 = 60; this->unk_3E8 = 20; this->unk_3E9 = 0; @@ -1114,13 +1114,13 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { break; case 15: - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); this->unk_3E9 = 0; this->unk_3E0 = 0; break; case 14: - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); this->unk_3E9 = 0; this->unk_3E0 = 0; this->actor.colChkInfo.health = 0; @@ -1183,7 +1183,7 @@ void EnRd_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if ((this->unk_3EF != 10) && (this->actor.speedXZ != 0.0f)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } if ((this->actor.shape.rot.x == 0) && (this->unk_3EF != 10) && (this->actor.speedXZ != 0.0f)) { diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 07f3ca850a..baa7aadadc 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -108,9 +108,9 @@ void EnRecepgirl_Wait(EnRecepgirl* this, GlobalContext* globalCtx) { } } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { EnRecepgirl_SetupTalk(this); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2000)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) { func_800B8614(&this->actor, globalCtx, 60.0f); if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { this->actor.textId = 0x2367; // "... doesn't Kafei want to break off his engagement ... ?" @@ -148,13 +148,13 @@ void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { } } - temp_v0_2 = func_80152498(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&globalCtx->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; // hear directions again? EnRecepgirl_SetupWait(this); } else if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." - Actor_SetSwitchFlag(globalCtx, this->actor.params); + Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); if (gSaveContext.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index 96e688bb4c..f1c6e9a168 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -148,7 +148,7 @@ void EnRr_Init(Actor* thisx, GlobalContext* globalCtx) { } Collider_UpdateCylinder(&this->actor, &this->collider2); - Actor_SetHeight(&this->actor, this->actor.scale.y * 2000.0f); + Actor_SetFocus(&this->actor, this->actor.scale.y * 2000.0f); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if ((this->actor.params == ENRR_2) || (this->actor.params == ENRR_3)) { @@ -197,7 +197,7 @@ void func_808FA11C(EnRr* this) { this->unk_224 = 1.2750001f; this->unk_21C = 1.0f; this->actor.flags &= ~0x400; - func_800BCB70(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808FA19C(EnRr* this, GlobalContext* globalCtx) { @@ -207,15 +207,15 @@ void func_808FA19C(EnRr* this, GlobalContext* globalCtx) { this->collider1.base.colType = COLTYPE_HIT0; this->collider1.info.elemType = ELEMTYPE_UNK1; this->unk_21C = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->unk_234, 20, 2, this->actor.scale.y * 23.333334f, - this->actor.scale.y * 20.000002f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_234, 20, 2, this->actor.scale.y * 23.333334f, + this->actor.scale.y * 20.000002f); this->actor.flags |= 0x400; } } void func_808FA238(EnRr* this, f32 arg1) { this->actor.speedXZ = arg1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_WALK); } void func_808FA260(EnRr* this) { @@ -236,7 +236,7 @@ void func_808FA260(EnRr* this) { this->actionFunc = func_808FB088; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_UNARI); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_UNARI); } void func_808FA344(EnRr* this) { @@ -286,7 +286,7 @@ void func_808FA3F8(EnRr* this, Player* player) { } this->actionFunc = func_808FB1C0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SUISEN_DRINK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SUISEN_DRINK); } void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { @@ -313,7 +313,7 @@ void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { sp34 = false; } - if (sp34 && (func_80152498(&globalCtx->msgCtx) == 0)) { + if (sp34 && (Message_GetState(&globalCtx->msgCtx) == 0)) { func_801518B0(globalCtx, 0xF6, NULL); } @@ -331,7 +331,7 @@ void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { player->actor.world.pos.z += sp30 * Math_CosS(this->actor.shape.rot.y); func_800B8D50(globalCtx, &this->actor, sp30, this->actor.shape.rot.y, sp2C, sp38); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SUISEN_THROW); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SUISEN_THROW); } } @@ -344,7 +344,7 @@ void func_808FA6B8(EnRr* this) { } else { this->unk_1EC = 40; } - func_800BCB70(&this->actor, 0x4000, 255, 0, this->unk_1EC); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, this->unk_1EC); this->unk_1E6 = 20; this->unk_1F6 = 2500; @@ -360,7 +360,7 @@ void func_808FA6B8(EnRr* this) { } this->actionFunc = func_808FB398; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_DAMAGE); } void func_808FA7AC(EnRr* this) { @@ -405,7 +405,7 @@ void func_808FA910(EnRr* this) { this->unk_1E4 = 0; this->unk_214 = 0.0f; - func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); this->unk_210 = 0.0f; for (i = 0; i < ARRAY_COUNT(this->unk_324); i++) { @@ -415,7 +415,7 @@ void func_808FA910(EnRr* this) { } this->actionFunc = func_808FB42C; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_DEAD); this->actor.flags &= ~1; } @@ -465,7 +465,7 @@ s32 func_808FAA94(EnRr* this, GlobalContext* globalCtx) { return false; } - func_800BE258(&this->actor, &sp2C->info); + Actor_SetDropFlag(&this->actor, &sp2C->info); func_808FA4F4(this, globalCtx); func_808FA19C(this, globalCtx); @@ -481,8 +481,8 @@ s32 func_808FAA94(EnRr* this, GlobalContext* globalCtx) { func_808FA910(this); } } else if (this->actor.colChkInfo.damageEffect == 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); - func_800BCB70(&this->actor, 0, 255, 0, 80); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 80); this->unk_1EE = 80; func_808FA9CC(this); } else if (this->actor.colChkInfo.damageEffect == 3) { @@ -630,7 +630,7 @@ void func_808FB1C0(EnRr* this, GlobalContext* globalCtx) { func_8013ECE0(this->actor.xyzDistToPlayerSq, 120, 2, 120); if (!(this->unk_1E4 & 7)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_DEMO_EYE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEMO_EYE); } player->unk_AE8 = 0; @@ -720,8 +720,8 @@ void func_808FB42C(EnRr* this, GlobalContext* globalCtx) { sp74.x = this->actor.world.pos.x; sp74.y = this->actor.world.pos.y + 20.0f; sp74.z = this->actor.world.pos.z; - func_800B3030(globalCtx, &sp74, &D_801D15B0, &D_801D15B0, 100, 0, 0); - Audio_PlaySoundAtPosition(globalCtx, &sp74, 11, NA_SE_EN_EXTINCT); + func_800B3030(globalCtx, &sp74, &gZeroVec3f, &gZeroVec3f, 100, 0, 0); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &sp74, 11, NA_SE_EN_EXTINCT); } else { temp_f20 = this->actor.scale.y * 66.66667f; @@ -786,7 +786,7 @@ void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_1F0--; } - Actor_SetHeight(&this->actor, this->actor.scale.y * 2000.0f); + Actor_SetFocus(&this->actor, this->actor.scale.y * 2000.0f); func_808FAE50(this, globalCtx); if (!func_808FAA94(this, globalCtx)) { @@ -801,7 +801,7 @@ void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, this->collider1.dim.radius, 0.0f, 0x5D); func_808FB794(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index 3adecaad3f..78af19c644 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -37,7 +37,7 @@ extern Gfx D_06005458[]; static ActorAnimationEntry animations[] = { { &D_0600788C, 1.0f, 0.0f, 0.0f, 0x00, 0.0f } }; void func_80C25D40(EnRsn* this) { - func_800BDC5C(&this->skelAnime, animations, 0); + Actor_ChangeAnimation(&this->skelAnime, animations, 0); this->actionFunc = func_80C25D84; } @@ -47,7 +47,7 @@ void func_80C25D84(EnRsn* this, GlobalContext* globalCtx) { void EnRsn_Init(Actor* thisx, GlobalContext* globalCtx) { EnRsn* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06009220, &D_06009120, NULL, NULL, 0); this->actor.flags &= ~1; func_80C25D40(this); @@ -63,7 +63,7 @@ void EnRsn_Update(Actor* thisx, GlobalContext* globalCtx) { EnRsn* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); SkelAnime_Update(&this->skelAnime); func_800E9250(globalCtx, &this->actor, &this->unk1D8, &this->unk1DE, this->actor.focus.pos); } diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c index ba851d64d2..414e1123b4 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -5,17 +5,41 @@ */ #include "z_en_ruppecrow.h" +#include "objects/object_crow/object_crow.h" #define FLAGS 0x00004030 #define THIS ((EnRuppecrow*)thisx) +enum { + ENRUPPECROW_EFFECT_NONE = 0, + ENRUPPECROW_EFFECT_ICE = 10, + ENRUPPECROW_EFFECT_LIGHT = 20, +}; + void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx); void EnRuppecrow_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRuppecrow_Update(Actor* thisx, GlobalContext* globalCtx); void EnRuppecrow_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRuppecrow_HandleSong(EnRuppecrow*, GlobalContext*); +s32 EnRuppecrow_UpdateCollision(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_UpdateRupees(EnRuppecrow*); +void EnRuppecrow_UpdateDamage(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_HandleDeath(EnRuppecrow*); +void EnRuppecrow_FallToDespawn(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_ShatterIce(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_UpdatePosition(EnRuppecrow*, GlobalContext*); +s32 EnRuppecrow_CheckPlayedMatchingSong(GlobalContext*); +void EnRuppecrow_HandleSongCutscene(EnRuppecrow*, GlobalContext*); +s32 EnRuppecrow_ReachedPointClockwise(EnRuppecrow*, Path*, s32); +s32 EnRuppecrow_ReachedPointCounterClockwise(EnRuppecrow*, Path*, s32); +f32 EnRuppecrow_GetPointDirection(Path*, s32, PosRot*, Vec3s*); +s32 EnRuppecrow_CanSpawnBlueRupees(GlobalContext*); +void EnRuppecrow_SpawnRupee(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_FlyWhileDroppingRupees(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_UpdateSpeed(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_FlyToDespawn(EnRuppecrow*, GlobalContext*); -#if 0 const ActorInit En_Ruppecrow_InitVars = { ACTOR_EN_RUPPECROW, ACTORCAT_ENEMY, @@ -28,25 +52,36 @@ const ActorInit En_Ruppecrow_InitVars = { (ActorFunc)EnRuppecrow_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80BE39B0[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80BE39D4 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80BE39B0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80BE39E4 = { 1, 15, 30, 30 }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 30, 30 }; -// static DamageTable sDamageTable = { -static DamageTable D_80BE39EC = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -81,62 +116,558 @@ static DamageTable D_80BE39EC = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BE3A0C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -#endif +s32 EnRuppecrow_UpdateCollision(EnRuppecrow* this, GlobalContext* globalCtx) { + s32 pad; -extern ColliderJntSphElementInit D_80BE39B0[1]; -extern ColliderJntSphInit D_80BE39D4; -extern CollisionCheckInfoInit D_80BE39E4; -extern DamageTable D_80BE39EC; -extern InitChainEntry D_80BE3A0C[]; + this->collider.elements->dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements->dim.worldSphere.center.y = + sJntSphInit.elements->dim.modelSphere.center.y + this->actor.world.pos.y; + this->collider.elements->dim.worldSphere.center.z = this->actor.world.pos.z; -extern UNK_TYPE D_060000F0; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f, 25.0f, 50.0f, 0x07); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2260.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2330.s") +s32 EnRuppecrow_ReachedPointClockwise(EnRuppecrow* this, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 pathCount = path->count; + s32 currentPoint = pointIndex; + s32 reached = false; + f32 diffX; + f32 diffZ; + f32 px; + f32 pz; + f32 d; + Vec3f point; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE24CC.s") + Math_Vec3s_ToVec3f(&point, &points[currentPoint]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2668.s") + if (currentPoint == 0) { + diffX = points[1].x - points[0].x; + diffZ = points[1].z - points[0].z; + } else { + if (currentPoint == (pathCount - 1)) { + diffX = points[pathCount - 1].x - points[pathCount - 2].x; + diffZ = points[pathCount - 1].z - points[pathCount - 2].z; + } else { + diffX = points[currentPoint + 1].x - points[currentPoint - 1].x; + diffZ = points[currentPoint + 1].z - points[currentPoint - 1].z; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2728.s") + func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { + reached = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2794.s") + return reached; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2808.s") +s32 EnRuppecrow_ReachedPointCounterClockwise(EnRuppecrow* this, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 pathCount = path->count; + s32 currentPoint = pointIndex; + s32 reached = false; + f32 diffX; + f32 diffZ; + f32 px; + f32 pz; + f32 d; + Vec3f point; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2874.s") + Math_Vec3s_ToVec3f(&point, &points[currentPoint]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2B80.s") + if (currentPoint == 0) { + diffX = points[0].x - points[1].x; + diffZ = points[0].z - points[1].z; + } else { + if (currentPoint == (pathCount - 1)) { + diffX = points[pathCount - 2].x - points[pathCount - 1].x; + diffZ = points[pathCount - 2].z - points[pathCount - 1].z; + } else { + diffX = points[currentPoint - 1].x - points[currentPoint + 1].x; + diffZ = points[currentPoint - 1].z - points[currentPoint + 1].z; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2D4C.s") + func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { + reached = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2E18.s") + return reached; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2F6C.s") +f32 EnRuppecrow_GetPointDirection(Path* path, s32 pointIndex, PosRot* world, Vec3s* direction) { + Vec3s* points; + Vec3f point; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE30F4.s") + if (path != NULL) { + points = Lib_SegmentedToVirtual(path->points); + points = &points[pointIndex]; + VEC_SET(point, points->x, points->y, points->z); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE3178.s") + direction->y = Math_Vec3f_Yaw(&world->pos, &point); + direction->x = Math_Vec3f_Pitch(&world->pos, &point); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE32DC.s") + return point.y - world->pos.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE3354.s") +void EnRuppecrow_ShatterIce(EnRuppecrow* this, GlobalContext* globalCtx) { + if (this->currentEffect == ENRUPPECROW_EFFECT_ICE) { + this->currentEffect = ENRUPPECROW_EFFECT_NONE; + this->unk_2C8 = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ENRUPPECROW_LIMB_POS_COUNT, 0x2, 0.2f, 0.2f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE348C.s") +s32 EnRuppecrow_CanSpawnBlueRupees(GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE35A4.s") + switch (player->transformation) { + case PLAYER_FORM_DEKU: + return false; + case PLAYER_FORM_GORON: + return true; + case PLAYER_FORM_ZORA: + return false; + case PLAYER_FORM_HUMAN: + if (player->stateFlags1 & 0x800000) { + return true; + } else { + return false; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/EnRuppecrow_Init.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/EnRuppecrow_Destroy.s") +void EnRuppecrow_UpdateRupees(EnRuppecrow* this) { + EnItem00* rupee; + s16 rupeeIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/EnRuppecrow_Update.s") + for (rupeeIndex = 0; rupeeIndex < ENRUPPECROW_RUPEE_COUNT; rupeeIndex++) { + rupee = this->rupees[rupeeIndex]; + if (rupee != NULL && rupee->unk152 == 0) { + Actor_MarkForDeath(&rupee->actor); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/EnRuppecrow_Draw.s") +void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 xOffset; + EnItem00* rupee; + s16 rupeeIndex = this->rupeeIndex; + + if (!(player->stateFlags3 & 0x1000)) { + xOffset = (this->rupeeIndex & 1) ? 10.0f : -10.0f; + } else { + xOffset = 0.0f; + } + + if (EnRuppecrow_CanSpawnBlueRupees(globalCtx) && (this->rupeeIndex % 5) == 4) { + if (this->rupeeIndex == 19) { + rupee = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, + this->actor.world.pos.x + xOffset, this->actor.world.pos.y, + this->actor.world.pos.z, 0x0, 0x0, 0x0, ITEM00_RUPEE_RED); + this->rupees[rupeeIndex] = rupee; + this->rupees[rupeeIndex]->actor.gravity = -5.0f; + this->rupees[rupeeIndex]->actor.velocity.y = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); + rupee = this->rupees[rupeeIndex]; + rupee->unk152 = 60; + this->rupees[rupeeIndex]->actor.flags |= 0x10; + } else { + rupee = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, + this->actor.world.pos.x + xOffset, this->actor.world.pos.y, + this->actor.world.pos.z, 0x0, 0x0, 0x0, ITEM00_RUPEE_BLUE); + this->rupees[rupeeIndex] = rupee; + this->rupees[rupeeIndex]->actor.gravity = -5.0f; + this->rupees[rupeeIndex]->actor.velocity.y = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); + rupee = this->rupees[rupeeIndex]; + rupee->unk152 = 60; + this->rupees[rupeeIndex]->actor.flags |= 0x10; + } + } else if (this->rupeeIndex == 19) { + rupee = + (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, + this->actor.world.pos.y, this->actor.world.pos.z, 0x0, 0x0, 0x0, ITEM00_RUPEE_RED); + this->rupees[rupeeIndex] = rupee; + this->rupees[rupeeIndex]->actor.gravity = -5.0f; + this->rupees[rupeeIndex]->actor.velocity.y = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); + rupee = this->rupees[rupeeIndex]; + rupee->unk152 = 60; + this->rupees[rupeeIndex]->actor.flags |= 0x10; + } else { + rupee = + (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, + this->actor.world.pos.y, this->actor.world.pos.z, 0x0, 0x0, 0x0, ITEM00_RUPEE_GREEN); + this->rupees[rupeeIndex] = rupee; + this->rupees[rupeeIndex]->actor.gravity = -5.0f; + this->rupees[rupeeIndex]->actor.velocity.y = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); + rupee = this->rupees[rupeeIndex]; + rupee->unk152 = 60; + this->rupees[rupeeIndex]->actor.flags |= 0x10; + } + + this->rupeeIndex++; +} + +void EnRuppecrow_UpdatePosition(EnRuppecrow* this, GlobalContext* globalCtx) { + Vec3s nextPointDirection; + + EnRuppecrow_GetPointDirection(this->path, this->currentPoint, &this->actor.world, &nextPointDirection); + if (this->actor.bgCheckFlags & 0x8) { + nextPointDirection.y = this->actor.wallYaw; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, nextPointDirection.y, 0x4, 0x3E8, 0x1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.world.rot.x, -nextPointDirection.x, 0x4, 0x3E8, 0x1); + + if (this->isGoingCounterClockwise & 1) { + if (EnRuppecrow_ReachedPointCounterClockwise(this, this->path, this->currentPoint)) { + if (this->currentPoint <= 0) { + this->currentPoint = this->path->count - 1; + } else { + this->currentPoint--; + } + + if (this->actionFunc == EnRuppecrow_FlyWhileDroppingRupees && + (!EnRuppecrow_CanSpawnBlueRupees(globalCtx) || (this->currentPoint % -2) == 0)) { + EnRuppecrow_SpawnRupee(this, globalCtx); + } + } + } else if (EnRuppecrow_ReachedPointClockwise(this, this->path, this->currentPoint)) { + if (this->currentPoint >= this->path->count - 1) { + this->currentPoint = 0; + } else { + this->currentPoint++; + } + + if (this->actionFunc == EnRuppecrow_FlyWhileDroppingRupees && + (!EnRuppecrow_CanSpawnBlueRupees(globalCtx) || (this->currentPoint % -2) == 0)) { + EnRuppecrow_SpawnRupee(this, globalCtx); + } + } +} + +s32 EnRuppecrow_CheckPlayedMatchingSong(GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (globalCtx->msgCtx.unk1202A == 0x3) { + switch (player->transformation) { + case PLAYER_FORM_DEKU: + if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_SONATA) { + return true; + } + break; + case PLAYER_FORM_GORON: + if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_GORON_LULLABY) { + return true; + } + break; + case PLAYER_FORM_ZORA: + if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_NEW_WAVE) { + return true; + } + break; + case PLAYER_FORM_HUMAN: + if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_SONATA) { + return true; + } else if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_GORON_LULLABY) { + return true; + } else if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_NEW_WAVE) { + return true; + } + break; + } + } + + return false; +} + +void EnRuppecrow_UpdateSpeed(EnRuppecrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (player->transformation) { + case PLAYER_FORM_DEKU: + this->speedModifier = 7.0f; + break; + case PLAYER_FORM_GORON: + if (player->stateFlags3 & 0x1000) { // Goron Link is curled + this->speedModifier = 19.0f; + } else { + this->speedModifier = 7.0f; + } + break; + case PLAYER_FORM_ZORA: + this->speedModifier = 7.0f; + break; + case PLAYER_FORM_HUMAN: + if (player->stateFlags1 & 0x800000) { + this->speedModifier = 16.0f; + } else { + this->speedModifier = 7.0f; + } + break; + } + + this->skelAnime.playSpeed = this->speedModifier / 6.0f; + if (this->actor.xzDistToPlayer > 800.0f) { + this->speedModifier *= 0.5f; + } else if (this->actor.xzDistToPlayer > 500.0f) { + this->speedModifier *= 0.8f; + } else if (this->actor.xzDistToPlayer < 150.0f) { + this->speedModifier *= 1.2f; + } +} + +void EnRuppecrow_HandleDeath(EnRuppecrow* this) { + f32 scale; + + this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); + this->actor.velocity.y = 0.0f; + Animation_Change(&this->skelAnime, &object_crow_Anim_0000F0, 0.4f, 0.0f, 0.0f, 0x1, -3.0f); + + this->actor.shape.yOffset = 0.0f; + this->actor.targetArrowOffset = 0.0f; + this->actor.bgCheckFlags &= ~0x1; + + scale = this->actor.scale.x * 100.0f; + this->actor.world.pos.y += 20.0f * scale; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); + + this->unk_2CC = 0.5f; + if (this->actor.colChkInfo.damageEffect == 0x3) { + this->currentEffect = ENRUPPECROW_EFFECT_ICE; + this->unk_2C8 = 1.0f; + this->iceSfxTimer = 0.75f; + } else if (this->actor.colChkInfo.damageEffect == 0x4) { + this->currentEffect = ENRUPPECROW_EFFECT_LIGHT; + this->unk_2C8 = 5.0f; + } else if (this->actor.colChkInfo.damageEffect == 0x2) { + this->currentEffect = ENRUPPECROW_EFFECT_NONE; + this->unk_2C8 = 5.0f; + } + + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x0, 0x28); + if (this->actor.flags & 0x8000) { + this->actor.speedXZ = 0.0f; + } + + this->collider.base.acFlags &= ~AC_ON; + this->actor.flags |= 0x10; + this->actionFunc = EnRuppecrow_FallToDespawn; +} + +void EnRuppecrow_UpdateDamage(EnRuppecrow* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.elements->info); + + if (this->actor.colChkInfo.damageEffect != 0x1) { + this->actor.colChkInfo.health = 0; + this->actor.flags &= ~0x1; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + EnRuppecrow_HandleDeath(this); + } + } +} + +void EnRuppecrow_HandleSong(EnRuppecrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + EnRuppecrow_UpdatePosition(this, globalCtx); + if (this->actor.xzDistToPlayer < 1000.0f && EnRuppecrow_CheckPlayedMatchingSong(globalCtx)) { + // If Link is in front, the guay will turn around and go the other way + if (Actor_IsFacingPlayer(&this->actor, 0x4000)) { + this->isGoingCounterClockwise |= 1; + if (this->currentPoint > 0) { + this->currentPoint--; + } else { + this->currentPoint = this->path->count - 1; + } + } + + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = EnRuppecrow_HandleSongCutscene; + } + + if (player->stateFlags2 & 0x8000000) { + Math_ApproachF(&this->actor.speedXZ, 0.0f, 0.1f, 1.0f); + } else { + Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.1f, 0.1f); + } + + Actor_MoveWithoutGravity(&this->actor); + this->yOffset += 0x1000; + this->actor.shape.yOffset = Math_SinS(this->yOffset) * 500.0f; + + if ((globalCtx->state.frames % 43) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + } +} + +void EnRuppecrow_HandleSongCutscene(EnRuppecrow* this, GlobalContext* globalCtx) { + EnRuppecrow_UpdatePosition(this, globalCtx); + + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + EnRuppecrow_UpdateSpeed(this, globalCtx); + this->actionFunc = EnRuppecrow_FlyWhileDroppingRupees; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + + Actor_MoveWithoutGravity(&this->actor); +} + +void EnRuppecrow_FlyWhileDroppingRupees(EnRuppecrow* this, GlobalContext* globalCtx) { + EnRuppecrow_UpdatePosition(this, globalCtx); + + if (this->rupeeIndex >= ENRUPPECROW_RUPEE_COUNT) { + // Finished spawning rupees; fly up and then despawn + this->speedModifier = 6.0f; + + // Source of the "Termina Field Guay Glitch"; guay will no longer fall if killed after this point + this->actor.gravity = 0.0f; + + Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); + Math_ApproachF(&this->actor.velocity.y, 3.0f, 0.2f, 0.5f); + + this->actionFunc = EnRuppecrow_FlyToDespawn; + this->skelAnime.playSpeed = 1.0f; + Actor_MoveWithGravity(&this->actor); + } else { + if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + EnRuppecrow_UpdateSpeed(this, globalCtx); + Math_ApproachF(&this->actor.speedXZ, this->speedModifier, 0.2f, 0.5f); + } + + Actor_MoveWithoutGravity(&this->actor); + this->yOffset += 0x1000; + this->actor.shape.yOffset = Math_SinS(this->yOffset) * 500.0f; + + if ((globalCtx->state.frames % 43) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + } + } +} + +void EnRuppecrow_FlyToDespawn(EnRuppecrow* this, GlobalContext* globalCtx) { + if (this->actor.bgCheckFlags & 0x8) { + this->actor.world.rot.y *= -0x1; + } + + Math_ApproachF(&this->actor.speedXZ, this->speedModifier, 0.1f, 0.1f); + Math_ApproachF(&this->actor.velocity.y, 3.0f, 0.2f, 0.5f); + + if (this->actor.world.pos.y > 1000.0f || this->actor.xzDistToPlayer > 2000.0f) { + Actor_MarkForDeath(&this->actor); + } else { + this->yOffset += 0x800; + this->actor.shape.yOffset = Math_SinS(this->yOffset) * 500.0f; + + Actor_MoveWithGravity(&this->actor); + + if ((globalCtx->state.frames % 43) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + } + } +} + +void EnRuppecrow_FallToDespawn(EnRuppecrow* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + + if (this->currentEffect != ENRUPPECROW_EFFECT_ICE) { + Math_StepToF(&this->unk_2C8, 0.0f, 0.05f); + this->unk_2CC = (this->unk_2C8 + 1.0f) * 0.25f; + this->unk_2CC = CLAMP_MAX(this->unk_2CC, 0.5f); + } else if (!Math_StepToF(&this->iceSfxTimer, 0.5f, 0.0125f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + + this->actor.colorFilterTimer = 40; + if (!(this->actor.flags & 0x8000)) { + if (this->currentEffect != ENRUPPECROW_EFFECT_ICE) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); + this->actor.shape.rot.z += 0x1780; + } + + if (this->actor.bgCheckFlags & 0x1 || this->actor.floorHeight == BGCHECK_Y_MIN) { + EnRuppecrow_ShatterIce(this, globalCtx); + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, (this->actor.scale.x * 10000.0f), + 0x0, 0x0); + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 0xB, NA_SE_EN_EXTINCT); + Actor_MarkForDeath(&this->actor); + return; + } + } + + Actor_MoveWithGravity(&this->actor); +} + +void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx2) { + EnRuppecrow* this = THIS; + GlobalContext* globalCtx = globalCtx2; + + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_crow_Skel_0010C0, &object_crow_Anim_0000F0, this->joinTable, + this->morphTable, ENRUPPECROW_LIMB_COUNT); + ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); + + Collider_InitJntSph(globalCtx, &this->collider); + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->colliderElement); + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius; + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + Actor_SetScale(&this->actor, 0.01f); + this->actor.flags |= 0x2000000; + + this->path = func_8013D648(globalCtx, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); + if (this->path != NULL) { + this->actionFunc = EnRuppecrow_HandleSong; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void EnRuppecrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRuppecrow* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); +} + +void EnRuppecrow_Update(Actor* thisx, GlobalContext* globalCtx) { + EnRuppecrow* this = THIS; + + EnRuppecrow_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + EnRuppecrow_UpdateRupees(this); + this->actor.focus.pos = this->actor.world.pos; + SkelAnime_Update(&this->skelAnime); + EnRuppecrow_UpdateCollision(this, globalCtx); +} + +void EnRuppecrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnRuppecrow* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h index eeba6774d8..4c9cafa675 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h @@ -3,15 +3,38 @@ #include "global.h" +#define ENRUPPECROW_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) + +#define ENRUPPECROW_RUPEE_COUNT 20 +#define ENRUPPECROW_LIMB_COUNT 9 +#define ENRUPPECROW_LIMB_POS_COUNT 4 + struct EnRuppecrow; typedef void (*EnRuppecrowActionFunc)(struct EnRuppecrow*, GlobalContext*); typedef struct EnRuppecrow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x94]; - /* 0x01D8 */ EnRuppecrowActionFunc actionFunc; - /* 0x01DC */ char unk_1DC[0x128]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnItem00* rupees[ENRUPPECROW_RUPEE_COUNT]; + /* 0x194 */ SkelAnime skelAnime; + /* 0x1D8 */ EnRuppecrowActionFunc actionFunc; + /* 0x1DC */ UNK_TYPE4 unk_1DC; // unused + /* 0x1E0 */ Vec3s joinTable[ENRUPPECROW_LIMB_COUNT]; + /* 0x216 */ Vec3s morphTable[ENRUPPECROW_LIMB_COUNT]; + /* 0x24C */ Path* path; + /* 0x250 */ s32 currentPoint; + /* 0x254 */ ColliderJntSph collider; + /* 0x274 */ ColliderJntSphElement colliderElement; + /* 0x2B4 */ u16 isGoingCounterClockwise; + /* 0x2B8 */ f32 speedModifier; + /* 0x2BC */ s16 rupeeIndex; + /* 0x2BE */ s16 yOffset; + /* 0x2C0 */ UNK_TYPE4 unk_2C0; // unused + /* 0x2C4 */ u8 currentEffect; + /* 0x2C8 */ f32 unk_2C8; // set but not used + /* 0x2CC */ f32 unk_2CC; // set but not used + /* 0x2D0 */ f32 iceSfxTimer; + /* 0x2D4 */ Vec3f limbPos[ENRUPPECROW_LIMB_POS_COUNT]; } EnRuppecrow; // size = 0x304 extern const ActorInit En_Ruppecrow_InitVars; diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.c b/src/overlays/actors/ovl_En_Sb/z_en_sb.c index c355f99344..59417e2b23 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -158,7 +158,7 @@ void EnSb_SetupOpen(EnSb* this) { Animation_Change(&this->skelAnime, &D_06000194, 1.0f, 0, Animation_GetLastFrame(&D_06000194), 2, 0.0f); this->state = SHELLBLADE_OPEN; this->actionFunc = EnSb_Open; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); } void EnSb_SetupWaitOpen(EnSb* this) { @@ -174,7 +174,7 @@ void EnSb_SetupLunge(EnSb* this) { Animation_Change(&this->skelAnime, &D_06000124, playbackSpeed, 0.0f, frameCount, 2, 0); this->state = SHELLBLADE_LUNGE; this->actionFunc = EnSb_Lunge; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); } void EnSb_SetupBounce(EnSb* this) { @@ -271,7 +271,7 @@ void EnSb_Lunge(EnSb* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); if (this->actor.velocity.y <= -0.1f || this->actor.bgCheckFlags & 2) { if (!(this->actor.depthInWater > 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } this->actor.bgCheckFlags &= ~2; EnSb_SetupBounce(this); @@ -332,7 +332,7 @@ void EnSb_UpdateDamage(EnSb* this, GlobalContext* globalCtx) { hitPlayer = 0; if (this->vulnerableTimer != 0) { Actor_ApplyDamage(&this->actor); - func_800BCB70(&this->actor, 0x4000, 0xFF, 0x2000, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 80); hitPlayer = 1; } } @@ -343,7 +343,7 @@ void EnSb_UpdateDamage(EnSb* this, GlobalContext* globalCtx) { } this->isDead = true; Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 0x28, NA_SE_EN_BEE_FLY); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 0x28, NA_SE_EN_BEE_FLY); return; } hitPoint.x = this->collider.info.bumper.hitPos.x; @@ -371,8 +371,8 @@ void EnSb_Update(Actor* thisx, GlobalContext* globalCtx) { Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x80); Actor_MarkForDeath(&this->actor); } else { - Actor_SetHeight(&this->actor, 20.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_SetFocus(&this->actor, 20.0f); + Actor_MoveWithGravity(&this->actor); this->actionFunc(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 20.0f, 5); EnSb_UpdateDamage(this, globalCtx); @@ -394,7 +394,7 @@ void EnSb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (this->isDrawn != false) { if (limbIndex < 7) { phi_a2 = (this->actor.depthInWater > 0) ? 4 : 1; - func_800BBCEC(thisx, globalCtx, phi_a2, dList); + Actor_SpawnBodyParts(thisx, globalCtx, phi_a2, dList); } if (limbIndex == 6) { this->isDrawn = false; diff --git a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c index b90ab3db92..e71a241e7c 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c @@ -35,7 +35,7 @@ void func_80BFCFA0(EnScopecoin* this, GlobalContext* globalCtx) { } void func_80BFCFB8(EnScopecoin* this, GlobalContext* globalCtx) { - if (Actor_GetCollectibleFlag(globalCtx, (this->actor.params & 0x7F0) >> 4)) { + if (Flags_GetCollectible(globalCtx, (this->actor.params & 0x7F0) >> 4)) { Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_RED); Actor_MarkForDeath(&this->actor); } @@ -45,7 +45,7 @@ void EnScopecoin_Init(Actor* thisx, GlobalContext* globalCtx) { EnScopecoin* this = THIS; Actor_SetScale(&this->actor, 0.01f); - ActorShape_Init(&this->actor.shape, 0, func_800B3FC0, 10.0f); + ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 10.0f); this->unk148 = (this->actor.params & 0xF); if (this->unk148 < 0 || this->unk148 >= 8) { this->unk148 = 0; @@ -53,7 +53,7 @@ void EnScopecoin_Init(Actor* thisx, GlobalContext* globalCtx) { if (globalCtx->actorCtx.unk5 & 2) { if (this->unk148 == 2 || this->unk148 == 6) { - if (Actor_GetCollectibleFlag(globalCtx, (this->actor.params & 0x7F0) >> 4)) { + if (Flags_GetCollectible(globalCtx, (this->actor.params & 0x7F0) >> 4)) { Actor_MarkForDeath(&this->actor); return; } @@ -63,7 +63,7 @@ void EnScopecoin_Init(Actor* thisx, GlobalContext* globalCtx) { return; } if (this->unk148 == 2 || this->unk148 == 6) { - if (Actor_GetCollectibleFlag(globalCtx, (this->actor.params & 0x7F0) >> 4)) { + if (Flags_GetCollectible(globalCtx, (this->actor.params & 0x7F0) >> 4)) { Actor_MarkForDeath(&this->actor); } else { this->actor.draw = NULL; diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index dd5db5c868..e07b6895c0 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -219,7 +219,7 @@ void func_80ADAFC0(EnSellnuts* this) { } Actor* func_80ADB040(GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (actor != NULL) { if ((actor->id == ACTOR_EN_SELLNUTS) && !ENSELLNUTS_GET_1(actor)) { @@ -304,7 +304,7 @@ void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); if (((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f) ? true : false) && ((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80ADB4F4; this->unk_34C = 3; this->collider.dim.height = 64; @@ -313,12 +313,12 @@ void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { if ((this->unk_34C == 4) || (this->unk_34C == 18)) { this->unk_34C = 17; this->collider.dim.height = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); func_8013BC6C(&this->skelAnime, D_80ADD990, 17); } else if (this->unk_34C == 2) { this->unk_34C = 16; this->collider.dim.height = 32; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); func_8013BC6C(&this->skelAnime, D_80ADD990, 16); } else if (this->unk_34C == 17) { if (DECR(this->unk_34E) == 0) { @@ -350,8 +350,8 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x7D0, 0); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { - if (func_800B8708(globalCtx) == 0x2A) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Player_GetExchangeItemId(globalCtx) == EXCH_ITEM_2A) { player->actor.textId = D_80ADD928[this->unk_33A]; this->unk_340 = player->actor.textId; this->actionFunc = func_80ADBAB8; @@ -392,7 +392,7 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { } else if (((this->actor.xzDistToPlayer < 80.0f) && (((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false)) || this->actor.isTargeted) { - func_800B85E0(&this->actor, globalCtx, 80.0f, 0x2A); + func_800B85E0(&this->actor, globalCtx, 80.0f, EXCH_ITEM_2A); if (player->transformation == PLAYER_FORM_DEKU) { if (gSaveContext.day == 3) { this->unk_33A = 2; @@ -426,16 +426,16 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u8 temp_v0 = func_80152498(&globalCtx->msgCtx); - s32 itemActionParam; + u8 msgState = Message_GetState(&globalCtx->msgCtx); + s32 item; - if (temp_v0 == 0x10) { - itemActionParam = func_80123810(globalCtx); - if (itemActionParam > PLAYER_AP_NONE) { - if (itemActionParam == PLAYER_AP_MOON_TEAR) { + if (msgState == 0x10) { + item = func_80123810(globalCtx); + if (item > EXCH_ITEM_NONE) { + if (item == EXCH_ITEM_2A) { player->actor.textId = D_80ADD928[this->unk_33A]; this->unk_340 = player->actor.textId; - player->unk_A87 = itemActionParam; + player->exchangeItemId = item; this->actionFunc = func_80ADBAB8; } else { player->actor.textId = D_80ADD920[this->unk_33A]; @@ -443,12 +443,12 @@ void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80ADB0D8; } func_801477B4(globalCtx); - } else if (itemActionParam < PLAYER_AP_NONE) { + } else if (item < EXCH_ITEM_NONE) { this->unk_340 = D_80ADD920[this->unk_33A]; func_80151938(globalCtx, this->unk_340); this->actionFunc = func_80ADB0D8; } - } else if ((temp_v0 == 5) && func_80147624(globalCtx)) { + } else if ((msgState == 5) && func_80147624(globalCtx)) { if (this->unk_340 == D_80ADD910[this->unk_33A]) { this->unk_340 = D_80ADD938[this->unk_33A]; func_80151938(globalCtx, this->unk_340); @@ -462,7 +462,7 @@ void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADBAB8(EnSellnuts* this, GlobalContext* globalCtx) { - u8 sp27 = func_80152498(&globalCtx->msgCtx); + u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 currentFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); @@ -492,30 +492,30 @@ void func_80ADBBEC(EnSellnuts* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[17] |= 0x80; this->actionFunc = func_80ADBCE4; } else { - func_800B8A1C(&this->actor, globalCtx, GI_DEED_LAND, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, GI_DEED_LAND, 300.0f, 300.0f); } } void func_80ADBC60(EnSellnuts* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); this->unk_340 = D_80ADD930[this->unk_33A]; } } void func_80ADBCE4(EnSellnuts* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); this->unk_340 = D_80ADD930[this->unk_33A]; this->actionFunc = func_80ADBC60; } } void func_80ADBD64(EnSellnuts* this, GlobalContext* globalCtx) { - u8 sp27 = func_80152498(&globalCtx->msgCtx); + u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 currentFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); @@ -557,7 +557,7 @@ void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_350 = 4; this->unk_34C = 19; func_8013BC6C(&this->skelAnime, D_80ADD990, 19); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_338 &= ~1; this->unk_338 |= 8; this->unk_32C = this->actor.world.pos.y; @@ -566,7 +566,7 @@ void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADBFA0(EnSellnuts* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; if (this->unk_34C == 0) { @@ -626,7 +626,7 @@ void func_80ADC118(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_34C = 9; this->unk_360 = 0.3f; func_8013BC6C(&this->skelAnime, D_80ADD990, 9); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80ADC034; } } @@ -680,7 +680,7 @@ void func_80ADC37C(EnSellnuts* this, GlobalContext* globalCtx) { } Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); if (this->unk_366 == 2) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); @@ -706,7 +706,7 @@ void func_80ADC580(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->linearVelocity = 0.0f; this->actor.flags &= ~0x10000; func_801518B0(globalCtx, this->unk_340, &this->actor); @@ -729,7 +729,7 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADC6D0(EnSellnuts* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; if (player->transformation == PLAYER_FORM_DEKU) { @@ -747,7 +747,7 @@ void func_80ADC6D0(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADC7B4(EnSellnuts* this, GlobalContext* globalCtx) { - s32 temp = func_80152498(&globalCtx->msgCtx); + s32 temp = Message_GetState(&globalCtx->msgCtx); if (this->unk_366 == 0) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -812,7 +812,7 @@ void func_80ADC8C4(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_334++; } Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); } } @@ -832,7 +832,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_34C = 19; this->actor.velocity.y = 0.0f; func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); } return; } @@ -893,7 +893,7 @@ void func_80ADCD3C(EnSellnuts* this, GlobalContext* globalCtx) { this->collider.dim.height = 64; this->unk_34C = 3; this->unk_350 = 4; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADCC04; } else if (D_80ADD940 != 0) { @@ -965,7 +965,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600AC70, &D_06005488, this->jointTable, this->morphTable, 28); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 35.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); this->path = func_8013D648(globalCtx, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); this->cutscene = this->actor.cutscene; Actor_SetScale(&this->actor, 0.01f); @@ -1053,10 +1053,10 @@ void EnSellnuts_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_33A = 0; } - Actor_SetHeight(&this->actor, 60.0f); + Actor_SetFocus(&this->actor, 60.0f); Actor_SetScale(&this->actor, 0.01f); SkelAnime_Update(&this->skelAnime); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); this->actionFunc(this, globalCtx); if (this->unk_338 & 8) { func_800B9010(&this->actor, NA_SE_EN_AKINDO_FLY - SFX_FLAG); diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 0f8a95f967..32802fb01e 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -215,7 +215,7 @@ void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.colChkInfo.damageTable = &sDamageTable; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 0.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); this->unk_3E0 = 0; this->unk_3E2 = 0; Actor_SetScale(&this->actor, 0.01f); @@ -279,7 +279,7 @@ void EnSkb_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80994DA8(EnSkb* this, GlobalContext* globalCtx) { - if (Actor_IsActorFacingLink(&this->actor, 0x11C7) && (this->actor.xzDistToPlayer < 60.0f) && + if (Actor_IsFacingPlayer(&this->actor, 0x11C7) && (this->actor.xzDistToPlayer < 60.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_CAPTAIN)) { func_80995C24(this); } else { @@ -288,9 +288,9 @@ void func_80994DA8(EnSkb* this, GlobalContext* globalCtx) { } void func_80994E2C(EnSkb* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actor.flags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); this->unk_3D0 = 0; this->unk_3DE = 0; this->actionFunc = func_80994E94; @@ -317,7 +317,7 @@ void func_80994E94(EnSkb* this, GlobalContext* globalCtx) { } void func_80994F7C(EnSkb* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3E2 = 1; if (this->unk_3E0 == 1) { func_801518B0(globalCtx, 0x13F8, &this->actor); @@ -327,7 +327,7 @@ void func_80994F7C(EnSkb* this, GlobalContext* globalCtx) { } this->actionFunc = func_80995190; this->actor.speedXZ = 0.0f; - } else if (Actor_IsActorFacingLink(&this->actor, 0x2AAA) && !(this->collider.base.acFlags & AC_HIT)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && !(this->collider.base.acFlags & AC_HIT)) { func_800B8614(&this->actor, globalCtx, 100.0f); } } @@ -338,12 +338,12 @@ void func_8099504C(EnSkb* this) { } void func_80995068(EnSkb* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3E2 = 1; if (this->unk_3E0 == 1) { func_801518B0(globalCtx, 0x13F8, &this->actor); if (this->unk_3DE == 2) { - func_800BDC5C(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); } } else { func_801518B0(globalCtx, 0x13F6, &this->actor); @@ -363,7 +363,7 @@ void func_80995068(EnSkb* this, GlobalContext* globalCtx) { } void func_80995190(EnSkb* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: case 1: case 2: @@ -375,7 +375,7 @@ void func_80995190(EnSkb* this, GlobalContext* globalCtx) { if (func_80147624(globalCtx)) { func_801518B0(globalCtx, 0x13F7, &this->actor); if (this->unk_3DE == 2) { - func_800BDC5C(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); } } break; @@ -413,7 +413,7 @@ void func_80995244(EnSkb* this, GlobalContext* globalCtx) { } void func_809952D8(EnSkb* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 9; this->actionFunc = func_8099533C; @@ -427,7 +427,7 @@ void func_8099533C(EnSkb* this, GlobalContext* globalCtx) { this->actor.flags &= ~(0x4 | 0x1); this->actor.flags |= (0x8 | 0x1); func_80994F7C(this, globalCtx); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { this->actor.hintId = 0x55; this->actor.colChkInfo.mass = MASS_HEAVY; func_8099571C(this); @@ -435,7 +435,7 @@ void func_8099533C(EnSkb* this, GlobalContext* globalCtx) { } void func_809953E8(EnSkb* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 10; this->actionFunc = func_8099544C; @@ -449,7 +449,7 @@ void func_8099544C(EnSkb* this, GlobalContext* globalCtx) { this->actor.flags &= ~(0x4 | 0x1); this->actor.flags |= (0x8 | 0x1); func_80994F7C(this, globalCtx); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { this->actor.hintId = 0x55; this->actor.colChkInfo.mass = MASS_HEAVY; func_8099571C(this); @@ -457,7 +457,7 @@ void func_8099544C(EnSkb* this, GlobalContext* globalCtx) { } void func_809954F8(EnSkb* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 11; this->actionFunc = func_8099556C; @@ -486,7 +486,7 @@ void func_8099556C(EnSkb* this, GlobalContext* globalCtx) { this->actor.flags &= ~(0x4 | 0x1); this->actor.flags |= (0x8 | 0x1); func_80994F7C(this, globalCtx); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f) && + } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f) && (this->skelAnime.curFrame > 24.0f) && (this->skelAnime.curFrame < 28.0f)) { this->actor.hintId = 0x55; this->actor.colChkInfo.mass = MASS_HEAVY; @@ -496,18 +496,18 @@ void func_8099556C(EnSkb* this, GlobalContext* globalCtx) { } void func_8099571C(EnSkb* this) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_3DC = 0; this->actor.shape.shadowScale = 0.0f; if (this->unk_3DE == 9) { - func_800BDC5C(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); this->actor.speedXZ = 2.4f; this->actor.gravity = -1.0f; this->actor.velocity.y = 3.0f; } else if (this->unk_3DE == 0xA) { - func_800BDC5C(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); } else if (this->unk_3DE == 0xB) { - func_800BDC5C(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); this->actor.speedXZ = 3.2f; this->actor.gravity = -1.0f; this->actor.velocity.y = 2.0f; @@ -540,7 +540,7 @@ void func_809958F4(EnSkb* this) { this->unk_3E4 = 0; this->actor.flags &= ~1; this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->unk_3DE = 1; this->actionFunc = func_8099599C; } @@ -560,7 +560,7 @@ void func_8099599C(EnSkb* this, GlobalContext* globalCtx) { } void func_80995A30(EnSkb* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); this->actor.speedXZ = 1.6f; this->unk_3DA = 0; this->unk_3DE = 2; @@ -573,7 +573,7 @@ void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { this->actor.flags |= (0x8 | 0x1); this->actor.hintId = 0xFF; this->actor.colChkInfo.mass = MASS_HEAVY; - func_800BDC5C(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); func_8099504C(this); return; } @@ -585,18 +585,18 @@ void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->unk_3DA, 1, 0x2EE, 0); this->actor.world.rot.y = this->actor.shape.rot.y; if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { - Audio_PlayActorSound2(&this->actor, 0x3830); + Actor_PlaySfxAtPos(&this->actor, 0x3830); } if ((this->actor.xzDistToPlayer > 800.0f) || func_80996594(this, globalCtx)) { func_809958F4(this); - } else if (Actor_IsActorFacingLink(&this->actor, 0x11C7) && (this->actor.xzDistToPlayer < 60.0f)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x11C7) && (this->actor.xzDistToPlayer < 60.0f)) { func_80995C24(this); } } void func_80995C24(EnSkb* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); this->collider.base.atFlags &= ~AT_BOUNCED; this->actor.speedXZ = 0.0f; this->unk_3DE = 3; @@ -605,7 +605,7 @@ void func_80995C24(EnSkb* this) { void func_80995C84(EnSkb* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 3.0f) && (this->unk_3E4 == 0)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_3E4 = 1; } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { this->unk_3E4 = 0; @@ -637,7 +637,7 @@ void func_80995E08(EnSkb* this) { if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = 0.0f; } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->unk_3E4 = 0; this->unk_3DE = 5; this->actionFunc = func_80995E64; @@ -681,22 +681,22 @@ void func_80995E64(EnSkb* this, GlobalContext* globalCtx) { void func_80995F98(EnSkb* this) { if ((this->unk_3DE == 9) || (this->unk_3DE == 0xA)) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - func_800BDC5C(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); this->actor.gravity = -1.0f; this->actor.speedXZ = 1.0f; } else if (this->unk_3DE == 0xB) { - func_800BDC5C(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); this->actor.speedXZ = 3.2f; this->actor.velocity.y = 2.0f; this->actor.gravity = -1.0f; } else { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -4.0f; } } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3DE = 6; this->actionFunc = func_809960AC; } @@ -727,14 +727,14 @@ void func_809960AC(EnSkb* this, GlobalContext* globalCtx) { } void func_809961E4(EnSkb* this, GlobalContext* globalCtx) { - func_800BDC5C(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); this->unk_3D8 |= 0x40; if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; } this->unk_3E4 = 0; this->actor.flags &= ~1; - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); this->unk_3DE = 7; this->actionFunc = func_80996284; } @@ -748,7 +748,7 @@ void func_80996284(EnSkb* this, GlobalContext* globalCtx) { } void func_809962D4(EnSkb* this) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = func_8099630C; } @@ -758,8 +758,8 @@ void func_8099630C(EnSkb* this, GlobalContext* globalCtx) { this->unk_230 = 0.0f; this->unk_22C = 0.0f; if (this->actor.colChkInfo.health != 0) { - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); this->unk_3D8 |= 1; func_80995F98(this); } else { @@ -780,8 +780,8 @@ void func_809963D8(EnSkb* this, GlobalContext* globalCtx) { this->unk_230 = 0.0f; this->unk_22C = 0.0f; if (this->actor.colChkInfo.health != 0) { - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); this->unk_3D8 |= 1; func_80995F98(this); } else { @@ -912,12 +912,12 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { this->unk_3D2 = 40; this->unk_22C = 1.0f; this->unk_230 = 0.0f; - func_800BCB70(&this->actor, 0, 0x78, 0, 40); + Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); func_80995E08(this); break; case 1: - func_800BCB70(&this->actor, 0, 0x78, 0, 40); + Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); func_80995E08(this); break; @@ -926,14 +926,14 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { this->unk_3E6 = 0; this->unk_22C = 1.0f; this->unk_230 = 0.0f; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->unk_3D8 |= 1; func_80995F98(this); break; case 3: if (this->actor.colChkInfo.health != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3D2 = 0x50; } else { this->unk_3D2 = 3; @@ -941,7 +941,7 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { this->unk_3E6 = 0xB; this->unk_22C = 1.0f; this->unk_230 = 0.5f; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); func_809962D4(this); break; @@ -950,9 +950,9 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { this->unk_3E6 = 0x14; this->unk_22C = 1.0f; this->unk_230 = 0.5f; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE); - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); func_809963C4(this); break; @@ -967,8 +967,8 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { } case 13: - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); func_80995F98(this); break; } @@ -1011,7 +1011,7 @@ void func_80996BEC(EnSkb* this, GlobalContext* globalCtx) { end = 14; } - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); + 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]); @@ -1054,7 +1054,7 @@ void EnSkb_Update(Actor* thisx, GlobalContext* globalCtx) { func_8099672C(this, globalCtx); if ((this->actionFunc != func_8099630C) && (this->actionFunc != func_809963D8) && (this->actionFunc != func_80995E64)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 60.0f, 0x1D); @@ -1099,12 +1099,12 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Collider_UpdateSpheres(limbIndex, &this->collider); if ((this->unk_3D8 & 1) && !(this->unk_3D8 & 2)) { if (limbIndex == 11) { - func_800BBCEC(&this->actor, globalCtx, 1, dList); + Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); this->unk_3D8 |= 2; } } else if ((this->unk_3D8 & 0x40) && !(this->unk_3D8 & 0x80) && ((limbIndex != 11) || !(this->unk_3D8 & 1)) && (limbIndex != 12)) { - func_800BBCEC(&this->actor, globalCtx, 1, dList); + Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } if (this->unk_3D2 != 0) { diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 140fc2c710..4d0b5f094b 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -436,7 +436,7 @@ void EnSob1_UpdateCursorPos(GlobalContext* globalCtx, EnSob1* this) { f32 xOffset = 0.0f; f32 yOffset = 17.0f; - func_800B8898(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); this->cursorPos.x = x + xOffset; this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; @@ -449,7 +449,7 @@ void EnSob1_EndInteraction(GlobalContext* globalCtx, EnSob1* this) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; } - func_800B84D0(&this->actor, globalCtx); + Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; Interface_ChangeAlpha(50); @@ -516,7 +516,7 @@ void EnSob1_SetupLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnSob1* thi } void EnSob1_EndingInteraction(EnSob1* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { EnSob1_EndInteraction(globalCtx, this); } } @@ -534,7 +534,7 @@ void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); this->headRotTarget = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -610,7 +610,7 @@ u8 EnSob1_SetCursorIndexFromNeutral(EnSob1* this, u8 shelfOffset) { } void EnSob1_Hello(EnSob1* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -650,7 +650,7 @@ s32 EnSob1_FacingShopkeeperDialogResult(EnSob1* this, GlobalContext* globalCtx) void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { s32 pad[2]; - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); u8 cursorIdx; if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { @@ -690,7 +690,7 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_TalkingToShopkeeper(EnSob1* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { EnSob1_StartShopping(globalCtx, this); } } @@ -737,7 +737,7 @@ void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { EnSob1_SetupAction(this, EnSob1_SetupIdle); } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void EnSob1_SetupIdle(EnSob1* this, GlobalContext* globalCtx) { @@ -777,7 +777,7 @@ void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx) { } } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); EnSob1_Walking(this, globalCtx); } @@ -792,7 +792,7 @@ void EnSob1_Walking(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -832,10 +832,10 @@ void EnSob1_ItemPurchased(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80151938(globalCtx, 0x647); } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); } } @@ -910,7 +910,7 @@ s32 EnSob1_HasPlayerSelectedItem(GlobalContext* globalCtx, EnSob1* this, Input* } void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; u8 prevCursorIdx = this->cursorIdx; u8 cursorIdx; @@ -940,7 +940,7 @@ void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnSob1* this) { Player* player = GET_PLAYER(globalCtx); - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; player->stateFlags2 &= ~0x20000000; @@ -1029,7 +1029,7 @@ void EnSob1_HandleCanBuyItem(GlobalContext* globalCtx, EnSob1* this) { } void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (EnSob1_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); @@ -1049,7 +1049,7 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5) { + if (Message_GetState(&globalCtx->msgCtx) == 5) { if (func_80147624(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); @@ -1060,7 +1060,7 @@ void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_CanBuy(EnSob1* this, GlobalContext* globalCtx) { EnGirlA* item; - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnSob1_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1075,12 +1075,12 @@ void EnSob1_BuyItemWithFanfare(EnSob1* this, GlobalContext* globalCtx) { this->actor.parent = NULL; EnSob1_SetupAction(this, EnSob1_SetupItemPurchased); } else { - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); } } void EnSob1_SetupItemPurchased(EnSob1* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; EnSob1_SetupAction(this, EnSob1_ItemPurchased); @@ -1091,7 +1091,7 @@ void EnSob1_SetupItemPurchased(EnSob1* this, GlobalContext* globalCtx) { this->cutscene = this->lookToShopkeeperCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); } - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); } } @@ -1099,7 +1099,7 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnGirlA* item; - if ((func_80152498(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { EnSob1_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); @@ -1107,7 +1107,7 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { player->stateFlags2 |= 0x20000000; func_801518B0(globalCtx, this->welcomeTextId, &this->actor); EnSob1_SetupStartShopping(globalCtx, this, true); - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } } @@ -1368,7 +1368,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { if (EnSob1_AreObjectsLoaded(this, globalCtx)) { this->actor.flags &= ~0x10; this->actor.objBankIndex = this->objIndices[0]; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); posOffset = &sPosOffset[this->shopType]; this->actor.world.pos.x += posOffset->x; this->actor.world.pos.y += posOffset->y; @@ -1381,7 +1381,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; EnSob1_GetCutscenes(this); this->cutscene = this->lookFowardCutscene; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); sInitFuncs[this->shopType](this, globalCtx); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; @@ -1473,7 +1473,7 @@ void EnSob1_Update(Actor* thisx, GlobalContext* globalCtx) { EnSob1_UpdateCursorAnim(this); Math_StepToS(&this->headRot, this->headRotTarget, 0x190); this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, 90.0f); + Actor_SetFocus(&this->actor, 90.0f); changeObjectFunc = this->changeObjectFunc; if (changeObjectFunc != NULL) { changeObjectFunc(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c index 827491ee12..26fdf6f08d 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -5,6 +5,7 @@ */ #include "z_en_ssh.h" +#include "objects/object_ssh/object_ssh.h" #define FLAGS 0x00000035 @@ -15,16 +16,15 @@ void EnSsh_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSsh_Update(Actor* thisx, GlobalContext* globalCtx); void EnSsh_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809755C0(EnSsh* this, GlobalContext* globalCtx); -void func_80975720(EnSsh* this, GlobalContext* globalCtx); -void func_809758B0(EnSsh* this, GlobalContext* globalCtx); -void func_80975998(EnSsh* this, GlobalContext* globalCtx); -void func_80975A98(EnSsh* this, GlobalContext* globalCtx); -void func_80975C14(EnSsh* this, GlobalContext* globalCtx); +void EnSsh_Wait(EnSsh* this, GlobalContext* globalCtx); +void EnSsh_Idle(EnSsh* this, GlobalContext* globalCtx); +void EnSsh_Land(EnSsh* this, GlobalContext* globalCtx); +void EnSsh_Drop(EnSsh* this, GlobalContext* globalCtx); +void EnSsh_Return(EnSsh* this, GlobalContext* globalCtx); +void EnSsh_Start(EnSsh* this, GlobalContext* globalCtx); -void EnSsh_SetupAction(EnSsh* this, EnSshActionFunc actionFunc); +extern AnimationHeader D_06000304; -#if 0 const ActorInit En_Ssh_InitVars = { ACTOR_EN_SSH, ACTORCAT_NPC, @@ -37,139 +37,900 @@ const ActorInit En_Ssh_InitVars = { (ActorFunc)EnSsh_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80976030 = { - { COLTYPE_HIT6, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 32, 50, -24, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_8097605C = { 1, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80976068 = { - { COLTYPE_HIT6, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT6, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 20, 60, -30, { 0, 0, 0 } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80976094[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 1, { { 0, -240, 0 }, 28 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809760B8 = { - { COLTYPE_HIT6, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80976094, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -#endif +void EnSsh_SetupAction(EnSsh* this, EnSshActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern ColliderCylinderInit D_80976030; -extern CollisionCheckInfoInit2 D_8097605C; -extern ColliderCylinderInit D_80976068; -extern ColliderJntSphElementInit D_80976094[1]; -extern ColliderJntSphInit D_809760B8; +void EnSsh_SpawnShockwave(EnSsh* this, GlobalContext* globalCtx) { + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; -extern UNK_TYPE D_060000D8; -extern UNK_TYPE D_06000304; -extern UNK_TYPE D_06005850; + pos.x = this->actor.world.pos.x; + pos.y = this->actor.floorHeight; + pos.z = this->actor.world.pos.z; + EffectSsBlast_SpawnWhiteCustomScale(globalCtx, &pos, &zeroVec, &zeroVec, 100, 220, 8); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/EnSsh_SetupAction.s") +s32 EnSsh_CreateBlureEffect(GlobalContext* globalCtx) { + EffectBlureInit1 blureInit; + u8 sP1StartColor[4] = { 255, 255, 255, 75 }; + u8 sP2StartColor[4] = { 255, 255, 255, 75 }; + u8 sP1EndColor[4] = { 255, 255, 255, 0 }; + u8 sP2EndColor[4] = { 255, 255, 255, 0 }; + s32 i; + s32 blureIdx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80973EFC.s") + for (i = 0; i < ARRAY_COUNT(blureInit.p1StartColor); i++) { + blureInit.p1StartColor[i] = sP1StartColor[i]; + blureInit.p2StartColor[i] = sP2StartColor[i]; + blureInit.p1EndColor[i] = sP1EndColor[i]; + blureInit.p2EndColor[i] = sP2EndColor[i]; + } + blureInit.elemDuration = 6; + blureInit.unkFlag = false; + blureInit.calcMode = 3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80973F84.s") + Effect_Add(globalCtx, &blureIdx, 1, 0, 0, &blureInit); + return blureIdx; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974080.s") +s32 EnSsh_CheckCeilingPos(EnSsh* this, GlobalContext* globalCtx) { + CollisionPoly* poly; + s32 bgId; + Vec3f posB; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974118.s") + posB.x = this->actor.world.pos.x; + posB.y = this->actor.world.pos.y + 1000.0f; + posB.z = this->actor.world.pos.z; + if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &posB, &this->ceilingPos, &poly, 0, 0, 1, + 1, &bgId)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974220.s") +void EnSsh_AddBlureVertex(EnSsh* this) { + Vec3f p1Base = { 834.0f, 834.0f, 0.0f }; + Vec3f p2Base = { 834.0f, -584.0f, 0.0f }; + Vec3f p1; + Vec3f p2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_8097424C.s") + p1Base.x *= this->colliderScale; + p1Base.y *= this->colliderScale; + p1Base.z *= this->colliderScale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974374.s") + p2Base.x *= this->colliderScale; + p2Base.y *= this->colliderScale; + p2Base.z *= this->colliderScale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809744A8.s") + Matrix_StatePush(); + Matrix_MultiplyVector3fByState(&p1Base, &p1); + Matrix_MultiplyVector3fByState(&p2Base, &p2); + Matrix_StatePop(); + EffectBlure_AddVertex(Effect_GetByIndex(this->blureIdx), &p1, &p2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809744C8.s") +void EnSsh_AddBlureSpace(EnSsh* this) { + EffectBlure_AddSpace(Effect_GetByIndex(this->blureIdx)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809744FC.s") +void EnSsh_InitColliders(EnSsh* this, GlobalContext* globalCtx) { + ColliderCylinderInit* cylinders[] = { + &sCylinderInit1, &sCylinderInit1, &sCylinderInit1, &sCylinderInit2, &sCylinderInit2, &sCylinderInit2, + }; + s32 i; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974540.s") + for (i = 0; i < ARRAY_COUNT(this->collider1); i++) { + Collider_InitAndSetCylinder(globalCtx, &this->collider1[i], &this->actor, cylinders[i]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974590.s") + this->collider1[0].info.bumper.dmgFlags = 0x38A9; + this->collider1[1].info.bumper.dmgFlags = ~0x83038A9; + this->collider1[2].base.colType = COLTYPE_METAL; + this->collider1[2].info.bumperFlags = (BUMP_NO_AT_INFO | BUMP_HOOKABLE | BUMP_ON); + this->collider1[2].info.elemType = ELEMTYPE_UNK2; + this->collider1[2].info.bumper.dmgFlags = ~0x83038A9; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809745BC.s") + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(2), &sColChkInfoInit); + Collider_InitJntSph(globalCtx, &this->collider2); + Collider_SetJntSph(globalCtx, &this->collider2, &this->actor, &sJntSphInit, this->collider2Elements); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974730.s") +f32 EnSsh_SetAnimation(EnSsh* this, s32 arg0) { + AnimationHeader* animation[] = { &object_ssh_Anim_006D78, &object_ssh_Anim_001494, &object_ssh_Anim_001494, + &object_ssh_Anim_006788, &object_ssh_Anim_001494, &object_ssh_Anim_001494, + &object_ssh_Anim_006D78 }; + f32 playerbackSpeed[] = { 1.0f, 4.0f, 1.0f, 1.0f, 8.0f, 6.0f, 2.0f }; + u8 mode[] = { + ANIMMODE_ONCE_INTERP, ANIMMODE_ONCE_INTERP, ANIMMODE_LOOP_INTERP, ANIMMODE_ONCE_INTERP, + ANIMMODE_LOOP_INTERP, ANIMMODE_LOOP_INTERP, ANIMMODE_LOOP_INTERP, + }; + f32 frameCount = Animation_GetLastFrame(animation[arg0]); + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_8097480C.s") + Animation_Change(&this->skelAnime, animation[arg0], playerbackSpeed[arg0], 0.0f, frameCount, mode[arg0], -6.0f); + return frameCount; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809748DC.s") +void EnSsh_SetWaitAnimation(EnSsh* this) { + EnSsh_SetAnimation(this, SSH_ANIM_WAIT); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_8097497C.s") +void EnSsh_SetReturnAnimation(EnSsh* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_UP); + EnSsh_SetAnimation(this, SSH_ANIM_UP); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809749B8.s") +void EnSsh_SetLandAnimation(EnSsh* this) { + this->actor.world.pos.y = this->floorHeightOffset + this->actor.floorHeight; + this->animTimer = EnSsh_SetAnimation(this, SSH_ANIM_LAND); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974A24.s") +void EnSsh_SetDropAnimation(EnSsh* this) { + if (this->unkTimer == 0) { + this->animTimer = EnSsh_SetAnimation(this, SSH_ANIM_DROP); + } + this->actor.velocity.y = -10.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974B0C.s") +void EnSsh_SetStunned(EnSsh* this) { + if (this->stunTimer == 0) { + this->stateFlags |= SSH_STATE_ATTACKED; + this->stunTimer = 120; + this->actor.colorFilterTimer = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974B44.s") +void EnSsh_SetColliderScale(EnSsh* this, f32 arg1, f32 arg2) { + s32 i; + f32 radius = this->collider2.elements[0].dim.modelSphere.radius; + f32 height; + f32 yShift; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974B84.s") + radius *= arg1; + this->collider2.elements[0].dim.modelSphere.radius = radius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974CC8.s") + for (i = 0; i < ARRAY_COUNT(this->collider1); i++) { + yShift = this->collider1[i].dim.yShift; + radius = this->collider1[i].dim.radius; + height = this->collider1[i].dim.height; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974D3C.s") + height *= arg1; + yShift *= arg1; + radius *= arg1 * arg2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974E44.s") + this->collider1[i].dim.yShift = yShift; + this->collider1[i].dim.radius = radius; + this->collider1[i].dim.height = height; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974EA0.s") + Actor_SetScale(&this->actor, 0.04f * arg1); + this->floorHeightOffset = 60.0f * arg1; + this->colliderScale = arg1 * 1.5f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974F78.s") +s32 EnSsh_Damaged(EnSsh* this) { + if ((this->stunTimer == 120) && (this->stateFlags & SSH_STATE_STUNNED)) { + Actor_SetColorFilter(&this->actor, 0, 200, 0, this->stunTimer); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_8097502C.s") + if (DECR(this->stunTimer) != 0) { + Math_SmoothStepToS(&this->maxTurnRate, 10000, 10, 1000, 1); + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975070.s") + this->stunTimer = 0; + this->stateFlags &= ~SSH_STATE_STUNNED; + this->spinTimer = 0; + if (this->swayTimer == 0) { + this->spinTimer = 30; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975128.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_ST_ATTACK); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975300.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/EnSsh_Init.s") +void EnSsh_Turn(EnSsh* this, GlobalContext* globalCtx) { + if (this->hitTimer != 0) { + this->hitTimer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/EnSsh_Destroy.s") + if (DECR(this->spinTimer) != 0) { + this->actor.world.rot.y += (s16)(10000.0f * (this->spinTimer / 30.0f)); + } else if ((this->swayTimer == 0) && (this->stunTimer == 0)) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 4, 10000, 1); + } + this->actor.shape.rot.y = this->actor.world.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809755C0.s") +void EnSsh_Stunned(EnSsh* this, GlobalContext* globalCtx) { + if ((this->swayTimer == 0) && (this->stunTimer == 0)) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer ^ 0x8000, 4, this->maxTurnRate, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_8097561C.s") + this->actor.shape.rot.y = this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809756D0.s") + if (this->stunTimer < 30) { + if (this->stunTimer & 1) { + this->actor.shape.rot.y += 2000; + } else { + this->actor.shape.rot.y -= 2000; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975720.s") +void EnSsh_UpdateYaw(EnSsh* this, GlobalContext* globalCtx) { + if (this->stunTimer != 0) { + EnSsh_Stunned(this, globalCtx); + } else { + EnSsh_Turn(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809758B0.s") +void EnSsh_Bob(EnSsh* this, GlobalContext* globalCtx) { + f32 bobVel = 0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975998.s") + if (globalCtx->state.frames & 8) { + bobVel *= -1.0f; + } + Math_SmoothStepToF(&this->actor.velocity.y, bobVel, 0.4f, 1000.0f, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975A98.s") +s32 EnSsh_IsCloseToLink(EnSsh* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 yDist; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975B6C.s") + if (this->stateFlags & SSH_STATE_GROUND_START) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975C14.s") + if (this->unkTimer != 0) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/EnSsh_Update.s") + if (this->swayTimer != 0) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975DBC.s") + if (this->animTimer != 0) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975EB8.s") + if (this->actor.xzDistToPlayer > 160.0f) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/EnSsh_Draw.s") + yDist = this->actor.world.pos.y - player->actor.world.pos.y; + if ((yDist < 0.0f) || (yDist > 400.0f)) { + return false; + } + + if (player->actor.world.pos.y < this->actor.floorHeight) { + return false; + } + + return true; +} + +s32 EnSsh_IsCloseToHome(EnSsh* this) { + f32 vel = this->actor.velocity.y; + f32 nextY = this->actor.world.pos.y + vel * 2.0f; + + if (this->actor.home.pos.y <= nextY) { + return true; + } + return false; +} + +s32 EnSsh_IsCloseToGround(EnSsh* this) { + f32 vel = this->actor.velocity.y; + f32 nextY = this->actor.world.pos.y + vel * 2.0f; + + if ((nextY - this->actor.floorHeight) <= this->floorHeightOffset) { + return true; + } + return false; +} + +void EnSsh_Sway(EnSsh* this) { + Vec3f swayVecBase; + Vec3f swayVec; + f32 temp_f20; + s16 swayAngle; + + if (this->swayTimer != 0) { + this->swayAngle += 1600; + this->swayTimer--; + if (this->swayTimer == 0) { + this->swayAngle = 0; + } + + temp_f20 = (this->swayTimer * (1.0f / 6)); + swayAngle = Math_SinS(this->swayAngle) * (temp_f20 * (0x10000 / 360.0f)); + temp_f20 = this->actor.world.pos.y - this->ceilingPos.y; + + swayVecBase.x = Math_SinS(swayAngle) * temp_f20; + swayVecBase.y = Math_CosS(swayAngle) * temp_f20; + swayVecBase.z = 0.0f; + + Matrix_StatePush(); + Matrix_InsertTranslation(this->ceilingPos.x, this->ceilingPos.y, this->ceilingPos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(this->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&swayVecBase, &swayVec); + Matrix_StatePop(); + + this->actor.shape.rot.z = -(swayAngle * 2); + this->actor.world.pos.x = swayVec.x; + this->actor.world.pos.z = swayVec.z; + } +} + +void EnSsh_CheckBodyStickHit(EnSsh* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + ColliderInfo* colliderInfo = &this->collider1[0].info; + + if (player->unk_B28 != 0) { + colliderInfo->bumper.dmgFlags |= 2; + this->collider1[1].info.bumper.dmgFlags &= ~2; + this->collider1[2].info.bumper.dmgFlags &= ~2; + } else { + colliderInfo->bumper.dmgFlags &= ~2; + this->collider1[1].info.bumper.dmgFlags |= 2; + this->collider1[2].info.bumper.dmgFlags |= 2; + } +} + +s32 EnSsh_CheckHitPlayer(EnSsh* this, GlobalContext* globalCtx) { + s32 i; + s32 hit = false; + + if ((this->hitCount == 0) && (this->spinTimer == 0)) { + return false; + } + + for (i = 0; i < ARRAY_COUNT(this->collider1) / 2; i++) { + if (this->collider1[3 + i].base.ocFlags2 & OC2_HIT_PLAYER) { + this->collider1[3 + i].base.ocFlags2 &= ~OC2_HIT_PLAYER; + hit = true; + } + } + + if (!hit) { + return false; + } + + this->hitTimer = 30; + if (this->swayTimer == 0) { + this->spinTimer = this->hitTimer; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_ST_ATTACK); + + globalCtx->damagePlayer(globalCtx, -8); + + func_800B8D98(globalCtx, &this->actor, 4.0f, this->actor.yawTowardsPlayer, 6.0f); + this->hitCount--; + return true; +} + +s32 EnSsh_CheckHitFront(EnSsh* this) { + u32 acFlags; + + if (this->collider1[2].base.acFlags) {} + acFlags = this->collider1[2].base.acFlags; + + if (!!(acFlags & AC_HIT) == 0) { + return false; + } + + this->collider1[2].base.acFlags &= ~AC_HIT; + this->invincibilityTimer = 8; + + if ((this->swayTimer == 0) && (this->hitTimer == 0) && (this->stunTimer == 0)) { + this->swayTimer = 60; + } + + return true; +} + +s32 EnSsh_CheckHitBack(EnSsh* this, GlobalContext* globalCtx) { + ColliderCylinder* collider = &this->collider1[0]; + s32 hit = false; + + if (collider->base.acFlags & AC_HIT) { + collider->base.acFlags &= ~AC_HIT; + hit = true; + } + + collider = &this->collider1[1]; + if (collider->base.acFlags & AC_HIT) { + collider->base.acFlags &= ~AC_HIT; + hit = true; + } + + if (!hit) { + return false; + } + + this->invincibilityTimer = 8; + if (this->hitCount <= 0) { + this->hitCount++; + } + + if (this->stunTimer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_ST_DAMAGE); + } + + EnSsh_SetStunned(this); + this->stateFlags |= SSH_STATE_STUNNED; + return false; +} + +s32 EnSsh_CollisionCheck(EnSsh* this, GlobalContext* globalCtx) { + if (this->stunTimer == 0) { + EnSsh_CheckHitPlayer(this, globalCtx); + } + + if (EnSsh_CheckHitFront(this)) { + return false; + } + + if (globalCtx->actorCtx.unk2 != 0) { + this->invincibilityTimer = 8; + if (this->stunTimer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_ST_DAMAGE); + } + EnSsh_SetStunned(this); + this->stateFlags |= SSH_STATE_STUNNED; + return false; + } + + return EnSsh_CheckHitBack(this, globalCtx); +} + +void EnSsh_SetBodyCylinderAC(EnSsh* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider1[0]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1[0].base); +} + +void EnSsh_SetLegsCylinderAC(EnSsh* this, GlobalContext* globalCtx) { + s16 angleTowardsLink = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)); + + if (angleTowardsLink < (90 * (0x10000 / 360))) { + Collider_UpdateCylinder(&this->actor, &this->collider1[2]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1[2].base); + } else { + Collider_UpdateCylinder(&this->actor, &this->collider1[1]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1[1].base); + } +} + +s32 EnSsh_SetCylinderOC(EnSsh* this, GlobalContext* globalCtx) { + Vec3f colliderOffsets[] = { { 40.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { -40.0f, 0.0f, 0.0f } }; + Vec3f colliderPos; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->collider1) / 2; i++) { + colliderPos = this->actor.world.pos; + + colliderOffsets[i].x *= this->colliderScale; + colliderOffsets[i].y *= this->colliderScale; + colliderOffsets[i].z *= this->colliderScale; + + Matrix_StatePush(); + Matrix_InsertTranslation(colliderPos.x, colliderPos.y, colliderPos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(BINANG_TO_RAD(this->initialYaw), MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&colliderOffsets[i], &colliderPos); + Matrix_StatePop(); + + this->collider1[3 + i].dim.pos.x = colliderPos.x; + this->collider1[3 + i].dim.pos.y = colliderPos.y; + this->collider1[3 + i].dim.pos.z = colliderPos.z; + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1[3 + i].base); + } + + return true; +} + +void EnSsh_SetColliders(EnSsh* this, GlobalContext* globalCtx) { + if (this->actor.colChkInfo.health == 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + return; + } + + if (this->hitTimer == 0) { + EnSsh_SetCylinderOC(this, globalCtx); + } + + if (DECR(this->invincibilityTimer) == 0) { + EnSsh_SetBodyCylinderAC(this, globalCtx); + EnSsh_SetLegsCylinderAC(this, globalCtx); + } +} + +void EnSsh_Init(Actor* thisx, GlobalContext* globalCtx) { + // @bug - this symbol no longer exists, reads from a random place in object_ssh_Tex_000190 instead + f32 frameCount = Animation_GetLastFrame(&D_06000304); + s32 pad; + EnSsh* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_ssh_Skel_006470, NULL, this->jointTable, this->morphtable, 30); + Animation_Change(&this->skelAnime, &object_ssh_Anim_001494, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP_INTERP, 0.0f); + this->blureIdx = EnSsh_CreateBlureEffect(globalCtx); + EnSsh_InitColliders(this, globalCtx); + this->stateFlags = 0; + this->hitCount = 0; + EnSsh_CheckCeilingPos(this, globalCtx); + + if (!ENSSH_IS_CHILD(&this->actor)) { + this->stateFlags |= SSH_STATE_FATHER; + } + + if (!(this->stateFlags & SSH_STATE_FATHER)) { + EnSsh_SetColliderScale(this, 0.5f, 1.0f); + } else { + EnSsh_SetColliderScale(this, 0.75f, 1.0f); + } + + this->actor.gravity = 0.0f; + this->initialYaw = this->actor.world.rot.y; + EnSsh_SetupAction(this, EnSsh_Start); + if (func_8012F22C(globalCtx->sceneNum) >= 30) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnSsh_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSsh* this = THIS; + s32 i; + + Effect_Destroy(globalCtx, this->blureIdx); + + for (i = 0; i < ARRAY_COUNT(this->collider1); i++) { + Collider_DestroyCylinder(globalCtx, &this->collider1[i]); + } + + Collider_DestroyJntSph(globalCtx, &this->collider2); +} + +void EnSsh_Wait(EnSsh* this, GlobalContext* globalCtx) { + if (EnSsh_IsCloseToLink(this, globalCtx)) { + EnSsh_SetDropAnimation(this); + EnSsh_SetupAction(this, EnSsh_Drop); + } else { + EnSsh_Bob(this, globalCtx); + } +} + +void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { + EnSsh_Bob(this, globalCtx); + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x904: + case 0x905: + case 0x906: + case 0x908: + case 0x910: + case 0x911: + case 0x912: + case 0x914: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = EnSsh_Idle; + break; + } + } +} + +void func_809756D0(EnSsh* this, GlobalContext* globalCtx) { + u16 phi_a1; + + if (gSaveContext.weekEventReg[34] & 8) { + phi_a1 = 0x914; + } else { + phi_a1 = 0x910; + gSaveContext.weekEventReg[34] |= 8; + } + func_801518B0(globalCtx, phi_a1, &this->actor); +} + +void EnSsh_Idle(EnSsh* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = EnSsh_Talk; + func_809756D0(this, globalCtx); + return; + } + + if ((this->unkTimer != 0) && (DECR(this->unkTimer) == 0)) { + EnSsh_SetAnimation(this, SSH_ANIM_WAIT); + } + + if ((this->animTimer != 0) && (DECR(this->animTimer) == 0)) { + EnSsh_SetAnimation(this, SSH_ANIM_WAIT); + } + + if (!EnSsh_IsCloseToLink(this, globalCtx)) { + EnSsh_SetReturnAnimation(this); + EnSsh_SetupAction(this, EnSsh_Return); + return; + } + + if (DECR(this->sfxTimer) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_LAUGH); + this->sfxTimer = 64; + } + + EnSsh_Bob(this, globalCtx); + + if ((this->unkTimer == 0) && (this->animTimer == 0) && (this->actor.xzDistToPlayer < 100.0f) && + Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} + +void EnSsh_Land(EnSsh* this, GlobalContext* globalCtx) { + if ((this->unkTimer != 0) && (DECR(this->unkTimer) == 0)) { + EnSsh_SetAnimation(this, SSH_ANIM_WAIT); + } + + if ((this->animTimer != 0) && (DECR(this->animTimer) == 0)) { + EnSsh_SetAnimation(this, SSH_ANIM_WAIT); + } + + if ((this->actor.floorHeight + this->floorHeightOffset) <= this->actor.world.pos.y) { + EnSsh_SetupAction(this, EnSsh_Idle); + } else { + Math_SmoothStepToF(&this->actor.velocity.y, 2.0f, 0.6f, 1000.0f, 0.0f); + } +} + +void EnSsh_Drop(EnSsh* this, GlobalContext* globalCtx) { + if ((this->unkTimer != 0) && (DECR(this->unkTimer) == 0)) { + EnSsh_SetAnimation(this, SSH_ANIM_DROP); + } + + if (!EnSsh_IsCloseToLink(this, globalCtx)) { + EnSsh_SetReturnAnimation(this); + EnSsh_SetupAction(this, EnSsh_Return); + } else if (EnSsh_IsCloseToGround(this)) { + EnSsh_SpawnShockwave(this, globalCtx); + EnSsh_SetLandAnimation(this); + EnSsh_SetupAction(this, EnSsh_Land); + } else if (DECR(this->sfxTimer) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_DOWN); + this->sfxTimer = 3; + } +} + +void EnSsh_Return(EnSsh* this, GlobalContext* globalCtx) { + f32 frameRatio = this->skelAnime.curFrame / (this->skelAnime.animLength - 1.0f); + + if (frameRatio == 1.0f) { + EnSsh_SetReturnAnimation(this); + } + + if (EnSsh_IsCloseToLink(this, globalCtx)) { + EnSsh_SetDropAnimation(this); + EnSsh_SetupAction(this, EnSsh_Drop); + } else if (EnSsh_IsCloseToHome(this)) { + EnSsh_SetWaitAnimation(this); + EnSsh_SetupAction(this, EnSsh_Wait); + } else { + this->actor.velocity.y = 4.0f * frameRatio; + } +} + +void EnSsh_UpdateColliderScale(EnSsh* this) { + if (this->stateFlags & SSH_STATE_SPIN) { + if (this->spinTimer == 0) { + this->stateFlags &= ~SSH_STATE_SPIN; + if (!(this->stateFlags & SSH_STATE_FATHER)) { + EnSsh_SetColliderScale(this, 0.5f, 1.0f); + } else { + EnSsh_SetColliderScale(this, 0.75f, 1.0f); + } + } + } else if (this->spinTimer != 0) { + this->stateFlags |= SSH_STATE_SPIN; + if (!(this->stateFlags & SSH_STATE_FATHER)) { + EnSsh_SetColliderScale(this, 0.5f, 2.0f); + } else { + EnSsh_SetColliderScale(this, 0.75f, 2.0f); + } + } +} + +void EnSsh_Start(EnSsh* this, GlobalContext* globalCtx) { + if (!EnSsh_IsCloseToGround(this)) { + EnSsh_SetupAction(this, EnSsh_Wait); + EnSsh_Wait(this, globalCtx); + } else { + EnSsh_SetLandAnimation(this); + this->stateFlags |= SSH_STATE_GROUND_START; + EnSsh_SetupAction(this, EnSsh_Land); + EnSsh_Land(this, globalCtx); + } +} + +void EnSsh_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSsh* this = THIS; + + EnSsh_UpdateColliderScale(this); + + if (EnSsh_CollisionCheck(this, globalCtx)) { + return; + } + + if (this->stunTimer != 0) { + EnSsh_Damaged(this); + } else { + SkelAnime_Update(&this->skelAnime); + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->actionFunc(this, globalCtx); + } + + EnSsh_UpdateYaw(this, globalCtx); + + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(60, 60); + } + + this->blinkState = this->blinkTimer; + if (this->blinkState >= 3) { + this->blinkState = 0; + } + + EnSsh_SetColliders(this, globalCtx); + Actor_SetFocus(&this->actor, 0.0f); +} + +s32 EnSsh_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnSsh* this = THIS; + + switch (limbIndex) { + case 1: + if ((this->spinTimer != 0) && (this->swayTimer == 0)) { + if (this->spinTimer >= 2) { + EnSsh_AddBlureVertex(this); + } else { + EnSsh_AddBlureSpace(this); + } + } + break; + + case 4: + if (this->stateFlags & SSH_STATE_FATHER) { + *dList = object_ssh_DL_005850; + } + break; + + case 5: + if (this->stateFlags & SSH_STATE_FATHER) { + *dList = object_ssh_DL_005210; + } + break; + + case 8: + if (this->stateFlags & SSH_STATE_FATHER) { + *dList = object_ssh_DL_005F78; + } + break; + } + return false; +} + +void EnSsh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnSsh* this = THIS; + + if ((limbIndex == 5) && (this->stateFlags & SSH_STATE_FATHER)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, object_ssh_DL_0000D8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + Collider_UpdateSpheres(limbIndex, &this->collider2); +} + +void EnSsh_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr D_80976178[] = { object_ssh_Tex_001970, object_ssh_Tex_001DF0, object_ssh_Tex_0021F0 }; + s32 pad; + EnSsh* this = THIS; + + EnSsh_CheckBodyStickHit(this, globalCtx); + EnSsh_Sway(this); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_80976178[this->blinkState])); + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSsh_OverrideLimbDraw, + EnSsh_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h index 7d081f88c2..172ecf0a51 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h @@ -7,11 +7,53 @@ struct EnSsh; typedef void (*EnSshActionFunc)(struct EnSsh*, GlobalContext*); +#define SSH_STATE_STUNNED (1 << 0) +#define SSH_STATE_GROUND_START (1 << 2) +#define SSH_STATE_ATTACKED (1 << 3) +#define SSH_STATE_SPIN (1 << 4) +#define SSH_STATE_FATHER (1 << 5) + +typedef enum { + SSH_ANIM_UNK0, // Unused animation. Possibly being knocked back? + SSH_ANIM_UP, + SSH_ANIM_WAIT, + SSH_ANIM_LAND, + SSH_ANIM_DROP, + SSH_ANIM_UNK5, // Slower version of ANIM_DROP + SSH_ANIM_UNK6 // Faster repeating version of ANIM_UNK0 +} EnSshAnimation; + +#define ENSSH_IS_CHILD(thisx) ((thisx)->params & 0xF) + typedef struct EnSsh { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1AC]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[30]; + /* 0x023C */ Vec3s morphtable[30]; /* 0x02F0 */ EnSshActionFunc actionFunc; - /* 0x02F4 */ char unk_2F4[0x2D8]; + /* 0x02F4 */ ColliderCylinder collider1[6]; + /* 0x04BC */ ColliderJntSph collider2; + /* 0x04DC */ ColliderJntSphElement collider2Elements[1]; + /* 0x051C */ s16 initialYaw; + /* 0x051E */ s16 maxTurnRate; + /* 0x0520 */ s16 unkTimer; + /* 0x0522 */ s16 spinTimer; + /* 0x0524 */ s16 hitTimer; + /* 0x0526 */ s16 invincibilityTimer; + /* 0x0528 */ s16 sfxTimer; + /* 0x052A */ s16 stunTimer; + /* 0x052C */ s16 animTimer; + /* 0x052E */ s16 swayTimer; + /* 0x0530 */ s32 blureIdx; + /* 0x0534 */ f32 colliderScale; + /* 0x0538 */ f32 floorHeightOffset; + /* 0x053C */ Vec3f ceilingPos; + /* 0x0548 */ UNK_TYPE1 unk_548[0x78]; + /* 0x05C0 */ s16 swayAngle; + /* 0x05C2 */ u16 stateFlags; + /* 0x05C4 */ u8 hitCount; + /* 0x05C6 */ s16 blinkState; + /* 0x05C8 */ s16 blinkTimer; } EnSsh; // size = 0x5CC extern const ActorInit En_Ssh_InitVars; diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c index c8335d92c1..e3116fb3c2 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -5,6 +5,8 @@ */ #include "z_en_st.h" +#include "objects/object_st/object_st.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x01004035 @@ -19,8 +21,8 @@ void func_808A6C04(EnSt* this, GlobalContext* globalCtx); void func_808A6D84(EnSt* this, GlobalContext* globalCtx); void func_808A6E24(EnSt* this, GlobalContext* globalCtx); void func_808A701C(EnSt* this, GlobalContext* globalCtx); +void func_808A7478(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_St_InitVars = { ACTOR_EN_ST, ACTORCAT_ENEMY, @@ -33,39 +35,89 @@ const ActorInit En_St_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808A75B0 = { - { COLTYPE_HIT2, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x800C3829, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HIT2, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x800C3829, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 18, 48, -20, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808A75DC = { - { COLTYPE_HIT2, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x77C3C7D6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT2, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x77C3C7D6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 18, 48, -20, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808A7608 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0x77C3C7D6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit3 = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0x77C3C7D6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 18, 48, -20, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808A7634 = { - { COLTYPE_HIT2, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x800C3829, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit4 = { + { + COLTYPE_HIT2, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x800C3829, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 18, 48, -20, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_808A7660 = { 2, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 2, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_808A766C = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -100,73 +152,791 @@ static DamageTable D_808A766C = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -#endif +static ActorAnimationEntryS sAnimations[] = { + { &object_st_Anim_000304, 1.0f, 0, -1, 0, 0 }, { &object_st_Anim_005B98, 1.0f, 0, -1, 2, -4 }, + { &object_st_Anim_000304, 4.0f, 0, -1, 2, -4 }, { &object_st_Anim_000304, 1.0f, 0, -1, 0, -4 }, + { &object_st_Anim_0055A8, 1.0f, 0, -1, 2, -4 }, { &object_st_Anim_000304, 8.0f, 0, -1, 0, -4 }, + { &object_st_Anim_000304, 6.0f, 0, -1, 2, -4 }, { &object_st_Anim_005B98, 2.0f, 0, -1, 0, -4 }, +}; -extern ColliderCylinderInit D_808A75B0; -extern ColliderCylinderInit D_808A75DC; -extern ColliderCylinderInit D_808A7608; -extern ColliderCylinderInit D_808A7634; -extern CollisionCheckInfoInit2 D_808A7660; -extern DamageTable D_808A766C; +void func_808A5050(EnSt* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_808A770C = { 170, 130, 90, 255 }; + static Color_RGBA8 D_808A7710 = { 100, 60, 20, 0 }; + s32 i; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + s32 rand; + s16 temp_s0 = (Rand_ZeroOne() - 0.5f) * 0x10000; -extern UNK_TYPE D_06005298; + spA0.y = this->actor.floorHeight; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5050.s") + for (i = 0; i < 16; i++, temp_s0 += 0xFFF) { + rand = (Rand_ZeroOne() * 4.0f) + 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A52A8.s") + sp94.x = 0.0f; + sp94.y = (Rand_ZeroOne() * 0.2f) + 0.1f; + sp94.z = Rand_ZeroOne() + 1.0f; + Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, temp_s0, &sp94, &spAC); + sp94.x = 0.0f; + sp94.y = 1.0f; + sp94.z = 5.0f; + Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, temp_s0, &sp94, &spB8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A54B0.s") + spA0.x = this->actor.world.pos.x + (2.0f * spB8.x); + spA0.z = this->actor.world.pos.z + (2.0f * spB8.z); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A576C.s") + func_800B0EB0(globalCtx, &spA0, &spB8, &spAC, &D_808A770C, &D_808A7710, 100, 40, rand); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5988.s") + spA0.x = this->actor.world.pos.x; + spA0.z = this->actor.world.pos.z; + spA0.y = this->actor.floorHeight; + EffectSsBlast_SpawnWhiteCustomScale(globalCtx, &spA0, &gZeroVec3f, &gZeroVec3f, 100, 220, 8); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5AF8.s") +void func_808A52A8(EnSt* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_808A7714 = { 170, 130, 90, 255 }; + static Color_RGBA8 D_808A7718 = { 100, 60, 20, 0 }; + s32 pad; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + s32 i; + s16 temp_s0 = (Rand_ZeroOne() - 0.5f) * 0x10000; + s32 rand; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5BEC.s") + spA0.y = this->actor.floorHeight; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5CCC.s") + for (i = 0; i < 8; i++, temp_s0 += 0x1FFE) { + rand = (Rand_ZeroOne() * 4.0f) + 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5D7C.s") + sp94.x = 0.0f; + sp94.y = (Rand_ZeroOne() * 0.2f) + 0.1f; + sp94.z = Rand_ZeroOne() + 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5DCC.s") + Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, temp_s0, &sp94, &spAC); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5F28.s") + sp94.x = 0.0f; + sp94.y = 1.0f; + sp94.z = 4.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6064.s") + Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, temp_s0, &sp94, &spB8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A60E0.s") + spA0.x = this->actor.world.pos.x + (2.0f * spB8.x); + spA0.z = this->actor.world.pos.z + (2.0f * spB8.z); + func_800B0EB0(globalCtx, &spA0, &spB8, &spAC, &D_808A7714, &D_808A7718, 100, 40, rand); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A61F4.s") +void func_808A54B0(EnSt* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6220.s") + if ((this->unk_18C & 1) && (this->actor.colChkInfo.health != 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A63E8.s") + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[this->unk_2C0].segment); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6468.s") + gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_2C0].segment); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A650C.s") + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.06f, 0.12f, 0.06f, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6580.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 195, 0, 0x40, 0x20, 1, 215, 0, 8, 8)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6A3C.s") + temp_f0 = (f32)this->unk_310 / 8; + if (temp_f0 > 1.0f) { + temp_f0 = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6A78.s") + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u8)(255 * temp_f0)); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_025850); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_025970); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6C04.s") + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6D84.s") +s32 func_808A576C(EnSt* this) { + s32 i; + s16 phi_s2 = (s16)((s16)(Rand_ZeroOne() * 1000.0f) % 12) * 0x1555; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6E24.s") + for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++, phi_s2 += 0x1555) { + if (this->unk_18E != 10) { + this->unk_31C[i] = (Rand_ZeroOne() * 16.0f) + 8.0f; + } else { + this->unk_31C[i] = 80; + } + this->unk_334[i] = this->unk_31C[i]; + this->unk_2DC[i] = 0.90000004f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A701C.s") + if ((this->unk_18E == 0) || (this->unk_18E == 1)) { + this->unk_358[i].y = ((Rand_ZeroOne() - 0.5f) * 40.0f) - 10.0f; + } else { + this->unk_358[i].y = ((Rand_ZeroOne() - 0.5f) * 30.0f) + 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/EnSt_Init.s") + this->unk_358[i].x = Math_SinS(phi_s2) * 18.0f; + this->unk_358[i].z = Math_CosS(phi_s2) * 18.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/EnSt_Destroy.s") + this->unk_31A = 1; + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/EnSt_Update.s") +s32 func_808A5988(EnSt* this, GlobalContext* globalCtx, s32 arg2) { + s32 ret = false; + u8 sp53; + Vec3f sp44; + f32 sp40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A73E8.s") + if (arg2 < this->unk_31A) { + if (this->unk_31C[arg2] != 0) { + sp40 = (f32)this->unk_31C[arg2] / this->unk_334[arg2]; + sp53 = this->unk_18E; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A7478.s") + Math_ApproachF(&this->unk_2DC[arg2], 0.6f, 0.3f, 0.5f); + Math_Vec3f_Copy(&sp44, &this->actor.world.pos); + + sp44.x += this->unk_358[arg2].x; + sp44.y += this->unk_358[arg2].y; + sp44.z += this->unk_358[arg2].z; + + if (sp53 == 10) { + if ((this->unk_334[arg2] - this->unk_31C[arg2]) < 20) { + sp53 = 11; + } + sp40 = 1.0f; + } + func_800BE680(globalCtx, &this->actor, &sp44, 1, 0.6f, this->unk_2DC[arg2], sp40, sp53); + ret = true; + } + } + return ret; +} + +void func_808A5AF8(EnSt* this, GlobalContext* globalCtx) { + Vec3f sp54; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_358); i++) { + Math_Vec3f_Copy(&sp54, &this->actor.world.pos); + sp54.x += this->unk_358[i].x; + sp54.y += this->unk_358[i].y; + sp54.z += this->unk_358[i].z; + Math_Vec3f_Copy(&this->unk_358[i], &sp54); + } + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_358, 12, 3, 0.1f, 0.3f); +} + +s16 func_808A5BEC(EnSt* this) { + s16 ret; + + if (!(this->unk_18C & 4) || (this->actor.xzDistToPlayer > 180.0f)) { + ret = this->actor.home.rot.y; + } else { + ret = this->actor.yawTowardsPlayer; + if (DECR(this->unk_30E) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_ROLL); + this->unk_18C ^= 2; + this->unk_310 = 8; + if (this->unk_18C & 1) { + this->unk_310 *= 2; + } + this->unk_30E = 30; + } + + if (this->unk_18C & 2) { + ret = BINANG_ROT180(ret); + } + } + + return ret; +} + +void func_808A5CCC(EnSt* this) { + if (this->unk_310 != 0) { + this->unk_310--; + } + + if (this->unk_310 < 8) { + Math_ApproachS(&this->actor.world.rot.y, func_808A5BEC(this), 3, 0x1FFE); + } else { + this->actor.world.rot.y += 0x2AA8; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (DECR(this->unk_310) == 0) { + this->unk_18C &= ~1; + } +} + +void func_808A5D7C(EnSt* this) { + if (this->unk_2C8 > 0.0f) { + this->actor.world.pos.y = this->actor.home.pos.y - 10.0f; + } else { + this->actor.world.pos.y = this->actor.floorHeight + 20.0f; + } +} + +void func_808A5DCC(EnSt* this, Color_RGB8* colour) { + if (this->unk_2D8 == 0.0f) { + Math_SmoothStepToF(&this->unk_34C, 0.0f, 0.3f, 1000.0f, 0.0f); + } else { + this->unk_34C += this->unk_2D8; + if (this->unk_34C >= 255.0f) { + this->unk_34C = 255.0f; + this->unk_2D8 *= -1.0f; + } + + if (this->unk_34C <= 0.0f) { + this->unk_34C = 0.0f; + this->unk_2D8 *= -1.0f; + } + } + + colour->r = this->unk_34C; + colour->g = 0; + colour->b = 0; +} + +s32 func_808A5F28(EnSt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 ret = false; + + if (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) { + if (this->unk_2C8 <= 0.0f) { + return false; + } + return true; + } + + if ((((this->unk_2C8 > 0.0f) && (this->actor.world.pos.y < player->actor.world.pos.y)) || + ((this->unk_2C8 > 0.0f) && (this->actor.xzDistToPlayer > 180.0f)) || + ((this->unk_2C8 < 0.0f) && (player->actor.world.pos.y <= this->actor.world.pos.y) && + (this->actor.floorHeight <= player->actor.world.pos.y) && (this->actor.xzDistToPlayer < 120.0f))) && + !(this->unk_18C & 8)) { + ret = true; + } + + return ret; +} + +s32 func_808A6064(EnSt* this) { + s32 ret = false; + + if (this->unk_2C8 > 0.0f) { + if ((this->actor.home.pos.y - 10.0f) < this->actor.world.pos.y) { + ret = true; + } + } else if (this->actor.world.pos.y < (this->actor.floorHeight + 20.0f)) { + ret = true; + } + return ret; +} + +void func_808A60E0(EnSt* this) { + s32 idx = (this->unk_2C8 > 0.0f) ? 2 : 6; + f32 sp20 = (this->unk_2C8 > 0.0f) ? 4.0f : 9.0f; + f32 sp1C; + u16 sfxId = (this->unk_2C8 < 0.0f) ? NA_SE_EN_STALTU_DOWN : NA_SE_EN_STALTU_UP; + + sp1C = this->skelAnime.curFrame / (this->skelAnime.animLength - 1.0f); + + if (sp1C == 1.0f) { + func_8013BC6C(&this->skelAnime, sAnimations, idx); + Actor_PlaySfxAtPos(&this->actor, sfxId); + } + + this->unk_2D4 = (1.0f - sp1C) * sp20 * this->unk_2C8; + + if (this->unk_2C8 < 0.0f) { + this->unk_2D4 = this->unk_2C8 * sp20; + } +} + +s32 func_808A61F4(EnSt* this) { + if (this->actor.colChkInfo.damage < this->actor.colChkInfo.health) { + this->actor.colChkInfo.health -= this->actor.colChkInfo.damage; + } else { + this->actor.colChkInfo.health = 0; + } + return this->actor.colChkInfo.health; +} + +void func_808A6220(EnSt* this, GlobalContext* globalCtx) { + s32 pad; + + if ((DECR(this->unk_314) == 0) && (this->actor.colChkInfo.health != 0)) { + Collider_UpdateCylinder(&this->actor, &this->collider2); + Collider_UpdateCylinder(&this->actor, &this->collider3); + Collider_UpdateCylinder(&this->actor, &this->collider4); + if ((s16)ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)) < 0x4E00) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider4.base); + } + + if (this->actor.colChkInfo.health != 0) { + Collider_UpdateCylinder(&this->actor, &this->collider1); + if (((this->unk_2C8 < 0.0f) && (this->unk_18C & 0x10)) || (this->unk_18C & 1)) { + this->collider1.dim.yShift = -40; + this->collider1.dim.radius = 56; + this->collider1.dim.height = 80; + } else { + this->collider1.dim.yShift = -20; + this->collider1.dim.radius = 18; + this->collider1.dim.height = 48; + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } +} + +void func_808A63E8(EnSt* this) { + func_8013BC6C(&this->skelAnime, sAnimations, 3); + this->unk_2C8 = 1.0f; + func_808A5D7C(this); + this->unk_30C = 0; + this->unk_18C &= ~0x10; + this->unk_2C8 = -1.0f; + this->unk_2D4 = 0.0f; + this->unk_2CC = 0.0f; + this->unk_2C4 = 1.0f; +} + +void func_808A6468(EnSt* this, GlobalContext* globalCtx) { + func_808A5050(this, globalCtx); + func_8013BC6C(&this->skelAnime, sAnimations, 4); + this->unk_18C |= (0x8 | 0x4); + this->unk_18C &= ~(0x10 | 0x2); + this->unk_2C8 = -1.0f; + func_808A5D7C(this); + this->unk_30E = 30; + this->unk_30C = 0; + this->unk_2C8 = 1.0f; + this->unk_2D8 = 30.0f; + this->unk_2D4 = 0.0f; + this->unk_2CC = 0.0f; + this->unk_2C4 = 6.0f; +} + +void func_808A650C(EnSt* this) { + s32 idx = (this->unk_2C8 > 0.0f) ? 2 : 6; + + func_8013BC6C(&this->skelAnime, sAnimations, idx); + this->unk_2CC = 0.0f; + this->unk_2D4 = 0.0f; + this->unk_2D8 = 0.0f; + this->unk_18C &= ~4; + this->unk_18C |= 0x10; +} + +s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { + Player* sp3C = GET_PLAYER(globalCtx); + s32 ret = false; + s32 i; + + if (this->unk_316 != 0) { + this->unk_316--; + } + + if (this->collider3.base.acFlags & AC_HIT) { + if (this->unk_18E == 10) { + // clang-format off + for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { this->unk_31C[i] = 0; } + // clang-format on + + this->unk_318 = 0; + } + + if (this->actor.colChkInfo.damageEffect == 4) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + this->collider3.base.acFlags &= ~AC_HIT; + } + + if ((this->collider2.base.acFlags & AC_HIT) || (this->collider4.base.acFlags & AC_HIT)) { + this->collider2.base.acFlags &= ~AC_HIT; + this->collider4.base.acFlags &= ~AC_HIT; + if (this->actor.colChkInfo.damageEffect == 4) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + + if (this->unk_18E == 10) { + // clang-format off + for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { this->unk_31C[i] = 0; } + // clang-format on + + this->unk_318 = 0; + } else if (func_808A61F4(this)) { + switch (this->actor.colChkInfo.damageEffect) { + case 1: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->unk_312 = 40; + Actor_SetColorFilter(&this->actor, 0, 200, 0, this->unk_312); + break; + + case 5: + this->unk_18E = 30; + this->unk_312 = 40; + func_808A576C(this); + Actor_SetColorFilter(&this->actor, 0, 200, 0, this->unk_312); + break; + + default: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_DAMAGE); + this->unk_314 = 20; + this->unk_312 = 0; + Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_314); + func_8013BC6C(&this->skelAnime, sAnimations, 1); + this->unk_18C |= 8; + this->actionFunc = func_808A6D84; + this->unk_2C8 = -1.0f; + break; + } + } else { + if (ENST_GET_3F(&this->actor) != ENST_3F_63) { + Flags_SetSwitch(globalCtx, ENST_GET_3F(&this->actor)); + } + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + + this->actor.flags &= ~1; + + switch (this->actor.colChkInfo.damageEffect) { + case 4: + this->unk_18E = 20; + this->unk_318 = 20; + func_808A576C(this); + break; + + case 3: + this->unk_18E = 10; + this->unk_318 = 0; + func_808A576C(this); + break; + + case 2: + this->unk_18E = 0; + this->unk_318 = 20; + func_808A576C(this); + break; + + default: + this->unk_18E = 1; + this->unk_318 = 0; + break; + } + + if (this->unk_18E != 10) { + func_8013BC6C(&this->skelAnime, sAnimations, 7); + this->unk_2CC = 0.0f; + this->unk_2D4 = 0.0f; + this->actor.gravity = -1.0f; + } + this->unk_314 = 20; + this->unk_312 = 0; + Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_314); + ret = true; + } + this->unk_310 = 0; + this->unk_18C &= ~1; + } + + if ((this->collider1.base.ocFlags2 & OC2_HIT_PLAYER) || (this->collider1.base.atFlags & AT_HIT)) { + if ((this->unk_316 == 0) && (this->unk_314 == 0) && (this->unk_312 == 0) && + !(this->collider1.base.atFlags & AT_BOUNCED) && (this->actor.colChkInfo.health != 0)) { + globalCtx->damagePlayer(globalCtx, -8); + Actor_PlaySfxAtPos(&sp3C->actor, NA_SE_PL_BODY_HIT); + func_800B8D98(globalCtx, &this->actor, 4.0f, this->actor.yawTowardsPlayer, 6.0f); + this->unk_316 = 10; + this->unk_18C |= 1; + this->unk_30E = 0; + } + this->collider1.base.ocFlags1 &= ~OC1_HIT; + this->collider1.base.atFlags &= ~AT_HIT; + } + return ret; +} + +s32 func_808A6A3C(EnSt* this) { + s32 ret = false; + + if ((ENST_GET_1C0(&this->actor) == ENST_1C0_1) && (this->actor.colChkInfo.health != 0)) { + ret = true; + } + return ret; +} + +void func_808A6A78(EnSt* this, GlobalContext* globalCtx) { + s32 pad[2]; + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_2C0)) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 8.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_st_Skel_005298, NULL, this->jointTable, this->morphTable, + 30); + func_8013BC6C(&this->skelAnime, sAnimations, 0); + + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); + Collider_InitAndSetCylinder(globalCtx, &this->collider3, &this->actor, &sCylinderInit3); + Collider_InitAndSetCylinder(globalCtx, &this->collider4, &this->actor, &sCylinderInit4); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + if (ENST_GET_1C0(&this->actor) == ENST_1C0_1) { + this->actor.flags |= 0x80; + } + + Actor_SetScale(&this->actor, 0.04f); + this->actor.draw = func_808A7478; + this->actor.hintId = 4; + this->actor.gravity = 0.0f; + func_808A63E8(this); + this->unk_18C = 0; + this->unk_18C &= ~0x10; + this->actionFunc = func_808A6C04; + } +} + +void func_808A6C04(EnSt* this, GlobalContext* globalCtx) { + this->unk_2CC = Math_SinS(this->unk_30C) * this->unk_2C4; + this->unk_30C += 0xE00; + Math_ApproachF(&this->unk_2C4, 1.0f, 0.1f, 0.3f); + this->actor.velocity.y = this->unk_2D4 + this->unk_2CC; + Actor_MoveWithGravity(&this->actor); + + if ((this->unk_18C & 8) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_8013BC6C(&this->skelAnime, sAnimations, 3); + this->unk_18C &= ~8; + } else if ((this->unk_310 == 0) && func_808A5F28(this, globalCtx) && !func_808A6064(this)) { + func_808A650C(this); + this->actionFunc = func_808A6D84; + } else { + if ((this->unk_316 == 0) && (this->unk_314 == 0) && (this->unk_312 == 0) && (this->unk_2C8 > 0.0f) && + (this->actor.xzDistToPlayer < 62.0f)) { + this->unk_30E = 0; + this->unk_18C |= 1; + } + func_808A5CCC(this); + } +} + +void func_808A6D84(EnSt* this, GlobalContext* globalCtx) { + func_808A60E0(this); + this->actor.velocity.y = this->unk_2D4 + this->unk_2CC; + Actor_MoveWithGravity(&this->actor); + if (func_808A6064(this)) { + if (this->unk_2C8 < 0.0f) { + func_808A6468(this, globalCtx); + } else { + func_808A63E8(this); + } + this->actionFunc = func_808A6C04; + } + func_808A5CCC(this); +} + +void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { + s32 i; + s32 count = 0; + + if (this->unk_18E == 10) { + for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { + if (DECR(this->unk_31C[i]) == 0) { + count++; + } + } + + if (count == ARRAY_COUNT(this->unk_31C)) { + func_8013BC6C(&this->skelAnime, sAnimations, 7); + this->unk_18E = 1; + this->unk_2CC = 0.0f; + this->unk_2D4 = 0.0f; + this->actor.gravity = -1.0f; + func_808A5AF8(this, globalCtx); + } + } else if (this->unk_18C & 0x80) { + this->actionFunc = func_808A701C; + this->actor.gravity = 0.0f; + this->unk_2CC = 0.0f; + this->unk_2D4 = 0.0f; + } else { + if (this->actor.bgCheckFlags & 1) { + this->actor.shape.yOffset = 400.0f; + this->actor.world.rot.x = 0x4000; + this->actor.shape.rot.x = this->actor.world.rot.x; + this->unk_2D0 = this->actor.velocity.y = fabsf(this->actor.velocity.y) * 0.6f; + this->actor.speedXZ = 0.0f; + + if ((s32)this->unk_2D0 != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + } else { + this->actor.velocity.y = 0.0f; + this->actionFunc = func_808A701C; + } + + if ((s32)this->actor.velocity.y >= 2) { + func_808A52A8(this, globalCtx); + } + } else { + Math_ApproachF(&this->actor.shape.yOffset, 400.0f, 0.3f, 1000.0f); + this->actor.world.rot.x += 0x1000; + if (this->actor.world.rot.x >= 0x4000) { + this->actor.world.rot.x = 0x4000; + } + this->actor.shape.rot.x = this->actor.world.rot.x; + } + Actor_MoveWithGravity(&this->actor); + } +} + +void func_808A701C(EnSt* this, GlobalContext* globalCtx) { + s32 i; + s32 count = 0; + + if (this->unk_18C & 0x40) { + if (DECR(this->unk_318) == 0) { + this->unk_18C |= 0x20; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { + if (DECR(this->unk_31C[i]) == 0) { + count++; + } + } + + if (count == ARRAY_COUNT(this->unk_31C)) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0); + Actor_MarkForDeath(&this->actor); + } + } else if (DECR(this->unk_318) == 0) { + this->unk_18C |= 0x40; + if (this->unk_18E == 1) { + func_808A576C(this); + this->unk_318 = 10; + } + } +} + +void EnSt_Init(Actor* thisx, GlobalContext* globalCtx) { + EnSt* this = THIS; + + this->unk_2C0 = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_KEEP); + if (((ENST_GET_3F(&this->actor) != ENST_3F_63) && Flags_GetSwitch(globalCtx, ENST_GET_3F(&this->actor))) || + (this->unk_2C0 < 0)) { + Actor_MarkForDeath(&this->actor); + } else { + this->actionFunc = func_808A6A78; + } +} + +void EnSt_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSt* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); + Collider_DestroyCylinder(globalCtx, &this->collider3); + Collider_DestroyCylinder(globalCtx, &this->collider4); +} + +void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSt* this = THIS; + + if (this->actor.flags & 0x8000) { + SkelAnime_Update(&this->skelAnime); + this->unk_18C |= 0x80; + return; + } + + if (!(this->actor.flags & 0x80) && func_808A6A3C(this)) { + this->actor.flags |= 0x80; + } + + if (func_808A6580(this, globalCtx)) { + this->actionFunc = func_808A6E24; + } else if (DECR(this->unk_312) == 0) { + this->actionFunc(this, globalCtx); + if (this->unk_18E != 10) { + SkelAnime_Update(&this->skelAnime); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 5); + } else if (this->unk_312 < 20) { + s16 idx = (this->unk_312 % 2) ? -1 : 1; + + idx *= 0x800; + idx += this->actor.world.rot.y; + this->actor.shape.rot.y = idx; + + if (this->unk_18E == 30) { + if (this->unk_312 == 1) { + s32 i; + + // clang-format off + for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { this->unk_31C[i] = 0; } + // clang-format on + } + } + } + + Actor_SetFocus(&this->actor, 0.0f); + func_808A6220(this, globalCtx); +} + +s32 EnSt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnSt* this = THIS; + Color_RGB8 sp20; + + if (limbIndex == 4) { + func_808A5DCC(this, &sp20); + + gDPPipeSync((*gfx)++); + gDPSetEnvColor((*gfx)++, sp20.r, sp20.g, sp20.b, 0); + } + return false; +} + +void func_808A7478(Actor* thisx, GlobalContext* globalCtx) { + EnSt* this = THIS; + s32 i; + s32 count; + + if (!(this->unk_18C & 0x20)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (func_808A6A3C(this)) { + func_8012C2DC(globalCtx->state.gfxCtx); + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + EnSt_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); + } else { + func_8012C28C(globalCtx->state.gfxCtx); + POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + EnSt_OverrideLimbDraw, NULL, &this->actor, POLY_OPA_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + for (i = 0, count = 0; i < ARRAY_COUNT(this->unk_31C); i++) { + count += func_808A5988(this, globalCtx, i); + } + + if (count != 0) { + this->unk_31A += 2; + } + + func_808A54B0(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_St/z_en_st.h b/src/overlays/actors/ovl_En_St/z_en_st.h index 0ad88efef6..a82ff397b4 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.h +++ b/src/overlays/actors/ovl_En_St/z_en_st.h @@ -7,11 +7,45 @@ struct EnSt; typedef void (*EnStActionFunc)(struct EnSt*, GlobalContext*); +#define ENST_GET_3F(thisx) (((thisx)->params & 0x3F) & 0xFF) +#define ENST_GET_1C0(thisx) ((((thisx)->params & 0x1C0) >> 6) & 0xFF) + +#define ENST_3F_63 63 +#define ENST_1C0_1 1 + typedef struct EnSt { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnStActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x3C4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnStActionFunc actionFunc; + /* 0x18C */ u16 unk_18C; + /* 0x18E */ u8 unk_18E; + /* 0x190 */ ColliderCylinder collider1; + /* 0x1DC */ ColliderCylinder collider2; + /* 0x228 */ ColliderCylinder collider3; + /* 0x274 */ ColliderCylinder collider4; + /* 0x2C0 */ s8 unk_2C0; + /* 0x2C4 */ f32 unk_2C4; + /* 0x2C8 */ f32 unk_2C8; + /* 0x2CC */ f32 unk_2CC; + /* 0x2D0 */ f32 unk_2D0; + /* 0x2D4 */ f32 unk_2D4; + /* 0x2D8 */ f32 unk_2D8; + /* 0x2DC */ f32 unk_2DC[12]; + /* 0x30C */ s16 unk_30C; + /* 0x30E */ s16 unk_30E; + /* 0x310 */ s16 unk_310; + /* 0x312 */ s16 unk_312; + /* 0x314 */ s16 unk_314; + /* 0x316 */ s16 unk_316; + /* 0x318 */ s16 unk_318; + /* 0x31A */ s16 unk_31A; + /* 0x31C */ s16 unk_31C[12]; + /* 0x334 */ s16 unk_334[12]; + /* 0x34C */ f32 unk_34C; + /* 0x350 */ UNK_TYPE1 unk_350[0x8]; + /* 0x358 */ Vec3f unk_358[12]; + /* 0x3E8 */ Vec3s jointTable[30]; + /* 0x49C */ Vec3s morphTable[30]; } EnSt; // size = 0x550 extern const ActorInit En_St_InitVars; diff --git a/src/overlays/actors/ovl_En_Stream/z_en_stream.c b/src/overlays/actors/ovl_En_Stream/z_en_stream.c index 6f20e1bd5b..9ce7ac906f 100644 --- a/src/overlays/actors/ovl_En_Stream/z_en_stream.c +++ b/src/overlays/actors/ovl_En_Stream/z_en_stream.c @@ -5,6 +5,7 @@ */ #include "z_en_stream.h" +#include "objects/object_stream/object_stream.h" #define FLAGS 0x00000010 @@ -33,8 +34,6 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 20, ICHAIN_STOP), }; -extern Gfx D_06000950[]; - void EnStream_SetupAction(EnStream* this, EnStreamActionFunc actionFunc) { this->actionFunc = actionFunc; } @@ -144,7 +143,7 @@ void EnStream_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(&gfx[1], 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, frames * 30, -multipliedFrames, 64, 64, 1, multipliedFrames, -multipliedFrames, 64, 64)); - gSPDisplayList(&gfx[2], D_06000950); + gSPDisplayList(&gfx[2], gWaterVortexDL); POLY_XLU_DISP = &gfx[3]; CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 0e6b20f3dd..dc10640406 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -173,7 +173,7 @@ void EnSuttari_UpdateCollider(EnSuttari* this, GlobalContext* globalCtx) { } Actor* EnSuttari_GetActorById(GlobalContext* globalCtx, s16 actorId) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (actor != NULL) { if (actor->id == actorId) { @@ -229,13 +229,13 @@ void func_80BAA9B4(EnSuttari* this) { case 0x145B: if ((this->animationIdx != 8) && (curFrame == frameCount)) { this->animationIdx = 8; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } break; default: if ((this->animationIdx != 1) && (curFrame == frameCount)) { this->animationIdx = 1; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } } } @@ -244,7 +244,7 @@ void func_80BAAA94(EnSuttari* this) { switch (this->textId) { case 0x29E5: this->animationIdx = 1; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); break; case 0x29E9: this->enFsn->flags |= ENFSN_ANGRY; @@ -257,11 +257,11 @@ void func_80BAAA94(EnSuttari* this) { break; case 0x29EC: this->animationIdx = 7; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); break; case 0x29ED: this->animationIdx = 1; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); break; } } @@ -331,7 +331,7 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { case 0: if (gSaveContext.weekEventReg[0x51] & 1) { this->textId = 0x1455; - ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk264 |= 8; + ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; } else { this->textId = 0x1450; @@ -353,7 +353,7 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { case 0x1453: this->flags1 |= 0x400; gSaveContext.weekEventReg[0x51] |= 1; - ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk264 |= 8; + ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; this->textId = 0x1454; break; @@ -387,10 +387,10 @@ void func_80BAAF1C(EnSuttari* this) { if (this->animationIdx == 5) { this->animationIdx = 3; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } else if ((this->animationIdx == 3) && (curFrame == frameCount)) { this->animationIdx = 6; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); this->flags1 &= ~0x100; } } @@ -411,7 +411,7 @@ void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); Matrix_StatePop(); if (this->unk3F0 == 0) { - EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &D_801D15B0, 50, &this->unk3F0, 1); + EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); } if (this->unk3F0 == 1) { play_sound(NA_SE_SY_FOUND); @@ -443,7 +443,7 @@ void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); Matrix_StatePop(); if (this->unk3F0 == 0) { - EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &D_801D15B0, 50, &this->unk3F0, 1); + EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); } if (this->unk3F0 == 1) { play_sound(NA_SE_SY_FOUND); @@ -469,7 +469,7 @@ void func_80BAB374(EnSuttari* this, GlobalContext* globalCtx) { sp38.x = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.x; sp38.y = this->actor.world.pos.y; sp38.z = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.z; - func_800BBDAC(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 0, 0, 0); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 0, 0, 0); } } @@ -689,7 +689,7 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg if (this->unk428 == 10 || this->unk428 == 11 || this->unk428 == 2) { return 0; } - sp48 = (EnDoor*)func_8013BB7C(&this->actor, globalCtx, ACTORCAT_DOOR, ACTOR_EN_DOOR); + sp48 = (EnDoor*)SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_DOOR, ACTOR_EN_DOOR); sp24 = D_80BAE8F8[unkStruct->unk0]; if ((sp48 != NULL) && (sp24 >= 0)) { this->unk404 = func_8013BB34(globalCtx, sp47, sp24); @@ -755,7 +755,7 @@ s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { func_8013AF00(sp7C, 3, this->unk404->count + 3); if (this->unk42C == 0) { - sp58 = D_801D15B0; + sp58 = gZeroVec3f; func_8013B6B0(this->unk404, &this->unk414, &this->unk424, this->unk41C, this->unk418, &this->unk420, sp7C, &sp58, this->unk42A); func_8013B878(globalCtx, this->unk404, this->unk420, &sp58); @@ -771,7 +771,7 @@ s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { sp50 = this->unk420; sp58 = this->actor.world.pos; } - this->unk408 = D_801D15B0; + this->unk408 = gZeroVec3f; if (func_8013B6B0(this->unk404, &this->unk414, &this->unk424, this->unk41C, this->unk418, &this->unk420, sp7C, &this->unk408, this->unk42A)) { this->unk430 = 1; @@ -823,7 +823,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { case 15: if ((this->animationIdx == 1) && (curFrame == frameCount)) { this->animationIdx = 2; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } if (!(gSaveContext.weekEventReg[0x53] & 4) && !(this->flags1 & 0x1000)) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { @@ -856,7 +856,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { this->enFsn->flags &= ~ENFSN_HAGGLE; if (this->animationIdx != 2) { this->animationIdx = 2; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } func_80BAC220(this, globalCtx); break; @@ -887,7 +887,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { if (!(gSaveContext.weekEventReg[0x21] & 8)) { if (this->animationIdx == 2 || this->animationIdx == 1) { this->animationIdx = 5; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } this->flags1 |= 0x10; if (this->flags2 & 2) { @@ -915,7 +915,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->flags1 |= 1; if (gSaveContext.day == 1 || gSaveContext.day == 2) { this->animationIdx = 2; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); this->flags1 |= 0x80; this->actionFunc = func_80BACA14; return; @@ -923,7 +923,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { !(gSaveContext.weekEventReg[0x3D] & 8) && !(gSaveContext.weekEventReg[0x21] & 8) && (gSaveContext.weekEventReg[0x33] & 8)) { this->animationIdx = 2; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); this->actionFunc = func_80BACEE0; return; } @@ -939,7 +939,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->flags1 |= 0x80; this->flags1 |= 8; this->animationIdx = 1; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); this->actionFunc = func_80BAD004; return; } else if (globalCtx->sceneNum == SCENE_ICHIBA) { @@ -948,7 +948,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { return; } this->animationIdx = 0; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); this->flags1 |= 2; this->actionFunc = func_80BAD5F8; return; @@ -958,7 +958,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { return; } this->animationIdx = 0; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); this->cutscenes[0] = this->actor.cutscene; this->cutscenes[1] = ActorCutscene_GetAdditionalCutscene(this->cutscenes[0]); this->flags1 |= 4; @@ -978,7 +978,7 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { if (this->animationIdx == 1 || this->animationIdx == 8) { this->animationIdx = 2; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } func_80BABA90(this, 0, 0); func_80BAB434(this); @@ -988,7 +988,7 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { this->actionFunc = func_80BACBB0; } } else if ((player->transformation == PLAYER_FORM_HUMAN) && CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) != 0) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk3F2 = this->unk2DC.y; func_80BAAB78(this, globalCtx); this->actionFunc = func_80BADA9C; @@ -997,7 +997,7 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { } } Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 0.1f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { @@ -1023,7 +1023,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { this->actionFunc = func_80BACD2C; this->actor.speedXZ = 0.0f; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (!(this->actor.bgCheckFlags & 1)) { this->actor.world.pos = this->actor.prevPos; this->actor.world.rot.y = -this->actor.world.rot.y; @@ -1045,7 +1045,7 @@ void func_80BACD2C(EnSuttari* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (!(this->actor.bgCheckFlags & 1)) { this->actor.world.pos = this->actor.prevPos; this->actor.world.rot.y = -this->actor.world.rot.y; @@ -1057,7 +1057,7 @@ void func_80BACE4C(EnSuttari* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer > 100.0f) { this->actionFunc = func_80BACBB0; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (this->actor.world.pos.y != this->actor.floorHeight) { this->actor.world.pos = this->actor.prevPos; this->actor.world.rot.y = -this->actor.world.rot.y; @@ -1087,7 +1087,7 @@ void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { } else if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { func_80BAB1A0(this, globalCtx); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { @@ -1104,17 +1104,17 @@ void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { } this->unk428 = unkStruct.unk0; func_80BAC2FC(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, 0x2A3A, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 200.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80BAD130(EnSuttari* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { globalCtx->msgCtx.unk11F22 = 0x43; @@ -1147,7 +1147,7 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD2B4(EnSuttari* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { if (this->textId == 0x2A30) { ActorCutscene_Stop(this->cutscenes[0]); ActorCutscene_SetIntentToPlay(this->cutscenes[1]); @@ -1164,7 +1164,7 @@ void func_80BAD2B4(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); if ((player->stateFlags1 & 0x40) && (globalCtx->msgCtx.unk11F04 != 0x2A31)) { @@ -1191,7 +1191,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_SMALL_EXPLOSION); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 30, NA_SE_IT_BOMB_EXPLOSION); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_IT_BOMB_EXPLOSION); Actor_MarkForDeath(&this->actor); return; } @@ -1206,7 +1206,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } else { this->unk3F2 = this->unk2DC.y; Math_ApproachF(&this->actor.speedXZ, 4.0f, 0.2f, 0.5f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80BAB374(this, globalCtx); } } @@ -1220,7 +1220,7 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { if ((curFrame == frameCount) && (this->animationIdx == 0) && (this->flags1 & 0x20)) { this->animationIdx = 2; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || @@ -1238,14 +1238,14 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { } func_80BAB434(this); if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.unk0 != 7)) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { @@ -1259,7 +1259,7 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { } else { if ((this->flags1 & 0x2000) && (this->animationIdx == 1) && (curFrame == frameCount)) { this->animationIdx = 2; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || @@ -1276,19 +1276,19 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { return; } if ((this->flags1 & 0x20) && (unkStruct.unk0 != 9)) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } } void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; func_80BAAB78(this, globalCtx); gSaveContext.weekEventReg[0x51] |= 4; @@ -1299,7 +1299,7 @@ void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { - u8 talkstate = func_80152498(&globalCtx->msgCtx); + u8 talkstate = Message_GetState(&globalCtx->msgCtx); s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); @@ -1308,7 +1308,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { func_80BAA9B4(this); } else if ((this->animationIdx == 7) && (curFrame == frameCount)) { this->animationIdx = 1; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } if (talkstate == 5) { if (func_80147624(globalCtx)) { @@ -1318,7 +1318,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { } this->flags1 &= ~0x400; if (this->flags2 & 1) { - ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk264 |= 0x10; + ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 0x10; this->flags2 &= ~1; } globalCtx->msgCtx.unk11F22 = 0x43; @@ -1372,7 +1372,7 @@ void func_80BADDB4(EnSuttari* this, GlobalContext* globalCtx) { if (gSaveContext.weekEventReg[0x33] & 0x10) { this->actionFunc = func_80BADE14; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80BADE14(EnSuttari* this, GlobalContext* globalCtx) { @@ -1383,13 +1383,13 @@ void func_80BADE14(EnSuttari* this, GlobalContext* globalCtx) { this->unk3F2 = this->unk2DC.y; Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80BADE8C(EnSuttari* this, GlobalContext* globalCtx) { this->unk3F2 = this->unk2DC.y; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; func_801518B0(globalCtx, 0x2A3A, &this->actor); this->actionFunc = func_80BAD130; @@ -1408,7 +1408,7 @@ void func_80BADF3C(EnSuttari* this, GlobalContext* globalCtx) { if (DECR(this->unk3F6) == 0) { Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void EnSuttari_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -1456,11 +1456,11 @@ void EnSuttari_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->unk428 != 0) { if (this->animationIdx == 2 || this->animationIdx == 6) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 16.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } } else if (this->animationIdx == 0 || this->animationIdx == 5) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } } } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 221de85014..a851f2ee9b 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -174,11 +174,11 @@ void func_808D8940(EnSw* this, GlobalContext* globalCtx) { sp94.x = 0.0f; sp94.y = (Rand_ZeroOne() * 0.2f) + 0.1f; sp94.z = Rand_ZeroOne() + 1.0f; - Lib_Vec3f_TranslateAndRotateY(&D_801D15B0, temp_s0, &sp94, &spAC); + Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, temp_s0, &sp94, &spAC); sp94.x = 0.0f; sp94.y = 0.7f; sp94.z = 2.0f; - Lib_Vec3f_TranslateAndRotateY(&D_801D15B0, temp_s0, &sp94, &spB8); + Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, temp_s0, &sp94, &spB8); spA0.x = this->actor.world.pos.x + (2.0f * spB8.x); spA0.z = this->actor.world.pos.z + (2.0f * spB8.z); func_800B0EB0(globalCtx, &spA0, &spB8, &spAC, &D_808DBAA4, &D_808DBAA8, 60, 30, temp_f4); @@ -248,7 +248,7 @@ void func_808D8ED0(EnSw* this, GlobalContext* globalCtx) { sp54.z += this->unk_380[i].z; Math_Vec3f_Copy(&this->unk_380[i], &sp54); } - func_800BF7CC(globalCtx, &this->actor, this->unk_380, ARRAY_COUNT(this->unk_380), 3, 0.1f, 0.3f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_380, ARRAY_COUNT(this->unk_380), 3, 0.1f, 0.3f); } void func_808D8FC4(EnSw* this, GlobalContext* globalCtx) { @@ -458,7 +458,7 @@ void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 } if (arg2 == 1) { - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); } } #else @@ -498,10 +498,10 @@ void func_808D9894(EnSw* this, Vec3f* vec) { s32 func_808D9968(EnSw* this, GlobalContext* globalCtx) { s32 ret = false; - u8 param = ENSW_GET_3FC(&this->actor); + s32 param = ENSW_GET_3FC(&this->actor) & 0xFF; if (ENSW_GET_3(&this->actor)) { - if ((param != 0x3F) && Actor_GetChestFlag(globalCtx, param)) { + if ((param != 0x3F) && Flags_GetTreasure(globalCtx, param)) { ret = true; } } @@ -536,9 +536,9 @@ s32 func_808D9A70(EnSw* this, GlobalContext* globalCtx) { } else { if (this->unk_456 != 0) { if (!ENSW_GET_3(&this->actor)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_ROLL); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); } this->unk_456--; this->skelAnime.curFrame = 0.0f; @@ -587,7 +587,7 @@ s32 func_808D9C18(EnSw* this) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTURA_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_APPEAR); if (ENSW_GET_3(&this->actor) == 1) { Actor_SetScale(&this->actor, 0.0f); @@ -686,7 +686,7 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { this->unk_45C = 0; } else if (!func_808D90C4(this)) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); Enemy_StartFinishingBlow(globalCtx, &this->actor); this->actor.flags &= ~1; if (!ENSW_GET_3(&this->actor)) { @@ -729,19 +729,19 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { } this->unk_458 = 20; this->unk_45A = 0; - func_800BCB70(&this->actor, 0x4000, 200, 0, this->unk_458); + Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_458); ret = true; } else if (this->actor.colChkInfo.damageEffect == 1) { if (this->unk_45A == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->unk_45A = 40; - func_800BCB70(&this->actor, 0, 200, 0, this->unk_45A); + Actor_SetColorFilter(&this->actor, 0, 200, 0, this->unk_45A); } } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_DAMAGE); this->unk_458 = 20; this->unk_45A = 0; - func_800BCB70(&this->actor, 0x4000, 200, 0, this->unk_458); + Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_458); } } return ret; @@ -751,7 +751,7 @@ void func_808DA350(EnSw* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if ((player->stateFlags1 & 0x200000) && (this->actor.xyzDistToPlayerSq < 8000.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_LAUGH); Math_Vec3f_Copy(&this->unk_374, &player->actor.world.pos); this->unk_410 &= ~0x20; this->unk_414 = 0.0f; @@ -776,7 +776,7 @@ void func_808DA3F4(EnSw* this, GlobalContext* globalCtx) { temp_v0 = Math_FAtan2F(sp38.z, sp38.x); if (ABS_ALT(temp_v0) < temp_s1) { this->skelAnime.curFrame = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); this->unk_414 = 0.0f; if (this->unk_410 & 0x20) { this->actionFunc = func_808DA6FC; @@ -787,7 +787,7 @@ void func_808DA3F4(EnSw* this, GlobalContext* globalCtx) { } temp_s1 *= (temp_v0 < 0) ? -1 : 1; } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_ROLL); this->skelAnime.curFrame = 0.0f; } func_808D94D0(this, globalCtx, 0, 0, temp_s1); @@ -813,7 +813,7 @@ void func_808DA578(EnSw* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&this->unk_374, &this->actor.home.pos); this->actionFunc = func_808DA3F4; } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); this->skelAnime.curFrame = 0.0f; } @@ -849,7 +849,7 @@ void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { func_808D94D0(this, globalCtx, 0, 0, Math_FAtan2F(sp38.z, sp38.x)); } } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); this->skelAnime.curFrame = 0.0f; } @@ -912,7 +912,7 @@ void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { this->unk_448 = temp_f2; this->actor.speedXZ = 0.0f; if ((s32)temp_f2 != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTURA_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); } else { this->actionFunc = func_808DAEB4; this->actor.velocity.y = 0.0f; @@ -924,7 +924,7 @@ void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.shape.yOffset, 400.0f, 0.3f, 1000.0f); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); } @@ -948,7 +948,7 @@ void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { temp_v0 = Math_FAtan2F(sp34.z, sp34.x); if (ABS_ALT(temp_v0) < sp40) { this->skelAnime.curFrame = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); Math_Vec3s_ToVec3f(&this->unk_374, &sp44[this->unk_4A0]); this->actionFunc = func_808DACF4; this->unk_414 = 0.0f; @@ -958,7 +958,7 @@ void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { } } else { if (this->unk_456 != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); this->unk_456--; this->skelAnime.curFrame = 0.0f; } else { @@ -1001,7 +1001,7 @@ void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { func_808D94D0(this, globalCtx, 0, 0, Math_FAtan2F(sp38.z, sp38.x)); } } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); this->skelAnime.curFrame = 0.0f; } @@ -1108,9 +1108,9 @@ void func_808DB100(EnSw* this, GlobalContext* globalCtx) { if ((DECR(this->unk_454) == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (this->unk_456 != 0) { if (!ENSW_GET_3(&this->actor)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_ROLL); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); } this->unk_456--; this->skelAnime.curFrame = 0.0f; @@ -1145,10 +1145,10 @@ void func_808DB2E0(EnSw* this, GlobalContext* globalCtx) { this->actor.velocity.z *= 0.5f; if ((s32)temp_f2 != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTURA_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); } else { func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); - Math_Vec3f_Copy(&this->actor.velocity, &D_801D15B0); + Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); this->unk_410 &= ~(0x10 | 0x1); this->actionFunc = func_808DB100; } @@ -1161,7 +1161,7 @@ void func_808DB2E0(EnSw* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.scale.x, 0.02f, 0.4f, 1.0f); Actor_SetScale(&this->actor, this->actor.scale.x); this->actor.velocity.y += this->actor.gravity; - Actor_ApplyMovement(&this->actor); + Actor_UpdatePos(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); } @@ -1266,7 +1266,7 @@ void EnSw_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } - Actor_SetHeight(&this->actor, 0.0f); + Actor_SetFocus(&this->actor, 0.0f); func_808D8FC4(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 5137628056..6defe10cb3 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -193,7 +193,7 @@ s32 func_809C6720(GlobalContext* globalCtx, Vec3f arg1) { } globalCtx->actorCtx.unk268 = 1; - func_800B6F20(globalCtx, globalCtx->actorCtx.pad26C, phi_f0, sp22); + func_800B6F20(globalCtx, &globalCtx->actorCtx.unk_26C, phi_f0, sp22); if (sp28 < 5.0f) { return true; @@ -213,10 +213,10 @@ void func_809C6810(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { u16 sp22; - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); sp22 = Text_GetFaceReaction(globalCtx, 0x31); if (sp22 != 0) { func_801518B0(globalCtx, sp22, &this->actor); @@ -381,7 +381,7 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; } - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 2: this->actionFunc = func_809C6848; this->unk_26A = 0; @@ -419,7 +419,7 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { if (this->skelAnime.animation == &D_0600D2F8) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); } } } @@ -427,7 +427,7 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { switch (gSaveContext.playerForm) { case PLAYER_FORM_HUMAN: - Actor_SetAllChestFlag(globalCtx, Actor_GetAllChestFlag(globalCtx) + 1); + Flags_SetAllTreasure(globalCtx, Flags_GetAllTreasure(globalCtx) + 1); if (CURRENT_DAY != 3) { if (!(this->unk_282 & 1)) { this->unk_282 |= 1; @@ -510,7 +510,7 @@ void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C72D8(EnSyatekiMan* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { u16 sp26 = Text_GetFaceReaction(globalCtx, 0x30); if (sp26 != 0) { @@ -715,7 +715,7 @@ void func_809C7990(EnSyatekiMan* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; } - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 2: this->actionFunc = func_809C72D8; this->unk_26A = 0; @@ -763,13 +763,13 @@ void func_809C7A90(EnSyatekiMan* this, GlobalContext* globalCtx) { this->actionFunc = func_809C7C14; } else { if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.weekEventReg[59] & 0x10)) { - func_800B8A1C(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); } else if (this->unk_280 < 0x884) { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_RED, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 500.0f, 100.0f); } else if (!(gSaveContext.weekEventReg[32] & 2)) { - func_800B8A1C(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); } player->actor.shape.rot.y = -0x8000; @@ -782,7 +782,7 @@ void func_809C7A90(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if ((CURRENT_DAY == 3) && (gSaveContext.time > CLOCK_TIME(12, 00))) { func_801518B0(globalCtx, 0xA36, &this->actor); this->unk_284 = 0xA36; @@ -796,7 +796,7 @@ void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_26A = 0; this->actionFunc = func_809C6E30; } else { - func_800B85E0(&this->actor, globalCtx, 500.0f, -1); + func_800B85E0(&this->actor, globalCtx, 500.0f, EXCH_ITEM_MINUS1); } } @@ -820,14 +820,14 @@ void func_809C7D14(EnSyatekiMan* this, GlobalContext* globalCtx) { } else { if (this->unk_284 == 0x407) { if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.weekEventReg[59] & 0x20)) { - func_800B8A1C(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); } } else if (!(gSaveContext.weekEventReg[32] & 4)) { - func_800B8A1C(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_HUGE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_HUGE, 500.0f, 100.0f); } player->actor.shape.rot.y = -0x8000; @@ -841,7 +841,7 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (CURRENT_DAY != 3) { - if ((func_80152498(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { player->stateFlags1 &= ~0x20; this->unk_280 = 0; this->unk_26A = 0; @@ -849,7 +849,7 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[63] &= (u8)~2; this->actionFunc = func_809C6810; } - } else if (func_800B84D0(&this->actor, globalCtx)) { + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, 0x408, &this->actor); this->unk_284 = 0x408; player->stateFlags1 &= ~0x20; @@ -858,7 +858,7 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_26A = 0; this->actionFunc = func_809C7990; } else { - func_800B85E0(&this->actor, globalCtx, 500.0f, -1); + func_800B85E0(&this->actor, globalCtx, 500.0f, EXCH_ITEM_MINUS1); } } @@ -895,7 +895,7 @@ void func_809C80C0(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_27E = 0; this->unk_280 = 0; player->stateFlags1 &= ~0x20; - Audio_PlayActorSound2(&this->actor, NA_SE_SY_FOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); this->unk_272 = 0x1F; this->unk_274 = 0; this->unk_276 = 0; @@ -917,7 +917,7 @@ void func_809C81D0(EnSyatekiMan* this, GlobalContext* globalCtx) { if (((this->unk_272 == 0) || (this->unk_26C > 140)) && (D_809C949C == 0) && (this->unk_27C < 4)) { D_809C949C = 1; this->unk_26C = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_SY_FOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); this->unk_274 = D_809C91C8[this->unk_27E]; if (this->unk_27E == 3) { this->unk_27E = 0; @@ -1037,7 +1037,7 @@ void func_809C8610(EnSyatekiMan* this, GlobalContext* globalCtx) { gSaveContext.unk_3E88[1] += 100; globalCtx->interfaceCtx.unk_25C += 10; this->unk_280 += 10; - Audio_PlayActorSound2(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); D_809C94A0 = 0; } else { D_809C94A0++; @@ -1144,7 +1144,7 @@ void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { if ((D_809C94A8 == (sp30 % 50)) && (this->unk_26C >= 70)) { if (this->unk_27E < 15) { this->unk_190 = D_809C94D0[this->unk_27E++]; - Audio_PlayActorSound2(&this->actor, NA_SE_SY_FOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); this->unk_26C = 0; } } @@ -1171,7 +1171,7 @@ void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx) { if (this->unk_26A == 1) { this->unk_190 = 0; if ((this->unk_270 <= 0) && (globalCtx->interfaceCtx.unk_286 == 0)) { - Actor_SetAllChestFlag(globalCtx, this->unk_280); + Flags_SetAllTreasure(globalCtx, this->unk_280); this->unk_270 = 15; if (((s32)(gSaveContext.roomInf[127][6] & 0xFFFF) < this->unk_280) || (this->unk_280 == 50)) { if ((s32)(gSaveContext.roomInf[127][6] & 0xFFFF) < this->unk_280) { @@ -1239,7 +1239,7 @@ void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); func_809C8DE8(this); this->actor.focus.pos.y = 70.0f; - Actor_SetHeight(&this->actor, 70.0f); + Actor_SetFocus(&this->actor, 70.0f); if (this->unk_26A != 1) { SkelAnime_Update(&this->skelAnime); func_800E9250(globalCtx, &this->actor, &this->unk_258, &this->unk_25E, this->actor.focus.pos); diff --git a/src/overlays/actors/ovl_En_Talk/z_en_talk.c b/src/overlays/actors/ovl_En_Talk/z_en_talk.c index 2d054f808f..fcfa36a4d6 100644 --- a/src/overlays/actors/ovl_En_Talk/z_en_talk.c +++ b/src/overlays/actors/ovl_En_Talk/z_en_talk.c @@ -13,11 +13,9 @@ void EnTalk_Init(Actor* thisx, GlobalContext* globalCtx); void EnTalk_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTalk_Update(Actor* thisx, GlobalContext* globalCtx); - void func_80BDE058(EnTalk* this, GlobalContext* globalCtx); void func_80BDE090(EnTalk* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Talk_InitVars = { ACTOR_EN_TALK, ACTORCAT_ITEMACTION, @@ -30,14 +28,42 @@ const ActorInit En_Talk_InitVars = { (ActorFunc)NULL, }; -#endif +void EnTalk_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTalk* this = THIS; + s8 targetMode = this->actor.home.rot.x - 0x1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk/EnTalk_Init.s") + if (targetMode >= 0 && targetMode < 7) { + this->actor.targetMode = targetMode; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk/EnTalk_Destroy.s") + Actor_SetScale(&this->actor, 1.0f); + this->actionFunc = func_80BDE090; + this->actor.textId = ENTALK_GET_TEXT_ID(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk/func_80BDE058.s") +void EnTalk_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk/func_80BDE090.s") +void func_80BDE058(EnTalk* this, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + this->actionFunc = func_80BDE090; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk/EnTalk_Update.s") +void func_80BDE090(EnTalk* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BDE058; + return; + } + + if ((this->actor.xzDistToPlayer < 40.0f && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) || + this->actor.isTargeted) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void EnTalk_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTalk* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Talk/z_en_talk.h b/src/overlays/actors/ovl_En_Talk/z_en_talk.h index 764127f760..629a5c0e27 100644 --- a/src/overlays/actors/ovl_En_Talk/z_en_talk.h +++ b/src/overlays/actors/ovl_En_Talk/z_en_talk.h @@ -3,6 +3,8 @@ #include "global.h" +#define ENTALK_GET_TEXT_ID(thisx) (((thisx)->params & 0x3F) + 0x1C00) + struct EnTalk; typedef void (*EnTalkActionFunc)(struct EnTalk*, GlobalContext*); 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 0c5dbfa718..931715a53d 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -5,6 +5,7 @@ */ #include "z_en_talk_gibud.h" +#include "objects/object_rd/object_rd.h" #define FLAGS 0x00000415 @@ -15,7 +16,81 @@ void EnTalkGibud_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTalkGibud_Update(Actor* thisx, GlobalContext* globalCtx); void EnTalkGibud_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +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_SetupWalkToPlayer(EnTalkGibud* this); +void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_SetupGrab(EnTalkGibud* this); +void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_SetupGrabFail(EnTalkGibud* this); +void EnTalkGibud_GrabFail(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_SetupTurnAwayAndShakeHead(EnTalkGibud* this); +void EnTalkGibud_TurnAwayAndShakeHead(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_SetupWalkToHome(EnTalkGibud* this); +void EnTalkGibud_WalkToHome(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_Stunned(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_SetupDamage(EnTalkGibud* this); +void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_SetupDead(EnTalkGibud* this); +void EnTalkGibud_Dead(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_SetupRevive(EnTalkGibud* this); +void EnTalkGibud_Revive(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_PassiveIdle(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_SetupTalk(EnTalkGibud* this); +void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_SetupDisappear(EnTalkGibud* this); +void EnTalkGibud_Disappear(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_FacePlayerWhenTalking(EnTalkGibud* this, GlobalContext* globalCtx); +s32 EnTalkGibud_PlayerInRangeWithCorrectState(EnTalkGibud* this, GlobalContext* globalCtx); +s32 EnTalkGibud_PlayerOutOfRange(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_TurnTowardsPlayer(EnTalkGibud* this, GlobalContext* globalCtx); +s32 EnTalkGibud_MoveToIdealGrabPositionAndRotation(EnTalkGibud* this, GlobalContext* globalCtx); + +typedef struct { + /* 0x0 */ s32 itemActionParam; + /* 0x4 */ s32 item; + /* 0x8 */ s32 amount; + /* 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, + /* 2 */ EN_TALK_GIBUD_REQUESTED_ITEM_NOT_MET, +} EnTalkGibudRequestedItemState; + +typedef enum { + /* 0 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BLUE_POTION, + /* 1 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BEANS, + /* 2 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_SPRING_WATER, + /* 3 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_FISH, + /* 4 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BUGS, + /* 5 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_DEKU_NUTS, + /* 6 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BOMBS, + /* 7 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_HOT_SPRING_WATER, + /* 8 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BIG_POE, + /* 9 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK, +} EnTalkGibudRequestedItemIndex; + const ActorInit En_Talk_Gibud_InitVars = { ACTOR_EN_TALK_GIBUD, ACTORCAT_ENEMY, @@ -28,166 +103,1056 @@ const ActorInit En_Talk_Gibud_InitVars = { (ActorFunc)EnTalkGibud_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B01350 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7EFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +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 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 }, + { 0xF7EFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 20, 70, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B0137C = { - /* 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), +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 + /* 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 + /* 0xE */ EN_TALK_GIBUD_DMGEFF_LIGHT_RAY, // Instantly kills a Redead on contact + /* 0xF */ EN_TALK_GIBUD_DMGEFF_DAMAGE, // Deals damage and plays the damage animation +} EnTalkGibudDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(2, EN_TALK_GIBUD_DMGEFF_DAMAGE), + /* Horse trample */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_TALK_GIBUD_DMGEFF_DAMAGE), + /* Zora boomerang */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_RECOIL), + /* Normal arrow */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_RECOIL), + /* UNK_DMG_0x06 */ DMG_ENTRY(2, EN_TALK_GIBUD_DMGEFF_DAMAGE), + /* Hookshot */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_RECOIL), + /* Goron punch */ DMG_ENTRY(1, EN_TALK_GIBUD_DMGEFF_DAMAGE), + /* Sword */ DMG_ENTRY(1, EN_TALK_GIBUD_DMGEFF_DAMAGE), + /* Goron pound */ DMG_ENTRY(1, EN_TALK_GIBUD_DMGEFF_DAMAGE), + /* Fire arrow */ DMG_ENTRY(1, EN_TALK_GIBUD_DMGEFF_FIRE_ARROW), + /* Ice arrow */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_RECOIL), + /* Light arrow */ DMG_ENTRY(2, EN_TALK_GIBUD_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_TALK_GIBUD_DMGEFF_DAMAGE), + /* Deku spin */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_RECOIL), + /* Deku launch */ DMG_ENTRY(2, EN_TALK_GIBUD_DMGEFF_DAMAGE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_LIGHT_RAY), + /* Thrown object */ DMG_ENTRY(1, EN_TALK_GIBUD_DMGEFF_DAMAGE), + /* Zora punch */ DMG_ENTRY(1, EN_TALK_GIBUD_DMGEFF_DAMAGE), + /* Spin attack */ DMG_ENTRY(1, EN_TALK_GIBUD_DMGEFF_DAMAGE), + /* Sword beam */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_TALK_GIBUD_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_TALK_GIBUD_DMGEFF_DAMAGE), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B0139C = { 8, 0, 0, 0, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B01448[] = { +static EnTalkGibudRequestedItem sRequestedItemTable[] = { + { PLAYER_AP_BOTTLE_POTION_BLUE, ITEM_POTION_BLUE, 1, true }, + { PLAYER_AP_MAGIC_BEANS, ITEM_MAGIC_BEANS, 5, false }, + { PLAYER_AP_BOTTLE_SPRING_WATER, ITEM_SPRING_WATER, 1, true }, + { PLAYER_AP_BOTTLE_FISH, ITEM_FISH, 1, true }, + { PLAYER_AP_BOTTLE_BUG, ITEM_BUG, 1, true }, + { PLAYER_AP_NUT, ITEM_NUT, 10, false }, + { PLAYER_AP_BOMB, ITEM_BOMB, 10, false }, + { PLAYER_AP_BOTTLE_HOT_SPRING_WATER, ITEM_HOT_SPRING_WATER, 1, true }, + { PLAYER_AP_BOTTLE_BIG_POE, ITEM_BIG_POE, 1, true }, + { PLAYER_AP_BOTTLE_MILK, ITEM_MILK_BOTTLE, 1, true }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -3500, ICHAIN_STOP), }; -#endif +static Vec3f sVelocity = { 0.0f, 0.0f, 0.0f }; -extern ColliderCylinderInit D_80B01350; -extern DamageTable D_80B0137C; -extern CollisionCheckInfoInit2 D_80B0139C; -extern InitChainEntry D_80B01448[]; +static Vec3f sAccel = { 0.0f, 0.600000023842f, 0.0f }; -extern UNK_TYPE D_06009298; -extern UNK_TYPE D_0600ABE0; -extern UNK_TYPE D_06010B88; +void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTalkGibud* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/EnTalkGibud_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + 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); + 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->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; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/EnTalkGibud_Destroy.s") + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + this->limbPos[i] = gZeroVec3f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFEB38.s") + 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; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFEB7C.s") + if (this->switchFlag == 0xFF) { + this->switchFlag = -1; + } + if (this->switchFlag != -1 && Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFEC08.s") + EnTalkGibud_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFEC4C.s") +void EnTalkGibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTalkGibud* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFED08.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFED7C.s") +void EnTalkGibud_SetupIdle(EnTalkGibud* this) { + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + this->actionFunc = EnTalkGibud_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFEFD4.s") +/** + * This is the idle for when the player is not wearing the Gibdo Mask. The + * Gibdo will attack the player if they get too close. + */ +void EnTalkGibud_Idle(EnTalkGibud* this, GlobalContext* globalCtx) { + if (this->actor.xzDistToPlayer <= 150.0f && func_800B715C(globalCtx)) { + EnTalkGibud_SetupAttemptPlayerStun(this); + } + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x64, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x64, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFF030.s") +void EnTalkGibud_SetupAttemptPlayerStun(EnTalkGibud* this) { + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + this->actionFunc = EnTalkGibud_AttemptPlayerStun; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFF22C.s") +void EnTalkGibud_AttemptPlayerStun(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); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFF288.s") + if (ABS_ALT(yaw) < 0x2008) { + 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); + EnTalkGibud_SetupWalkToPlayer(this); + } + EnTalkGibud_TurnTowardsPlayer(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFF330.s") +void EnTalkGibud_SetupWalkToPlayer(EnTalkGibud* this) { + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + this->actor.speedXZ = 0.4f; + if (this->actionFunc == EnTalkGibud_AttemptPlayerStun) { + this->playerStunWaitTimer = 80; + } else { + this->playerStunWaitTimer = 20; + } + this->actionFunc = EnTalkGibud_WalkToPlayer; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFF378.s") +void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFF45C.s") + 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); + if (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { + if (this->grabWaitTimer == 0 && this->actor.xzDistToPlayer <= 45.0f) { + player->actor.freezeTimer = 0; + if (gSaveContext.playerForm == PLAYER_FORM_GORON || gSaveContext.playerForm == PLAYER_FORM_DEKU) { + // 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. + EnTalkGibud_SetupGrabFail(this); + } else if (globalCtx->grabPlayer(globalCtx, player)) { + EnTalkGibud_SetupGrab(this); + } + } else { + if (this->playerStunWaitTimer == 0) { + player->actor.freezeTimer = 40; + 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->playerStunWaitTimer--; + } + } + } 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--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFF4AC.s") + 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)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFF618.s") +void EnTalkGibud_SetupGrab(EnTalkGibud* this) { + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_START); + this->grabDamageTimer = 0; + this->actor.flags &= ~1; + this->grabState = EN_TALK_GIBUD_GRAB_START; + this->actionFunc = EnTalkGibud_Grab; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFF6A0.s") +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; + s32 inPositionToAttack; + u16 damageSfxId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFF700.s") + switch (this->grabState) { + case EN_TALK_GIBUD_GRAB_START: + inPositionToAttack = EnTalkGibud_MoveToIdealGrabPositionAndRotation(this, globalCtx); + 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); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFF76C.s") + case EN_TALK_GIBUD_GRAB_ATTACK: + if (this->grabDamageTimer == 20) { + s16 requiredScopeTemp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFF880.s") + damageSfxId = player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S; + globalCtx->damagePlayer(globalCtx, -8); + func_800B8E58(player, damageSfxId); + func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); + this->grabDamageTimer = 0; + } else { + this->grabDamageTimer++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFF8E4.s") + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFF9CC.s") + 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; + this->grabState = EN_TALK_GIBUD_GRAB_RELEASE; + this->grabDamageTimer = 0; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFFA68.s") + case EN_TALK_GIBUD_GRAB_RELEASE: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->grabWaitTimer = 20; + this->actor.shape.yOffset = 0.0f; + EnTalkGibud_SetupWalkToPlayer(this); + } else { + Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 400.0f, 0.0f); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFFAB0.s") +void EnTalkGibud_SetupGrabFail(EnTalkGibud* this) { + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + this->actionFunc = EnTalkGibud_GrabFail; + this->actor.speedXZ = -2.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFFC10.s") +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); + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->actor.world.rot.y = this->actor.shape.rot.y; + EnTalkGibud_SetupTurnAwayAndShakeHead(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFFC9C.s") +void EnTalkGibud_SetupTurnAwayAndShakeHead(EnTalkGibud* this) { + this->headShakeTimer = 0; + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + this->actionFunc = EnTalkGibud_TurnAwayAndShakeHead; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFFD3C.s") +void EnTalkGibud_TurnAwayAndShakeHead(EnTalkGibud* 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->headShakeTimer > 60) { + EnTalkGibud_SetupWalkToHome(this); + this->playerStunWaitTimer = 0; + } else { + this->headRotation.y = + Math_SinS(this->headShakeTimer * 4000) * (0x256F * ((60 - this->headShakeTimer) / 60.0f)); + this->headShakeTimer++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFFE3C.s") +void EnTalkGibud_SetupWalkToHome(EnTalkGibud* this) { + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + this->actor.speedXZ = 0.4f; + this->actionFunc = EnTalkGibud_WalkToHome; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFFE94.s") +void EnTalkGibud_WalkToHome(EnTalkGibud* 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) { + EnTalkGibud_SetupIdle(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 (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx)) { + if (gSaveContext.playerForm != PLAYER_FORM_GORON && gSaveContext.playerForm != PLAYER_FORM_DEKU && + Actor_IsFacingPlayer(&this->actor, 0x38E3)) { + EnTalkGibud_SetupWalkToPlayer(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFFFA4.s") +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) { + Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); + } else { + Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); + } + this->actionFunc = EnTalkGibud_Stunned; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80AFFFBC.s") +void EnTalkGibud_Stunned(EnTalkGibud* this, GlobalContext* globalCtx) { + if (this->actor.colorFilterTimer == 0) { + if (this->actor.colChkInfo.health == 0) { + EnTalkGibud_SetupDead(this); + } else { + EnTalkGibud_SetupDamage(this); + } + } + if (this->stunTimer != 0) { + this->stunTimer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B000FC.s") +void EnTalkGibud_SetupDamage(EnTalkGibud* this) { + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + this->stunTimer = 0; + this->grabWaitTimer = 0; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actionFunc = EnTalkGibud_Damage; + this->actor.speedXZ = -2.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B00158.s") +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) { + 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->type = EN_TALK_GIBUD_TYPE_REDEAD; + } + if (EnTalkGibud_PlayerOutOfRange(this, globalCtx)) { + EnTalkGibud_SetupWalkToHome(this); + } else { + EnTalkGibud_SetupWalkToPlayer(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B00384.s") +void EnTalkGibud_SetupDead(EnTalkGibud* this) { + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DEATH); + this->actor.flags &= ~1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); + this->deathTimer = 0; + this->actionFunc = EnTalkGibud_Dead; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B0040C.s") +void EnTalkGibud_Dead(EnTalkGibud* this, GlobalContext* globalCtx) { + if (this->deathTimer > 300) { + EnTalkGibud_SetupRevive(this); + } else { + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 250, 0); + 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); + this->type = EN_TALK_GIBUD_TYPE_REDEAD; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B00484.s") +void EnTalkGibud_SetupRevive(EnTalkGibud* this) { + Animation_Change(&this->skelAnime, &object_rd_Anim_009298, -1.0f, Animation_GetLastFrame(&object_rd_Anim_009298), + 0.0f, 2, -8.0f); + this->actor.flags |= 1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_REVERSE); + this->deathTimer = 0; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnTalkGibud_Revive; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B004D0.s") +void EnTalkGibud_Revive(EnTalkGibud* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->actor.colChkInfo.health = 8; + EnTalkGibud_SetupIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B005EC.s") +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); + this->textId = 0x138C; + break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BEANS: + func_801518B0(globalCtx, 0x138D, &this->actor); + this->textId = 0x138D; + break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_SPRING_WATER: + func_801518B0(globalCtx, 0x138E, &this->actor); + this->textId = 0x138E; + break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_FISH: + func_801518B0(globalCtx, 0x138F, &this->actor); + this->textId = 0x138F; + break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BUGS: + func_801518B0(globalCtx, 0x1390, &this->actor); + this->textId = 0x1390; + break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_DEKU_NUTS: + func_801518B0(globalCtx, 0x1391, &this->actor); + this->textId = 0x1391; + break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BOMBS: + func_801518B0(globalCtx, 0x1392, &this->actor); + this->textId = 0x1392; + break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_HOT_SPRING_WATER: + func_801518B0(globalCtx, 0x1393, &this->actor); + this->textId = 0x1393; + break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BIG_POE: + func_801518B0(globalCtx, 0x1394, &this->actor); + this->textId = 0x1394; + break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK: + func_801518B0(globalCtx, 0x1395, &this->actor); + this->textId = 0x1395; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B00760.s") +void EnTalkGibud_GetNextTextBoxId(EnTalkGibud* this, GlobalContext* globalCtx) { + if (func_80147624(globalCtx)) { + switch (this->textId) { + case 0x1388: + EnTalkGibud_GetTextIdForRequestedItem(this, globalCtx); + break; + case 0x138C: + case 0x138D: + case 0x138E: + case 0x138F: + case 0x1390: + case 0x1391: + case 0x1392: + case 0x1393: + case 0x1394: + case 0x1395: + // Prompts the player to choose an item + func_801518B0(globalCtx, 0xFF, &this->actor); + this->textId = 0xFF; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B008BC.s") +s32 EnTalkGibud_PresentedItemMatchesRequest(EnTalkGibud* this, GlobalContext* globalCtx, s32 presentedItemActionParam) { + EnTalkGibudRequestedItem* requestedItem = &sRequestedItemTable[this->requestedItemIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B008FC.s") + if (requestedItem->itemActionParam == presentedItemActionParam) { + if (!requestedItem->isBottledItem) { + if (AMMO(requestedItem->item) >= requestedItem->amount) { + return EN_TALK_GIBUD_REQUESTED_ITEM_MET; + } else { + return EN_TALK_GIBUD_REQUESTED_ITEM_NOT_ENOUGH_AMMO; + } + } + if (func_80114F2C(requestedItem->item)) { + return EN_TALK_GIBUD_REQUESTED_ITEM_MET; + } + } + return EN_TALK_GIBUD_REQUESTED_ITEM_NOT_MET; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B0094C.s") +void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 itemActionParam; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B00B8C.s") + if (this->itemActionParam == PLAYER_AP_NONE) { + itemActionParam = func_80123810(globalCtx); + if (itemActionParam != PLAYER_AP_NONE) { + this->itemActionParam = itemActionParam; + } + if (this->itemActionParam > PLAYER_AP_NONE) { + switch (EnTalkGibud_PresentedItemMatchesRequest(this, globalCtx, this->itemActionParam)) { + case EN_TALK_GIBUD_REQUESTED_ITEM_MET: + 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); + this->textId = 0x1389; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B00C94.s") +void EnTalkGibud_SetupPassiveIdle(EnTalkGibud* this) { + this->isTalking = false; + if (this->actionFunc != EnTalkGibud_Talk) { + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + } + this->actionFunc = EnTalkGibud_PassiveIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B00D9C.s") +/** + * This is the idle for when the player is wearing the Gibdo Mask. The + * Gibdo will not attempt to attack the player and can be spoken to. + */ +void EnTalkGibud_PassiveIdle(EnTalkGibud* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->isTalking = true; + func_801518B0(globalCtx, 0x1388, &this->actor); + this->textId = 0x1388; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); + EnTalkGibud_SetupTalk(this); + } else if (this->actor.xzDistToPlayer < 100.0f && !(this->collider.base.acFlags & AC_HIT)) { + func_800E9250(globalCtx, &this->actor, &this->headRotation, &this->upperBodyRotation, this->actor.focus.pos); + func_800B8614(&this->actor, globalCtx, 100.0f); + } else { + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 100, 0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/EnTalkGibud_Update.s") +void EnTalkGibud_SetupTalk(EnTalkGibud* this) { + this->itemActionParam = PLAYER_AP_NONE; + this->actionFunc = EnTalkGibud_Talk; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B00F08.s") +void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnTalkGibudRequestedItem* requestedItem; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/func_80B00F64.s") + switch (Message_GetState(&globalCtx->msgCtx)) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + break; + case 5: + EnTalkGibud_GetNextTextBoxId(this, globalCtx); + break; + case 6: + if (func_80147624(globalCtx)) { + if (this->textId == 0x138A) { + // Remove the requested item/amount from the player's inventory + requestedItem = &sRequestedItemTable[this->requestedItemIndex]; + if (!requestedItem->isBottledItem) { + func_80115A14(requestedItem->item, -requestedItem->amount); + } else { + func_80123D50(globalCtx, player, ITEM_BOTTLE, PLAYER_AP_BOTTLE); + } + player->stateFlags1 |= 0x20; + player->stateFlags1 |= 0x20000000; + this->actor.flags |= 0x100000; + EnTalkGibud_SetupDisappear(this); + } else { + EnTalkGibud_SetupPassiveIdle(this); + } + } + break; + case 16: + EnTalkGibud_CheckPresentedItem(this, globalCtx); + break; + } + EnTalkGibud_FacePlayerWhenTalking(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Talk_Gibud/EnTalkGibud_Draw.s") +void EnTalkGibud_SetupDisappear(EnTalkGibud* this) { + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + this->actor.flags &= ~1; + this->disappearanceTimer = 40; + this->actionFunc = EnTalkGibud_Disappear; +} + +void EnTalkGibud_Disappear(EnTalkGibud* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f velocity = sVelocity; + Vec3f accel = sAccel; + Vec3f pos; + s32 numFlamesToSpawn; + s32 i; + + if (this->disappearanceTimer > 0) { + numFlamesToSpawn = CLAMP_MAX(this->disappearanceTimer, 3); + for (i = 0; i < numFlamesToSpawn; i++) { + pos = this->actor.world.pos; + pos.x += Rand_Centered() * 20.0f; + pos.y += 50.0f + (Rand_Centered() * 50.0f); + pos.z += Rand_Centered() * 20.0f; + velocity.x += Rand_Centered() * 1.5f; + velocity.z += Rand_Centered() * 1.5f; + func_800B3030(globalCtx, &pos, &velocity, &accel, 100, 0, 1); + } + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + player->stateFlags1 |= 0x20000000; + this->disappearanceTimer--; + } else { + if (this->switchFlag != -1) { + Flags_SetSwitch(globalCtx, this->switchFlag); + } + player->stateFlags1 &= ~0x20; + player->stateFlags1 &= ~0x20000000; + Actor_MarkForDeath(&this->actor); + } +} + +void EnTalkGibud_FacePlayerWhenTalking(EnTalkGibud* this, GlobalContext* globalCtx) { + s16 target = this->actor.yawTowardsPlayer; + + Math_ScaledStepToS(&this->actor.shape.rot.y, target, 0x320); + target -= this->actor.shape.rot.y; + this->actor.world.rot.y = this->actor.shape.rot.y; + Math_ScaledStepToS(&this->upperBodyRotation.y, target, 0x258); + target -= this->upperBodyRotation.y; + Math_ScaledStepToS(&this->headRotation.y, target, 0x190); +} + +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)) { + return true; + } + + return false; +} + +/** + * 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 EnTalkGibud_PlayerOutOfRange(EnTalkGibud* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { + return true; + } + + return false; +} + +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_PassiveIdle) { + if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { + this->actor.flags &= ~(0x4 | 0x1); + this->actor.flags |= (0x8 | 0x1); + 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); + if (this->type == EN_TALK_GIBUD_TYPE_REDEAD) { + this->actor.hintId = 0x2A; + } else { + this->actor.hintId = 0x2D; + } + this->actor.textId = 0; + EnTalkGibud_SetupWalkToHome(this); + } + } +} + +void EnTalkGibud_TurnTowardsPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { + s16 headAngle = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->upperBodyRotation.y; + s16 upperBodyAngle = CLAMP(headAngle, -500, 500); + + headAngle -= this->headRotation.y; + headAngle = CLAMP(headAngle, -500, 500); + + if (BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y) >= 0) { + this->upperBodyRotation.y += ABS_ALT(upperBodyAngle); + this->headRotation.y += ABS_ALT(headAngle); + } else { + this->upperBodyRotation.y -= ABS_ALT(upperBodyAngle); + this->headRotation.y -= ABS_ALT(headAngle); + } + + this->upperBodyRotation.y = CLAMP(this->upperBodyRotation.y, -0x495F, 0x495F); + this->headRotation.y = CLAMP(this->headRotation.y, -0x256F, 0x256F); +} + +/** + * 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 EnTalkGibud_MoveToIdealGrabPositionAndRotation(EnTalkGibud* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f targetPos; + f32 distanceFromTargetPos; + f32 distanceFromTargetYOffset = 0.0f; + s16 distanceFromTargetAngle; + + 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.playerForm == PLAYER_FORM_HUMAN) { + 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) { + return true; + } + + return false; +} + +void EnTalkGibud_PlayAnimation(EnTalkGibud* this, GlobalContext* globalCtx) { + if (this->actionFunc != EnTalkGibud_Stunned) { + SkelAnime_Update(&this->skelAnime); + } +} + +void EnTalkGibud_MoveWithGravity(EnTalkGibud* this, GlobalContext* globalCtx) { + if (this->actionFunc == EnTalkGibud_WalkToPlayer || this->actionFunc == EnTalkGibud_WalkToHome || + this->actionFunc == EnTalkGibud_Damage) { + Actor_MoveWithGravity(&this->actor); + } +} + +void EnTalkGibud_CheckDamageEffect(EnTalkGibud* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_ApplyDamage(&this->actor); + + switch (this->actor.colChkInfo.damageEffect) { + case EN_TALK_GIBUD_DMGEFF_DAMAGE: + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + if (player->unk_ADC != 0) { + this->unk_3F7 = player->unk_ADD; + } + this->actor.shape.yOffset = 0.0f; + if (this->actor.colChkInfo.health == 0) { + EnTalkGibud_SetupDead(this); + } else { + EnTalkGibud_SetupDamage(this); + } + break; + + case EN_TALK_GIBUD_DMGEFF_LIGHT_RAY: + if (this->type == EN_TALK_GIBUD_TYPE_REDEAD) { + this->actor.colChkInfo.health = 0; + this->actor.shape.yOffset = 0.0f; + EnTalkGibud_SetupDead(this); + } + break; + + case EN_TALK_GIBUD_DMGEFF_FIRE_ARROW: + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + if (this->actor.colChkInfo.health == 0) { + EnTalkGibud_SetupDead(this); + } else { + EnTalkGibud_SetupDamage(this); + } + this->effectTimer = 180; + this->effectType = 0; + this->effectAlpha = 1.0f; + break; + + case EN_TALK_GIBUD_DMGEFF_LIGHT_ARROW: + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + if (this->actor.colChkInfo.health == 0) { + EnTalkGibud_SetupDead(this); + } else { + EnTalkGibud_SetupDamage(this); + } + this->effectTimer = 60; + this->effectType = 20; + this->effectAlpha = 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; + EnTalkGibud_SetupStunned(this); + } + break; + + case EN_TALK_GIBUD_DMGEFF_STUN: + if ((this->actionFunc != EnTalkGibud_Stunned) || this->stunTimer == 0) { + EnTalkGibud_SetupStunned(this); + } + break; + } + } +} + +void EnTalkGibud_CheckCollision(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->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)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } + } +} + +/** + * 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 EnTalkGibud_MoveGrabbedPlayerAwayFromWall(EnTalkGibud* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f targetPos; + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 29); + if (this->actionFunc == EnTalkGibud_Grab && this->grabState == EN_TALK_GIBUD_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 EnTalkGibud_UpdateEffect(EnTalkGibud* this, GlobalContext* globalCtx) { + if (this->effectTimer > 0) { + this->effectTimer--; + } + if (this->effectTimer < 20) { + Math_SmoothStepToF(&this->effectScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->effectAlpha = this->effectTimer * 0.05f; + } else { + Math_SmoothStepToF(&this->effectScale, 0.5f, 0.1f, 0.02f, 0.0f); + } +} + +void EnTalkGibud_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTalkGibud* this = THIS; + + EnTalkGibud_CheckForGibdoMask(this, globalCtx); + EnTalkGibud_CheckDamageEffect(this, globalCtx); + this->actionFunc(this, globalCtx); + EnTalkGibud_PlayAnimation(this, globalCtx); + EnTalkGibud_MoveWithGravity(this, globalCtx); + EnTalkGibud_CheckCollision(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; +} + +s32 EnTalkGibud_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx, Gfx** gfx) { + EnTalkGibud* this = THIS; + + if (limbIndex == EN_TALK_GIBUD_LIMB_UPPER_BODY_ROOT) { + rot->y += this->upperBodyRotation.y; + } else if (limbIndex == EN_TALK_GIBUD_LIMB_HEAD_ROOT) { + rot->y += this->headRotation.y; + } + + return false; +} + +void EnTalkGibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, + 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))) { + Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + this->limbIndex++; + } +} + +void EnTalkGibud_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTalkGibud* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + this->limbIndex = 0; + if (this->actor.shape.shadowAlpha == 255) { + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->actor.shape.shadowAlpha); + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnTalkGibud_OverrideLimbDraw, + EnTalkGibud_PostLimbDraw, &this->actor, POLY_OPA_DISP); + } else { + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->actor.shape.shadowAlpha); + gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + 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); + } + + 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 57c0d2ae9f..2c154ea89b 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 @@ -3,15 +3,86 @@ #include "global.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*); typedef struct EnTalkGibud { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; - /* 0x01D4 */ EnTalkGibudActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x220]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnTalkGibudActionFunc actionFunc; + /* 0x1D8 */ Vec3f limbPos[15]; + /* 0x28C */ s32 limbIndex; + /* 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]; + /* 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; + }; + /* 0x3EC */ s16 grabState; + /* 0x3EE */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x3F0 */ s16 effectTimer; + /* 0x3F2 */ s16 type; + /* 0x3F4 */ s16 isTalking; + /* 0x3F6 */ u8 effectType; + /* 0x3F7 */ s8 unk_3F7; // related to player->unk_ADD } EnTalkGibud; // size = 0x3F8 extern const ActorInit En_Talk_Gibud_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 313a0a1fdb..c735f4ca25 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c @@ -199,7 +199,7 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&this->targetPos, &player->actor.world.pos); if (!(this->timer & 0xF)) { if (Rand_ZeroOne() < 0.5f && this->actor.xzDistToPlayer <= 200.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PIRANHA_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_ATTACK); } } @@ -260,7 +260,7 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { Math_ApproachS(&this->rotationStep, this->targetRotationStep, 1, 0x100); Math_ApproachF(&this->actor.speedXZ, this->targetSpeedXZ, 1.0f, this->speedMaxStep); - Actor_SetVelocityAndMoveXYRotationReverse(&this->actor); + Actor_MoveWithoutGravityReverse(&this->actor); } else { switch (this->isBeached) { case false: @@ -315,7 +315,7 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { } break; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } this->currentRotationAngle += this->nextRotationAngle; @@ -341,11 +341,11 @@ void EnTanron3_SetupDie(EnTanron3* this, GlobalContext* globalCtx) { this->actor.world.rot.y = Math_FAtan2F(zDistance, xDistance); this->workTimer[TANRON3_WORK_TIMER_DIE] = 6; this->actor.speedXZ = 10.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KONB_MINI_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_MINI_DEAD); } void EnTanron3_Die(EnTanron3* this, GlobalContext* globalCtx) { - Actor_SetVelocityAndMoveXYRotationReverse(&this->actor); + Actor_MoveWithoutGravityReverse(&this->actor); if (this->workTimer[TANRON3_WORK_TIMER_DIE] == 0) { EnTanron3_SpawnBubbles(this, globalCtx); Actor_MarkForDeath(&this->actor); @@ -407,7 +407,7 @@ void EnTanron3_Update(Actor* thisx, GlobalContext* globalCtx) { splashPos.y = this->waterSurfaceYPos + 10.0f; splashPos.z = this->actor.world.pos.z; EffectSsGSplash_Spawn(globalCtx, &splashPos, NULL, NULL, 1, 500); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_OUT_OF_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); } } diff --git a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c index 2c855d36a9..c34d2e5b5d 100644 --- a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c +++ b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c @@ -69,7 +69,7 @@ void EnTanron6_Init(Actor* thisx, GlobalContext* globalCtx) { EnTanron6* this = THIS; this->actor.colChkInfo.mass = 10; - ActorShape_Init(&this->actor.shape, 0, func_800B3FC0, 19.0f); + ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 19.0f); this->actor.colChkInfo.health = 1; this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.targetMode = 6; @@ -90,7 +90,7 @@ void EnTanron6_Update(Actor* thisx, GlobalContext* globalCtx) { EnTanron6* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 40.0f, 40.0f, 0x1D); } diff --git a/src/overlays/actors/ovl_En_Test5/z_en_test5.c b/src/overlays/actors/ovl_En_Test5/z_en_test5.c index 4da30599cb..0360af9271 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.c +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.c @@ -66,15 +66,15 @@ void EnTest5_HandleBottleAction(EnTest5* this, GlobalContext* globalCtx) { player = GET_PLAYER(globalCtx); - if (player->unk_388 == NULL || player->unk_384 != GI_MAX) { + if (player->interactRangeActor == NULL || player->getItemId != GI_MAX) { Math_Vec3f_DistXYZAndStoreDiff(&this->minPos, &player->actor.world.pos, &playerPosRelativeToWater); // Make sure that the player is within the bounds of the water and deep enough to grab some if (playerPosRelativeToWater.x >= 0.0f && playerPosRelativeToWater.x <= this->xLength && playerPosRelativeToWater.z >= 0.0f && playerPosRelativeToWater.z <= this->zLength && fabsf(playerPosRelativeToWater.y) < 100.0f && player->actor.depthInWater > 12.0f) { - func_800B8A1C(&this->actor, globalCtx, GI_MAX, this->actor.xzDistToPlayer, - fabsf(this->actor.playerHeightRel)); + Actor_PickUp(&this->actor, globalCtx, GI_MAX, this->actor.xzDistToPlayer, + fabsf(this->actor.playerHeightRel)); } } } @@ -102,7 +102,7 @@ void EnTest5_Update(Actor* thisx, GlobalContext* globalCtx2) { steamVel.x = 0.0f; steamVel.z = 0.0f; - EffectSsIceSmoke_Spawn(globalCtx, &steamPos, &steamVel, &D_801D15B0, + EffectSsIceSmoke_Spawn(globalCtx, &steamPos, &steamVel, &gZeroVec3f, (s16)((-200) - (s32)(Rand_ZeroOne() * 50.0f))); } } 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 89973ff694..cee811bdf9 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -174,7 +174,7 @@ void EnThiefbird_Init(Actor* thisx, GlobalContext* globalCtx) { } CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - ActorShape_Init(&this->actor.shape, 1500.0f, func_800B3FC0, 35.0f); + ActorShape_Init(&this->actor.shape, 1500.0f, ActorShadow_DrawCircle, 35.0f); if (this->actor.params == 1) { D_80C1392C = 1; Math_Vec3f_Copy(&D_80C13920, &this->actor.world.pos); @@ -251,7 +251,7 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { if (isItemFound) { func_801149A0(itemId2, slotId); this->unk_3E8 = D_060033B0; - if (!func_80152498(&globalCtx->msgCtx)) { + if (!Message_GetState(&globalCtx->msgCtx)) { func_801518B0(globalCtx, 0xF4, NULL); } itemId1 = ITEM_BOTTLE; @@ -275,7 +275,7 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_3E8 = D_80C13680[phi_a3 - 1]; } - if (!func_80152498(&globalCtx->msgCtx)) { + if (!Message_GetState(&globalCtx->msgCtx)) { func_801518B0(globalCtx, 0xF5, NULL); } } else { @@ -401,12 +401,12 @@ s32 func_80C10E98(GlobalContext* globalCtx) { sp64.y = player->actor.world.pos.y + 20.0f; sp64.z = (Math_CosS(phi_s3) * 40.0f) + player->actor.world.pos.z; if (dropItem00Ids[i] != ITEM00_NO_DROP) { - EnItem00* temp_s1_5 = Item_DropCollectible(globalCtx, &sp64, dropItem00Ids[i]); + Actor* temp_s1_5 = Item_DropCollectible(globalCtx, &sp64, dropItem00Ids[i]); if (temp_s1_5 != NULL) { - temp_s1_5->actor.velocity.y = Rand_ZeroFloat(3.0f) + 6.0f; - temp_s1_5->actor.speedXZ = Rand_ZeroFloat(3.0f) + 3.0f; - temp_s1_5->actor.world.rot.y = phi_s3; + temp_s1_5->velocity.y = Rand_ZeroFloat(3.0f) + 6.0f; + temp_s1_5->speedXZ = Rand_ZeroFloat(3.0f) + 3.0f; + temp_s1_5->world.rot.y = phi_s3; } phi_s3 += (s16)(0x10000 / (spB0 + spAC + phi_s0_2 + spA0 + phi_s2 + spA8)); } @@ -429,7 +429,7 @@ void func_80C11338(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_3EC = NULL; do { - item = (EnItem00*)func_ActorCategoryIterateById(globalCtx, &item->actor, ACTORCAT_MISC, ACTOR_EN_ITEM00); + item = (EnItem00*)SubS_FindActor(globalCtx, &item->actor, ACTORCAT_MISC, ACTOR_EN_ITEM00); if (item != NULL) { if (item->unk152 > 0) { if (Actor_XZDistanceBetweenActors(&player->actor, &item->actor) > 10.0f) { @@ -459,14 +459,14 @@ void func_80C11454(EnThiefbird* this) { this->unk_3DC = 0.75f; this->unk_3D4 = 1.0f; this->actor.flags &= ~0x200; - func_800BCB70(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_80C114C0(EnThiefbird* this, GlobalContext* globalCtx) { if (this->unk_18C == 10) { this->unk_18C = 0; this->unk_3D4 = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->unk_350, 11, 2, 0.2f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_350, 11, 2, 0.2f, 0.2f); this->actor.flags |= 0x200; } } @@ -503,7 +503,7 @@ void func_80C11590(EnThiefbird* this, GlobalContext* globalCtx) { } else { this->unk_192 -= Rand_S16Offset(4096, 4096); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); } if ((this->actor.depthInWater > -40.0f) || (this->actor.bgCheckFlags & 1)) { @@ -548,7 +548,7 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KAICHO_FLUTTER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_FLUTTER); } if (this->unk_18E != 0) { @@ -560,7 +560,7 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.x, pitch, 4, 0x800, 0x80); if (this->actor.bgCheckFlags & 8) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 6, 0x1000, 0x100); - } else if (Actor_IsActorFacingLink(&this->actor, 0x3C00) || (this->actor.xzDistToPlayer > 120.0f)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x3C00) || (this->actor.xzDistToPlayer > 120.0f)) { s16 rot = BINANG_ROT180(this->actor.yawTowardsPlayer - player->actor.shape.rot.y); if (rot > 0x4000) { @@ -578,7 +578,7 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { (this->actor.depthInWater > -40.0f)) { if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); if (!(this->collider.base.atFlags & AT_BOUNCED)) { if ((D_80C1392C != 0) && CUR_UPG_VALUE(UPG_QUIVER) && (!((gSaveContext.roomInf[126][5] & 0xFF000000) >> 0x18) || @@ -608,8 +608,8 @@ void func_80C11C60(EnThiefbird* this) { this->actor.shape.rot.x = 0; this->unk_18E = 40; this->actor.velocity.y = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_THIEFBIRD_DEAD); - func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_DEAD); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); this->collider.base.acFlags &= ~AC_ON; this->actor.flags |= 0x10; this->unk_192 = 0x1C00; @@ -658,10 +658,10 @@ 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], &D_801D15B0, &D_801D15B0, 0x8C, 0, 0); + func_800B3030(globalCtx, &this->unk_350[i], &gZeroVec3f, &gZeroVec3f, 0x8C, 0, 0); } - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_HUGE); for (i = 0; i < ARRAY_COUNT(D_80C13664); i++) { @@ -684,14 +684,14 @@ void func_80C11F6C(EnThiefbird* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 5) { - func_800BCB70(&this->actor, 0, 255, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); } else if (this->actor.colChkInfo.damageEffect == 1) { - func_800BCB70(&this->actor, 0, 255, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); } else { - func_800BCB70(&this->actor, 0x4000, 255, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_THIEFBIRD_DAMAGE); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_DAMAGE); } this->collider.base.acFlags &= ~AC_ON; @@ -931,7 +931,7 @@ void func_80C12B1C(EnThiefbird* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; this->collider.base.atFlags &= ~AT_HIT; - func_800BE258(&this->actor, this->collider.elements); + Actor_SetDropFlag(&this->actor, &this->collider.elements->info); func_80C114C0(this, globalCtx); this->unk_194 = 0; @@ -1016,9 +1016,9 @@ void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.world.rot.x = -this->actor.shape.rot.x; if (this->actor.colChkInfo.health != 0) { - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); } else { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 25.0f, 50.0f, 7); @@ -1044,7 +1044,7 @@ void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx2) { func_80C12D00(this); if (((this->skelAnime.animation == &D_06000604) && Animation_OnFrame(&this->skelAnime, 13.0f)) || ((this->skelAnime.animation == &D_06000278) && Animation_OnFrame(&this->skelAnime, 1.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KAICHO_FLUTTER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_FLUTTER); } } diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index 61a12cfb0a..5afdd500f6 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -140,7 +140,7 @@ static Vec3f D_80896B44 = { 0.0f, 0.45f, 0.0f }; static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 70, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(minVelocityY, -40, ICHAIN_CONTINUE), + ICHAIN_F32(terminalVelocity, -40, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; @@ -154,8 +154,8 @@ void EnTite_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); SkelAnime_Init(globalCtx, &this->skelAnime, &D_06003A20, &D_060012E4, this->jointTable, this->morphTable, 25); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 60.0f); - Actor_SetHeight(&this->actor, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 60.0f); + Actor_SetFocus(&this->actor, 20.0f); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; @@ -266,12 +266,12 @@ void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { sp7C.x = ptr->x + randPlusMinusPoint5Scaled(1.0f); sp7C.y = ptr->y + randPlusMinusPoint5Scaled(1.0f); sp7C.z = ptr->z + randPlusMinusPoint5Scaled(1.0f); - func_800B0DE0(globalCtx, &sp7C, &D_801D15B0, &D_80896B64, &D_80896B3C, &D_80896B40, + func_800B0DE0(globalCtx, &sp7C, &gZeroVec3f, &D_80896B64, &D_80896B3C, &D_80896B40, (s32)Rand_ZeroFloat(16.0f) + 80, 15); } } } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } } @@ -282,7 +282,7 @@ void func_80893DD4(EnTite* this) { this->unk_2C8 = 0.5f; this->unk_2CC = 0.75f; this->unk_2C4 = 1.0f; - func_800BCB70(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); this->actor.flags &= ~0x200; } @@ -291,7 +291,7 @@ void func_80893E54(EnTite* this, GlobalContext* globalCtx) { this->unk_2BB = 0; this->collider.base.colType = COLTYPE_HIT6; this->unk_2C4 = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->unk_2D0, 9, 2, 0.2f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D0, 9, 2, 0.2f, 0.2f); this->actor.flags |= 0x200; } } @@ -335,10 +335,10 @@ void func_80894024(EnTite* this, GlobalContext* globalCtx) { void func_8089408C(EnTite* this, GlobalContext* globalCtx) { Animation_PlayOnce(&this->skelAnime, &D_060004F8); if (!func_80893ADC(this)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); } else { this->actor.world.pos.y += this->actor.depthInWater; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); } if (this->actor.shape.yOffset < 0.0f) { @@ -361,7 +361,7 @@ void func_8089408C(EnTite* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= 1; this->actor.velocity.y = 10.0f; } else { @@ -389,7 +389,7 @@ void func_808942B4(EnTite* this, GlobalContext* globalCtx) { func_8089452C(this, globalCtx); } else { this->actor.velocity.y = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); func_80894414(this); } } @@ -412,7 +412,7 @@ void func_80894454(EnTite* this, GlobalContext* globalCtx) { if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (this->actor.xzDistToPlayer > 450.0f) || (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); - } else if (!Actor_IsActorFacingLink(&this->actor, 0x2328)) { + } else if (!Actor_IsFacingPlayer(&this->actor, 0x2328)) { func_808945EC(this); } else { func_80893A9C(this, globalCtx); @@ -430,7 +430,7 @@ void func_8089452C(EnTite* this, GlobalContext* globalCtx) { sp2C.y += this->actor.depthInWater; this->actor.velocity.y *= 0.75f; EffectSsGRipple_Spawn(globalCtx, &sp2C, 0, 500, 0); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER); this->actionFunc = func_808945B4; } @@ -466,9 +466,9 @@ void func_80894638(EnTite* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 7.0f)) { if (func_80893ADC(this)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_WALK_WATER); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_WALK); } } @@ -476,7 +476,7 @@ void func_80894638(EnTite* this, GlobalContext* globalCtx) { (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); } else if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.depthInWater < 10.0f))) && - Actor_IsActorFacingLink(&this->actor, 0xE38)) { + Actor_IsFacingPlayer(&this->actor, 0xE38)) { if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.playerHeightRel <= 80.0f)) { func_80893A9C(this, globalCtx); } else { @@ -495,9 +495,9 @@ void func_8089484C(EnTite* this) { this->actor.speedXZ = 4.0f; if (func_80893ADC(this)) { this->actor.world.pos.y += this->actor.depthInWater; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); } this->actionFunc = func_80894910; } @@ -508,7 +508,7 @@ void func_80894910(EnTite* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 1.0f, 0.0f); SkelAnime_Update(&this->skelAnime); if (this->actor.bgCheckFlags & 0x40) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER); if (func_80893ADC(this)) { Math_Vec3f_Copy(&sp34, &this->actor.world.pos); @@ -569,7 +569,7 @@ void func_80894BC8(EnTite* this, GlobalContext* globalCtx) { } if (this->actor.bgCheckFlags & 0x40) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); } else { func_80893BCC(this, globalCtx); } @@ -582,7 +582,7 @@ void func_80894BC8(EnTite* this, GlobalContext* globalCtx) { (ABS_ALT(this->actor.shape.rot.x) < 4000) && (ABS_ALT(this->actor.shape.rot.z) < 4000))) { func_80893ED4(this); } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.playerHeightRel <= 80.0f) && - Actor_IsActorFacingLink(&this->actor, 0x1770)) { + Actor_IsFacingPlayer(&this->actor, 0x1770)) { func_80893A9C(this, globalCtx); } else { func_8089484C(this); @@ -611,7 +611,7 @@ void func_80894E0C(EnTite* this, GlobalContext* globalCtx) { } if (this->actor.bgCheckFlags & 0x40) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); } else { func_80893BCC(this, globalCtx); } @@ -627,7 +627,7 @@ void func_80894E0C(EnTite* this, GlobalContext* globalCtx) { (ABS_ALT(this->actor.shape.rot.x) < 4000) && (ABS_ALT(this->actor.shape.rot.z) < 4000))) { func_80893ED4(this); } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.playerHeightRel <= 80.0f) && - Actor_IsActorFacingLink(&this->actor, 0x1770)) { + Actor_IsFacingPlayer(&this->actor, 0x1770)) { func_80893A9C(this, globalCtx); } else { func_8089484C(this); @@ -644,7 +644,7 @@ void func_80895020(EnTite* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; this->collider.base.acFlags &= ~AC_ON; this->actor.colorFilterTimer = 0; - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_TEKU_DEAD); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_TEKU_DEAD); this->actor.flags &= ~1; this->actor.flags |= 0x10; this->unk_2BA = 1; @@ -677,8 +677,8 @@ void func_808951B8(EnTite* this, GlobalContext* globalCtx) { if (this->unk_2BC == 0) { for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { - func_800B3030(globalCtx, &this->unk_2D0[i], &D_801D15B0, &D_801D15B0, 40, 7, 1); - Audio_PlaySoundAtPosition(globalCtx, &this->unk_2D0[i], 11, NA_SE_EN_EXTINCT); + func_800B3030(globalCtx, &this->unk_2D0[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 1); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->unk_2D0[i], 11, NA_SE_EN_EXTINCT); } Actor_MarkForDeath(&this->actor); } else { @@ -691,7 +691,7 @@ void func_808951B8(EnTite* this, GlobalContext* globalCtx) { void func_808952EC(EnTite* this) { Animation_PlayLoopSetSpeed(&this->skelAnime, &D_06000A14, 1.5f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); this->collider.base.acFlags &= ~AC_ON; func_80893A18(this); this->unk_2B9 = 1; @@ -718,8 +718,8 @@ void func_80895424(EnTite* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { this->collider.base.acFlags |= AC_ON; if (this->actor.bgCheckFlags & 2) { - func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, 20.0f, 11, 4.0f, 0, 0, 0); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 20.0f, 11, 4.0f, 0, 0, 0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } if (this->unk_2BC == 0) { @@ -735,7 +735,7 @@ void func_80895424(EnTite* this, GlobalContext* globalCtx) { void func_808955E4(EnTite* this) { this->unk_2B9 = 0; this->actor.velocity.y = 13.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); this->actor.bgCheckFlags &= ~1; this->collider.base.acFlags &= ~AC_ON; this->actionFunc = func_80895640; @@ -801,7 +801,7 @@ void func_80895738(EnTite* this, GlobalContext* globalCtx) { if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (this->actor.xzDistToPlayer > 450.0f) || (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); - } else if (!Actor_IsActorFacingLink(&this->actor, 0x2328)) { + } else if (!Actor_IsFacingPlayer(&this->actor, 0x2328)) { func_808945EC(this); } else { func_80893A9C(this, globalCtx); @@ -816,7 +816,7 @@ void func_8089595C(EnTite* this, GlobalContext* globalCtx) { sp2C.x = randPlusMinusPoint5Scaled(20.0f) + this->actor.world.pos.x; sp2C.y = this->actor.world.pos.y + 15.0f; sp2C.z = randPlusMinusPoint5Scaled(20.0f) + this->actor.world.pos.z; - func_800B0DE0(globalCtx, &sp2C, &D_801D15B0, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); + func_800B0DE0(globalCtx, &sp2C, &gZeroVec3f, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); } void func_80895A10(EnTite* this) { @@ -839,7 +839,7 @@ void func_80895AC0(EnTite* this, GlobalContext* globalCtx) { if (Rand_ZeroOne() < 0.25f) { func_8089595C(this, globalCtx); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_WALK); } if ((this->unk_2BC == 1) || (this->unk_2BC == -1)) { @@ -885,7 +885,7 @@ void func_80895D08(EnTite* this, GlobalContext* globalCtx) { if (Rand_ZeroOne() < 0.5f) { func_8089595C(this, globalCtx); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_WALK); } if ((this->actor.xzDistToPlayer < 240.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { func_8089408C(this, globalCtx); @@ -899,7 +899,7 @@ void func_80895D08(EnTite* this, GlobalContext* globalCtx) { void func_80895DE8(EnTite* this) { this->collider.base.acFlags &= ~AC_ON; - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->skelAnime.playSpeed = 1.0f; this->actor.speedXZ = 0.0f; this->actionFunc = func_80895E28; @@ -950,7 +950,7 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { return; } - func_800BE258(&this->actor, &this->collider.info); + Actor_SetDropFlag(&this->actor, &this->collider.info); if ((this->unk_2BB != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { func_80893E54(this, globalCtx); @@ -966,8 +966,8 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect != 0xF) { if (this->actor.colChkInfo.damageEffect == 5) { this->unk_2BC = 40; - func_800BCB70(&this->actor, 0, 200, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 200, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->unk_2BB = 32; this->unk_2C8 = 0.5f; this->unk_2C4 = 2.0f; @@ -977,8 +977,8 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 1) { this->unk_2BC = 40; - func_800BCB70(&this->actor, 0, 200, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 200, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_80894DD0(this); return; } @@ -1006,12 +1006,12 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { func_80895020(this, globalCtx); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_DAMAGE); if (this->unk_2B9 == 0) { func_80894B2C(this); @@ -1028,7 +1028,7 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { this->actor.flags |= 1; if (this->actor.shape.yOffset < 0.0f) { this->actor.shape.yOffset = 0.0f; - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; } if (this->unk_2B9 != 0) { func_808955E4(this); @@ -1067,7 +1067,7 @@ void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (this->actionFunc != func_808951B8) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 40.0f, 20.0f, this->unk_2C0); func_808963B4(this, globalCtx); if (this->actor.bgCheckFlags & 1) { @@ -1085,7 +1085,7 @@ void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_SetHeight(&this->actor, this->actor.scale.y * 2000.0f); + Actor_SetFocus(&this->actor, this->actor.scale.y * 2000.0f); this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; this->collider.dim.worldSphere.center.y = (s32)this->actor.world.pos.y + 15; this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 07bf625d21..102286a257 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -235,7 +235,7 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B9E8, NULL, this->jointTable, this->morphTable, 18); Animation_Change(&this->skelAnime, &D_060030A4, 1.0f, 0.0f, Animation_GetLastFrame(&D_060030A4.common), 0, 0.0f); this->unk_318 = 0; @@ -299,7 +299,7 @@ void func_80AECA3C(EnTk* this, GlobalContext* globalCtx) { } void func_80AECA90(EnTk* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.unk11F22 = 0; globalCtx->msgCtx.unk11F10 = 0; func_80AEDE10(this, globalCtx); @@ -326,7 +326,7 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { struct_80133038_arg2 sp34; this->actor.textId = 0; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.unk11F22 = 0; globalCtx->msgCtx.unk11F10 = 0; func_80AED4F8(this, globalCtx); @@ -405,7 +405,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { func_8013AF00(spA0, 3, this->unk_3C8->count + 3); if (!(this->unk_3CE & 4)) { - sp7C = D_801D15B0; + sp7C = gZeroVec3f; func_8013B6B0(this->unk_3C8, &this->unk_3E0, &this->unk_3F0, this->unk_3E8, this->unk_3E4, &this->unk_3EC, spA0, &sp7C, this->unk_3D0); func_8013B878(globalCtx, this->unk_3C8, this->unk_3EC, &sp7C); @@ -428,7 +428,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { sp7C = this->actor.world.pos; } - this->unk_3D4 = D_801D15B0; + this->unk_3D4 = gZeroVec3f; if (func_8013B6B0(this->unk_3C8, &this->unk_3E0, &this->unk_3F0, this->unk_3E8, this->unk_3E4, &this->unk_3EC, spA0, &this->unk_3D4, this->unk_3D0)) { @@ -450,7 +450,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { door1 = NULL; label: do { - door1 = func_ActorCategoryIterateById(globalCtx, door1, ACTORCAT_DOOR, ACTOR_EN_DOOR); + door1 = SubS_FindActor(globalCtx, door1, ACTORCAT_DOOR, ACTOR_EN_DOOR); if (door1 != NULL) { if (Actor_XZDistanceBetweenActors(&this->actor, door1) <= 120.0f) { if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &door1->world.pos), this->actor.shape.rot.y)) <= @@ -466,7 +466,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { } else { door2 = NULL; do { - door2 = func_ActorCategoryIterateById(globalCtx, door2, ACTORCAT_DOOR, ACTOR_EN_DOOR); + door2 = SubS_FindActor(globalCtx, door2, ACTORCAT_DOOR, ACTOR_EN_DOOR); if (door2 != NULL) { if (Actor_XZDistanceBetweenActors(&this->actor, door2) <= 160.0f) { sp4C4 = (EnDoor*)door2; @@ -480,7 +480,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { if ((sp4C4 != NULL) && (this->unk_2CA & 0x400)) { Vec3f sp5C; - Actor_CalcOffsetOrientedToDrawRotation(&this->actor, &sp5C, &sp4C4->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->actor, &sp5C, &sp4C4->actor.world.pos); sp4C4->unk_1A7 = 2; if (sp5C.z < -20.0f) { this->unk_2CA &= ~0x400; @@ -562,7 +562,7 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 0x71C)) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { @@ -682,7 +682,7 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { actor = NULL; do { - actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_TK); + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_TK); if (actor != NULL) { if (ENTK_GET_F(actor) == 1) { Math_Vec3f_Copy(&this->unk_2EC, &actor->world.pos); @@ -696,7 +696,7 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { } while (actor != NULL); } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_2CA &= ~0x80; this->actor.flags &= ~0x10000; globalCtx->msgCtx.unk11F22 = 0; @@ -801,7 +801,7 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: switch (this->unk_2E6) { case 0x1404: @@ -933,7 +933,7 @@ void func_80AEE374(EnTk* this, GlobalContext* globalCtx) { sp30.unk_00 = NULL; sp30.unk_04 = FLT_MAX; - func_8013E640(globalCtx, &this->actor, NULL, ACTORCAT_NPC, ACTOR_EN_TK, &sp30, func_80AEE300); + SubS_FindActorCustom(globalCtx, &this->actor, NULL, ACTORCAT_NPC, ACTOR_EN_TK, &sp30, func_80AEE300); if (sp30.unk_00 == 0) { Actor_MarkForDeath(&this->actor); } else { @@ -964,14 +964,14 @@ void func_80AEE4D0(EnTk* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 33.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_DIG_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIG_UP); } if (!(this->unk_2CA & 0x20)) { if (Animation_OnFrame(&this->skelAnime, 37.0f)) { bigPoe = NULL; do { - bigPoe = func_ActorCategoryIterateById(globalCtx, bigPoe, ACTORCAT_PROP, ACTOR_EN_BIGPO); + bigPoe = SubS_FindActor(globalCtx, bigPoe, ACTORCAT_PROP, ACTOR_EN_BIGPO); if (bigPoe != NULL) { if ((bigPoe->params == 3) && (Actor_DistanceBetweenActors(&this->actor, bigPoe) < 80.0f)) { @@ -1197,7 +1197,7 @@ void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; } - if (!func_80152498(&globalCtx->msgCtx) && !func_801690CC(globalCtx) && (this->unk_2C6-- <= 0)) { + if (!Message_GetState(&globalCtx->msgCtx) && !func_801690CC(globalCtx) && (this->unk_2C6-- <= 0)) { func_801518B0(globalCtx, 0x140C, NULL); this->unk_2CA |= 0x4000; this->unk_2C6 = 200; @@ -1270,12 +1270,12 @@ void func_80AEF2D8(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.draw != NULL) && ((this->unk_2D4 == 0) || (this->unk_2D4 == 1)) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 24.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_WALK); } this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 4); func_80AEC460(this); } @@ -1292,7 +1292,7 @@ void EnTk_Update(Actor* thisx, GlobalContext* globalCtx) { if (((this->unk_2D4 == 0) || (this->unk_2D4 == 1)) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 24.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_WALK); } this->unk_2CA &= ~1; @@ -1315,7 +1315,7 @@ void EnTk_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 5); if ((this->unk_2B0 == 0) && @@ -1331,7 +1331,7 @@ void EnTk_Update(Actor* thisx, GlobalContext* globalCtx) { if (!(this->actor.bgCheckFlags & 1)) { func_800B9010(&this->actor, NA_SE_EV_HONEYCOMB_FALL - SFX_FLAG); } else if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HUMAN_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); } } } diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index ba6945b841..9f0ce13f8d 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -88,7 +88,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx) { } this->actor.gravity = -1.0f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 70.0f, 0x05); if (this->framesUntilNextState == 0) { @@ -140,7 +140,7 @@ void EnTorch2_UpdateDeath(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } else { this->actor.gravity = -1.0f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } } @@ -154,11 +154,11 @@ void EnTorch2_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->alpha == 0xFF) { Scene_SetRenderModeXlu(globalCtx, 0, 0x01); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - func_800BDFC0(globalCtx, gfx); + Gfx_DrawDListOpa(globalCtx, gfx); } else { Scene_SetRenderModeXlu(globalCtx, 1, 0x02); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->alpha); - func_800BE03C(globalCtx, gfx); + Gfx_DrawDListXlu(globalCtx, gfx); } CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index 0acdc04856..f92ef5afda 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -203,7 +203,7 @@ void EnToto_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); this->actor.bgCheckFlags |= 0x400; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600A978, ((globalCtx->sceneNum == 0x12) ? &D_06003AA8 : &D_0600C880), this->jointTable, this->morphTable, @@ -227,7 +227,7 @@ void func_80BA383C(EnToto* this, GlobalContext* globalCtx) { } Animation_PlayOnce(&this->skelAnime, D_80BA5078[this->unk2B4]); } - func_800BBB74(&this->unk260, 0x14, 0x50, 3); + func_800BBB74(this->unk260, 0x14, 0x50, 3); } void func_80BA3930(EnToto* this, GlobalContext* globalCtx) { @@ -253,12 +253,12 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); func_80BA383C(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80BA36C0(this, globalCtx, 1); if (globalCtx->sceneNum != 0x12) { - Actor_SetSwitchFlag(globalCtx, this->actor.params & 0x7F); + Flags_SetSwitch(globalCtx, this->actor.params & 0x7F); } else if (player->transformation == PLAYER_FORM_DEKU) { - Actor_SetSwitchFlag(globalCtx, this->actor.home.rot.x); + Flags_SetSwitch(globalCtx, this->actor.home.rot.x); } this->unk2B6 = 0; return; @@ -269,7 +269,7 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { if (this->unk2B6 != 0) { this->text = D_80BA5044; this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, 0); + func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, EXCH_ITEM_NONE); } else { this->actor.flags &= ~0x10000; func_800B8614(&this->actor, globalCtx, 50.0f); @@ -315,7 +315,7 @@ void func_80BA3C88(EnToto* this) { void func_80BA3CC4(EnToto* this, GlobalContext* globalCtx) { func_80BA383C(this, globalCtx); func_80BA3C88(this); - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { func_80BA36C0(this, globalCtx, this->text->unk1); } else { func_80BA4C44(this, globalCtx); @@ -327,7 +327,7 @@ void func_80BA3D38(EnToto* this, GlobalContext* globalCtx) { this->text = ENTOTO_WEEK_EVENT_FLAGS ? D_80BA50BC : D_80BA5088; func_80BA4C0C(this, globalCtx); globalCtx->actorCtx.unk5 |= 0x20; - this->unk260 = 0; + this->unk260[0] = 0; } void func_80BA3DBC(EnToto* this, GlobalContext* globalCtx) { @@ -419,21 +419,21 @@ s32 func_80BA407C(EnToto* this, GlobalContext* globalCtx) { } s32 func_80BA40D4(EnToto* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { return 1; } return 0; } s32 func_80BA4128(EnToto* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 2) { + if (Message_GetState(&globalCtx->msgCtx) == 2) { return 1; } return 0; } s32 func_80BA415C(EnToto* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 4 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 4 && func_80147624(globalCtx)) { if (globalCtx->msgCtx.choiceIndex != 0) { func_8019F230(); } else { @@ -655,14 +655,14 @@ s32 func_80BA4B24(EnToto* this, GlobalContext* globalCtx) { Animation_MorphToPlayOnce(&this->skelAnime, &D_060028B8, -4.0f); if (player->transformation == PLAYER_FORM_ZORA) { if (!Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { - Actor_SetSwitchFlag(globalCtx, this->actor.params & 0x7F); + Flags_SetSwitch(globalCtx, this->actor.params & 0x7F); return 1; } else { return 3; } } else { if (!Flags_GetSwitch(globalCtx, (this->actor.params >> 7) & 0x7F)) { - Actor_SetSwitchFlag(globalCtx, (this->actor.params >> 7) & 0x7F); + Flags_SetSwitch(globalCtx, (this->actor.params >> 7) & 0x7F); return 4; } else { return 7; @@ -712,7 +712,7 @@ void func_80BA4CB4(EnToto* this, GlobalContext* globalCtx) { } } if (this->unk2B5 == 4 && !Actor_HasParent(&this->actor, globalCtx)) { - func_800B8A1C(&this->actor, globalCtx, GI_MASK_CIRCUS_LEADER, 9999.9f, 9999.9f); + Actor_PickUp(&this->actor, globalCtx, GI_MASK_CIRCUS_LEADER, 9999.9f, 9999.9f); } } @@ -730,7 +730,7 @@ void EnToto_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_SetHeight(&this->actor, 40.0f); + Actor_SetFocus(&this->actor, 40.0f); } void EnToto_Draw(Actor* thisx, GlobalContext* globalCtx) { @@ -741,7 +741,7 @@ void EnToto_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp4C[this->unk260])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp4C[this->unk260[0]])); Scene_SetRenderModeXlu(globalCtx, 0, 1); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, &this->actor); diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.h b/src/overlays/actors/ovl_En_Toto/z_en_toto.h index aa96284266..cdfe3294ea 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.h +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.h @@ -26,7 +26,7 @@ typedef struct EnToto { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ Vec3s jointTable[18]; /* 0x1F4 */ Vec3s morphTable[18]; - /* 0x260 */ s16 unk260; + /* 0x260 */ s16 unk260[2]; /* 0x264 */ ColliderCylinder collider; /* 0x2B0 */ u8 actionFuncIndex; /* 0x2B1 */ u8 unk2B1; diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index a03072c529..98bcf100b7 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -159,7 +159,7 @@ void EnTrt_UpdateCursorPos(GlobalContext* globalCtx, EnTrt* this) { f32 xOffset = 0.0f; f32 yOffset = 17.0f; - func_800B8898(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); this->cursorPos.x = x + xOffset; this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; @@ -213,7 +213,7 @@ void EnTrt_EndInteraction(GlobalContext* globalCtx, EnTrt* this) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } - func_800B84D0(&this->actor, globalCtx); + Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; Interface_ChangeAlpha(50); @@ -312,7 +312,7 @@ u8 EnTrt_SetCursorIndexFromNeutral(EnTrt* this, u8 shelfOffset) { } void EnTrt_Hello(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -331,7 +331,7 @@ void EnTrt_Hello(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_GetMushroom(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); this->tmpGetMushroomCutscene = this->getMushroomCutscene; @@ -375,12 +375,12 @@ void EnTrt_PayForMushroom(EnTrt* this, GlobalContext* globalCtx) { func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); this->actionFunc = EnTrt_SetupItemGiven; } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_RED, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 300.0f, 300.0f); } } void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { switch (this->textId) { case 0x886: this->textId = 0x887; @@ -395,7 +395,7 @@ void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { if (this->textId == 0x88F) { if (func_80114E90() || !(gSaveContext.weekEventReg[0xC] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { @@ -450,9 +450,9 @@ void EnTrt_GiveRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x20000000; this->actionFunc = EnTrt_GivenRedPotionForKoume; } else if (gSaveContext.weekEventReg[0xC] & 0x10) { - func_800B8A1C(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); } else { - func_800B8A1C(&this->actor, globalCtx, GI_BOTTLE_POTION_RED, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, GI_BOTTLE_POTION_RED, 300.0f, 300.0f); } } @@ -460,7 +460,7 @@ void EnTrt_GivenRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { //! @bug: player is set to NULL not PLAYER Player* player = NULL; - if (func_80152498(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); @@ -476,13 +476,13 @@ void EnTrt_GivenRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); this->actionFunc = EnTrt_ItemGiven; } } void EnTrt_EndConversation(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { if (func_80147624(globalCtx)) { @@ -510,7 +510,7 @@ s32 EnTrt_FacingShopkeeperDialogResult(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_FaceShopkeeper(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); u8 cursorIdx; if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { @@ -617,7 +617,7 @@ s32 EnTrt_HasPlayerSelectedItem(GlobalContext* globalCtx, EnTrt* this, Input* in } void EnTrt_BrowseShelf(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; u8 prevCursorIdx = this->cursorIdx; u8 cursorIdx; @@ -646,7 +646,7 @@ void EnTrt_BrowseShelf(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnTrt* this) { Player* player = GET_PLAYER(globalCtx); - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; player->stateFlags2 &= ~0x20000000; @@ -712,7 +712,7 @@ void EnTrt_HandleCanBuyItem(GlobalContext* globalCtx, EnTrt* this) { void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { EnGirlA* item = this->items[this->cursorIdx]; - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (EnTrt_TakeItemOffShelf(this)) { if (talkState == 4) { @@ -774,7 +774,7 @@ void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_SCENTS) { this->textId = 0x890; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (player->transformation == PLAYER_FORM_HUMAN) { this->flags |= ENTRT_MET; } @@ -818,7 +818,7 @@ void EnTrt_IdleAwake(EnTrt* this, GlobalContext* globalCtx) { } else { this->textId = 0x850; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -869,7 +869,7 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { this->blinkFunc = EnTrt_OpenEyesThenSetToBlink; this->timer = 10; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KOTAKE_SURPRISED2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_SURPRISED2); } } else { this->blinkFunc = EnTrt_OpenEyesThenSetToBlink; @@ -923,7 +923,7 @@ void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx) { EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 4); this->animationIdx = 4; this->blinkFunc = EnTrt_OpenEyes2; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KOTAKE_SURPRISED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_SURPRISED); this->timer = 30; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; } @@ -937,7 +937,7 @@ void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); this->blinkFunc = EnTrt_Blink; if (talkState == 6 && func_80147624(globalCtx)) { @@ -958,7 +958,7 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt } void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { if (this->textId == 0x83C) { if (func_80114E90()) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { @@ -999,7 +999,7 @@ void EnTrt_ItemGiven(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { switch (this->textId) { case 0x889: this->textId = 0x88A; @@ -1020,21 +1020,21 @@ void EnTrt_ItemGiven(EnTrt* this, GlobalContext* globalCtx) { } func_80151938(globalCtx, this->textId); } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); } } void EnTrt_SetupEndInteraction(EnTrt* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { EnTrt_EndInteraction(globalCtx, this); } } void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, this->textId, &this->actor); } else { if ((player->actor.world.pos.x >= -50.0f && player->actor.world.pos.x <= 50.0f) && @@ -1055,7 +1055,7 @@ void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_CannotBuy(EnTrt* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, EnTrt_GetItemTextId(this)); } @@ -1064,7 +1064,7 @@ void EnTrt_CannotBuy(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_CanBuy(EnTrt* this, GlobalContext* globalCtx) { EnGirlA* item; - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1079,12 +1079,12 @@ void EnTrt_BuyItemWithFanfare(EnTrt* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = EnTrt_SetupItemGiven; } else { - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); } } void EnTrt_SetupItemGiven(EnTrt* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { this->actionFunc = EnTrt_ItemGiven; if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -1093,12 +1093,12 @@ void EnTrt_SetupItemGiven(EnTrt* this, GlobalContext* globalCtx) { this->cutscene = this->lookToShopkeeperCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); } - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); } } void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); EnGirlA* item; @@ -1116,7 +1116,7 @@ void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { player->stateFlags2 |= 0x20000000; func_801518B0(globalCtx, this->textId, &this->actor); EnTrt_SetupStartShopping(globalCtx, this, true); - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); break; case 1: default: @@ -1368,9 +1368,9 @@ void EnTrt_OpenEyesThenSetToBlink(EnTrt* this) { } void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); - s32 itemActionParam; + s32 itemGiven; if (talkState == 5) { if (func_80147624(globalCtx)) { @@ -1381,16 +1381,16 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { } } } else if (talkState == 16) { - itemActionParam = func_80123810(globalCtx); - if (itemActionParam > PLAYER_AP_NONE) { - if (itemActionParam == PLAYER_AP_BOTTLE_MUSHROOM) { + itemGiven = func_80123810(globalCtx); + if (itemGiven > EXCH_ITEM_NONE) { + if (itemGiven == EXCH_ITEM_1E) { if (gSaveContext.weekEventReg[0x35] & 8) { player->actor.textId = 0x888; } else { player->actor.textId = 0x883; } this->textId = player->actor.textId; - player->unk_A87 = itemActionParam; + player->exchangeItemId = itemGiven; this->actionFunc = EnTrt_GetMushroom; } else { if (this->flags & ENTRT_GIVEN_MUSHROOM) { @@ -1402,7 +1402,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { this->actionFunc = EnTrt_Goodbye; } func_801477B4(globalCtx); - } else if (itemActionParam < PLAYER_AP_NONE) { + } else if (itemGiven < EXCH_ITEM_NONE) { if (this->flags & ENTRT_GIVEN_MUSHROOM) { this->textId = 0x88B; } else { @@ -1466,7 +1466,7 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { EnTrt_GetCutscenes(this, globalCtx); this->cutscene = this->lookForwardCutscene; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); EnTrt_InitShopkeeper(this, globalCtx); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; @@ -1690,7 +1690,7 @@ void EnTrt_Update(Actor* thisx, GlobalContext* globalCtx) { EnTrt_UpdateCursorAnim(this); EnTrt_UpdateHeadYawAndPitch(this, globalCtx); this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, 90.0f); + Actor_SetFocus(&this->actor, 90.0f); SkelAnime_Update(&this->skelAnime); EnTrt_UpdateCollider(this, globalCtx); } @@ -1712,11 +1712,11 @@ void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_UpdateHeadPosAndRot(s16 pitch, s16 yaw, Vec3f* pos, Vec3s* rot, s32 isFullyAwake) { Vec3f newPos; - Vec3f D_801D15B0tmp = D_801D15B0; + Vec3f zeroVec = gZeroVec3f; Vec3s newRot; MtxF currentState; - Matrix_MultiplyVector3fByState(&D_801D15B0tmp, &newPos); + Matrix_MultiplyVector3fByState(&zeroVec, &newPos); Matrix_CopyCurrentState(¤tState); func_8018219C(¤tState, &newRot, MTXMODE_NEW); *pos = newPos; 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 4874ac2496..74037ce2f7 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -130,7 +130,7 @@ void func_80A85620(EnTruUnkStruct* arg0, Vec3f* arg1, f32 arg2, f32 arg3, f32 ar arg0->unk_01 = arg0->unk_02; arg0->unk_00 = 1; arg0->unk_04 = *arg1; - arg0->unk_1C = D_801D15B0; + arg0->unk_1C = gZeroVec3f; arg0->unk_10 = D_80A8B250; arg0->unk_28 = arg2; arg0->unk_2C = arg3; @@ -190,8 +190,8 @@ void func_80A85AA4(EnTruUnkStruct* arg0, Vec3f* arg1, f32 arg2, f32 arg3, f32 ar arg0->unk_01 = arg0->unk_02; arg0->unk_00 = 2; arg0->unk_04 = *arg1; - arg0->unk_1C = D_801D15B0; - arg0->unk_10 = D_801D15B0; + arg0->unk_1C = gZeroVec3f; + arg0->unk_10 = gZeroVec3f; arg0->unk_28 = arg2; arg0->unk_2C = arg3; break; @@ -350,23 +350,23 @@ s32 func_80A86460(EnTru* this) { f32 temp_f6; s16 phi_s1; - Math_Vec3f_Copy(&spB0, &D_801D15B0); - Math_Vec3f_Copy(&sp8C, &D_801D15B0); - Math_Vec3f_Copy(&spA4, &D_801D15B0); - Math_Vec3f_Copy(&sp98, &D_801D15B0); + Math_Vec3f_Copy(&spB0, &gZeroVec3f); + Math_Vec3f_Copy(&sp8C, &gZeroVec3f); + Math_Vec3f_Copy(&spA4, &gZeroVec3f); + Math_Vec3f_Copy(&sp98, &gZeroVec3f); phi_s1 = (Rand_ZeroOne() * 360.0f) * 182.0f; spB0.z = 20.0f; Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.world.rot.y, &spB0, &sp8C); for (i = 0; i < 8; i++, phi_s1 += 0x1FFE) { - Math_Vec3f_Copy(&spB0, &D_801D15B0); + Math_Vec3f_Copy(&spB0, &gZeroVec3f); spB0.y = 1.0f; spB0.z = Rand_ZeroOne() + 3.0f; - Lib_Vec3f_TranslateAndRotateY(&D_801D15B0, phi_s1, &spB0, &sp98); - Math_Vec3f_Copy(&spB0, &D_801D15B0); + Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, phi_s1, &spB0, &sp98); + Math_Vec3f_Copy(&spB0, &gZeroVec3f); spB0.z = (Rand_ZeroOne() * 4.0f) + 12.0f; Lib_Vec3f_TranslateAndRotateY(&sp8C, phi_s1, &spB0, &spA4); - func_80A85E2C(this->unk_394, &spA4, &D_801D15B0, &sp98, 0.4f, 0.06f, 12.0f, 4); + func_80A85E2C(this->unk_394, &spA4, &gZeroVec3f, &sp98, 0.4f, 0.06f, 12.0f, 4); } return false; @@ -378,7 +378,7 @@ s32 func_80A86674(EnTru* this) { Vec3f sp34; Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.world.rot.y, &D_80A8B3D8, &sp40); - Lib_Vec3f_TranslateAndRotateY(&D_801D15B0, this->actor.world.rot.y, &D_80A8B3E4, &sp34); + Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, this->actor.world.rot.y, &D_80A8B3E4, &sp34); if (this->unk_390 == 1) { func_80A85E2C(this->unk_394, &sp40, &D_80A8B3F0, &sp34, 0.2f, 0.1f, 12.0f, 3); } else if (this->unk_390 == 2) { @@ -396,12 +396,12 @@ s32 func_80A86770(EnTru* this) { s16 phi_s0 = Rand_ZeroOne() * 360.0f * 182.0f; for (i = 0; i < 4; i++, phi_s0 += 0x3FFC) { - Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, phi_s0, &D_801D15B0, &sp98); + Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, phi_s0, &gZeroVec3f, &sp98); sp98.y = this->actor.floorHeight + 1.0f; sp8C.x = Rand_ZeroOne() - 0.5f; sp8C.z = Rand_ZeroOne() - 0.5f; sp8C.y = Rand_ZeroOne() * 0.2f; - func_80A85E2C(this->unk_394, &sp98, &sp8C, &D_801D15B0, 1.0f, 0.04f, 28.0f, 4); + func_80A85E2C(this->unk_394, &sp98, &sp8C, &gZeroVec3f, 1.0f, 0.04f, 28.0f, 4); } return false; @@ -661,16 +661,16 @@ s32 func_80A872AC(EnTru* this, GlobalContext* globalCtx) { s32 ret = false; if (this->unk_34E & 7) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (player->transformation == PLAYER_FORM_HUMAN) { this->unk_34E &= ~0x80; } this->unk_34E &= ~(0x4000 | 0x2000); - if ((player->unk_A87 == 35) || (player->unk_A87 == 36)) { + if ((player->exchangeItemId == 35) || (player->exchangeItemId == 36)) { this->unk_34E |= 0x2000; - this->unk_38C = player->unk_A87; - } else if (player->unk_A87 != 0) { + this->unk_38C = player->exchangeItemId; + } else if (player->exchangeItemId != 0) { this->unk_34E |= 0x4000; } @@ -730,7 +730,7 @@ s32 func_80A87400(EnTru* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.world.rot.y, phi_a1, 4, 3640); this->actor.shape.rot.y = this->actor.world.rot.y; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if ((s32)(this->actor.floorHeight + 80.0f) >= (s32)this->actor.world.pos.y) { func_80A86770(this); } @@ -801,7 +801,7 @@ s32 func_80A8777C(Actor* thisx, GlobalContext* globalCtx) { s32 temp_v0; s32 ret = 0; - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); switch (temp_v0) { default: @@ -894,9 +894,9 @@ s32 func_80A87880(Actor* thisx, GlobalContext* globalCtx) { this->unk_34E &= ~0x400; func_80123D50(globalCtx, player, 18, 21); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KOUME_DRINK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DRINK); } else if (Animation_OnFrame(&this->skelAnime, 90.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KOUME_REGAIN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_REGAIN); } if ((this->skelAnime.curFrame > 90.0f) && (this->skelAnime.curFrame < 95.0f)) { @@ -931,7 +931,7 @@ 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))); - Math_Vec3f_Copy(&sp4C, &D_801D15B0); + 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); @@ -940,7 +940,7 @@ s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) { this->unk_372 = 10; this->unk_364++; } else if (Animation_OnFrame(&this->skelAnime, 22.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KOUME_MAGIC); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_MAGIC); func_80A85AA4(this->unk_394, &this->unk_1F8, 1.0f, 0.1f, 40.0f); } break; @@ -952,8 +952,8 @@ s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.shadowDraw = NULL; this->unk_34E |= (0x200 | 0x8); this->unk_34E &= ~0x800; - if (player->unk_A87 != 0) { - player->unk_A87 = 0; + if (player->exchangeItemId != 0) { + player->exchangeItemId = 0; } func_80A86924(this, 12); } @@ -996,8 +996,8 @@ s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { case 2: func_801A75E8(NA_SE_EN_KOUME_MAGIC); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KOUME_AWAY); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KOUME_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_AWAY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_LAUGH); func_80A86924(this, 13); this->skelAnime.baseTransl.y = 0; this->skelAnime.moveFlags = 2; @@ -1111,7 +1111,7 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tru_Skel_01AA60, NULL, this->jointTable, this->morphTable, 27); Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c index 667f9a841c..05f4e76d73 100644 --- a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c @@ -5,6 +5,7 @@ */ #include "z_en_tubo_trap.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #define FLAGS 0x00000000 @@ -63,7 +64,7 @@ void EnTuboTrap_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.shape.rot.z = 0; this->actor.world.rot.z = 0; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 1.8f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 1.8f); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actionFunc = EnTuboTrap_Idle; @@ -174,7 +175,7 @@ void EnTuboTrap_HandleImpact(EnTuboTrap* this, GlobalContext* globalCtx) { if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 15.0f)) { EnTuboTrap_SpawnEffectsInWater(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_BOMB_DROP_WATER); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_BOMB_DROP_WATER); EnTuboTrap_DropCollectible(this, globalCtx); Actor_MarkForDeath(&this->actor); return; @@ -183,8 +184,8 @@ void EnTuboTrap_HandleImpact(EnTuboTrap* this, GlobalContext* globalCtx) { if (this->collider.base.atFlags & AT_BOUNCED) { this->collider.base.atFlags &= ~AT_BOUNCED; EnTuboTrap_SpawnEffectsOnLand(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_IT_SHIELD_REFLECT_SW); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_IT_SHIELD_REFLECT_SW); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); EnTuboTrap_DropCollectible(this, globalCtx); Actor_MarkForDeath(&this->actor); return; @@ -193,8 +194,8 @@ void EnTuboTrap_HandleImpact(EnTuboTrap* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; EnTuboTrap_SpawnEffectsOnLand(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_EXPLOSION); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_EXPLOSION); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); EnTuboTrap_DropCollectible(this, globalCtx); Actor_MarkForDeath(&this->actor); return; @@ -205,8 +206,8 @@ void EnTuboTrap_HandleImpact(EnTuboTrap* this, GlobalContext* globalCtx) { if (&player->actor == this->collider.base.at) { EnTuboTrap_SpawnEffectsOnLand(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); - Audio_PlaySoundAtPosition(globalCtx, &player2->actor.world.pos, 40, NA_SE_PL_BODY_HIT); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &player2->actor.world.pos, 40, NA_SE_PL_BODY_HIT); EnTuboTrap_DropCollectible(this, globalCtx); Actor_MarkForDeath(&this->actor); return; @@ -215,7 +216,7 @@ void EnTuboTrap_HandleImpact(EnTuboTrap* this, GlobalContext* globalCtx) { if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1)) { EnTuboTrap_SpawnEffectsOnLand(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); EnTuboTrap_DropCollectible(this, globalCtx); Actor_MarkForDeath(&this->actor); } @@ -245,7 +246,7 @@ void EnTuboTrap_Idle(EnTuboTrap* this, GlobalContext* globalCtx) { this->targetHeight += transformationHeight; } this->originPos = this->actor.world.pos; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_POT_MOVE_START); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POT_MOVE_START); this->actionFunc = EnTuboTrap_Levitate; } } @@ -272,7 +273,7 @@ void EnTuboTrap_FlyAtPlayer(EnTuboTrap* this, GlobalContext* globalCtx) { // But in MM, certain sfxIds got reordered and devs forgot to update: // In MM, NA_SE_EN_MIZUBABA2_ATTACK is the old value 0x3837 // In MM, NA_SE_EN_TUBOOCK_FLY is the new value 0x3AE0 - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MIZUBABA2_ATTACK - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MIZUBABA2_ATTACK - SFX_FLAG); if ((SQ(dX) + SQ(dY) + SQ(dZ) > SQ(240.0f))) { Math_ApproachF(&this->actor.gravity, -3.0f, 0.2f, 0.5f); @@ -287,17 +288,17 @@ void EnTuboTrap_Update(Actor* thisx, GlobalContext* globalCtx) { s32 padding; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f, 10.0f, 20.0f, 0x1F); - Actor_SetHeight(&this->actor, 0.0f); + Actor_SetFocus(&this->actor, 0.0f); if (this->actor.projectedPos.z < 811.0f) { if (this->actor.projectedPos.z > 300.0f) { this->actor.shape.shadowAlpha = (u8)((811 - (s32)this->actor.projectedPos.z) >> 1); - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; } else if (this->actor.projectedPos.z > -10.0f) { this->actor.shape.shadowAlpha = 255; - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; } else { this->actor.shape.shadowDraw = NULL; } @@ -311,6 +312,5 @@ void EnTuboTrap_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnTuboTrap_Draw(Actor* thisx, GlobalContext* globalCtx) { - // Gfx_DrawDListOpa with a display list - func_800BDFC0(globalCtx, D_05017EA0); + Gfx_DrawDListOpa(globalCtx, gameplay_dangeon_keep_DL_017EA0); } diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c index 2031127f7c..5959841904 100644 --- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c +++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c @@ -96,7 +96,7 @@ void func_80A66278(EnWarpUzu* this, GlobalContext* globalCtx) { do { player = GET_PLAYER(globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80A66384(this, globalCtx); } else { phi_a0 = ABS((s16)(Actor_YawBetweenActors(&this->actor, &player->actor) - this->actor.shape.rot.y)); @@ -133,5 +133,5 @@ void EnWarpUzu_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnWarpUzu_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000EC0); + Gfx_DrawDListOpa(globalCtx, D_06000EC0); } diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c index 236881f252..5e45f8c033 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c @@ -5,6 +5,8 @@ */ #include "z_en_water_effect.h" +#include "objects/object_water_effect/object_water_effect.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000035 @@ -15,7 +17,11 @@ void EnWaterEffect_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWaterEffect_Update(Actor* thisx, GlobalContext* globalCtx); void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2); +void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2); +void func_80A5A534(Actor* thisx, GlobalContext* globalCtx); +void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2); + const ActorInit En_Water_Effect_InitVars = { ACTOR_EN_WATER_EFFECT, ACTORCAT_BOSS, @@ -28,30 +34,672 @@ const ActorInit En_Water_Effect_InitVars = { (ActorFunc)EnWaterEffect_Draw, }; -#endif +static Vec3f D_80A5AFB0 = { 0.0f, 0.0f, 0.0f }; +static Vec3f D_80A5AFBC = { 0.0f, -1.0f, 0.0f }; -extern UNK_TYPE D_06000DE0; -extern UNK_TYPE D_060042B0; -extern UNK_TYPE D_060043E8; +void func_80A587A0(EnWaterEffect* this, Vec3f* arg1, u8 arg2) { + s16 i; + EnWaterEffectStruct* ptr = &this->unk_144[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/func_80A587A0.s") + for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { + if (!ptr->unk_00) { + ptr->unk_00 = true; + ptr->unk_04 = *arg1; + ptr->unk_10 = D_80A5AFB0; + ptr->unk_1C = D_80A5AFB0; + ptr->unk_2C.x = 0.1f; + ptr->unk_2C.y = 0.0f; + ptr->unk_2C.z = Rand_ZeroFloat(M_PI * 2); + ptr->unk_01 = Rand_ZeroFloat(100.0f); + ptr->unk_2A = arg2; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/func_80A58908.s") +void func_80A58908(EnWaterEffect* this, Vec3f* arg1, Vec3f* arg2, u8 arg3) { + Vec3f sp2C = D_80A5AFBC; + EnWaterEffectStruct* ptr = &this->unk_144[0]; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/EnWaterEffect_Init.s") + for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 2; + ptr->unk_04 = *arg1; + ptr->unk_10 = *arg2; + ptr->unk_1C = sp2C; + ptr->unk_2C.y = Rand_ZeroFloat(0.02f) + 0.02f; + ptr->unk_2C.x = ptr->unk_2C.y; + ptr->unk_2C.z = Rand_ZeroFloat(M_PI * 2); + ptr->unk_01 = Rand_ZeroFloat(100.0f); + ptr->unk_2A = arg3; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/EnWaterEffect_Destroy.s") +void EnWaterEffect_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWaterEffect* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/EnWaterEffect_Update.s") + this->actor.flags &= ~1; + this->unk_DC4 = Rand_ZeroFloat(100.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/EnWaterEffect_Draw.s") + if (this->actor.params == ENWATEREFFECT_1) { + this->actor.update = func_80A59C04; + this->actor.draw = func_80A5A184; + this->unk_DC6 = Rand_ZeroFloat(100.0f) + 60.0f; + } else if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_778) || + (this->actor.params == ENWATEREFFECT_779) || (this->actor.params == ENWATEREFFECT_780)) { + this->actor.update = func_80A5A534; + this->actor.draw = func_80A5A6B8; + this->actor.shape.rot.y = Rand_ZeroFloat(0x10000); + Actor_SetScale(&this->actor, this->actor.shape.rot.z * 0.0002f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/func_80A599E8.s") + if (this->actor.params == ENWATEREFFECT_777) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, this->actor.shape.rot.z, 0x30A); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, this->actor.shape.rot.z, 0x30B); + } else if (this->actor.params == ENWATEREFFECT_778) { + this->unk_DC4 = -3; + } else if (this->actor.params == ENWATEREFFECT_779) { + this->unk_DC4 = -6; + } else if (this->actor.params == ENWATEREFFECT_780) { + this->unk_DC4 = 23; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/func_80A59C04.s") + this->unk_E08[1] = 0.2f; + this->unk_E18[1] = -0.017f; + this->unk_E08[2] = 0.2f; + this->unk_E18[2] = -0.018f; + this->unk_E08[3] = 0.2f; + this->unk_E18[3] = -0.019f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/func_80A5A184.s") + this->unk_DC8[1].y = 1.0f; + this->unk_DC8[2].y = 1.0f; + this->unk_DC8[3].y = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/func_80A5A534.s") + this->unk_E2C = 255.0f; + this->unk_E34 = 255.0f; + this->unk_E30 = 200.0f; + this->unk_E38 = 191.25f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/func_80A5A6B8.s") +void EnWaterEffect_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnWaterEffect_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWaterEffect* this = THIS; + Player* player = GET_PLAYER(globalCtx); + EnWaterEffectStruct* ptr = &this->unk_144[0]; + s16 i; + s16 j; + s32 phi_v0; + Vec3f spA4; + Vec3f sp98; + u8 phi_v1; + Vec3f sp88; + + if (!Flags_GetSwitch(globalCtx, this->actor.params)) { + this->unk_DC4++; + if ((this->unk_DC4 % 32) == 0) { + if (Rand_ZeroOne() < 0.5f) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 10.0f, 40.0f, 4); + sp88.x = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.x; + sp88.y = this->actor.world.pos.y; + sp88.z = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.z; + if ((this->actor.world.pos.y + this->actor.depthInWater) <= this->actor.floorHeight) { + phi_v1 = 0; + } else { + phi_v1 = 1; + this->actor.floorHeight = this->actor.world.pos.y + this->actor.depthInWater; + } + func_80A587A0(this, &sp88, phi_v1); + } + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { + if (ptr->unk_00 != 0) { + ptr->unk_01++; + + ptr->unk_04.x += ptr->unk_10.x; + ptr->unk_04.y += ptr->unk_10.y; + ptr->unk_04.z += ptr->unk_10.z; + ptr->unk_10.y += ptr->unk_1C.y; + + Math_ApproachF(&ptr->unk_38, (ptr->unk_01 & 6) ? 80.0f : 200.0f, 1.0f, 80); + + if (ptr->unk_00 == 1) { + ptr->unk_2C.z += 0.15f; + Math_ApproachF(&ptr->unk_2C.x, 0.03f, 0.5f, 0.005f); + Math_ApproachF(&ptr->unk_2C.y, 0.5f, 0.5f, 0.02f); + + if (ptr->unk_2C.y > 0.15f) { + ptr->unk_1C.y = -1.0f; + if (ptr->unk_10.y < -20.0f) { + ptr->unk_10.y = -20.0f; + } + } + + if ((fabsf(ptr->unk_04.x - player->actor.world.pos.x) < 15.0f) && + (fabsf(ptr->unk_04.z - player->actor.world.pos.z) < 15.0f) && + (player->actor.world.pos.y < ptr->unk_04.y) && + ((ptr->unk_04.y - player->actor.world.pos.y) < 40.0f)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if ((ptr->unk_04.y <= this->actor.floorHeight) || phi_v0) { + + if (phi_v0) { + ptr->unk_00 = 0; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &ptr->unk_04, 30, NA_SE_EV_BOMB_DROP_WATER); + } else { + ptr->unk_04.y = this->actor.floorHeight; + if (ptr->unk_2A == 0) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &ptr->unk_04, 30, NA_SE_EV_WATERDROP_GRD); + ptr->unk_00 = 3; + ptr->unk_2C.x = 0.1f; + ptr->unk_2C.y = 0.6f; + ptr->unk_10 = D_80A5AFB0; + ptr->unk_1C = D_80A5AFB0; + ptr->unk_3C = 200; + ptr->unk_28 = 9; + Math_Vec3f_Copy(&sp98, &ptr->unk_04); + sp98.y += 3.0f; + EffectSsGSplash_Spawn(globalCtx, &sp98, NULL, NULL, 1, 100); + } else { + ptr->unk_00 = 0; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &ptr->unk_04, 30, NA_SE_EV_WATERDROP); + EffectSsGRipple_Spawn(globalCtx, &ptr->unk_04, 70, 500, 0); + EffectSsGRipple_Spawn(globalCtx, &ptr->unk_04, 70, 500, 10); + Math_Vec3f_Copy(&sp98, &ptr->unk_04); + sp98.y += 10.0f; + EffectSsGSplash_Spawn(globalCtx, &sp98, NULL, NULL, 1, 300); + } + } + + for (j = 0; j < 12; j++) { + Matrix_InsertYRotation_f((2.0f * (j * M_PI)) / 5.5f, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(1.5f) + 1.5f, &spA4); + spA4.y = Rand_ZeroFloat(4.0f) + 2.0f; + func_80A58908(this, &ptr->unk_04, &spA4, ptr->unk_2A); + } + } + } else if (ptr->unk_00 == 2) { + ptr->unk_2C.z += 0.15f; + if (ptr->unk_10.y < -8.0f) { + ptr->unk_10.y = -8.0f; + } + + if (ptr->unk_10.y < 0.0f) { + if (ptr->unk_04.y <= this->actor.floorHeight) { + ptr->unk_04.y = this->actor.floorHeight; + if (ptr->unk_2A == 0) { + ptr->unk_00 = 3; + ptr->unk_2C.x = 0.05f; + ptr->unk_2C.y = 0.2f; + ptr->unk_10 = D_80A5AFB0; + ptr->unk_1C = D_80A5AFB0; + ptr->unk_3C = 150; + ptr->unk_28 = Rand_ZeroFloat(5.0f) + 7.0f; + } else { + EffectSsGRipple_Spawn(globalCtx, &ptr->unk_04, 0, 200, 0); + ptr->unk_00 = 0; + } + } + } + } else if (ptr->unk_00 == 3) { + Math_ApproachF(&ptr->unk_2C.x, ptr->unk_2C.y, 0.1f, 0.6f); + ptr->unk_3C -= ptr->unk_28; + if (ptr->unk_3C <= 0) { + ptr->unk_3C = 0; + ptr->unk_00 = 0; + } + } + } + } +} + +void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + EnWaterEffect* this = THIS; + s32 pad; + EnWaterEffectStruct* backupPtr = &this->unk_144[0]; + EnWaterEffectStruct* ptr = backupPtr; + u8 phi_s4 = false; + s16 i; + + OPEN_DISPS(gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { + if ((ptr->unk_00 == 1) || (ptr->unk_00 == 2)) { + if (!phi_s4) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_08DBE0)); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); + phi_s4++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, 150); + + Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + + if (ptr->unk_00 == 1) { + Matrix_RotateY(func_800DFC68(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + } else { + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + } + + Matrix_Scale(ptr->unk_2C.x, ptr->unk_2C.y, 1.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042B0); + } + } + + phi_s4 = false; + ptr = backupPtr; + + for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { + if (ptr->unk_00 == 3) { + if (!phi_s4) { + func_8012C448(gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_08DBE0)); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); + phi_s4++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, + ptr->unk_3C); + + Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_2C.x, 1.0f, ptr->unk_2C.x, MTXMODE_APPLY); + Matrix_InsertYRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042F8); + } + } + + CLOSE_DISPS(gfxCtx); +} + +void func_80A599E8(EnWaterEffect* this, Vec3f* arg1, u8 arg2) { + s16 i; + EnWaterEffectStruct* ptr = &this->unk_144[0]; + + for (i = 0; i < ARRAY_COUNT(this->unk_144); i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 4; + ptr->unk_04 = *arg1; + + ptr->unk_1C = D_80A5AFB0; + ptr->unk_10 = D_80A5AFB0; + + if ((arg2 == 0) || (arg2 == 2)) { + ptr->unk_1C.y = -1.0f; + } + + if (arg2 >= 2) { + if (arg2 == 2) { + ptr->unk_10.x = randPlusMinusPoint5Scaled(10.0f); + ptr->unk_10.y = Rand_ZeroFloat(3.0f) + 5.0f; + ptr->unk_10.z = randPlusMinusPoint5Scaled(10.0f); + } + ptr->unk_2C.z = 0.0017f; + ptr->unk_2C.x = 0.003f; + ptr->unk_2C.y = 0.0018f; + } else { + ptr->unk_2C.z = 0.003f; + ptr->unk_2C.x = 0.003f; + ptr->unk_2C.y = 0.003f; + } + ptr->unk_38 = 255.0f; + ptr->unk_28 = Rand_ZeroFloat(0x10000); + ptr->unk_3C = 255; + ptr->unk_01 = Rand_ZeroFloat(200.0f); + ptr->unk_2A = arg2; + break; + } + } +} + +void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWaterEffect* this = THIS; + s16 i; + s16 j; + f32 temp_f0_2; + Player* player = GET_PLAYER(globalCtx); + Vec3f sp90; + Actor* rotaryRoom = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; + CollisionPoly* sp88; + EnWaterEffectStruct* ptr = &this->unk_144[0]; + u8 phi_s5; + Vec3f sp74; + + while (rotaryRoom != NULL) { + if (rotaryRoom->id == ACTOR_BG_IKANA_ROTARYROOM) { + break; + } + rotaryRoom = rotaryRoom->next; + } + + if (this->unk_DC6 != 0) { + this->unk_DC6--; + } + + if ((rotaryRoom != NULL) && Flags_GetSwitch(globalCtx, (rotaryRoom->params >> 1) & 0x7F)) { + this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; + } else if (!func_801690CC(globalCtx)) { + this->unk_DC4++; + if (this->unk_DC6 == 0) { + this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 10.0f, 40.0f, 4); + sp74.x = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.x; + sp74.y = this->actor.world.pos.y; + sp74.z = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.z; + func_80A599E8(this, &sp74, 0); + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_144); i++, ptr++) { + phi_s5 = false; + + if (ptr->unk_00 != 0) { + ptr->unk_01++; + + ptr->unk_04.x += ptr->unk_10.x; + ptr->unk_04.y += ptr->unk_10.y; + ptr->unk_04.z += ptr->unk_10.z; + ptr->unk_10.y = ptr->unk_10.y + ptr->unk_1C.y; + + if (ptr->unk_00 == 4) { + if (ptr->unk_2A > 0) { + if (ptr->unk_2A == 1) { + Math_ApproachF(&ptr->unk_2C.x, 0.001f, 0.5f, 0.0002f); + } + + if (ptr->unk_2A & 1) { + Math_ApproachZeroF(&ptr->unk_38, 1.0f, 30.0f); + if (ptr->unk_2A == 1) { + ptr->unk_3C -= 20; + } else { + ptr->unk_3C -= 10; + } + if (ptr->unk_3C <= 0) { + ptr->unk_00 = 0; + } + Math_ApproachZeroF(&ptr->unk_10.x, 1.0f, 1.0f); + Math_ApproachZeroF(&ptr->unk_10.z, 1.0f, 1.0f); + } + } + + if ((ptr->unk_2A % 2) == 0) { + if (ptr->unk_2A == 0) { + func_80A599E8(this, &ptr->unk_04, 1); + } else if ((ptr->unk_01 & 1) == 0) { + func_80A599E8(this, &ptr->unk_04, 3); + } + + if (ptr->unk_10.y < -20.0f) { + ptr->unk_10.y = -20.0f; + } + + ptr->unk_28 += 0x800; + if ((fabsf(ptr->unk_04.x - player->actor.world.pos.x) < 20.0f) && + (fabsf(ptr->unk_04.z - player->actor.world.pos.z) < 20.0f) && + (fabsf(ptr->unk_04.y - (player->actor.world.pos.y + 25.0f)) < 30.0f)) { + phi_s5 = true; + if ((player->transformation != PLAYER_FORM_GORON) && !player->isBurning) { + func_800B8D50(globalCtx, &this->actor, 2.0f, Rand_ZeroFloat(0x10000), 0.0f, 0x10); + for (j = 0; j < ARRAY_COUNT(player->flameTimers); j++) { + player->flameTimers[j] = Rand_S16Offset(0, 200); + } + player->isBurning = true; + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DEMO_DAMAGE); + } + } + + Math_Vec3f_Copy(&sp90, &ptr->unk_04); + sp90.y += 30.0f; + + temp_f0_2 = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp88, &sp90); + if (fabsf(temp_f0_2 - this->actor.floorHeight) > 200.0f) { + phi_s5 = true; + } + + if ((ptr->unk_04.y <= temp_f0_2) || (phi_s5 != 0)) { + if (phi_s5 == 0) { + ptr->unk_04.y = temp_f0_2; + } + ptr->unk_10.y = 0.0f; + ptr->unk_1C.y = 0.0f; + if (ptr->unk_2A == 0) { + for (j = 0; j < 5; j++) { + func_80A599E8(this, &ptr->unk_04, 2); + } + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &ptr->unk_04, 30, NA_SE_EV_PLANT_BROKEN); + } + ptr->unk_2A++; + } + } + } + } + } +} + +void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWaterEffect* this = THIS; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + EnWaterEffectStruct* ptr = &this->unk_144[0]; + u8 flag = false; + s16 i; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_144); i++, ptr++) { + if (ptr->unk_00 == 4) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004340); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 500, 3600); + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, (u8)ptr->unk_38, 0, 0, (u8)ptr->unk_3C); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (ptr->unk_01 * -20) & 0x1FF, + 0x20, 0x80)); + + Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + + if (ptr->unk_2A >= 2) { + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + } else { + Matrix_RotateY(func_800DFC68(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + } + + Matrix_Scale(ptr->unk_2C.x, ptr->unk_2C.y, 1.0f, MTXMODE_APPLY); + + if ((i & 1) != 0) { + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0043E8); + + if ((ptr->unk_2A & 1) == 0) { + Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y + 5.0f, ptr->unk_04.z, MTXMODE_NEW); + Matrix_InsertXRotation_s(ptr->unk_28, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_2C.z, ptr->unk_2C.z, ptr->unk_2C.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06AB30); + } + } + } + + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + + CLOSE_DISPS(gfxCtx); +} + +void func_80A5A534(Actor* thisx, GlobalContext* globalCtx) { + EnWaterEffect* this = THIS; + s32 i; + + if (this->unk_E38 < 1.0f) { + Actor_MarkForDeath(&this->actor); + } + + this->unk_DC4++; + + if (this->unk_DC4 >= 0) { + for (i = 1; i < 4; i++) { + this->unk_DC8[i].z += this->unk_E08[i]; + this->unk_E08[i] += this->unk_E18[i]; + if (this->unk_DC8[i].z <= 0.0f) { + this->unk_DC8[i].z = 0.0f; + this->unk_E08[i] = 0.0f; + } + } + + Math_ApproachF(&this->unk_DC8[1].y, 20.0f, 1.0f, 0.025f); + Math_ApproachF(&this->unk_DC8[2].y, 20.0f, 1.0f, 0.075f); + Math_ApproachF(&this->unk_DC8[3].y, 20.0f, 1.0f, 0.1f); + + if (this->unk_DC4 >= 24) { + Math_ApproachF(&this->unk_DC8[4].y, 2.0f, 0.1f, 0.2f); + Math_ApproachZeroF(&this->unk_E2C, 1.0f, 26.0f); + Math_ApproachZeroF(&this->unk_E30, 1.0f, 26.0f); + Math_ApproachZeroF(&this->unk_E34, 1.0f, 24.0f); + if (this->unk_DC4 >= 50) { + Math_ApproachZeroF(&this->unk_E38, 1.0f, 3.75f); + } + } + } +} + +void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWaterEffect* this = THIS; + EnWaterEffectStruct* ptr = &this->unk_144[0]; + u8 phi_s4 = false; + s16 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_XLU_DISP++, 165, 235, 255, 128); + + Matrix_StatePush(); + Matrix_StatePush(); + Matrix_StatePush(); + + if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_778)) { + if (this->unk_E2C > 1.0f) { + func_8012C2DC(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_water_effect_Matanimheader_000DE0)); + Matrix_Scale(this->unk_DC8[1].y, this->unk_DC8[1].z, this->unk_DC8[1].y, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E2C); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000420); + } + + Matrix_StatePop(); + + if (this->unk_E30 > 1.0f) { + func_8012C2DC(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_water_effect_Matanimheader_000E0C)); + Matrix_Scale(this->unk_DC8[2].y, this->unk_DC8[2].z, this->unk_DC8[2].y, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E30); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000730); + } + Matrix_StatePop(); + } else { + Matrix_StatePop(); + Matrix_StatePop(); + } + + if ((this->unk_E34 > 1.0f) && (this->actor.params != ENWATEREFFECT_780)) { + func_8012C2DC(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_water_effect_Matanimheader_000E40)); + Matrix_Scale(this->unk_DC8[3].y, this->unk_DC8[3].z, this->unk_DC8[3].y, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E34); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000A48); + } + + Matrix_StatePop(); + + if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_780)) { + func_8012C2DC(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_water_effect_Matanimheader_000E58)); + Matrix_Scale(this->unk_DC8[4].y, this->unk_DC8[4].z, this->unk_DC8[4].y, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E38); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000CD8); + } + + if (this->actor.params == ENWATEREFFECT_777) { + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { + if (ptr->unk_00 == 3) { + if (!phi_s4) { + func_8012C448(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_08DBE0)); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); + phi_s4++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, + ptr->unk_3C); + + Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_2C.x, 1.0f, ptr->unk_2C.x, MTXMODE_APPLY); + Matrix_InsertYRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042F8); + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h index f7805ddca8..774b858cda 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h @@ -5,9 +5,41 @@ struct EnWaterEffect; +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; + /* 0x04 */ Vec3f unk_04; + /* 0x10 */ Vec3f unk_10; + /* 0x1C */ Vec3f unk_1C; + /* 0x28 */ s16 unk_28; + /* 0x2A */ u8 unk_2A; + /* 0x2C */ Vec3f unk_2C; + /* 0x38 */ f32 unk_38; + /* 0x3C */ s16 unk_3C; +} EnWaterEffectStruct; // size = 0x40 + +enum { + /* 0x 1 */ ENWATEREFFECT_1 = 1, + /* 0x309 */ ENWATEREFFECT_777 = 777, + /* 0x30A */ ENWATEREFFECT_778, + /* 0x30B */ ENWATEREFFECT_779, + /* 0x30C */ ENWATEREFFECT_780, +}; + typedef struct EnWaterEffect { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xCF8]; + /* 0x144 */ EnWaterEffectStruct unk_144[50]; + /* 0xDC4 */ s16 unk_DC4; + /* 0xDC6 */ s16 unk_DC6; + /* 0xDC8 */ Vec3f unk_DC8[5]; + /* 0xE04 */ UNK_TYPE1 unk_E04[4]; + /* 0xE04 */ f32 unk_E08[4]; + /* 0xE18 */ f32 unk_E18[4]; + /* 0xE28 */ UNK_TYPE1 unk_E28[4]; + /* 0xE2C */ f32 unk_E2C; + /* 0xE30 */ f32 unk_E30; + /* 0xE34 */ f32 unk_E34; + /* 0xE38 */ f32 unk_E38; } EnWaterEffect; // size = 0xE3C extern const ActorInit En_Water_Effect_InitVars; diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c index fac66b679a..a453e23e77 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -283,7 +283,7 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { s32 temp_s0; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 70.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 70.0f); this->actor.shape.shadowAlpha = 150; Collider_InitAndSetJntSph(globalCtx, &this->collider1, &this->actor, &sJntSphInit, this->collider1Elements); Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit1); @@ -325,7 +325,7 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if (Actor_GetRoomCleared(globalCtx, this->actor.room)) { + if (Flags_GetClear(globalCtx, this->actor.room)) { Actor_MarkForDeath(&this->actor); return; } @@ -384,7 +384,7 @@ void func_809907D4(EnWf* this) { this->collider3.base.colType = COLTYPE_HIT3; this->unk_2A0 = 80; this->actor.flags &= ~0x400; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); } void func_80990854(EnWf* this, GlobalContext* globalCtx) { @@ -393,7 +393,7 @@ void func_80990854(EnWf* this, GlobalContext* globalCtx) { this->collider2.base.colType = COLTYPE_HIT5; this->collider3.base.colType = COLTYPE_HIT5; this->unk_2AC = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->unk_2B8, 10, 2, 0.3f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2B8, 10, 2, 0.3f, 0.2f); this->actor.flags |= 0x400; } } @@ -463,13 +463,13 @@ s32 func_80990948(GlobalContext* globalCtx, EnWf* this, s16 arg2) { } if (arg2 != 0) { - if (!Actor_IsActorFacingLink(&this->actor, 7000)) { + if (!Actor_IsFacingPlayer(&this->actor, 7000)) { func_80992A74(this, globalCtx); return true; } sp2E = player->actor.shape.rot.y - this->actor.shape.rot.y; - if ((this->actor.xzDistToPlayer <= 80.0f) && !func_800BC5EC(globalCtx, &this->actor)) { + if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &this->actor)) { if (((globalCtx->gameplayFrames % 8) != 0) || (ABS_ALT(sp2E) < 0x38E0)) { func_80991C04(this); return true; @@ -508,7 +508,7 @@ void func_80990C6C(EnWf* this, GlobalContext* globalCtx, s32 arg2) { sp88.x = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.x; sp88.y = Rand_ZeroFloat(5.0f) + this->actor.world.pos.y; sp88.z = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.z; - func_800B0F18(globalCtx, &sp88, &D_801D15B0, &D_809942DC, phi_s1, phi_s1, phi_s6, 5, + func_800B0F18(globalCtx, &sp88, &gZeroVec3f, &D_809942DC, phi_s1, phi_s1, phi_s6, 5, Rand_ZeroFloat(5.0f) + 14.0f); } } @@ -518,7 +518,7 @@ void func_80990C6C(EnWf* this, GlobalContext* globalCtx, s32 arg2) { void func_80990E4C(EnWf* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 1.0f) && (this->actor.bgCheckFlags & 1)) { func_80990C6C(this, globalCtx, 2); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_WALK); } } @@ -534,7 +534,7 @@ s32 func_80990EAC(EnWf* this) { void func_80990ED4(EnWf* this) { this->actor.child = NULL; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); func_80991438(this); } @@ -578,7 +578,7 @@ void func_80991040(EnWf* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.shape.shadowScale, 70.0f, 14.0f); this->unk_2A0--; if (this->unk_2A0 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); } } else if (SkelAnime_Update(&this->skelAnime)) { this->actor.scale.y = this->actor.scale.x; @@ -639,7 +639,7 @@ void func_80991280(EnWf* this, GlobalContext* globalCtx) { } else { this->unk_2A0--; if (this->unk_2A0 == 0) { - if (Actor_IsActorFacingLink(&this->actor, 0x1555)) { + if (Actor_IsFacingPlayer(&this->actor, 0x1555)) { if (Rand_ZeroOne() > 0.3f) { func_80991438(this); } else { @@ -650,7 +650,7 @@ void func_80991280(EnWf* this, GlobalContext* globalCtx) { } if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } } } @@ -674,7 +674,7 @@ void func_8099149C(EnWf* this, GlobalContext* globalCtx) { if (!func_8099408C(globalCtx, this)) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 500); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_800BC5EC(globalCtx, &this->actor)) { + if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { sp2C = 150.0f; } else { sp2C = 0.0f; @@ -693,17 +693,17 @@ void func_8099149C(EnWf* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (!func_80990948(globalCtx, this, 0)) { - if (!Actor_IsActorFacingLink(&this->actor, 0x11C7)) { + if (!Actor_IsFacingPlayer(&this->actor, 0x11C7)) { if (Rand_ZeroOne() > 0.5f) { func_80991948(this); } else { func_80991200(this); } } else if (this->actor.xzDistToPlayer < (90.0f + sp2C)) { - if (!func_800BC5EC(globalCtx, &this->actor) && + if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && ((Rand_ZeroOne() > 0.03f) || ((this->actor.xzDistToPlayer <= 80.0f) && (sp28 < 0x38E0)))) { func_80991C04(this); - } else if (func_800BC5EC(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { + } else if (Actor_OtherIsTargeted(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { func_8099223C(this); } else { func_80991948(this); @@ -711,7 +711,7 @@ void func_8099149C(EnWf* this, GlobalContext* globalCtx) { } if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } func_80990E4C(this, globalCtx); @@ -757,7 +757,7 @@ void func_8099177C(EnWf* this, GlobalContext* globalCtx) { this->skelAnime.playSpeed = -phi_f2; SkelAnime_Update(&this->skelAnime); - if (Actor_IsActorFacingLink(&this->actor, 0x1555)) { + if (Actor_IsFacingPlayer(&this->actor, 0x1555)) { if (Rand_ZeroOne() > 0.8f) { func_80991948(this); } else { @@ -765,7 +765,7 @@ void func_8099177C(EnWf* this, GlobalContext* globalCtx) { } } if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } } } @@ -804,16 +804,16 @@ void func_809919F4(EnWf* this, GlobalContext* globalCtx) { func_80990E4C(this, globalCtx); if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } - if ((Math_CosS(sp26 - this->actor.shape.rot.y) < -0.85f) && !func_800BC5EC(globalCtx, &this->actor) && + if ((Math_CosS(sp26 - this->actor.shape.rot.y) < -0.85f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && (this->actor.xzDistToPlayer <= 80.0f)) { func_80991C04(this); } else { this->unk_2A0--; if (this->unk_2A0 == 0) { - if (func_800BC5EC(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { + if (Actor_OtherIsTargeted(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { func_8099223C(this); } else { func_80991200(this); @@ -848,7 +848,7 @@ void func_80991C80(EnWf* this, GlobalContext* globalCtx) { if (((this->skelAnime.curFrame >= 9.0f) && (this->skelAnime.curFrame < 13.0f)) || ((this->skelAnime.curFrame >= 17.0f) && (this->skelAnime.curFrame < 20.0f))) { if (!(this->collider1.base.atFlags & AT_ON)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_ATTACK); } this->collider1.base.atFlags |= AT_ON; } else { @@ -856,14 +856,14 @@ void func_80991C80(EnWf* this, GlobalContext* globalCtx) { } sp2C = Animation_OnFrame(&this->skelAnime, 15.0f); - if (((sp2C != 0) && !func_800BC5B8(globalCtx, &this->actor) && - (!Actor_IsActorFacingLink(&this->actor, 0x2000) || (this->actor.xzDistToPlayer >= 100.0f))) || + if (((sp2C != 0) && !Actor_IsTargeted(globalCtx, &this->actor) && + (!Actor_IsFacingPlayer(&this->actor, 0x2000) || (this->actor.xzDistToPlayer >= 100.0f))) || SkelAnime_Update(&this->skelAnime)) { if ((sp2C == 0) && (this->unk_2A0 != 0)) { this->actor.shape.rot.y += (s16)(0xCCC * (1.5f + ((this->unk_2A0 - 4) * 0.4f))); func_80990C6C(this, globalCtx, 1); this->unk_2A0--; - } else if (!Actor_IsActorFacingLink(&this->actor, 0x1554) && (sp2C == 0)) { + } else if (!Actor_IsFacingPlayer(&this->actor, 0x1554) && (sp2C == 0)) { func_80991200(this); this->unk_2A0 = (s32)Rand_ZeroFloat(5.0f) + 5; if (sp30 >= 0x32C9) { @@ -910,7 +910,7 @@ void func_80992068(EnWf* this, GlobalContext* globalCtx) { sp28 = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)); if (SkelAnime_Update(&this->skelAnime)) { - if (!Actor_IsActorFacingLink(&this->actor, 0x1554)) { + if (!Actor_IsFacingPlayer(&this->actor, 0x1554)) { func_80991200(this); this->unk_2A0 = (s32)Rand_ZeroFloat(5.0f) + 5; if (sp28 > 0x32C8) { @@ -944,13 +944,13 @@ void func_8099223C(EnWf* this) { this->actor.speedXZ = -6.0f; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); this->actionFunc = func_809922B4; } void func_809922B4(EnWf* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { - if (!func_800BC5EC(globalCtx, &this->actor) && (this->actor.xzDistToPlayer < 170.0f) && + if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && (this->actor.xzDistToPlayer < 170.0f) && (this->actor.xzDistToPlayer > 140.0f) && (Rand_ZeroOne() < 0.2f)) { func_80991438(this); } else if ((globalCtx->gameplayFrames % 2) != 0) { @@ -960,7 +960,7 @@ void func_809922B4(EnWf* this, GlobalContext* globalCtx) { } } if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } } @@ -995,7 +995,7 @@ void func_8099245C(EnWf* this) { } this->unk_298 = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_DAMAGE); this->actionFunc = func_809924EC; } @@ -1021,7 +1021,7 @@ void func_809924EC(EnWf* this, GlobalContext* globalCtx) { if ((this->actor.bgCheckFlags & 8) && (ABS_ALT(sp26) < 0x2EE0) && (this->actor.xzDistToPlayer < 120.0f)) { func_809926D0(this); } else if (!func_8099408C(globalCtx, this)) { - if ((this->actor.xzDistToPlayer <= 80.0f) && !func_800BC5EC(globalCtx, &this->actor) && + if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && ((globalCtx->gameplayFrames % 8) != 0)) { func_80991C04(this); } else if (Rand_ZeroOne() > 0.5f) { @@ -1041,7 +1041,7 @@ void func_809926D0(EnWf* this) { this->unk_2A0 = 0; this->actor.speedXZ = 6.5f; this->actor.velocity.y = 15.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_80992784; } @@ -1055,7 +1055,7 @@ void func_80992784(EnWf* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; this->actor.speedXZ = 0.0f; this->actor.world.pos.y = this->actor.floorHeight; - if (!func_800BC5EC(globalCtx, &this->actor)) { + if (!Actor_OtherIsTargeted(globalCtx, &this->actor)) { func_80991C04(this); } else { func_80991200(this); @@ -1085,10 +1085,10 @@ void func_809928CC(EnWf* this, GlobalContext* globalCtx) { } else { func_8099223C(this); } - } else if (Actor_IsActorFacingLink(&this->actor, 0x4000) && (this->actor.xzDistToPlayer < 60.0f) && + } else if (Actor_IsFacingPlayer(&this->actor, 0x4000) && (this->actor.xzDistToPlayer < 60.0f) && (fabsf(this->actor.playerHeightRel) < 50.0f)) { sp2A = player->actor.shape.rot.y - this->actor.shape.rot.y; - if (!func_800BC5EC(globalCtx, &this->actor) && + if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && (((globalCtx->gameplayFrames % 2) != 0) || (ABS_ALT(sp2A) < 0x38E0))) { func_80991C04(this); } else { @@ -1148,7 +1148,7 @@ void func_80992B8C(EnWf* this, GlobalContext* globalCtx) { this->unk_2A0 = (s32)Rand_ZeroFloat(3.0f) + 1; } else { this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->actor.xzDistToPlayer <= 80.0f) && !func_800BC5EC(globalCtx, &this->actor) && + if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && (((globalCtx->gameplayFrames % 4) == 0) || (sp28 < 0x38E0))) { func_80991C04(this); } else { @@ -1160,7 +1160,7 @@ void func_80992B8C(EnWf* this, GlobalContext* globalCtx) { func_80990E4C(this, globalCtx); if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } } } @@ -1174,7 +1174,7 @@ void func_80992D6C(EnWf* this) { } this->actor.flags &= ~1; this->unk_2A0 = 25; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_DEAD); this->actionFunc = func_80992E0C; } @@ -1201,7 +1201,8 @@ void func_80992E0C(EnWf* this, GlobalContext* globalCtx) { Vec3f sp60; if (this->unk_2A0 == 25) { - func_800F0590(globalCtx, &this->actor.world.pos, 36, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + SoundSource_PlaySfxEachFrameAtFixedWorldPos(globalCtx, &this->actor.world.pos, 36, + NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); } this->unk_2A0--; @@ -1285,13 +1286,13 @@ void func_80993194(EnWf* this, GlobalContext* globalCtx) { } if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } } void func_80993350(EnWf* this) { Animation_MorphToLoop(&this->skelAnime, &D_06005700, -4.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); this->actionFunc = func_809933A0; } @@ -1325,7 +1326,7 @@ void func_809933A0(EnWf* this, GlobalContext* globalCtx) { func_80990ED4(this); } if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } } @@ -1378,7 +1379,7 @@ void func_8099357C(EnWf* this, GlobalContext* globalCtx) { } if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } } @@ -1407,15 +1408,15 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { if ((this->collider2.base.acFlags & AC_HIT) || (this->collider3.base.acFlags & AC_HIT)) { if ((!(this->collider2.base.acFlags & AC_HIT) && (this->collider3.base.acFlags & AC_HIT)) || - !Actor_IsActorFacingLink(&this->actor, 0x4A38)) { + !Actor_IsFacingPlayer(&this->actor, 0x4A38)) { this->actor.colChkInfo.damage *= 4; } if (this->collider2.base.acFlags & AC_HIT) { - func_800BE258(&this->actor, &this->collider2.info); + Actor_SetDropFlag(&this->actor, &this->collider2.info); collider = &this->collider2; } else { - func_800BE258(&this->actor, &this->collider3.info); + Actor_SetDropFlag(&this->actor, &this->collider3.info); collider = &this->collider3; } @@ -1435,16 +1436,16 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 1) { this->unk_2A0 = 40; - func_800BCB70(&this->actor, 0, 0x78, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_809923B0(this); } else if (this->actor.colChkInfo.damageEffect == 5) { this->unk_2A0 = 40; - func_800BCB70(&this->actor, 0, 0xFF, 0, 40); + Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); this->unk_296 = 30; this->unk_2B0 = 0.75f; this->unk_2AC = 2.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_809923B0(this); } else if (this->actor.colChkInfo.damageEffect == 3) { func_809907D4(this); @@ -1467,7 +1468,7 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { CLEAR_TAG_LARGE_LIGHT_RAYS); } - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); if (this->actor.colChkInfo.health == 0) { func_80992D6C(this); } else { @@ -1495,7 +1496,7 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 32.0f, 30.0f, 60.0f, 0x1D); func_80993738(this, globalCtx); @@ -1528,7 +1529,7 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_SetHeight(&this->actor, 25.0f); + Actor_SetFocus(&this->actor, 25.0f); if (this->unk_2AC > 0.0f) { if (this->unk_296 != 10) { diff --git a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h index 822ceadd9a..1388260cf4 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h @@ -11,7 +11,13 @@ typedef struct EnWiz { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x268]; /* 0x03AC */ EnWizActionFunc actionFunc; - /* 0x03B0 */ char unk_3B0[0x9D0]; + /* 0x03B0 */ char unk_3B0[0xA]; + /* 0x03BA */ s16 unk_3BA; + /* 0x03BC */ char unk_3BC[0x8C]; + /* 0x0448 */ s32 unk_448; + /* 0x044C */ char unk_44C[0x2FE]; + /* 0x074A */ s16 unk_74A; + /* 0x074C */ char unk_74C[0x634]; } EnWiz; // size = 0xD80 extern const ActorInit En_Wiz_InitVars; diff --git a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c index 480bdaeaa4..0bdbf86794 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c @@ -5,6 +5,8 @@ */ #include "z_en_wiz_fire.h" +#include "overlays/actors/ovl_En_Wiz/z_en_wiz.h" +#include "objects/object_wiz/object_wiz.h" #define FLAGS 0x08000015 @@ -21,8 +23,13 @@ void func_80A49F38(EnWizFire* this, GlobalContext* globalCtx); void func_80A49FD8(EnWizFire* this, GlobalContext* globalCtx); void func_80A4A11C(EnWizFire* this, GlobalContext* globalCtx); void func_80A4A608(EnWizFire* this, GlobalContext* globalCtx); +void func_80A4BAB4(Actor* thisx, GlobalContext* globalCtx); +void func_80A4BC74(EnWizFire* this, Vec3f* arg1, Vec3f* arg2); +void func_80A4BDDC(EnWizFire* this, GlobalContext* globalCtx); +void func_80A4BF78(EnWizFire* this, GlobalContext* globalCtx); + +static s32 D_80A4C1C0 = 0; -#if 0 const ActorInit En_Wiz_Fire_InitVars = { ACTOR_EN_WIZ_FIRE, ACTORCAT_ENEMY, @@ -35,51 +42,838 @@ const ActorInit En_Wiz_Fire_InitVars = { (ActorFunc)EnWizFire_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A4C1E4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x09, 0x10 }, { 0x01001202, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x09, 0x10 }, + { 0x01001202, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 0, 0, 0, { 0, 0, 0 } }, }; -#endif +void EnWizFire_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWizFire* this = THIS; -extern ColliderCylinderInit D_80A4C1E4; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->unk_162 = this->actor.params; + this->actor.targetMode = 3; + this->unk_172 = 10; + this->unk_1FC = 255.0f; + this->actor.flags &= ~1; -extern UNK_TYPE D_06000FD8; -extern UNK_TYPE D_06002630; -extern UNK_TYPE D_06002B40; -extern UNK_TYPE D_06003120; -extern UNK_TYPE D_06005190; + if (!func_8012405C(globalCtx)) { + this->collider.info.toucher.dmgFlags = 0x20000000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/EnWizFire_Init.s") + switch (this->unk_162) { + case 4: + this->unk_166 = 1; + this->collider.info.toucher.damage = 8; + this->collider.info.toucher.effect = 2; + this->collider.info.bumper.dmgFlags = (0x1000000 | 0x800 | 0x200 | 0x2); + this->unk_162 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/EnWizFire_Destroy.s") + case 0: + if (this->unk_162 == 4) { + this->unk_162 = 0; + this->collider.info.toucher.damage = 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4984C.s") + case 1: + case 3: + this->actionFunc = func_80A4984C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A49A44.s") + case 2: + this->actor.draw = func_80A4BAB4; + this->unk_170 = Rand_S16Offset(0, 10000); + this->unk_160 = 1; + this->collider.info.toucher.damage = 2; + this->actionFunc = func_80A49F38; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A49F38.s") +void EnWizFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWizFire* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A49FD8.s") + if (this->unk_162 == 0) { + globalCtx->envCtx.unk_8C.fogColor[2] = 0; + globalCtx->envCtx.unk_8C.fogColor[1] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.fogColor[0] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.diffuseColor2[2] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.diffuseColor2[1] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.diffuseColor2[0] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.diffuseColor1[2] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.diffuseColor1[1] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.diffuseColor1[0] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.ambientColor[2] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.ambientColor[1] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.ambientColor[0] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.fogNear = globalCtx->envCtx.unk_8C.fogColor[2]; + } + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4A11C.s") +void func_80A4984C(EnWizFire* this, GlobalContext* globalCtx) { + Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4A608.s") + for (i = 0; i < ARRAY_COUNT(this->unk_178); i++) { + this->unk_178[i] = this->actor.world.pos; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/EnWizFire_Update.s") + this->unk_16E = 0; + Matrix_StatePush(); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4B0C8.s") + if (this->unk_162 != 0) { + sp44.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; + } else { + sp44.z = 12.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4B33C.s") + Matrix_MultiplyVector3fByState(&sp44, &this->actor.velocity); + Matrix_StatePop(); + this->actor.world.rot.x = this->actor.world.rot.y = this->actor.world.rot.z = 0; + this->unk_168 = 50; + if (this->unk_162 != 0) { + this->actor.velocity.y = 10.0f; + this->actor.gravity = -1.0f; + this->unk_150 = 0.01f; + } else { + this->unk_150 = 0.02f; + this->unk_168 = 100; + } + this->unk_160 = 0; + this->actionFunc = func_80A49A44; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/EnWizFire_Draw.s") +void func_80A49A44(EnWizFire* this, GlobalContext* globalCtx) { + Vec3f sp54 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4BAB4.s") + this->actor.world.rot.z += 5000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4BC74.s") + if (this->unk_162 != 0) { + this->unk_150 = 0.01f; + } else { + this->unk_150 = 0.02f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4BDDC.s") + if ((this->unk_168 == 0) && (this->unk_14C < 0.001f)) { + Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); + this->unk_160 = 3; + this->unk_16A = 0; + this->actionFunc = func_80A4A608; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4BF78.s") + if (this->unk_168 == 0) { + this->unk_150 = 0.0f; + } + + Math_ApproachF(&this->unk_14C, this->unk_150, 0.2f, 0.01f); + + if (this->unk_172 == 0) { + if ((this->actor.bgCheckFlags & 8) && (this->unk_162 == 0) && (this->unk_168 != 0) && + (this->actor.bgCheckFlags & 8)) { + D_80A4C1C0 = 0; + this->unk_168 = 0; + this->unk_150 = 0.0f; + } + } + + if ((this->actor.bgCheckFlags & 1) && (this->unk_16A == 0)) { + s32 i; + s16 phi_s0; + s32 temp; + + if (this->unk_162 == 1) { + this->unk_16A = 10; + + Matrix_StatePush(); + Matrix_RotateY((s16)randPlusMinusPoint5Scaled(0x100) + this->actor.world.rot.y, MTXMODE_NEW); + sp54.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; + Matrix_MultiplyVector3fByState(&sp54, &this->actor.velocity); + Matrix_StatePop(); + + this->actor.velocity.y = 6.0f; + this->actor.gravity = -0.7f; + + if (this->unk_164 == 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WIZ_FIRE, this->actor.world.pos.x, + this->actor.world.pos.y - 10.0f, this->actor.world.pos.z, 0, 0, 0, 2); + this->unk_164 = 1; + } + + this->unk_168 = 0; + this->unk_14C = 0.0f; + Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); + this->unk_160 = 3; + this->unk_16A = 0; + this->actionFunc = func_80A4A608; + return; + } + + if ((this->unk_162 == 0) && (this->unk_168 != 0)) { + if (this->actor.floorBgId == BGCHECK_SCENE) { + this->unk_16A = 100; + if (this->unk_166 == 0) { + phi_s0 = 0; + + for (i = 0; i < 5; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WIZ_FIRE, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, phi_s0, 0, 1); + phi_s0 += BINANG_ADD((s32)randPlusMinusPoint5Scaled(0x1000), 0x3333); + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + this->unk_16A = Rand_S16Offset(70, 30); + if (this->unk_16A != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_EXP - SFX_FLAG); + } + } else if (this->unk_16A != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); + this->unk_168 = 0; + this->unk_160 = 2; + this->unk_14C = 0.0f; + this->actionFunc = func_80A4A11C; + } + return; + } + } + + if ((this->unk_162 != 3) && (this->unk_168 != 0)) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000) { + this->unk_168 = 0; + this->unk_148 = 1; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); + } + } + + if (func_8012405C(globalCtx) && (this->collider.base.atFlags & AT_BOUNCED)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SHIELD_REFLECT_MG); + this->collider.base.atFlags &= ~(AT_TYPE_ENEMY | AT_BOUNCED | AT_HIT); + this->collider.base.atFlags |= AT_TYPE_PLAYER; + this->collider.info.toucher.dmgFlags = 0x20; + this->collider.info.toucher.damage = 2; + this->unk_168 = 100; + this->unk_162 = 3; + this->actor.velocity.x *= -1.0f; + this->actor.velocity.y *= -0.5f; + this->actor.velocity.z *= -1.0f; + + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && + (this->actor.parent->update != NULL)) { + ((EnWiz*)this->actor.parent)->unk_3BA = 0; + } + } + } +} + +void func_80A49F38(EnWizFire* this, GlobalContext* globalCtx) { + this->unk_150 = 0.02f; + this->unk_168 = Rand_S16Offset(50, 50); + this->unk_154 = randPlusMinusPoint5Scaled(1.0f) * 0.007f; + this->unk_158 = randPlusMinusPoint5Scaled(1.0f) * 0.005f; + this->unk_15C = randPlusMinusPoint5Scaled(1.0f) * 0.007f; + this->actionFunc = func_80A49FD8; +} + +void func_80A49FD8(EnWizFire* this, GlobalContext* globalCtx) { + if (this->unk_168 > 10) { + Math_ApproachF(&this->unk_14C, this->unk_150, 0.3f, 0.01f); + } else { + Math_ApproachF(&this->unk_14C, 2.0f * this->unk_150, 0.2f, 0.002f); + Math_ApproachZeroF(&this->unk_1FC, 1.0f, 35.0f); + if ((this->unk_168 == 0) && (this->unk_1FC < 2.0f)) { + Actor_MarkForDeath(&this->actor); + } + return; + } + + if (this->collider.base.acFlags & AC_HIT) { + if (this->unk_168 != 0) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->unk_168 > 10) { + this->unk_168 -= 10; + } + + if (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000) { + this->unk_168 = 0; + this->unk_148 = 1; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); + } + } + } + + if (this->unk_168 != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); + } +} + +void func_80A4A11C(EnWizFire* this, GlobalContext* globalCtx) { + s32 pad; + + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && + (this->actor.parent->update != NULL) && (this->actor.parent->colChkInfo.health == 0)) { + this->unk_16A = 0; + this->unk_174 = 1; + } + + this->unk_16E++; + + if (this->unk_16E > 10) { + this->unk_16E = 10; + } + + if (this->unk_16A != 0) { + Math_ApproachF(&this->unk_200, 60.0f, 0.5f, 10.0f); + if (this->unk_166 == 1) { + Vec3f sp40 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp34; + + sp40.x = randPlusMinusPoint5Scaled(3.0f) / 10.0f; + sp40.y = 0.23f; + sp40.z = randPlusMinusPoint5Scaled(3.0f) / 10.0f; + + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp34.x += randPlusMinusPoint5Scaled(150.0f); + sp34.z += randPlusMinusPoint5Scaled(150.0f); + + Math_ApproachF(&this->unk_1F0, 0.022f, 0.3f, 0.01f); + this->collider.dim.radius = this->unk_1F0 * 4300.0f; + this->collider.dim.height = 30; + this->collider.dim.yShift = 15; + func_80A4BC74(this, &sp34, &sp40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + return; + } + + Math_ApproachF(&this->unk_1F0, 0.02f, 0.3f, 0.002f); + Math_ApproachF(&this->unk_1F8, 0.02f, 0.3f, 0.002f); + Math_ApproachF(&this->unk_1F4, 0.02f, 0.3f, 0.2f); + this->collider.dim.radius = this->unk_1F0 * 4000.0f; + this->collider.dim.height = this->unk_1F4 * 1850.0f; + this->collider.dim.yShift = -15; + + if (this->collider.dim.height < 2) { + this->collider.dim.height = 2; + } + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + if ((D_80A4C1C0 == 0) && (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000)) { + D_80A4C1C0 = 1; + this->unk_148 = 1; + this->unk_16A = 0; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); + } + } + this->actor.world.pos.y = this->actor.floorHeight + 10.0f; + Actor_SetFocus(&this->actor, 0.0f); + return; + } + + Math_ApproachZeroF(&this->unk_200, 0.2f, 3.0f); + + if (this->unk_166 == 1) { + Math_ApproachZeroF(&this->unk_1F0, 0.046f, 0.001f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + + if (this->unk_164 == 0) { + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->unk_1F0 < 0.05f)) { + EnWiz* wiz = (EnWiz*)this->actor.parent; + + this->collider.dim.yShift = -15; + this->unk_164 = 1; + wiz->unk_3BA = 0; + } + } + + if ((this->unk_164 != 0) && (this->unk_1F0 < 0.05f)) { + Math_ApproachZeroF(&this->unk_1FC, 1.0f, 5.0f); + } + + if ((this->unk_1F0 < 0.001f) && (this->unk_204 < 0.001f)) { + D_80A4C1C0 = 0; + Actor_MarkForDeath(&this->actor); + } + return; + } + + Math_ApproachZeroF(&this->unk_1F4, 0.1f, 0.01f); + + if (this->unk_1F4 < 0.01f) { + Math_ApproachZeroF(&this->unk_1FC, 1.0f, 10.0f); + if ((this->unk_1FC < 10.0f) && (this->unk_204 < 0.001f)) { + D_80A4C1C0 = 0; + if ((this->actor.parent != NULL) && (this->unk_162 == 0) && (this->actor.parent->id == ACTOR_EN_WIZ) && + (this->actor.parent->update != NULL)) { + EnWiz* wiz = (EnWiz*)this->actor.parent; + + wiz->unk_3BA = 0; + } + Actor_MarkForDeath(&this->actor); + } + } +} + +void func_80A4A608(EnWizFire* this, GlobalContext* globalCtx) { + if (this->unk_16A == 0) { + this->unk_16A = 2; + this->unk_16E++; + if (this->unk_16E >= 6) { + if ((this->actor.parent != NULL) && (this->unk_162 == 0) && (this->actor.parent->id == ACTOR_EN_WIZ)) { + EnWiz* wiz = (EnWiz*)this->actor.parent; + + D_80A4C1C0 = 0; + if (wiz->actor.update != NULL) { + wiz->unk_3BA = 0; + } + } + Actor_MarkForDeath(&this->actor); + } + } +} + +void EnWizFire_Update(Actor* thisx, GlobalContext* globalCtx2) { + static Color_RGB8 D_80A4C234[] = { + { 100, 40, 40 }, { 180, 0x78, 80 }, { 155, 80, 80 }, { 125, 20, 0 }, + { 0, 0, 0 }, { 200, 250, 250 }, { 100, 250, 250 }, { 225, 255, 235 }, + }; + static Color_RGBA8 D_80A4C24C = { 250, 250, 250, 255 }; + static Color_RGBA8 D_80A4C250 = { 180, 180, 180, 255 }; + GlobalContext* globalCtx = globalCtx2; + EnWizFire* this = THIS; + Player* player = GET_PLAYER(globalCtx); + s32 j; + s16 temp_s0; + s16 idx; + + Actor_SetScale(&this->actor, this->unk_14C); + func_80A4BDDC(this, globalCtx); + this->unk_204 = this->unk_200 / 60.0f; + + if (this->unk_162 == 0) { + Actor* wiz = this->actor.parent; + + if ((wiz != NULL) && (wiz->id == ACTOR_EN_WIZ) && (wiz->update != NULL) && (((EnWiz*)wiz)->unk_74A != 2)) { + f32 phi_f0; + + idx = this->unk_166 * 4; + + phi_f0 = 970.0f; + if (this->unk_166 == 0) { + phi_f0 = 968.0f; + } + + globalCtx->envCtx.unk_8C.fogNear = (phi_f0 - (s16)globalCtx->envCtx.unk_C4.fogNear) * this->unk_204; + + globalCtx->envCtx.unk_8C.ambientColor[0] = + ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.ambientColor[0]) * this->unk_204; + globalCtx->envCtx.unk_8C.ambientColor[1] = + ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.ambientColor[1]) * this->unk_204; + globalCtx->envCtx.unk_8C.ambientColor[2] = + ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.ambientColor[2]) * this->unk_204; + + idx++; + globalCtx->envCtx.unk_8C.diffuseColor1[0] = + ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.diffuseColor1[0]) * this->unk_204; + globalCtx->envCtx.unk_8C.diffuseColor1[1] = + ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.diffuseColor1[1]) * this->unk_204; + globalCtx->envCtx.unk_8C.diffuseColor1[2] = + ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.diffuseColor1[2]) * this->unk_204; + + idx++; + globalCtx->envCtx.unk_8C.diffuseColor2[0] = + ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.diffuseColor[0]) * this->unk_204; + globalCtx->envCtx.unk_8C.diffuseColor2[1] = + ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.diffuseColor[1]) * this->unk_204; + globalCtx->envCtx.unk_8C.diffuseColor2[2] = + ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.diffuseColor[2]) * this->unk_204; + + idx++; + globalCtx->envCtx.unk_8C.fogColor[0] = + ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.fogColor[0]) * this->unk_204; + globalCtx->envCtx.unk_8C.fogColor[1] = + ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.fogColor[1]) * this->unk_204; + globalCtx->envCtx.unk_8C.fogColor[2] = + ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.fogColor[2]) * this->unk_204; + } + } + + this->unk_170++; + + this->actionFunc(this, globalCtx); + + this->actor.shape.yOffset = 10.0f; + Actor_UpdatePos(&this->actor); + + this->unk_178[0] = this->actor.world.pos; + + for (j = 8; j >= 0; j--) { + this->unk_178[j + 1] = this->unk_178[j]; + } + + this->actor.velocity.y += this->actor.gravity; + + if (this->unk_172 != 0) { + this->unk_172--; + } + + if (this->unk_168 != 0) { + this->unk_168--; + } + + if (this->unk_16C != 0) { + this->unk_16C--; + } + + if (this->unk_16A != 0) { + this->unk_16A--; + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 5.0f, 10, 0x1D); + + if (((this->unk_148 != 0) || (D_80A4C1C0 != 0)) && (this->unk_16C == 0)) { + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + f32 sp54; + s32 i; + + sp70.x = 0.0f; + sp70.y = 1.0f; + sp70.z = 0.0f; + sp64.x = 0.0f; + sp64.y = 1.0f; + sp64.z = 0.0f; + + sp54 = Rand_S16Offset(20, 10); + if (this->unk_162 == 0) { + sp54 = Rand_S16Offset(40, 20); + } + + this->unk_16C = Rand_S16Offset(2, 2); + + for (i = 0; i < 2; i++) { + temp_s0 = Rand_S16Offset(20, 20); + sp58.x = ((f32)((Rand_ZeroOne() < 0.5f) ? -1 : 1) * temp_s0) + this->actor.world.pos.x; + sp58.y = (Rand_ZeroOne() * 20.0f) + this->actor.floorHeight; + temp_s0 = Rand_S16Offset(20, 20); + sp58.z = ((f32)((Rand_ZeroOne() < .5f) ? -1 : 1) * temp_s0) + this->actor.world.pos.z; + func_800B0DE0(globalCtx, &sp58, &sp64, &sp70, &D_80A4C24C, &D_80A4C250, Rand_S16Offset(350, 100), sp54); + } + } + + if (this->unk_160 < 2) { + this->collider.dim.radius = (this->unk_14C * 15.0f) + 25.0f; + this->collider.dim.height = (this->unk_14C * 15.0f) + 25.0f; + this->collider.dim.yShift = (this->unk_14C * -0.75f) - 5.0f; + } + + if (this->unk_162 == 2) { + this->collider.dim.radius = 10; + this->collider.dim.height = this->unk_14C * 5000.0f; + this->collider.dim.yShift = 0; + } + + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + if (this->unk_162 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_LAUGH2); + if (player->invincibilityTimer > 0) { + player->invincibilityTimer += 40; + if (this->unk_166 != 0) { + player->invincibilityTimer += 50; + this->unk_174 = 1; + } + } + } + } + + if ((player->stateFlags2 & 0x4000) && (player->unk_AE8 < 90)) { + player->unk_AE8 = 90; + } + + if ((this->unk_148 == 0) && (D_80A4C1C0 == 0) && ((this->unk_162 != 0) || (this->unk_1FC > 200.0f))) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (player->invincibilityTimer == 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void func_80A4B0C8(EnWizFire* this, GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->unk_162 == 0) && (this->unk_160 == 2)) { + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_Scale(this->unk_1F0, this->unk_1F0, this->unk_1F0, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)this->unk_1FC); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 40, 30, 80); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_005190); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 215, 215, 215, (s8)this->unk_1FC); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -globalCtx->state.frames & 0x7F, + -globalCtx->state.frames & 0x7F, 0x20, 0x40, 1, globalCtx->state.frames & 0xFF, + globalCtx->state.frames & 0xFF, 0x10, 0x10)); + + Matrix_RotateY(0, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_005750); + } + + func_80A4BF78(this, globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->unk_162 == 0) && (this->unk_160 == 2)) { + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_StatePush(); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_Scale(this->unk_1F0, this->unk_1F0, this->unk_1F0, MTXMODE_APPLY); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -globalCtx->state.frames % 128, 0, 0x20, 0x20, 1, + (globalCtx->state.frames * 2) % 128, 0, 0x20, 0x20)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 40, 0, (s8)this->unk_1FC); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 245, 255, 128); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003120); + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->state.frames % 128, + (-globalCtx->state.frames * 6) % 256, 0x20, 0x40, 1, + (globalCtx->state.frames * 2) % 128, (-globalCtx->state.frames * 6) % 256, 0x20, + 0x40)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 80, 0, 0, (s8)this->unk_1FC); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 100); + + Matrix_Scale(this->unk_1F8, this->unk_1F8, this->unk_1F8, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003640); + + Matrix_StatePop(); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, 0); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (-globalCtx->state.frames * 3) % 128, 0, 0x20, 0x20, 1, + 0, (-globalCtx->state.frames * 10) % 256, 0x20, 0x40)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 50, 0, 255); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 240, 128); + + Matrix_Scale(this->unk_1F4, this->unk_1F4, this->unk_1F4, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003FC0); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnWizFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWizFire* this = THIS; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_StatePush(); + + for (i = 9; i >= this->unk_16E; i--) { + f32 temp_f20 = this->actor.scale.x - (i * -0.0019f); + + if (temp_f20 > 0.0f) { + if (this->unk_166 == 0) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255 - (i * 25), 0, 255 - (i * 25)); + gDPSetEnvColor(POLY_XLU_DISP++, 255 - (i * 25), 0, 0, 0); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255 - (i * 7), 255 - (i * 3), 255 - (i * 3), 255 - (i * 25)); + gDPSetEnvColor(POLY_XLU_DISP++, 220, 255, 235, 0); + } + + Matrix_InsertTranslation(this->unk_178[i].x, this->unk_178[i].y + this->actor.shape.yOffset, + this->unk_178[i].z, MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_InsertZRotation_s(this->actor.world.rot.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002B40); + } + } + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_166 == 0) { + func_80A4B33C(this, globalCtx); + } else { + func_80A4B0C8(this, globalCtx); + } +} + +void func_80A4BAB4(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWizFire* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight + 20.0f, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_Scale(this->unk_14C + this->unk_154, this->unk_14C + this->unk_158, this->unk_14C + this->unk_15C, + MTXMODE_APPLY); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, this->unk_170 & 0x7F, + (-this->unk_170 * 10) & 0x7F, 0x20, 0x20)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 100, 50, 0, (s8)this->unk_1FC); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 245, 255); + + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002630); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A4BC74(EnWizFire* this, Vec3f* arg1, Vec3f* arg2) { + s16 i; + EnWizFireStruct* ptr = this->unk_254; + + for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 1; + Math_Vec3f_Copy(&ptr->unk_1C, &gZeroVec3f); + ptr->unk_01 = Rand_ZeroFloat(100.0f); + ptr->unk_10 = *arg1; + ptr->unk_28 = *arg2; + ptr->unk_0C = (Rand_ZeroFloat(5.0f) + 20.0f) * 0.001f; + ptr->unk_08 = 0; + ptr->unk_06 = 0; + break; + } + } +} + +void func_80A4BDDC(EnWizFire* this, GlobalContext* globalCtx) { + s32 i; + EnWizFireStruct* ptr = &this->unk_254[0]; + + for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { + if (ptr->unk_00 != 0) { + ptr->unk_01++; + + ptr->unk_10.x += ptr->unk_1C.x; + ptr->unk_10.y += ptr->unk_1C.y; + ptr->unk_10.z += ptr->unk_1C.z; + + ptr->unk_1C.x += ptr->unk_28.x; + ptr->unk_1C.y += ptr->unk_28.y; + ptr->unk_1C.z += ptr->unk_28.z; + + if (ptr->unk_08 == 0) { + ptr->unk_06 += 10; + if (ptr->unk_06 >= 100) { + ptr->unk_08 = 1; + } + } else { + ptr->unk_06 -= 8; + if (ptr->unk_06 <= 0) { + ptr->unk_06 = 0; + ptr->unk_00 = 0; + } + } + } + } +} + +void func_80A4BF78(EnWizFire* this, GlobalContext* globalCtx) { + s16 i; + u8 flag; + EnWizFireStruct* ptr = &this->unk_254[0]; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + flag = false; + for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { + if (ptr->unk_00 != 0) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_000E70); + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, ptr->unk_06); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_01 * 3) & 0x7F, + (ptr->unk_01 * 0xF) & 0xFF, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + + Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(ptr->unk_0C, ptr->unk_0C, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); + gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BACK | G_FOG); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_000FD8); + } + } + + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h index 0f5b705f5c..df396da97b 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h @@ -7,10 +7,48 @@ struct EnWizFire; typedef void (*EnWizFireActionFunc)(struct EnWizFire*, GlobalContext*); +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; + /* 0x02 */ UNK_TYPE1 unk02[0x4]; + /* 0x06 */ s16 unk_06; + /* 0x08 */ s16 unk_08; + /* 0x0A */ UNK_TYPE1 unk0A[0x2]; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ Vec3f unk_10; + /* 0x1C */ Vec3f unk_1C; + /* 0x28 */ Vec3f unk_28; +} EnWizFireStruct; // size = 0x34 + typedef struct EnWizFire { /* 0x0000 */ Actor actor; /* 0x0144 */ EnWizFireActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x29AC]; + /* 0x0148 */ u8 unk_148; + /* 0x014C */ f32 unk_14C; + /* 0x0150 */ f32 unk_150; + /* 0x0154 */ f32 unk_154; + /* 0x0158 */ f32 unk_158; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ s16 unk_160; + /* 0x0162 */ s16 unk_162; + /* 0x0164 */ u8 unk_164; + /* 0x0166 */ s16 unk_166; + /* 0x0168 */ s16 unk_168; + /* 0x016A */ s16 unk_16A; + /* 0x016C */ s16 unk_16C; + /* 0x016E */ s16 unk_16E; + /* 0x0170 */ s16 unk_170; + /* 0x0172 */ s16 unk_172; + /* 0x0174 */ s8 unk_174; + /* 0x0178 */ Vec3f unk_178[10]; + /* 0x01F0 */ f32 unk_1F0; + /* 0x01F4 */ f32 unk_1F4; + /* 0x01F8 */ f32 unk_1F8; + /* 0x01FC */ f32 unk_1FC; + /* 0x0200 */ f32 unk_200; + /* 0x0204 */ f32 unk_204; + /* 0x0208 */ ColliderCylinder collider; + /* 0x0254 */ EnWizFireStruct unk_254[200]; } EnWizFire; // size = 0x2AF4 extern const ActorInit En_Wiz_Fire_InitVars; diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index a4c63543c3..3306fc7866 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -5,6 +5,7 @@ */ #include "z_en_zog.h" +#include "objects/object_zog/object_zog.h" #define FLAGS 0x00000009 @@ -30,7 +31,8 @@ void func_80B94E34(EnZog* this, GlobalContext* globalCtx); void func_80B95128(EnZog* this, GlobalContext* globalCtx); void func_80B95240(EnZog* this, GlobalContext* globalCtx); -#if 0 +static u8 D_80B95E10; + const ActorInit En_Zog_InitVars = { ACTOR_EN_ZOG, ACTORCAT_NPC, @@ -43,78 +45,1041 @@ const ActorInit En_Zog_InitVars = { (ActorFunc)EnZog_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B95880 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_PLAYER, 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_PLAYER, + 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 TexturePtr D_80B958AC[] = { &object_zog_Tex_024750, &object_zog_Tex_024F50, &object_zog_Tex_025750 }; -extern ColliderCylinderInit D_80B95880; +static TexturePtr D_80B958B8[] = { &object_zog_Tex_025F50, &object_zog_Tex_026750 }; -extern UNK_TYPE D_0600FC0C; -extern UNK_TYPE D_060280A8; +static AnimationHeader* D_80B958C0[] = { + &object_zog_Anim_00FC0C, &object_zog_Anim_0106B0, &object_zog_Anim_0166F4, &object_zog_Anim_017170, + &object_zog_Anim_014B10, &object_zog_Anim_018600, &object_zog_Anim_01A06C, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B93310.s") +static AnimationHeader* D_80B958DC[] = { &object_zog_Anim_00CA94, &object_zog_Anim_00F110 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B93468.s") +static AnimationHeader* D_80B958E4[] = { &object_zog_Anim_01579C, &object_zog_Anim_015B80, &object_zog_Anim_00ECBC }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/EnZog_Init.s") +static AnimationHeader* D_80B958F0[] = { &object_zog_Anim_008EB8, &object_zog_Anim_0099A4 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/EnZog_Destroy.s") +static AnimationHeader* D_80B958F8[] = { &object_zog_Anim_00931C, &object_zog_Anim_009EC4, &object_zog_Anim_00B01C }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B939C0.s") +static AnimationHeader* D_80B95904[] = { + &object_zog_Anim_00BF38, &object_zog_Anim_01A990, &object_zog_Anim_01AD58, + &object_zog_Anim_01B72C, &object_zog_Anim_01BC88, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B93A48.s") +static AnimationHeader* D_80B95918 = &object_zog_Anim_001000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B93B44.s") +static AnimationHeader* D_80B9591C = &object_zog_Anim_001970; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B93BA8.s") +static AnimationHeader* D_80B95920 = &object_zog_Anim_002344; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B93BE0.s") +static AnimationHeader* D_80B95924 = &object_zog_Anim_002894; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B93D2C.s") +static AnimationHeader* D_80B95928 = &object_zog_Anim_0030E0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B93DE8.s") +static AnimationHeader* D_80B9592C = &object_zog_Anim_0037F8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B93EA0.s") +static AnimationHeader* D_80B95930 = &object_zog_Anim_0041D0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B943A0.s") +static AnimationHeader* D_80B95934 = &object_zog_Anim_004BDC; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B943C0.s") +static AnimationHeader* D_80B95938 = &object_zog_Anim_0055B4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B943EC.s") +static s16 D_80B9593C[] = { 0, 1, 2, 3 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B94470.s") +static s16 D_80B95944[] = { 4, 5 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B9451C.s") +static s16 D_80B95948[] = { 5, 6, 7, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B9461C.s") +static s16 D_80B95950[] = { 7, 8, 9, 10, 7, 11, 12, 13, 14, 15, 12, 13, 14, 15, 12, 16, 17, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B946B4.s") +static s16* D_80B95974[] = { D_80B9593C, D_80B95944, D_80B95948, D_80B95950 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B946FC.s") +static s16 D_80B95984[] = { 4, 2, 3, 17 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B948A8.s") +static Vec3f D_80B9598C = { 0.0f, -0.05f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B94A00.s") +static Vec3f D_80B95998 = { 0.0f, -0.025f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B94C5C.s") +static Color_RGBA8 D_80B959A4 = { 220, 220, 255, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B94D0C.s") +static Color_RGBA8 D_80B959A8 = { 80, 80, 220, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B94E34.s") +static Vec3f D_80B959AC = { 0.0f, 0.0f, 15.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B95128.s") +void func_80B93310(Actor* thisx, Lights* mapper, GlobalContext* globalCtx) { + Vec3f sp34; + EnZog* this = THIS; + f32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B95240.s") + if (this->unk_322 > 0) { + if (this->unk_30A & 8) { + this->actor.shape.shadowAlpha = this->unk_322; + } else { + this->actor.shape.shadowAlpha = 255; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/EnZog_Update.s") + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B954C4.s") + sp2C = sqrtf(SQ(this->actor.focus.pos.x - this->unk_2F0.x) + SQ(this->actor.focus.pos.z - this->unk_2F0.z)); + if (sp2C < 12.0f) { + sp2C = 12.0f; + } else if (sp2C > 60.0f) { + sp2C = 60.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/func_80B95598.s") + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_2F0); + func_800B4AEC(globalCtx, &this->actor, 50.0f); + if (sp34.y < this->actor.floorHeight) { + this->actor.world.pos.y = this->actor.floorHeight; + } else { + this->actor.world.pos.y = sp34.y; + } + this->actor.scale.z *= sp2C * (1 / 12.0f); + ActorShadow_DrawCircle(&this->actor, mapper, globalCtx); + this->actor.scale.z = this->actor.scale.x; + Math_Vec3f_Copy(&this->actor.world.pos, &sp34); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zog/EnZog_Draw.s") +void func_80B93468(EnZog* this, GlobalContext* globalCtx) { + Vec3s* points; + + this->unk_2E8 = &globalCtx->setupPathList[ENZOG_GET_FC00(&this->actor)]; + if (this->unk_2E8 != NULL) { + points = &((Vec3s*)Lib_SegmentedToVirtual(this->unk_2E8->points))[this->unk_2EC]; + points++; + + this->actor.world.pos.x = points[-1].x; + this->actor.world.pos.z = points[-1].z; + this->actor.world.rot.y = Math_Atan2S(points->x - this->actor.world.pos.x, points->z - this->actor.world.pos.z); + this->actor.speedXZ = 0.0f; + } +} + +void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZog* this = THIS; + s32 i; + s16 cs; + + if (!D_80B95E10) { + for (i = 0; i < ARRAY_COUNT(D_80B958AC); i++) { + D_80B958AC[i] = Lib_SegmentedToVirtual(D_80B958AC[i]); + } + + for (i = 0; i < ARRAY_COUNT(D_80B958B8); i++) { + D_80B958B8[i] = Lib_SegmentedToVirtual(D_80B958B8[i]); + } + + D_80B95E10 = true; + } + + ActorShape_Init(&this->actor.shape, 0.0f, func_80B93310, 24.0f); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80B95128; + this->actor.textId = 0x1004; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zog_Skel_029170, &object_zog_Anim_00FC0C, this->jointTable, + this->morphTable, 23); + Animation_PlayOnce(&this->skelAnime, &object_zog_Anim_00FC0C); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + 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->sceneNum != SCENE_30GYOSON))) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.terminalVelocity = -4.0f; + this->actor.gravity = -1.0f; + this->actor.uncullZoneScale = 3000.0f; + this->actor.shape.yOffset = 1000.0f; + this->unk_308 = 0; + this->unk_30A = 0; + this->unk_31C = 2; + this->unk_31E = 0; + this->unk_31A = -1; + this->unk_322 = 100; + + Math_Vec3f_Copy(&this->unk_2F0, &this->actor.world.pos); + + if (ENZOG_GET_F(&this->actor) == ENZOG_F_2) { + this->actionFunc = func_80B95240; + this->unk_322 = 255; + this->unk_31C = 0; + this->unk_31E = 0; + this->actor.shape.yOffset = 0.0f; + } + + this->unk_2EC = 0; + if (ENZOG_GET_FC00(&this->actor) != ENZOG_FC00_63) { + func_80B93468(this, globalCtx); + } else { + this->unk_2E8 = NULL; + } + + this->unk_2FC = 0; + this->unk_302 = 0; + this->unk_2EC++; + this->unk_304 = 0; + this->unk_2FE = this->unk_2FC; + this->unk_300 = this->unk_302; + cs = this->actor.cutscene; + + for (i = 0; i < ARRAY_COUNT(this->unk_30C); i++) { + this->unk_30C[i] = cs; + if (cs != -1) { + this->actor.cutscene = cs; + cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } + + this->actor.flags |= 0x10000; + this->actor.home.rot.z = 0; + if (ENZOG_GET_F(&this->actor) != ENZOG_F_2) { + for (i = 0; i < 5; i++) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON4, this->actor.world.pos.x, + this->actor.world.pos.y + 500.0f, this->actor.world.pos.z, 0, 0, 0, 100); + } + } + + if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (gSaveContext.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->unk_31C = 2; + this->unk_31E = 0; + + Animation_PlayLoop(&this->skelAnime, D_80B958DC[0]); + this->actor.textId = 0x1009; + if (gSaveContext.weekEventReg[91] & 2) { + this->actor.textId = 0x103C; + this->actionFunc = func_80B9451C; + } else { + this->actionFunc = func_80B948A8; + } + this->actor.shape.rot.y = 0x4000; + this->actor.world.rot.y = 0x4000; + this->actor.world.pos.x = -376.0f; + this->actor.world.pos.y = 80.0f; + this->actor.world.pos.z = 4793.0f; + this->actor.shape.yOffset = 0.0f; + } +} + +void EnZog_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZog* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void func_80B939C0(EnZog* this, s16 arg1, u8 arg2) { + Animation_Change(&this->skelAnime, D_80B958C0[arg1], 1.0f, 0.0f, Animation_GetLastFrame(D_80B958C0[arg1]), arg2, + -5.0f); + this->unk_304 = arg1; +} + +void func_80B93A48(EnZog* this, GlobalContext* globalCtx) { + s16* table; + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_302 != this->unk_300) { + this->unk_302++; + } else if (this->unk_302 == 0) { + if (this->unk_2FC != this->unk_2FE) { + this->unk_2FC = this->unk_2FE; + } + } + + if (this->unk_302 >= D_80B95984[this->unk_2FC]) { + this->unk_302 = 0; + this->unk_300 = 0; + if (this->unk_2FC != this->unk_2FE) { + this->unk_2FC = this->unk_2FE; + } + } + + table = D_80B95974[this->unk_2FC]; + + this->unk_304 = table[this->unk_302]; + Animation_PlayOnce(&this->skelAnime, D_80B958C0[this->unk_304]); + SkelAnime_Update(&this->skelAnime); + } +} + +void func_80B93B44(EnZog* this) { + if (!(this->unk_30A & 4)) { + if (this->unk_31A != -1) { + ActorCutscene_Stop(this->unk_30C[this->unk_31A]); + } + } + this->unk_31A = -1; + this->unk_30A &= ~4; +} + +void func_80B93BA8(EnZog* this, s16 arg1) { + func_80B93B44(this); + this->unk_31A = arg1; + this->unk_30A |= 4; +} + +s32 func_80B93BE0(EnZog* this, GlobalContext* globalCtx) { + Path* path = this->unk_2E8; + s16 temp_v0; + Vec3s* points; + + if (this->unk_2E8 == 0) { + return false; + } + + points = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[this->unk_2EC]; + + if (this->unk_30A & 1) { + this->actor.world.pos.x = points->x; + this->actor.world.pos.z = points->z; + return true; + } + + points++; + temp_v0 = Math_Atan2S(points->x - this->actor.world.pos.x, points->z - this->actor.world.pos.z); + + if (ABS_ALT(temp_v0 - this->actor.world.rot.y) > 0x4000) { + this->unk_2EC++; + func_80B93468(this, globalCtx); + if ((this->unk_2EC + 1) >= this->unk_2E8->count) { + this->unk_30A |= 1; + return true; + } + } else { + this->actor.world.rot.y = temp_v0; + } + + return false; +} + +void func_80B93D2C(EnZog* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp28 = this->actor.world.pos; + + sp28.y += this->actor.depthInWater; + this->actor.world.pos.y += (this->actor.depthInWater - 10.0f) + (2.0f * Math_SinS(this->unk_308)); + this->unk_308 += 0x200; + if ((globalCtx->gameplayFrames % 16) == 0) { + EffectSsGRipple_Spawn(globalCtx, &sp28, 150, 500, 0); + } +} + +void func_80B93DE8(Vec3f* arg0, GlobalContext* globalCtx, s32 arg2) { + Vec3f sp2C; + + sp2C.x = randPlusMinusPoint5Scaled(30.0f) + arg0->x; + sp2C.y = arg0->y + 3.0f; + sp2C.z = randPlusMinusPoint5Scaled(30.0f) + arg0->z; + EffectSsKiraKira_SpawnDispersed(globalCtx, &sp2C, &D_80B9598C, &D_80B95998, &D_80B959A4, &D_80B959A8, 1000, arg2); +} + +s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { + s16 sp3E; + + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_306) { + case 2: + case 3: + Animation_PlayLoop(&this->skelAnime, *D_80B958F0); + this->unk_31C = 0; + this->unk_31E = 1; + break; + + case 4: + Animation_PlayLoop(&this->skelAnime, *D_80B958F8); + this->unk_31C = 2; + this->unk_31E = 1; + break; + + case 5: + switch (this->unk_304) { + case 16: + Animation_PlayOnce(&this->skelAnime, *D_80B95904); + this->unk_304 = 17; + this->unk_31C = 2; + this->unk_31E = 0; + break; + + case 17: + Animation_Change(&this->skelAnime, *D_80B958DC, 0.0f, 0.0f, 0.0f, 0, 0.0f); + break; + } + break; + + case 6: + Animation_PlayLoop(&this->skelAnime, *D_80B958E4); + this->unk_31C = 1; + this->unk_31E = 1; + break; + + case 12: + Animation_PlayLoop(&this->skelAnime, D_80B95930); + break; + + case 13: + Animation_PlayLoop(&this->skelAnime, D_80B95938); + break; + + case 14: + Animation_PlayLoop(&this->skelAnime, D_80B95928); + break; + + case 15: + Animation_PlayLoop(&this->skelAnime, D_80B9591C); + break; + } + 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)); + + switch (this->unk_306) { + case 2: + if (globalCtx->csCtx.frames == 60) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_JUMP_SAND); + } + break; + + case 8: + if (this->unk_322 > 4) { + this->unk_322 -= 4; + } else { + this->unk_322 = 0; + } + + if (this->unk_322 > 0) { + func_80B93DE8(&this->unk_2F0, globalCtx, 20); + func_80B93DE8(&this->actor.world.pos, globalCtx, 20); + func_80B93DE8(&this->actor.focus.pos, globalCtx, 20); + } + break; + + case 9: + case 10: + if (this->unk_322 < 150) { + this->unk_322 += 15; + } else { + this->unk_322 = 150; + } + break; + + default: + this->unk_30A &= ~8; + break; + } + + if (this->unk_306 != sp3E) { + this->unk_306 = sp3E; + + switch (this->unk_306) { + case 1: + func_80B939C0(this, 7, 0); + this->unk_31C = 2; + this->unk_31E = 0; + break; + + case 2: + func_80B939C0(this, 11, 2); + this->unk_31C = 1; + this->unk_31E = 0; + break; + + case 3: + func_80B939C0(this, 15, 2); + this->unk_31C = 0; + this->unk_31E = 1; + break; + + case 4: + func_80B939C0(this, 13, 2); + this->unk_31C = 2; + this->unk_31E = 1; + break; + + case 5: + func_80B939C0(this, 16, 2); + this->unk_31C = 2; + this->unk_31E = 1; + break; + + case 6: + func_80B939C0(this, 8, 2); + this->unk_31C = 1; + this->unk_31E = 0; + break; + + case 8: + this->unk_322 = 0xFA; + this->unk_30A |= 8; + break; + + case 9: + this->unk_322 = 0; + this->unk_30A |= 8; + func_80B939C0(this, 18, 0); + this->unk_31C = 0; + this->unk_31E = 0; + this->unk_30A &= ~2; + break; + + case 10: + func_80B939C0(this, 14, 0); + this->unk_31C = 0; + this->unk_30A |= 2; + this->unk_31E = 1; + break; + + case 11: + Animation_PlayLoop(&this->skelAnime, D_80B95920); + break; + + case 12: + Animation_PlayOnce(&this->skelAnime, D_80B9592C); + break; + + case 13: + Animation_PlayOnce(&this->skelAnime, D_80B95934); + break; + + case 14: + this->unk_30A |= 2; + Animation_PlayOnce(&this->skelAnime, D_80B95924); + break; + + case 15: + Animation_PlayOnce(&this->skelAnime, D_80B95918); + break; + } + } + return true; + } + + return false; +} + +void func_80B943A0(EnZog* this, GlobalContext* globalCtx) { + func_80B93EA0(this, globalCtx); +} + +void func_80B943C0(EnZog* this, GlobalContext* globalCtx) { + if (!(this->unk_30A & 4)) { + this->actionFunc = func_80B943A0; + this->unk_306 = -1; + } +} + +void func_80B943EC(EnZog* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_30A & 0x10) { + if (!(player->stateFlags2 & 0x8000000)) { + this->unk_30A &= ~0x10; + } + } else if ((player->stateFlags2 & 0x8000000) && (this->actor.xzDistToPlayer < 120.0f)) { + this->unk_30A |= 0x10; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + } +} + +void func_80B94470(EnZog* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 5) { + if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x103C)) { + func_801477B4(globalCtx); + this->actionFunc = func_80B9451C; + this->unk_300 = this->unk_302 = 0; + this->unk_31C = 2; + this->unk_31E = 0; + } + } + func_80B93A48(this, globalCtx); +} + +void func_80B9451C(EnZog* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_300 = 2; + this->actionFunc = func_80B94470; + } else if ((globalCtx->msgCtx.unk1202A == 3) && (this->actor.xzDistToPlayer < 120.0f)) { + if ((globalCtx->msgCtx.unk1202E == 7) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { + func_80B93BA8(this, 2); + this->actionFunc = func_80B943C0; + this->actor.shape.shadowDraw = NULL; + } + } else if (this->actor.xzDistToPlayer < 120.0f) { + func_800B8614(&this->actor, globalCtx, 150.0f); + } + func_80B943EC(this, globalCtx); +} + +void func_80B9461C(EnZog* this, GlobalContext* globalCtx) { + if (!func_80B93EA0(this, globalCtx)) { + this->actor.textId = 0x103C; + this->actionFunc = func_80B9451C; + this->actor.flags |= 0x2000000; + gSaveContext.weekEventReg[91] |= 2; + } + + if ((this->unk_304 == 11) && ((s32)this->skelAnime.curFrame >= 55)) { + this->unk_30A |= 2; + } +} + +void func_80B946B4(EnZog* this, GlobalContext* globalCtx) { + func_80B93A48(this, globalCtx); + if (!(this->unk_30A & 4)) { + this->actionFunc = func_80B9461C; + this->unk_306 = -1; + } +} + +void func_80B946FC(EnZog* this, GlobalContext* globalCtx) { + switch (Message_GetState(&globalCtx->msgCtx)) { + case 4: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80B946B4; + func_80B93BA8(this, 1); + break; + + case 1: + func_8019F230(); + func_80151938(globalCtx, 0x1014); + break; + } + } + break; + + case 5: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x1008: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x1009: + this->unk_300 = 4; + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x1014: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x1015: + func_801477B4(globalCtx); + this->actionFunc = func_80B948A8; + this->unk_300 = this->unk_302 = 0; + this->unk_31C = 2; + this->unk_31E = 0; + return; + } + } + break; + } + + func_80B93A48(this, globalCtx); +} + +void func_80B948A8(EnZog* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_300 = 2; + this->actionFunc = func_80B946FC; + } else if ((globalCtx->msgCtx.unk1202A == 3) && (this->actor.xzDistToPlayer < 120.0f)) { + if ((globalCtx->msgCtx.unk1202E == 7) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { + func_80B93BA8(this, 2); + this->actionFunc = func_80B943C0; + this->actor.shape.shadowDraw = NULL; + } + return; + } else { + if ((this->unk_302 == 2) && (this->unk_2FC == 2)) { + this->unk_300 = 0; + this->unk_2FE = 3; + this->unk_302 = this->unk_300; + this->unk_2FC = this->unk_2FE; + func_80B93B44(this); + } + + if ((this->unk_302 == 0) && (this->actor.xzDistToPlayer < 120.0f)) { + func_800B8614(&this->actor, globalCtx, 150.0f); + } + } + func_80B93A48(this, globalCtx); + func_80B943EC(this, globalCtx); +} + +void func_80B94A00(EnZog* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + + if (func_80B93BE0(this, globalCtx)) { + this->actionFunc = func_80B948A8; + this->actor.flags |= 0x2000000; + if (gSaveContext.weekEventReg[29] & 0x20) { + this->actor.textId = 0x1009; + } else { + this->actor.textId = 0x1008; + gSaveContext.weekEventReg[29] |= 0x20; + } + this->unk_300 = 2; + this->unk_31C = 2; + this->unk_31E = 0; + return; + } + + if ((this->skelAnime.curFrame >= 35.0f) || + ((this->skelAnime.curFrame >= 10.0f) && (this->skelAnime.curFrame <= 24.0f))) { + this->actor.speedXZ = 0.0f; + } else { + this->actor.speedXZ = 1.5f; + } + + if ((this->actor.depthInWater > 0.0f) && ((globalCtx->gameplayFrames % 8) == 0)) { + sp30 = this->actor.world.pos; + sp30.y += this->actor.depthInWater; + EffectSsGRipple_Spawn(globalCtx, &sp30, 150, 500, 0); + } + + if (this->actor.shape.yOffset > 0.0f) { + this->actor.shape.yOffset -= 20.0f; + } + + func_80B93A48(this, globalCtx); + + if ((this->unk_304 == 4) && + (Animation_OnFrame(&this->skelAnime, 136.0f) || Animation_OnFrame(&this->skelAnime, 155.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_WATER0); + } + + if ((this->unk_304 == 5) && + (Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 37.0f))) { + if (this->actor.depthInWater > 0.0f) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_WATER0); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_SAND); + } + } +} + +void func_80B94C5C(EnZog* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + if (this->unk_304 != 0) { + if (this->actor.shape.yOffset > 0.0f) { + this->actor.shape.yOffset -= 20.0f; + } + this->actor.velocity.y = -1.0f; + this->actor.terminalVelocity = -1.0f; + } + + if ((this->unk_2FC == 1) && (this->unk_302 == 0)) { + this->unk_2FE = 2; + this->unk_300 = 2; + } + + if (this->unk_304 == 5) { + this->actionFunc = func_80B94A00; + } + + func_80B93A48(this, globalCtx); +} + +void func_80B94D0C(EnZog* this, GlobalContext* globalCtx) { + func_80B93D2C(this, globalCtx); + this->actor.speedXZ = 0.0f; + if (this->unk_320 > 0) { + this->unk_320--; + this->unk_31C = 1; + this->unk_31E = 1; + } else { + this->unk_31C = 2; + this->unk_31E = 0; + } + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + this->unk_320 = 5; + switch (globalCtx->msgCtx.unk11F04) { + case 0x1004: + case 0x1005: + case 0x1006: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x1007: + func_801477B4(globalCtx); + this->actionFunc = func_80B94E34; + this->unk_300 = 5; + this->unk_320 = 0; + this->unk_31C = 2; + this->unk_31E = 0; + func_80B93B44(this); + break; + } + } + func_80B93A48(this, globalCtx); +} + +void func_80B94E34(EnZog* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + func_80B93D2C(this, globalCtx); + func_80B93BE0(this, globalCtx); + if (this->actor.speedXZ < 0.1f) { + this->actor.speedXZ = 0.0f; + } else { + if (this->actor.speedXZ > 0.1f) { + WaterBox* sp44; + Vec3f sp38; + + Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80B959AC, &sp38); + sp38.x += randPlusMinusPoint5Scaled(30.0f); + sp38.y += 20.0f; + sp38.z += randPlusMinusPoint5Scaled(30.0f); + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, sp38.x, sp38.z, &sp38.y, &sp44) && + (this->actor.world.pos.y < sp38.y)) { + EffectSsGSplash_Spawn(globalCtx, &sp38, NULL, NULL, 1, + Rand_ZeroFloat(this->actor.speedXZ * 40.0f) + (this->actor.speedXZ * 60.0f)); + } + + if ((player->actor.speedXZ > 3.0f) && (this->unk_324 == 0)) { + this->unk_324 = 25; + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_PUSH); + } + } + this->actor.speedXZ *= 0.3f; + } + + if (ABS_ALT(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0x5000) { + Actor_PickUp(&this->actor, globalCtx, 0, 60.0f, 40.0f); + } + + if (this->unk_324 > 0) { + this->unk_324--; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B94D0C; + this->actor.speedXZ = 0.0f; + this->unk_300 = 2; + } else if (this->actor.bgCheckFlags & 1) { + this->actor.home.rot.z = 1; + this->actionFunc = func_80B94C5C; + this->actor.speedXZ = 0.0f; + this->unk_2FE = 1; + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = 0.0f; + this->actor.gravity = 0.0f; + this->unk_31C = 1; + this->unk_31E = 0; + func_80B93BA8(this, 0); + gSaveContext.weekEventReg[88] |= 0x10; + } else if ((this->actor.yawTowardsPlayer > 16000) && (this->actor.yawTowardsPlayer < 32000) && + (this->unk_302 == 0)) { + func_800B8614(&this->actor, globalCtx, 150.0f); + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + func_80B93A48(this, globalCtx); +} + +void func_80B95128(EnZog* this, GlobalContext* globalCtx) { + func_80B93D2C(this, globalCtx); + func_80B93BE0(this, globalCtx); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B94D0C; + this->unk_300 = 2; + this->actor.speedXZ = 0.0f; + + switch (CURRENT_DAY) { + case 1: + func_80B93BA8(this, 4); + break; + + case 2: + func_80B93BA8(this, 5); + break; + + default: + func_80B93BA8(this, 6); + break; + } + + this->actor.flags &= ~0x10000; + gSaveContext.weekEventReg[91] |= 1; + } else { + func_800B8614(&this->actor, globalCtx, 150.0f); + } + this->actor.shape.rot.y = this->actor.world.rot.y; + func_80B93A48(this, globalCtx); +} + +void func_80B95240(EnZog* this, GlobalContext* globalCtx) { + func_80B93EA0(this, globalCtx); +} + +void EnZog_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZog* this = THIS; + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 5); + if (func_800EE29C(globalCtx, 0x1D7) && (ENZOG_GET_F(&this->actor) != ENZOG_F_2)) { + this->actionFunc = func_80B9461C; + this->actor.shape.yOffset = 0.0f; + } + + this->actionFunc(this, globalCtx); + + if (((this->unk_304 == 6) && Animation_OnFrame(&this->skelAnime, 43.0f)) || + ((this->unk_304 == 17) && Animation_OnFrame(&this->skelAnime, 14.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_LAND_SAND); + } + + if (this->unk_30A & 1) { + this->collider.dim.pos.x = this->unk_2F0.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->unk_2F0.z; + } else { + Collider_UpdateCylinder(&this->actor, &this->collider); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 30.0f; + + if (this->unk_30A & 4) { + if (this->unk_31A == -1) { + this->unk_30A &= ~4; + } else if (this->unk_30C[this->unk_31A] == -1) { + this->unk_30A &= ~4; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_30C[this->unk_31A]); + } else if (ActorCutscene_GetCanPlayNext(this->unk_30C[this->unk_31A])) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_30C[this->unk_31A], &this->actor); + this->unk_30A &= ~4; + } else { + ActorCutscene_SetIntentToPlay(this->unk_30C[this->unk_31A]); + } + } +} + +void func_80B954C4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80B959B8 = { 0.0f, 0.0f, 0.0f }; + EnZog* this = THIS; + + D_80B959B8.y = 1000.0f; + if (limbIndex == 9) { + Matrix_MultiplyVector3fByState(&D_80B959B8, &this->actor.focus.pos); + } + D_80B959B8.y = 0.0f; + + if (limbIndex == 1) { + Matrix_MultiplyVector3fByState(&D_80B959B8, &this->unk_2F0); + } + + if ((this->unk_30A & 2) && (limbIndex == 17)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, object_zog_DL_0280A8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80B95598(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + static Vec3f D_80B959C4 = { 0.0f, 0.0f, 0.0f }; + EnZog* this = THIS; + + D_80B959C4.y = 1000.0f; + if (limbIndex == 9) { + Matrix_MultiplyVector3fByState(&D_80B959C4, &this->actor.focus.pos); + } + D_80B959C4.y = 0.0f; + + if (limbIndex == 1) { + Matrix_MultiplyVector3fByState(&D_80B959C4, &this->unk_2F0); + } + + if ((this->unk_30A & 2) && (limbIndex == 17)) { + gSPDisplayList((*gfx)++, object_zog_DL_0280A8); + } +} + +void EnZog_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnZog* this = THIS; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_30A & 8) { + if (this->unk_322 > 128) { + gfx = POLY_XLU_DISP++; + func_8012C2B4(gfx); + Scene_SetRenderModeXlu(globalCtx, 2, 2); + } else { + gfx = POLY_XLU_DISP++; + func_8012C304(gfx); + Scene_SetRenderModeXlu(globalCtx, 1, 2); + } + + gfx = POLY_XLU_DISP; + + gSPSegment(&gfx[0], 0x08, Lib_SegmentedToVirtual(D_80B958AC[this->unk_31C])); + gSPSegment(&gfx[1], 0x09, Lib_SegmentedToVirtual(D_80B958B8[this->unk_31E])); + gDPSetEnvColor(&gfx[2], 0, 0, 0, this->unk_322); + + POLY_XLU_DISP = &gfx[3]; + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, func_80B95598, &this->actor, POLY_XLU_DISP); + } else { + func_8012C28C(globalCtx->state.gfxCtx); + Scene_SetRenderModeXlu(globalCtx, 0, 1); + + gfx = POLY_OPA_DISP; + + gSPSegment(&gfx[0], 0x08, Lib_SegmentedToVirtual(D_80B958AC[this->unk_31C])); + gSPSegment(&gfx[1], 0x09, Lib_SegmentedToVirtual(D_80B958B8[this->unk_31E])); + gDPSetEnvColor(&gfx[2], 0, 0, 0, 255); + + POLY_OPA_DISP = &gfx[3]; + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, func_80B954C4, &this->actor); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.h b/src/overlays/actors/ovl_En_Zog/z_en_zog.h index 48600b3f76..7dba946d58 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.h +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.h @@ -7,10 +7,37 @@ struct EnZog; typedef void (*EnZogActionFunc)(struct EnZog*, GlobalContext*); +#define ENZOG_GET_F(thisx) ((thisx)->params & 0xF) +#define ENZOG_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) + +#define ENZOG_F_2 2 +#define ENZOG_FC00_63 63 + typedef struct EnZog { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1E4]; - /* 0x0328 */ EnZogActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ Vec3s jointTable[23]; + /* 0x25E */ Vec3s morphTable[23]; + /* 0x2E8 */ Path* unk_2E8; + /* 0x2EC */ s32 unk_2EC; + /* 0x2F0 */ Vec3f unk_2F0; + /* 0x2FC */ s16 unk_2FC; + /* 0x2FE */ s16 unk_2FE; + /* 0x300 */ s16 unk_300; + /* 0x302 */ s16 unk_302; + /* 0x304 */ s16 unk_304; + /* 0x306 */ s16 unk_306; + /* 0x308 */ s16 unk_308; + /* 0x30A */ u16 unk_30A; + /* 0x30C */ s16 unk_30C[7]; + /* 0x31A */ s16 unk_31A; + /* 0x31C */ s16 unk_31C; + /* 0x31E */ s16 unk_31E; + /* 0x320 */ s16 unk_320; + /* 0x322 */ s16 unk_322; + /* 0x324 */ s16 unk_324; + /* 0x328 */ EnZogActionFunc actionFunc; } EnZog; // size = 0x32C extern const ActorInit En_Zog_InitVars; diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index fe2b2cbefd..c179517cde 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -97,7 +97,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; s32 i; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80B97100; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600D208, &D_06004248, this->jointTable, this->morphTable, 20); @@ -110,7 +110,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.world.rot.z = this->actor.shape.rot.z = 0; this->actor.targetMode = 6; - this->actor.minVelocityY = -4.0f; + this->actor.terminalVelocity = -4.0f; this->actor.gravity = -4.0f; switch (ENZOT_GET_1F(thisx)) { @@ -288,7 +288,7 @@ void func_80B96D4C(EnZot* this) { } s32 func_80B96DF0(EnZot* this, GlobalContext* globalCtx) { - if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsActorFacingLink(&this->actor, 0x3000) && + if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x3000) && (this->actor.xzDistToPlayer < 100.0f)) { return true; } @@ -391,7 +391,7 @@ void func_80B97110(EnZot* this, GlobalContext* globalCtx) { } void func_80B97194(EnZot* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.unk11F04) { case 0x125C: case 0x125F: @@ -410,11 +410,11 @@ void func_80B97194(EnZot* this, GlobalContext* globalCtx) { } void func_80B97240(EnZot* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B97194; func_80B97110(this, globalCtx); - } else if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && - Actor_IsActorFacingLink(&this->actor, 0x3000)) { + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x3000)) { func_800B8614(&this->actor, globalCtx, 120.0f); } } @@ -460,7 +460,7 @@ void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { func_80B96D4C(this); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.unk11F04) { case 0x126E: case 0x1270: @@ -525,10 +525,10 @@ void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { void func_80B975F8(EnZot* this, GlobalContext* globalCtx) { func_80B96D4C(this); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B973BC; } else { - func_800B8500(&this->actor, globalCtx, 10000.0f, 1000.0f, 0); + func_800B8500(&this->actor, globalCtx, 10000.0f, 1000.0f, EXCH_ITEM_NONE); } } @@ -537,7 +537,7 @@ void func_80B9765C(EnZot* this, GlobalContext* globalCtx) { do { } while (0); } func_80B96D4C(this); - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { u16 temp = globalCtx->msgCtx.unk11F04; u32 temp2; @@ -558,7 +558,7 @@ void func_80B97708(EnZot* this, GlobalContext* globalCtx) { func_80B96D4C(this); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B9765C; func_80B972E8(this, globalCtx); return; @@ -670,7 +670,7 @@ void func_80B979DC(EnZot* this, GlobalContext* globalCtx) { } void func_80B97A44(EnZot* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.unk11F04) { case 0x1279: case 0x127C: @@ -708,7 +708,7 @@ void func_80B97A44(EnZot* this, GlobalContext* globalCtx) { void func_80B97B5C(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B97A44; func_80B9787C(this, globalCtx); } else if (func_80B96DF0(this, globalCtx)) { @@ -730,17 +730,17 @@ void func_80B97BF8(EnZot* this, GlobalContext* globalCtx) { void func_80B97C40(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); this->actionFunc = func_80B97CC8; } } void func_80B97CC8(EnZot* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B97C40; func_801518B0(globalCtx, 0x128B, &this->actor); - } else if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + } else if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { func_800B8614(&this->actor, globalCtx, 120.0f); } } @@ -755,7 +755,7 @@ void func_80B97D6C(EnZot* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ZORA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_WALK); } } @@ -779,7 +779,7 @@ void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.unk11F04) { case 0x128C: this->unk_2F2 &= ~4; @@ -812,7 +812,7 @@ void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { void func_80B97FD0(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B97E4C; func_80B97BF8(this, globalCtx); } else if (gSaveContext.weekEventReg[38] & 8) { @@ -821,7 +821,7 @@ void func_80B97FD0(EnZot* this, GlobalContext* globalCtx) { this->actionFunc = func_80B97E0C; func_80B96BEC(this, 6, 2); } - } else if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + } else if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { func_800B8614(&this->actor, globalCtx, 120.0f); } } @@ -916,7 +916,7 @@ void func_80B98348(EnZot* this, GlobalContext* globalCtx) { if (ENZOT_GET_1F(&this->actor) == 7) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - } else if (Actor_IsActorFacingLink(&this->actor, 0x3000)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x3000)) { this->unk_2F2 &= ~8; } else { this->unk_2F2 |= 8; @@ -935,7 +935,7 @@ void func_80B98348(EnZot* this, GlobalContext* globalCtx) { void func_80B9849C(EnZot* this, GlobalContext* globalCtx) { func_80B98348(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->unk_2D4 == 2) { func_801518B0(globalCtx, 0x12AD, &this->actor); } else { @@ -943,7 +943,7 @@ void func_80B9849C(EnZot* this, GlobalContext* globalCtx) { } this->actionFunc = func_80B98728; } else { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } } @@ -953,9 +953,9 @@ void func_80B9854C(EnZot* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = func_80B9849C; this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } else { - func_800B8A1C(&this->actor, globalCtx, this->unk_2D4, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, globalCtx, this->unk_2D4, 10000.0f, 50.0f); } } @@ -964,7 +964,7 @@ void func_80B985EC(EnZot* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); func_80B98348(this, globalCtx); - if (func_80152498(&globalCtx->msgCtx) == 0x10) { + if (Message_GetState(&globalCtx->msgCtx) == 0x10) { itemActionParam = func_80123810(globalCtx); if (itemActionParam > PLAYER_AP_NONE) { func_801477B4(globalCtx); @@ -989,7 +989,7 @@ void func_80B985EC(EnZot* this, GlobalContext* globalCtx) { void func_80B98728(EnZot* this, GlobalContext* globalCtx) { func_80B98348(this, globalCtx); - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 4: if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1293)) { switch (globalCtx->msgCtx.choiceIndex) { @@ -1074,11 +1074,11 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { void func_80B98998(EnZot* this, GlobalContext* globalCtx) { this->unk_2F2 &= ~8; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B98728; func_80B98178(this, globalCtx); - } else if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && - Actor_IsActorFacingLink(&this->actor, 0x7000)) { + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x7000)) { func_800B8614(&this->actor, globalCtx, 120.0f); } } @@ -1103,7 +1103,7 @@ void func_80B98A4C(EnZot* this, GlobalContext* globalCtx) { } void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.unk11F04) { case 0x12B1: case 0x12B4: @@ -1135,7 +1135,7 @@ void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { } void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; if (gSaveContext.weekEventReg[41] & 0x20) { func_801518B0(globalCtx, 0x12B7, &this->actor); @@ -1150,17 +1150,17 @@ void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { } void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { - if (func_800B8718(&this->actor, globalCtx)) { + if (func_800B8718(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.unk1202A = 4; func_8019B544(0xFFFF); this->actionFunc = func_80B98BF4; this->actor.flags |= 0x10000; func_800B8614(&this->actor, globalCtx, 120.0f); - } else if (func_800B84D0(&this->actor, globalCtx)) { + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B98AD0; func_80B98A4C(this, globalCtx); } else { - if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx)) { + if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { func_800B8614(&this->actor, globalCtx, 120.0f); } @@ -1215,7 +1215,7 @@ void func_80B98F30(EnZot* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = func_80B990A4; } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_BLUE, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 10000.0f, 50.0f); } } @@ -1225,7 +1225,7 @@ void func_80B98F94(EnZot* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.unk11F04) { case 0x12BB: this->unk_2F2 &= ~4; @@ -1253,10 +1253,10 @@ void func_80B98F94(EnZot* this, GlobalContext* globalCtx) { void func_80B990A4(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B98F94; func_80B98E10(this, globalCtx); - } else if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + } else if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { func_800B8614(&this->actor, globalCtx, 120.0f); } } @@ -1286,7 +1286,7 @@ void func_80B991E4(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { u16 temp = globalCtx->msgCtx.unk11F04; u32 temp2; @@ -1302,13 +1302,13 @@ void func_80B991E4(EnZot* this, GlobalContext* globalCtx) { } void func_80B992C0(EnZot* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B991E4; func_80B99160(this, globalCtx); this->actor.speedXZ = 0.0f; func_80B96BEC(this, 0, 0); } else { - if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { func_800B8614(&this->actor, globalCtx, 120.0f); } this->actor.speedXZ = 1.5f; @@ -1323,7 +1323,7 @@ void EnZot_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnZot* this = THIS; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 15.0f, 30.0f, 5); diff --git a/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c b/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c index 2bac5660d3..519d87e7fb 100644 --- a/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c +++ b/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c @@ -42,7 +42,7 @@ extern Gfx D_06001470[]; void ItemBHeart_Init(Actor* thisx, GlobalContext* globalCtx) { ItemBHeart* this = THIS; - if (Actor_GetCollectibleFlag(globalCtx, 0x1F)) { + if (Flags_GetCollectible(globalCtx, 0x1F)) { Actor_MarkForDeath(&this->actor); return; } @@ -69,10 +69,10 @@ void ItemBHeart_Update(Actor* thisx, GlobalContext* globalCtx) { if (!(this->unk_168 < 0.5f)) { if (Actor_HasParent(&this->actor, globalCtx)) { - Actor_SetCollectibleFlag(globalCtx, 0x1F); + Flags_SetCollectible(globalCtx, 0x1F); Actor_MarkForDeath(&this->actor); } else { - func_800B8A1C(&this->actor, globalCtx, GI_HEART_CONTAINER, 30.0f, 80.0f); + Actor_PickUp(&this->actor, globalCtx, GI_HEART_CONTAINER, 30.0f, 80.0f); } } } @@ -90,7 +90,7 @@ void ItemBHeart_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - blueWarpActor = globalCtx->actorCtx.actorList[ACTORCAT_ITEMACTION].first; + blueWarpActor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (blueWarpActor != NULL) { if ((blueWarpActor->id == ACTOR_DOOR_WARP1) && (blueWarpActor->projectedPos.z > this->actor.projectedPos.z)) { diff --git a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c index d30a74878d..a006270f35 100644 --- a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c +++ b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c @@ -40,7 +40,7 @@ void ItemInbox_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void ItemInbox_Idle(ItemInbox* this, GlobalContext* globalCtx) { - if (Actor_GetChestFlag(globalCtx, (this->actor.params >> 8) & 0x1F)) { + if (Flags_GetTreasure(globalCtx, (this->actor.params >> 8) & 0x1F)) { Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c index a3073a7e0e..8e168cba89 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -5,6 +5,7 @@ */ #include "z_obj_aqua.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000010 @@ -57,7 +58,7 @@ static ColliderCylinderInit sCylinderInit = { static InitChainEntry sInitChain[] = { ICHAIN_VEC3S(shape.rot, 0, ICHAIN_CONTINUE), ICHAIN_VEC3S(world.rot, 0, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -900, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -4000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -900, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 300, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), }; @@ -66,8 +67,6 @@ Vec3f D_80ACC308 = { 1.0f / 1000.0f, 7.0f / 10000.0f, 1.0f / 1000.0f }; Vec3f D_80ACC314 = { 8.6f / 1000.0f, 8.0f / 10000.0f, 8.6f / 1000.0f }; Vec3f D_80ACC320 = { 1.0f / 100.0f, 2.6f / 1000.0f, 1.0f / 100.0f }; -extern Gfx D_0407D590[]; - void func_80ACB6A0(ObjAqua* this, GlobalContext* globalCtx) { s32 pad; Vec3f sp58; @@ -115,7 +114,7 @@ void func_80ACB940(ObjAqua* this, GlobalContext* globalCtx) { effectPos.x = this->actor.world.pos.x + (effectVel.x * 40.0f); effectPos.y = this->actor.world.pos.y; effectPos.z = this->actor.world.pos.z + (effectVel.z * 40.0f); - EffectSsIceSmoke_Spawn(globalCtx, &effectPos, &effectVel, &D_801D15B0, (s32)(Rand_ZeroOne() * 24.0f) + 70); + EffectSsIceSmoke_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, (s32)(Rand_ZeroOne() * 24.0f) + 70); } void func_80ACBA10(ObjAqua* this) { @@ -151,7 +150,7 @@ void ObjAqua_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.scale.z = 0.0009f; Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 60.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 60.0f); if (1) {}; this->actor.shape.shadowAlpha = 140; this->alpha = 255; @@ -181,11 +180,11 @@ void func_80ACBC8C(ObjAqua* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { func_80ACB7F4(this, globalCtx); func_80ACBA10(this); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOTTLE_WATERING); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOTTLE_WATERING); func_80ACBD34(this); } else { func_80ACB6A0(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 0x28, NA_SE_EV_BOMB_DROP_WATER); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 0x28, NA_SE_EV_BOMB_DROP_WATER); Actor_MarkForDeath(&this->actor); } } else if (this->counter <= 0) { @@ -255,7 +254,7 @@ void ObjAqua_Update(Actor* thisx, GlobalContext* globalCtx) { Math_Vec3f_StepTo(&this->actor.scale, &D_80ACC320, 0.0004f); } this->actor.velocity.y *= 0.9f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f, 4.0f, 0.0f, 5); if (this->actionFunc != func_80ACBDFC) { Collider_UpdateCylinder(&this->actor, &this->collider); @@ -292,6 +291,6 @@ void ObjAqua_Draw(Actor* thisx, GlobalContext* globalCtx) { } Matrix_RotateY(yaw, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_0407D590); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c index 55b8f301f5..651adf6d22 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -198,11 +198,11 @@ s32 func_80A357A8(ObjBell* this, GlobalContext* globalCtx) { this->unk_20E = 10; switch (this->dyna.actor.colChkInfo.damageEffect) { case 15: - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BIGBELL); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGBELL); func_80A35510(this, 1); break; case 14: - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BIGBELL); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGBELL); func_80A35510(this, 2); break; default: diff --git a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c index 0d5a2c1b94..a0d6301f33 100644 --- a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c +++ b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c @@ -182,5 +182,5 @@ void ObjBoyo_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjBoyo* this = THIS; AnimatedMat_Draw(globalCtx, this->unk_190); - func_800BDFC0(globalCtx, D_06000300); + Gfx_DrawDListOpa(globalCtx, D_06000300); } diff --git a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c index 98f66c014d..a75bc0a3b6 100644 --- a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c +++ b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c @@ -14,7 +14,9 @@ void ObjDowsing_Init(Actor* thisx, GlobalContext* globalCtx); void ObjDowsing_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjDowsing_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 ObjDowsing_GetFlag(ObjDowsing* this, GlobalContext* globalCtx); +s32 ObjDowsing_CheckValidSpawn(ObjDowsing* this, GlobalContext* globalCtx); + const ActorInit Obj_Dowsing_InitVars = { ACTOR_OBJ_DOWSING, ACTORCAT_ITEMACTION, @@ -27,14 +29,42 @@ const ActorInit Obj_Dowsing_InitVars = { (ActorFunc)NULL, }; -#endif +s32 ObjDowsing_GetFlag(ObjDowsing* this, GlobalContext* globalCtx) { + s32 type = DOWSING_GET_TYPE(&this->actor); + s32 flag = DOWSING_GET_FLAG(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dowsing/func_80B23D50.s") + if (type == DOWSING_COLLECTIBLE) { + return Flags_GetCollectible(globalCtx, flag); + } else if (type == DOWSING_CHEST) { + return Flags_GetTreasure(globalCtx, flag); + } else if (type == DOWSING_SWITCH) { + return Flags_GetSwitch(globalCtx, flag); + } else { + return 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dowsing/func_80B23DD0.s") +s32 ObjDowsing_CheckValidSpawn(ObjDowsing* this, GlobalContext* globalCtx) { + if (ObjDowsing_GetFlag(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dowsing/ObjDowsing_Init.s") +void ObjDowsing_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjDowsing* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dowsing/ObjDowsing_Destroy.s") + ObjDowsing_CheckValidSpawn(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dowsing/ObjDowsing_Update.s") +void ObjDowsing_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void ObjDowsing_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjDowsing* this = THIS; + + if (!ObjDowsing_CheckValidSpawn(this, globalCtx)) { + func_800B8C50(thisx, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.h b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.h index 5a2982cab7..7b1125a283 100644 --- a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.h +++ b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.h @@ -3,8 +3,17 @@ #include "global.h" +#define DOWSING_GET_TYPE(thisx) ((thisx)->params >> 7) +#define DOWSING_GET_FLAG(thisx) ((thisx)->params & 0x7F) + struct ObjDowsing; +typedef enum { + /* 1 */ DOWSING_COLLECTIBLE = 1, + /* 2 */ DOWSING_CHEST, + /* 3 */ DOWSING_SWITCH +} DowsingType; + typedef struct ObjDowsing { /* 0x000 */ Actor actor; } ObjDowsing; // size = 0x144 diff --git a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c index 7ae7399ca4..cb6aabaff7 100644 --- a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c +++ b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c @@ -65,10 +65,10 @@ void ObjEnding_Draw(Actor* thisx, GlobalContext* globalCtx) { } dl1 = this->modelInfo->dLists[0]; if (dl1 != NULL) { - func_800BDFC0(globalCtx, dl1); + Gfx_DrawDListOpa(globalCtx, dl1); } dl2 = this->modelInfo->dLists[1]; if (dl2 != NULL) { - func_800BE03C(globalCtx, dl2); + Gfx_DrawDListXlu(globalCtx, dl2); } } diff --git a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c index a4eb9ad9ac..ca6ea9f6f0 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c @@ -5,6 +5,7 @@ */ #include "z_obj_etcetera.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000010 @@ -14,8 +15,8 @@ void ObjEtcetera_Init(Actor* thisx, GlobalContext* globalCtx); void ObjEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjEtcetera_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjEtcetera_PlaySmallFlutterAnimation(ObjEtcetera* this, GlobalContext* globalCtx); -void ObjEtcetera_DoIntenseOscillation(ObjEtcetera* this, GlobalContext* globalCtx); +void ObjEtcetera_PlayRustleAnimation(ObjEtcetera* this, GlobalContext* globalCtx); +void ObjEtcetera_DoBounceOscillation(ObjEtcetera* this, GlobalContext* globalCtx); void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx); void ObjEtcetera_DrawIdle(Actor* thisx, GlobalContext* globalCtx); void ObjEtcetera_DrawAnimated(Actor* thisx, GlobalContext* globalCtx); @@ -105,6 +106,11 @@ void ObjEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } +/** + * This function will make the flower oscillate on the X and Z axes in most situations + * where something interacts with it. When the player launches out of the flower, the + * oscillation is handled by ObjEtcetera_DoBounceOscillation instead. + */ void ObjEtcetera_DoNormalOscillation(ObjEtcetera* this, GlobalContext* globalCtx) { if (this->oscillationTimer > 0) { s32 requiredScopeTemp; @@ -119,10 +125,11 @@ void ObjEtcetera_DoNormalOscillation(ObjEtcetera* this, GlobalContext* globalCtx } } -void ObjEtcetera_StartSmallFlutterAnimation(ObjEtcetera* this) { - Animation_Change(&this->skelAnime, &D_040117A8, 1.0f, 0.0f, Animation_GetLastFrame(&D_040117A8), 2, 0.0f); +void ObjEtcetera_StartRustleAnimation(ObjEtcetera* this) { + Animation_Change(&this->skelAnime, &gDekuFlowerRustleAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuFlowerRustleAnim), 2, 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; - this->actionFunc = ObjEtcetera_PlaySmallFlutterAnimation; + this->actionFunc = ObjEtcetera_PlayRustleAnimation; } void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { @@ -131,12 +138,13 @@ void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { if ((player->stateFlags3 & 0x200) && (this->dyna.actor.xzDistToPlayer < 20.0f)) { // Player is launching out of the Deku Flower - Animation_Change(&this->skelAnime, &D_0400EB7C, 1.0f, 0.0f, Animation_GetLastFrame(&D_0400EB7C), 2, 0.0f); + Animation_Change(&this->skelAnime, &gDekuFlowerBounceAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuFlowerBounceAnim), 2, 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; - this->actionFunc = ObjEtcetera_DoIntenseOscillation; + this->actionFunc = ObjEtcetera_DoBounceOscillation; Actor_SetScale(&this->dyna.actor, 0.01f); this->dyna.actor.scale.y = 0.02f; - this->intenseOscillationScale = 0.003f; + this->bounceOscillationScale = 0.003f; this->oscillationTimer = 30; this->burrowFlag &= ~1; } else if ((player->stateFlags3 & 0x2000) && (this->dyna.actor.xzDistToPlayer < 30.0f) && @@ -151,7 +159,7 @@ void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { if (!(this->burrowFlag & 1)) { // Player is walking onto the Deku Flower, or falling on it from a height this->oscillationTimer = 10; - ObjEtcetera_StartSmallFlutterAnimation(this); + ObjEtcetera_StartRustleAnimation(this); } else if ((player->actor.speedXZ > 0.1f) || ((player->unk_ABC < 0.0f) && !(player->stateFlags3 & 0x100))) { // Player is walking on top of the Deku Flower, is at the very start of burrowing, or is at the very // start of launching @@ -162,19 +170,19 @@ void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { if (this->burrowFlag & 1) { // Player is walking off the Deku Flower this->oscillationTimer = 10; - ObjEtcetera_StartSmallFlutterAnimation(this); + ObjEtcetera_StartRustleAnimation(this); } this->burrowFlag &= ~1; } } if ((this->collider.base.acFlags & AC_HIT)) { this->oscillationTimer = 10; - ObjEtcetera_StartSmallFlutterAnimation(this); + ObjEtcetera_StartRustleAnimation(this); } ObjEtcetera_DoNormalOscillation(this, globalCtx); } -void ObjEtcetera_PlaySmallFlutterAnimation(ObjEtcetera* this, GlobalContext* globalCtx) { +void ObjEtcetera_PlayRustleAnimation(ObjEtcetera* this, GlobalContext* globalCtx) { if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { this->burrowFlag |= 1; } else { @@ -187,7 +195,12 @@ void ObjEtcetera_PlaySmallFlutterAnimation(ObjEtcetera* this, GlobalContext* glo ObjEtcetera_DoNormalOscillation(this, globalCtx); } -void ObjEtcetera_DoIntenseOscillation(ObjEtcetera* this, GlobalContext* globalCtx) { +/** + * When the bounce animation plays (either because the player launched out of the flower, + * or because the flower spawned after killing a Mad Scrub), this function makes the + * flower oscillate stronger than it normally does, including an oscillation on the Y-axis. + */ +void ObjEtcetera_DoBounceOscillation(ObjEtcetera* this, GlobalContext* globalCtx) { // In order to match, we are seemingly required to access scale.x at one point // without using this. We can create a thisx or dyna pointer to achieve that, but // it's more likely they used dyna given that DynaPolyActor_IsInRidingMovingState takes a DynaPolyActor. @@ -208,12 +221,12 @@ void ObjEtcetera_DoIntenseOscillation(ObjEtcetera* this, GlobalContext* globalCt Actor_SetScale(&this->dyna.actor, 0.01f); this->dyna.actor.scale.y = 0.02f; this->oscillationTimer = 0; - this->intenseOscillationScale = 0.0f; + this->bounceOscillationScale = 0.0f; return; } - this->intenseOscillationScale *= 0.8f; - this->intenseOscillationScale -= (this->dyna.actor.scale.x - 0.01f) * 0.4f; - scaleTemp = dyna->actor.scale.x + this->intenseOscillationScale; + this->bounceOscillationScale *= 0.8f; + this->bounceOscillationScale -= (this->dyna.actor.scale.x - 0.01f) * 0.4f; + scaleTemp = dyna->actor.scale.x + this->bounceOscillationScale; Actor_SetScale(&this->dyna.actor, scaleTemp); this->dyna.actor.scale.y = 2.0f * scaleTemp; } @@ -221,7 +234,12 @@ void ObjEtcetera_DoIntenseOscillation(ObjEtcetera* this, GlobalContext* globalCt void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { CollisionHeader* colHeader = NULL; s32 type; - CollisionHeader* collisionHeaders[] = { &D_0400E710, &D_0400E710, &D_040118D8, &D_040118D8 }; + CollisionHeader* collisionHeaders[] = { + &gPinkDekuFlowerCol, + &gPinkDekuFlowerCol, + &gGoldDekuFlowerCol, + &gGoldDekuFlowerCol, + }; s32 pad; CollisionHeader* thisCollisionHeader; @@ -232,7 +250,7 @@ void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { this->dyna.actor.objBankIndex = this->objIndex; - Actor_SetObjectSegment(globalCtx, &this->dyna.actor); + Actor_SetObjectDependency(globalCtx, &this->dyna.actor); DynaPolyActor_Init(&this->dyna, 1); thisCollisionHeader = collisionHeaders[type]; if (thisCollisionHeader != 0) { @@ -244,15 +262,15 @@ void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { switch (type) { case DEKU_FLOWER_TYPE_PINK: case DEKU_FLOWER_TYPE_PINK_SPAWNED_FROM_MAD_SCRUB: - SkelAnime_Init(globalCtx, &this->skelAnime, &D_04011518, &D_0400EB7C, this->jointTable, - this->morphTable, 11); - this->dList = &D_0400ED80; + SkelAnime_Init(globalCtx, &this->skelAnime, &gPinkDekuFlowerSkel, &gDekuFlowerBounceAnim, + this->jointTable, this->morphTable, DEKU_FLOWER_LIMB_MAX); + this->dList = gPinkDekuFlowerIdleDL; break; case DEKU_FLOWER_TYPE_GOLD: case DEKU_FLOWER_TYPE_GOLD_SPAWNED_FROM_MAD_SCRUB: - this->dList = &D_04011BD0; - SkelAnime_Init(globalCtx, &this->skelAnime, &D_040127E8, &D_0400EB7C, this->jointTable, - this->morphTable, 11); + this->dList = gGoldDekuFlowerIdleDL; + SkelAnime_Init(globalCtx, &this->skelAnime, &gGoldDekuFlowerSkel.sh, &gDekuFlowerBounceAnim, + this->jointTable, this->morphTable, DEKU_FLOWER_LIMB_MAX); this->collider.dim.height = 20; break; } @@ -270,13 +288,13 @@ void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { break; case DEKU_FLOWER_TYPE_PINK_SPAWNED_FROM_MAD_SCRUB: case DEKU_FLOWER_TYPE_GOLD_SPAWNED_FROM_MAD_SCRUB: - Animation_Change(&this->skelAnime, &D_0400EB7C, 1.0f, 0.0f, Animation_GetLastFrame(&D_0400EB7C), 2, - 0.0f); + Animation_Change(&this->skelAnime, &gDekuFlowerBounceAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuFlowerBounceAnim), 2, 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; - this->actionFunc = ObjEtcetera_DoIntenseOscillation; + this->actionFunc = ObjEtcetera_DoBounceOscillation; Actor_SetScale(&this->dyna.actor, 0.0f); this->oscillationTimer = 30; - this->intenseOscillationScale = 0.0f; + this->bounceOscillationScale = 0.0f; this->dyna.actor.focus.pos.y = this->dyna.actor.home.pos.y + 10.0f; this->dyna.actor.targetMode = 3; break; @@ -299,6 +317,11 @@ void ObjEtcetera_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } +/** + * When the flower isn't animating, this function is used to draw it. + * It draws the flower as a single, non-moving display list that encompasses the whole flower. + * When an animation is finished, functions are expected to set the actor's draw function to this. + */ void ObjEtcetera_DrawIdle(Actor* thisx, GlobalContext* globalCtx) { ObjEtcetera* this = THIS; @@ -311,6 +334,11 @@ void ObjEtcetera_DrawIdle(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } +/** + * When the flower is animating, this function is used to draw it. + * It draws the flower as an animated bunch of limbs using the SkelAnime system. + * When a function wants to play an animation, it is expected to set the actor's draw function to this. + */ void ObjEtcetera_DrawAnimated(Actor* thisx, GlobalContext* globalCtx) { ObjEtcetera* this = THIS; diff --git a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h index f5642ff282..a52f5ae2ef 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h @@ -13,6 +13,26 @@ typedef enum { /* 4 */ DEKU_FLOWER_TYPE_MAX, } DekuFlowerType; +/** + * For the petal/leaf directions, "back" is negative and "front" is positive + * on the flower's local Z-axis. "Left" and "right" are relative to the front + * and back. + */ +typedef enum { + /* 0 */ DEKU_FLOWER_LIMB_NONE, + /* 1 */ DEKU_FLOWER_LIMB_BASE, + /* 2 */ DEKU_FLOWER_LIMB_CENTER, + /* 3 */ DEKU_FLOWER_LIMB_BACK_PETAL_OR_LEAF, + /* 4 */ DEKU_FLOWER_LIMB_FRONT_PETAL_OR_LEAF, + /* 5 */ DEKU_FLOWER_LIMB_FRONT_RIGHT_PETAL, + /* 6 */ DEKU_FLOWER_LIMB_BACK_RIGHT_PETAL, + /* 7 */ DEKU_FLOWER_LIMB_RIGHT_PETAL_OR_LEAF, + /* 8 */ DEKU_FLOWER_LIMB_FRONT_LEFT_PETAL, + /* 9 */ DEKU_FLOWER_LIMB_LEFT_PETAL_OR_LEAF, + /* 10 */ DEKU_FLOWER_LIMB_BACK_LEFT_PETAL, + /* 11 */ DEKU_FLOWER_LIMB_MAX, +} DekuFlowerLimbs; + struct ObjEtcetera; typedef void (*ObjEtceteraActionFunc)(struct ObjEtcetera*, GlobalContext*); @@ -21,9 +41,9 @@ typedef struct ObjEtcetera { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ SkelAnime skelAnime; /* 0x1A0 */ ColliderCylinder collider; - /* 0x1EC */ Vec3s jointTable[11]; - /* 0x22E */ Vec3s morphTable[11]; - /* 0x270 */ f32 intenseOscillationScale; + /* 0x1EC */ Vec3s jointTable[DEKU_FLOWER_LIMB_MAX]; + /* 0x22E */ Vec3s morphTable[DEKU_FLOWER_LIMB_MAX]; + /* 0x270 */ f32 bounceOscillationScale; /* 0x274 */ s16 oscillationTimer; /* 0x276 */ u16 burrowFlag; /* 0x278 */ s8 objIndex; diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index 8a67950942..e72dfb836e 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -5,6 +5,7 @@ */ #include "z_obj_flowerpot.h" +#include "objects/object_flowerpot/object_flowerpot.h" #define FLAGS 0x00000000 @@ -15,7 +16,21 @@ void ObjFlowerpot_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjFlowerpot_Update(Actor* thisx, GlobalContext* globalCtx); void ObjFlowerpot_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A1C818(ObjFlowerpot* this); +void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx); +void func_80A1CBF8(ObjFlowerpot* this); +void func_80A1CC0C(ObjFlowerpot* this, GlobalContext* globalCtx); +void func_80A1CD10(ObjFlowerpot* this); +void func_80A1CEF4(ObjFlowerpot* this2, GlobalContext* globalCtx); + +static u32 D_80A1D830; +static MtxF D_80A1D838[8]; +static s16 D_80A1DA38; +static s16 D_80A1DA3A; +static s16 D_80A1DA3C; +static s16 D_80A1DA3E; +static s16 D_80A1DA40; + const ActorInit Obj_Flowerpot_InitVars = { ACTOR_OBJ_FLOWERPOT, ACTORCAT_PROP, @@ -28,86 +43,649 @@ const ActorInit Obj_Flowerpot_InitVars = { (ActorFunc)ObjFlowerpot_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_80A1D3A0[2] = { +static ColliderJntSphElementInit sJntSphElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x05CBFFBE, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x05CBFFBE, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 100, 0 }, 12 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x0580C71C, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x0580C71C, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 1, { { 0, 300, 0 }, 12 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80A1D3E8 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 2, D_80A1D3A0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A1D414[] = { - ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1600, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), +static s16 D_80A1D3F8 = 0; + +static s16 D_80A1D3FC = 0; + +static s16 D_80A1D400 = 0; + +static u8 D_80A1D404 = true; + +static Vec3f D_80A1D408 = { 0.0f, 20.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1600, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), }; -#endif +void func_80A1B3D0(void) { + s32 i; + s32 pad; + f32 spB4; + f32* ptr; + f32 spAC; + f32 spA8; + f32 tempf1; + f32 tempf2; + f32 tempf3; + f32 tempf4; + f32 tempf5; + f32 sp74[8]; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + f32 temp_f28; + f32 temp_f0; + f32 temp_f30; -extern ColliderJntSphElementInit D_80A1D3A0[2]; -extern ColliderJntSphInit D_80A1D3E8; -extern InitChainEntry D_80A1D414[]; + D_80A1DA38 += 70; + D_80A1DA3A += 300; + D_80A1DA3C += 700; + D_80A1DA3E += 1300; + D_80A1DA40 += 8900; -extern UNK_TYPE D_060012E0; -extern UNK_TYPE D_060014F0; -extern UNK_TYPE D_060015B0; + temp_f28 = Math_SinS(D_80A1DA38); + spB4 = Math_SinS(D_80A1DA3A); + temp_f30 = Math_SinS(D_80A1DA3C); + spAC = Math_SinS(D_80A1DA3E); + spA8 = Math_SinS(D_80A1DA40); + temp_f26 = Math_CosS(D_80A1DA38); + temp_f20 = Math_CosS(D_80A1DA3A); + temp_f22 = Math_CosS(D_80A1DA3C); + temp_f24 = Math_CosS(D_80A1DA3E); + temp_f0 = Math_CosS(D_80A1DA40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1B3D0.s") + sp74[0] = (temp_f28 - temp_f20) * temp_f30 * temp_f26 * temp_f28 * 0.0012f; + sp74[1] = (spB4 - temp_f22) * spAC * temp_f20 * temp_f28 * 0.0012f; + sp74[2] = (temp_f30 - temp_f24) * temp_f22 * temp_f28 * temp_f26 * 0.0012f; + sp74[3] = (spAC - temp_f20) * temp_f24 * spB4 * temp_f26 * 0.0012f; + sp74[4] = (temp_f28 - temp_f22) * temp_f28 * spB4 * spA8 * 0.0013f; + sp74[5] = (spB4 - temp_f24) * temp_f30 * spAC * spA8 * 0.0013f; + sp74[6] = (temp_f30 - temp_f26) * temp_f26 * temp_f20 * temp_f0 * 0.0013f; + sp74[7] = (spAC - temp_f20) * temp_f22 * temp_f24 * temp_f0 * 0.0013f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1B840.s") + for (i = 0; i < ARRAY_COUNT(D_80A1D838); i++) { + ptr = (f32*)&D_80A1D838[i].mf[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1B914.s") + tempf1 = sp74[(i + 0) & 7]; + tempf2 = sp74[(i + 1) & 7]; + tempf3 = sp74[(i + 2) & 7]; + tempf4 = sp74[(i + 3) & 7]; + tempf5 = sp74[(i + 4) & 7]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1B994.s") + ptr[0] = sp74[1] * 0.2f; + ptr[1] = tempf1; + ptr[2] = tempf2; + ptr[3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1B9CC.s") + ptr[4] = tempf3; + ptr[5] = sp74[0]; + ptr[6] = tempf3; + ptr[7] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1BA04.s") + ptr[8] = tempf4; + ptr[9] = tempf5; + ptr[10] = sp74[3] * 0.2f; + ptr[11] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1BA44.s") + ptr[12] = 0.0f; + ptr[13] = 0.0f; + ptr[14] = 0.0f; + ptr[15] = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1BD80.s") +void func_80A1B840(MtxF* matrix) { + MtxF* temp = Matrix_GetCurrentState(); + f32* tmp = (f32*)&temp->mf[0]; + f32* tmp2 = (f32*)&matrix->mf[0]; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1C0FC.s") + for (i = 0; i < 16; i++) { + *tmp++ += *tmp2++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1C328.s") +void func_80A1B914(ObjFlowerpot* this, GlobalContext* globalCtx) { + if (!(this->unk_1EA & 4)) { + s32 temp_v0 = func_800A8150(ENOBJFLOWERPOT_GET_3F(&this->actor)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1C554.s") + if (temp_v0 >= 0) { + s32 params = ENOBJFLOWERPOT_GET_7F00(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1C5E8.s") + Item_DropCollectible(globalCtx, &this->actor.world.pos, temp_v0 | (params << 8)); + this->unk_1EA |= 4; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1C62C.s") +void func_80A1B994(ObjFlowerpot* this, GlobalContext* globalCtx) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/ObjFlowerpot_Init.s") +void func_80A1B9CC(ObjFlowerpot* this, GlobalContext* globalCtx) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/ObjFlowerpot_Destroy.s") +void func_80A1BA04(ObjFlowerpot* this, Vec3f* arg1) { + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_MultiplyVector3fByState(&D_80A1D408, arg1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1C818.s") +void func_80A1BA44(ObjFlowerpot* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spD0; + Vec3f spC4; + Vec3f spB8; + f32 temp_f0; + f32 temp_f20; + s16 phi_s3; + s32 phi_s0; + s32 phi_s1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1C838.s") + spD0.x = this->actor.world.pos.x; + spD0.y = this->actor.world.pos.y; + spD0.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1CBF8.s") + for (i = 0, phi_s3 = 0; i < 18; i++, phi_s3 += 0xE38) { + temp_f20 = (Rand_ZeroOne() * 8.0f) + 2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1CC0C.s") + spC4.x = Math_SinS((s32)(Rand_ZeroOne() * 3640.0f) + phi_s3) * temp_f20; + spC4.y = Rand_ZeroOne() * 30.0f; + spC4.z = Math_CosS((s32)(Rand_ZeroOne() * 3640.0f) + phi_s3) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1CD10.s") + spB8.x = spC4.x * 0.27f; + spB8.y = (Rand_ZeroOne() * 6.0f) + 2.6f + ((30.0f - spC4.y) * 0.2f); + spB8.z = spC4.z * 0.27f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1CEF4.s") + Math_Vec3f_Sum(&spC4, &spD0, &spC4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/ObjFlowerpot_Update.s") + temp_f0 = Rand_ZeroOne(); + if (temp_f0 < 0.2f) { + phi_s0 = 32; + phi_s1 = 0; + } else if (temp_f0 < 0.6f) { + phi_s0 = 65; + phi_s1 = 1; + } else { + phi_s0 = 64; + phi_s1 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/ObjFlowerpot_Draw.s") + EffectSsKakera_Spawn(globalCtx, &spC4, &spB8, &spC4, -600, phi_s0, 30, 0, 0, (Rand_ZeroOne() * 12.0f) + 16.6f, + phi_s1, 0, 35, -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0015B0); + } + + spD0.y += 20.0f; + + func_800BBFB0(globalCtx, &spD0, 30.0f, 2, 20, 50, 1); + func_800BBFB0(globalCtx, &spD0, 30.0f, 2, 10, 80, 1); + func_800BBFB0(globalCtx, &spD0, 30.0f, 1, 10, 40, 1); +} + +void func_80A1BD80(ObjFlowerpot* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + f32 temp_f20; + s16 phi_s1; + s32 phi_s0; + + spC8.x = this->actor.world.pos.x; + spC8.y = this->actor.world.pos.y; + spC8.z = this->actor.world.pos.z; + + for (i = 0, phi_s1 = 0; i < 14; i++, phi_s1 += 0x1249) { + temp_f20 = (Rand_ZeroOne() * 8.0f) + 2.0f; + + spBC.x = Math_SinS((s32)(Rand_ZeroOne() * 4681.0f) + phi_s1) * temp_f20; + spBC.y = Rand_ZeroOne() * 20.0f; + spBC.z = Math_CosS((s32)(Rand_ZeroOne() * 4681.0f) + phi_s1) * temp_f20; + + spB0.x = spBC.x * 0.17f; + spB0.y = (Rand_ZeroOne() * 5.0f) + 1.4f; + spB0.z = spBC.z * 0.17f; + + Math_Vec3f_Sum(&spBC, &spC8, &spBC); + + if (Rand_ZeroOne() < 0.2f) { + phi_s0 = 64; + } else { + phi_s0 = 32; + } + + EffectSsKakera_Spawn(globalCtx, &spBC, &spB0, &spBC, -240, phi_s0, 40, 0, 0, (Rand_ZeroOne() * 20.0f) + 10.6f, + 0, 0, 42, -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0015B0); + } + + spBC.y = this->actor.world.pos.y + this->actor.depthInWater; + + for (phi_s1 = 0, i = 0; i < 4; i++, phi_s1 += 0x4000) { + spBC.x = (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s1) * 15.0f) + this->actor.world.pos.x; + spBC.z = (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s1) * 15.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &spBC, NULL, NULL, 0, 200); + } + + spBC.x = this->actor.world.pos.x; + spBC.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &spBC, NULL, NULL, 0, 350); + EffectSsGRipple_Spawn(globalCtx, &spBC, 150, 650, 0); +} + +void func_80A1C0FC(ObjFlowerpot* this, GlobalContext* globalCtx) { + Vec3f spC4; + Vec3f spB8; + Vec3f spAC; + f32 temp_f20; + s16 phi_s0; + s32 i; + + func_80A1BA04(this, &spC4); + + for (i = 0, phi_s0 = 0; i < 10; i++, phi_s0 += 0x1999) { + temp_f20 = (Rand_ZeroOne() * 18.0f) + 2.0f; + + spB8.x = Math_SinS((s32)(Rand_ZeroOne() * 6553.0f) + phi_s0) * temp_f20; + spB8.y = Rand_ZeroOne() * 15.0f; + spB8.z = Math_CosS((s32)(Rand_ZeroOne() * 6553.0f) + phi_s0) * temp_f20; + + spAC.x = spB8.x * 0.23f; + spAC.y = (Rand_ZeroOne() * 8.0f) + 1.5f; + spAC.z = spB8.z * 0.23f; + + Math_Vec3f_Sum(&spB8, &spC4, &spB8); + EffectSsKakera_Spawn(globalCtx, &spB8, &spAC, &spB8, -100, 64, 40, 0, 0, (Rand_ZeroOne() * 16.0f) + 14.0f, 0, 0, + 80, -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0014F0); + } +} + +void func_80A1C328(ObjFlowerpot* this, GlobalContext* globalCtx) { + Vec3f spC4; + Vec3f spB8; + Vec3f spAC; + f32 temp_f20; + s16 phi_s0; + s32 i; + + func_80A1BA04(this, &spC4); + + for (i = 0, phi_s0 = 0; i < 10; i++, phi_s0 += 0x1999) { + temp_f20 = (Rand_ZeroOne() * 18.0f) + 2.0f; + + spB8.x = Math_SinS((s32)(Rand_ZeroOne() * 6553.0f) + phi_s0) * temp_f20; + spB8.y = Rand_ZeroOne() * 15.0f; + spB8.z = Math_CosS((s32)(Rand_ZeroOne() * 6553.0f) + phi_s0) * temp_f20; + + spAC.x = spB8.x * 0.18f; + spAC.y = (Rand_ZeroOne() * 4.0f) + 1.2f; + spAC.z = spB8.z * 0.18f; + + Math_Vec3f_Sum(&spB8, &spC4, &spB8); + EffectSsKakera_Spawn(globalCtx, &spB8, &spAC, &spB8, -80, 64, 44, 0, 0, (Rand_ZeroOne() * 16.0f) + 14.0f, 0, 0, + 80, -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0014F0); + } +} + +void func_80A1C554(ObjFlowerpot* this) { + if ((this->actor.projectedPos.z < 455.0f) && (this->actor.projectedPos.z > -10.0f)) { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.shape.shadowScale = 1.9f; + if (this->actor.projectedPos.z < 255.0f) { + this->actor.shape.shadowAlpha = 200; + } else { + this->actor.shape.shadowAlpha = 455 - (s32)this->actor.projectedPos.z; + } + } else { + this->actor.shape.shadowDraw = NULL; + } +} + +void func_80A1C5E8(ObjFlowerpot* this, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); +} + +void func_80A1C62C(ObjFlowerpot* this, GlobalContext* globalCtx) { + if (!(this->unk_1EA & 4) && (globalCtx->roomCtx.currRoom.num != this->unk_1EC)) { + this->unk_1EA |= 4; + } +} + +void ObjFlowerpot_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjFlowerpot* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (this->actor.shape.rot.y == 0) { + this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + } + + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + Matrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + &this->actor.shape.rot); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Collider_UpdateSpheres(0, &this->collider); + Collider_UpdateSpheres(1, &this->collider); + + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_1EC = this->actor.room; + func_80A1C818(this); + + if (D_80A1D404) { + D_80A1DA38 = (u32)Rand_Next() >> 0x10; + D_80A1DA3A = (u32)Rand_Next() >> 0x10; + D_80A1DA3C = (u32)Rand_Next() >> 0x10; + D_80A1DA3E = (u32)Rand_Next() >> 0x10; + D_80A1DA40 = (u32)Rand_Next() >> 0x10; + D_80A1D404 = false; + func_80A1B3D0(); + D_80A1D830 = globalCtx->gameplayFrames; + } + this->unk_1EB = D_80A1D400 & 7; + D_80A1D400++; +} + +void ObjFlowerpot_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyJntSph(globalCtx, &THIS->collider); +} + +void func_80A1C818(ObjFlowerpot* this) { + this->actionFunc = func_80A1C838; + this->unk_1EA |= 1; +} + +void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { + s32 pad; + + if (Actor_HasParent(&this->actor, globalCtx)) { + func_80A1CBF8(this); + this->actor.room = -1; + this->actor.colChkInfo.mass = 180; + this->actor.flags |= 0x10; + if (func_800A817C(ENOBJFLOWERPOT_GET_3F(&this->actor))) { + func_80A1B914(this, globalCtx); + } + + //! @bug: This function should only pass Player*: it uses *(this + 0x153), which is meant to be + //! player->currentMask, but in this case is garbage in the collider + func_800B8E58((Player*)this, NA_SE_PL_PULL_UP_POT); + } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 19.0f)) { + if (!(this->unk_1EA & 2)) { + func_80A1B914(this, globalCtx); + func_80A1C328(this, globalCtx); + func_80A1B9CC(this, globalCtx); + this->unk_1EA |= 2; + } + func_80A1BD80(this, globalCtx); + func_80A1B994(this, globalCtx); + Actor_MarkForDeath(&this->actor); + } else if ((this->collider.elements[0].info.bumperFlags & 2) && + (this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x058BFFBC)) { + if (!(this->unk_1EA & 2)) { + func_80A1B914(this, globalCtx); + func_80A1C0FC(this, globalCtx); + func_80A1B9CC(this, globalCtx); + this->unk_1EA |= 2; + } + func_80A1BA44(this, globalCtx); + func_80A1B994(this, globalCtx); + Actor_MarkForDeath(&this->actor); + } else { + if (this->collider.elements[1].info.bumperFlags & 2) { + if (!(this->unk_1EA & 2)) { + this->unk_1EA |= 2; + this->collider.elements[1].info.bumperFlags &= ~0x1; + func_80A1C0FC(this, globalCtx); + func_80A1B914(this, globalCtx); + func_80A1B9CC(this, globalCtx); + } + } + + if (this->unk_1EA & 1) { + Actor_MoveWithGravity(&this->actor); + func_80A1C5E8(this, globalCtx); + if (this->actor.bgCheckFlags & 1) { + if (this->actor.colChkInfo.mass == MASS_IMMOVABLE) { + if (DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId) == NULL) { + this->actor.flags &= ~0x10; + this->unk_1EA &= ~0x1; + } + } else if (Math3D_Vec3fDistSq(&this->actor.world.pos, &this->actor.prevPos) < 0.01f) { + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } + } + } + + if (!(this->collider.base.ocFlags1 & OC1_TYPE_PLAYER) && (this->actor.xzDistToPlayer > 28.0f)) { + this->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; + } + + this->collider.base.acFlags &= ~AC_HIT; + + if (this->actor.xzDistToPlayer < 600.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actor.xzDistToPlayer < 180.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actor.xzDistToPlayer < 100.0f) { + s16 temp_v0_3 = this->actor.yawTowardsPlayer - GET_PLAYER(globalCtx)->actor.world.rot.y; + + if (ABS_ALT(temp_v0_3) >= 0x5556) { + Actor_PickUp(&this->actor, globalCtx, 0, 36.0f, 30.0f); + } + } + } + } + } +} + +void func_80A1CBF8(ObjFlowerpot* this) { + this->actionFunc = func_80A1CC0C; +} + +void func_80A1CC0C(ObjFlowerpot* this, GlobalContext* globalCtx) { + s32 pad; + + func_80A1C62C(this, globalCtx); + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + this->actor.room = globalCtx->roomCtx.currRoom.num; + if (fabsf(this->actor.speedXZ) < 0.1f) { + func_80A1C818(this); + func_800B8E58(GET_PLAYER(globalCtx), NA_SE_PL_PUT_DOWN_POT); + this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; + } else { + Actor_MoveWithGravity(&this->actor); + func_80A1CD10(this); + } + func_80A1C5E8(this, globalCtx); + } else { + Vec3f sp30; + s32 sp2C; + + sp30.x = this->actor.world.pos.x; + sp30.y = this->actor.world.pos.y + 20.0f; + sp30.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); + } +} + +void func_80A1CD10(ObjFlowerpot* this) { + f32 sp1C; + + this->actionFunc = func_80A1CEF4; + this->unk_1E8 = 64; + + if (this->unk_1EA & 2) { + sp1C = (Rand_ZeroOne() * 1.2f) - 1.1f; + if (sp1C < -0.9f) { + sp1C = -0.9f; + } + D_80A1D3F8 = sp1C * 8000.0f; + D_80A1D3FC = ((Rand_ZeroOne() - 0.5f) * 3800.0f) * (fabsf(sp1C) + 0.1f); + this->actor.shape.yOffset = -71.5f; + this->actor.world.pos.y += 7.15f; + } else { + sp1C = (Rand_ZeroOne() - 0.78f) * 1.3f; + if (sp1C < -0.78f) { + sp1C = -0.78f; + } else if (sp1C > 0.22000003f) { + sp1C = 0.22000003f; + } + D_80A1D3F8 = sp1C * 6200.0f; + D_80A1D3FC = (Rand_ZeroOne() - 0.5f) * 4200.0f; + this->actor.shape.yOffset = -110.0f; + this->actor.world.pos.y += 11.0f; + } +} + +void func_80A1CEF4(ObjFlowerpot* this2, GlobalContext* globalCtx) { + ObjFlowerpot* this = this2; + s32 sp28 = this->collider.elements[0].info.toucherFlags & TOUCH_HIT; + + if (sp28) { + this->collider.elements[0].info.toucherFlags &= ~TOUCH_ON; + } + + if (this->unk_1E8 > 0) { + this->unk_1E8--; + } + + func_80A1C62C(this, globalCtx); + + if ((this->actor.bgCheckFlags & (0x8 | 0x2 | 0x1)) || sp28 || (this->unk_1E8 <= 0)) { + if (!(this->unk_1EA & 2)) { + func_80A1B914(this, globalCtx); + func_80A1C0FC(this, globalCtx); + func_80A1B9CC(this, globalCtx); + this->unk_1EA |= 2; + } + func_80A1BA44(this, globalCtx); + func_80A1B994(this, globalCtx); + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->actor.bgCheckFlags & 0x40) { + if (!(this->unk_1EA & 2)) { + func_80A1B914(this, globalCtx); + func_80A1C328(this, globalCtx); + func_80A1B9CC(this, globalCtx); + this->unk_1EA |= 2; + } + func_80A1BD80(this, globalCtx); + func_80A1B994(this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + Actor_MarkForDeath(&this->actor); + return; + } + + Actor_MoveWithGravity(&this->actor); + + if (!(this->unk_1EA & 2)) { + D_80A1D3F8 += (s16)(this->actor.shape.rot.x * -0.06f); + } else { + Math_StepToS(&D_80A1D3F8, 0, 80); + Math_StepToS(&D_80A1D3FC, 0, 20); + } + + this->actor.shape.rot.x += D_80A1D3F8; + this->actor.shape.rot.y += D_80A1D3FC; + + func_80A1C5E8(this, globalCtx); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjFlowerpot_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjFlowerpot* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80A1C554(this); + + if ((D_80A1D830 != globalCtx->gameplayFrames) && (globalCtx->roomCtx.currRoom.unk3 == 0)) { + func_80A1B3D0(); + D_80A1D830 = globalCtx->gameplayFrames; + } +} + +void ObjFlowerpot_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjFlowerpot* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_flowerpot_DL_0012E0); + + if ((this->actionFunc != func_80A1C838) || (this->unk_1EA & 1)) { + Collider_UpdateSpheres(0, &this->collider); + if (!(this->unk_1EA & 2)) { + Collider_UpdateSpheres(1, &this->collider); + } + } + + if (!(this->unk_1EA & 2)) { + if ((globalCtx->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == func_80A1C838)) { + if ((this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { + func_80A1B840(&D_80A1D838[this->unk_1EB]); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + } + + gSPDisplayList(POLY_OPA_DISP++, object_flowerpot_DL_001408); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h index 3396a1abaf..01557bc2bb 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h @@ -7,11 +7,18 @@ struct ObjFlowerpot; typedef void (*ObjFlowerpotActionFunc)(struct ObjFlowerpot*, GlobalContext*); +#define ENOBJFLOWERPOT_GET_3F(thisx) ((thisx)->params & 0x3F) +#define ENOBJFLOWERPOT_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + typedef struct ObjFlowerpot { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xA0]; + /* 0x0144 */ ColliderJntSph collider; + /* 0x0164 */ ColliderJntSphElement colliderElements[2]; /* 0x01E4 */ ObjFlowerpotActionFunc actionFunc; - /* 0x01E8 */ char unk_1E8[0x8]; + /* 0x01E8 */ s16 unk_1E8; + /* 0x01EA */ u8 unk_1EA; + /* 0x01EB */ s8 unk_1EB; + /* 0x01EC */ s8 unk_1EC; } ObjFlowerpot; // size = 0x1F0 extern const ActorInit Obj_Flowerpot_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c index 4cfc3fcf7b..060a4e0c03 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -75,7 +75,7 @@ void func_80B3C39C(ObjGhaka* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 distDiff = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.shape.rot.y; - if (func_800B84D0(&this->dyna.actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { func_80B3C29C(this); } else if (this->dyna.actor.xzDistToPlayer < 100.0f || this->dyna.actor.isTargeted) { if (distDiff <= -0x5556 || distDiff >= 0x5556) { @@ -97,7 +97,7 @@ void func_80B3C39C(ObjGhaka* this, GlobalContext* globalCtx) { } void func_80B3C4E0(ObjGhaka* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { if (func_80147624(globalCtx)) { @@ -140,9 +140,9 @@ void func_80B3C624(ObjGhaka* this, GlobalContext* globalCtx) { func_80B3C2C4(this, globalCtx); gSaveContext.weekEventReg[20] |= 0x20; func_80B3C260(this); - func_8019F1C0(&D_80B3C960, NA_SE_EV_BLOCK_BOUND); + Audio_PlaySfxAtPos(&D_80B3C960, NA_SE_EV_BLOCK_BOUND); } else { - func_8019F1C0(&D_80B3C960, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + Audio_PlaySfxAtPos(&D_80B3C960, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); } } diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c index af5ebd44a9..4d717fabd7 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c @@ -37,7 +37,7 @@ static ColliderCylinderInit D_809ABBD0 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_809ABC4C[] = { ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -17000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_STOP), }; diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h index 22a38fef1e..5c6f1a64ae 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h @@ -11,7 +11,9 @@ typedef struct ObjHakaisi { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x18]; /* 0x015C */ ObjHakaisiActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x40]; + /* 0x0160 */ char unk_160[0x38]; + /* 0x0198 */ s16 unk_198; + /* 0x019A */ char unk_19A[0x6]; } ObjHakaisi; // size = 0x1A0 extern const ActorInit Obj_Hakaisi_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c b/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c index b82932eaa5..d7e0d66332 100644 --- a/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c +++ b/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c @@ -49,5 +49,5 @@ void ObjHana_Update(Actor* thisx, GlobalContext* globalCtx) { } void ObjHana_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000500); + Gfx_DrawDListOpa(globalCtx, D_06000500); } diff --git a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c index 0b32504fa1..c11fa4903c 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c @@ -49,7 +49,7 @@ static s32 unused = 0; static s32 unused2 = 0; void ObjHgdoor_SetChild(ObjHgdoor* this, GlobalContext* globalCtx) { - Actor* actorIterator = globalCtx->actorCtx.actorList[ACTORCAT_PROP].first; + Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; while (actorIterator) { if ((actorIterator->id == ACTOR_OBJ_HGDOOR) && (&this->dyna.actor != actorIterator)) { @@ -61,7 +61,7 @@ void ObjHgdoor_SetChild(ObjHgdoor* this, GlobalContext* globalCtx) { } void ObjHgdoor_SetParent(ObjHgdoor* this, GlobalContext* globalCtx) { - Actor* actorIterator = globalCtx->actorCtx.actorList[ACTORCAT_PROP].first; + Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; while (actorIterator) { if (actorIterator->id == ACTOR_EN_HG) { @@ -142,7 +142,7 @@ void func_80BD4358(ObjHgdoor* this, GlobalContext* globalCtx) { this->unk166 = globalCtx->csCtx.npcActions[actionIndex]->unk0; switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { case 1: - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WOOD_DOOR_OPEN_SPEEDY); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOOD_DOOR_OPEN_SPEEDY); if ((this->dyna.actor.parent != NULL) && (this->dyna.actor.parent->id == ACTOR_EN_HG)) { this->dyna.actor.parent->colChkInfo.health = 1; } diff --git a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c index cca1b99224..cf84a1bd7e 100644 --- a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c +++ b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c @@ -116,7 +116,7 @@ void ObjHsStump_Appear(ObjHsStump* this, GlobalContext* globalCtx) { offsetAngle = i * angleBinary; Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.world.pos, offsetAngle, &iceSmokePosOffset, &iceSmokePos); - Lib_Vec3f_TranslateAndRotateY(&D_801D15B0, offsetAngle, &iceSmokeVelOffset, &iceSmokeVel); + Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, offsetAngle, &iceSmokeVelOffset, &iceSmokeVel); EffectSsIceSmoke_Spawn(globalCtx, &iceSmokePos, &iceSmokeVel, &iceSmokeAccel, 100); } } @@ -146,5 +146,5 @@ void ObjHsStump_Update(Actor* thisx, GlobalContext* globalCtx) { } void ObjHsStump_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_060003B8); + Gfx_DrawDListOpa(globalCtx, D_060003B8); } diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c index 6731feda71..b4004c1809 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -5,6 +5,7 @@ */ #include "z_obj_hugebombiwa.h" +#include "objects/object_bombiwa/object_bombiwa.h" #define FLAGS 0x00000010 @@ -15,7 +16,16 @@ void ObjHugebombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHugebombiwa_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHugebombiwa_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A54BF0(ObjHugebombiwa* this); +void func_80A54C04(ObjHugebombiwa* this, GlobalContext* globalCtx); +void func_80A54CD8(ObjHugebombiwa* this); +void func_80A54CEC(ObjHugebombiwa* this, GlobalContext* globalCtx); +void func_80A54E10(ObjHugebombiwa* this); +void func_80A55064(ObjHugebombiwa* this, GlobalContext* globalCtx); +void func_80A55310(ObjHugebombiwa* this); +void func_80A55564(ObjHugebombiwa* this, GlobalContext* globalCtx); +void func_80A55B34(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Hugebombiwa_InitVars = { ACTOR_OBJ_HUGEBOMBIWA, ACTORCAT_PROP, @@ -28,64 +38,683 @@ const ActorInit Obj_Hugebombiwa_InitVars = { (ActorFunc)ObjHugebombiwa_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A55D00 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x81C37BB6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x81C37BB6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 180, 226, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A55D7C[] = { +static Vec3f D_80A55D2C = { 0.0f, 0.3f, 0.0f }; + +void func_80A53BE0(GlobalContext* globalCtx, Vec3f* arg1) { + Vec3f spBC; + Vec3f spB0; + s32 i; + s32 gravity; + s16 phi_v0; + s16 life; + s16 phi_v1; + + for (i = 0, gravity = -300; i < 16; i++, gravity -= 30) { + spBC.x = (Rand_ZeroOne() - 0.5f) * 260.0f; + spBC.y = i * (40.0f / 3); + spBC.z = (Rand_ZeroOne() - 0.5f) * 260.0f; + + spB0.x = ((Rand_ZeroOne() - 0.5f) * 5.7f) + (spBC.x * 0.035f); + spB0.y = (Rand_ZeroOne() * 16.0f) + 5.0f + ((16 - i) * 0.25f); + spB0.z = ((Rand_ZeroOne() - 0.5f) * 5.7f) + (spBC.z * 0.035f); + + spBC.x += arg1->x; + spBC.y += arg1->y; + spBC.z += arg1->z; + + if (i >= 14) { + phi_v0 = 37; + life = 70; + } else { + phi_v0 = 65; + if (i >= 12) { + life = 70; + } else { + life = 40; + if (Rand_ZeroOne() < 0.7f) { + phi_v0 = 64; + } else { + phi_v0 = 32; + } + } + } + + phi_v1 = i; + if (phi_v1 <= 0) { + phi_v1 = 1; + if (1) {} + } + + EffectSsKakera_Spawn(globalCtx, &spBC, &spB0, &spBC, gravity, phi_v0, 15, 0, 0, phi_v1, 1, 0, life, -1, + OBJECT_BOMBIWA, object_bombiwa_DL_001990); + } +} + +void func_80A53E60(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3) { + static Color_RGBA8 D_80A55D38 = { 210, 210, 210, 255 }; + static Color_RGBA8 D_80A55D3C = { 140, 140, 140, 255 }; + static f32 D_80A55D40[] = { 3.0f, 5.0f, 9.0f, 18.0f }; + Vec3f spDC; + Vec3f spD0; + s32 i; + f32 temp_f0; + s32 phi_s1; + s32 phi_s2; + s32 phi_v0; + s32 phi_v1; + s16 phi_s0; + s32 pad; + + for (phi_s2 = -300, i = 0; phi_s2 > -540; phi_s2 -= 60, i++) { + spDC.x = (Rand_ZeroOne() - 0.5f) * 11.0f; + spDC.y = (Rand_ZeroOne() - 0.2f) * 8.0f; + spDC.z = (Rand_ZeroOne() - 0.5f) * 11.0f; + + spD0.x = ((Rand_ZeroOne() - 0.5f) * 5.0f) + (spDC.x * 1.4f); + spD0.y = (Rand_ZeroOne() * 13.0f) + 8.2f + (arg2 * -0.26f); + if (1) {} + spD0.z = ((Rand_ZeroOne() - 0.5f) * 5.0f) + (spDC.z * 1.4f); + + spDC.x += arg1->x; + spDC.y += arg1->y; + spDC.z += arg1->z; + + if ((s32)(phi_s2 & 0xFFFFFFFF) == -480) { + phi_v0 = 33; + phi_s0 = 70; + } else { + phi_v0 = 65; + if (phi_s2 == -420) { + phi_s0 = 70; + } else { + phi_s0 = 40; + if (Rand_ZeroOne() < 0.7f) { + phi_v0 = 64; + } else { + phi_v0 = 32; + } + } + } + + temp_f0 = D_80A55D40[i] * arg3; + if (temp_f0 <= 1.0f) { + phi_v1 = 1; + } else { + phi_v1 = temp_f0; + } + + EffectSsKakera_Spawn(globalCtx, &spDC, &spD0, &spDC, phi_s2, phi_v0, 15, 0, 0, phi_v1, 1, 0, phi_s0, -1, + OBJECT_BOMBIWA, object_bombiwa_DL_001990); + + spDC.x += (Rand_ZeroOne() - 0.5f) * 270.0f; + spDC.y += (Rand_ZeroOne() - 0.1f) * 150.0f; + spDC.z += (Rand_ZeroOne() - 0.5f) * 270.0f; + + phi_s0 = (Rand_ZeroOne() * 160.0f) + 140.0f; + phi_s1 = (Rand_ZeroOne() * 180.0f) + 120.0f; + func_800B0E48(globalCtx, &spDC, &gZeroVec3f, &D_80A55D2C, &D_80A55D38, &D_80A55D3C, phi_s0, phi_s1); + } +} + +void func_80A541F4(ObjHugebombiwa* this, GlobalContext* globalCtx) { + static s16 D_80A55D50[] = { 24, 17, 13, 7, 6, 5, 3, 2 }; + s32 i; + s32 pad[2]; + s32 phi_s2; + Vec3f spF4; + Vec3f spE8; + Vec3f spDC; + Vec3f spD0; + Vec3f spC4; + f32 temp_f0; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + s32 phi_s0; + f32 phi_f30; + + for (i = 0, phi_s2 = 0, phi_f30 = 0.0f; i < 13; i++, phi_s2 += 0x4E20, phi_f30 += (230.0f / 13)) { + temp_f0 = Rand_ZeroOne(); + temp_f22 = (1.0f - SQ(temp_f0)) * 120.0f; + temp_f20 = Math_SinS(phi_s2 & 0xFFFF); + temp_f24 = Math_CosS(phi_s2 & 0xFFFF); + + spF4.x = (temp_f20 * temp_f22) + this->actor.world.pos.x; + spF4.y = this->actor.world.pos.y + phi_f30; + spF4.z = (temp_f24 * temp_f22) + this->actor.world.pos.z; + + spE8.x = temp_f20 * 10.0f; + spE8.y = (Rand_ZeroOne() * 18.0f) + 10.0f; + spE8.z = temp_f24 * 10.0f; + + EffectSsKakera_Spawn(globalCtx, &spF4, &spE8, &spF4, -650, 37, 15, 0, 0, D_80A55D50[i & 7], 1, 0, 60, -1, + OBJECT_BOMBIWA, object_bombiwa_DL_0009E0); + + spDC.x = ((Rand_ZeroOne() - 0.5f) * 230.0f) + spF4.x; + spDC.y = ((Rand_ZeroOne() - 0.2f) * 200.0f) + spF4.y; + spDC.z = ((Rand_ZeroOne() - 0.5f) * 230.0f) + spF4.z; + + spD0.x = temp_f20 * 7.0f; + spD0.y = -7.0f; + spD0.z = temp_f24 * 7.0f; + + spC4.x = temp_f20 * -0.07f; + spC4.y = 0.24f; + spC4.z = temp_f24 * -0.07f; + + func_800B12F0(globalCtx, &spDC, &spD0, &spC4, (s32)(Rand_ZeroOne() * 800.0f) + 1000, -49, 20); + + spDC.x = ((Rand_ZeroOne() - 0.5f) * 160.0f) + spF4.x; + spDC.y = ((Rand_ZeroOne() - 0.2f) * 140.0f) + spF4.y; + spDC.z = ((Rand_ZeroOne() - 0.5f) * 160.0f) + spF4.z; + + spD0.x = temp_f20 * 15.0f; + spD0.y = 0.0f; + spD0.z = temp_f24 * 15.0f; + + spC4.x = temp_f20 * -0.09f; + spC4.y = 0.3f; + spC4.z = temp_f24 * -0.09f; + + func_800B12F0(globalCtx, &spDC, &spD0, &spC4, (s32)(Rand_ZeroOne() * 100.0f) + 40, + (s32)(Rand_ZeroOne() * 200.0f) + 20, 10); + } +} + +void func_80A54600(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3) { + static f32 D_80A55D60[] = { 3.0f, 5.0f, 9.0f, 18.0f }; + static s8 D_80A55D70 = 0; + Vec3f spCC; + Vec3f spC0; + s32 i; + f32 spA0; + s16 temp_s0; + s16 temp_s1; + s32 phi_v0; + s16 phi_v1; + f32 temp; + + for (i = 0; i < 2; i++) { + spCC.x = (Rand_ZeroOne() - 0.5f) * 11.0f; + spCC.y = (Rand_ZeroOne() - 0.2f) * 8.0f; + spCC.z = (Rand_ZeroOne() - 0.5f) * 11.0f; + + spC0.x = ((Rand_ZeroOne() - 0.5f) * 5.0f) + (spCC.x * 1.4f); + spC0.y = (Rand_ZeroOne() * 13.0f) + 8.2f + (arg2 * -0.38f); + spC0.z = ((Rand_ZeroOne() - 0.5f) * 5.0f) + (spCC.z * 1.4f); + + spCC.x += arg1->x; + spCC.y += arg1->y; + spCC.z += arg1->z; + + temp = D_80A55D60[D_80A55D70] * arg3; + phi_v1 = (D_80A55D70 * -90) - 350; + D_80A55D70++; + D_80A55D70 &= 3; + + if (temp <= 1.0f) { + phi_v0 = 1; + } else { + phi_v0 = temp; + } + + EffectSsKakera_Spawn(globalCtx, &spCC, &spC0, &spCC, phi_v1, 33, 15, 0, 0, phi_v0, 1, 0, 70, -1, OBJECT_BOMBIWA, + object_bombiwa_DL_0009E0); + + spCC.x += (Rand_ZeroOne() - 0.5f) * 270.0f; + spCC.y += (Rand_ZeroOne() - 0.1f) * 150.0f; + spCC.z += (Rand_ZeroOne() - 0.5f) * 270.0f; + + temp_s0 = (Rand_ZeroOne() * 160.0f) + 140.0f; + temp_s1 = (Rand_ZeroOne() * 180.0f) + 120.0f; + func_800B1210(globalCtx, &spCC, &gZeroVec3f, &D_80A55D2C, temp_s0, temp_s1); + } +} + +void func_80A54980(ObjHugebombiwa* this, GlobalContext* globalCtx, s32 arg2) { + s32 pad[2]; + s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + + Quake_SetSpeed(quake, 0x4E20); + Quake_SetQuakeValues(quake, arg2, 0, 0, 0); + Quake_SetCountdown(quake, 7); + func_8013ECE0(this->actor.xyzDistToPlayerSq, 255, 20, 150); +} + +s32 func_80A54A0C(ObjHugebombiwa* this) { + static f32 D_80A55D74[] = { 62500.0f, 108900.0f }; + s32 sp2C; + Actor* ac; + s32 params; + Vec3f sp20; + + if ((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000)) { + ac = this->collider.base.ac; + params = ENHUGEBOMBIWA_GET_100(&this->actor); + + sp20.x = this->actor.world.pos.x; + sp20.y = this->actor.world.pos.y + 50.0f; + sp20.z = this->actor.world.pos.z; + if (ac != NULL) { + if (Math3D_Vec3fDistSq(&sp20, &ac->world.pos) < D_80A55D74[params]) { + return true; + } + } + } + return false; +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 3700, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 900, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 900, ICHAIN_STOP), }; -#endif +void ObjHugebombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjHugebombiwa* this = THIS; -extern ColliderCylinderInit D_80A55D00; -extern InitChainEntry D_80A55D7C[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitCylinder(globalCtx, &this->collider); -extern UNK_TYPE D_060009E0; -extern UNK_TYPE D_06001820; -extern UNK_TYPE D_06001990; -extern UNK_TYPE D_06002F60; + if (Flags_GetSwitch(globalCtx, ENHUGEBOMBIWA_GET_7F(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A53BE0.s") + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + if ((ENHUGEBOMBIWA_GET_100(&this->actor)) == 1) { + this->actor.draw = func_80A55B34; + Actor_SetScale(&this->actor, 0.74f); + this->collider.dim.radius = 204; + this->collider.dim.height = 230; + } else { + Actor_SetScale(&this->actor, 0.067f); + this->collider.dim.radius = 120; + this->collider.dim.height = 151; + } + func_80A54BF0(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A53E60.s") +void ObjHugebombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyCylinder(globalCtx, &THIS->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A541F4.s") +void func_80A54BF0(ObjHugebombiwa* this) { + this->actionFunc = func_80A54C04; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54600.s") +void func_80A54C04(ObjHugebombiwa* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54980.s") + if (this->collider.base.acFlags & AC_HIT) { + this->unk_4B3 = 5; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54A0C.s") + if (func_80A54A0C(this)) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + func_80A54CD8(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/ObjHugebombiwa_Init.s") + this->collider.base.acFlags &= ~AC_HIT; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/ObjHugebombiwa_Destroy.s") + if (this->unk_4B3 > 0) { + this->unk_4B3--; + if (this->unk_4B3 == 0) { + this->collider.base.colType = COLTYPE_HARD; + } else { + this->collider.base.colType = COLTYPE_NONE; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54BF0.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54C04.s") +void func_80A54CD8(ObjHugebombiwa* this) { + this->actionFunc = func_80A54CEC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54CD8.s") +void func_80A54CEC(ObjHugebombiwa* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54CEC.s") + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + Flags_SetSwitch(globalCtx, ENHUGEBOMBIWA_GET_7F(&this->actor)); + if (!(ENHUGEBOMBIWA_GET_100(&this->actor)) && + ((globalCtx->sceneNum == SCENE_17SETUGEN) || (globalCtx->sceneNum == SCENE_17SETUGEN2))) { + gSaveContext.weekEventReg[19] |= 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54E10.s") + if (!(ENHUGEBOMBIWA_GET_100(&this->actor))) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 80, NA_SE_EV_WALL_BROKEN); + } else { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 80, NA_SE_EV_SNOWBALL_BROKEN); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A55064.s") + if (!(ENHUGEBOMBIWA_GET_100(&this->actor))) { + func_80A53BE0(globalCtx, &this->actor.world.pos); + func_80A54E10(this); + } else { + func_80A541F4(this, globalCtx); + func_80A55310(this); + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A55310.s") +void func_80A54E10(ObjHugebombiwa* this) { + s32 i; + EnHugebombiwaStruct* ptr; + f32 temp_f20; + f32 temp_f20_2; + s16 phi_s2; + s32 pad; + Vec3f sp84; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A55564.s") + Matrix_StatePush(); + Matrix_RotateY(this->actor.shape.rot.y, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/ObjHugebombiwa_Update.s") + for (i = 0, phi_s2 = 0x1000; i < 20; i++, phi_s2 += 0x4000) { + ptr = &this->unk_190[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/ObjHugebombiwa_Draw.s") + temp_f20 = (Rand_ZeroOne() * 0.06f) + 0.013f; + ptr->unk_00.x = ((Rand_ZeroOne() * 0.6f) + 0.6f) * temp_f20; + ptr->unk_00.y = ((Rand_ZeroOne() * 0.6f) + 0.4f) * temp_f20; + ptr->unk_00.z = ((Rand_ZeroOne() * 0.6f) + 0.6f) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A55B34.s") + temp_f20_2 = (Rand_ZeroOne() * 55.0f) + 47.0f; + sp84.x = Math_SinS(phi_s2) * temp_f20_2; + sp84.y = (i + 1) * 10.0f; + sp84.z = fabsf(Math_CosS(phi_s2)) * temp_f20_2; + + Matrix_MultiplyVector3fByState(&sp84, &ptr->unk_0C); + + ptr->unk_0C.x += this->actor.world.pos.x; + ptr->unk_0C.y += this->actor.world.pos.y; + ptr->unk_0C.z += this->actor.world.pos.z; + + ptr->unk_18 = (i * 1.04f) + 2.4f; + ptr->unk_1C.x = phi_s2; + ptr->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr->unk_1C.z = 0; + ptr->unk_22 = Rand_ZeroFloat(5000.0f); + ptr->unk_24 = 0; + } + + this->unk_4B0 = 0; + this->unk_4B2 = 100; + Matrix_StatePop(); + this->actionFunc = func_80A55064; +} + +void func_80A55064(ObjHugebombiwa* this, GlobalContext* globalCtx) { + s32 i; + s32 pad; + Vec3f spA4; + s32 pad2; + CollisionPoly* sp9C; + s32 sp98; + f32 temp_f0; + EnHugebombiwaStruct* ptr; + s16 phi_s3 = this->actor.shape.rot.y - 0x4000; + + for (i = 0; i < ARRAY_COUNT(this->unk_190); i++, phi_s3 += 0x666) { + ptr = &this->unk_190[i]; + if (ptr->unk_24 != 0) { + continue; + } + + ptr->unk_18 -= 3.0f; + if (ptr->unk_18 < -30.0f) { + ptr->unk_18 = -30.0f; + } + + ptr->unk_0C.x += Math_SinS(phi_s3) * 4.0f; + ptr->unk_0C.y += ptr->unk_18; + ptr->unk_0C.z += Math_CosS(phi_s3) * 4.0f; + + ptr->unk_1C.x += ptr->unk_22; + + spA4.x = ptr->unk_0C.x; + spA4.y = ptr->unk_0C.y + 60.0f; + spA4.z = ptr->unk_0C.z; + + temp_f0 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp9C, &sp98, &this->actor, &spA4); + if ((temp_f0 <= BGCHECK_Y_MIN + 10.0f) || ((ptr->unk_0C.y - (350.0f * ptr->unk_00.y)) < temp_f0)) { + this->unk_4B0++; + ptr->unk_24 = 1; + func_80A53E60(globalCtx, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 9.8f); + if ((globalCtx->gameplayFrames % 4) == 0) { + func_80A54980(this, globalCtx, (s32)(Rand_ZeroOne() * 5.5f) + 1); + } + } + } + + this->unk_4B2--; + if ((this->unk_4B0 >= 20) || (this->unk_4B2 <= 0)) { + ActorCutscene_Stop(this->actor.cutscene); + Actor_MarkForDeath(&this->actor); + } +} + +void func_80A55310(ObjHugebombiwa* this) { + s32 i; + EnHugebombiwaStruct* ptr; + s32 pad; + f32 temp_f20; + f32 temp_f20_2; + s16 phi_s2; + Vec3f sp84; + + Matrix_StatePush(); + Matrix_RotateY(this->actor.shape.rot.y, 0); + + for (i = 0, phi_s2 = 0x1000; i < ARRAY_COUNT(this->unk_190); i++, phi_s2 += 0x4000) { + ptr = &this->unk_190[i]; + + temp_f20 = (Rand_ZeroOne() * 0.09f) + 0.016f; + ptr->unk_00.x = ((Rand_ZeroOne() * 0.1f) + 0.95f) * temp_f20; + ptr->unk_00.y = ((Rand_ZeroOne() * 0.1f) + 0.95f) * temp_f20; + ptr->unk_00.z = ((Rand_ZeroOne() * 0.1f) + 0.95f) * temp_f20; + + temp_f20_2 = (Rand_ZeroOne() * 85.0f) + 77.0f; + sp84.x = Math_SinS(phi_s2) * temp_f20_2; + sp84.y = (i + 1) * 14.0f; + sp84.z = fabsf(Math_CosS(phi_s2)) * temp_f20_2; + Matrix_MultiplyVector3fByState(&sp84, &ptr->unk_0C); + + ptr->unk_0C.x += this->actor.world.pos.x; + ptr->unk_0C.y += this->actor.world.pos.y; + ptr->unk_0C.z += this->actor.world.pos.z; + + ptr->unk_18 = (i * 1.04f) + 2.4f; + + ptr->unk_1C.x = phi_s2; + ptr->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr->unk_1C.z = 0; + + ptr->unk_22 = Rand_ZeroFloat(5000.0f); + ptr->unk_24 = 0; + } + + this->unk_4B0 = 0; + this->unk_4B2 = 100; + Matrix_StatePop(); + this->actionFunc = func_80A55564; +} + +void func_80A55564(ObjHugebombiwa* this, GlobalContext* globalCtx) { + s32 i; + EnHugebombiwaStruct* ptr; + Vec3f spA4; + s32 pad; + CollisionPoly* sp9C; + s32 sp98; + f32 temp_f0; + s16 phi_s3 = this->actor.shape.rot.y - 0x4000; + + for (i = 0; i < ARRAY_COUNT(this->unk_190); i++, phi_s3 += 0x666) { + ptr = &this->unk_190[i]; + + if (ptr->unk_24 != 0) { + continue; + } + + ptr->unk_18 -= 3.0f; + if (ptr->unk_18 < -30.0f) { + ptr->unk_18 = -30.0f; + } + + ptr->unk_0C.x += (Math_SinS(phi_s3) * 4.0f); + ptr->unk_0C.y += ptr->unk_18; + ptr->unk_0C.z += (Math_CosS(phi_s3) * 4.0f); + + ptr->unk_1C.x += ptr->unk_22; + + spA4.x = ptr->unk_0C.x; + spA4.y = ptr->unk_0C.y + 60.0f; + spA4.z = ptr->unk_0C.z; + + temp_f0 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp9C, &sp98, &this->actor, &spA4); + if ((temp_f0 <= BGCHECK_Y_MIN + 10.0f) || (ptr->unk_0C.y < temp_f0)) { + this->unk_4B0++; + ptr->unk_24 = 1; + func_80A54600(globalCtx, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 10.1f); + if ((globalCtx->gameplayFrames % 4) == 0) { + func_80A54980(this, globalCtx, (s32)(Rand_ZeroOne() * 5.5f) + 1); + } + } + } + + this->unk_4B2--; + if ((this->unk_4B0 >= 20) || (this->unk_4B2 <= 0)) { + ActorCutscene_Stop(this->actor.cutscene); + Actor_MarkForDeath(&this->actor); + } +} + +void ObjHugebombiwa_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjHugebombiwa* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void ObjHugebombiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHugebombiwa* this = THIS; + s32 pad[8]; + f32 sp38; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->actionFunc == func_80A54C04) || (this->actionFunc == func_80A54CEC)) { + if (this->actor.projectedPos.z <= 4300.0f) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0xFF, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_002F60); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_003110); + + } else if (this->actor.projectedPos.z < 4500.0f) { + sp38 = (4500.0f - this->actor.projectedPos.z) * 1.275f; + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, (s32)sp38); + gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_002F60); + } + } else { + s32 i; + EnHugebombiwaStruct* ptr; + Gfx* gfx = POLY_OPA_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + + for (i = 0; i < ARRAY_COUNT(this->unk_190); i++) { + ptr = &this->unk_190[i]; + + if (ptr->unk_24 == 0) { + Matrix_SetStateRotationAndTranslation(ptr->unk_0C.x, ptr->unk_0C.y, ptr->unk_0C.z, &ptr->unk_1C); + Matrix_Scale(ptr->unk_00.x, ptr->unk_00.x, ptr->unk_00.x, MTXMODE_APPLY); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, object_bombiwa_DL_001990); + } + } + + POLY_OPA_DISP = gfx; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A55B34(Actor* thisx, GlobalContext* globalCtx) { + ObjHugebombiwa* this = THIS; + s32 i; + Gfx* gfx; + EnHugebombiwaStruct* ptr; + + if ((this->actionFunc == func_80A54C04) || (this->actionFunc == func_80A54CEC)) { + Gfx_DrawDListOpa(globalCtx, object_bombiwa_DL_001820); + return; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_OPA_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + + for (i = 0; i < ARRAY_COUNT(this->unk_190); i++) { + ptr = &this->unk_190[i]; + + if (ptr->unk_24 != 0) { + continue; + } + + Matrix_SetStateRotationAndTranslation(ptr->unk_0C.x, ptr->unk_0C.y + (325.0f * ptr->unk_00.y), ptr->unk_0C.z, + &ptr->unk_1C); + Matrix_Scale(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -325.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, object_bombiwa_DL_0009E0); + } + + POLY_OPA_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.h b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.h index b85add2efa..f1d26aaf4b 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.h +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.h @@ -7,9 +7,25 @@ struct ObjHugebombiwa; typedef void (*ObjHugebombiwaActionFunc)(struct ObjHugebombiwa*, GlobalContext*); +#define ENHUGEBOMBIWA_GET_7F(thisx) ((thisx)->params & 0x7F) +#define ENHUGEBOMBIWA_GET_100(thisx) (((thisx)->params >> 8) & 1) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ f32 unk_18; + /* 0x1C */ Vec3s unk_1C; + /* 0x22 */ s16 unk_22; + /* 0x24 */ s16 unk_24; +} EnHugebombiwaStruct; // size = 0x28 + typedef struct ObjHugebombiwa { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x370]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ EnHugebombiwaStruct unk_190[20]; + /* 0x04B0 */ s16 unk_4B0; + /* 0x04B2 */ s8 unk_4B2; + /* 0x04B3 */ s8 unk_4B3; /* 0x04B4 */ ObjHugebombiwaActionFunc actionFunc; } ObjHugebombiwa; // size = 0x4B8 diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index bbeb4da26a..0c4f8f63e1 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -5,6 +5,7 @@ */ #include "z_obj_iceblock.h" +#include "objects/object_ice_block/object_ice_block.h" #define FLAGS 0x00000010 @@ -15,7 +16,35 @@ void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx); void ObjIceblock_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A257A0(ObjIceblock* this); +void func_80A257B4(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25824(ObjIceblock* this); +void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25978(ObjIceblock* this); +void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25A8C(ObjIceblock* this); +void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25BA0(ObjIceblock* this); +void func_80A25BBC(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25C5C(ObjIceblock* this); +void func_80A25C70(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25CF4(ObjIceblock* this); +void func_80A25D28(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25E3C(ObjIceblock* this); +void func_80A25E50(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A25FA0(ObjIceblock* this); +void func_80A25FD4(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A260E8(ObjIceblock* this); +void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A262BC(ObjIceblock* this); +void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A26574(ObjIceblock* this); +void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A266E0(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A26B64(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A26B74(ObjIceblock* this, GlobalContext* globalCtx); +void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx); + const ActorInit Obj_Iceblock_InitVars = { ACTOR_OBJ_ICEBLOCK, ACTORCAT_BG, @@ -28,158 +57,1504 @@ const ActorInit Obj_Iceblock_InitVars = { (ActorFunc)ObjIceblock_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A26E50 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 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_NO_PUSH | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 44, 62, -31, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A26FA4[] = { +static AnimatedMaterial* D_80A26E7C = NULL; + +s16 func_80A23090(s16 arg0, s16 arg1, s16 arg2) { + if (arg0 >= 0) { + if (arg2 < arg0) { + return arg2; + } else if (arg0 < arg1) { + return arg1; + } + } else if (arg0 < -arg2) { + return -arg2; + } else if (-arg1 < arg0) { + return -arg1; + } + + return arg0; +} + +void func_80A2311C(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_80A2319C(ObjIceblock* this, f32 arg1) { + s32 i; + s16 temp_s1 = (u32)Rand_Next() >> 0x10; + s16 temp_s2 = (u32)Rand_Next() >> 0x10; + ObjIceBlockUnkStruct* ptr; + + for (i = 0; i < ARRAY_COUNT(this->unk_1B4); i++) { + ptr = &this->unk_1B4[i]; + temp_s1 += Rand_S16Offset(2700, 10000); + temp_s2 += Rand_S16Offset(2700, 10000); + ptr->unk_00 = temp_s1; + ptr->unk_02 = temp_s2; + ptr->unk_04 = ((Rand_ZeroOne() * 0.2f) + 0.9f) * arg1; + ptr->unk_08 = ((Rand_ZeroOne() * 0.2f) + 0.9f) * arg1; + ptr->unk_0C = ((Rand_ZeroOne() * 0.2f) + 0.9f) * arg1; + } +} + +void func_80A232C4(ObjIceblock* this, s32 arg1) { + static s16 D_80A26E80[] = { 1, -1, 0, 0 }; + static s16 D_80A26E88[] = { 0, 0, 1, -1 }; + + this->unk_276 += D_80A26E80[arg1]; + this->unk_278 += D_80A26E88[arg1]; + + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_264 = &this->dyna.actor.world.pos.x; + this->unk_268 = this->dyna.actor.home.pos.x + (this->unk_276 * 60); + } else { + this->unk_264 = &this->dyna.actor.world.pos.z; + this->unk_268 = this->dyna.actor.home.pos.z + (this->unk_278 * 60); + } + this->unk_26C = arg1; +} + +void func_80A23370(ObjIceblock* this, s32 arg1) { + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_264 = &this->dyna.actor.world.pos.x; + } else { + this->unk_264 = &this->dyna.actor.world.pos.z; + } + this->unk_26C = arg1; +} + +void func_80A2339C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3, s32 arg4) { + Vec3f spBC; + Vec3f spB0; + Vec3f spA4; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + s32 i; + f32 sp88; + s16 temp_s4; + s16 phi_s0; + s16 temp; + + spA4.z = 0.0f; + spA4.x = 0.0f; + temp_f24 = ((Rand_ZeroOne() * 0.1656f) + 0.3312f) * arg3; + sp88 = 10.0f * arg3; + + for (i = 0, phi_s0 = 0; i < arg4; i++, phi_s0 += temp) { + temp = 0x10000 / arg4; + + temp_f20 = ((Rand_ZeroOne() * 0.4f) + 0.6f) * (arg2 * 3.5f); + temp_s4 = temp_f20 * 100.0f; + temp_f22 = ((Rand_ZeroOne() * 0.7f) + 0.3f) * arg2 * 300.0f; + + spBC.x = Math_SinS(Rand_S16Offset(phi_s0, temp)) * temp_f22; + spBC.y = (Rand_ZeroOne() - 0.5f) * (600.0f * arg2); + spBC.z = Math_CosS(Rand_S16Offset(phi_s0, temp)) * temp_f22; + + spB0.x = spBC.x * temp_f24; + spB0.y = ((Rand_ZeroOne() * 1.2f) + 0.3f + (temp_f20 * 4.0f)) * sp88; + spB0.z = spBC.z * temp_f24; + + spBC.x += arg1->x; + spBC.y += arg1->y; + spBC.z += arg1->z; + + spA4.y = -0.8f - (temp_f20 * 18.0f); + + EffectSsIceBlock_Spawn(globalCtx, &spBC, &spB0, &spA4, temp_s4); + } +} + +void func_80A23690(ObjIceblock* 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; +} + +s32 func_80A236D4(ObjIceblock* this, Vec3f* arg1) { + f32 sp2C; + f32 sp28; + s16 sp26; + s32 sp20; + + sp26 = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, arg1); + sp2C = Math_SinS(sp26) * this->dyna.actor.speedXZ; + sp2C = fabsf(sp2C) + 0.01f; + + sp28 = Math_CosS(sp26) * this->dyna.actor.speedXZ; + sp28 = fabsf(sp28) + 0.01f; + + sp20 = Math_StepToF(&this->dyna.actor.world.pos.x, arg1->x, sp2C); + sp20 &= 1; + sp20 &= Math_StepToF(&this->dyna.actor.world.pos.z, arg1->z, sp28); + return sp20; +} + +void func_80A237A4(ObjIceblock* this) { + s32 pad[2]; + ObjIceBlockUnkStruct4* ptr = &this->unk_27C; + f32 sp20; + + ptr->unk_10 += ptr->unk_0C; + ptr->unk_12 += ptr->unk_0E; + Math_StepToF(&this->unk_27C.unk_08, this->unk_27C.unk_04, 0.08f); + + if (this->unk_1B0 & 0x20) { + Math_StepToF(&ptr->unk_00, -5.0f, (Math_CosS(fabsf(ptr->unk_00) * 3276.8f) * 0.3f) + 0.02f); + } else { + Math_StepToF(&ptr->unk_00, 0.0f, (Math_SinS(fabsf(ptr->unk_00) * 3276.8f) * 0.3f) + 0.02f); + } + + sp20 = Math_SinS(ptr->unk_10); + this->dyna.actor.world.pos.y = + (Math_SinS(ptr->unk_12) * ptr->unk_08 * 0.5f) + + ((this->unk_244 - ((600.0f * this->dyna.actor.scale.y) - 90.0f)) + (sp20 * ptr->unk_08)) + ptr->unk_00; +} + +void func_80A23938(ObjIceblock* this2) { + ObjIceblock* this = this2; + + if (this->unk_1B0 & 0x80) { + Math_ScaledStepToS(&this->dyna.actor.shape.rot.x, 0, 400); + Math_ScaledStepToS(&this->dyna.actor.shape.rot.z, 0, 400); + } else { + ObjIceBlockUnkStruct4* ptr = &this->unk_27C; + f32 phi_f0; + s16 temp; + + if (this->unk_1B0 & 0x20) { + phi_f0 = 0.3f; + ptr->unk_14 = this->dyna.actor.yawTowardsPlayer; + } else { + phi_f0 = 0.08f; + } + + Math_StepToF(&ptr->unk_1C, phi_f0, 0.04f); + ptr->unk_22 += (s16)(ptr->unk_20 * -0.02f); + ptr->unk_22 = func_80A23090(ptr->unk_22, 50, 800); + ptr->unk_20 += ptr->unk_22; + + temp = ptr->unk_16 - ptr->unk_14; + + ptr->unk_18 += + (s16)(temp * -0.04f * this->dyna.actor.xzDistToPlayer * this->dyna.actor.scale.x * (1.0f / 600.0f)); + ptr->unk_18 = func_80A23090(ptr->unk_18, 50, 800); + ptr->unk_16 += ptr->unk_18; + + this->dyna.actor.shape.rot.x = Math_CosS(ptr->unk_16) * ptr->unk_20 * ptr->unk_1C; + this->dyna.actor.shape.rot.x = CLAMP(this->dyna.actor.shape.rot.x, -2000, 2000); + + this->dyna.actor.shape.rot.z = -Math_SinS(ptr->unk_16) * ptr->unk_20 * ptr->unk_1C; + this->dyna.actor.shape.rot.z = CLAMP(this->dyna.actor.shape.rot.z, -2000, 2000); + } +} + +void func_80A23B88(ObjIceblock* this) { + f32 f4; + f32 f2; + f32 f14; + f32 f16; + f32 f6; + + f14 = this->dyna.actor.world.pos.x - this->dyna.actor.home.pos.x; + f2 = (f14 >= 0.0f) ? (0.5f) : (-0.5f); + f4 = (((s32)(f2 + f14)) / 30) * 30; + f14 -= f4; + if (fabsf(f14) < 3.0f) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + f4; + } + + f16 = this->dyna.actor.world.pos.z - this->dyna.actor.home.pos.z; + f2 = (f16 >= 0.0f) ? (0.5f) : (-0.5f); + f6 = (((s32)(f2 + f16)) / 30) * 30; + f16 -= f6; + if (fabsf(f16) < 3.0f) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + f6; + } +} + +s32 func_80A23D08(ObjIceblock* this, GlobalContext* globalCtx) { + static ObjIceBlockUnkStruct3 D_80A26E90[] = { + { -300.0f, 300.0f }, { 300.0f, 300.0f }, { -300.0f, -300.0f }, { 300.0f, -300.0f }, { 0.0f, 0.0f }, + }; + static ObjIceBlockUnkStruct3 D_80A26EB8[] = { + { 0.5f, -0.5f }, { -0.5f, -0.5f }, { 0.5f, 0.5f }, { -0.5f, 0.5f }, { 0.0f, 0.0f }, + }; + s32 pad3; + ObjIceBlockUnkStruct2* ptr; + WaterBox* spC4; + s32 i; + s32 spBC; + s32 spB8; + s32 pad; + f32 phi_f20; + Vec3f spA4; + Vec3f sp98; + s32 sp94 = 0; + f32 phi_f22; + + sp98.y = this->dyna.actor.world.pos.y + 40.0f; + spBC = spB8 = -1; + phi_f20 = BGCHECK_Y_MIN; + phi_f22 = BGCHECK_Y_MIN; + + for (i = 0; i < ARRAY_COUNT(this->unk_1F4); i++) { + ptr = &this->unk_1F4[i]; + + ptr->unk_00 = NULL; + ptr->unk_04 = BGCHECK_Y_MIN; + ptr->unk_08 = 50; + + sp98.x = (D_80A26E90[i].unk_00 * this->dyna.actor.scale.x) + D_80A26EB8[i].unk_00; + sp98.z = (D_80A26E90[i].unk_04 * this->dyna.actor.scale.z) + D_80A26EB8[i].unk_04; + + func_80A2311C(&spA4, &sp98, this->dyna.actor.shape.rot.y); + spA4.x += this->dyna.actor.world.pos.x; + spA4.z += this->dyna.actor.world.pos.z; + + ptr->unk_04 = + BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, &ptr->unk_00, &ptr->unk_08, &this->dyna.actor, &spA4, 0.0f); + if (ptr->unk_04 > BGCHECK_Y_MIN + 1) { + sp94 = 1; + if (phi_f22 < ptr->unk_04) { + spBC = i; + phi_f22 = ptr->unk_04; + } + } + + if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, spA4.x, spA4.z, &ptr->unk_0C, &spC4)) { + if (phi_f20 < ptr->unk_0C) { + spB8 = i; + phi_f20 = ptr->unk_0C; + } + } else { + ptr->unk_0C = BGCHECK_Y_MIN; + } + } + + if (spBC >= 0) { + this->dyna.actor.floorPoly = this->unk_1F4[spBC].unk_00; + this->dyna.actor.floorHeight = this->unk_1F4[spBC].unk_04; + this->dyna.actor.floorBgId = this->unk_1F4[spBC].unk_08; + } else { + this->dyna.actor.floorPoly = NULL; + this->dyna.actor.floorHeight = BGCHECK_Y_MIN; + this->dyna.actor.floorBgId = BGCHECK_SCENE; + } + + if (spB8 >= 0) { + this->unk_244 = this->unk_1F4[spB8].unk_0C; + } else { + this->unk_244 = BGCHECK_Y_MIN; + } + + return sp94; +} + +s32 func_80A23F90(ObjIceblock* this, GlobalContext* globalCtx) { + this->unk_1B0 &= ~4; + + if (func_80A23D08(this, globalCtx)) { + f32 phi_f2 = BGCHECK_Y_MIN; + s32 ret = false; + s32 i; + ObjIceBlockUnkStruct2* ptr; + + for (i = 0; i < ARRAY_COUNT(this->unk_1F4); i++) { + ptr = &this->unk_1F4[i]; + if (((this->dyna.actor.world.pos.y - 10.0f) < ptr->unk_04) && (phi_f2 < ptr->unk_04)) { + phi_f2 = ptr->unk_04; + ret = true; + } + } + + if (ret) { + this->dyna.actor.world.pos.y = phi_f2; + this->unk_1B0 |= 4; + this->dyna.actor.velocity.y = 0.0f; + } + return ret; + } + return false; +} + +s32 func_80A24118(ObjIceblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f* arg3) { + static ObjIceBlockUnkStruct3 D_80A26EE0[] = { + { -300.0f, -300.0f }, { 300.0f, -300.0f }, { -300.0f, 600.0f }, { 300.0f, 600.0f }, { 0.0f, 0.0f }, + }; + static ObjIceBlockUnkStruct3 D_80A26F08[] = { + { 1.0f, 1.0f }, { -1.0f, 1.0f }, { 1.0f, -1.0f }, { -1.0f, -1.0f }, { 0.0f, 0.0f }, + }; + f32 temp_f20; + f32 spF0; + f32 spEC; + f32 phi_f20; + Vec3f spDC; + Vec3f spD0; + Vec3f spC4; + Vec3f spB8; + s32 pad[2]; + s32 spAC; + CollisionPoly* spA8; + s32 ret; + s32 i; + s16 sp9E; + f32 temp_f24; + f32 temp_f26; + + sp9E = this->dyna.yRotation; + if (this->dyna.pushForce < 0.0f) { + sp9E -= 0x8000; + } + + spF0 = Math_SinS(sp9E); + spEC = Math_CosS(sp9E); + temp_f20 = Math3D_Distance(&this->dyna.actor.world.pos, &this->dyna.actor.prevPos) + + (300.0f * this->dyna.actor.scale.z) + arg2; + temp_f24 = temp_f20 * spF0; + temp_f26 = temp_f20 * spEC; + ret = false; + phi_f20 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(D_80A26EE0); i++) { + spC4.x = (D_80A26EE0[i].unk_00 * this->dyna.actor.scale.x) + D_80A26F08[i].unk_00; + spC4.y = (D_80A26EE0[i].unk_04 * this->dyna.actor.scale.y) + D_80A26F08[i].unk_04 + + (this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y); + spC4.z = 0.0f; + + func_80A2311C(&spDC, &spC4, sp9E); + + spDC.x += this->dyna.actor.prevPos.x; + spDC.y += this->dyna.actor.prevPos.y; + spDC.z += this->dyna.actor.prevPos.z; + + spD0.x = temp_f24 + spDC.x; + spD0.y = spDC.y; + spD0.z = temp_f26 + spDC.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spDC, &spD0, &spB8, &spA8, 1, 0, 0, 1, &spAC, + &this->dyna.actor, 0.0f)) { + temp_f20 = Math3D_Vec3fDistSq(&spDC, &spB8); + if (temp_f20 < phi_f20) { + phi_f20 = temp_f20; + ret = true; + Math_Vec3f_Diff(&spB8, &spD0, arg3); + } + } + } + return ret; +} + +s32 func_80A24384(ObjIceblock* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + if (func_80A24118(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_80A243E0(ObjIceblock* this, GlobalContext* globalCtx, Vec3f* arg0) { + static f32 D_80A26F30[] = { -300.0f, 300.0f }; + static f32 D_80A26F38[] = { 1.0f, -1.0f }; + s32 i; + f32 sp100; + f32 spFC; + f32 phi_f22; + Vec3f spEC; + Vec3f spE0; + Vec3f spD4; + Vec3f spC8; + s16 temp_s6; + f32 temp_f28; + s32 spBC; + CollisionPoly* spB8; + s32 ret; + f32 temp_f30; + f32 temp_f0; + f32 temp_f12; + + temp_s6 = this->dyna.yRotation; + if (this->dyna.pushForce < 0.0f) { + temp_s6 -= 0x8000; + } + + sp100 = Math_SinS(temp_s6); + spFC = Math_CosS(temp_s6); + + temp_f0 = ((Math3D_Distance(&this->dyna.actor.world.pos, &this->dyna.actor.prevPos) + + (300.0f * this->dyna.actor.scale.z)) + + 2.0f); + temp_f12 = -temp_f0; + ret = false; + temp_f28 = temp_f12 * sp100; + temp_f30 = temp_f12 * spFC; + phi_f22 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(D_80A26F30); i++) { + spD4.x = (D_80A26F30[i] * this->dyna.actor.scale.x) + D_80A26F38[i]; + spD4.y = -10.0f; + spD4.z = 0.0f; + + func_80A2311C(&spEC, &spD4, temp_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, 1, 0, 0, 1, &spBC, + &this->dyna.actor, 0.0f)) { + temp_f12 = Math3D_Vec3fDistSq(&spEC, &spC8); + if (temp_f12 < phi_f22) { + phi_f22 = temp_f12; + ret = true; + arg0->x = (spC8.x - spEC.x) + (300.0f * this->dyna.actor.scale.z * sp100); + arg0->y = 0.0f; + arg0->z = (spC8.z - spEC.z) + (300.0f * this->dyna.actor.scale.z * spFC); + } + } + } + return ret; +} + +s32 func_80A24680(ObjIceblock* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + if (func_80A243E0(this, globalCtx, &sp1C)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + return false; +} + +s32 func_80A246D8(ObjIceblock* this, GlobalContext* globalCtx, Vec3f* arg2) { + static ObjIceBlockUnkStruct3 D_80A26F40[] = { + { -300.0f, -300.0f }, { 300.0f, -300.0f }, { -300.0f, 600.0f }, { 300.0f, 600.0f }, { 0.0f, 0.0f }, + }; + static ObjIceBlockUnkStruct3 D_80A26F68[] = { + { 1.0f, 1.0f }, { -1.0f, 1.0f }, { 1.0f, -1.0f }, { -1.0f, -1.0f }, { 0.0f, 0.0f }, + }; + s32 pad; + s32 i; + s32 j; + Vec3f spC0; + Vec3f spB4; + Vec3f spA8; + Vec3f sp9C; + s32 sp98; + CollisionPoly* sp94; + ObjIceblock* temp_v0; + f32 temp_f20 = (this->dyna.actor.scale.z * 300.0f) + 2.0f; + s16 phi_s3; + s32 ret = false; + + for (i = 0, phi_s3 = 0; i < 4; i++, phi_s3 += 0x4000) { + for (j = 0; j < ARRAY_COUNT(D_80A26F40); j++) { + spA8.x = (D_80A26F40[j].unk_00 * this->dyna.actor.scale.x) + D_80A26F68[j].unk_00; + spA8.y = ((D_80A26F40[j].unk_04 * this->dyna.actor.scale.y) + D_80A26F68[j].unk_04) + + (this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y); + spA8.z = 0.0f; + + func_80A2311C(&spC0, &spA8, phi_s3); + + spC0.x += arg2->x; + spC0.y += arg2->y; + spC0.z += arg2->z; + + spB4.x = (Math_SinS(phi_s3) * temp_f20) + spC0.x; + 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, + &this->dyna.actor, 0.0f)) { + ret = true; + temp_v0 = (ObjIceblock*)DynaPoly_GetActor(&globalCtx->colCtx, sp98); + if ((temp_v0 != NULL) && (temp_v0->dyna.actor.id == ACTOR_OBJ_ICEBLOCK) && (temp_v0->unk_2B0 == 3)) { + temp_v0->unk_1B0 |= 0x80; + } + } + } + } + + return ret; +} + +void func_80A2491C(ObjIceblock* this) { + Math_Vec3f_Copy(&this->dyna.actor.home.pos, &this->dyna.actor.world.pos); + this->unk_278 = 0; + this->unk_276 = this->unk_278; +} + +s32 func_80A24954(ObjIceblock* this, GlobalContext* globalCtx) { + s32 pad[2]; + s8 sp27 = this->unk_2B0; + f32 temp = (this->dyna.actor.scale.y * 600.0f) - 90.0f; + + if ((this->unk_244 > BGCHECK_Y_MIN + 1) && (temp < (this->unk_244 - this->dyna.actor.world.pos.y))) { + func_80A262BC(this); + this->unk_2B0 = 3; + } else if (this->unk_1B0 & 4) { + if (func_800C99D4(&globalCtx->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) == 5) { + func_80A25FA0(this); + this->unk_2B0 = 2; + } else { + func_80A25CF4(this); + this->unk_2B0 = 1; + } + } + return sp27 != this->unk_2B0; +} + +void func_80A24A48(ObjIceblock* this, GlobalContext* globalCtx) { + if (!(this->unk_1B0 & 0x10) && !(this->collider.base.ocFlags1 & OC1_HIT)) { + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->unk_1B0 |= 0x10; + } +} + +void func_80A24AA8(ObjIceblock* this, GlobalContext* globalCtx) { + s32 i; + f32 x; + ObjIceblock* temp_v0; + + if (this->unk_1B0 & 4) { + for (i = 0; i < ARRAY_COUNT(this->unk_1F4); i++) { + temp_v0 = (ObjIceblock*)DynaPoly_GetActor(&globalCtx->colCtx, ((void)0, this->unk_1F4[i]).unk_08); + if ((temp_v0 != NULL) && (temp_v0->dyna.actor.id == ACTOR_OBJ_ICEBLOCK)) { + x = this->dyna.actor.world.pos.y - this->unk_1F4[i].unk_04; + + if (fabsf(x) < 0.1f) { + temp_v0->unk_1B0 |= 2; + } + } + } + } +} + +void func_80A24B74(ObjIceblock* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp20; + + if (this->dyna.actor.flags & 0x40) { + if (1) {} + sp20.x = this->dyna.actor.world.pos.x; + sp20.y = this->unk_244; + sp20.z = this->dyna.actor.world.pos.z; + EffectSsGRipple_Spawn(globalCtx, &sp20, 480, 880, 0); + } +} + +void func_80A24BDC(ObjIceblock* this, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4) { + s32 i; + Vec3f sp88; + f32 temp_f20; + s16 temp_f22; + s16 phi_s0; + s32 phi_s1 = 0; + + if (this->dyna.actor.flags & 0x40) { + sp88.y = this->unk_244; + temp_f22 = 0x10000 / arg4; + + for (i = 0, phi_s0 = 0; i < arg4; i++, phi_s0 += temp_f22) { + temp_f20 = ((Rand_ZeroOne() * 5.0f) + 40.0f) * arg2; + sp88.x = (Math_SinS((s32)(Rand_ZeroOne() * temp_f22) + phi_s0) * temp_f20) + this->dyna.actor.world.pos.x; + sp88.z = (Math_CosS((s32)(Rand_ZeroOne() * temp_f22) + phi_s0) * temp_f20) + this->dyna.actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp88, NULL, NULL, 0, ((Rand_ZeroOne() * 60.0f) + 320.0f) * arg3); + } + } +} + +void func_80A24DC4(ObjIceblock* this) { + this->unk_2A2 = 0; +} + +void func_80A24DD0(ObjIceblock* this, GlobalContext* globalCtx) { + static Vec3f D_80A26F90 = { 0.0f, 0.3f, 0.0f }; + static Color_RGBA8 D_80A26F9C = { 250, 250, 250, 255 }; + static Color_RGBA8 D_80A26FA0 = { 180, 180, 180, 255 }; + s32 pad; + Vec3f spA8; + Vec3f sp9C; + s32 i; + f32 temp_f20; + f32 phi_f22; + s32 pad2; + s16 sp8A; + + sp8A = this->dyna.yRotation; + if (this->dyna.pushForce < 0.0f) { + sp8A -= 0x8000; + } + + this->unk_2A2++; + if (this->dyna.actor.flags & 0x40) { + if (this->unk_2A2 >= 0x2E) { + phi_f22 = 1.0f; + } else { + phi_f22 = (this->unk_2A2 * 0.017777778f) + 0.2f; + } + sp9C.y = 12.0f; + + for (i = 0; i < 2; i++) { + if (phi_f22 < (Rand_ZeroOne() * 1.2f)) { + continue; + } + + this->unk_2A4 += Rand_ZeroOne(); + if (this->unk_2A4 > 1.0f) { + this->unk_2A4 -= 1.0f; + } + + sp9C.x = (this->unk_2A4 - 0.5f) * 600.0f * this->dyna.actor.scale.x; + sp9C.z = (this->dyna.actor.scale.z * -300.0f) + 4.0f; + + func_80A2311C(&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_f20 = ((Rand_ZeroOne() * 800.0f) + (1600.0f * this->dyna.actor.scale.x)) * phi_f22; + func_800B0E48(globalCtx, &spA8, &gZeroVec3f, &D_80A26F90, &D_80A26F9C, &D_80A26FA0, temp_f20, + (Rand_ZeroOne() * 20.0f) + 30.0f); + } + } +} + +void func_80A2508C(ObjIceblock* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + f32 temp_f0; + s32 temp_v0; + + if (this->dyna.actor.flags & 0x40) { + temp_v0 = (s32)(this->dyna.actor.scale.y * 130.0f) - 3; + if (temp_v0 > 0) { + this->unk_2AC += temp_v0; + } + + if (this->unk_2AC >= 10) { + this->unk_2AC = 0; + sp34.x = (Rand_ZeroOne() * 600.0f) - 300.0f; + sp34.y = 600.0f; + sp34.z = (Rand_ZeroOne() * 600.0f) - 300.0f; + + temp_f0 = sqrtf(this->dyna.actor.scale.y + 0.01f); + sp40.x = sp34.x * 0.006935f * temp_f0; + sp40.y = 2.0f; + sp40.z = sp34.z * 0.006935f * temp_f0; + + sp34.x = (this->dyna.actor.scale.x * sp34.x) + this->dyna.actor.world.pos.x; + sp34.y = (this->dyna.actor.scale.y * sp34.y) + this->dyna.actor.world.pos.y; + sp34.z = (this->dyna.actor.scale.z * sp34.z) + this->dyna.actor.world.pos.z; + + if ((this->unk_244 - 3.0f) < sp34.y) { + EffectSsIceSmoke_Spawn(globalCtx, &sp34, &sp40, &gZeroVec3f, + (s32)(this->dyna.actor.scale.y * 1300.0f) + 60); + } + } + } +} + +s32 func_80A25238(ObjIceblock* this) { + s16 phi_v0; + + if (fabsf(this->dyna.pushForce) > 0.1f) { + if (this->dyna.pushForce > 0.0f) { + phi_v0 = this->dyna.yRotation + 0x2000; + } else { + phi_v0 = this->dyna.yRotation - 0x6000; + } + + if (phi_v0 < -0x4000) { + return 3; + } + + if (phi_v0 < 0) { + return 1; + } + + if (phi_v0 < 0x4000) { + return 2; + } + return 0; + } + return -1; +} + +void func_80A252DC(ObjIceblock* this, s32 arg1) { + s32 phi_v0; + s32 i; + + if (this->unk_2B0 == 1) { + phi_v0 = true; + } else if (this->unk_2B0 == 2) { + phi_v0 = (this->dyna.pushForce > 0.0f); + } else { + phi_v0 = false; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_26E); i++) { + if ((arg1 == i) && phi_v0) { + this->unk_26E[i]++; + } else if (this->unk_26E[i] > 0) { + this->unk_26E[i]--; + } + } +} + +void func_80A25404(ObjIceblock* this) { + this->unk_26E[1] = 0; + this->unk_26E[2] = 0; + this->unk_26E[3] = 0; + this->unk_26E[0] = 0; +} + +void func_80A2541C(ObjIceblock* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; +} + +void func_80A25440(ObjIceblock* this) { + s32 pad[2]; + MtxF sp40; + Vec3f sp34; + Vec3f sp28; + f32 sp24; + Actor* temp_s1 = this->dyna.actor.parent; + + if (temp_s1 != NULL) { + if (this->unk_2B0 == 3) { + sp24 = this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y; + + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + + sp34.x = this->unk_248.x; + sp34.y = this->unk_248.y - sp24; + sp34.z = this->unk_248.z; + + Matrix_MultiplyVector3fByState(&sp34, &sp28); + + sp34.x = this->dyna.actor.world.pos.x; + sp34.y = this->dyna.actor.world.pos.y + sp24; + sp34.z = this->dyna.actor.world.pos.z; + + Math_Vec3f_Sum(&sp34, &sp28, &temp_s1->world.pos); + Matrix_RotateY(this->unk_254.y + this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_254.x + this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_254.z + this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&sp40); + func_8018219C(&sp40, &temp_s1->shape.rot, MTXMODE_APPLY); + } else { + Math_Vec3f_Sum(&this->dyna.actor.world.pos, &this->unk_248, &temp_s1->world.pos); + } + } +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(speedXZ, 16000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1800, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -26000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -26000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif - -extern ColliderCylinderInit D_80A26E50; -extern InitChainEntry D_80A26FA4[]; - -extern UNK_TYPE D_060001A0; -extern UNK_TYPE D_06000438; - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A23090.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A2311C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A2319C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A232C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A23370.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A2339C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A23690.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A236D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A237A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A23938.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A23B88.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A23D08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A23F90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A24118.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A24384.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A243E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A24680.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A246D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A2491C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A24954.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A24A48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A24AA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A24B74.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A24BDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A24DC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A24DD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A2508C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25238.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A252DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25404.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A2541C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25440.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/ObjIceblock_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/ObjIceblock_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A257A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A257B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25824.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A2586C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25978.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25994.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25A8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25AA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25BA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25BBC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25C5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25C70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25CF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25D28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25E3C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25E50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25FA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A25FD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A260E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A26144.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A262BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A262EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A26574.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A265C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A266C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A266E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/ObjIceblock_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A26B64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A26B74.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/func_80A26BF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Iceblock/ObjIceblock_Draw.s") +void ObjIceblock_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjIceblock* this = THIS; + Actor* parent; + s32 pad2; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.rot.x = 0; + 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)) { + 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); + 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)) { + 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 (!(this->unk_1B0 & 8)) { + parent = this->dyna.actor.parent; + if (parent != NULL) { + this->unk_1B0 |= 8; + Math_Vec3f_Diff(&parent->world.pos, &this->dyna.actor.world.pos, &this->unk_248); + this->unk_254.x = parent->shape.rot.x - this->dyna.actor.home.rot.x; + this->unk_254.y = parent->shape.rot.y - this->dyna.actor.home.rot.y; + this->unk_254.z = parent->shape.rot.z - this->dyna.actor.home.rot.z; + } + } + + if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + this->unk_2B4 = -1.0f; + } + + this->unk_2B0 = 0; + this->unkFunc = func_80A26B64; + func_80A257A0(this); + this->unk_2AE = 450; +} + +void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjIceblock* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void func_80A257A0(ObjIceblock* this) { + this->actionFunc = func_80A257B4; +} + +void func_80A257B4(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; + func_80A25824(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80A25824(ObjIceblock* this) { + this->actionFunc = func_80A2586C; + this->unk_2A0 = 2; + Actor_SetScale(&this->dyna.actor, 0.01f); + func_80A2319C(this, this->dyna.actor.scale.x); +} + +void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx) { + func_80A236D4(this, &this->dyna.actor.home.pos); + + if (this->unk_2A0 > 0) { + this->unk_2A0--; + 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)) { + this->unk_2B4 = 0.05f; + } + func_80A25978(this); + } else { + Actor_SetScale(&this->dyna.actor, this->dyna.actor.scale.x); + this->unk_2A0 = 2; + } + + func_80A2319C(this, this->dyna.actor.scale.x); + + if (this->dyna.actor.flags & 0x40) { + 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; +} + +void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + + func_80A236D4(this, &this->dyna.actor.home.pos); + if (this->unk_2A0 > 0) { + this->unk_2A0--; + return; + } + + if (this->dyna.actor.flags & 0x40) { + func_80A2339C(globalCtx, &this->dyna.actor.world.pos, this->dyna.actor.scale.x, 1.2f, 15); + if (OBJICEBLOCK_GET_1(&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; + func_80A2339C(globalCtx, &sp30, this->dyna.actor.scale.x, 1.2f, 10); + } + } + + if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + this->unk_2B4 = 0.1f; + } + + func_80A25A8C(this); + this->unkFunc = func_80A26B74; +} + +void func_80A25A8C(ObjIceblock* this) { + this->actionFunc = func_80A25AA8; + this->unk_2A0 = 2; +} + +void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { + s32 pad[2]; + f32 sp24; + s32 temp = func_80A236D4(this, &this->dyna.actor.home.pos); + + if (this->unk_2A0 > 0) { + this->unk_2A0--; + return; + } + + if (temp) { + sp24 = this->dyna.actor.scale.y * 300.0f; + func_80A23D08(this, globalCtx); + if (sp24 < (this->dyna.actor.world.pos.y - this->dyna.actor.floorHeight)) { + func_80A25BA0(this); + } else { + func_80A25C5C(this); + } + + this->dyna.actor.world.pos.y -= sp24; + this->dyna.actor.shape.yOffset = 300.0f; + this->unk_248.y += sp24; + + if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + this->collider.dim.yShift = -69; + } else { + this->collider.dim.yShift = 0; + } + this->unk_1B0 |= 0x100; + } +} + +void func_80A25BA0(ObjIceblock* this) { + this->actionFunc = func_80A25BBC; + this->dyna.actor.velocity.y = 0.0f; +} + +void func_80A25BBC(ObjIceblock* this, GlobalContext* globalCtx) { + if (func_80A25238(this) != -1) { + func_80A2541C(this, globalCtx); + } + + func_80A23690(this); + + if (func_80A23F90(this, globalCtx)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + + if (func_80A24954(this, globalCtx)) { + func_80A2491C(this); + if (this->unk_2B0 == 3) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DIVE_INTO_WATER_L); + } + } +} + +void func_80A25C5C(ObjIceblock* this) { + this->actionFunc = func_80A25C70; +} + +void func_80A25C70(ObjIceblock* this, GlobalContext* globalCtx) { + if (func_80A25238(this) != -1) { + func_80A2541C(this, globalCtx); + } + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.floorHeight - 0.1f, 14.0f)) { + func_80A23F90(this, globalCtx); + func_80A24954(this, globalCtx); + } +} + +void func_80A25CF4(ObjIceblock* this) { + func_80A25404(this); + this->actionFunc = func_80A25D28; +} + +void func_80A25D28(ObjIceblock* this, GlobalContext* globalCtx) { + s32 sp34; + s32 sp30; + Vec3f sp24; + + func_80A23690(this); + func_80A23F90(this, globalCtx); + sp30 = func_80A25238(this); + func_80A252DC(this, sp30); + sp34 = true; + if (sp30 == -1) { + sp34 = false; + } else if (!(this->unk_1B0 & 2) && (this->unk_26E[sp30] >= 11)) { + sp34 = true; + if (!func_80A24118(this, globalCtx, (this->dyna.pushForce > 0.0f) ? 59.9f : 89.9f, &sp24)) { + func_80A232C4(this, sp30); + func_80A25E3C(this); + sp34 = false; + } + } + + if (sp34) { + func_80A2541C(this, globalCtx); + } + + func_80A24A48(this, globalCtx); +} + +void func_80A25E3C(ObjIceblock* this) { + this->actionFunc = func_80A25E50; +} + +void func_80A25E50(ObjIceblock* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp_f0 = this->unk_268 - *this->unk_264; + f32 temp_f2 = (Math_SinS(fabsf(temp_f0) * 546.13336f) * 2.8f) + 1.2f; + s32 sp38 = Math_StepToF(this->unk_264, this->unk_268, CLAMP_MAX(temp_f2, 3.5f)); + s32 pad2; + Vec3f sp28; + + func_80A23690(this); + if (!func_80A23F90(this, globalCtx)) { + func_80A24680(this, globalCtx); + func_80A23B88(this); + func_80A2541C(this, globalCtx); + func_80A25BA0(this); + } else if (sp38) { + if (func_80A24118(this, globalCtx, 59.9f, &sp28)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + func_80A2541C(this, globalCtx); + func_80A25CF4(this); + } else { + func_800B9010(&this->dyna.actor, 0xDF); + } +} + +void func_80A25FA0(ObjIceblock* this) { + func_80A25404(this); + this->actionFunc = func_80A25FD4; +} + +void func_80A25FD4(ObjIceblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30; + s32 sp2C; + Vec3f sp20; + + func_80A23690(this); + func_80A23F90(this, globalCtx); + sp2C = func_80A25238(this); + func_80A252DC(this, sp2C); + sp30 = true; + + if (sp2C == -1) { + sp30 = false; + } else if (!(this->unk_1B0 & 2) && (this->unk_26E[sp2C] >= 11) && !func_80A24118(this, globalCtx, 2.0f, &sp20) && + !Player_InCsMode(&globalCtx->state)) { + func_80A23370(this, sp2C); + func_80A260E8(this); + sp30 = false; + func_800B7298(globalCtx, &this->dyna.actor, 7); + this->unk_1B0 |= 1; + } + + if (this) {} + + if (sp30) { + func_80A2541C(this, globalCtx); + } + func_80A24A48(this, globalCtx); +} + +void func_80A260E8(ObjIceblock* this) { + static f32 D_80A26FC0[] = { 14.0, -14.0, 14.0, -14.0 }; + + this->unk_260 = D_80A26FC0[this->unk_26C]; + this->unk_25C = 0.0f; + this->dyna.actor.velocity.y = 0.0f; + this->unk_2A0 = 15; + func_80A24DC4(this); + this->actionFunc = func_80A26144; +} + +void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { + s32 pad2; + s32 sp28; + s32 isBool; + s32 sp24; + + if (this->unk_2A0 > 0) { + this->unk_2A0--; + } + + Math_StepToF(&this->unk_25C, this->unk_260, 0.75f); + *this->unk_264 += this->unk_25C; + sp28 = func_80A24384(this, globalCtx); + func_80A23690(this); + sp24 = func_80A23F90(this, globalCtx); + isBool = sp24 == 0; + + if (isBool || sp28 || (this->unk_2A0 == 1)) { + func_80A2541C(this, globalCtx); + } + + if ((this->unk_1B0 & 1) && (isBool || sp28 || (this->dyna.actor.xzDistToPlayer > 400.0f))) { + this->unk_1B0 &= ~1; + func_800B7298(globalCtx, &this->dyna.actor, 6); + } + + if (isBool) { + func_80A24680(this, globalCtx); + func_80A23B88(this); + func_80A25BA0(this); + } else if (sp28) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + func_80A23B88(this); + func_80A25FA0(this); + } else { + func_800B9010(&this->dyna.actor, 0xDF); + } + + func_80A24DD0(this, globalCtx); +} + +void func_80A262BC(ObjIceblock* this) { + this->actionFunc = func_80A262EC; + this->dyna.actor.velocity.y *= 0.7f; + this->unk_2A0 = -1; +} + +void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp_f14; + f32 temp_f18; + Vec3f sp38; + f32 temp; + + if (func_80A25238(this) != -1) { + func_80A2541C(this, globalCtx); + } + + if (this->unk_2A0 > 0) { + this->unk_2A0--; + } + + if (this->unk_2A0 == -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; + } else { + this->unk_2A0 = 0; + } + } else if (this->unk_2A0 == 1) { + func_80A24BDC(this, globalCtx, 0.7f, 1.3f, 6); + func_80A24B74(this, globalCtx); + } + + this->dyna.actor.velocity.y += 5.0f; + if (this->dyna.actor.velocity.y > 3.0f) { + this->dyna.actor.velocity.y = 3.0f; + } + + temp = this->dyna.actor.velocity.y; + this->dyna.actor.world.pos.y += temp; + temp_f14 = this->dyna.actor.world.pos.y + (600.0f * this->dyna.actor.scale.y); + if (this->unk_244 < (temp_f14 - 90.0f)) { + func_80A24B74(this, globalCtx); + func_80A26574(this); + } else { + if ((this->dyna.actor.velocity.y > 0.0f) && (temp_f14 < (this->unk_244 + 3.0f)) && + (this->unk_244 <= temp_f14)) { + func_80A24BDC(this, globalCtx, 0.8f, 1.0f, 11); + func_80A24B74(this, globalCtx); + } + + sp38.x = this->dyna.actor.world.pos.x; + sp38.y = (this->unk_244 - (600.0f * this->dyna.actor.scale.y)) + 90.0f; + sp38.z = this->dyna.actor.world.pos.z; + + if (func_80A246D8(this, globalCtx, &sp38)) { + this->unk_1B0 |= 0x80; + } + } +} + +void func_80A26574(ObjIceblock* this) { + this->actionFunc = func_80A265C0; + this->unk_27C.unk_10 = 0; + this->unk_27C.unk_12 = 0; + this->unk_27C.unk_0C = 2111; + this->unk_27C.unk_0E = 3000; + this->unk_27C.unk_18 = 500; + this->unk_27C.unk_22 = 500; + this->unk_27C.unk_08 = 7.0f; + this->unk_2A0 = 40; +} + +void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx) { + s32 pad; + ObjIceBlockUnkStruct4* ptr; + + if (func_80A25238(this) != -1) { + func_80A2541C(this, globalCtx); + } + + if (this->unk_2A0 > 0) { + this->unk_2A0--; + } else { + ptr = &this->unk_27C; + this->unk_2A0 = 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; + ptr->unk_14 = (u32)Rand_Next() >> 0x10; + func_80A24B74(this, globalCtx); + } + + func_80A237A4(this); + func_80A23938(this); + + if (this->unk_1B0 & 0x40) { + func_80A24B74(this, globalCtx); + } + + func_80A24A48(this, globalCtx); +} + +void func_80A266C4(ObjIceblock* this) { + this->actionFunc = func_80A266E0; + this->unk_2A8 = 0.0f; +} + +void func_80A266E0(ObjIceblock* this, GlobalContext* globalCtx) { + f32 temp; + s32 sp20; + Actor* actor = &this->dyna.actor; + + Math_StepToF(&this->unk_2A8, (1.0f / 600.0f), (1.0f / 6000.0f)); + sp20 = Math_StepToF(&actor->scale.y, 0.0f, this->unk_2A8); + temp = actor->scale.y * 10.0f * 300.0f; + actor->shape.yOffset = temp; + + if (actor->scale.y < 0.075f) { + actor->scale.x = Math_SinS(actor->scale.y * 218453.33f) * 0.1f; + if (actor->scale.x < 0.0f) { + actor->scale.x = 0.0f; + } + actor->scale.z = actor->scale.x; + } + + if (OBJICEBLOCK_GET_1(&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; + this->collider.dim.radius = actor->scale.x * 290.0f; + } + + func_80A2508C(this, globalCtx); + + if (sp20) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjIceblock* this = THIS; + Actor* parent = this->dyna.actor.parent; + + if (parent != NULL) { + if ((parent->update == NULL) || (&this->dyna.actor != parent->child)) { + this->dyna.actor.parent = NULL; + parent = NULL; + } + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (this->unk_1B0 & 0x20) { + this->unk_1B0 &= ~0x40; + } else { + this->unk_1B0 |= 0x40; + this->unk_1B0 |= 0x20; + } + } else if (this->unk_1B0 & 0x20) { + this->unk_1B0 |= 0x40; + this->unk_1B0 &= ~0x20; + } else { + this->unk_1B0 &= ~0x40; + } + + if ((this->unk_2B0 == 1) || (this->unk_2B0 == 2) || (this->unk_2B0 == 3)) { + if (this->unk_2AE > 0) { + this->unk_2AE--; + } + } + + if (((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800)) || + (this->unk_2AE == 0)) { + this->unk_2AE = -1; + this->unk_2B0 = 4; + this->unk_1B0 &= ~0x100; + if (this->unk_1B0 & 1) { + this->unk_1B0 &= ~1; + func_800B7298(globalCtx, &this->dyna.actor, 6); + } + func_80A266C4(this); + } + + if (this->unk_2B1 > 0) { + this->unk_2B1--; + if (this->unk_2B1 == 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + } + } + + this->actionFunc(this, globalCtx); + if (this->dyna.actor.update == NULL) { + if (parent != NULL) { + parent->child = NULL; + parent->shape.rot.x = this->unk_254.x + this->dyna.actor.home.rot.x; + parent->shape.rot.y = this->unk_254.y + this->dyna.actor.home.rot.y; + parent->shape.rot.z = this->unk_254.z + this->dyna.actor.home.rot.z; + this->dyna.actor.parent = NULL; + } + return; + } + + this->collider.base.ocFlags1 &= ~OC1_HIT; + this->collider.base.acFlags &= ~AC_HIT; + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + + if (this->unk_1B0 & 0x10) { + if (OBJICEBLOCK_GET_1(&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 |= + (0x800000 | 0x400000 | 0x10000 | 0x2000 | 0x1000 | 0x800 | 0x200 | 0x100 | 0x80 | 0x20 | 0x10 | 0x2); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } else { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->unk_1B0 & 0x100) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + func_80A25440(this); + Actor_SetFocus(&this->dyna.actor, this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y); + this->unk_1B0 &= ~0x2; + + if (parent) {} +} + +void func_80A26B64(ObjIceblock* this, GlobalContext* globalCtx) { +} + +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); + } +} + +void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { + s32 pad[2]; + ObjIceBlockUnkStruct* ptr; + s32 i; + Vec3s sp70; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + sp70.z = 0; + + for (i = 0; i < ARRAY_COUNT(this->unk_1B4); i++) { + ptr = &this->unk_1B4[i]; + sp70.x = ptr->unk_00; + sp70.y = ptr->unk_02; + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &sp70); + 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); + } + + if (OBJICEBLOCK_GET_1(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_ice_block_Matanimheader_0009D0)); + 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); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjIceblock_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjIceblock* this = THIS; + + AnimatedMat_Draw(globalCtx, D_80A26E7C); + this->unkFunc(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 4851a87638..6a4875bb31 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h @@ -6,12 +6,76 @@ struct ObjIceblock; typedef void (*ObjIceblockActionFunc)(struct ObjIceblock*, GlobalContext*); +typedef void (*ObjIceblockUnkFunc)(struct ObjIceblock*, GlobalContext*); + +#define OBJICEBLOCK_GET_2(thisx) (((thisx)->params >> 1) & 1) +#define OBJICEBLOCK_GET_1(thisx) ((thisx)->params & 1) + +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; +} ObjIceBlockUnkStruct; // size = 0x10 + +typedef struct { + /* 0x00 */ CollisionPoly* unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ s32 unk_08; + /* 0x0C */ f32 unk_0C; +} ObjIceBlockUnkStruct2; // size = 0x10 + +typedef struct { + f32 unk_00; + f32 unk_04; +} ObjIceBlockUnkStruct3; // size = 0x8 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s16 unk_0E; + /* 0x10 */ s16 unk_10; + /* 0x12 */ s16 unk_12; + /* 0x14 */ s16 unk_14; + /* 0x14 */ s16 unk_16; + /* 0x18 */ s16 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ s16 unk_20; + /* 0x22 */ s16 unk_22; +} ObjIceBlockUnkStruct4; // size = 0x24 typedef struct ObjIceblock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderCylinder collider; /* 0x01A8 */ ObjIceblockActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x10C]; + /* 0x01AC */ ObjIceblockUnkFunc unkFunc; + /* 0x01B0 */ s32 unk_1B0; + /* 0x01B4 */ ObjIceBlockUnkStruct unk_1B4[4]; + /* 0x01F4 */ ObjIceBlockUnkStruct2 unk_1F4[5]; + /* 0x0244 */ f32 unk_244; + /* 0x0248 */ Vec3f unk_248; + /* 0x0254 */ Vec3s unk_254; + /* 0x025C */ f32 unk_25C; + /* 0x0260 */ f32 unk_260; + /* 0x0264 */ f32* unk_264; + /* 0x0268 */ f32 unk_268; + /* 0x026C */ s16 unk_26C; + /* 0x026E */ s16 unk_26E[4]; + /* 0x0276 */ s16 unk_276; + /* 0x0278 */ s16 unk_278; + /* 0x027C */ ObjIceBlockUnkStruct4 unk_27C; + /* 0x02A0 */ s16 unk_2A0; + /* 0x02A2 */ s16 unk_2A2; + /* 0x02A4 */ f32 unk_2A4; + /* 0x02A8 */ f32 unk_2A8; + /* 0x02AC */ s16 unk_2AC; + /* 0x02AE */ s16 unk_2AE; + /* 0x02B0 */ s8 unk_2B0; + /* 0x02B1 */ s8 unk_2B1; + /* 0x02B4 */ f32 unk_2B4; } ObjIceblock; // size = 0x2B8 extern const ActorInit Obj_Iceblock_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c index e855487587..4334659864 100644 --- a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c +++ b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c @@ -15,7 +15,6 @@ void ObjJgGakki_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjJgGakki_Update(Actor* thisx, GlobalContext* globalCtx); void ObjJgGakki_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Jg_Gakki_InitVars = { ACTOR_OBJ_JG_GAKKI, ACTORCAT_PROP, @@ -28,14 +27,42 @@ const ActorInit Obj_Jg_Gakki_InitVars = { (ActorFunc)ObjJgGakki_Draw, }; -#endif +extern AnimationHeader D_0601B1E8; // gGoronElderDrumAnim +extern SkeletonHeader D_0601B210; // gGoronElderDrumSkel -extern UNK_TYPE D_0601B1E8; +void ObjJgGakki_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjJgGakki* this = THIS; + f32 frameCount = Animation_GetLastFrame(&D_0601B1E8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jg_Gakki/ObjJgGakki_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &D_0601B210, NULL, NULL, NULL, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jg_Gakki/ObjJgGakki_Destroy.s") + if (((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7)) && + (globalCtx->csCtx.unk_12 == 0)) { + Animation_Change(&this->skelAnime, &D_0601B1E8, 1.0f, frameCount, frameCount, 2, 0.0f); + } else if ((globalCtx->sceneNum == SCENE_17SETUGEN) || (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA)) { + Animation_Change(&this->skelAnime, &D_0601B1E8, 1.0f, 0.0f, frameCount, 2, 0.0f); + } else { + Actor_MarkForDeath(&this->actor); + } + Actor_SetScale(&this->actor, 0.01f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jg_Gakki/ObjJgGakki_Update.s") +void ObjJgGakki_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjJgGakki* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jg_Gakki/ObjJgGakki_Draw.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void ObjJgGakki_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjJgGakki* this = THIS; + + SkelAnime_Update(&this->skelAnime); +} + +void ObjJgGakki_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjJgGakki* this = THIS; + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.h b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.h index 75a02ed4aa..a3e8ae8eb8 100644 --- a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.h +++ b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.h @@ -7,7 +7,8 @@ struct ObjJgGakki; typedef struct ObjJgGakki { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x90]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderCylinder collider; } ObjJgGakki; // size = 0x1D4 extern const ActorInit Obj_Jg_Gakki_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c b/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c index 65a39be35b..6782e15ebe 100644 --- a/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c +++ b/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c @@ -57,5 +57,5 @@ void ObjKepnKoya_Update(Actor* thisx, GlobalContext* globalCtx) { } void ObjKepnKoya_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06003478); + Gfx_DrawDListOpa(globalCtx, D_06003478); } diff --git a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c index 204b506630..34d45038ae 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c @@ -5,6 +5,8 @@ */ #include "z_obj_kibako.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "objects/object_kibako/object_kibako.h" #define FLAGS 0x04000010 @@ -66,18 +68,15 @@ static ColliderCylinderInit sCylinderInit = { { 15, 30, 0, { 0, 0, 0 } }, }; -extern Gfx D_06001A70[]; -extern Gfx D_06001180[]; - static s16 sObjectIdList[] = { GAMEPLAY_DANGEON_KEEP, OBJECT_KIBAKO }; -static Gfx* sKakeraDisplayLists[] = { D_05007980, D_06001A70 }; +static Gfx* sKakeraDisplayLists[] = { gameplay_dangeon_keep_DL_007980, gSmallCrateFragmentDL }; -static Gfx* sDisplayLists[] = { D_05007890, D_06001180 }; +static Gfx* sDisplayLists[] = { gameplay_dangeon_keep_DL_007890, gSmallCrateDL }; static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -1500, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -18000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -18000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 60, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 60, ICHAIN_STOP), }; @@ -97,7 +96,7 @@ void ObjKibako_SpawnCollectible(ObjKibako* this, GlobalContext* globalCtx) { void ObjKibako_SetShadow(ObjKibako* this) { if ((this->actor.projectedPos.z < 370.0f) && (this->actor.projectedPos.z > -10.0f)) { - this->actor.shape.shadowDraw = func_800B4024; + this->actor.shape.shadowDraw = ActorShadow_DrawSquare; this->actor.shape.shadowScale = 1.4f; this->actor.shape.shadowAlpha = (this->actor.projectedPos.z < 200.0f) ? 100 : (400 - ((s32)this->actor.projectedPos.z)) >> 1; @@ -121,8 +120,8 @@ void func_80926318(ObjKibako* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer < 100.0f) { angle = this->actor.yawTowardsPlayer - GET_PLAYER(globalCtx)->actor.world.rot.y; - if (ABS_ALT(angle) >= 0x5556) { - func_800B8A1C(&this->actor, globalCtx, GI_NONE, 36.0f, 30.0f); + if (ABS_ALT(angle) > 0x5555) { + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 36.0f, 30.0f); } } } @@ -252,7 +251,7 @@ void func_80926B40(ObjKibako* this) { } void func_80926B54(ObjKibako* this, GlobalContext* globalCtx) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.draw = ObjKibako_Draw; @@ -276,20 +275,23 @@ void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx) { if (func_800A817C(KIBAKO_COLLECTIBLE_ID(&this->actor))) { ObjKibako_SpawnCollectible(this, globalCtx); } - func_800B8E58(&this->actor, NA_SE_PL_PULL_UP_WOODBOX); + + //! @bug: This function should only pass Player*: it uses *(this + 0x153), which is meant to be + //! player->currentMask, but in this case is garbage in the collider + func_800B8E58((Player*)this, NA_SE_PL_PULL_UP_WOODBOX); } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 19.0f)) { ObjKibako_WaterBreak(this, globalCtx); ObjKibako_SpawnCollectible(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); Actor_MarkForDeath(&this->actor); } else if (this->collider.base.acFlags & AC_HIT) { ObjKibako_AirBreak(this, globalCtx); ObjKibako_SpawnCollectible(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); Actor_MarkForDeath(&this->actor); } else { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_809262BC(this); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); @@ -341,9 +343,9 @@ void ObjKibako_Held(ObjKibako* this, GlobalContext* globalCtx) { if (fabsf(this->actor.speedXZ) < 0.1f) { ObjKibako_SetupIdle(this); this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PUT_DOWN_WOODBOX); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PUT_DOWN_WOODBOX); } else { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); ObjKibako_SetupThrown(this); this->actor.flags &= ~0x4000000; } @@ -385,20 +387,20 @@ void ObjKibako_Thrown(ObjKibako* this, GlobalContext* globalCtx) { if ((this->actor.bgCheckFlags & 0xB) || (atHit) || (this->timer <= 0)) { ObjKibako_AirBreak(this, globalCtx); ObjKibako_SpawnCollectible(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); Actor_MarkForDeath(&this->actor); } else { if (this->actor.bgCheckFlags & 0x40) { ObjKibako_WaterBreak(this, globalCtx); ObjKibako_SpawnCollectible(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); Actor_MarkForDeath(&this->actor); } else { if (this->actor.velocity.y < -0.05f) { this->actor.gravity = -2.3f; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Math_StepToS(&D_80927384, D_80927380, 0xA0); Math_StepToS(&D_8092738C, D_80927388, 0xA0); this->actor.shape.rot.x = (s16)(this->actor.shape.rot.x + D_80927384); @@ -419,5 +421,5 @@ void ObjKibako_Update(Actor* thisx, GlobalContext* globalCtx) { } void ObjKibako_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, sDisplayLists[KIBAKO_BANK_INDEX(thisx)]); + Gfx_DrawDListOpa(globalCtx, sDisplayLists[KIBAKO_BANK_INDEX(thisx)]); } diff --git a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c index 69bfaad18c..dd8029eca3 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c @@ -5,6 +5,7 @@ */ #include "z_obj_kibako2.h" +#include "objects/object_kibako2/object_kibako2.h" #include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" #define FLAGS 0x00000000 @@ -57,10 +58,6 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -extern Gfx D_06000960[]; -extern CollisionHeader D_06000B70; -extern Gfx D_06001040[]; - s32 ObjKibako2_ContainsSkulltula(ObjKibako2* this, GlobalContext* globalCtx) { s32 actorSpawnParam = KIBAKO2_SKULLTULA_SPAWN_PARAM(&this->dyna.actor); s32 flag = -1; @@ -68,7 +65,7 @@ s32 ObjKibako2_ContainsSkulltula(ObjKibako2* this, GlobalContext* globalCtx) { if ((u16)actorSpawnParam & 3) { flag = ((actorSpawnParam & 0x3FC) >> 2) & 0xFF; } - return !(flag >= 0 && Actor_GetChestFlag(globalCtx, flag)); + return !(flag >= 0 && Flags_GetTreasure(globalCtx, flag)); } void ObjKibako2_Break(ObjKibako2* this, GlobalContext* globalCtx) { @@ -103,7 +100,7 @@ void ObjKibako2_Break(ObjKibako2* this, GlobalContext* globalCtx) { phi_s0 = 0x20; } EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -200, phi_s0, 28, 2, 0, (Rand_ZeroOne() * 30.0f) + 5.0f, - 0, 0, 70, KAKERA_COLOR_NONE, OBJECT_KIBAKO2, D_06001040); + 0, 0, 70, KAKERA_COLOR_NONE, OBJECT_KIBAKO2, gLargeCrateFragment1DL); } func_800BBFB0(globalCtx, thisPos, 90.0f, 6, 100, 160, 1); } @@ -147,12 +144,12 @@ void ObjKibako2_SpawnContents(ObjKibako2* this, GlobalContext* globalCtx) { void ObjKibako2_Init(Actor* thisx, GlobalContext* globalCtx) { ObjKibako2* this = THIS; s32 pad; - ObjKibako2Contents contents = KIBAKO2_CONTENTS(&this->dyna.actor); + s32 contents = KIBAKO2_CONTENTS(&this->dyna.actor); DynaPolyActor_Init(&this->dyna, 0); Collider_InitCylinder(globalCtx, &this->collider); Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000B70); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gLargeCrateCol); Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->dyna.actor.home.rot.z = 0; @@ -212,7 +209,7 @@ s32 ObjKibako2_ShouldBreak(ObjKibako2* this) { void ObjKibako2_Idle(ObjKibako2* this, GlobalContext* globalCtx) { if (ObjKibako2_ShouldBreak(this)) { ObjKibako2_Break(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); this->dyna.actor.flags |= 0x10; func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; @@ -236,7 +233,7 @@ void ObjKibako2_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->skulltulaNoiseTimer >= 0) { if (this->skulltulaNoiseTimer == 0) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_STALGOLD_ROLL); if (Rand_ZeroOne() < 0.1f) { this->skulltulaNoiseTimer = Rand_S16Offset(40, 80); } else { @@ -250,5 +247,5 @@ void ObjKibako2_Update(Actor* thisx, GlobalContext* globalCtx) { } void ObjKibako2_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000960); + Gfx_DrawDListOpa(globalCtx, gLargeCrateDL); } diff --git a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.h b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.h index b6de7da89c..dd4687ab21 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.h +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.h @@ -18,11 +18,11 @@ struct ObjKibako2; typedef void (*ObjKibako2ActionFunc)(struct ObjKibako2*, GlobalContext*); typedef struct ObjKibako2 { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ ObjKibako2ActionFunc actionFunc; - /* 0x01AC */ s8 unk_1AC; - /* 0x01AD */ s8 skulltulaNoiseTimer; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ ObjKibako2ActionFunc actionFunc; + /* 0x1AC */ s8 unk_1AC; + /* 0x1AD */ s8 skulltulaNoiseTimer; } ObjKibako2; // size = 0x1B0 extern const ActorInit Obj_Kibako2_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c index c6fd52f13d..481cc22f6a 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -31,7 +31,7 @@ const ActorInit Obj_Lift_InitVars = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_8093DD84[] = { ICHAIN_F32_DIV1000(gravity, -600, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -15000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -15000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 350, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 350, ICHAIN_STOP), diff --git a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c index 9f4b8c2b0d..185361c41b 100644 --- a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c +++ b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c @@ -148,7 +148,7 @@ void func_80AF3B8C(ObjLightblock* this) { void func_80AF3BA0(ObjLightblock* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - Actor_SetSwitchFlag(globalCtx, LIGHTBLOCK_DESTROYED(&this->dyna.actor)); + Flags_SetSwitch(globalCtx, LIGHTBLOCK_DESTROYED(&this->dyna.actor)); func_80AF3910(this, globalCtx); func_80AF3C18(this); } else { diff --git a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c index 35c81daa91..3d8b8d307d 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -106,9 +106,9 @@ void ObjLightswitch_UpdateSwitchFlags(ObjLightswitch* this, GlobalContext* globa if (this) {} if (set) { - Actor_SetSwitchFlag(globalCtx, GET_LIGHTSWITCH_SWITCHFLAG(this)); + Flags_SetSwitch(globalCtx, GET_LIGHTSWITCH_SWITCHFLAG(this)); } else { - Actor_UnsetSwitchFlag(globalCtx, GET_LIGHTSWITCH_SWITCHFLAG(this)); + Flags_UnsetSwitch(globalCtx, GET_LIGHTSWITCH_SWITCHFLAG(this)); } } @@ -145,7 +145,7 @@ void ObjLightswitch_SpawnEffects(ObjLightswitch* this, GlobalContext* globalCtx) effectPos.y = this->actor.world.pos.y + tempResultDiff + 10.0f; effectPos.z = this->actor.world.pos.z + ((rand * cosResult) - (tempResult * sinResult)); - EffectSsDeadDb_Spawn(globalCtx, &effectPos, &D_801D15B0, &D_801D15B0, &sLightswitchEffectPrimColor, + EffectSsDeadDb_Spawn(globalCtx, &effectPos, &gZeroVec3f, &gZeroVec3f, &sLightswitchEffectPrimColor, &sLightswitchEffectEnvColor, 100, 0, 9); } } @@ -159,7 +159,7 @@ void ObjLightswitch_Init(Actor* thisx, GlobalContext* globalCtx) { isSwitchActivated = Flags_GetSwitch(globalCtx, GET_LIGHTSWITCH_SWITCHFLAG(this)); isTriggered = false; Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetHeight(&this->actor, 0.0f); + Actor_SetFocus(&this->actor, 0.0f); if (isSwitchActivated) { if (GET_LIGHTSWITCH_TYPE(this) == LIGHTSWITCH_TYPE_FAKE) { @@ -237,7 +237,7 @@ void ObjLightSwitch_SetupAsleep(ObjLightswitch* this) { void ObjLightSwitch_Asleep(ObjLightswitch* this, GlobalContext* globalCtx) { if (this->colorShiftTimer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SUN_MARK_FLASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SUN_MARK_FLASH); } this->colorShiftTimer++; @@ -250,7 +250,7 @@ void ObjLightSwitch_Asleep(ObjLightswitch* this, GlobalContext* globalCtx) { ObjLightSwitch_SetupEnabled(this); } else if (this->colorShiftTimer == 15) { this->faceState = LIGHTSWITCH_FACE_WAKING; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FOOT_SWITCH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FOOT_SWITCH); } } @@ -308,7 +308,7 @@ void ObjLightSwitch_Disabled(ObjLightswitch* this, GlobalContext* globalCtx) { ObjLightswitch_SetupIdle(this); } else if (this->colorShiftTimer == 15) { this->faceState = LIGHTSWITCH_FACE_ASLEEP; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FOOT_SWITCH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FOOT_SWITCH); } } diff --git a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c index e864e86b42..c7f49d683a 100644 --- a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c +++ b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c @@ -43,15 +43,15 @@ void ObjMakeoshihiki_SetSwitchFlags(ObjMakeoshihiki* this, GlobalContext* global switchFlag1 = OBJMAKEOSHIHIKI_GET_SWITCHFLAG_1(this); if (pathIndex & 2) { - Actor_SetSwitchFlag(globalCtx, switchFlag2); + Flags_SetSwitch(globalCtx, switchFlag2); } else { - Actor_UnsetSwitchFlag(globalCtx, switchFlag2); + Flags_UnsetSwitch(globalCtx, switchFlag2); } if (pathIndex & 1) { - Actor_SetSwitchFlag(globalCtx, switchFlag1); + Flags_SetSwitch(globalCtx, switchFlag1); } else { - Actor_UnsetSwitchFlag(globalCtx, switchFlag1); + Flags_UnsetSwitch(globalCtx, switchFlag1); } } diff --git a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c index 5af8763039..9a614c47d2 100644 --- a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c +++ b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c @@ -100,6 +100,6 @@ void ObjMilkBin_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjMilkBin* this = THIS; if (!(this->disableDraw & 1)) { - func_800BDFC0(globalCtx, D_060004B0); + Gfx_DrawDListOpa(globalCtx, D_060004B0); } } diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c index 153a4a914b..6bacc61642 100644 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c +++ b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c @@ -78,7 +78,7 @@ void func_80C06640(ObjMoonStone* this, GlobalContext* globalCtx) { s16 sp1A = this->actor.yawTowardsPlayer - 0x8000; sp1A -= player->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.colChkInfo.health = 1; func_801518B0(globalCtx, 0x5E3U, &this->actor); func_80C066F8(this); @@ -95,7 +95,7 @@ void func_80C066F8(ObjMoonStone* this) { } void func_80C0670C(ObjMoonStone* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx) != 0) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actor.colChkInfo.health = 0; func_80C0662C(this); } @@ -122,7 +122,7 @@ void func_80C06768(ObjMoonStone* this, GlobalContext* globalCtx) { this->actor.draw = NULL; func_80C0685C(this); } else if (this->actor.xzDistToPlayer < 25.0f) { - func_800B8A1C(&this->actor, globalCtx, GI_MOON_TEAR, 100.0f, 30.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MOON_TEAR, 100.0f, 30.0f); } } } @@ -132,7 +132,7 @@ void func_80C0685C(ObjMoonStone* this) { } void func_80C06870(ObjMoonStone* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { gSaveContext.weekEventReg[74] |= 0x40; Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c index 0e510d6b31..04fe449916 100644 --- a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c +++ b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c @@ -63,7 +63,7 @@ void func_80C06B5C(ObjMuPict* this) { void func_80C06B70(ObjMuPict* this, GlobalContext* globalCtx) { s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->actor.cutscene < 0) { func_80C06DC8(this, globalCtx); func_80C06CC4(this); @@ -98,7 +98,7 @@ void func_80C06CC4(ObjMuPict* this) { } void func_80C06CD8(ObjMuPict* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: case 1: case 2: @@ -122,7 +122,7 @@ void func_80C06CD8(ObjMuPict* this, GlobalContext* globalCtx) { } void func_80C06D90(ObjMuPict* this, GlobalContext* globalCtx) { - Actor* actorPtr = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* actorPtr = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (actorPtr != NULL) { if (actorPtr->id == ACTOR_EN_HGO) { diff --git a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c index 041e869826..45bb9ffca9 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c @@ -226,7 +226,7 @@ void ObjRaillift_Update(Actor* thisx, GlobalContext* globalCtx) { f32 step; this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->dyna.actor, 10.0f); + Actor_SetFocus(&this->dyna.actor, 10.0f); if (this->cutsceneTimer > 0) { this->cutsceneTimer--; if (this->cutsceneTimer == 0) { @@ -283,12 +283,12 @@ void ObjRaillift_Draw(Actor* thisx, GlobalContext* globalCtx) { The non-colorful platforms are the ones found in Woodfall Temple */ void ObjRaillift_DrawDekuFlowerPlatform(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000208); + Gfx_DrawDListOpa(globalCtx, D_06000208); } /* The colorful platforms are the ones found in Deku Palace */ void ObjRaillift_DrawDekuFlowerPlatformColorful(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_060071B8); + Gfx_DrawDListOpa(globalCtx, D_060071B8); } diff --git a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c index e398d3336a..d7f15477a7 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c @@ -18,7 +18,6 @@ void func_80973CD8(ObjRoomtimer* this, GlobalContext* globalCtx); void func_80973D3C(ObjRoomtimer* this, GlobalContext* globalCtx); void func_80973DE0(ObjRoomtimer* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Roomtimer_InitVars = { ACTOR_OBJ_ROOMTIMER, ACTORCAT_ENEMY, @@ -31,16 +30,64 @@ const ActorInit Obj_Roomtimer_InitVars = { (ActorFunc)NULL, }; -#endif +void ObjRoomtimer_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjRoomtimer* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/ObjRoomtimer_Init.s") + this->switchFlag = ROOMTIMER_GET_SWITCHFLAG(thisx); + this->actor.params &= 0x1FF; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/ObjRoomtimer_Destroy.s") + if (this->actor.params != 0x1FF) { + this->actor.params = CLAMP_MAX(this->actor.params, 500); + } + this->actionFunc = func_80973CD8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/func_80973CD8.s") +void ObjRoomtimer_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjRoomtimer* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/func_80973D3C.s") + if (this->actor.params != 0x1FF && gSaveContext.unk_3DD0[4] > 0) { + gSaveContext.unk_3DD0[4] = 5; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/func_80973DE0.s") +void func_80973CD8(ObjRoomtimer* this, GlobalContext* globalCtx) { + if (this->actor.params != 0x1FF) { + func_8010E9F0(4, this->actor.params); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/ObjRoomtimer_Update.s") + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); + this->actionFunc = func_80973D3C; +} + +void func_80973D3C(ObjRoomtimer* this, GlobalContext* globalCtx) { + if (Flags_GetClearTemp(globalCtx, this->actor.room)) { + if (this->actor.params != 0x1FF) { + gSaveContext.unk_3DD0[4] = 5; + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_80973DE0; + } else if (this->actor.params != 0x1FF && gSaveContext.unk_3DD0[4] == 0) { + play_sound(NA_SE_OC_ABYSS); + func_80169EFC(globalCtx); + Actor_MarkForDeath(&this->actor); + } +} + +void func_80973DE0(ObjRoomtimer* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + Flags_SetClear(globalCtx, this->actor.room); + Flags_SetSwitch(globalCtx, this->switchFlag); + if (ActorCutscene_GetLength(this->actor.cutscene) != -1) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } + Actor_MarkForDeath(&this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void ObjRoomtimer_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjRoomtimer* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h index db43c5c16b..b58d5da495 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h @@ -3,6 +3,8 @@ #include "global.h" +#define ROOMTIMER_GET_SWITCHFLAG(thisx) (((thisx)->params >> 9) & 0x7F) + struct ObjRoomtimer; typedef void (*ObjRoomtimerActionFunc)(struct ObjRoomtimer*, GlobalContext*); @@ -10,7 +12,7 @@ typedef void (*ObjRoomtimerActionFunc)(struct ObjRoomtimer*, GlobalContext*); typedef struct ObjRoomtimer { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjRoomtimerActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4]; + /* 0x0148 */ s32 switchFlag; } ObjRoomtimer; // size = 0x14C extern const ActorInit Obj_Roomtimer_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c index 677ab56b98..7bd1dfc1e1 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c @@ -31,7 +31,7 @@ const ActorInit Obj_Skateblock_InitVars = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_80A22AE0[] = { ICHAIN_F32_DIV1000(gravity, -1700, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c index 42cec66230..9eb0ae99f4 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -5,6 +5,8 @@ */ #include "z_obj_snowball.h" +#include "objects/object_goroiwa/object_goroiwa.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -15,7 +17,22 @@ void ObjSnowball_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSnowball_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSnowball_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B02CD0(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B02D58(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B02DB0(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B02E54(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04338(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04350(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04540(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B0457C(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04608(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04648(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B046E4(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B047C0(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04B48(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04B60(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04D34(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Snowball_InitVars = { ACTOR_OBJ_SNOWBALL, ACTORCAT_PROP, @@ -28,80 +45,799 @@ const ActorInit Obj_Snowball_InitVars = { (ActorFunc)ObjSnowball_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80B04F50[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x81837FBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x81837FBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 73 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B04F74 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, D_80B04F50, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B04FD4[] = { +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ ObjSnowballActionFunc unk_04; +} ObjSnowballStruct2; + +static ObjSnowballStruct2 D_80B04F84[] = { + { -1, 0, func_80B02D58 }, + { ACTOR_EN_JG, 0, func_80B02DB0 }, + { ACTOR_EN_WF, 1, func_80B02E54 }, + { ACTOR_EN_TITE, -4, func_80B02CD0 }, + { ACTOR_EN_KAME, 0, func_80B02CD0 }, + { -1, 0, NULL }, +}; + +static Color_RGBA8 D_80B04FB4 = { 250, 250, 250, 255 }; +static Color_RGBA8 D_80B04FB8 = { 180, 180, 180, 255 }; +static Vec3f D_80B04FBC = { 0.0f, 0.3f, 0.0f }; + +static Gfx* D_80B04FC8[] = { + object_goroiwa_DL_0072F0, + object_goroiwa_DL_0077D0, + object_goroiwa_DL_007C60, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), }; +void func_80B02CD0(ObjSnowball* this, GlobalContext* globalCtx) { + ObjSnowballStruct2* ptr = &D_80B04F84[this->actor.home.rot.y]; + + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ptr->unk_00, this->actor.home.pos.x, + this->actor.home.pos.y, this->actor.home.pos.z, this->actor.home.rot.x, 0, + this->actor.home.rot.z, ptr->unk_02, -1, this->actor.unk20, NULL); +} + +void func_80B02D58(ObjSnowball* this, GlobalContext* globalCtx) { + s32 temp_v0 = func_800A8150(OBJSNOWBALL_GET_3F(&this->actor)); + + if (temp_v0 >= 0) { + Item_DropCollectible(globalCtx, &this->actor.home.pos, (OBJSNOWBALL_GET_7F00(&this->actor) << 8) | temp_v0); + } +} + +void func_80B02DB0(ObjSnowball* this, GlobalContext* globalCtx) { + s32 pad; + ObjSnowballStruct2* ptr = &D_80B04F84[this->actor.home.rot.y]; + + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ptr->unk_00, this->actor.home.pos.x, + this->actor.home.pos.y, this->actor.home.pos.z, this->actor.home.rot.x, 0, + this->actor.home.rot.z, this->actor.params | ptr->unk_02, + ActorCutscene_GetAdditionalCutscene(this->actor.cutscene), this->actor.unk20, NULL); +} + +void func_80B02E54(ObjSnowball* this, GlobalContext* globalCtx) { + ObjSnowballStruct2* ptr = &D_80B04F84[this->actor.home.rot.y]; + + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ptr->unk_00, this->actor.home.pos.x, + this->actor.home.pos.y, this->actor.home.pos.z, this->actor.home.rot.x, 0, + this->actor.home.rot.z, this->actor.params | ptr->unk_02, -1, this->actor.unk20, + NULL); +} + +void func_80B02EE4(ObjSnowball* this, GlobalContext* globalCtx) { + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + Vec3s* hitPos = &this->collider.elements->info.bumper.hitPos; + s32 i; + + for (i = 0; i < 4; i++) { + sp94.x = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->x; + sp94.y = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->y; + sp94.z = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->z; + + spA0.x = (Rand_ZeroOne() - 0.5f) * 1.6f; + spA0.y = -0.8f; + spA0.z = (Rand_ZeroOne() - 0.5f) * 1.6f; + + spAC.x = spA0.x * -0.06f; + spAC.y = spA0.y * -0.06f; + spAC.z = spA0.z * -0.06f; + + func_800B0E48(globalCtx, &sp94, &spA0, &spAC, &D_80B04FB4, &D_80B04FB8, (s32)(Rand_ZeroOne() * 30.0f) + 15, + (s32)(Rand_ZeroOne() * 40.0f) + 30); + } +} + +void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp_f28 = sqrtf(this->unk_20C); + Vec3f spFC; + Vec3f spF0; + Vec3f spE4; + s32 i; + s32 phi_s6; + Gfx* temp_s2; + s16 scale; + s32 temp_s1; + f32 temp_f20; + f32 temp_f22; + f32 temp_f26; + s16 temp_s0; + s32 temp_s7; + f32 phi_f22; + s32 gravity; + s32 phi_s0; + s32 phi_s4; + + for (i = 0, phi_s6 = 0; i < 25; i++, phi_s6 += 0xA3D) { + temp_s7 = i & 7; + if (temp_s7 < 4) { + temp_s2 = D_80B04FC8[2]; + gravity = -280; + phi_s4 = 0; + phi_s0 = 0x40; + phi_f22 = 1.0f; + } else if (temp_s7 < 6) { + temp_s2 = D_80B04FC8[1]; + gravity = -340; + phi_s4 = 0; + phi_f22 = 0.9f; + if (Rand_ZeroOne() < 0.4f) { + phi_s0 = 0x20; + } else { + phi_s0 = 0x40; + } + } else { + temp_s2 = D_80B04FC8[0]; + gravity = -400; + phi_s4 = 1; + phi_f22 = 0.8f; + if (Rand_Next() > 0) { + phi_s0 = 0x21; + } else { + phi_s0 = 0x41; + } + } + + temp_f20 = (Rand_ZeroOne() * (40.0f * this->unk_20C)) + 20.0f; + + spFC.x = Math_SinS((s32)(Rand_ZeroOne() * 2621.44f) + phi_s6) * temp_f20; + spFC.y = (Rand_ZeroOne() - 0.4f) * temp_f20 * 1.6666666f; + spFC.z = Math_CosS((s32)(Rand_ZeroOne() * 2621.44f) + phi_s6) * temp_f20; + + spF0.x = spFC.x * 0.16f * phi_f22; + spF0.y = (Rand_ZeroOne() * 16.0f) + 3.0f; + spF0.z = spFC.z * 0.16f * phi_f22; + + spFC.x += this->actor.world.pos.x; + spFC.y += this->actor.world.pos.y; + spFC.z += this->actor.world.pos.z; + + scale = ((Rand_ZeroOne() * 15.0f) + 30.0f) * this->unk_20C; + + EffectSsKakera_Spawn(globalCtx, &spFC, &spF0, &spFC, gravity, phi_s0, 30, 0, 0, scale, phi_s4, 0, 50, -1, 0xEF, + temp_s2); + if ((this->unk_210 == 0) && (temp_s7 >= 3)) { + spFC.x += (Rand_ZeroOne() * 120.0f) - 60.0f; + spFC.y += Rand_ZeroOne() * 80.0f; + spFC.z += (Rand_ZeroOne() * 120.0f) - 60.0f; + + temp_s0 = (s32)(Rand_ZeroOne() * 50.0f * temp_f28) + 40; + temp_s1 = (s32)(Rand_ZeroOne() * 60.0f * temp_f28) + 50; + func_800B0E48(globalCtx, &spFC, &gZeroVec3f, &D_80B04FBC, &D_80B04FB4, &D_80B04FB8, temp_s0, temp_s1); + } + } + + if (this->unk_210 != 0) { + temp_f26 = this->unk_20C * 60.0f; + + for (i = 0, phi_s6 = 0; i < 16; i++, phi_s6 += 0x1000) { + temp_s0 = (u32)Rand_Next() >> 0x10; + temp_f20 = Math_SinS(temp_s0); + temp_f22 = Math_CosS(temp_s0); + + spFC.x = Math_SinS(phi_s6); + spFC.z = Math_CosS(phi_s6); + + spF0.x = 2.0f * spFC.x; + spF0.y = (2.0f * Rand_ZeroOne()) + 1.0f; + spF0.z = 2.0f * spFC.z; + + spFC.x *= temp_f22 * temp_f26; + spFC.y = temp_f20 * temp_f26; + spFC.z *= temp_f22 * temp_f26; + + spFC.x += this->actor.world.pos.x; + spFC.y += this->actor.world.pos.y; + spFC.z += this->actor.world.pos.z; + + spE4.x = spF0.x * -0.02f; + spE4.y = spF0.y * -0.05f; + spE4.z = spF0.z * -0.02f; + + EffectSsIceSmoke_Spawn(globalCtx, &spFC, &spF0, &spE4, ((s32)(Rand_ZeroOne() * 170.0f) + 150) * temp_f28); + } + } +} + +void func_80B03688(ObjSnowball* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + s32 pad[2]; + f32 temp_f20; + f32 temp_f22 = sqrtf(this->unk_20C); + s16 temp_s3; + s32 phi_s0; + + if (this->unk_210 == 0) { + for (i = 0, phi_s0 = 0; i < 10; i++, phi_s0 += 0x1999) { + temp_f20 = (Rand_ZeroOne() * (45.0f * this->unk_20C)) + 50.0f; + + spB8.x = Math_SinS((s32)(Rand_ZeroOne() * 6553.6f) + phi_s0) * temp_f20; + spB8.y = Rand_ZeroOne() * 20.0f; + spB8.z = Math_CosS((s32)(Rand_ZeroOne() * 6553.6f) + phi_s0) * temp_f20; + + spAC.x = spB8.x * 0.06f; + spAC.y = 0.0f; + spAC.z = spB8.z * 0.06f; + + spA0.x = spAC.x * -0.08f; + spA0.y = 0.3f; + spA0.z = spAC.z * -0.08f; + + spB8.x += this->actor.home.pos.x; + spB8.y += this->actor.home.pos.y; + spB8.z += this->actor.home.pos.z; + + temp_s3 = (s32)(Rand_ZeroOne() * 60.0f * temp_f22) + 70; + + func_800B0E48(globalCtx, &spB8, &spAC, &spA0, &D_80B04FB4, &D_80B04FB8, temp_s3, + (s32)(Rand_ZeroOne() * 70.0f * temp_f22) + 70); + } + } else { + for (i = 0, phi_s0 = 0; i < 18; i++, phi_s0 += 0xE38) { + temp_f20 = (Rand_ZeroOne() * (45.0f * this->unk_20C)) + 50.0f; + + spB8.x = Math_SinS((s32)(Rand_ZeroOne() * 3640.889f) + phi_s0); + spB8.z = Math_CosS((s32)(Rand_ZeroOne() * 3640.889f) + phi_s0); + + spAC.x = spB8.x * 3.0f * temp_f22; + spAC.y = 0.0f; + spAC.z = spB8.z * 3.0f * temp_f22; + + spA0.x = spAC.x * -0.02f; + spA0.y = 0.03f; + spA0.z = spAC.z * -0.02f; + + spB8.x = (spB8.x * temp_f20) + this->actor.home.pos.x; + spB8.y = (Rand_ZeroOne() * 20.0f) + this->actor.home.pos.y; + spB8.z = (spB8.z * temp_f20) + this->actor.home.pos.z; + + EffectSsIceSmoke_Spawn(globalCtx, &spB8, &spAC, &spA0, (s32)(Rand_ZeroOne() * 140.0f * temp_f22) + 100); + } + } +} + +#ifdef NON_MATCHING +void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { + f32 temp_f30 = sqrtf(arg1); + Vec3f spD8; + Vec3f spCC; + s32 i; + Gfx* temp_s1; + f32 temp_f20; + s32 phi_s5; + s32 pad; + s16 phi_s2; + s32 pad2; + s16 phi_s0; + s16 phi_s3; + + for (i = 0, phi_s5 = 0; i < 13; i++, phi_s5 += 0x1999) { + temp_f20 = (Rand_ZeroOne() * (40.0f * arg1)) + 20.0f; + + spD8.x = Math_SinS((s32)(Rand_ZeroOne() * 6553.6f) + phi_s5) * temp_f20; + spD8.y = Rand_ZeroOne() * temp_f20; + spD8.z = Math_CosS((s32)(Rand_ZeroOne() * 6553.6f) + phi_s5) * temp_f20; + + spCC.x = spD8.x * 0.17f; + spCC.y = (Rand_ZeroOne() * 14.0f) + 3.0f; + spCC.z = spD8.z * 0.17f; + + spD8.x += arg2->x; + spD8.y += arg2->y; + spD8.z += arg2->z; + + if ((i & 3) == 0) { + temp_s1 = D_80B04FC8[0]; + phi_s2 = -400; + phi_s3 = 1; + if (Rand_Next() > 0) { + phi_s0 = 0x21; + } else { + phi_s0 = 0x41; + } + } else if ((i & 3) == 1) { + temp_s1 = D_80B04FC8[1]; + phi_s2 = -340; + phi_s3 = 1; + if (Rand_Next() > 0) { + phi_s0 = 0x21; + } else { + phi_s0 = 0x41; + } + } else { + temp_s1 = D_80B04FC8[2]; + phi_s2 = -280; + phi_s3 = 0; + phi_s0 = 0x40; + } + + EffectSsKakera_Spawn(globalCtx, &spD8, &spCC, &spD8, phi_s2, phi_s0, 30, 0, 0, + ((Rand_ZeroOne() * 15.0f) + 25.0f) * arg1, phi_s3, 0, 0x36, -1, 0xEF, temp_s1); + + spD8.x += (Rand_ZeroOne() * 80.0f) - 40.0f; + spD8.y += Rand_ZeroOne() * 55.0f; + spD8.z += (Rand_ZeroOne() * 80.0f) - 40.0f; + + phi_s0 = (s32)(Rand_ZeroOne() * 60.0f * temp_f30) + 60; + + func_800B0E48(globalCtx, &spD8, &gZeroVec3f, &D_80B04FBC, &D_80B04FB4, &D_80B04FB8, phi_s0, + (s32)(Rand_ZeroOne() * 30.0f * temp_f30) + 60); + } +} +#else +void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B03A80.s") #endif -extern ColliderJntSphElementInit D_80B04F50[1]; -extern ColliderJntSphInit D_80B04F74; -extern InitChainEntry D_80B04FD4[]; +void func_80B03E2C(ObjSnowball* this, GlobalContext* globalCtx) { + ObjSnowballStruct* ptr; + s32 i; -extern UNK_TYPE D_060082D0; -extern UNK_TYPE D_06008B90; + this->unk_1A8[0].unk_1C.y = this->actor.yawTowardsPlayer - 0x4000; + this->unk_1A8[0].unk_24 = Rand_ZeroOne() * -600.0f; + this->unk_1A8[1].unk_1C.y = this->actor.yawTowardsPlayer + 0x4000; + this->unk_1A8[1].unk_24 = Rand_ZeroOne() * 600.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B02CD0.s") + for (i = 0; i < ARRAY_COUNT(this->unk_1A8); i++) { + ptr = &this->unk_1A8[i]; + ptr->unk_00.x = this->actor.home.pos.x; + ptr->unk_00.y = this->actor.home.pos.y + (61.0f * this->unk_20C); + ptr->unk_00.z = this->actor.home.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B02D58.s") + ptr->unk_0C = Math_SinS(ptr->unk_1C.y) * (Rand_ZeroOne() + 5.0f); + ptr->unk_10 = (Rand_ZeroOne() * 11.0f) + 20.0f; + ptr->unk_14 = Math_CosS(ptr->unk_1C.y) * (Rand_ZeroOne() + 5.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B02DB0.s") + ptr->unk_1C.x = 0; + ptr->unk_1C.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B02E54.s") + ptr->unk_22 = (s32)(Rand_ZeroOne() * 400.0f) + 1100; + ptr->unk_26 = Rand_ZeroOne() * -600.0f; + ptr->unk_2D = 0; + ptr->unk_2C = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B02EE4.s") +void func_80B03FF8(ObjSnowball* this, GlobalContext* globalCtx) { + s32 pad; + s16 rotY = this->actor.home.rot.y; + ObjSnowballStruct2* sp18 = &D_80B04F84[rotY]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B030F8.s") + if (sp18->unk_04 != NULL) { + sp18->unk_04(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B03688.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SNOWBALL_BROKEN); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B03A80.s") + if (rotY == 5) { + Flags_SetSwitch(globalCtx, OBJSNOWBALL_GET_3F(&this->actor)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B03E2C.s") +void ObjSnowball_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball* this = THIS; + Sphere16* sphere; + ColliderJntSphElementDim* elementDim; + Vec3f sp48; + s32 sp44; + s32 sp40 = this->actor.home.rot.y; + f32 phi_f20; + s32 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B03FF8.s") + Actor_ProcessInitChain(&this->actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/ObjSnowball_Init.s") + sp34 = sp40 == 1; + if (sp34) { + phi_f20 = 1.5f; + } else { + phi_f20 = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/ObjSnowball_Destroy.s") + Actor_SetScale(&this->actor, 0.1f * phi_f20); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04338.s") + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->actor.world.pos.y += 20.0f * phi_f20; + this->actor.uncullZoneScale = 150.0f * phi_f20; + this->actor.uncullZoneDownward = 300.0f * phi_f20; + this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->unk_20C = phi_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04350.s") + if (sp34) { + this->actor.textId = 0x238; + this->actor.flags |= 1; + this->actor.targetArrowOffset = 1400.0f / 3.0f; + Actor_SetFocus(&this->actor, 24.0f); + this->actor.targetMode = 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04540.s") + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + this->actor.colChkInfo.mass = MASS_HEAVY; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B0457C.s") + sphere = &this->collider.elements[0].dim.worldSphere; + sphere->center.x = this->actor.world.pos.x; + sphere->center.y = this->actor.world.pos.y; + sphere->center.z = this->actor.world.pos.z; + sphere->radius = + (this->collider.elements[0].dim.scale * this->collider.elements[0].dim.modelSphere.radius) * phi_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04608.s") + sp48.x = this->actor.home.pos.x; + sp48.y = this->actor.home.pos.y + 30.0f; + sp48.z = this->actor.home.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04648.s") + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp44, &this->actor, &sp48); + if (this->actor.floorHeight < (this->actor.home.pos.y - 10.0f)) { + this->actor.floorPoly = NULL; + } else { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 13.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B046E4.s") + func_80B04338(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B047C0.s") + if ((sp40 == 5) && Flags_GetSwitch(globalCtx, OBJSNOWBALL_GET_3F(&this->actor))) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04B48.s") +void ObjSnowball_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04B60.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/ObjSnowball_Update.s") +void func_80B04338(ObjSnowball* this, GlobalContext* globalCtx) { + this->actionFunc = func_80B04350; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/ObjSnowball_Draw.s") +void func_80B04350(ObjSnowball* this, GlobalContext* globalCtx) { + s32 pad; + s32 flag = (this->collider.base.acFlags & AC_HIT) != 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04D34.s") + if (flag) { + this->collider.base.acFlags &= ~AC_HIT; + } + + if (flag && (this->unk_211 == 0) && + (this->collider.elements->info.acHitInfo->toucher.dmgFlags & + (0x80000000 | 0x4000 | 0x800 | 0x400 | 0x100 | 0x8))) { + this->actor.flags |= 0x10; + if (this->actor.home.rot.y == 1) { + this->actor.flags &= ~(8 | 1); + } + + if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x4000) { + this->unk_20A = 1; + } else { + if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x800) { + this->unk_210 = 1; + } + this->unk_20A = 0; + } + + if (this->actor.cutscene < 0) { + func_80B03FF8(this, globalCtx); + if (this->unk_20A == 0) { + func_80B04608(this, globalCtx); + } else { + func_80B046E4(this, globalCtx); + } + } else { + func_80B04540(this, globalCtx); + } + return; + } + + if (flag && + !(this->collider.elements->info.acHitInfo->toucher.dmgFlags & (0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20))) { + if (this->unk_209 <= 0) { + func_80B02EE4(this, globalCtx); + if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x1000000) { + this->unk_209 = 25; + } else { + this->unk_209 = 10; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_REFLECTION_SNOW); + } + } + + if (this->unk_209 > 0) { + this->unk_209--; + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80B04540(ObjSnowball* this, GlobalContext* globalCtx) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_80B0457C; +} + +void func_80B0457C(ObjSnowball* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + func_80B03FF8(this, globalCtx); + this->unk_20B = 1; + if (this->unk_20A == 0) { + func_80B04608(this, globalCtx); + } else { + func_80B046E4(this, globalCtx); + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80B04608(ObjSnowball* this, GlobalContext* globalCtx) { + func_80B030F8(this, globalCtx); + this->actor.draw = NULL; + this->unk_208 = 50; + this->actor.floorPoly = NULL; + this->actionFunc = func_80B04648; +} + +void func_80B04648(ObjSnowball* this, GlobalContext* globalCtx) { + this->unk_208--; + if (this->unk_208 <= 0) { + if (this->unk_20B != 0) { + ActorCutscene_Stop(this->actor.cutscene); + } + + if (this->actor.home.rot.y == 1) { + func_80B04B48(this, globalCtx); + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (this->unk_208 == 0x2D) { + func_80B03688(this, globalCtx); + } +} + +void func_80B046E4(ObjSnowball* this, GlobalContext* globalCtx) { + Vec3f sp44; + s32 i; + + func_80B03E2C(this, globalCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_1A8); i++) { + sp44.x = this->unk_1A8[i].unk_00.x; + sp44.y = this->unk_1A8[i].unk_00.y - (60.0f * this->unk_20C); + sp44.z = this->unk_1A8[i].unk_00.z; + func_80B03A80(globalCtx, this->unk_20C, &sp44); + } + + this->actor.draw = func_80B04D34; + this->actor.floorPoly = NULL; + this->unk_208 = 50; + this->actionFunc = func_80B047C0; +} + +void func_80B047C0(ObjSnowball* this, GlobalContext* globalCtx) { + static Vec3f D_80B04FD8 = { 0.0f, 1.0f, 0.0f }; + static Vec3f D_80B04FE4 = { 0.0f, 0.0f, 1.0f }; + s32 pad; + ObjSnowballStruct* ptr; + Vec3f sp9C; + s32 sp98; + s32 i; + Vec3f sp88; + f32 sp84; + f32 phi_f2; + f32 sp7C; + Vec3f sp70; + + for (i = 0; i < ARRAY_COUNT(this->unk_1A8); i++) { + ptr = &this->unk_1A8[i]; + + if (!(ptr->unk_2D & 1)) { + ptr->unk_10 -= 6.0f; + ptr->unk_10 *= 0.96f; + if (ptr->unk_10 < -20.0f) { + ptr->unk_10 = -20.0f; + } + + ptr->unk_00.x += ptr->unk_0C; + ptr->unk_00.y += ptr->unk_10; + ptr->unk_00.z += ptr->unk_14; + + ptr->unk_1C.x += ptr->unk_22; + ptr->unk_1C.y += ptr->unk_24; + ptr->unk_1C.z += ptr->unk_26; + + sp9C.x = ptr->unk_00.x; + sp9C.y = ptr->unk_00.y + 25.0f; + sp9C.z = ptr->unk_00.z; + + ptr->unk_18 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &ptr->unk_28, &sp98, &this->actor, &sp9C); + + if (ptr->unk_10 <= 0.0f) { + Matrix_InsertRotation(ptr->unk_1C.x, ptr->unk_1C.y, ptr->unk_1C.z, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&D_80B04FE4, &sp88); + + sp84 = this->unk_20C * 60.0f * 0.9f; + if (sp88.y > 0.0f) { + if (Math3D_AngleBetweenVectors(&D_80B04FD8, &sp88, &sp7C)) { + phi_f2 = 1.0f; + } else { + phi_f2 = 1.0f - SQ(sp7C); + } + + if (phi_f2 <= 0.0f) { + sp84 = 0.0f; + } else { + sp84 *= sqrtf(phi_f2); + } + } + + if (((ptr->unk_00.y - sp84) < ptr->unk_18) || (ptr->unk_18 < BGCHECK_Y_MIN + 10.0f)) { + ptr->unk_2D |= 1; + sp70.x = ptr->unk_00.x; + sp70.y = ptr->unk_00.y - sp84; + sp70.z = ptr->unk_00.z; + func_80B03A80(globalCtx, this->unk_20C, &sp70); + } + } + } + } + + this->unk_208--; + + if ((this->unk_208 <= 0) || ((this->unk_1A8[0].unk_2D & 1) && (this->unk_1A8[1].unk_2D & 1))) { + if (this->unk_20B != 0) { + ActorCutscene_Stop(this->actor.cutscene); + } + + if (this->actor.home.rot.y == 1) { + func_80B04B48(this, globalCtx); + } else { + Actor_MarkForDeath(&this->actor); + } + } else { + for (i = 0; i < ARRAY_COUNT(this->unk_1A8); i++) { + ptr = &this->unk_1A8[i]; + + if (ptr->unk_2D & 1) { + ptr->unk_2C = 0; + } else if (ptr->unk_2C < 136) { + ptr->unk_2C += 24; + } else { + ptr->unk_2C = 160; + } + } + } +} + +void func_80B04B48(ObjSnowball* this, GlobalContext* globalCtx) { + this->actionFunc = func_80B04B60; +} + +void func_80B04B60(ObjSnowball* this, GlobalContext* globalCtx) { +} + +void ObjSnowball_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSnowball* this = THIS; + s32 sp24 = false; + + if (this->actor.home.rot.y == 1) { + if (this->unk_211 != 0) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + this->actor.flags &= ~0x10; + this->unk_211 = 0; + } + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags |= 0x10; + this->unk_211 = 1; + } else if (this->actor.isTargeted) { + sp24 = true; + } + } + + this->actionFunc(this, globalCtx); + + if (sp24 && (this->actionFunc == func_80B04350)) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } + + if ((this->actor.floorPoly != NULL) && (this->actor.projectedPos.z < 920.0f)) { + if (this->actor.projectedPos.z > 400.0f) { + this->actor.shape.shadowAlpha = (920 - (s32)this->actor.projectedPos.z) >> 2; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else if (this->actor.projectedPos.z > -30.0f) { + this->actor.shape.shadowAlpha = 130; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else { + this->actor.shape.shadowDraw = NULL; + } + } else { + this->actor.shape.shadowDraw = NULL; + } +} + +void ObjSnowball_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball* this = THIS; + + Gfx_DrawDListOpa(globalCtx, object_goroiwa_DL_008B90); +} + +void func_80B04D34(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSnowball* this = THIS; + ObjSnowballStruct* ptr; + s32 i; + MtxF sp88; + Vec3s sp80; + + for (i = 0; i < ARRAY_COUNT(this->unk_1A8); i++) { + ptr = &this->unk_1A8[i]; + + if (!(ptr->unk_2D & 1)) { + sp80.x = ptr->unk_1C.x; + sp80.y = ptr->unk_1C.y; + sp80.z = ptr->unk_1C.z; + + Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, object_goroiwa_DL_0082D0); + + if ((ptr->unk_28 != NULL) && (ptr->unk_2C > 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, + 0, COMBINED); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, ptr->unk_2C); + + func_800C0094(ptr->unk_28, ptr->unk_00.x, ptr->unk_18, ptr->unk_00.z, &sp88); + Matrix_SetCurrentState(&sp88); + Matrix_Scale(this->actor.scale.x * 7.5f, 1.0f, this->actor.scale.z * 7.5f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } + } +} diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.h b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.h index fc5aafddee..c6bc03100e 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.h +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.h @@ -7,11 +7,37 @@ struct ObjSnowball; typedef void (*ObjSnowballActionFunc)(struct ObjSnowball*, GlobalContext*); +#define OBJSNOWBALL_GET_3F(thisx) ((thisx)->params & 0x3F) +#define OBJSNOWBALL_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ Vec3s unk_1C; + /* 0x22 */ s16 unk_22; + /* 0x24 */ s16 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ CollisionPoly* unk_28; + /* 0x2C */ u8 unk_2C; + /* 0x2D */ u8 unk_2D; +} ObjSnowballStruct; // size = 0x30 + typedef struct ObjSnowball { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x60]; - /* 0x01A4 */ ObjSnowballActionFunc actionFunc; - /* 0x01A8 */ char unk_1A8[0x6C]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElements[1]; + /* 0x1A4 */ ObjSnowballActionFunc actionFunc; + /* 0x1A8 */ ObjSnowballStruct unk_1A8[2]; + /* 0x208 */ s8 unk_208; + /* 0x209 */ s8 unk_209; + /* 0x20A */ s8 unk_20A; + /* 0x20B */ s8 unk_20B; + /* 0x20C */ f32 unk_20C; + /* 0x210 */ s8 unk_210; + /* 0x211 */ s8 unk_211; } ObjSnowball; // size = 0x214 extern const ActorInit Obj_Snowball_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c index ea554c4cf7..d21acc8b5a 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -45,7 +45,7 @@ static ColliderJntSphInit D_80B3A904 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_80B3A93C[] = { ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), diff --git a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c index 3eb50153be..d1fb1b23ec 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -5,6 +5,7 @@ */ #include "z_obj_syokudai.h" +#include "objects/gameplay_keep/gameplay_keep.h" #include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" #define FLAGS 0x00000410 @@ -115,7 +116,7 @@ void ObjSyokudai_Init(Actor* thisx, GlobalContext* globalCtx) { sNumLitTorchesInGroup = 0; } this->flameTexScroll = (u32)(Rand_ZeroOne() * OBJ_SYOKUDAI_SNUFF_DEFAULT); - Actor_SetHeight(thisx, 60.0f); + Actor_SetFocus(thisx, 60.0f); } void ObjSyokudai_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -145,7 +146,7 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { if (ActorCutscene_GetCanPlayNext(thisx->cutscene) != 0) { ActorCutscene_StartAndSetUnkLinkFields(thisx->cutscene, thisx); if (this->pendingAction >= OBJ_SYOKUDAI_PENDING_ACTION_CUTSCENE_AND_SWITCH) { - Actor_SetSwitchFlag(globalCtx, switchFlag); + Flags_SetSwitch(globalCtx, switchFlag); } } else { ActorCutscene_SetIntentToPlay(thisx->cutscene); @@ -161,7 +162,7 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { this->snuffTimer = OBJ_SYOKUDAI_SNUFF_OUT; if (type == OBJ_SYOKUDAI_TYPE_FLAME_CAUSES_SWITCH) { - Actor_UnsetSwitchFlag(globalCtx, switchFlag); + Flags_UnsetSwitch(globalCtx, switchFlag); if (groupSize != 0) { this->snuffTimer = OBJ_SYOKUDAI_SNUFF_GROUP_BY_WATER; } @@ -208,7 +209,7 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { if (interaction <= OBJ_SYOKUDAI_INTERACTION_STICK) { if (player->unk_B28 == 0) { player->unk_B28 = 0xD2; - func_8019F1C0(&thisx->projectedPos, NA_SE_EV_FLAME_IGNITION); + Audio_PlaySfxAtPos(&thisx->projectedPos, NA_SE_EV_FLAME_IGNITION); } else if (player->unk_B28 < 0xC8) { player->unk_B28 = 0xC8; } @@ -241,7 +242,7 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { } else if (thisx->cutscene >= 0) { this->pendingAction = OBJ_SYOKUDAI_PENDING_ACTION_CUTSCENE_AND_SWITCH; } else { - Actor_SetSwitchFlag(globalCtx, switchFlag); + Flags_SetSwitch(globalCtx, switchFlag); this->snuffTimer = OBJ_SYOKUDAI_SNUFF_NEVER; } } else { @@ -252,8 +253,8 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { OBJ_SYOKUDAI_SNUFF_TIMER_INITIAL(groupSize) + OBJ_SYOKUDAI_SNUFF_TIMER_JUST_LIT_BONUS; } } - func_801A5CFC(NA_SE_EV_FLAME_IGNITION, &thisx->projectedPos, 4, &D_801DB4B0, &D_801DB4B0, - &D_801DB4B8); + Audio_PlaySfxGeneral(NA_SE_EV_FLAME_IGNITION, &thisx->projectedPos, 4, &D_801DB4B0, &D_801DB4B0, + &D_801DB4B8); } } } @@ -314,7 +315,7 @@ void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_RotateY(BINANG_ROT180(func_800DFCDC(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++, D_0407D590); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c index 7bb44cc94d..bf535300b5 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c @@ -41,7 +41,7 @@ static ColliderCylinderInit D_809A4CB0 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_809A4D14[] = { - ICHAIN_F32_DIV1000(minVelocityY, 0, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 150, ICHAIN_STOP), diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c index a62ce6cf6c..50f879aec9 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c @@ -5,6 +5,7 @@ */ #include "z_obj_tokei_step.h" +#include "objects/object_tokei_step/object_tokei_step.h" #define FLAGS 0x00400010 @@ -37,11 +38,11 @@ const ActorInit Obj_Tokei_Step_InitVars = { (ActorFunc)ObjTokeiStep_Draw, }; -static f32 panelXOffsets[] = { -105.0f, -90.0f, -75.0f, -60.0f, -45.0f, -30.0f, -15.0f }; +static f32 sPanelXOffsets[] = { -105.0f, -90.0f, -75.0f, -60.0f, -45.0f, -30.0f, -15.0f }; -static f32 dustSpawnXOffsets[] = { -60.0f, -40.0f, -20.0f, 0.0f, 20.0f, 40.0f, 60.0f }; +static f32 sDustSpawnXOffsets[] = { -60.0f, -40.0f, -20.0f, 0.0f, 20.0f, 40.0f, 60.0f }; -static Vec3f dustEffectAccel = { 0.0f, 0.3f, 0.0f }; +static Vec3f sDustEffectAccel = { 0.0f, 0.3f, 0.0f }; static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), @@ -50,27 +51,22 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -extern Gfx D_06000088[]; -extern CollisionHeader D_06000968; - void ObjTokeiStep_SetSysMatrix(ObjTokeiStepPanel* panel) { - MtxF* sysMatrix; + MtxF* mtx = Matrix_GetCurrentState(); - sysMatrix = Matrix_GetCurrentState(); - sysMatrix->wx = panel->pos.x; - sysMatrix->wy = panel->pos.y; - sysMatrix->wz = panel->pos.z; + mtx->wx = panel->pos.x; + mtx->wy = panel->pos.y; + mtx->wz = panel->pos.z; } void ObjTokeiStep_AddQuake(ObjTokeiStep* this, GlobalContext* globalCtx) { s32 pad[2]; - s16 quake; + s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); - quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); - Quake_SetSpeed(quake, 0x4E20); + Quake_SetSpeed(quake, 20000); Quake_SetQuakeValues(quake, 1, 0, 0, 0); Quake_SetCountdown(quake, 7); - func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 0x78, 0x14, 0xA); + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); } void ObjTokeiStep_SpawnDust(ObjTokeiStep* this, ObjTokeiStepPanel* panel, GlobalContext* globalCtx) { @@ -84,12 +80,12 @@ void ObjTokeiStep_SpawnDust(ObjTokeiStep* this, ObjTokeiStepPanel* panel, Global dustSpawnOffset.y = 115.0f; dustSpawnOffset.z = -10.0f; for (i = 0; i < 7; i++) { - dustSpawnOffset.x = dustSpawnXOffsets[i]; + dustSpawnOffset.x = sDustSpawnXOffsets[i]; Matrix_MultiplyVector3fByState(&dustSpawnOffset, &dustSpawnPos); dustSpawnPos.x += panel->pos.x; dustSpawnPos.y += panel->pos.y; dustSpawnPos.z += panel->pos.z; - func_800B1210(globalCtx, &dustSpawnPos, &D_801D15B0, &dustEffectAccel, (s32)((Rand_ZeroOne() * 40.0f) + 80.0f), + func_800B1210(globalCtx, &dustSpawnPos, &gZeroVec3f, &sDustEffectAccel, (s32)((Rand_ZeroOne() * 40.0f) + 80.0f), (s32)((Rand_ZeroOne() * 20.0f) + 50.0f)); } } @@ -105,7 +101,7 @@ void ObjTokeiStep_InitSteps(ObjTokeiStep* this) { panelOffset.x = 0.0f; panelOffset.y = 0.0f; - for (i = 0; i < 7; i++) { + for (i = 0; i < ARRAY_COUNT(this->panels); i++) { panel = &this->panels[i]; panelOffset.z = i * -20.0f; Matrix_MultiplyVector3fByState(&panelOffset, &panel->pos); @@ -123,9 +119,9 @@ void ObjTokeiStep_InitStepsOpen(ObjTokeiStep* this) { this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); panelOffset.x = 0.0f; - for (i = 0; i < 7; i++) { + for (i = 0; i < ARRAY_COUNT(this->panels); i++) { panel = &this->panels[i]; - panelOffset.y = panelXOffsets[i]; + panelOffset.y = sPanelXOffsets[i]; panelOffset.z = i * -20.0f; Matrix_MultiplyVector3fByState(&panelOffset, &panel->pos); } @@ -135,7 +131,7 @@ void ObjTokeiStep_InitTimers(ObjTokeiStep* this) { s32 i; this->panels[0].startFallingTimer = 0; - for (i = 1; i < 7; i++) { + for (i = 1; i < ARRAY_COUNT(this->panels); i++) { this->panels[i].startFallingTimer = 10; } } @@ -145,25 +141,25 @@ s32 ObjTokeiStep_OpenProcess(ObjTokeiStep* this, GlobalContext* globalCtx) { s32 i; ObjTokeiStepPanel* panel; f32 finalPosY; - s32 isOpen = 1; - s32 prevBounced = 1; + s32 isOpen = true; + s32 hasPrevBounced = true; - for (i = 0; i < 7; i++) { + for (i = 0; i < ARRAY_COUNT(this->panels); i++) { panel = &this->panels[i]; - if (prevBounced && panel->startFallingTimer > 0) { + if (hasPrevBounced && (panel->startFallingTimer > 0)) { panel->startFallingTimer--; - isOpen = 0; + isOpen = false; } - if (prevBounced && panel->numBounces < 3 && panel->startFallingTimer <= 0) { - finalPosY = panelXOffsets[i] + this->dyna.actor.world.pos.y; + if (hasPrevBounced && (panel->numBounces < 3) && (panel->startFallingTimer <= 0)) { + finalPosY = sPanelXOffsets[i] + this->dyna.actor.world.pos.y; if (!panel->hasSoundPlayed) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_CLOCK_TOWER_STAIR_MOVE); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CLOCK_TOWER_STAIR_MOVE); panel->hasSoundPlayed = true; } panel->posChangeY += -2.5f; panel->posChangeY *= 0.83f; panel->pos.y += panel->posChangeY; - isOpen = 0; + isOpen = false; if (panel->pos.y < finalPosY) { panel->numBounces++; if (panel->numBounces >= 3) { @@ -186,7 +182,7 @@ s32 ObjTokeiStep_OpenProcess(ObjTokeiStep* this, GlobalContext* globalCtx) { } } } - prevBounced = panel->numBounces > 0; + hasPrevBounced = panel->numBounces > 0; } return isOpen; } @@ -196,16 +192,17 @@ void ObjTokeiStep_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - if ((globalCtx->sceneNum == 0x6F) && (gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.unk_12 == 0)) { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000968); + if ((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + (globalCtx->csCtx.unk_12 == 0)) { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClocktowerPanelCol); ObjTokeiStep_InitSteps(this); ObjTokeiStep_SetupBeginOpen(this); - } else if (!((CURRENT_DAY != 3) || (gSaveContext.time >= 0x4000)) || gSaveContext.day >= 4) { + } else if (((CURRENT_DAY == 3) && (gSaveContext.time < CLOCK_TIME(6, 0))) || (gSaveContext.day >= 4)) { this->dyna.actor.draw = ObjTokeiStep_DrawOpen; ObjTokeiStep_InitStepsOpen(this); ObjTokeiStep_SetupDoNothingOpen(this); } else { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000968); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClocktowerPanelCol); ObjTokeiStep_InitSteps(this); ObjTokeiStep_SetupDoNothing(this); } @@ -226,7 +223,7 @@ void ObjTokeiStep_BeginOpen(ObjTokeiStep* this, GlobalContext* globalCtx) { if (func_800EE29C(globalCtx, 0x86)) { action = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x86)]; - if ((globalCtx->csCtx.frames == (*action).startFrame) && action->unk0) { + if ((action->startFrame == globalCtx->csCtx.frames) && (action->unk0 != 0)) { this->dyna.actor.draw = ObjTokeiStep_DrawOpen; ObjTokeiStep_SetupOpen(this); } @@ -269,12 +266,12 @@ void ObjTokeiStep_Update(Actor* thisx, GlobalContext* globalCtx) { void ObjTokeiStep_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjTokeiStep* this = THIS; - func_800BDFC0(globalCtx, D_06000088); + Gfx_DrawDListOpa(globalCtx, gClocktowerPanelDL); } void ObjTokeiStep_DrawOpen(Actor* thisx, GlobalContext* globalCtx) { ObjTokeiStep* this = THIS; - int i; + s32 i; ObjTokeiStepPanel* panel; Gfx* gfx; @@ -282,11 +279,11 @@ void ObjTokeiStep_DrawOpen(Actor* thisx, GlobalContext* globalCtx) { gfx = POLY_OPA_DISP; gSPDisplayList(gfx++, &sSetupDL[6 * 0x19]); - for (i = 0; i < 7; i++) { + for (i = 0; i < ARRAY_COUNT(this->panels); i++) { panel = &this->panels[i]; ObjTokeiStep_SetSysMatrix(panel); gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, D_06000088); + gSPDisplayList(gfx++, gClocktowerPanelDL); } POLY_OPA_DISP = gfx; CLOSE_DISPS(globalCtx->state.gfxCtx); 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 13fbb074b0..70a144238d 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -1,43 +1,51 @@ /* * File: z_obj_tokeidai.c * Overlay: ovl_Obj_Tokeidai - * Description: Components of the Clock Tower (gears, clock face, counterweight, etc). + * Description: Components of the Clock Tower (gears, clock face, counterweight, etc). Also used for wall clocks. + * + * This actor handles most of the functionality related to the Clock Tower and the various + * wall clocks around Clock Town. Among its responsibilities are making the clocks correctly + * tell the time by spinning the various pieces and gears and controlling the spotlight that + * is emitted from the Clock Tower at night. + * + * On the midnight of the Final Day, the Clock Tower opens up, and the various pieces of it + * are moved around. This actor is responsible for managing all of this movement. Additionally, + * if the moon crashes into Termina, this actor is responsible for making the pieces of the + * Clock Tower collapse. */ #include "z_obj_tokeidai.h" +#include "objects/object_obj_tokeidai/object_obj_tokeidai.h" #define FLAGS 0x00000030 #define THIS ((ObjTokeidai*)thisx) +#define GET_CURRENT_HOUR(this) ((s32)((this)->currentTime * (24.0f / 0x10000))) +#define GET_CURRENT_MINUTE(this) ((s32)((this)->currentTime * (360 * 2.0f / 0x10000)) % 30) +#define GET_CLOCK_FACE_ROTATION(currentHour) ((s16)(currentHour * (0x10000 / 24.0f))) +#define GET_OUTER_RING_OR_GEAR_ROTATION(currentMinute) ((s16)(currentMinute * (0x10000 * 12.0f / 360))) + void ObjTokeidai_Init(Actor* thisx, GlobalContext* globalCtx); void ObjTokeidai_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjTokeidai_Update(Actor* thisx, GlobalContext* globalCtx); void ObjTokeidai_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AB319C(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB3240(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB32F0(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB3370(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB34CC(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB3544(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB3598(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB363C(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB365C(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB3808(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB3880(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB38B0(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB39BC(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB3A7C(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB3B34(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB3BD8(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB3BE8(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB3ED0(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB4040(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB4080(ObjTokeidai* this, GlobalContext* globalCtx); -void func_80AB4160(ObjTokeidai* this, GlobalContext* globalCtx); +void ObjTokeidai_DoNothing(ObjTokeidai* this, GlobalContext* globalCtx); +void ObjTokeidai_TowerClock_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx); +void ObjTokeidai_TowerGear_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx); +void ObjTokeidai_Counterweight_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx); +void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx); +void ObjTokeidai_WallClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx); +void ObjTokeidai_TowerGear_Idle(ObjTokeidai* this, GlobalContext* globalCtx); +void ObjTokeidai_Counterweight_Idle(ObjTokeidai* this, GlobalContext* globalCtx); +void ObjTokeidai_Walls_Idle(ObjTokeidai* this, GlobalContext* globalCtx); +void ObjTokeidai_StaircaseIntoTower_Idle(ObjTokeidai* this, GlobalContext* globalCtx); +void ObjTokeidai_SetupTowerOpening(ObjTokeidai* this); +void ObjTokeidai_Clock_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjTokeidai_Counterweight_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjTokeidai_TowerGear_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Tokeidai_InitVars = { ACTOR_OBJ_TOKEIDAI, ACTORCAT_PROP, @@ -50,87 +58,794 @@ const ActorInit Obj_Tokeidai_InitVars = { (ActorFunc)ObjTokeidai_Draw, }; -#endif +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 3300, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1100, ICHAIN_STOP), +}; -extern UNK_TYPE D_0600B208; -extern UNK_TYPE D_0600BA78; -extern UNK_TYPE D_0600CF28; -extern UNK_TYPE D_0600D388; +/** + * Returns the angle necessary to show the correct side of + * the sun and moon disk based on the time of day. The actual + * angle can differ from the target angle if the disk is in + * the middle of rotating. + */ +s32 ObjTokeidai_GetTargetSunMoonDiskRotation() { + if (gSaveContext.isNight) { + return 0x8000; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB2790.s") +void ObjTokeidai_SetupClockOrGear(ObjTokeidai* this) { + s32 currentMinute = GET_CURRENT_MINUTE(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB27B4.s") + this->clockMinute = currentMinute; + this->outerRingOrGearRotation = GET_OUTER_RING_OR_GEAR_ROTATION(currentMinute); + this->outerRingOrGearRotationalVelocity = 0x3C; + this->outerRingOrGearRotationTimer = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB2834.s") +void ObjTokeidai_Clock_Init(ObjTokeidai* this) { + s32 currentHour; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB28C8.s") + ObjTokeidai_SetupClockOrGear(this); + currentHour = GET_CURRENT_HOUR(this); + this->clockHour = currentHour; + this->clockFaceRotation = GET_CLOCK_FACE_ROTATION(currentHour); + this->clockFaceRotationalVelocity = 0; + this->clockFaceRotationTimer = 0; + this->sunMoonDiskRotationalVelocity = 0; + this->sunMoonDiskRotation = ObjTokeidai_GetTargetSunMoonDiskRotation(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB29F8.s") +void ObjTokeidai_TowerGear_Init(ObjTokeidai* this, GlobalContext* globalCtx) { + this->actor.draw = ObjTokeidai_TowerGear_Draw; + this->opaDList = object_obj_tokeidai_DL_00BA78; + ObjTokeidai_SetupClockOrGear(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB2BBC.s") + if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + (globalCtx->csCtx.unk_12 == 0)) || + ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && + (globalCtx->csCtx.unk_12 == 0))) { + ObjTokeidai_SetupTowerOpening(this); + } else if ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { + this->actionFunc = ObjTokeidai_TowerGear_OpenedIdle; + this->actor.world.pos.y += this->actor.scale.y * 1900.0f; + this->actor.shape.yOffset = 1500.0f; + gSaveContext.weekEventReg[8] |= 0x40; + } else { + this->actionFunc = ObjTokeidai_TowerGear_Idle; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/ObjTokeidai_Init.s") +void ObjTokeidai_TowerClock_Init(ObjTokeidai* this, GlobalContext* globalCtx) { + this->actor.draw = ObjTokeidai_Clock_Draw; + ObjTokeidai_Clock_Init(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/ObjTokeidai_Destroy.s") + if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + (globalCtx->csCtx.unk_12 == 0)) || + ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && + (globalCtx->csCtx.unk_12 == 0))) { + ObjTokeidai_SetupTowerOpening(this); + } else if ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { + this->actor.world.pos.y += (this->actor.scale.y * 5191.0f) - 50.0f; + this->actor.world.pos.x += Math_SinS(this->actor.world.rot.y) * this->actor.scale.z * 1791.0f; + this->actor.world.pos.z += -Math_CosS(this->actor.world.rot.y) * this->actor.scale.z * 1791.0f; + this->clockFaceZTranslation = -0x140; + this->actor.shape.rot.x = -0x4000; + this->actor.home.pos = this->actor.world.pos; + this->actor.home.pos.y -= 1178.0f; + this->actor.home.pos.z += 13.0f; + this->actionFunc = ObjTokeidai_TowerClock_OpenedIdle; + } else { + this->actionFunc = ObjTokeidai_TowerClock_Idle; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3010.s") +void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, GlobalContext* globalCtx) { + s32 type; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB319C.s") + this->actor.draw = ObjTokeidai_Counterweight_Draw; + this->opaDList = object_obj_tokeidai_DL_00B208; + this->xluDList = object_obj_tokeidai_DL_00B0C0; + if (gSaveContext.isNight) { + this->spotlightIntensity = 100; + } else { + this->spotlightIntensity = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3240.s") + if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + (globalCtx->csCtx.unk_12 == 0)) || + ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && + (globalCtx->csCtx.unk_12 == 0))) { + this->spotlightIntensity = 0; + ObjTokeidai_SetupTowerOpening(this); + if (this->actor.child == NULL) { + type = OBJ_TOKEIDAI_TYPE(&this->actor); + if (type == OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_CLOCK_TOWN || + type == OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_TERMINA_FIELD) { + this->actor.child = + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HANABI, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + } + } + if (this->actor.child != NULL) { + if (OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_TERMINA_FIELD) { + this->actor.child->home.rot.x = 0x384; + } else { + this->actor.child->home.rot.x = 0x12C; + } + } + } else if ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { + this->spotlightIntensity = 0; + this->actor.world.pos.y += this->actor.scale.y * -2160.0f; + this->actor.world.pos.x += Math_SinS(this->actor.world.rot.y) * this->actor.scale.z * 5400.0f; + this->actor.world.pos.z += -Math_CosS(this->actor.world.rot.y) * this->actor.scale.z * 5400.0f; + this->actor.shape.rot.x = -0x4000; + this->actionFunc = ObjTokeidai_Counterweight_OpenedIdle; + } else { + this->actionFunc = ObjTokeidai_Counterweight_Idle; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB32F0.s") +void ObjTokeidai_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjTokeidai* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3370.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->actionFunc = ObjTokeidai_DoNothing; + this->opaDList = NULL; + this->xluDList = NULL; + this->xRotation = 0; + this->yTranslation = 0; + this->clockFaceZTranslation = 0; + this->currentTime = gSaveContext.time; + this->actor.home.rot.x = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB34CC.s") + switch (OBJ_TOKEIDAI_TYPE(&this->actor)) { + case OBJ_TOKEIDAI_TYPE_TOWER_GEAR_TERMINA_FIELD: + Actor_SetScale(&this->actor, 0.15f); + ObjTokeidai_TowerGear_Init(this, globalCtx); + break; + case OBJ_TOKEIDAI_TYPE_TOWER_GEAR_CLOCK_TOWN: + ObjTokeidai_TowerGear_Init(this, globalCtx); + break; + case OBJ_TOKEIDAI_TYPE_UNUSED_WALL: + this->opaDList = object_obj_tokeidai_DL_00D388; + break; + case OBJ_TOKEIDAI_TYPE_TOWER_WALLS_TERMINA_FIELD: + Actor_SetScale(&this->actor, 1.0f); + this->opaDList = object_obj_tokeidai_DL_009A08; + this->actionFunc = ObjTokeidai_Walls_Idle; + break; + case OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD: + Actor_SetScale(&this->actor, 0.15f); + ObjTokeidai_TowerClock_Init(this, globalCtx); + break; + case OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_CLOCK_TOWN: + ObjTokeidai_TowerClock_Init(this, globalCtx); + break; + case OBJ_TOKEIDAI_TYPE_WALL_CLOCK: + Actor_SetScale(&this->actor, 0.02f); + this->actor.draw = ObjTokeidai_Clock_Draw; + ObjTokeidai_Clock_Init(this); + this->actionFunc = ObjTokeidai_WallClock_Idle; + break; + case OBJ_TOKEIDAI_TYPE_SMALL_WALL_CLOCK: + Actor_SetScale(&this->actor, 0.01f); + this->actor.draw = ObjTokeidai_Clock_Draw; + ObjTokeidai_Clock_Init(this); + this->actionFunc = ObjTokeidai_WallClock_Idle; + break; + case OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_TERMINA_FIELD: + Actor_SetScale(&this->actor, 0.15f); + ObjTokeidai_Counterweight_Init(this, globalCtx); + break; + case OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_CLOCK_TOWN: + ObjTokeidai_Counterweight_Init(this, globalCtx); + break; + case OBJ_TOKEIDAI_TYPE_STAIRCASE_INTO_TOWER: + this->opaDList = object_obj_tokeidai_DL_00D8E8; + this->xluDList = object_obj_tokeidai_DL_00D8E0; + this->actionFunc = ObjTokeidai_StaircaseIntoTower_Idle; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3544.s") +void ObjTokeidai_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3598.s") +void ObjTokeidai_RotateOnMinuteChange(ObjTokeidai* this, s32 playSfx) { + s32 currentMinute = GET_CURRENT_MINUTE(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB363C.s") + if (currentMinute != this->clockMinute) { + if (this->outerRingOrGearRotationTimer == 8 && playSfx) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_SECOND_HAND); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB365C.s") + if (this->outerRingOrGearRotationTimer > 8) { + // This actually performs the rotation to the next minute + // for the outer ring or gear. + this->outerRingOrGearRotationalVelocity += 0x3C; + this->outerRingOrGearRotation += this->outerRingOrGearRotationalVelocity; + } else { + // This makes the outer ring or gear wiggle in place for a bit + // before rotating to the next position. + if ((this->outerRingOrGearRotationTimer & 3) == 0) { + this->outerRingOrGearRotation += 0x5A; + } + if ((this->outerRingOrGearRotationTimer & 3) == 1) { + this->outerRingOrGearRotation -= 0x5A; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB36C4.s") + this->outerRingOrGearRotationTimer++; + if ((currentMinute == 15 && this->outerRingOrGearRotation < 0) || + (currentMinute != 15 && this->outerRingOrGearRotation > GET_OUTER_RING_OR_GEAR_ROTATION(currentMinute))) { + this->outerRingOrGearRotation = GET_OUTER_RING_OR_GEAR_ROTATION(currentMinute); + this->clockMinute = currentMinute; + this->outerRingOrGearRotationalVelocity = 0x5A; + this->outerRingOrGearRotationTimer = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3808.s") +void ObjTokeidai_TowerGear_Collapse(ObjTokeidai* this, GlobalContext* globalCtx) { + if ((this->actor.bgCheckFlags & 1) || this->actor.world.pos.y < 0.0f) { + this->actionFunc = ObjTokeidai_DoNothing; + } else { + this->actor.shape.rot.x += 0x50; + this->actor.shape.rot.z += 0x50; + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3880.s") +void ObjTokeidai_TowerGear_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { + if (func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 2) { + this->actionFunc = ObjTokeidai_TowerGear_Collapse; + this->actor.speedXZ = this->actor.scale.y * 5.0f; + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = this->actor.scale.y * -50.0f; + this->actor.gravity = this->actor.scale.y * -5.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB38B0.s") +/** + * This is hard to see in the final game. This, used in conjunction + * with the following function, makes the tower's clock slide off the + * tower and spin through the air when the moon crashes. + */ +void ObjTokeidai_TowerClock_Fall(ObjTokeidai* this, GlobalContext* globalCtx) { + this->actor.shape.rot.x += this->fallingClockFaceRotationalVelocity; + if (this->fallingClockFaceRotationalVelocity > 0xA0) { + this->fallingClockFaceRotationalVelocity -= 5; + } + this->actor.world.pos.z += 4.0f; + Actor_MoveWithGravity(&this->actor); + if (this->actor.world.pos.y < 0.0f) { + this->actionFunc = ObjTokeidai_DoNothing; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB39BC.s") +/** + * This is hard to see in the final game. This makes the + * tower's clock slide off as the moon crashes into it. + */ +void ObjTokeidai_TowerClock_SlideOff(ObjTokeidai* this, GlobalContext* globalCtx) { + f32 cos; + f32 sin; + Actor* thisx = &this->actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3A7C.s") + if (this->slidingClockFaceAngle < 0x4000) { + this->slidingClockFaceAngle += 0x28; + } + if (this->slidingClockFaceAngle > 0x800) { + this->aerialClockFaceSpeed += 4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3B34.s") + if (this->aerialClockFaceSpeed < 0x80) { + thisx->shape.rot.x = this->slidingClockFaceAngle - 0x4000; + this->fallingClockFaceRotationalVelocity = 0x28; + } else { + if (thisx->shape.rot.x < -0x1000) { + thisx->shape.rot.x += this->fallingClockFaceRotationalVelocity; + if (this->fallingClockFaceRotationalVelocity < 0x1E0) { + this->fallingClockFaceRotationalVelocity += 0xA; + } + } else { + thisx->shape.rot.x += this->fallingClockFaceRotationalVelocity; + this->actionFunc = ObjTokeidai_TowerClock_Fall; + thisx->terminalVelocity = -7.5f; + thisx->gravity = -0.75f; + thisx->velocity.y = -2.0f; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3BB0.s") + sin = Math_SinS(this->slidingClockFaceAngle); + cos = Math_CosS(this->slidingClockFaceAngle); + thisx->world.pos.y = (1178.0f * cos) - (this->aerialClockFaceSpeed * sin) + thisx->home.pos.y; + thisx->world.pos.z = (1178.0f * sin) + (this->aerialClockFaceSpeed * cos) + thisx->home.pos.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3BD8.s") +void ObjTokeidai_TowerClock_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { + if (func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 1) { + this->actionFunc = ObjTokeidai_TowerClock_SlideOff; + this->slidingClockFaceAngle = 0; + this->aerialClockFaceSpeed = -0xD; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3BE8.s") +void ObjTokeidai_Counterweight_Collapse(ObjTokeidai* this, GlobalContext* globalCtx) { + if (this->actor.world.pos.y < 0.0f) { + this->actionFunc = ObjTokeidai_DoNothing; + } else { + this->xRotation += 0x64; + Actor_MoveWithGravity(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3C50.s") +void ObjTokeidai_Counterweight_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { + if (func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 3) { + this->actionFunc = ObjTokeidai_Counterweight_Collapse; + this->xRotation = 0; + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = this->actor.scale.y * -50.0f; + this->actor.gravity = this->actor.scale.y * -5.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3CCC.s") +/** + * This is hard to see in the final game. It makes the walls of + * the clock tower tip over as the moon crashes into it, but the + * giant moon mostly obscures it. + */ +void ObjTokeidai_Walls_Collapse(ObjTokeidai* this, GlobalContext* globalCtx) { + if (this->actor.shape.rot.x < 0x4000) { + this->actor.shape.rot.x += 0x28; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB3ED0.s") +void ObjTokeidai_Walls_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { + if (func_800EE29C(globalCtx, 0x84) != 0 && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 1) { + this->actionFunc = ObjTokeidai_Walls_Collapse; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB4040.s") +void ObjTokeidai_TowerOpening_EndCutscene(ObjTokeidai* this, GlobalContext* globalCtx) { + if (func_800EE29C(globalCtx, 0x84) != 0 && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 5) { + gSaveContext.weekEventReg[8] |= 0x40; + if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && + (globalCtx->csCtx.unk_12 == 0)) || + ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && + (globalCtx->csCtx.unk_12 == 0))) { + func_801A3F54(false); + gSaveContext.cutscene = 0; + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.respawnFlag = 2; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->nextEntranceIndex = gSaveContext.respawn[1].entranceIndex; + globalCtx->unk_1887F = 2; + if (gSaveContext.respawn[1].playerParams == 0xCFF) { + gSaveContext.nextTransition = 0x15; + } else { + gSaveContext.nextTransition = 2; + } + } + this->actionFunc = ObjTokeidai_DoNothing; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB4080.s") +void ObjTokeidai_TowerOpening_FinishOpening(ObjTokeidai* this, GlobalContext* globalCtx) { + s32 type; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB4160.s") + if (this->clockFaceZTranslation > -320) { + // Recess the clock face before ending the cutscene, since the Termina + // Field version of the cutscene looks right at it. + this->clockFaceZTranslation -= 10; + } else { + type = OBJ_TOKEIDAI_TYPE(&this->actor); + if ((type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_CLOCK_TOWN) || + (type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD)) { + ObjTokeidai_TowerOpening_EndCutscene(this, globalCtx); + } else { + this->actionFunc = ObjTokeidai_DoNothing; + if (this->actor.child != NULL) { + this->actor.child->home.rot.x = 0; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/ObjTokeidai_Update.s") +void ObjTokeidai_TowerOpening_Wait(ObjTokeidai* this, GlobalContext* globalCtx) { + if (this->openingWaitTimer > 0) { + this->openingWaitTimer--; + } else { + this->actionFunc = ObjTokeidai_TowerOpening_FinishOpening; + this->openingWaitTimer = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/ObjTokeidai_Draw.s") +void ObjTokeidai_TowerOpening_DropCounterweight(ObjTokeidai* this, GlobalContext* globalCtx) { + this->xRotation += this->counterweightRotationalVelocity; + if (this->xRotation < 0x4000) { + this->counterweightRotationalVelocity += this->counterweightRotationalAcceleration; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB4394.s") + this->counterweightRotationalAcceleration = 0x14; + this->xRotation = 0x4000; + switch (this->boundCount) { + case 0: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_0); + break; + case 1: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_1); + break; + case 2: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_2); + break; + } + this->boundCount++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB4664.s") + if (this->counterweightRotationalVelocity > 0x190) { + // This condition is met for the first bound, causing the counterweight + // to rebound upwards quickly. + this->counterweightRotationalVelocity = -0xC8; + } else if (this->counterweightRotationalVelocity > 0x32) { + // This condition is met for the second bound, causing the counterweight + // to rebound upwards slowly. + this->counterweightRotationalVelocity = -(this->counterweightRotationalVelocity >> 1); + } else { + // This condition is met for the third bound, causing the counterweight + // to stop moving. + this->actionFunc = ObjTokeidai_TowerOpening_Wait; + this->openingWaitTimer = 10; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokeidai/func_80AB4894.s") +void ObjTokeidai_TowerOpening_FinishRaise(ObjTokeidai* this, GlobalContext* globalCtx) { + s32 type; + + if (this->settleTimer > 0) { + // Jiggle the parts of the tower up and down to give it the appearance + // of "settling" into place. + if (this->settleTimer & 1) { + this->yTranslation = this->settleAmount + 3400; + } else { + this->yTranslation = 3400 - this->settleAmount; + if (this->settleAmount > 0) { + this->settleAmount -= 4; + } + } + this->settleTimer--; + } else { + type = OBJ_TOKEIDAI_TYPE(&this->actor); + if ((type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_CLOCK_TOWN) || + (type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_FALL); + } + this->yTranslation = 3400; + this->actionFunc = ObjTokeidai_TowerOpening_DropCounterweight; + this->counterweightRotationalVelocity = 0; + this->counterweightRotationalAcceleration = 0xA; + this->boundCount = 0; + } +} + +void ObjTokeidai_TowerOpening_RaiseTower(ObjTokeidai* this, GlobalContext* globalCtx) { + s32 type; + + if (this->yTranslation < 3400) { + type = OBJ_TOKEIDAI_TYPE(&this->actor); + this->yTranslation += 25; + if ((type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_CLOCK_TOWN) || + (type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD)) { + func_800B9010(&this->actor, NA_SE_EV_CLOCK_TOWER_UP - SFX_FLAG); + } + } else { + type = OBJ_TOKEIDAI_TYPE(&this->actor); + if ((type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_CLOCK_TOWN) || + (type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_STOP); + } + this->yTranslation = 3400; + this->actionFunc = ObjTokeidai_TowerOpening_FinishRaise; + this->settleTimer = 10; + this->settleAmount = 20; + } +} + +void ObjTokeidai_TowerOpening_Start(ObjTokeidai* this, GlobalContext* globalCtx) { + if ((func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 4) || + (gSaveContext.weekEventReg[8] & 0x40)) { + this->actionFunc = ObjTokeidai_TowerOpening_RaiseTower; + } +} + +/** + * Sets up the sequence where the Clock Tower "transforms" and opens up + * on the midnight of the Final Day. + */ +void ObjTokeidai_SetupTowerOpening(ObjTokeidai* this) { + this->actionFunc = ObjTokeidai_TowerOpening_Start; + this->clockFaceRotationalVelocity = 0; + this->clockFaceRotationTimer = 0; + this->yTranslation = 0; + this->xRotation = 0; + this->clockFaceZTranslation = 0; +} + +void ObjTokeidai_DoNothing(ObjTokeidai* this, GlobalContext* globalCtx) { +} + +void ObjTokeidai_StaircaseIntoTower_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { + if (((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) || + (gSaveContext.weekEventReg[8] & 0x40)) { + this->actor.draw = ObjTokeidai_Draw; + } else { + this->actor.draw = NULL; + } +} + +s32 ObjTokeidai_IsPostFirstCycleFinalHours(ObjTokeidai* this, GlobalContext* globalCtx) { + if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + return false; + } + if (CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) { + ObjTokeidai_SetupTowerOpening(this); + return true; + } + return false; +} + +void ObjTokeidai_RotateOnHourChange(ObjTokeidai* this, GlobalContext* globalCtx) { + s32 currentHour = GET_CURRENT_HOUR(this); + + if (currentHour != this->clockHour) { + if (this->clockFaceRotationTimer > 12) { + // This actually performs the rotation to the next hour + // for the clock face. + this->clockFaceRotationalVelocity += 0xA; + this->clockFaceRotation += this->clockFaceRotationalVelocity; + } else { + // This makes the clock face wiggle in place for a bit + // before rotating to the next position. + if ((this->clockFaceRotationTimer & 3) == 0) { + this->clockFaceRotation += 0x3C; + } + if ((this->clockFaceRotationTimer & 3) == 1) { + this->clockFaceRotation -= 0x3C; + } + } + + this->clockFaceRotationTimer++; + if ((currentHour == 12 && this->clockFaceRotation < 0) || + (currentHour != 12 && this->clockFaceRotation > GET_CLOCK_FACE_ROTATION(currentHour))) { + this->clockFaceRotation = GET_CLOCK_FACE_ROTATION(currentHour); + this->clockHour = currentHour; + this->clockFaceRotationalVelocity = 0; + this->clockFaceRotationTimer = 0; + } + } + + // If the sun and moon disk doesn't have the target rotation (e.g., the time of day + // just changed), rotate it until it matches the target. + if (this->sunMoonDiskRotation != ObjTokeidai_GetTargetSunMoonDiskRotation()) { + if (this->clockHour == 6) { + this->sunMoonDiskRotationalVelocity += 0x222; + this->sunMoonDiskRotation += this->sunMoonDiskRotationalVelocity; + if (this->sunMoonDiskRotation > 0x10000) { + this->sunMoonDiskRotation = ObjTokeidai_GetTargetSunMoonDiskRotation(); + this->sunMoonDiskRotationalVelocity = 0; + } + } + if (this->clockHour == 18) { + this->sunMoonDiskRotationalVelocity += 0x222; + this->sunMoonDiskRotation += this->sunMoonDiskRotationalVelocity; + if (this->sunMoonDiskRotation > 0x8000) { + this->sunMoonDiskRotation = ObjTokeidai_GetTargetSunMoonDiskRotation(); + this->sunMoonDiskRotationalVelocity = 0; + } + } + } +} + +void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { + if (CURRENT_DAY == 3 && this->clockHour < 6 && gSaveContext.time < CLOCK_TIME(6, 0)) { + this->actor.draw = ObjTokeidai_Clock_Draw; + ObjTokeidai_SetupTowerOpening(this); + gSaveContext.weekEventReg[8] |= 0x40; + return; + } + + if (globalCtx->csCtx.state != 0) { + this->actor.home.rot.x = 1; + this->currentTime += 3; + this->actor.draw = ObjTokeidai_Clock_Draw; + } else { + if (!(globalCtx->actorCtx.unk5 & 2) && + OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD && + ActorCutscene_GetCurrentIndex() == -1) { + this->actor.draw = NULL; + } + this->currentTime = gSaveContext.time; + if (this->actor.home.rot.x != 0) { + ObjTokeidai_Clock_Init(this); + this->actor.home.rot.x = 0; + } + } + + if (CURRENT_DAY != 3 || gSaveContext.time >= CLOCK_TIME(6, 0)) { + ObjTokeidai_RotateOnMinuteChange(this, true); + } + ObjTokeidai_RotateOnHourChange(this, globalCtx); +} + +void ObjTokeidai_WallClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { + this->currentTime = gSaveContext.time; + ObjTokeidai_RotateOnMinuteChange(this, true); + ObjTokeidai_RotateOnHourChange(this, globalCtx); +} + +void ObjTokeidai_TowerGear_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { + if (ObjTokeidai_IsPostFirstCycleFinalHours(this, globalCtx)) { + this->actor.draw = ObjTokeidai_TowerGear_Draw; + } else { + if (globalCtx->csCtx.state != 0) { + this->actor.home.rot.x = 1; + this->currentTime += 3; + this->actor.draw = ObjTokeidai_TowerGear_Draw; + } else { + if ((globalCtx->actorCtx.unk5 & 2) == 0 && + OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_TOWER_GEAR_TERMINA_FIELD && + ActorCutscene_GetCurrentIndex() == -1) { + this->actor.draw = NULL; + } + this->currentTime = gSaveContext.time; + if (this->actor.home.rot.x != 0) { + ObjTokeidai_SetupClockOrGear(this); + this->actor.home.rot.x = 0; + } + } + ObjTokeidai_RotateOnMinuteChange(this, false); + } +} + +void ObjTokeidai_Counterweight_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { + s32 type; + + if (ObjTokeidai_IsPostFirstCycleFinalHours(this, globalCtx)) { + this->spotlightIntensity = 0; + if (this->actor.child == NULL) { + type = OBJ_TOKEIDAI_TYPE(&this->actor); + if (type == OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_CLOCK_TOWN || + type == OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_TERMINA_FIELD) { + this->actor.child = + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HANABI, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + } + } + if (this->actor.child != NULL) { + if (OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_TERMINA_FIELD) { + this->actor.child->home.rot.x = 0x384; + } else { + this->actor.child->home.rot.x = 0x12C; + } + } + } else { + this->actor.shape.rot.y -= 0x40; + if (gSaveContext.isNight) { + if (this->spotlightIntensity < 100) { + this->spotlightIntensity += 4; + } + } else if (this->spotlightIntensity > 0) { + this->spotlightIntensity -= 4; + } + } +} + +void ObjTokeidai_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjTokeidai* this = THIS; + this->actionFunc(this, globalCtx); +} + +void ObjTokeidai_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjTokeidai* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->opaDList != NULL) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, this->opaDList); + } + if (this->xluDList != NULL) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_XLU_DISP++, this->xluDList); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjTokeidai_Clock_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjTokeidai* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-this->xRotation, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); + Matrix_StatePush(); + Matrix_InsertZRotation_s(-this->outerRingOrGearRotation, 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_obj_tokeidai_DL_00CF28); + Matrix_StatePop(); + Matrix_InsertTranslation(0.0f, 0.0f, this->clockFaceZTranslation, 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_obj_tokeidai_DL_00BEE8); + Matrix_InsertZRotation_s(-this->clockFaceRotation * 2, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_WALL_CLOCK || + OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_SMALL_WALL_CLOCK) { + gSPDisplayList(POLY_OPA_DISP++, object_obj_tokeidai_DL_00F518); + } else { + gSPDisplayList(POLY_OPA_DISP++, object_obj_tokeidai_DL_00E818); + } + Matrix_InsertTranslation(0.0f, -1112.0f, -19.6f, MTXMODE_APPLY); + Matrix_RotateY((s16)this->sunMoonDiskRotation, 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_obj_tokeidai_DL_00C368); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjTokeidai_Counterweight_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + u32 gameplayFrames = globalCtx->gameplayFrames; + ObjTokeidai* this = THIS; + + Matrix_RotateY(-this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -5480.0f, 80.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-this->xRotation, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 5480.0f, -80.0f, MTXMODE_APPLY); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, -gameplayFrames, 0, 0x20, 0x20)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, this->opaDList); + 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++, 0, 255, 255, 235, 180, (s32)(this->spotlightIntensity * 2.55f)); + gSPDisplayList(POLY_XLU_DISP++, this->xluDList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjTokeidai_TowerGear_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjTokeidai* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); + Matrix_RotateY(-this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-this->xRotation, MTXMODE_APPLY); + Matrix_RotateY(thisx->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->outerRingOrGearRotation, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, object_obj_tokeidai_DL_00BA78); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h index f550606f05..c5cf8d70cf 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.h @@ -3,14 +3,63 @@ #include "global.h" +#define OBJ_TOKEIDAI_TYPE(thisx) (((thisx)->params & 0xF000) >> 12) + +typedef enum { + /* 0 */ OBJ_TOKEIDAI_TYPE_TOWER_GEAR_CLOCK_TOWN, + /* 1 */ OBJ_TOKEIDAI_TYPE_UNUSED_WALL, + /* 2 */ OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_CLOCK_TOWN, + /* 3 */ OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_CLOCK_TOWN, + /* 4 */ OBJ_TOKEIDAI_TYPE_TOWER_GEAR_TERMINA_FIELD, + /* 5 */ OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD, + /* 6 */ OBJ_TOKEIDAI_TYPE_COUNTERWEIGHT_TERMINA_FIELD, + /* 8 */ OBJ_TOKEIDAI_TYPE_TOWER_WALLS_TERMINA_FIELD = 8, + /* 9 */ OBJ_TOKEIDAI_TYPE_WALL_CLOCK, + /* 10 */ OBJ_TOKEIDAI_TYPE_SMALL_WALL_CLOCK, + /* 11 */ OBJ_TOKEIDAI_TYPE_STAIRCASE_INTO_TOWER, +} ObjTokeidaiType; + struct ObjTokeidai; typedef void (*ObjTokeidaiActionFunc)(struct ObjTokeidai*, GlobalContext*); typedef struct ObjTokeidai { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x30]; - /* 0x0174 */ ObjTokeidaiActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ Gfx* opaDList; + /* 0x148 */ Gfx* xluDList; + /* 0x14C */ s16 outerRingOrGearRotation; + /* 0x14E */ s16 outerRingOrGearRotationalVelocity; + /* 0x150 */ s16 outerRingOrGearRotationTimer; + /* 0x152 */ s16 clockFaceRotation; + /* 0x154 */ union { + s16 clockFaceRotationalVelocity; + s16 settleTimer; + s16 counterweightRotationalVelocity; + s16 openingWaitTimer; + s16 slidingClockFaceAngle; + }; + /* 0x156 */ union { + s16 clockFaceRotationTimer; + s16 settleAmount; + s16 counterweightRotationalAcceleration; + s16 aerialClockFaceSpeed; + }; + /* 0x158 */ s32 sunMoonDiskRotation; + /* 0x15C */ union { + s16 sunMoonDiskRotationalVelocity; + s16 fallingClockFaceRotationalVelocity; + }; + /* 0x15E */ s16 yTranslation; + /* 0x160 */ s16 xRotation; + /* 0x162 */ s16 clockFaceZTranslation; // amount the clock face recesses inwards once it transforms + /* 0x164 */ s16 boundCount; + /* 0x168 */ s32 clockMinute; // only 30 minutes in an hour + /* 0x16C */ union { + s32 clockHour; + s32 spotlightIntensity; + }; + /* 0x170 */ u16 currentTime; + /* 0x174 */ ObjTokeidaiActionFunc actionFunc; } ObjTokeidai; // size = 0x178 extern const ActorInit Obj_Tokeidai_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c index 0ffa733316..7b756a10f8 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c @@ -144,7 +144,7 @@ void ObTree_SetupSway(ObjTree* this) { this->timer = 0; this->swayAmplitude = 546.0f; this->swayVelocity = 35 * 0x10000 / 360; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_TREE_SWING); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_TREE_SWING); this->actionFunc = ObTree_Sway; } diff --git a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c index 5eac816e2d..e91c3387fb 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -43,7 +43,7 @@ static ColliderCylinderInit D_809295B0 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_809295DC[] = { ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), diff --git a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c index 427400f99a..ea27c1ad99 100644 --- a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c +++ b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c @@ -51,5 +51,5 @@ void ObjVisiblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void ObjVisiblock_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BE03C(globalCtx, D_06000140); + Gfx_DrawDListXlu(globalCtx, D_06000140); } diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index 6e66c9cabe..1563ea2fa9 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -71,7 +71,7 @@ void ObjWarpstone_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - Actor_SetHeight(&this->dyna.actor, 40.0f); + Actor_SetFocus(&this->dyna.actor, 40.0f); if (!OBJ_WARPSTONE_IS_ACTIVATED(OBJ_WARPSTONE_GET_ID(this))) { ObjWarpstone_SetupAction(this, ObjWarpstone_ClosedIdle); @@ -102,7 +102,7 @@ s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, GlobalContext* globalC if (this->dyna.actor.cutscene < 0 || ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); ObjWarpstone_SetupAction(this, ObjWarpstone_PlayOpeningCutscene); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_OWL_WARP_SWITCH_ON); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_OWL_WARP_SWITCH_ON); } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); } @@ -138,9 +138,9 @@ void ObjWarpstone_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; if (this->isTalking) { - if (func_800B867C(&this->dyna.actor, globalCtx) != 0) { + if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { this->isTalking = false; - } else if ((func_80152498(&globalCtx->msgCtx) == 4) && (func_80147624(globalCtx))) { + } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && (func_80147624(globalCtx))) { if (globalCtx->msgCtx.choiceIndex != 0) { func_8019F208(); globalCtx->msgCtx.unk11F22 = 0x4D; @@ -151,11 +151,12 @@ void ObjWarpstone_Update(Actor* thisx, GlobalContext* globalCtx) { func_801477B4(globalCtx); } } - } else if (func_800B84D0(&this->dyna.actor, globalCtx)) { + } else if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { this->isTalking = true; } else if (!this->actionFunc(this, globalCtx)) { func_800B863C(&this->dyna.actor, globalCtx); } + Collider_ResetCylinderAC(globalCtx, &this->collider.base); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); @@ -166,7 +167,7 @@ void ObjWarpstone_Draw(Actor* thisx, GlobalContext* globalCtx2) { ObjWarpstone* this = THIS; GlobalContext* globalCtx = globalCtx2; - func_800BDFC0(globalCtx, sOwlStatueDLs[this->modelIndex]); + Gfx_DrawDListOpa(globalCtx, sOwlStatueDLs[this->modelIndex]); if (this->dyna.actor.home.rot.x != 0) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c index 2d8689d4fd..3d34f1bf4b 100644 --- a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c +++ b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c @@ -69,8 +69,8 @@ void ObjYado_Draw(Actor* thisx, GlobalContext* globalCtx) { } AnimatedMat_Draw(globalCtx, D_80C16470); - func_800BDFC0(globalCtx, D_06000430); - func_800BE03C(globalCtx, D_06000320); + Gfx_DrawDListOpa(globalCtx, D_06000430); + Gfx_DrawDListXlu(globalCtx, D_06000320); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index ce88071314..0c0a722793 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -5,6 +5,7 @@ */ #include "z_object_kankyo.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x02000030 @@ -15,12 +16,17 @@ void ObjectKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjectKankyo_Update(Actor* thisx, GlobalContext* globalCtx); void ObjectKankyo_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjectKankyo_SetupAction(ObjectKankyo* this, ObjectKankyoActionFunc actionFunc); +void func_808DC18C(ObjectKankyo* this, GlobalContext* globalCtx); void func_808DCB7C(ObjectKankyo* this, GlobalContext* globalCtx); void func_808DCBF8(ObjectKankyo* this, GlobalContext* globalCtx); +void func_808DCDB4(ObjectKankyo* this, GlobalContext* globalCtx); +void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2); +void func_808DD970(Actor* thisx, GlobalContext* globalCtx2); +void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2); -void ObjectKankyo_SetupAction(ObjectKankyo* this, ObjectKankyoActionFunc actionFunc); +static f32 D_808DE5B0; -#if 0 const ActorInit Object_Kankyo_InitVars = { ACTOR_OBJECT_KANKYO, ACTORCAT_ITEMACTION, @@ -33,42 +39,694 @@ const ActorInit Object_Kankyo_InitVars = { (ActorFunc)ObjectKankyo_Draw, }; -#endif +static u16 D_808DE340 = 0; -extern UNK_TYPE D_01000000; +void ObjectKankyo_SetupAction(ObjectKankyo* this, ObjectKankyoActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/ObjectKankyo_SetupAction.s") +void func_808DBE8C(ObjectKankyo* this) { + ObjectKankyo_SetupAction(this, func_808DC18C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DBE8C.s") +void func_808DBEB0(ObjectKankyo* this, GlobalContext* globalCtx) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DBEB0.s") + D_808DE5B0 = 0.0f; + this->unk_144 = Rand_ZeroOne() * 360.0f; + this->unk_148 = Rand_ZeroOne() * 360.0f; + if (globalCtx->envCtx.unk_F2[2] == 128) { + D_808DE5B0 = 1.0f; + this->unk_114E = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DBFB0.s") + for (i = 0; i < globalCtx->envCtx.unk_F2[2]; i++) { + this->unk_14C[i].unk_10 = Rand_ZeroOne() * -200.0f; + } + } else { + this->unk_114E = 0; + } + ObjectKankyo_SetupAction(this, func_808DCB7C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DC038.s") +void func_808DBFB0(ObjectKankyo* this, GlobalContext* globalCtx) { + D_808DE5B0 = 0.0f; + this->unk_114E = 0; + this->unk_144 = Rand_ZeroOne() * 360.0f; + this->unk_148 = Rand_ZeroOne() * 360.0f; + this->unk_114C = D_808DE340; + D_808DE340++; + ObjectKankyo_SetupAction(this, func_808DCBF8); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/ObjectKankyo_Init.s") +void func_808DC038(ObjectKankyo* this, GlobalContext* globalCtx) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/ObjectKankyo_Destroy.s") + this->unk_144 = Rand_ZeroOne() * 360.0f; + this->unk_148 = Rand_ZeroOne() * 360.0f; + this->unk_114C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DC18C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_14C); i++) { + this->unk_14C[i].unk_1C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DC454.s") + ObjectKankyo_SetupAction(this, func_808DCDB4); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DCB7C.s") +void ObjectKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjectKankyo* this = THIS; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DCBF8.s") + for (i = 0; i < ARRAY_COUNT(this->unk_14C); i++) { + this->unk_14C[i].unk_1C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DCDB4.s") + this->actor.room = -1; + switch (this->actor.params) { + case 0: + func_808DBE8C(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/ObjectKankyo_Update.s") + case 2: + globalCtx->envCtx.unk_F2[2] = 0x80; + func_808DBFB0(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/ObjectKankyo_Draw.s") + case 1: + case 3: + func_808DBEB0(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DD3C8.s") + case 4: + func_808DC038(this, globalCtx); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DD970.s") +void ObjectKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjectKankyo* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DDE74.s") + Actor_MarkForDeath(&this->actor); +} +void func_808DC18C(ObjectKankyo* this, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + s32 pad3; + f32 magnitude; + f32 y; + f32 z; + f32 temp_f18; + Vec3f sp30; + f32 x; + f32 sp1C; + + x = globalCtx->view.at.x - globalCtx->view.eye.x; + y = globalCtx->view.at.y - globalCtx->view.eye.y; + z = globalCtx->view.at.z - globalCtx->view.eye.z; + magnitude = sqrtf(SQ(x) + SQ(y) + SQ(z)); + + temp_f18 = x / magnitude; + x = z / magnitude; + sp1C = (y / magnitude) * 120.0f; + + this->unk_14C[0].unk_00 = globalCtx->view.eye.x + (temp_f18 * 50.0f); + this->unk_14C[0].unk_04 = globalCtx->view.eye.y + sp1C; + this->unk_14C[0].unk_08 = globalCtx->view.eye.z + (x * 50.0f); + this->unk_14C[1].unk_00 = globalCtx->view.eye.x + (temp_f18 * 220.0f); + this->unk_14C[1].unk_08 = globalCtx->view.eye.z + (x * 220.0f); + this->unk_114C = 0; + this->unk_144 = 100.0f; + + if ((this->unk_14C[0].unk_00 < -252.0f) && (this->unk_14C[0].unk_00 > -500.0f)) { + if ((this->unk_14C[0].unk_08 > 3820.0f) && (this->unk_14C[0].unk_08 < 4150.0f)) { + this->unk_114C = 1; + this->unk_144 = 400.0f; + if (x < 0.0f) { + this->unk_14C[0].unk_00 = -350.0f; + this->unk_14C[0].unk_04 = globalCtx->view.eye.y + sp1C; + this->unk_14C[0].unk_08 = 3680.0f; + this->unk_14C[1].unk_00 = -350.0f; + this->unk_14C[1].unk_08 = 3680.0f; + } else { + this->unk_14C[0].unk_00 = -350.0f; + this->unk_14C[0].unk_04 = globalCtx->view.eye.y + sp1C; + this->unk_14C[0].unk_08 = 4280.0f; + this->unk_14C[1].unk_00 = -350.0f; + this->unk_14C[1].unk_08 = 4280.0f; + } + } + } + + magnitude = globalCtx->envCtx.windSpeed / 60.0f; + magnitude = CLAMP(magnitude, 0.0f, 1.0f); + + sp30.x = globalCtx->envCtx.windDir.x * magnitude; + sp30.y = globalCtx->envCtx.windDir.y + 100.0f; + sp30.z = globalCtx->envCtx.windDir.z * magnitude; + this->unk_14C[2].unk_00 = 0x4000 - Math_Vec3f_Pitch(&gZeroVec3f, &sp30); + this->unk_14C[2].unk_04 = Math_Vec3f_Yaw(&gZeroVec3f, &sp30) + 0x8000; +} + +void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { + s16 i; + u32 tempI; + f32 phi_f20; + f32 spD0; + f32 spCC; + f32 spC8; + f32 spC4; + f32 spC0; + f32 spBC; + f32 temp_f0_4; + f32 temp_f22; + f32 temp_f24; + f32 temp_f28; + f32 x = globalCtx->view.at.x - globalCtx->view.eye.x; + f32 y = globalCtx->view.at.y - globalCtx->view.eye.y; + f32 z = globalCtx->view.at.z - globalCtx->view.eye.z; + f32 magnitude = sqrtf(SQ(x) + SQ(y) + SQ(z)); + f32 temp_120 = 120.0f; + f32 temp_f30; + Vec3f sp88; + s32 pad; + + spD0 = x / magnitude; + spCC = y / magnitude; + spC8 = z / magnitude; + + for (i = 0; i < globalCtx->envCtx.unk_F2[2]; i++) { + switch (this->unk_14C[i].unk_1C) { + case 0: + this->unk_14C[i].unk_00 = globalCtx->view.eye.x + (spD0 * 120.0f); + this->unk_14C[i].unk_04 = globalCtx->view.eye.y + (spCC * 120.0f); + this->unk_14C[i].unk_08 = globalCtx->view.eye.z + (spC8 * 120.0f); + this->unk_14C[i].unk_0C = (Rand_ZeroOne() - 0.5f) * (2.0f * temp_120); + + temp_f22 = (func_800DFCB4(GET_ACTIVE_CAM(globalCtx)) * 0.004f) + 60.0f; + if (temp_f22 < 20.0f) { + temp_f22 = 20.0f; + } + + if (this->unk_114E == 0) { + this->unk_14C[i].unk_10 = temp_f22; + } else { + this->unk_14C[i].unk_10 += temp_f22; + tempI = i; + if (globalCtx->envCtx.unk_F2[2] == (tempI + 1)) { + this->unk_114E = 0; + } + } + + this->unk_14C[i].unk_14 = (Rand_ZeroOne() - 0.5f) * (2.0f * temp_120); + if (globalCtx->envCtx.unk_F2[4] == 0) { + this->unk_14C[i].unk_18 = (Rand_ZeroOne() * 3.0f) + 1.0f; + } else { + this->unk_14C[i].unk_18 = (Rand_ZeroOne() * 3.0f) + 8.0f; + } + this->unk_14C[i].unk_1C++; + break; + + case 1: + temp_f24 = globalCtx->view.eye.x + (spD0 * 120.0f); + temp_f28 = globalCtx->view.eye.y + (spCC * 120.0f); + temp_f30 = globalCtx->view.eye.z + (spC8 * 120.0f); + + magnitude = sqrtf((f32)SQ(globalCtx->envCtx.windDir.x) + SQ(globalCtx->envCtx.windDir.y) + + SQ(globalCtx->envCtx.windDir.z)); + if (magnitude == 0.0f) { + magnitude = 0.001f; + } + spC4 = -globalCtx->envCtx.windDir.x / magnitude; + spC0 = -globalCtx->envCtx.windDir.y / magnitude; + spBC = -globalCtx->envCtx.windDir.z / magnitude; + + if (i == 0) { + this->unk_144 += 0.049999997f * Rand_ZeroOne(); + this->unk_148 += 0.049999997f * Rand_ZeroOne(); + } + + phi_f20 = globalCtx->envCtx.windSpeed / 120.0f; + phi_f20 = CLAMP(phi_f20, 0.0f, 1.0f); + + this->unk_14C[i].unk_0C += __sinf((this->unk_144 + (i * 100.0f)) * 0.01f) + (spC4 * 10.0f * phi_f20); + this->unk_14C[i].unk_14 += __cosf((this->unk_148 + (i * 100.0f)) * 0.01f) + (spBC * 10.0f * phi_f20); + this->unk_14C[i].unk_10 -= + this->unk_14C[i].unk_18 - (spC0 * 3.0f * (globalCtx->envCtx.windSpeed / 100.0f)); + + temp_f22 = (-func_800DFCB4(GET_ACTIVE_CAM(globalCtx)) * 0.012f) + 40.0f; + if (temp_f22 < -40.0f) { + temp_f22 = -40.0f; + } + + if (((this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C) - temp_f24) > temp_120) { + this->unk_14C[i].unk_00 = temp_f24 - temp_120; + } + + if (((this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C) - temp_f24) < -temp_120) { + this->unk_14C[i].unk_00 = temp_f24 + temp_120; + } + + sp88.x = this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C; + sp88.y = this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10; + sp88.z = this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14; + + phi_f20 = Math_Vec3f_DistXZ(&sp88, &globalCtx->view.eye) / 200.0f; + phi_f20 = CLAMP(phi_f20, 0.0f, 1.0f); + temp_f0_4 = 100.0f + phi_f20 + 60.0f; + + if (temp_f0_4 < (this->unk_14C[i].unk_04 + (this->unk_14C[i].unk_10) - temp_f28)) { + this->unk_14C[i].unk_04 = temp_f28 - temp_f0_4; + } + + if (((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) - temp_f28) < -temp_f0_4) { + this->unk_14C[i].unk_04 = temp_f28 + temp_f0_4; + } + + if (((this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14) - temp_f30) > temp_120) { + this->unk_14C[i].unk_08 = temp_f30 - temp_120; + } + + if (((this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14) - temp_f30) < -temp_120) { + this->unk_14C[i].unk_08 = temp_f30 + temp_120; + } + + if ((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) < + ((globalCtx->view.eye.y - temp_f22) - 40.0f)) { + this->unk_14C[i].unk_1C = 0; + } + break; + } + } +} + +void func_808DCB7C(ObjectKankyo* this, GlobalContext* globalCtx) { + if (globalCtx->envCtx.unk_F2[2] < globalCtx->envCtx.unk_F2[3]) { + if ((globalCtx->state.frames % 16) == 0) { + globalCtx->envCtx.unk_F2[2] += 2; + } + } else if (globalCtx->envCtx.unk_F2[3] < globalCtx->envCtx.unk_F2[2]) { + if ((globalCtx->state.frames % 16) == 0) { + globalCtx->envCtx.unk_F2[2] -= 2; + } + } + func_808DC454(this, globalCtx); +} + +void func_808DCBF8(ObjectKankyo* this, GlobalContext* globalCtx) { + f32 temp_f0; + + if ((globalCtx->envCtx.unk_F2[2] > 0) && (this->unk_114C == 0)) { + if ((globalCtx->state.frames % 16) == 0) { + globalCtx->envCtx.unk_F2[2] -= 9; + if ((s8)globalCtx->envCtx.unk_F2[2] < 0) { + globalCtx->envCtx.unk_F2[2] = 0; + } + } + } + + temp_f0 = (f32)globalCtx->envCtx.unk_F2[2] / 128; + temp_f0 = CLAMP(temp_f0, 0.0f, 1.0f); + + if (temp_f0 > 0.01f) { + D_801F4E30 = 155.0f * temp_f0; + globalCtx->envCtx.unk_EA = 10; + } else { + D_801F4E30 = 0; + globalCtx->envCtx.unk_EA = 10; + } + func_808DC454(this, globalCtx); +} + +void func_808DCDB4(ObjectKankyo* this, GlobalContext* globalCtx) { + s16 i; + f32 magnitude; + f32 temp_80; + f32 temp_120; + f32 spAC; + f32 spA8; + f32 spA4; + f32 spA0; + f32 sp9C; + f32 x; + f32 y; + f32 z; + f32 temp_f18; + f32 temp_f20; + f32 temp_f26; + f32 temp_f28; + + if (this->unk_114C < 0x80) { + this->unk_114C++; + } + + x = globalCtx->view.at.x - globalCtx->view.eye.x; + y = globalCtx->view.at.y - globalCtx->view.eye.y; + z = globalCtx->view.at.z - globalCtx->view.eye.z; + + magnitude = sqrtf(SQ(x) + SQ(y) + SQ(z)); + + spAC = x / magnitude; + spA8 = y / magnitude; + spA4 = z / magnitude; + + temp_80 = 80.0f; + temp_120 = 120.0f; + + for (i = 0; i < this->unk_114C; i++) { + switch (this->unk_14C[i].unk_1C) { + case 0: + this->unk_14C[i].unk_00 = globalCtx->view.eye.x + (spAC * 120.0f); + this->unk_14C[i].unk_04 = globalCtx->view.eye.y + (spA8 * 120.0f); + this->unk_14C[i].unk_08 = globalCtx->view.eye.z + (spA4 * 120.0f); + this->unk_14C[i].unk_0C = (Rand_ZeroOne() - 0.5f) * (temp_120 * 2.0f); + if ((i % 2) == 0) { + this->unk_14C[i].unk_10 = -100.0f; + } else { + this->unk_14C[i].unk_10 = 100.0f; + } + this->unk_14C[i].unk_14 = (Rand_ZeroOne() - 0.5f) * (temp_120 * 2.0f); + this->unk_14C[i].unk_18 = Rand_ZeroOne() + 0.2f; + this->unk_14C[i].unk_1C++; + break; + + case 1: + + temp_f26 = globalCtx->view.eye.x + (spAC * 120.0f); + temp_f28 = globalCtx->view.eye.y + (spA8 * 120.0f); + temp_f18 = globalCtx->view.eye.z + (spA4 * 120.0f); + + magnitude = sqrtf((f32)SQ(globalCtx->envCtx.windDir.x) + SQ(globalCtx->envCtx.windDir.y) + + SQ(globalCtx->envCtx.windDir.z)); + if (magnitude == 0.0f) { + magnitude = 0.001f; + } + + spA0 = -globalCtx->envCtx.windDir.x / magnitude; + sp9C = -globalCtx->envCtx.windDir.z / magnitude; + + if (i == 0) { + this->unk_144 += 0.049999997f * Rand_ZeroOne(); + this->unk_148 += 0.049999997f * Rand_ZeroOne(); + } + temp_f20 = globalCtx->envCtx.windSpeed / 120.0f; + temp_f20 = CLAMP(temp_f20, 0.0f, 1.0f); + + this->unk_14C[i].unk_0C += __sinf((this->unk_144 + i) * 0.01f) + (spA0 * 10.0f * temp_f20); + this->unk_14C[i].unk_14 += __cosf((this->unk_148 + i) * 0.01f) + (sp9C * 10.0f * temp_f20); + + if ((i % 2) == 0) { + this->unk_14C[i].unk_10 += this->unk_14C[i].unk_18; + if ((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) > (globalCtx->view.eye.y + 100.0f)) { + this->unk_14C[i].unk_1C = 0; + } + } else { + this->unk_14C[i].unk_10 -= this->unk_14C[i].unk_18; + if ((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) < (globalCtx->view.eye.y - 100.0f)) { + this->unk_14C[i].unk_1C = 0; + } + } + + if (((this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C) - temp_f26) > temp_80) { + this->unk_14C[i].unk_00 = temp_f26 - temp_80; + } + + if (((this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C) - temp_f26) < -temp_80) { + this->unk_14C[i].unk_00 = temp_f26 + temp_80; + } + + if (((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) - temp_f28) > temp_80) { + this->unk_14C[i].unk_04 = temp_f28 - temp_80; + } + + if (((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) - temp_f28) < -temp_80) { + this->unk_14C[i].unk_04 = temp_f28 + temp_80; + } + + if (((this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14) - temp_f18) > temp_80) { + this->unk_14C[i].unk_08 = temp_f18 - temp_80; + } + + if (((this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14) - temp_f18) < -temp_80) { + this->unk_14C[i].unk_08 = temp_f18 + temp_80; + } + break; + } + } +} + +void ObjectKankyo_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjectKankyo* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void ObjectKankyo_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjectKankyo* this = THIS; + + switch (this->actor.params) { + case 0: + func_808DDE9C(thisx, globalCtx); + break; + + case 1: + case 2: + case 3: + func_808DD3C8(thisx, globalCtx); + break; + + case 4: + func_808DD970(thisx, globalCtx); + break; + } +} + +void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjectKankyo* this = THIS; + Vec3f spC4; + Vec3f spB8; + s16 i; + u8 pad2; + u8 spB4; + f32 temp_f0; + u8 sp68; + s32 pad; + f32 temp_f2; + f32 tempf; + + if ((globalCtx->cameraPtrs[MAIN_CAM]->flags2 & 0x100) || ((u8)globalCtx->envCtx.unk_E2 == 0)) { + return; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + spB4 = false; + + if (this->actor.params == 3) { + temp_f0 = func_80173B48(&globalCtx->state) / 1.4e7f; + temp_f0 = CLAMP(temp_f0, 0.0f, 1.0f); + Math_SmoothStepToF(&D_808DE5B0, temp_f0, 0.2f, 0.1f, 0.001f); + + sp68 = globalCtx->envCtx.unk_F2[2]; + sp68 *= D_808DE5B0; + + if ((globalCtx->envCtx.unk_F2[2] >= 32) && (sp68 < 32)) { + sp68 = 32; + } + } else { + sp68 = globalCtx->envCtx.unk_F2[2]; + } + + for (i = 0; i < sp68; i++) { + spC4.x = this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C; + spC4.y = this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10; + spC4.z = this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14; + func_80169474(globalCtx, &spC4, &spB8); + + if ((spB8.x >= 0.0f) && (spB8.x < 320.0f) && (spB8.y >= 0.0f) && (spB8.y < 240.0f)) { + if (!spB4) { + spB4 = true; + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 255); + gSPClearGeometryMode(POLY_XLU_DISP++, G_LIGHTING); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_08EBE0)); + } + + Matrix_InsertTranslation(spC4.x, spC4.y, spC4.z, MTXMODE_NEW); + tempf = (i & 7) * 0.008f; + Matrix_Scale(0.05f + tempf, 0.05f + tempf, 0.05f + tempf, MTXMODE_APPLY); + temp_f2 = Math_Vec3f_DistXYZ(&spC4, &globalCtx->view.eye) / 300.0f; + temp_f2 = ((1.0f < temp_f2) ? 0.0f : (((1.0f - temp_f2) > 1.0f) ? 1.0f : 1.0f - temp_f2)); + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(160.0f * temp_f2)); + + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023130); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { + f32 temp_f0; + f32 temp_f20; + Vec3f spBC; + Vec3f spB0; + f32 tempf; + s16 i; + f32 phi_f26; + GlobalContext* globalCtx = globalCtx2; + ObjectKankyo* this = THIS; + f32 tempA; + + if (globalCtx->sceneNum == SCENE_KYOJINNOMA) { + phi_f26 = 1.0f; + } else { + tempA = func_800E031C(GET_ACTIVE_CAM(globalCtx)); + if (tempA != BGCHECK_Y_MIN) { + tempA -= globalCtx->view.eye.y; + phi_f26 = tempA / 4000.0f; + } else { + phi_f26 = 0.0f; + } + + phi_f26 = CLAMP_MAX(phi_f26, 1.0f); + + if (!(globalCtx->cameraPtrs[MAIN_CAM]->flags2 & 0x100) || (phi_f26 == 0.0f)) { + return; + } + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + for (i = 0; i < this->unk_114C; i++) { + spBC.x = this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C; + spBC.y = this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10; + spBC.z = this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14; + func_80169474(globalCtx, &spBC, &spB0); + + if ((spB0.x >= 0.0f) && (spB0.x < 320.0f) && (spB0.y >= 0.0f) && (spB0.y < 240.0f)) { + Matrix_InsertTranslation(spBC.x, spBC.y, spBC.z, MTXMODE_NEW); + Matrix_Scale(0.03f, 0.03f, 0.03f, MTXMODE_APPLY); + temp_f0 = Math_Vec3f_DistXYZ(&spBC, &globalCtx->view.eye); + temp_f0 = (u8)(255.0f * phi_f26) * (1.0f - (temp_f0 / 300.0f)); + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 55, temp_f0); + gDPSetEnvColor(POLY_XLU_DISP++, 55, 50, 255, temp_f0); + + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_08EBE0)); + gSPClearGeometryMode(POLY_XLU_DISP++, G_LIGHTING); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023130); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +f32 func_808DDE74(void) { + return Rand_ZeroOne() - 0.5f; +} + +#ifdef NON_MATCHING +// globalCtx->envCtx.unk_F2[1] needs to be laoded into s0 and then copied to s7 +void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjectKankyo* this = THIS; + Player* player = GET_PLAYER(globalCtx); + s32 i; + s16 temp; + f32 temp_f12; + f32 temp_f20; + f32 temp_f22; + f32 temp_f2; + u8 phi_s5; + s32 end = globalCtx->envCtx.unk_F2[1]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (end != 0) { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 150, 255, 255, 25); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); + } + + for (i = 0; i < end; i++) { + temp_f20 = this->unk_14C[0].unk_00 + ((Rand_ZeroOne() - 0.7f) * this->unk_144); + temp_f22 = this->unk_14C[0].unk_04 + ((Rand_ZeroOne() - 0.7f) * this->unk_144); + temp_f2 = this->unk_14C[0].unk_08 + ((Rand_ZeroOne() - 0.7f) * this->unk_144); + + if ((temp_f20 < -252.0f) && (temp_f20 > -500.0f) && (temp_f2 > 3820.0f) && (temp_f2 < 4150.0f)) { + continue; + } + + Matrix_InsertTranslation(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); + + gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + + Matrix_RotateY((s16)this->unk_14C[2].unk_04 + (s16)(i << 5), MTXMODE_APPLY); + Matrix_InsertXRotation_s((s16)this->unk_14C[2].unk_00 + (s16)(i << 5), MTXMODE_APPLY); + + if (this->unk_114C == 0) { + Matrix_Scale(0.5f, 1.0f, 0.5f, MTXMODE_APPLY); + } else { + Matrix_Scale(2.0f, 4.0f, 2.0f, MTXMODE_APPLY); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0706E0); + } + + phi_s5 = false; + if (player->actor.floorHeight < globalCtx->view.eye.y) { + for (i = 0; i < end; i++) { + if (!phi_s5) { + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 255); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 100); + phi_s5++; + } + + temp_f20 = this->unk_14C[1].unk_00 + (func_808DDE74() * 220.0f); + temp_f22 = player->actor.floorHeight + 2.0f; + temp_f2 = this->unk_14C[1].unk_08 + (func_808DDE74() * 220.0f); + + if ((temp_f20 < -252.0f) && (temp_f20 > -500.0f) && (temp_f2 > 3820.0f) && (temp_f2 < 4150.0f)) { + continue; + } + + Matrix_InsertTranslation(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); + temp_f12 = (Rand_ZeroOne() * 0.05f) + 0.05f; + Matrix_Scale(temp_f12, temp_f12, temp_f12, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_030100); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DDE9C.s") +#endif diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h index f61d140d84..646863be0a 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h @@ -7,9 +7,24 @@ struct ObjectKankyo; typedef void (*ObjectKankyoActionFunc)(struct ObjectKankyo*, GlobalContext*); +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ u8 unk_1C; +} ObjectKankyoStruct; // size = 0x20 + typedef struct ObjectKankyo { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x100C]; + /* 0x0144 */ f32 unk_144; + /* 0x0148 */ f32 unk_148; + /* 0x014C */ ObjectKankyoStruct unk_14C[128]; + /* 0x114C */ u16 unk_114C; + /* 0x114E */ u8 unk_114E; /* 0x1150 */ ObjectKankyoActionFunc actionFunc; } ObjectKankyo; // size = 0x1154 diff --git a/src/overlays/actors/ovl_Player_Actor/overlay.cfg b/src/overlays/actors/ovl_Player_Actor/overlay.cfg deleted file mode 100644 index 6dea57e3f1..0000000000 --- a/src/overlays/actors/ovl_Player_Actor/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Player_Actor -z_player.c diff --git a/src/overlays/actors/ovl_Player_Actor/z_player.c b/src/overlays/actors/ovl_Player_Actor/z_player.c deleted file mode 100644 index 2d5b3d59a7..0000000000 --- a/src/overlays/actors/ovl_Player_Actor/z_player.c +++ /dev/null @@ -1,1297 +0,0 @@ -/* - * File: z_player.c - * Overlay: ovl_Player_Actor - * Description: Player - */ - -#include "global.h" - -#define THIS ((Player*)thisx) - -extern UNK_TYPE D_06008860; -extern UNK_TYPE D_0600BDD8; -extern UNK_TYPE D_060178D0; - -#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") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DAD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DAFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DB18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DB3C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DB60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DB90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DBC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DC28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DC38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DC64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DCA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DD2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DE14.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DE50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DE88.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DF2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DF48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082DF8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E00C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E078.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E094.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E0CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E0F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E12C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E188.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E1BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E1F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E224.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E438.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E4A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E514.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E55C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E5A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E5EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E634.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E67C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E6D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E6F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E784.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E794.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E820.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E920.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082E9C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EA10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EA38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EA60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EA80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EAC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EAF0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EB18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EB38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EC9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082ECCC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082ECE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082ED20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082ED94.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EEA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EEE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EF20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EF54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EF9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082EFE4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F02C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F09C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F0E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F164.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F1AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F43C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F470.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F524.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F594.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F5A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F5C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F5FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F62C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F7F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F8A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F8BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082F938.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082FA5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082FB68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082FBE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082FC24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082FC60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082FC78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082FCC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082FD0C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082FDC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8082FE0C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808302CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808304BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808305BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808306F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808308DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808309CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80830A58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80830AE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80830B38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80830B88.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80830CE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80830D40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80830DF0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80830E30.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80830F9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80830FD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80831010.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80831094.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80831124.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80831194.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083133C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808313A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808313F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80831454.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80831494.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083172C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80831760.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808317C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80831814.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808318C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80831944.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80831990.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80831F34.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80832090.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083213C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083216C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808323C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80832444.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083249C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808324EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80832558.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80832578.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80832660.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80832754.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80832888.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80832CAC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80832F24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80832F78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80833058.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808331FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808332A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808333CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808334D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808335B0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808335F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80833728.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083375C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80833864.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80833998.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808339B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808339D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80833A64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80833AA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80833B18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808340AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808340D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80834104.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80834140.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808341F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808344C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80834534.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083456C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808345A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808345C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80834600.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80834CD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80834D50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80834DB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80834DFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80835324.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808353DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80835428.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808354A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808355D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083562C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80835BC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80835BF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80835C64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80835CD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80835D2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80835D58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80835DF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80835EAC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083604C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80836258.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808365DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80836888.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083692C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80836988.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808369F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80836A5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80836A98.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80836AD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80836B3C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80836C70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80836D8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80836DC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80836EA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80836F10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808370D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80837134.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808373A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808373F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80837730.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083784C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808378FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083798C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808379C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80837B60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80837BD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80837BF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80837C20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80837C78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80837CEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80837DEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808381A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808381F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083827C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083868C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80838760.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808387A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80838830.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808388B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808389BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80838A20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80838A90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808391D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80839518.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808395F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808396B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80839770.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80839800.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80839860.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80839978.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80839A10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80839A84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80839B18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80839CD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80839E3C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80839E74.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80839ED0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80839F98.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083A04C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083A0CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083A114.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083A274.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083A4A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083A548.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083A580.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083A658.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083A6C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083A794.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083A844.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083A878.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083A98C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083AD04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083AD8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083ADB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083ADF0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083AE38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083AECC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083AF30.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083AF8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083B030.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083B090.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083B0E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083B1A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083B23C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083B29C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083B2E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083B32C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083B3B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083B73C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083B798.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083B850.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083B8D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083B930.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083BB4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083BF54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083C62C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083C6E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083C85C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083C8E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083CB04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083CB58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083CBC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083CCB4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083CF68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083D168.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083D23C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083D6DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083D738.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083D78C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083D860.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083DCC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083DD1C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083DEE4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083DF38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083DFC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083E14C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083E234.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083E28C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083E2F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083E354.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083E404.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083E514.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083E758.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083E7F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083E8E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083E958.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083E9C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083EA44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083EBD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083EE60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083F144.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083F190.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083F230.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083F27C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083F358.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083F57C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083F828.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083F8A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083FBC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083FCF0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083FD80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083FE38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083FE90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083FEF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083FF30.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8083FFEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80840094.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808400CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808401F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80840770.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80840980.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808409A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80840A30.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80840CD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80840DEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80840E24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80840E5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80840EC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80840F34.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80840F90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808411D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808412A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808412BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80841358.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80841408.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808414E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80841528.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808415A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808415E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80841624.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80841744.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084182C.s") - -#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/func_80842510.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808425B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808426F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808430E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80843178.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80843EC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808442D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808445C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808446F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80844784.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80844D80.s") - -#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/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/func_808470D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80847190.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084748C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808475B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808477D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80847880.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80847994.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808479F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80847A50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80847A94.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80847BF0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80847E2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80847ED4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80847F1C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80847FF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80848048.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80848094.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808481CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80848250.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80848294.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808482E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808484CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808484F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80848570.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80848640.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80848780.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808487B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80848808.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084894C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80848A0C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80848AB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80848B6C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80848BF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80848E4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80849054.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808490B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808491B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084923C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808492C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084933C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80849570.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80849620.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808496AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808497A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80849A9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80849DD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80849FE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084A26C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084A5C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084A794.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084A884.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084A8E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084AB4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084AC84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084AEEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084AF9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084B0EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084B288.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084B3B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084B4A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084B5C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084BAA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084BBF0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084BC64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084BE40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084BF28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084BFDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084C124.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084C16C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084C6EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084C94C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084CA24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084CB58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084CCEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084CE84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084D18C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084D4EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084D770.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084D820.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084E034.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084E25C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084E334.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084E434.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084E4E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084E58C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084E65C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084E724.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084E980.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084ED9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084EE50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084EF9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084F1B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084F3DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084F4E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084FC0C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084FD7C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084FE48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8084FE7C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808505D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80850734.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80850854.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808508C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80850B18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80850BA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80850BF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80850D20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80850D68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808513EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80851588.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808516B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808519FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80851B58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80851BD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80851C40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80851D30.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80851EAC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80851EC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80851F18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808521E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80852290.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085255C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808525C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085269C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80852B28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80852C04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80852FD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808530E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80853194.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808534C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80853754.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80853850.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80853A5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80853CC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80853D68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80854010.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808540A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80854118.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085421C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085437C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085439C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80854430.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80854614.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808546D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80854800.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808548B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80854C70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80854CD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80854EFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808550D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80855218.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808553F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80855818.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80855A7C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80855AF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80855B9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80855C28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80855E08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80855F9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80856000.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80856074.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80856110.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808561B0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808566C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085687C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80856888.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80856918.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808573A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80857640.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808576BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808577E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80857950.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80857A44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80857AEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80857BE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858C84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858CC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858D48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858DB4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858DDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858DFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858E40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858E60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858E80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858EA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858EC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858EFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858F1C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858F3C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858F5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858F7C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858F9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858FBC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80858FE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859028.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859168.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808591BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859210.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859248.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085929C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859300.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859414.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808594D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808595B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085968C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859708.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085978C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859890.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859990.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_808599DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859A10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859A44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859AD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859AF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859B28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859B54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859BA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859C60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859CA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859CE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859CFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859D44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859D70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859EBC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859F4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859FCC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_80859FF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A04C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A120.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A144.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A19C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A1D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A24C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A2AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A330.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A364.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A40C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A4A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A530.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A5DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A66C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A6C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A710.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A768.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A7C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A8C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085A940.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085AA10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085AA60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085AA84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085AACC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085AB58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085ABA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085AC9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085AD5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085ADA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085B08C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085B134.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085B170.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085B1F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085B28C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085B384.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085B3E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085B460.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085B74C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085B820.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085B854.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Player_Actor/func_8085B930.s") diff --git a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c index d1a6afb3e2..9dcf3ab159 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c @@ -56,7 +56,7 @@ void TGSw_ActionExecuteOneShot(TGSw* this, GlobalContext* globalCtx) { if (1) {} do { - actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_ENEMY, ACTOR_EN_SW); + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_ENEMY, ACTOR_EN_SW); if (actor == NULL) { break; } @@ -71,7 +71,7 @@ void TGSw_ActionExecuteOneShot(TGSw* this, GlobalContext* globalCtx) { actor = NULL; do { - actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_SW); + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_SW); if (actor == NULL) { break; diff --git a/src/overlays/actors/ovl_player_actor/overlay.cfg b/src/overlays/actors/ovl_player_actor/overlay.cfg new file mode 100644 index 0000000000..2d48492357 --- /dev/null +++ b/src/overlays/actors/ovl_player_actor/overlay.cfg @@ -0,0 +1,2 @@ +ovl_player_actor +z_player.c diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c new file mode 100644 index 0000000000..6a5fa04231 --- /dev/null +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -0,0 +1,1297 @@ +/* + * File: z_player.c + * Overlay: ovl_player_actor + * Description: Player + */ + +#include "global.h" + +#define THIS ((Player*)thisx) + +extern UNK_TYPE D_06008860; +extern UNK_TYPE D_0600BDD8; +extern UNK_TYPE D_060178D0; + +#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") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DAD4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DAFC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DB18.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DB3C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DB60.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DB90.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DBC0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DC28.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DC38.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DC64.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DCA0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DD2C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DE14.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DE50.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DE88.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DF2C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DF48.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DF8C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E00C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E078.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E094.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E0CC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E0F4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E12C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E188.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E1BC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E1F0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E224.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E438.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E4A4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E514.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E55C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E5A8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E5EC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E634.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E67C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E6D0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E6F8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E784.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E794.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E820.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E920.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E9C8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EA10.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EA38.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EA60.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EA80.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EAC8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EAF0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EB18.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EB38.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EC9C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082ECCC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082ECE0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082ED20.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082ED94.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EEA4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EEE0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EF20.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EF54.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EF9C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EFE4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F02C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F09C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F0E4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F164.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F1AC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F43C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F470.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F524.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F594.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F5A4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F5C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F5FC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F62C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F7F4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F8A0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F8BC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F938.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FA5C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FB68.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FBE8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FC24.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FC60.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FC78.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FCC4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FD0C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FDC4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FE0C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808302CC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808304BC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808305BC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808306F8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808308DC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808309CC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830A58.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830AE8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830B38.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830B88.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830CE8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830D40.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830DF0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830E30.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830F9C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830FD4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831010.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831094.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831124.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831194.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083133C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808313A8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808313F0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831454.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831494.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083172C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831760.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808317C4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831814.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808318C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831944.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831990.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831F34.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832090.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083213C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083216C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808323C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832444.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083249C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808324EC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832558.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832578.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832660.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832754.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832888.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832CAC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832F24.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832F78.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80833058.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808331FC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808332A0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808333CC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808334D4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808335B0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808335F4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80833728.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083375C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80833864.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80833998.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808339B4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808339D4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80833A64.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80833AA0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80833B18.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808340AC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808340D4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834104.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834140.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808341F4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808344C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834534.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083456C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808345A8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808345C8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834600.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834CD0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834D50.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834DB8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834DFC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835324.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808353DC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835428.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808354A4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808355D8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083562C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835BC8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835BF8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835C64.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835CD8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835D2C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835D58.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835DF8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835EAC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083604C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836258.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808365DC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836888.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083692C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836988.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808369F4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836A5C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836A98.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836AD8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836B3C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836C70.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836D8C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836DC0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836EA0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836F10.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808370D4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837134.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808373A4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808373F8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837730.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083784C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808378FC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083798C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808379C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837B60.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837BD0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837BF8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837C20.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837C78.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837CEC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837DEC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808381A0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808381F8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083827C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083868C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80838760.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808387A0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80838830.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808388B8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808389BC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80838A20.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80838A90.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808391D8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839518.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808395F0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808396B8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839770.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839800.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839860.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839978.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839A10.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839A84.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839B18.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839CD8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839E3C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839E74.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839ED0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839F98.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A04C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A0CC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A114.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A274.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A4A4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A548.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A580.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A658.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A6C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A794.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A844.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A878.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A98C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083AD04.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083AD8C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083ADB8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083ADF0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083AE38.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083AECC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083AF30.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083AF8C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B030.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B090.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B0E4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B1A0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B23C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B29C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B2E4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B32C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B3B4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B73C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B798.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B850.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B8D0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B930.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083BB4C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083BF54.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083C62C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083C6E8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083C85C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083C8E8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083CB04.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083CB58.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083CBC4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083CCB4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083CF68.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083D168.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083D23C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083D6DC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083D738.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083D78C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083D860.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083DCC4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083DD1C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083DEE4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083DF38.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083DFC4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E14C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E234.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E28C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E2F4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E354.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E404.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E514.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E758.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E7F8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E8E0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E958.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E9C4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083EA44.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083EBD0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083EE60.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F144.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F190.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F230.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F27C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F358.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F57C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F828.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F8A8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FBC4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FCF0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FD80.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FE38.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FE90.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FEF4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FF30.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FFEC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840094.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808400CC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808401F4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840770.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840980.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808409A8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840A30.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840CD4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840DEC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840E24.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840E5C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840EC0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840F34.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840F90.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808411D4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808412A0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808412BC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841358.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841408.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808414E0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841528.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808415A0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808415E4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841624.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841744.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084182C.s") + +#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/func_80842510.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808425B4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808426F0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808430E0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80843178.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80843EC0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808442D8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808445C4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808446F4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80844784.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80844D80.s") + +#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/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/func_808470D4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847190.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084748C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808475B4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808477D0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847880.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847994.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808479F4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847A50.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847A94.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847BF0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847E2C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847ED4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847F1C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847FF8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848048.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848094.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808481CC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848250.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848294.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808482E0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808484CC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808484F0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848570.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848640.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848780.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808487B8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848808.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084894C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848A0C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848AB0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848B6C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848BF4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848E4C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80849054.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808490B4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808491B4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084923C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808492C4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084933C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80849570.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80849620.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808496AC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808497A0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80849A9C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80849DD0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80849FE0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084A26C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084A5C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084A794.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084A884.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084A8E8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084AB4C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084AC84.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084AEEC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084AF9C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084B0EC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084B288.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084B3B8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084B4A8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084B5C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084BAA4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084BBF0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084BC64.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084BE40.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084BF28.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084BFDC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084C124.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084C16C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084C6EC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084C94C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084CA24.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084CB58.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084CCEC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084CE84.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084D18C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084D4EC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084D770.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084D820.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E034.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E25C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E334.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E434.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E4E4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E58C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E65C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E724.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E980.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084ED9C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084EE50.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084EF9C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084F1B8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084F3DC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084F4E8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084FC0C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084FD7C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084FE48.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084FE7C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808505D0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80850734.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80850854.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808508C8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80850B18.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80850BA8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80850BF8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80850D20.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80850D68.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808513EC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851588.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808516B4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808519FC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851B58.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851BD4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851C40.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851D30.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851EAC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851EC8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851F18.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808521E0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80852290.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085255C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808525C4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085269C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80852B28.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80852C04.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80852FD4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808530E0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80853194.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808534C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80853754.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80853850.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80853A5C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80853CC0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80853D68.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854010.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808540A0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854118.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085421C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085437C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085439C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854430.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854614.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808546D0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854800.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808548B8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854C70.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854CD0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854EFC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808550D0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855218.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808553F4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855818.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855A7C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855AF4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855B9C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855C28.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855E08.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855F9C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80856000.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80856074.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80856110.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808561B0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808566C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085687C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80856888.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80856918.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808573A4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80857640.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808576BC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808577E0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80857950.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80857A44.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80857AEC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80857BE8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858C84.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858CC8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858D48.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858DB4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858DDC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858DFC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858E40.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858E60.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858E80.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858EA0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858EC0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858EFC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858F1C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858F3C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858F5C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858F7C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858F9C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858FBC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858FE8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859028.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859168.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808591BC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859210.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859248.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085929C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859300.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859414.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808594D0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808595B8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085968C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859708.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085978C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859890.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859990.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808599DC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859A10.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859A44.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859AD0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859AF8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859B28.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859B54.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859BA8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859C60.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859CA0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859CE0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859CFC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859D44.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859D70.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859EBC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859F4C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859FCC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859FF4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A04C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A120.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A144.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A19C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A1D4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A24C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A2AC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A330.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A364.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A40C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A4A4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A530.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A5DC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A66C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A6C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A710.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A768.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A7C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A8C4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A940.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085AA10.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085AA60.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085AA84.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085AACC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085AB58.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085ABA8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085AC9C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085AD5C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085ADA0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B08C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B134.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B170.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B1F0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B28C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B384.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B3E0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B460.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B74C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B820.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B854.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B930.s") diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c index 39f9e51d5f..0d26eec89c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c @@ -20,8 +20,6 @@ const EffectSsInit Effect_Ss_Dead_Dd_InitVars = { #endif -extern UNK_TYPE D_01000000; - #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Dd/EffectSsDeadDd_Init.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Dd/EffectSsDeadDd_Draw.s") diff --git a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c index 2b4feda09e..c490592625 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 @@ -1,27 +1,57 @@ /* * File: z_eff_ss_stick.c * Overlay: ovl_Effect_Ss_Stick - * Description: + * Description: Breaking Deku Stick Fragment */ #include "z_eff_ss_stick.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define PARAMS ((EffectSsStickInitParams*)initParamsx) -s32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsStick_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Stick_InitVars = { EFFECT_SS_STICK, EffectSsStick_Init, }; -#endif +u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsStickInitParams* params = PARAMS; + Vec3f pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Stick/EffectSsStick_Init.s") + this->regs[0] = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_KEEP); + pos = params->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->life = 20; + this->draw = EffectSsStick_Draw; + this->update = EffectSsStick_Update; + this->velocity.y = 26.0f; + this->accel.y = -4.0f; + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Stick/EffectSsStick_Draw.s") +void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Stick/EffectSsStick_Update.s") + 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); + 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++, 0x0C, D_801C0850); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0032B0); + CLOSE_DISPS(gfxCtx); +} + +void EffectSsStick_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.h b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.h index ec43b41bfb..d44a6a468f 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.h +++ b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.h @@ -8,6 +8,4 @@ typedef struct { /* 0x0C */ s16 yaw; } EffectSsStickInitParams; // size = 0x10 -extern const EffectSsInit Effect_Ss_Stick_InitVars; - #endif diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index a98b8e24a5..9b36a7e148 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -74,7 +74,7 @@ void Title_Draw(GameState* thisx) { eye.y = 4002.5417f; eye.z = 1119.0837f; - func_800B7FE0(&object, &eye, &lightDir, this->gameState.gfxCtx); + Hilite_DrawOpa(&object, &eye, &lightDir, this->gameState.gfxCtx); gSPSetLights1(POLY_OPA_DISP++, sTitleLights); diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c index e2fdb18c4d..5573ecb119 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c @@ -60,10 +60,10 @@ extern UNK_TYPE D_0C006C00; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80827E08.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808283D8.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_Draw.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808286D8.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80828788.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8082895C.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_Update.s") diff --git a/tools/ZAPD/.gitrepo b/tools/ZAPD/.gitrepo index a942638a2e..ccd6c7d649 100644 --- a/tools/ZAPD/.gitrepo +++ b/tools/ZAPD/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/zeldaret/ZAPD.git branch = master - commit = 50242eca96a9c36fd84f438bab24548e73b42303 - parent = 744955732b1fc9e8a835c62440aa97799cfe8940 + commit = fd5a7f434171a33b1b3eb2a3e112fdcee6d9262d + parent = 844c24e39c96b7a3f3a40035058bda6c91ed4bbf method = merge cmdver = 0.4.3 diff --git a/tools/ZAPD/Jenkinsfile b/tools/ZAPD/Jenkinsfile index 8db69a1e30..ec9b56ac5a 100644 --- a/tools/ZAPD/Jenkinsfile +++ b/tools/ZAPD/Jenkinsfile @@ -22,13 +22,13 @@ pipeline { } } - // stage('Checkout mm') { - // steps{ - // dir('mm') { - // git url: 'https://github.com/zeldaret/mm.git' - // } - // } - // } + stage('Checkout mm') { + steps{ + dir('mm') { + git url: 'https://github.com/zeldaret/mm.git' + } + } + } } } @@ -51,20 +51,20 @@ pipeline { } } - // stage('Setup MM') { - // steps { - // dir('mm') { - // sh 'cp /usr/local/etc/roms/mm.us.rev1.z64 baserom.mm.us.rev1.z64' + stage('Setup MM') { + steps { + dir('mm') { + sh 'cp /usr/local/etc/roms/mm.us.rev1.z64 baserom.mm.us.rev1.z64' - // // Identical to `make setup` except for copying our newer ZAPD.out into mm - // sh 'make -C tools' - // sh 'cp ../ZAPD.out tools/ZAPD/' - // sh 'python3 tools/fixbaserom.py' - // sh 'python3 tools/extract_baserom.py' - // sh 'python3 extract_assets.py -t 4' - // } - // } - // } + // Identical to `make setup` except for copying our newer ZAPD.out into mm + sh 'make -C tools' + sh 'cp ../ZAPD.out tools/ZAPD/' + sh 'python3 tools/fixbaserom.py' + sh 'python3 tools/extract_baserom.py' + sh 'python3 extract_assets.py -t$(nproc)' + } + } + } } } @@ -78,14 +78,14 @@ pipeline { } } } - // stage('Build mm') { - // steps { - // dir('mm') { - // sh 'make -j disasm' - // sh 'make -j all' - // } - // } - // } + stage('Build mm') { + steps { + dir('mm') { + sh 'make -j disasm' + sh 'make -j all' + } + } + } } } } diff --git a/tools/ZAPD/README.md b/tools/ZAPD/README.md index 44d26b8b3e..448aea0339 100644 --- a/tools/ZAPD/README.md +++ b/tools/ZAPD/README.md @@ -119,6 +119,7 @@ ZAPD also accepts the following list of extra parameters: - `-tm MODE`: Test Mode (enables certain experimental features). To enable it, set `MODE` to `1`. - `-se` / `--set-exporter` : Sets which exporter to use. - `--gcc-compat` : Enables GCC compatibly mode. Slower. +- `-us` / `--unaccounted-static` : Mark unaccounted data as `static` - `-s` / `--static` : Mark every asset as `static`. - This behaviour can be overridden per asset using `Static=` in the respective XML node. - `-W...`: warning flags, see below diff --git a/tools/ZAPD/ZAPD/Declaration.h b/tools/ZAPD/ZAPD/Declaration.h index b7bb0d30d2..4a743b50fa 100644 --- a/tools/ZAPD/ZAPD/Declaration.h +++ b/tools/ZAPD/ZAPD/Declaration.h @@ -12,8 +12,7 @@ typedef uint32_t offset_t; enum class DeclarationAlignment { Align4, - Align8, - Align16 + Align8 }; enum class StaticConfig diff --git a/tools/ZAPD/ZAPD/Globals.cpp b/tools/ZAPD/ZAPD/Globals.cpp index 528a09d256..a10705e9af 100644 --- a/tools/ZAPD/ZAPD/Globals.cpp +++ b/tools/ZAPD/ZAPD/Globals.cpp @@ -152,8 +152,8 @@ bool Globals::GetSegmentedPtrName(segptr_t segAddress, ZFile* currentFile, } } - const auto& symbolFromMap = Globals::Instance->symbolMap.find(segAddress); - if (symbolFromMap != Globals::Instance->symbolMap.end()) + const auto& symbolFromMap = Globals::Instance->cfg.symbolMap.find(segAddress); + if (symbolFromMap != Globals::Instance->cfg.symbolMap.end()) { declName = "&" + symbolFromMap->second; return true; diff --git a/tools/ZAPD/ZAPD/Globals.h b/tools/ZAPD/ZAPD/Globals.h index 19e193f123..1ae753e204 100644 --- a/tools/ZAPD/ZAPD/Globals.h +++ b/tools/ZAPD/ZAPD/Globals.h @@ -58,11 +58,11 @@ public: bool verboseUnaccounted = false; bool gccCompat = false; bool forceStatic = false; + bool forceUnaccountedStatic = false; std::vector files; std::vector externalFiles; std::vector segments; - std::map symbolMap; std::string currentExporter; static std::map& GetExporterMap(); diff --git a/tools/ZAPD/ZAPD/Main.cpp b/tools/ZAPD/ZAPD/Main.cpp index fd2ed06dc0..048338fb70 100644 --- a/tools/ZAPD/ZAPD/Main.cpp +++ b/tools/ZAPD/ZAPD/Main.cpp @@ -48,7 +48,7 @@ void ErrorHandler(int sig) const char* crashEasterEgg[] = { "\tYou've met with a terrible fate, haven't you?", "\tSEA BEARS FOAM. SLEEP BEARS DREAMS. \n\tBOTH END IN THE SAME WAY: CRASSSH!", - "ZAPD has fallen and cannot get up." + "\tZAPD has fallen and cannot get up.", }; srand(time(nullptr)); @@ -216,6 +216,10 @@ int main(int argc, char* argv[]) { Globals::Instance->forceStatic = true; } + else if (arg == "-us" || arg == "--unaccounted-static") + { + Globals::Instance->forceUnaccountedStatic = true; + } } // Parse File Mode diff --git a/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.cpp b/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.cpp index 9d16de4389..0879861997 100644 --- a/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.cpp +++ b/tools/ZAPD/ZAPD/OtherStructs/SkinLimbStructs.cpp @@ -263,7 +263,7 @@ void Struct_800A5E28::DeclareReferences(const std::string& prefix) ZResource::DeclareReferences(varPrefix); - if (unk_4 != 0 && GETSEGNUM(unk_4) == parent->segment) + if (unk_4 != SEGMENTED_NULL && GETSEGNUM(unk_4) == parent->segment) { const auto& res = unk_4_arr.at(0); std::string unk_4_Str = res.GetDefaultName(varPrefix); @@ -293,7 +293,7 @@ void Struct_800A5E28::DeclareReferences(const std::string& prefix) decl->text = entryStr; } - if (unk_8 != 0 && GETSEGNUM(unk_8) == parent->segment) + if (unk_8 != SEGMENTED_NULL && GETSEGNUM(unk_8) == parent->segment) { uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); @@ -306,6 +306,8 @@ void Struct_800A5E28::DeclareReferences(const std::string& prefix) std::string dListStr = StringHelper::Sprintf("%sSkinLimbDL_%06X", varPrefix.c_str(), unk_8_Offset); unk_8_dlist->SetName(dListStr); + unk_8_dlist->DeclareVar(varPrefix, ""); + unk_8_dlist->DeclareReferences(varPrefix); parent->AddResource(unk_8_dlist); } } diff --git a/tools/ZAPD/ZAPD/Overlays/ZOverlay.cpp b/tools/ZAPD/ZAPD/Overlays/ZOverlay.cpp index 510de19aba..113c4ef339 100644 --- a/tools/ZAPD/ZAPD/Overlays/ZOverlay.cpp +++ b/tools/ZAPD/ZAPD/Overlays/ZOverlay.cpp @@ -90,7 +90,8 @@ ZOverlay* ZOverlay::FromBuild(fs::path buildPath, fs::path cfgFolderPath) std::vector readers; for (size_t i = 1; i < cfgLines.size(); i++) { - std::string elfPath = (buildPath / (cfgLines[i].substr(0, cfgLines[i].size() - 2) + ".o")).string(); + std::string elfPath = + (buildPath / (cfgLines[i].substr(0, cfgLines[i].size() - 2) + ".o")).string(); elfio* reader = new elfio(); if (!reader->load(elfPath)) diff --git a/tools/ZAPD/ZAPD/ZAnimation.cpp b/tools/ZAPD/ZAPD/ZAnimation.cpp index adb0ae7c9a..4d9266b091 100644 --- a/tools/ZAPD/ZAPD/ZAnimation.cpp +++ b/tools/ZAPD/ZAPD/ZAnimation.cpp @@ -104,7 +104,7 @@ void ZNormalAnimation::DeclareReferences(const std::string& prefix) valuesStr += "\n "; } - parent->AddDeclarationArray(rotationValuesOffset, DeclarationAlignment::Align16, + parent->AddDeclarationArray(rotationValuesOffset, DeclarationAlignment::Align4, rotationValues.size() * 2, "s16", StringHelper::Sprintf("%sFrameData", defaultPrefix.c_str()), rotationValues.size(), valuesStr); @@ -118,7 +118,7 @@ void ZNormalAnimation::DeclareReferences(const std::string& prefix) indicesStr += "\n"; } - parent->AddDeclarationArray(rotationIndicesOffset, DeclarationAlignment::Align16, + parent->AddDeclarationArray(rotationIndicesOffset, DeclarationAlignment::Align4, rotationIndices.size() * 6, "JointIndex", StringHelper::Sprintf("%sJointIndices", defaultPrefix.c_str()), rotationIndices.size(), indicesStr); @@ -385,7 +385,7 @@ size_t ZCurveAnimation::GetRawDataSize() const DeclarationAlignment ZCurveAnimation::GetDeclarationAlignment() const { - return DeclarationAlignment::Align16; + return DeclarationAlignment::Align4; } std::string ZCurveAnimation::GetSourceTypeName() const diff --git a/tools/ZAPD/ZAPD/ZDisplayList.cpp b/tools/ZAPD/ZAPD/ZDisplayList.cpp index bdb7374fe1..5e9b1b205e 100644 --- a/tools/ZAPD/ZAPD/ZDisplayList.cpp +++ b/tools/ZAPD/ZAPD/ZDisplayList.cpp @@ -27,8 +27,8 @@ ZDisplayList::ZDisplayList(ZFile* nParent) : ZResource(nParent) lastTexSizTest = F3DZEXTexSizes::G_IM_SIZ_16b; lastTexLoaded = false; lastTexIsPalette = false; - name = ""; dListType = Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX; + RegisterOptionalAttribute("Ucode"); } ZDisplayList::~ZDisplayList() @@ -44,13 +44,29 @@ void ZDisplayList::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDat { rawDataIndex = nRawDataIndex; ParseXML(reader); + // TODO add error handling here + bool ucodeSet = registeredAttributes.at("Ucode").wasSet; + std::string ucodeValue = registeredAttributes.at("Ucode").value; + if ((Globals::Instance->game == ZGame::OOT_SW97) || (ucodeValue == "f3dex")) + { + dListType = DListType::F3DEX; + } + else if (!ucodeSet || ucodeValue == "f3dex2") + { + dListType = DListType::F3DZEX; + } + else + { + HANDLE_ERROR_RESOURCE( + WarningType::InvalidAttributeValue, parent, this, rawDataIndex, + StringHelper::Sprintf("Invalid ucode type in node: %s\n", reader->Name()), ""); + } // Don't parse raw data of external files if (parent->GetMode() != ZFileMode::ExternalFile) { - int32_t rawDataSize = ZDisplayList::GetDListLength( - parent->GetRawData(), rawDataIndex, - Globals::Instance->game == ZGame::OOT_SW97 ? DListType::F3DEX : DListType::F3DZEX); + int32_t rawDataSize = + ZDisplayList::GetDListLength(parent->GetRawData(), rawDataIndex, dListType); numInstructions = rawDataSize / 8; ParseRawData(); } @@ -693,7 +709,8 @@ void ZDisplayList::Opcode_G_DL(uint64_t data, const std::string& prefix, char* l else if (dListDecl != nullptr) sprintf(line, "gsSPBranchList(%s),", dListDecl->varName.c_str()); else - sprintf(line, "gsSPBranchList(%sDlist0x%06" PRIX64 "),", prefix.c_str(), GETSEGOFFSET(data)); + sprintf(line, "gsSPBranchList(%sDlist0x%06" PRIX64 "),", prefix.c_str(), + GETSEGOFFSET(data)); } else { @@ -702,7 +719,8 @@ void ZDisplayList::Opcode_G_DL(uint64_t data, const std::string& prefix, char* l else if (dListDecl != nullptr) sprintf(line, "gsSPDisplayList(%s),", dListDecl->varName.c_str()); else - sprintf(line, "gsSPDisplayList(%sDlist0x%06" PRIX64 "),", prefix.c_str(), GETSEGOFFSET(data)); + sprintf(line, "gsSPDisplayList(%sDlist0x%06" PRIX64 "),", prefix.c_str(), + GETSEGOFFSET(data)); } // if (segNum == 8 || segNum == 9 || segNum == 10 || segNum == 11 || segNum == 12 || segNum == @@ -832,7 +850,7 @@ void ZDisplayList::Opcode_G_VTX(uint64_t data, char* line) { segptr_t segmented = data & 0xFFFFFFFF; references.push_back(segmented); - parent->AddDeclaration(segmented, DeclarationAlignment::Align16, 16, "Vtx", + parent->AddDeclaration(segmented, DeclarationAlignment::Align8, 16, "Vtx", StringHelper::Sprintf("0x%08X", segmented), ""); return; } @@ -1748,7 +1766,7 @@ void ZDisplayList::DeclareReferences(const std::string& prefix) if (vertices.size() > 0) { std::vector>> verticesSorted(vertices.begin(), - vertices.end()); + vertices.end()); for (size_t i = 0; i < verticesSorted.size() - 1; i++) { @@ -1796,7 +1814,7 @@ void ZDisplayList::DeclareReferences(const std::string& prefix) if (vertices.size() > 0) { std::vector>> verticesSorted(vertices.begin(), - vertices.end()); + vertices.end()); for (size_t i = 0; i < verticesSorted.size() - 1; i++) { diff --git a/tools/ZAPD/ZAPD/ZFile.cpp b/tools/ZAPD/ZAPD/ZFile.cpp index 77387fc72c..22a6a45058 100644 --- a/tools/ZAPD/ZAPD/ZFile.cpp +++ b/tools/ZAPD/ZAPD/ZFile.cpp @@ -8,6 +8,7 @@ #include "Globals.h" #include "OutputFormatter.h" #include "Utils/BinaryWriter.h" +#include "Utils/BitConverter.h" #include "Utils/Directory.h" #include "Utils/File.h" #include "Utils/MemoryStream.h" @@ -192,7 +193,7 @@ void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename) rawData = File::ReadAllBytes((basePath / name).string()); if (reader->Attribute("RangeEnd") == nullptr) - rangeEnd = rawData.size(); + rangeEnd = rawData.size(); } std::unordered_set nameSet; @@ -378,7 +379,7 @@ void ZFile::ExtractResources() ZResourceExporter* exporter = Globals::Instance->GetExporter(res->GetResourceType()); if (exporter != nullptr) { - //exporter->Save(res, Globals::Instance->outputPath.string(), &writerFile); + // exporter->Save(res, Globals::Instance->outputPath.string(), &writerFile); exporter->Save(res, Globals::Instance->outputPath.string(), &writerRes); } @@ -391,7 +392,7 @@ void ZFile::ExtractResources() File::WriteAllBytes(StringHelper::Sprintf("%s%s.bin", Globals::Instance->outputPath.string().c_str(), GetName().c_str()), - memStreamFile->ToVector()); + memStreamFile->ToVector()); } writerFile.Close(); @@ -949,9 +950,6 @@ std::string ZFile::ProcessDeclarations() defines += ProcessTextureIntersections(name); - // Account for padding/alignment - uint32_t lastAddr = 0; - // printf("RANGE START: 0x%06X - RANGE END: 0x%06X\n", rangeStart, rangeEnd); // Optimization: See if there are any arrays side by side that can be merged... @@ -1002,43 +1000,6 @@ std::string ZFile::ProcessDeclarations() { while (item.second->size % 4 != 0) item.second->size++; - - if (lastAddr != 0) - { - if (item.second->alignment == DeclarationAlignment::Align16) - { - int32_t curPtr = lastAddr + declarations[lastAddr]->size; - - while (curPtr % 4 != 0) - { - declarations[lastAddr]->size++; - curPtr++; - } - } - else if (item.second->alignment == DeclarationAlignment::Align8) - { - size_t curPtr = lastAddr + declarations[lastAddr]->size; - - while (curPtr % 4 != 0) - { - declarations[lastAddr]->size++; - curPtr++; - } - - while (curPtr % 8 != 0) - { - char buffer[2048]; - - sprintf(buffer, "u32 %s_align%02zX = 0;\n", name.c_str(), curPtr); - item.second->preText = buffer + item.second->preText; - - declarations[lastAddr]->size += 4; - curPtr += 4; - } - } - } - - lastAddr = item.first; } HandleUnaccountedData(); @@ -1199,14 +1160,15 @@ void ZFile::HandleUnaccountedData() { uint32_t lastAddr = 0; uint32_t lastSize = 0; - std::vector declsAddresses; + std::vector declsAddresses; + for (const auto& item : declarations) { declsAddresses.push_back(item.first); } bool breakLoop = false; - for (uint32_t currentAddress : declsAddresses) + for (offset_t currentAddress : declsAddresses) { if (currentAddress >= rangeEnd) { @@ -1235,7 +1197,7 @@ void ZFile::HandleUnaccountedData() } } -bool ZFile::HandleUnaccountedAddress(uint32_t currentAddress, uint32_t lastAddr, uint32_t& lastSize) +bool ZFile::HandleUnaccountedAddress(offset_t currentAddress, offset_t lastAddr, uint32_t& lastSize) { if (currentAddress != lastAddr && declarations.find(lastAddr) != declarations.end()) { @@ -1275,6 +1237,29 @@ bool ZFile::HandleUnaccountedAddress(uint32_t currentAddress, uint32_t lastAddr, xmlFilePath.c_str(), currentAddress, name.c_str(), rawData.size())); } + // Handle Align8 + if (currentAddress % 8 == 0 && diff % 8 != 0) + { + Declaration* currentDecl = GetDeclaration(currentAddress); + + if (currentDecl != nullptr) + { + if (currentDecl->alignment == DeclarationAlignment::Align8) + { + // Check removed bytes are zeroes + if (BitConverter::ToUInt32BE(rawData, unaccountedAddress + diff - 4) == 0) + { + diff -= 4; + } + } + + if (diff == 0) + { + return false; + } + } + } + for (int i = 0; i < diff; i++) { uint8_t val = rawData.at(unaccountedAddress + i); @@ -1320,7 +1305,10 @@ bool ZFile::HandleUnaccountedAddress(uint32_t currentAddress, uint32_t lastAddr, StringHelper::Sprintf("%s_%s_%06X", name.c_str(), unaccountedPrefix.c_str(), unaccountedAddress), diff, src); + decl->isUnaccounted = true; + if (Globals::Instance->forceUnaccountedStatic) + decl->staticConf = StaticConfig::On; if (nonZeroUnaccounted) { diff --git a/tools/ZAPD/ZAPD/ZFile.h b/tools/ZAPD/ZAPD/ZFile.h index 7918d5f595..ac4062d5b1 100644 --- a/tools/ZAPD/ZAPD/ZFile.h +++ b/tools/ZAPD/ZAPD/ZFile.h @@ -133,5 +133,5 @@ protected: std::string ProcessTextureIntersections(const std::string& prefix); void HandleUnaccountedData(); - bool HandleUnaccountedAddress(uint32_t currentAddress, uint32_t lastAddr, uint32_t& lastSize); + bool HandleUnaccountedAddress(offset_t currentAddress, offset_t lastAddr, uint32_t& lastSize); }; diff --git a/tools/ZAPD/ZAPD/ZLimb.cpp b/tools/ZAPD/ZAPD/ZLimb.cpp index a47615d6c6..330fbaf7ce 100644 --- a/tools/ZAPD/ZAPD/ZLimb.cpp +++ b/tools/ZAPD/ZAPD/ZLimb.cpp @@ -228,8 +228,8 @@ std::string ZLimb::GetBodySourceCode() const { std::string childName; std::string siblingName; - Globals::Instance->GetSegmentedPtrName(childPtr, parent, "Gfx", childName); - Globals::Instance->GetSegmentedPtrName(siblingPtr, parent, "Gfx", siblingName); + Globals::Instance->GetSegmentedPtrName(childPtr, parent, "LegacyLimb", childName); + Globals::Instance->GetSegmentedPtrName(siblingPtr, parent, "LegacyLimb", siblingName); entryStr += StringHelper::Sprintf("%s,\n", dListStr.c_str()); entryStr += diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp index 69668c49c1..ba0bbe2c24 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp @@ -152,7 +152,6 @@ void PolygonDlist::GetSourceOutputCode(const std::string& prefix) DeclareVar(prefix, bodyStr); else decl->text = bodyStr; - } std::string PolygonDlist::GetSourceTypeName() const diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp index 0c24a2f328..696a3de014 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetSpecialObjects.cpp @@ -1,6 +1,8 @@ #include "SetSpecialObjects.h" + #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" +#include "ZRoom/ZNames.h" SetSpecialObjects::SetSpecialObjects(ZFile* nParent) : ZRoomCommand(nParent) { @@ -15,8 +17,10 @@ void SetSpecialObjects::ParseRawData() std::string SetSpecialObjects::GetBodySourceCode() const { - return StringHelper::Sprintf("SCENE_CMD_SPECIAL_FILES(0x%02X, 0x%04X)", elfMessage, - globalObject); + std::string objectName = ZNames::GetObjectName(globalObject); + + return StringHelper::Sprintf("SCENE_CMD_SPECIAL_FILES(0x%02X, %s)", elfMessage, + objectName.c_str()); } std::string SetSpecialObjects::GetCommandCName() const diff --git a/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp b/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp index d47a2e75cb..5831eaa56b 100644 --- a/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/ZRoom.cpp @@ -261,7 +261,8 @@ void ZRoom::ParseRawData() if (Globals::Instance->profile) { auto end = std::chrono::steady_clock::now(); - int64_t diff = std::chrono::duration_cast(end - start).count(); + int64_t diff = + std::chrono::duration_cast(end - start).count(); if (diff > 50) printf("OP: %s, TIME: %" PRIi64 "ms\n", cmd->GetCommandCName().c_str(), diff); } diff --git a/tools/ZAPD/ZAPD/ZSkeleton.cpp b/tools/ZAPD/ZAPD/ZSkeleton.cpp index 1a2f93ff7b..4467c96320 100644 --- a/tools/ZAPD/ZAPD/ZSkeleton.cpp +++ b/tools/ZAPD/ZAPD/ZSkeleton.cpp @@ -139,7 +139,7 @@ ZResourceType ZSkeleton::GetResourceType() const DeclarationAlignment ZSkeleton::GetDeclarationAlignment() const { - return DeclarationAlignment::Align16; + return DeclarationAlignment::Align4; } uint8_t ZSkeleton::GetLimbCount() diff --git a/tools/ZAPD/ZAPD/ZVtx.cpp b/tools/ZAPD/ZAPD/ZVtx.cpp index d5214e840a..e4b3d97968 100644 --- a/tools/ZAPD/ZAPD/ZVtx.cpp +++ b/tools/ZAPD/ZAPD/ZVtx.cpp @@ -82,5 +82,5 @@ std::string ZVtx::GetExternalExtension() const DeclarationAlignment ZVtx::GetDeclarationAlignment() const { - return DeclarationAlignment::Align16; + return DeclarationAlignment::Align8; } diff --git a/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h b/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h index 0b0d676429..6c9e541190 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h +++ b/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h @@ -109,6 +109,6 @@ public: static bool IEquals(const std::string& a, const std::string& b) { return std::equal(a.begin(), a.end(), b.begin(), b.end(), - [](char a, char b) { return tolower(a) == tolower(b); }); + [](char a, char b) { return tolower(a) == tolower(b); }); } }; diff --git a/tools/ZAPDConfigs/MM/Config.xml b/tools/ZAPDConfigs/MM/Config.xml index 6570400107..02656c7df7 100644 --- a/tools/ZAPDConfigs/MM/Config.xml +++ b/tools/ZAPDConfigs/MM/Config.xml @@ -4,10 +4,5 @@ - - diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 428c6dee5b..fc26e60e00 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -51,13 +51,43 @@ animdict = { "func_8012404c": "Player_RemoveMask", "Actor_SpawnWithParentAndCutscene": "Actor_SpawnAsChildAndCutscene", "Actor_SpawnWithParent": "Actor_SpawnAsChild", + "Actor_IsLinkFacingActor": "Player_IsFacingActor", + "Actor_IsActorFacingLink": "Actor_IsFacingPlayer", + "Actor_IsActorFacingLinkAndWithinRange": "Actor_IsFacingAndNearPlayer", + "Actor_IsActorFacingActorAndWithinRange": "Actor_ActorAIsFacingAndNearActorB", + "Actor_IsActorFacingActor": "Actor_ActorAIsFacingActorB", + "Actor_IsActorFacedByActor": "Actor_ActorBIsFacingActorA", + "func_800B84D0": "Actor_ProcessTalkRequest", + "func_8017D668": "Math3D_PointDistToLine2D", + "func_800BDFC0": "Gfx_DrawDListOpa", + "func_800BE03C": "Gfx_DrawDListXlu", + "func_800B6FC8": "Player_GetHeight", + "Actor_InitCurrPosition": "Actor_SetWorldToHome", + "Actor_SetHeight": "Actor_SetFocus", + "Actor_SetRotationFromDrawRotation": "Actor_SetWorldRotToShape", + "Actor_InitDrawRotation": "Actor_SetShapeRotToWorld", + "Actor_CalcOffsetOrientedToDrawRotation": "Actor_OffsetOfPointInActorCoords", + "Actor_ApplyMovement": "Actor_UpdatePos", + "Actor_SetVelocityYRotationAndGravity": "Actor_UpdateVelocityWithGravity", + "Actor_SetVelocityAndMoveYRotationAndGravity": "Actor_MoveWithGravity", + "Actor_SetVelocityXYRotation": "Actor_UpdateVelocityWithoutGravity", + "Actor_SetVelocityAndMoveXYRotation": "Actor_MoveWithoutGravity", + "Actor_SetVelocityXYRotationReverse": "Actor_UpdateVelocityWithoutGravityReverse", + "Actor_SetVelocityAndMoveXYRotationReverse": "Actor_MoveWithoutGravityReverse", + "func_800B6C04": "Actor_SetSpeeds", + "func_800B81E0": "Actor_GetFocus", + "func_800B8214": "Actor_GetWorld", + "func_800B8248": "Actor_GetWorldPosShapeRot", "func_800BE22C": "Actor_ApplyDamage", - "func_800F0568": "Audio_PlaySoundAtPosition", + "Audio_PlaySoundAtPosition": "SoundSource_PlaySfxAtFixedWorldPos", + "func_800F0590": "SoundSource_PlaySfxEachFrameAtFixedWorldPos", "func_8016970C": "Play_CameraSetAtEye", "func_800BBA88": "Enemy_StartFinishingBlow", "ShrinkWindow_Step": "ShrinkWindow_Update", "ShrinkWindow_Fini": "ShrinkWindow_Destroy", "func_801A89A8": "Audio_QueueSeqCmd", + "func_8019F1C0": "Audio_PlaySfxAtPos", + "func_801A72CC": "Audio_StopSfxByPos", "SkelAnime_LodDrawLimb(": "SkelAnime_DrawLimbLod(", "SkelAnime_LodDraw(": "SkelAnime_DrawLod(", "SkelAnime_LodDrawLimbSV(": "SkelAnime_DrawFlexLimbLod(", @@ -144,6 +174,53 @@ animdict = { "SkelAnime_CopyVec3s": "SkelAnime_CopyFrameTable", "SysMatrix_StatePop": "Matrix_StatePop", "SysMatrix_GetCurrentState": "Matrix_GetCurrentState", + "Actor_SetObjectSegment": "Actor_SetObjectDependency", + "func_800B3FC0": "ActorShadow_DrawCircle", + "func_800B4024": "ActorShadow_DrawSquare", + "func_800B4088": "ActorShadow_DrawWhiteCircle", + "func_800B40B8": "ActorShadow_DrawHorse", + "func_800B40E0": "ActorShadow_DrawFoot", + "func_800B42F8": "ActorShadow_DrawFeet", + "func_800B4A98": "Actor_SetFeetPos", + "Actor_SetSwitchFlag": "Flags_SetSwitch", + "Actor_UnsetSwitchFlag": "Flags_UnsetSwitch", + "Actor_GetChestFlag": "Flags_GetTreasure", + "Actor_SetChestFlag": "Flags_SetTreasure", + "Actor_SetAllChestFlag": "Flags_SetAllTreasure", + "Actor_GetAllChestFlag": "Flags_GetAllTreasure", + "Actor_GetRoomCleared(": "Flags_GetClear(", + "Actor_SetRoomCleared(": "Flags_SetClear(", + "Actor_UnsetRoomCleared(": "Flags_UnsetClear(", + "Actor_GetRoomClearedTemp(": "Flags_GetClearTemp(", + "Actor_SetRoomClearedTemp(": "Flags_SetClearTemp(", + "Actor_UnsetRoomClearedTemp(": "Flags_UnsetTempClear(", + "Actor_GetCollectibleFlag": "Flags_GetCollectible", + "Actor_SetCollectibleFlag": "Flags_SetCollectible", + "func_800B8A1C": "Actor_PickUp", + "func_800B8B84": "Actor_PickUpNearby", + "func_800B8BB0": "Actor_LiftActor", + "func_800B8BD0": "Actor_PickUpFar", + "func_801A5CFC": "Audio_PlaySfxGeneral", + "func_800BBDAC": "Actor_SpawnFloorDustRing", + "func_800B8708": "Player_GetExchangeItemId", + "func_801233E4": "Player_InCsMode", + "func_800BC4EC": "Actor_TestFloorInDirection", + "func_800BC5B8": "Actor_IsTargeted", + "func_800BC5EC": "Actor_OtherIsTargeted", + "func_800BCB70": "Actor_SetColorFilter", + "func_800BE0B8": "Actor_FindNearby", + "func_800BE258": "Actor_SetDropFlag", + "func_800BE2B8": "Actor_SetDropFlagJntSph", + "Actor_TitleCardCreate": "TitleCard_InitBossName", + "func_800B867C": "Actor_TextboxIsClosing", + "func_800BDC5C": "Actor_ChangeAnimation", + "func_80152498": "Message_GetState", + "func_800B8898": "Actor_GetScreenPos", + "Audio_PlayActorSound2": "Actor_PlaySfxAtPos", + "func_800BF7CC": "Actor_SpawnIceEffects", + "Actor_IsFacingPlayerAndWithinRange": "Actor_IsFacingAndNearPlayer", + "func_800BC8B8": "Actor_DrawDoorLock", + "func_800B86C8": "Actor_ChangeFocus", "zelda_malloc(": "ZeldaArena_Malloc(", "zelda_mallocR(": "ZeldaArena_MallocR(", "zelda_realloc": "ZeldaArena_Realloc", @@ -301,25 +378,15 @@ animdict = { "func_8017F9C0": "Math3D_XZInSphere", "func_8017FA34": "Math3D_XYInSphere", "func_8017FAA8": "Math3D_YZInSphere", + "func_8013A7C0": "SubS_FindDoor", + "func_8013E640": "SubS_FindActorCustom", + "func_ActorCategoryIterateById": "SubS_FindActor", + "func_8013BB7C": "SubS_FindNearestActor", + "func_800A81F0": "EffectBlure_AddVertex", + "func_800A8514": "EffectBlure_AddSpace", + "Effect_GetParams": "Effect_GetByIndex", - - "skelanime.unk03": "skelanime.taper", - "skelanime.animCurrentSeg": "skelanime.animation", - "skelanime.initialFrame": "skelanime.startFrame", - "skelanime.animFrameCount": "skelanime.endFrame", - "skelanime.totalFrames": "skelanime.animLength", - "skelanime.animCurrentFrame": "skelanime.curFrame", - "skelanime.animPlaybackSpeed": "skelanime.playSpeed", - "skelanime.limbDrawTbl": "skelanime.jointTable", - "skelanime.transitionDrawTbl": "skelanime.morphTable", - "skelanime.transCurrentFrame": "skelanime.morphWeight", - "skelanime.transitionStep": "skelanime.morphRate", - "skelanime.animUpdate": "skelanime.update", - "skelanime.flags": "skelanime.moveFlags", - "skelanime.prevFrameRot": "skelanime.prevRot", - "skelanime.prevFramePos": "skelanime.prevTransl", - "skelanime.unk3E": "skelanime.baseTransl", - + # Structs members "skelAnime.unk03": "skelAnime.taper", "skelAnime.animCurrentSeg": "skelAnime.animation", "skelAnime.initialFrame": "skelAnime.startFrame", @@ -336,11 +403,30 @@ animdict = { "skelAnime.prevFrameRot": "skelAnime.prevRot", "skelAnime.prevFramePos": "skelAnime.prevTransl", "skelAnime.unk3E": "skelAnime.baseTransl", + "actor.minVelocityY": "actor.terminalVelocity", "actor.yDistToWater" : "actor.depthInWater", - "actor.yDistToPlayer" : "actor.playerHeightRel", - + "actor.yDistToPlayer": "actor.playerHeightRel", "globalCtx->mf_187FC" : "globalCtx->billboardMtxF", "globalCtx->projectionMatrix" : "globalCtx->viewProjectionMtxF", + "player->unk_A87": "player->exchangeItemId", + "player->leftHandActor": "player->heldActor", + "player->unk_384": "player->getItemId", + "player->unk_386": "player->getItemDirection", + "player->unk_388": "player->interactRangeActor", + "player->unk_38C": "player->mountSide", + "player->unk_394": "player->csMode", + "player->unk_A87": "player->exchangeItemId", + "globalCtx->actorCtx.actorList[": "globalCtx->actorCtx.actorLists[", + + # Variables + "D_0407D590": "gGameplayKeepDrawFlameDL", + "D_801D15B0": "gZeroVec3f", + "D_801D15BC": "gZeroVec3s", + "D_801D1DE0": "gIdentityMtx", + "D_801D1E20": "gIdentityMtxF", + + "ICHAIN_F32_DIV1000(minVelocityY,": "ICHAIN_F32_DIV1000(terminalVelocity,", + "ICHAIN_F32(minVelocityY,": "ICHAIN_F32(terminalVelocity,", } def replace_anim(file): diff --git a/tools/disasm/disasm.py b/tools/disasm/disasm.py index 5f8aae37d9..e0b7705ea0 100755 --- a/tools/disasm/disasm.py +++ b/tools/disasm/disasm.py @@ -3,10 +3,21 @@ import argparse, ast, math, os, re, struct import bisect from mips_isa import * -from multiprocessing import Pool +from multiprocessing import * +from pathlib import Path parser = argparse.ArgumentParser() -parser.add_argument('-j', dest='jobs', type=int, default=1, help='number of processes to run at once') +parser.add_argument( + "-j", dest="jobs", type=int, default=1, help="number of processes to run at once" +) +parser.add_argument( + "--full", + "-f", + dest="full", + action="store_true", + default=False, + help="Decompile all files regardless of whether they are used or not", +) args = parser.parse_args() jobs = args.jobs @@ -14,127 +25,242 @@ jobs = args.jobs ASM_OUT = "asm/" DATA_OUT = "data/" + +def discard_decomped_files(files_spec): + root_path = Path(__file__).parent.parent.parent + + with open(root_path / "spec", "r") as f: + spec = f.read() + # No need to check anything beyond here + spec = spec[: spec.find('name "gameplay_keep"')].splitlines()[:-2] + + new_spec = [] + for f in files_spec: + name, _, type, _, file_list = f + + # Find the beginseg for this file + i = 0 + while i < len(spec): + if spec[i].startswith("beginseg") and f'"{name}"' in spec[i + 1]: + break + i += 1 + + # For every file within this segment, look through the seg for lines with this file's name + # if found, check whether it's still in build/asm/ or build/data/, in which case it's not decomped + # if all references to it are in build/src/ then it should be ok to skip, some code/boot files are a bit different + + seg_start = i + new_files = {} + included = False + saved_off = 0 + for offset, file in file_list.items(): + if file == "[PADDING]": + continue + + # some files aren't named + if file == "": + file = f"{type}_{offset:08X}" + include = True + # flg_set_table is not in the spec, and buffers has its own section, just add them + elif file == "flg_set_table" or "buffers" in file: + include = True + else: + include = False + i = seg_start + last_line = "" + while not spec[i].startswith("endseg"): + if f"/{file}." in spec[i]: + if spec[i].count(".") == 1: + last_line = spec[i] + if "build/asm/" in spec[i] or "build/data/" in spec[i]: + include = True + break + i += 1 + else: + # Many code/boot files only have a single section (i.e .text) + # In that case it will be inside build/src/ and pragma in the asm + # For these files, open the source and look for the pragmas to be sure + # Overlays always have at least a data section we can check in the spec, so it's not needed for them + if type != "overlay" and last_line != "": + assert last_line.count(".") == 1 + last_line = ( + last_line.strip() + .split("build/", 1)[1] + .replace(".o", ".c")[:-1] + ) + with open(root_path / last_line, "r") as f2: + if "GLOBAL_ASM" in f2.read(): + include = True + + if include: + new_files[offset] = file + included = True + + if type == "overlay" and not included: + continue + if included: + f[4] = new_files + + new_spec.append(f) + + return new_spec + + MIPS_BRANCH_LIKELY_INSNS = [ - MIPS_INS_BEQL, MIPS_INS_BGEZALL, - MIPS_INS_BGEZL, MIPS_INS_BGTZL, - MIPS_INS_BLEZL, MIPS_INS_BLTZALL, - MIPS_INS_BLTZL, MIPS_INS_BNEL, - MIPS_INS_BC1TL, MIPS_INS_BC1FL, + MIPS_INS_BEQL, + MIPS_INS_BGEZALL, + MIPS_INS_BGEZL, + MIPS_INS_BGTZL, + MIPS_INS_BLEZL, + MIPS_INS_BLTZALL, + MIPS_INS_BLTZL, + MIPS_INS_BNEL, + MIPS_INS_BC1TL, + MIPS_INS_BC1FL, ] MIPS_BRANCH_INSNS = [ *MIPS_BRANCH_LIKELY_INSNS, MIPS_INS_BEQ, - MIPS_INS_BGEZ, MIPS_INS_BGEZAL, + MIPS_INS_BGEZ, + MIPS_INS_BGEZAL, MIPS_INS_BGTZ, MIPS_INS_BNE, - MIPS_INS_BLTZ, MIPS_INS_BLTZAL, + MIPS_INS_BLTZ, + MIPS_INS_BLTZAL, MIPS_INS_BLEZ, - MIPS_INS_BC1T, MIPS_INS_BC1F, - + MIPS_INS_BC1T, + MIPS_INS_BC1F, MIPS_INS_BEQZ, MIPS_INS_BNEZ, MIPS_INS_B, ] -MIPS_JUMP_INSNS = [ - MIPS_INS_JAL, MIPS_INS_JALR, MIPS_INS_J, MIPS_INS_JR -] +MIPS_JUMP_INSNS = [MIPS_INS_JAL, MIPS_INS_JALR, MIPS_INS_J, MIPS_INS_JR] -MIPS_FP_LOAD_INSNS = [ - MIPS_INS_LWC1, MIPS_INS_LDC1 -] +MIPS_FP_LOAD_INSNS = [MIPS_INS_LWC1, MIPS_INS_LDC1] -MIPS_FP_STORE_INSNS = [ - MIPS_INS_SWC1, MIPS_INS_SDC1 -] +MIPS_FP_STORE_INSNS = [MIPS_INS_SWC1, MIPS_INS_SDC1] -MIPS_FP_LOAD_STORE_INSNS = [ - *MIPS_FP_LOAD_INSNS, *MIPS_FP_STORE_INSNS -] +MIPS_FP_LOAD_STORE_INSNS = [*MIPS_FP_LOAD_INSNS, *MIPS_FP_STORE_INSNS] MIPS_STORE_INSNS = [ - MIPS_INS_SB, - MIPS_INS_SH, - MIPS_INS_SW, MIPS_INS_SWL, MIPS_INS_SWR, - MIPS_INS_SD, MIPS_INS_SDL, MIPS_INS_SDR, - MIPS_INS_SC, MIPS_INS_SCD, - *MIPS_FP_STORE_INSNS + MIPS_INS_SB, + MIPS_INS_SH, + MIPS_INS_SW, + MIPS_INS_SWL, + MIPS_INS_SWR, + MIPS_INS_SD, + MIPS_INS_SDL, + MIPS_INS_SDR, + MIPS_INS_SC, + MIPS_INS_SCD, + *MIPS_FP_STORE_INSNS, ] MIPS_LOAD_STORE_INSNS = [ - MIPS_INS_LB, MIPS_INS_LBU, - MIPS_INS_LH, MIPS_INS_LHU, - MIPS_INS_LW, MIPS_INS_LWL, MIPS_INS_LWR, MIPS_INS_LWU, - MIPS_INS_LD, MIPS_INS_LDL, MIPS_INS_LDR, - MIPS_INS_LL, MIPS_INS_LLD, + MIPS_INS_LB, + MIPS_INS_LBU, + MIPS_INS_LH, + MIPS_INS_LHU, + MIPS_INS_LW, + MIPS_INS_LWL, + MIPS_INS_LWR, + MIPS_INS_LWU, + MIPS_INS_LD, + MIPS_INS_LDL, + MIPS_INS_LDR, + MIPS_INS_LL, + MIPS_INS_LLD, *MIPS_STORE_INSNS, - *MIPS_FP_LOAD_STORE_INSNS + *MIPS_FP_LOAD_STORE_INSNS, ] -functions = set() # vram of functions -data_labels = set() # vram of data labels, TODO this + functions can merge into something more general eventually +VRAM_BASE = { + "code": {"data": 0x801AAAB0, "rodata": 0x801DBDF0, "bss": 0x801E3FA0}, + "boot": {"data": 0x800969C0, "rodata": 0x80098190, "bss": 0x80099500}, +} +functions = set() # vram of functions +# vram of data labels, TODO this + functions can merge into something more general eventually +data_labels = set() branch_labels = set() # vram of branch labels via branch/jump instructions -jtbls = set() # vram of jump tables -jtbl_labels = set() # vram of branch labels via jtbls, higher output priority than regular branch labels -floats = set() # vram of floats -doubles = set() # vram of doubles -prospective_strings = set() # vram of possible strings -strings = set() # vram of confirmed strings -symbols = {} # lui/addiu pairs : {addr of %hi : full symbol} AND {addr of %lo : full symbol} , twice the space complexity but much less time complexity -constants = {} # lui/ori pairs : {addr of %hi : full constant} AND {addr of %lo : full constant} , twice the space complexity but much less time complexity -dwords = set() # doublewords -multiply_referenced_rodata = set() # rodata with more than 1 reference outside of the same function cannot be migrated +jtbls = set() # vram of jump tables +# vram of branch labels via jtbls, higher output priority than regular branch labels +jtbl_labels = set() +floats = set() # vram of floats +doubles = set() # vram of doubles +prospective_strings = set() # vram of possible strings +strings = set() # vram of confirmed strings +# lui/addiu pairs : {addr of %hi : full symbol} AND {addr of %lo : full symbol} , +# twice the space complexity but much less time complexity +symbols = {} +# lui/ori pairs : {addr of %hi : full constant} AND {addr of %lo : full constant} , +# twice the space complexity but much less time complexity +constants = {} +dwords = set() # doublewords +# rodata with more than 1 reference outside of the same function cannot be migrated +multiply_referenced_rodata = set() +files = set() # vram start of file -files = set() # vram start of file - -vrom_variables = list() # (name,addr) -vrom_addrs = set() # set of addrs from vrom_variables, for faster lookup +vrom_variables = list() # (name,addr) +vrom_addrs = set() # set of addrs from vrom_variables, for faster lookup functions_ast = None variables_ast = None variable_addrs = None +files_text = {} + + def proper_name(symbol, in_data=False, is_symbol=True): # hacks - if symbol == 0x809C46F0: # ovl_En_Encount4 fake symbol at the very end of the data section + # ovl_En_Encount4 fake symbol at the very end of the data section + if symbol == 0x809C46F0: return variables_ast[0x809C46DC][0] + " + 0x14" - elif symbol == 0x801EF66D: # z_message_nes constant-folding stray fairy array + elif symbol == 0x801EF66D: # z_message_nes constant-folding stray fairy array return variables_ast[0x801EF670][0] + f" - 0x{0x801EF670 - 0x801EF66D:X}" - elif symbol == 0x80A09740: # boss_07 symbol with large addend folded into %lo + elif symbol == 0x80A09740: # boss_07 symbol with large addend folded into %lo return variables_ast[0x80A09A60][0] + f" - 0x{0x80A09A60 - 0x80A09740:X}" - elif symbol == 0x80B80248: # bg_ikana_mirror symbol with large addend folded into %lo + # bg_ikana_mirror symbol with large addend folded into %lo + elif symbol == 0x80B80248: return variables_ast[0x80B801A8][0] + f" + 0x{0x80B80248 - 0x80B801A8:X}" - elif symbol == 0x8084D2FC: # player symbol with very large addend folded into %lo, since we don't know the real symbol just use the first data symbol for now + # player symbol with very large addend folded into %lo, since we don't know the real symbol just use the first data symbol for now + elif symbol == 0x8084D2FC: return variables_ast[0x8085B9F0][0] + f" - 0x{0x8085B9F0 - 0x8084D2FC:X}" - elif symbol == 0x001ABAB0 or symbol == 0x001E3BB0: # OS_K0_TO_PHYSICAL on rspS2DEX text and data symbols + # OS_K0_TO_PHYSICAL on rspS2DEX text and data symbols + elif symbol == 0x001ABAB0 or symbol == 0x001E3BB0: return variables_ast[symbol + 0x80000000][0] + " - 0x80000000" - elif symbol == 0x00AC0480: # do_action_static + 0x480, this is the only rom segment that has a constant offset folded into it so just hack it + # do_action_static + 0x480, this is the only rom segment that has a constant offset folded into it so just hack it + elif symbol == 0x00AC0480: return "_do_action_staticSegmentRomStart + 0x480" # real names - if symbol in functions and symbol in functions_ast.keys(): + if symbol in functions_ast.keys(): return functions_ast[symbol][0] elif symbol in variables_ast.keys(): return variables_ast[symbol][0] elif symbol in vrom_addrs: # prefer "start" vrom symbols - if symbol in [addr for name,addr in vrom_variables if "SegmentRomStart" in name]: - return [name for name,addr in vrom_variables if "SegmentRomStart" in name and addr == symbol][0] + filteredVromSymbols = { + addr: name + for name, addr in vrom_variables + if "SegmentRomStart" in name and addr == symbol + } + if symbol in filteredVromSymbols: + return filteredVromSymbols[symbol] else: - return [name for name,addr in vrom_variables if addr == symbol][0] + return [name for name, addr in vrom_variables if addr == symbol][0] # addends if is_symbol: symbol_index = bisect.bisect(variable_addrs, symbol) if symbol_index: - vram_addr = variable_addrs[symbol_index-1] + vram_addr = variable_addrs[symbol_index - 1] symbol_name, _, _, symbol_size = variables_ast[vram_addr] if vram_addr < symbol < vram_addr + symbol_size: return f"{symbol_name} + 0x{symbol-vram_addr:X}" - # generated names if symbol in functions and not in_data: return f"func_{symbol:08X}" @@ -148,63 +274,77 @@ def proper_name(symbol, in_data=False, is_symbol=True): else: return f"0x{symbol:08X}" + def lookup_name(symbol, word): # hacks for vrom variables in data if word in vrom_addrs: - if word == 0: # no makerom segment start + if word == 0: # no makerom segment start return "0x00000000" - if symbol in [0x801AE4A0, # effect table - 0x801C2740, # object table - 0x801C2650, # elf_message table - 0x801C3CA0, # scene table - 0x801AEFD0, # actor table - 0x801D0B70, # kaleido table - 0x801D0BB0, # fbdemo table - 0x801BE4D4, # kankyo skybox table - 0x801BD910, # gamestate table - 0x801C2660 # scene textures table - ]: # data labels that are allowed to have vrom variables + if symbol in [ + 0x801AE4A0, # effect table + 0x801C2740, # object table + 0x801C2650, # elf_message table + 0x801C3CA0, # scene table + 0x801AEFD0, # actor table + 0x801D0B70, # kaleido table + 0x801D0BB0, # fbdemo table + 0x801BE4D4, # kankyo skybox table + 0x801BD910, # gamestate table + 0x801C2660, # scene textures table + ]: # data labels that are allowed to have vrom variables return proper_name(word, is_symbol=False) else: return f"0x{word:08X}" # hacks for variables with references to variables with addends (i.e. gSaveContext + 0x...) - if symbol in [0x800980C4, 0x801AE8F0]: # __osViNext and flg_set table + if symbol in [0x800980C4, 0x801AE8F0]: # __osViNext and flg_set table return proper_name(word, is_symbol=True) return proper_name(word, is_symbol=False) + def as_double(b): return struct.unpack(">d", b)[0] + def as_float(b): return struct.unpack(">f", b)[0] + def as_dword(b): return struct.unpack(">Q", b)[0] + def as_word(b): return struct.unpack(">I", b)[0] + def as_hword(b): return struct.unpack(">H", b)[0] + def as_double_list(b): return [i[0] for i in struct.iter_unpack(">d", b)] + def as_float_list(b): return [i[0] for i in struct.iter_unpack(">f", b)] + def as_dword_list(b): return [i[0] for i in struct.iter_unpack(">Q", b)] + def as_word_list(b): return [i[0] for i in struct.iter_unpack(">I", b)] + def as_hword_list(b): return [h[0] for h in struct.iter_unpack(">H", b)] + STR_INDENT = " " -def try_decode_string(data_bytes, output_ends = True, force_ascii = False): + +def try_decode_string(data_bytes, output_ends=True, force_ascii=False): """ Swiss Cheese """ @@ -225,20 +365,49 @@ def try_decode_string(data_bytes, output_ends = True, force_ascii = False): char = "\\x1B" index = data_bytes.index(0x1B) else: - assert False , "???" + assert False, "???" part1 = try_decode_string(data_bytes[0:index], output_ends=False) - part2 = try_decode_string(data_bytes[index+1:], output_ends=False) + part2 = try_decode_string(data_bytes[index + 1 :], output_ends=False) if part2 != "": - result = part1 + (("\"\n" + STR_INDENT + ".ascii \"") if part2[0] in hex_digits and part1 != "" else "") + \ - char + (("\"\n" + STR_INDENT + ".asciz \"") if part2[0] in hex_digits else "") + part2 + result = ( + part1 + + ( + ('"\n' + STR_INDENT + '.ascii "') + if part2[0] in hex_digits and part1 != "" + else "" + ) + + char + + (('"\n' + STR_INDENT + '.asciz "') if part2[0] in hex_digits else "") + + part2 + ) if output_ends and part2[0] in hex_digits and part1 == "": directive = "ascii" else: - result = part1 + (("\"\n" + STR_INDENT + ".ascii \"") if part2[0] in hex_digits and part1 != "" else "") + char + "\"\n" + result = ( + part1 + + ( + ('"\n' + STR_INDENT + '.ascii "') + if part2[0] in hex_digits and part1 != "" + else "" + ) + + char + + '"\n' + ) else: - result = data_bytes.decode("EUC-JP").replace("\n", "\\n").replace("\r", "\\r").replace("\t", "\\t").replace("\0", "") + result = ( + data_bytes.decode("EUC-JP") + .replace("\n", "\\n") + .replace("\r", "\\r") + .replace("\t", "\\t") + .replace("\0", "") + ) + + return ( + (("." + directive + ' "') if output_ends else "") + + result + + ('"' if output_ends else "") + ) - return (("." + directive + " \"") if output_ends else "") + result + ("\"" if output_ends else "") def reduce_float(flt_str, is_double=False): def n_digits(str): @@ -249,8 +418,8 @@ def reduce_float(flt_str, is_double=False): def str_round(string, precision): if "." not in string or precision < 0: return string - int_part = string.split(".")[0] - frac_part = string.split(".")[1] + int_part = string.split(".")[0] + frac_part = string.split(".")[1] while len(frac_part) > precision: last_digit = int(frac_part[-1]) @@ -271,7 +440,9 @@ def reduce_float(flt_str, is_double=False): return int_part + "." + frac_part def to_binary(flt_str): - return as_dword(struct.pack(">d", float(flt_str))) if is_double else as_word(struct.pack(">f", float(flt_str))) + if is_double: + return as_dword(struct.pack(">d", float(flt_str))) + return as_word(struct.pack(">f", float(flt_str))) exponent = "" if "e" in flt_str: @@ -300,18 +471,20 @@ def reduce_float(flt_str, is_double=False): return flt_str + exponent + def format_f64(d_dwd): d = as_double(struct.pack(">Q", d_dwd)) if math.isnan(d): return f".long 0x{d_dwd:016X}" return f".double {reduce_float(repr(d), is_double=True)}" + def format_f32(f_wd): # GNU AS isn't ieee compliant? if f_wd in [0xB8E4AECD, 0xB8E4C3AA, 0x38D1B718]: return f".word 0x{f_wd:08X}" - if f_wd == 0x7F7FFFFF: # FLT_MAX + if f_wd == 0x7F7FFFFF: # FLT_MAX return ".float 3.4028235e+38" f = as_float(struct.pack(">I", f_wd)) @@ -319,19 +492,30 @@ def format_f32(f_wd): return f".word 0x{f_wd:08X}" return f".float {reduce_float(repr(f))}" + def put_symbol(symbols_dict, setname, symbol): if setname in symbols_dict: symbols_dict[setname].add(symbol) else: symbols_dict[setname] = {symbol} + def put_symbols(symbols_dict, setname, symbols): if setname in symbols_dict: symbols_dict[setname].update(symbols) else: symbols_dict[setname] = symbols.copy() + +def put_text(name, text): + files_text[name] = text + + def update_symbols_from_dict(symbols_dict): + file_text = [] + if type(symbols_dict) == tuple: + symbols_dict, file_text = symbols_dict + for setname, symbol in symbols_dict.items(): if setname == "functions": functions.update(symbol) @@ -360,10 +544,18 @@ def update_symbols_from_dict(symbols_dict): elif setname == "files": files.update(symbol) -def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, segment_name): + for file in file_text: + put_text(file[0], file[1]) + + +def find_symbols_in_text(section, rodata_section, data_regions): + data, rodata = section[4], rodata_section[4] if rodata_section else None + vram, vram_rodata = section[0], rodata_section[0] if rodata_section else None + relocs, info = section[5], section[-1] + symbols_dict = dict() - print(f"Finding symbols from .text in {segment_name}") + print(f"Finding symbols from .text in {info['name']}") if rodata is not None: rodata_words = as_word_list(rodata) @@ -376,14 +568,15 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, put_symbol(symbols_dict, "files", vram) # lui trackers are saved at branches to be restored when the branch target is reached - saved_lui_trackers = {} # vram: tracker list + saved_lui_trackers = {} # vram: tracker list + def save_tracker(restore_at, tracker): if restore_at in saved_lui_trackers.keys(): saved_lui_trackers[restore_at].update(tracker) else: saved_lui_trackers.update({restore_at: tracker}) - lui_tracker = {} # register : (addr, immediate) + lui_tracker = {} # register : (addr, immediate) prospective_jtbls = set() @@ -391,7 +584,7 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, func_jtbl_labels = set() individual_jtbl_labels = {} - clobber_later = {} # addr : reg + clobber_later = {} # addr : reg delay_slot = False delayed_insn = None @@ -409,8 +602,14 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, # print(f"insn: {insn.mnemonic}, rt: {insn.rt}, first: {insn.value_forname(insn.fields[0])}") # assert insn.id not in [MIPS_INS_ORI, MIPS_INS_ADDIU, *MIPS_LOAD_STORE_INSNS] or insn.rt == insn.value_forname(insn.fields[0]) - if delay_slot and delayed_insn is not None and delayed_insn.id in MIPS_BRANCH_LIKELY_INSNS: - clobber_later.update({delayed_insn.offset : insn.value_forname(insn.fields[0])}) + if ( + delay_slot + and delayed_insn is not None + and delayed_insn.id in MIPS_BRANCH_LIKELY_INSNS + ): + clobber_later.update( + {delayed_insn.offset: insn.value_forname(insn.fields[0])} + ) else: lui_tracker.pop(insn.value_forname(insn.fields[0]), None) @@ -420,45 +619,9 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, if region[1] % 0x10 == 0: put_symbol(symbols_dict, "files", region[1]) - if relocs is not None: - """ - Relocation info is our friend. Get symbols via relocations first. - """ - prev_hi = None - hi_vram = -1 - for reloc in relocs: - insn = decode_insn(raw_insns[reloc[2]//4], vram + reloc[2]) - - if reloc[1] == 2: # R_MIPS_32 - assert False , "R_MIPS_32 in .text section?" - elif reloc[1] == 4: # R_MIPS_26 - """ - Relocated jump targets give us functions in this section - """ - assert insn.id == MIPS_INS_JAL , f"R_MIPS_26 applied to {insn.mnemonic} when it should be JAL" - put_symbol(symbols_dict, "functions", insn.target) - elif reloc[1] == 5: # R_MIPS_HI16 - """ - Relocated %hi gives us %hi values to match with associated %lo - """ - assert insn.id == MIPS_INS_LUI , f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be LUI" - prev_hi = insn.imm - hi_vram = vram + reloc[2] - elif reloc[1] == 6: # R_MIPS_LO16 - """ - Relocated %lo + a %hi to match with gives us relocated symbols in data sections - """ - assert insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS , f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be ADDIU or a load/store" - symbol_value = (prev_hi << 0x10) + insn.imm - put_symbols(symbols_dict, "symbols", {hi_vram : symbol_value}) - put_symbols(symbols_dict, "symbols", {vram + reloc[2] : symbol_value}) - else: - assert False , "Invalid relocation type encountered" - - for i,raw_insn in enumerate(raw_insns,0): - i *= 4 - vaddr = vram + i - insn = decode_insn(raw_insn, vaddr) + insns = [] + for i, raw_insn in enumerate(raw_insns, 0): + insn = decode_insn(raw_insn, vram + i * 4) if insn.id == MIPS_INS_JR and insn.rs != MIPS_REG_RA: # It's hard to find when two jump tables next to each other end, so do a naive first pass @@ -469,17 +632,72 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, # addu $at, $at, $reg # lw $reg, %lo(jtbl)($at) # jr $reg - insn_m1 = decode_insn(raw_insns[i//4 - 1], vaddr - 0x4) - insn_m2 = decode_insn(raw_insns[i//4 - 2], vaddr - 0x8) - insn_m3 = decode_insn(raw_insns[i//4 - 3], vaddr - 0xC) - - if insn_m1.id == MIPS_INS_LW and insn_m2.id == MIPS_INS_ADDU and insn_m3.id == MIPS_INS_LUI: + insn_m1 = insns[-1] + insn_m2 = insns[-2] + insn_m3 = insns[-3] + if ( + insn_m1.id == MIPS_INS_LW + and insn_m2.id == MIPS_INS_ADDU + and insn_m3.id == MIPS_INS_LUI + ): prospective_jtbls.add((insn_m3.imm << 0x10) + insn_m1.imm) + insns.append(insn) - for i,raw_insn in enumerate(raw_insns,0): - i *= 4 - vaddr = vram + i - insn = decode_insn(raw_insn, vaddr) + if relocs is not None: + """ + Relocation info is our friend. Get symbols via relocations first. + """ + prev_hi = None + hi_vram = -1 + for reloc in relocs: + insn = insns[reloc[2] // 4] + + if reloc[1] == 2: # R_MIPS_32 + assert False, "R_MIPS_32 in .text section?" + elif reloc[1] == 4: # R_MIPS_26 + """ + Relocated jump targets give us functions in this section + """ + assert ( + insn.id == MIPS_INS_JAL + ), f"R_MIPS_26 applied to {insn.mnemonic} when it should be JAL" + put_symbol(symbols_dict, "functions", insn.target) + elif reloc[1] == 5: # R_MIPS_HI16 + """ + Relocated %hi gives us %hi values to match with associated %lo + """ + assert ( + insn.id == MIPS_INS_LUI + ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be LUI" + prev_hi = insn.imm + hi_vram = vram + reloc[2] + elif reloc[1] == 6: # R_MIPS_LO16 + """ + Relocated %lo + a %hi to match with gives us relocated symbols in data sections + """ + assert ( + insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS + ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be ADDIU or a load/store" + symbol_value = (prev_hi << 0x10) + insn.imm + put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) + put_symbols(symbols_dict, "symbols", {vram + reloc[2]: symbol_value}) + else: + assert False, "Invalid relocation type encountered" + + result_files = [] + results = [asm_header(".text")] + raw_insns = as_word_list(data) + + cur_file = "" + cur_vaddr = 0 + + segment_dirname = ("" if info["type"] != "overlay" else "overlays/") + info["name"] + + delayed_insn = None + delay_slot = False + + for i, insn in enumerate(insns, 0): + vaddr = vram + i * 4 # sometimes there's data embedded in .text in handwritten asm files that don't respect section contents in_data = False @@ -488,6 +706,16 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, in_data = True break if in_data: + results.append( + { + "vaddr": vaddr, + "insn": {"id": insn.id}, + "addr": f"/* {i*4:06X} {vaddr:08X} {raw_insns[i]:08X} */ ", + "mnem": "", + "op": [f" .word 0x{raw_insns[i]:08X}"], + "data": True, + } + ) continue if vaddr in functions or vaddr in symbols_dict["functions"]: @@ -525,64 +753,99 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, func_branch_labels.add(insn.target) elif insn.id == MIPS_INS_JR: # check if anything branches past it in either branch or jtbl labels - if vaddr >= max(func_branch_labels, default=0) and vaddr >= max(func_jtbl_labels, default=0): # vaddr being largest in list means nothing branches past here + if vaddr >= max(func_branch_labels, default=0) and vaddr >= max( + func_jtbl_labels, default=0 + ): # vaddr being largest in list means nothing branches past here # mark next function after delay slot and after any nop padding if present - if len(raw_insns) > i//4 + 2: + if len(insns) > i + 2: n_padding = 0 end = False - while (raw_insns[i//4 + 2 + n_padding] == 0): + while raw_insns[i + 2 + n_padding] == 0: n_padding += 1 - if len(raw_insns) <= i//4 + 2 + n_padding: + if len(raw_insns) <= i + 2 + n_padding: end = True break if not end: if n_padding > 0: - assert (vaddr + 8 + n_padding * 4) % 0x10 == 0 , f"padding to non-0x10 alignment?, 0x{vaddr + 8 + n_padding * 4:08X}" - put_symbol(symbols_dict, "functions", vaddr + 8 + n_padding * 4) - put_symbol(symbols_dict, "functions", vaddr + 8 + n_padding * 4) + assert ( + vaddr + 8 + n_padding * 4 + ) % 0x10 == 0, f"padding to non-0x10 alignment?, 0x{vaddr + 8 + n_padding * 4:08X}" + put_symbol( + symbols_dict, "functions", vaddr + 8 + n_padding * 4 + ) + put_symbol( + symbols_dict, "functions", vaddr + 8 + n_padding * 4 + ) delayed_insn = insn elif insn.id == MIPS_INS_LUI: """ Process LUI instruction - + All symbol loading involves LUI, and tracking how %hi values loaded via LUI instructions propagate through a function is key to identifying symbol references """ # add lui to tracker - if delay_slot and delayed_insn is not None and delayed_insn.id in MIPS_BRANCH_LIKELY_INSNS: + if ( + delay_slot + and delayed_insn is not None + and delayed_insn.id in MIPS_BRANCH_LIKELY_INSNS + ): # for branch likelies, the current tracker does not update but the lui is saved to be tracked at the branch target - save_tracker(delayed_insn.offset, {insn.rt : (vaddr, insn.imm)}) + save_tracker(delayed_insn.offset, {insn.rt: (vaddr, insn.imm)}) else: - lui_tracker.update({insn.rt : (vaddr, insn.imm)}) + lui_tracker.update({insn.rt: (vaddr, insn.imm)}) elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: # try match with tracked lui and mark symbol - hi_vram, imm_value = lui_tracker.get(insn.rs if insn.id == MIPS_INS_ADDIU else insn.base, (None, None)) + hi_vram, imm_value = lui_tracker.get( + insn.rs if insn.id == MIPS_INS_ADDIU else insn.base, (None, None) + ) # if a match was found, validate and record the symbol, TODO improve validation - if hi_vram != None and ((((imm_value >> 0x8) & 0xF) != 0 and imm_value < 0x1000) or \ - (imm_value >= 0x8000 and imm_value < 0x80D0) or \ - (imm_value >= 0xA400 and imm_value < 0xA480) or (imm_value < 0x0400 and insn.id == MIPS_INS_ADDIU)): + if hi_vram != None and ( + (((imm_value >> 0x8) & 0xF) != 0 and imm_value < 0x1000) + or (imm_value >= 0x8000 and imm_value < 0x80D0) + or (imm_value >= 0xA400 and imm_value < 0xA480) + or (imm_value < 0x0400 and insn.id == MIPS_INS_ADDIU) + ): lo_vram = vaddr symbol_value = (imm_value << 0x10) + insn.imm - put_symbols(symbols_dict, "symbols", {hi_vram : symbol_value}) - put_symbols(symbols_dict, "symbols", {lo_vram : symbol_value}) + put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) + put_symbols(symbols_dict, "symbols", {lo_vram: symbol_value}) if insn.id == MIPS_INS_LW: # try find jr within the same block - cur_idx = i//4 - lookahead_insn = decode_insn(raw_insns[cur_idx], vram + cur_idx * 4) # TODO fix vaddr here + cur_idx = i + lookahead_insn = insns[cur_idx] # TODO fix vaddr here # still in same block unless one of these instructions are found - while lookahead_insn.id not in [*MIPS_BRANCH_INSNS, MIPS_INS_JAL, MIPS_INS_JALR, MIPS_INS_J]: + while lookahead_insn.id not in [ + *MIPS_BRANCH_INSNS, + MIPS_INS_JAL, + MIPS_INS_JALR, + MIPS_INS_J, + ]: if lookahead_insn.id == MIPS_INS_JR: - if lookahead_insn.rs == (insn.ft if insn.id in MIPS_FP_LOAD_STORE_INSNS else insn.rt): + if lookahead_insn.rs == ( + insn.ft + if insn.id in MIPS_FP_LOAD_STORE_INSNS + else insn.rt + ): # read the jtbl and add targets to func_jtbl_labels - assert rodata is not None , "A rodata section should be present if functions use jump tables" + assert ( + rodata is not None + ), "A rodata section should be present if functions use jump tables" next_jtbl_jr = vaddr + cur_idx * 4 - individual_jtbl_labels.update({next_jtbl_jr : set()}) + individual_jtbl_labels.update({next_jtbl_jr: set()}) - offset = (symbol_value - vram_rodata)//4 + offset = (symbol_value - vram_rodata) // 4 label = rodata_words[offset] - while label >= vram and label < vram + len(data) and \ - (vram_rodata + offset * 4 not in prospective_jtbls or vram_rodata + offset * 4 == symbol_value): + while ( + label >= vram + and label < vram + len(data) + and ( + vram_rodata + offset * 4 + not in prospective_jtbls + or vram_rodata + offset * 4 == symbol_value + ) + ): func_jtbl_labels.add(label) individual_jtbl_labels[next_jtbl_jr].add(label) offset += 1 @@ -593,44 +856,55 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, put_symbol(symbols_dict, "jtbls", symbol_value) # found a jr that matches, no need to keep searching break - elif (insn.ft if insn.id in MIPS_FP_LOAD_STORE_INSNS else insn.rt) in [lookahead_insn.value_forname(field) for field in lookahead_insn.fields[1:]]: + elif ( + insn.ft if insn.id in MIPS_FP_LOAD_STORE_INSNS else insn.rt + ) in [ + lookahead_insn.value_forname(field) + for field in lookahead_insn.fields[1:] + ]: # register clobbered, no need to keep searching break cur_idx += 1 # found end before finding jr insn, not a jtbl if cur_idx >= len(raw_insns): break - lookahead_insn = decode_insn(raw_insns[cur_idx], vram + cur_idx * 4) # TODO fix vaddr here - elif insn.id == MIPS_INS_LD: # doubleword loads + lookahead_insn = insns[cur_idx] # TODO fix vaddr here + elif insn.id == MIPS_INS_LD: # doubleword loads put_symbol(symbols_dict, "dwords", symbol_value) - elif insn.id in [MIPS_INS_LWC1, MIPS_INS_SWC1]: # float load/stores + elif insn.id in [MIPS_INS_LWC1, MIPS_INS_SWC1]: # float load/stores # add float put_symbol(symbols_dict, "floats", symbol_value) - elif insn.id in [MIPS_INS_LDC1, MIPS_INS_SDC1]: # double load/stores + elif insn.id in [MIPS_INS_LDC1, MIPS_INS_SDC1]: # double load/stores # add double put_symbol(symbols_dict, "doubles", symbol_value) - elif insn.id == MIPS_INS_ADDIU and vaddr % 4 == 0: # strings seem to only ever be 4-byte aligned + elif ( + insn.id == MIPS_INS_ADDIU and vaddr % 4 == 0 + ): # strings seem to only ever be 4-byte aligned # add possible string put_symbol(symbols_dict, "prospective_strings", symbol_value) # clear lui tracking state if register is clobbered by the addiu/load instruction itself - # insn.rt == (insn.rs if insn.id == MIPS_INS_ADDIU else insn.base) and + # insn.rt == (insn.rs if insn.id == MIPS_INS_ADDIU else insn.base) and if insn.id not in MIPS_STORE_INSNS and insn.id not in MIPS_FP_LOAD_INSNS: clobber_conditionally(insn) elif insn.id == MIPS_INS_ORI: # try match with tracked lui and mark constant hi_vram, imm_value = lui_tracker.get(insn.rs, (None, None)) - if hi_vram != None: # found match + if hi_vram != None: # found match lo_vram = vaddr const_value = (imm_value << 0x10) | insn.imm - put_symbols(symbols_dict, "constants", {hi_vram : const_value}) - put_symbols(symbols_dict, "constants", {lo_vram : const_value}) + put_symbols(symbols_dict, "constants", {hi_vram: const_value}) + put_symbols(symbols_dict, "constants", {lo_vram: const_value}) # clear lui tracking state if register is clobbered by the ori instruction itself - # insn.rt == insn.rs or + # insn.rt == insn.rs or if insn.rt in lui_tracker.keys(): clobber_conditionally(insn) else: # clear lui tracking if register is clobbered by something unrelated - if insn.id == MIPS_INS_ADDU and insn.rs in lui_tracker.keys() and (insn.rd == insn.rs): + if ( + insn.id == MIPS_INS_ADDU + and insn.rs in lui_tracker.keys() + and (insn.rd == insn.rs) + ): # array accesses optimisation: # lui reg, %hi(symbol) # addu reg, reg, idx @@ -639,22 +913,113 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, # if the output is not currently tracked it will behave as intended anyway pass # insns listed either write to fprs/cop0 or don't write to any - elif insn.id not in [MIPS_INS_MTC0, MIPS_INS_MTC1, MIPS_INS_DMTC1, - MIPS_INS_MULT, MIPS_INS_MULTU, MIPS_INS_DMULT, MIPS_INS_DMULTU, - MIPS_INS_DIV, MIPS_INS_DIVU, MIPS_INS_DDIV, MIPS_INS_DDIVU, - MIPS_INS_MTHI, MIPS_INS_MTLO, - MIPS_INS_CTC1, - MIPS_INS_NOP, - MIPS_INS_BREAK, - MIPS_INS_TLBP, MIPS_INS_TLBR, MIPS_INS_TLBWI, - MIPS_INS_MOV_S, MIPS_INS_MOV_D, MIPS_INS_C_LT_S, MIPS_INS_C_LT_D, - MIPS_INS_DIV_S, MIPS_INS_MUL_S, MIPS_INS_TRUNC_W_S, MIPS_INS_CVT_S_W, - MIPS_INS_SUB_S, MIPS_INS_ADD_S]: + elif insn.id not in [ + MIPS_INS_MTC0, + MIPS_INS_MTC1, + MIPS_INS_DMTC1, + MIPS_INS_MULT, + MIPS_INS_MULTU, + MIPS_INS_DMULT, + MIPS_INS_DMULTU, + MIPS_INS_DIV, + MIPS_INS_DIVU, + MIPS_INS_DDIV, + MIPS_INS_DDIVU, + MIPS_INS_MTHI, + MIPS_INS_MTLO, + MIPS_INS_CTC1, + MIPS_INS_NOP, + MIPS_INS_BREAK, + MIPS_INS_TLBP, + MIPS_INS_TLBR, + MIPS_INS_TLBWI, + MIPS_INS_MOV_S, + MIPS_INS_MOV_D, + MIPS_INS_C_LT_S, + MIPS_INS_C_LT_D, + MIPS_INS_DIV_S, + MIPS_INS_MUL_S, + MIPS_INS_TRUNC_W_S, + MIPS_INS_CVT_S_W, + MIPS_INS_SUB_S, + MIPS_INS_ADD_S, + ]: clobber_conditionally(insn) + ############# Start text disassembly ########## + # Symbols aren't avaialble here yet, so placeholders are added + # in each instruction, to be looked up later + mnemonic = f" {insn.mnemonic}" if delay_slot else insn.mnemonic + op_str = insn.op_str + instr = {"id": insn.id} + + if vaddr in full_file_list[info["name"]]: + if cur_file != "": + if cur_vaddr in info["syms"]: + result_files.append([cur_file, results]) + results = [asm_header(".text")] + cur_vaddr = vaddr + cur_file = full_file_list[info["name"]][vaddr] + if cur_file == "": + cur_file = f"{info['name']}_{vaddr:08X}" + + if insn.id in MIPS_BRANCH_INSNS: + op_str_parts = [] + for field in insn.fields: + if field == "offset": + op_str_parts.append(f".L{insn.offset:08X}") + else: + op_str_parts.append(insn.format_field(field)) + op_str = [", ".join(op_str_parts)] + + elif insn.id in MIPS_JUMP_INSNS: + op_str = [] + op_str_parts = [] + for field in insn.fields: + if field == "target": + op_str_parts.append([insn.target, False, True]) + else: + op_str_parts.append(insn.format_field(field)) + for x, part in enumerate(op_str_parts): + if x + 1 < len(op_str_parts): + part += ", " + op_str.append(part) + + elif insn.id == MIPS_INS_LUI: + op_str = [op_str] + instr["rt"] = insn.rt + + elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + op_str = [op_str] + instr["rt"] = insn.rt + instr["rs"] = insn.rs + instr["ft"] = insn.ft + instr["base"] = insn.base + + elif insn.id == MIPS_INS_ORI: + op_str = [op_str] + instr["rt"] = insn.rt + instr["rs"] = insn.rs + + results.append( + { + "vaddr": vaddr, + "insn": instr, + "addr": f"/* {i*4:06X} {vaddr:08X} {raw_insns[i]:08X} */ ", + "mnem": mnemonic, + "op": op_str, + "data": False, + } + ) + + ######### End text disassembly ############## + if delay_slot and delayed_insn is not None: - if delayed_insn.id == MIPS_INS_JAL or delayed_insn.id == MIPS_INS_JALR or \ - (delayed_insn.id == MIPS_INS_JR and delayed_insn.rs == MIPS_REG_RA): + if ( + delayed_insn.id == MIPS_INS_JAL + or delayed_insn.id == MIPS_INS_JALR + or (delayed_insn.id == MIPS_INS_JR and delayed_insn.rs == MIPS_REG_RA) + ): # destroy lui tracking state lui_tracker.clear() elif delayed_insn.id == MIPS_INS_JR and vaddr == next_jtbl_jr + 4: @@ -673,82 +1038,124 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, delay_slot = delayed_insn is not None + result_files.append([cur_file, results]) + put_symbols(symbols_dict, "branch_labels", func_branch_labels) put_symbols(symbols_dict, "jtbl_labels", func_jtbl_labels) - return symbols_dict + return symbols_dict, result_files -def find_symbols_in_data(data, vram, end, relocs, segment_name): + +def find_symbols_in_data(section): + data, vram, end, relocs = section[4], section[0], section[1], section[5] symbols_dict = dict() - print(f"Finding symbols from .data in {segment_name}") + print(f"Finding symbols from .data in {section[-1]['name']}") # read relocations for symbols if relocs is not None: for reloc in relocs: - if reloc[1] == 2: # R_MIPS_32 - put_symbol(symbols_dict, "data_labels", as_word(data[reloc[2] : reloc[2] + 4])) - elif reloc[1] == 4: # R_MIPS_26 - assert False , "R_MIPS_26 in .data section?" - elif reloc[1] == 5: # R_MIPS_HI16 - assert False , "R_MIPS_HI16 in .data section?" - elif reloc[1] == 6: # R_MIPS_LO16 - assert False , "R_MIPS_LO16 in .data section?" + if reloc[1] == 2: # R_MIPS_32 + put_symbol( + symbols_dict, "data_labels", as_word(data[reloc[2] : reloc[2] + 4]) + ) + elif reloc[1] == 4: # R_MIPS_26 + assert False, "R_MIPS_26 in .data section?" + elif reloc[1] == 5: # R_MIPS_HI16 + assert False, "R_MIPS_HI16 in .data section?" + elif reloc[1] == 6: # R_MIPS_LO16 + assert False, "R_MIPS_LO16 in .data section?" else: - assert False , "Invalid relocation type encountered" + assert False, "Invalid relocation type encountered" return symbols_dict # TODO more -# matches several codepoint regions of EUC-JP -strings_regex = re.compile(rb'^(?:[\x00\x1A\x1B\n\t\x20-\x7E\x8C\x8D]|\x30[\x00-\xFF]|[\x4E-\x9F][\x00-\xFF]|[\xA4\xA5\xBB][\xA1-\xF6]|[\xA1-\xA3\xB0-\xBF\xC0-\xCF][\xA1-\xFE]|\xFF[\x00-\xEF])+$') -def find_symbols_in_rodata(data, vram, end, relocs, segment): +# matches several codepoint regions of EUC-JP +strings_regex = re.compile( + rb"^(?:[\x00\x1A\x1B\n\t\x20-\x7E\x8C\x8D]|\x30[\x00-\xFF]|[\x4E-\x9F][\x00-\xFF]|[\xA4\xA5\xBB][\xA1-\xF6]|[\xA1-\xA3\xB0-\xBF\xC0-\xCF][\xA1-\xFE]|\xFF[\x00-\xEF])+$" +) + + +def find_symbols_in_rodata(section): + data, vram, end, relocs = section[4], section[0], section[1], section[5] + symbols_dict = dict() + + print(f"Finding symbols from .rodata in {section[-1]['name']}") + # read relocations for symbols if relocs is not None: for reloc in relocs: - if reloc[1] == 2: # R_MIPS_32 - data_labels.add(as_word(data[reloc[2] : reloc[2] + 4])) - elif reloc[1] == 4: # R_MIPS_26 - assert False , "R_MIPS_26 in .rodata section?" - elif reloc[1] == 5: # R_MIPS_HI16 - assert False , "R_MIPS_HI16 in .rodata section?" - elif reloc[1] == 6: # R_MIPS_LO16 - assert False , "R_MIPS_LO16 in .rodata section?" + if reloc[1] == 2: # R_MIPS_32 + put_symbol( + symbols_dict, "data_labels", as_word(data[reloc[2] : reloc[2] + 4]) + ) + elif reloc[1] == 4: # R_MIPS_26 + assert False, "R_MIPS_26 in .rodata section?" + elif reloc[1] == 5: # R_MIPS_HI16 + assert False, "R_MIPS_HI16 in .rodata section?" + elif reloc[1] == 6: # R_MIPS_LO16 + assert False, "R_MIPS_LO16 in .rodata section?" else: - assert False , "Invalid relocation type encountered" + assert False, "Invalid relocation type encountered" - section_symbols = set([sym for sym in symbols.values() if sym >= vram and sym < end]) + section_symbols = set( + [sym for sym in symbols.values() if sym >= vram and sym < end] + ) section_symbols.add(vram) - section_symbols.update(set([sym for sym in data_labels if sym >= vram and sym < end])) + section_symbols.update( + set([sym for sym in data_labels if sym >= vram and sym < end]) + ) # TODO temp hack, move - for data_file_st in [sym for sym in segment[4].keys() if sym >= vram and sym < end]: + for data_file_st in [ + sym for sym in section[-1]["syms"].keys() if sym >= vram and sym < end + ]: section_symbols.add(data_file_st) - rodata_starts = [addr for addr,name in segment[4].items() if addr >= vram and addr < end] + rodata_starts = [ + addr + for addr, name in section[-1]["syms"].items() + if addr >= vram and addr < end + ] section_symbols.update(set(rodata_starts)) section_symbols = list(section_symbols) section_symbols.sort() - section_late_rodata = [sym for sym in section_symbols if sym in floats or sym in doubles or sym in jtbls] + section_late_rodata = [ + sym + for sym in section_symbols + if sym in floats or sym in doubles or sym in jtbls + ] # string finding is best done per-file as the late_rodata sections are not merged per-segment, so you get stripes of # rodata - late_rodata -(file boundary)- rodata - late_rodata -(file boundary)- etc. # all rodata file starts - for fi,rodata_start in enumerate(rodata_starts,0): - next_rodata_start = rodata_starts[fi + 1] if fi < len(rodata_starts) - 1 else end + for fi, rodata_start in enumerate(rodata_starts, 0): + next_rodata_start = ( + rodata_starts[fi + 1] if fi < len(rodata_starts) - 1 else end + ) # symbols in this file - file_symbols = [sym for sym in section_symbols if sym >= rodata_start and sym < next_rodata_start] + file_symbols = [ + sym + for sym in section_symbols + if sym >= rodata_start and sym < next_rodata_start + ] # the first (minimum st_value) symbol in section_late_rodata in this file is the start of late_rodata - late_rodata_start = min([sym for sym in file_symbols if sym in section_late_rodata], default=next_rodata_start) + late_rodata_start = min( + [sym for sym in file_symbols if sym in section_late_rodata], + default=next_rodata_start, + ) - for i,symbol in enumerate(file_symbols,0): - next_symbol = file_symbols[i + 1] if i < len(file_symbols) - 1 else next_rodata_start + for i, symbol in enumerate(file_symbols, 0): + next_symbol = ( + file_symbols[i + 1] if i < len(file_symbols) - 1 else next_rodata_start + ) # not late_rodata if symbol >= late_rodata_start: @@ -759,7 +1166,7 @@ def find_symbols_in_rodata(data, vram, end, relocs, segment): data_offset = symbol - vram data_size = next_symbol - symbol - string_data = data[data_offset:data_offset+data_size] + string_data = data[data_offset : data_offset + data_size] if len(string_data) > 0 and string_data[0] == 0: # empty strings that are auto-detected are dubious @@ -769,8 +1176,10 @@ def find_symbols_in_rodata(data, vram, end, relocs, segment): if strings_regex.match(string_data) != None: k = 0 done = False - for j,b in enumerate(string_data,0): - if b == 0 and (j + 1 >= len(string_data) or string_data[j + 1] != 0): + for j, b in enumerate(string_data, 0): + if b == 0 and ( + j + 1 >= len(string_data) or string_data[j + 1] != 0 + ): # try: # decoded = try_decode_string(string_data[k:string_data.index(0)]) # except UnicodeDecodeError: @@ -778,14 +1187,16 @@ def find_symbols_in_rodata(data, vram, end, relocs, segment): # done = True # if done: # break - data_labels.add(symbol + k) - strings.add(symbol + k) - data_labels.add(symbol + j + 1) + put_symbol(symbols_dict, "data_labels", symbol + k) + put_symbol(symbols_dict, "data_labels", symbol + j + 1) + put_symbol(symbols_dict, "strings", symbol + k) k = j + 1 # TODO more + return symbols_dict -def asm_header(section_name): + +def asm_header(section_name): return f""".include "macro.inc" # assembler directives @@ -798,36 +1209,128 @@ def asm_header(section_name): .balign 16 """ -def disassemble_text(data, vram, data_regions, segment): + +def fixup_text_symbols(data, vram, data_regions, info): + segment_dirname = "" if info["type"] != "overlay" else "overlays/" + if info["type"] in ("boot", "code"): + segment_dirname += info["type"] + else: + segment_dirname += info["name"] + + os.makedirs(f"{ASM_OUT}/{segment_dirname}/", exist_ok=True) + + file = files_text[info["name"]] + # header + text = [file.pop(0)] + + # We didn't have full symbols available during initial disassembly, + # so here we loop over each instruction, and do symbol lookups, add labels etc + + for i, entry in enumerate(file): + vaddr = entry["vaddr"] + + if vaddr in functions: + text.append(f"\nglabel {proper_name(vaddr, in_data=entry['data'])}\n") + if vaddr in jtbl_labels: + text.append(f"glabel L{vaddr:08X}\n") + if vaddr in branch_labels: + text.append(f".L{vaddr:08X}:\n") + + line = entry["addr"] + if not entry["data"]: + line += f"{entry['mnem']:12}" + + insn = entry["insn"] + if insn["id"] in MIPS_JUMP_INSNS: + for op_part in entry["op"]: + if type(op_part) == list: + line += proper_name( + op_part[0], in_data=op_part[1], is_symbol=op_part[2] + ) + else: + line += op_part + + elif insn["id"] == MIPS_INS_LUI: + symbol_value = symbols.get(vaddr, None) + if symbol_value is not None: + line += ( + f"{mips_gpr_names[insn['rt']]}, %hi({proper_name(symbol_value)})" + ) + else: + constant_value = constants.get(vaddr, None) + if constant_value is not None: + line += ( + f"{mips_gpr_names[insn['rt']]}, (0x{constant_value:08X} >> 16)" + ) + else: + line += entry["op"][0] + + elif insn["id"] == MIPS_INS_ADDIU or insn["id"] in MIPS_LOAD_STORE_INSNS: + symbol_value = symbols.get(vaddr, None) + if symbol_value is not None: + if insn["id"] == MIPS_INS_ADDIU: + line += f"{mips_gpr_names[insn['rt']]}, {mips_gpr_names[insn['rs']]}, %lo({proper_name(symbol_value)})" + else: + line += f"{mips_fpr_names[insn['ft']] if insn['id'] in MIPS_FP_LOAD_STORE_INSNS else mips_gpr_names[insn['rt']]}, %lo({proper_name(symbol_value)})({mips_gpr_names[insn['base']]})" + else: + line += entry["op"][0] + + elif insn["id"] == MIPS_INS_ORI: + constant_value = constants.get(vaddr, None) + if constant_value is not None: + line += f"{mips_gpr_names[insn['rt']]}, {mips_gpr_names[insn['rs']]}, (0x{constant_value:08X} & 0xFFFF)" + else: + line += entry["op"][0] + + else: + for part in entry["op"]: + if type(part) == list: + line += ( + f"{proper_name(part[0], in_data=part[1], is_symbol=part[2])}" + ) + else: + line += part + + line += "\n" + text.append(line) + + with open(f"{ASM_OUT}/{segment_dirname}/{info['name']}.text.s", "w") as outfile: + outfile.write("".join(text)) + + +def disassemble_text(data, vram, data_regions, info): result = asm_header(".text") raw_insns = as_word_list(data) cur_file = "" + cur_vaddr = 0 - segment_dirname = ("" if segment[2] != "overlay" else "overlays/") + segment[0] + segment_dirname = ("" if info["type"] != "overlay" else "overlays/") + info["name"] + os.makedirs(f"{ASM_OUT}/{segment_dirname}/", exist_ok=True) delayed_insn = None delay_slot = False - for i,raw_insn in enumerate(raw_insns,0): + for i, raw_insn in enumerate(raw_insns, 0): i *= 4 vaddr = vram + i - insn = decode_insn(raw_insns[i//4], vaddr) + insn = decode_insn(raw_insns[i // 4], vaddr) mnemonic = insn.mnemonic op_str = insn.op_str - if vaddr in segment[4].keys(): + if vaddr in full_file_list[info["name"]]: if cur_file != "": - os.makedirs(f"{ASM_OUT}/{segment_dirname}/", exist_ok=True) - with open(f"{ASM_OUT}/{segment_dirname}/{cur_file}.text.s", "w") as outfile: - outfile.write(result) + if cur_vaddr in info["syms"]: + os.makedirs(f"{ASM_OUT}/{segment_dirname}/", exist_ok=True) + with open( + f"{ASM_OUT}/{segment_dirname}/{cur_file}.text.s", "w" + ) as outfile: + outfile.write(result) result = asm_header(".text") - cur_file = segment[4][vaddr] + cur_vaddr = vaddr + cur_file = full_file_list[info["name"]][vaddr] if cur_file == "": - cur_file = f"{segment[0]}_{vaddr:08X}" - - if cur_file == "[PADDING]": # workaround for assumed linker bug - continue + cur_file = f"{info['name']}_{vaddr:08X}" # DATA EMBEDDED IN TEXT in_data = False @@ -836,9 +1339,12 @@ def disassemble_text(data, vram, data_regions, segment): in_data = True break if in_data: - if vaddr in functions: # TODO not really a function if it falls in a data region... + # TODO not really a function if it falls in a data region... + if vaddr in functions: result += f"\nglabel {proper_name(vaddr, True)}\n" - result += f"/* {i:06X} {vaddr:08X} {raw_insn:08X} */ .word 0x{raw_insn:08X}\n" + result += ( + f"/* {i:06X} {vaddr:08X} {raw_insn:08X} */ .word 0x{raw_insn:08X}\n" + ) continue # LABELS @@ -853,7 +1359,7 @@ def disassemble_text(data, vram, data_regions, segment): if insn.id in MIPS_BRANCH_INSNS: op_str_parts = [] for field in insn.fields: - if field == 'offset': + if field == "offset": op_str_parts.append(f".L{insn.offset:08X}") else: op_str_parts.append(insn.format_field(field)) @@ -862,7 +1368,7 @@ def disassemble_text(data, vram, data_regions, segment): elif insn.id in MIPS_JUMP_INSNS: op_str_parts = [] for field in insn.fields: - if field == 'target': + if field == "target": op_str_parts.append(proper_name(insn.target, is_symbol=True)) else: op_str_parts.append(insn.format_field(field)) @@ -875,7 +1381,9 @@ def disassemble_text(data, vram, data_regions, segment): else: constant_value = constants.get(vaddr, None) if constant_value is not None: - op_str = f"{mips_gpr_names[insn.rt]}, (0x{constant_value:08X} >> 16)" + op_str = ( + f"{mips_gpr_names[insn.rt]}, (0x{constant_value:08X} >> 16)" + ) elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: @@ -897,194 +1405,458 @@ def disassemble_text(data, vram, data_regions, segment): result += f"/* {i:06X} {vaddr:08X} {raw_insn:08X} */ {mnemonic:12}{op_str}\n" - os.makedirs(f"{ASM_OUT}/{segment_dirname}/", exist_ok=True) with open(f"{ASM_OUT}/{segment_dirname}/{cur_file}.text.s", "w") as outfile: outfile.write(result) -def disassemble_data(data, vram, end, segment): + +def disassemble_data(data, vram, end, info): section_symbols = [sym for sym in symbols.values() if sym >= vram and sym < end] section_symbols.append(vram) section_symbols.extend([sym for sym in data_labels if sym >= vram and sym < end]) - section_symbols.extend([sym for sym in variables_ast.keys() if sym >= vram and sym < end]) + section_symbols.extend( + [sym for sym in variables_ast.keys() if sym >= vram and sym < end] + ) # TODO temp hack, move - section_symbols.extend([sym for sym in segment[4].keys() if sym >= vram and sym < end]) + section_symbols.extend( + [sym for sym in info["syms"].keys() if sym >= vram and sym < end] + ) # remove symbols that are addends of other symbols - section_symbols = [sym for sym in section_symbols if " + 0x" not in proper_name(sym, True) and " - 0x" not in proper_name(sym, True)] + section_symbols = [ + sym + for sym in section_symbols + if " + 0x" not in proper_name(sym, True) + and " - 0x" not in proper_name(sym, True) + ] section_symbols = list(set(section_symbols)) section_symbols.sort() - segment_dirname = ("" if segment[2] != "overlay" else "overlays/") + segment[0] - - result = asm_header(".data") - cur_file = "" - - for i,symbol in enumerate(section_symbols,0): - next_symbol = section_symbols[i + 1] if i < len(section_symbols) - 1 else end - - # assert symbol % 4 == 0 , f"Unaligned .data symbol 0x{symbol:08X}" - - if symbol in segment[4].keys(): - if cur_file != "": - os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) - with open(f"{DATA_OUT}/{segment_dirname}/{cur_file}.data.s", "w") as outfile: - outfile.write(result) - result = asm_header(".data") - cur_file = segment[4][symbol] - if cur_file == "": - cur_file = f"{segment[0]}_{symbol:08X}" - - data_offset = symbol - vram - data_size = next_symbol - symbol - - if data_offset == len(data): - continue - - result += f"\nglabel {proper_name(symbol, True)}\n" - - if symbol % 8 == 0 and data_size % 8 == 0 and symbol in doubles: - result += "\n".join(\ - [f"/* {data_offset + j * 8:06X} {symbol + j * 8:08X} {dbl_dwd:016X} */ {format_f64(dbl_dwd)}" for j,dbl_dwd in enumerate(as_dword_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - elif symbol % 8 == 0 and data_size % 8 == 0 and symbol in dwords: - result += "\n".join(\ - [f"/* {data_offset + j * 8:06X} {symbol + j * 8:08X} */ .quad 0x{dword:08X}" for j,dword in enumerate(as_dword_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - elif symbol % 4 == 0 and data_size % 4 == 0: - if symbol in floats: - result += "\n".join(\ - [f"/* {data_offset + j * 4:06X} {symbol + j * 4:08X} {flt_wd:08X} */ {format_f32(flt_wd)}" for j,flt_wd in enumerate(as_word_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - else: - result += "\n".join(\ - [f"/* {data_offset + j * 4:06X} {symbol + j * 4:08X} */ .word {lookup_name(symbol, word)}" for j,word in enumerate(as_word_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - elif symbol % 2 == 0 and data_size % 2 == 0: - result += "\n".join(\ - [f"/* {data_offset + j * 2:06X} {symbol + j * 2:08X} */ .half 0x{hword:04X}" for j,hword in enumerate(as_hword_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - else: - result += "\n".join(\ - [f"/* {data_offset + j:06X} {symbol + j:08X} */ .byte 0x{byte:02X}" for j,byte in enumerate(data[data_offset:data_offset + data_size], 0)]) + "\n" - - os.makedirs(f"{DATA_OUT}/{segment[0]}/", exist_ok=True) - with open(f"{DATA_OUT}/{segment[0]}/{cur_file}.data.s", "w") as outfile: - outfile.write(result) - -def disassemble_rodata(data, vram, end, segment): - section_symbols = [sym for sym in symbols.values() if sym >= vram and sym < end] - section_symbols.append(vram) - section_symbols.extend([sym for sym in data_labels if sym >= vram and sym < end]) - section_symbols.extend([sym for sym in variables_ast.keys() if sym >= vram and sym < end]) - # TODO temp hack, move - section_symbols.extend([sym for sym in segment[4].keys() if sym >= vram and sym < end]) - - # remove symbols that are addends of other symbols - section_symbols = [sym for sym in section_symbols if " + 0x" not in proper_name(sym, True) and " - 0x" not in proper_name(sym, True)] - - section_symbols = list(set(section_symbols)) - - section_symbols.sort() - - segment_dirname = ("" if segment[2] != "overlay" else "overlays/") + segment[0] - - result = asm_header(".rodata") - cur_file = "" - - force_ascii_str = False # hack for non-null-terminated strings in .data - - for i,symbol in enumerate(section_symbols,0): - next_symbol = section_symbols[i + 1] if i < len(section_symbols) - 1 else end - - # assert symbol % 4 == 0 , f"Unaligned .data symbol 0x{symbol:08X}" - - if symbol in segment[4].keys(): - if cur_file != "": - os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) - with open(f"{DATA_OUT}/{segment_dirname}/{cur_file}.rodata.s", "w") as outfile: - outfile.write(result) - result = asm_header(".rodata") - cur_file = segment[4][symbol] - if cur_file == "": - cur_file = f"{segment[0]}_{symbol:08X}" - - data_offset = symbol - vram - data_size = next_symbol - symbol - - if data_offset == len(data): - continue - - force_ascii_str = symbol in [0x801D0708] - - result += f"\nglabel {proper_name(symbol, True)}\n" - - if symbol in strings: - string_data = data[data_offset:data_offset+data_size] - string_data = string_data[:string_data.index(0)] - assert all([b != 0 for b in string_data[:-1]]) , f"{symbol:08X} , {data_size:X} , {string_data}" # ensure strings don't have a null char midway through - result += f"/* {data_offset:06X} {symbol:08X} */ {try_decode_string(string_data, force_ascii=force_ascii_str)}\n{STR_INDENT}.balign 4\n" - elif symbol % 8 == 0 and data_size % 8 == 0 and symbol in doubles: - result += "\n".join(\ - [f"/* {data_offset + j * 8:06X} {symbol + j * 8:08X} {dbl_dwd:016X} */ {format_f64(dbl_dwd)}" for j,dbl_dwd in enumerate(as_dword_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - elif symbol % 4 == 0 and data_size % 4 == 0: - if symbol in floats: - result += "\n".join(\ - [f"/* {data_offset + j * 4:06X} {symbol + j * 4:08X} {flt_wd:08X} */ {format_f32(flt_wd)}" for j,flt_wd in enumerate(as_word_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - else: - result += "\n".join(\ - [f"/* {data_offset + j * 4:06X} {symbol + j * 4:08X} */ .word {lookup_name(symbol, word)}" for j,word in enumerate(as_word_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - elif symbol % 2 == 0 and data_size % 2 == 0: - result += "\n".join(\ - [f"/* {data_offset + j * 2:06X} {symbol + j * 2:08X} */ .half 0x{hword:04X}" for j,hword in enumerate(as_hword_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - else: - result += "\n".join(\ - [f"/* {data_offset + j:06X} {symbol + j:08X} */ .byte 0x{byte:02X}" for j,byte in enumerate(data[data_offset:data_offset + data_size], 0)]) + "\n" - - os.makedirs(f"{DATA_OUT}/{segment[0]}/", exist_ok=True) - with open(f"{DATA_OUT}/{segment[0]}/{cur_file}.rodata.s", "w") as outfile: - outfile.write(result) - -def disassemble_bss(vram, end, segment): - section_symbols = [sym for sym in symbols.values() if sym >= vram and sym < end] - section_symbols.append(vram) - section_symbols.extend([sym for sym in data_labels if sym >= vram and sym < end]) - section_symbols.extend([sym for sym in variables_ast.keys() if sym >= vram and sym < end]) - # TODO temp hack, move - section_symbols.extend([sym for sym in segment[4].keys() if sym >= vram and sym < end]) - - # remove symbols that are addends of other symbols - section_symbols = [sym for sym in section_symbols if " + 0x" not in proper_name(sym, True) and " - 0x" not in proper_name(sym, True)] - - section_symbols = list(set(section_symbols)) - - section_symbols.sort() - - # ("" if segment[2] != "overlay" else "overlays/" - segment_dirname = segment[0] - - result = asm_header(".bss") - cur_file = "" - - for i,symbol in enumerate(section_symbols,0): - next_symbol = section_symbols[i + 1] if i < len(section_symbols) - 1 else end - - if symbol in segment[4].keys(): - if cur_file != "": - os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) - with open(f"{DATA_OUT}/{segment_dirname}/{cur_file}.bss.s", "w") as outfile: - outfile.write(result) - result = asm_header(".bss") - cur_file = segment[4][symbol] - if cur_file == "": - cur_file = f"{segment[0]}_{symbol:08X}" - - result += f"\nglabel {proper_name(symbol, True)}\n" - result += f"/* {symbol - vram:06X} {symbol:08X} */ .space 0x{next_symbol - symbol:X}\n" + segment_dirname = info["name"] + if info["type"] in ("boot", "code"): + segment_dirname = info["type"] os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) - with open(f"{DATA_OUT}/{segment_dirname}/{cur_file}.bss.s", "w") as outfile: - outfile.write(result) + + if info["type"] in ("boot", "code"): + sym_list = full_file_list[info["type"]] + else: + sym_list = full_file_list[info["name"]] + + file_syms = [] + syms = [] + file_name = "" + for i, sym in enumerate(section_symbols): + if i == 0: + if info["type"] == "overlay": + file_name = info["name"] + else: + file_name = sym_list[sym] + + if sym in sym_list: + new_file = sym_list[sym] + if file_name != new_file: + file_syms.append( + {"name": file_name, "first_sym": syms[0], "syms": syms} + ) + syms = [] + file_name = new_file + syms.append(sym) + if len(syms) > 0: + file_syms.append({"name": file_name, "first_sym": syms[0], "syms": syms}) + + for i, file in enumerate(file_syms): + if file["first_sym"] not in info["syms"]: + continue + + result = [asm_header(".data")] + + for x, symbol in enumerate(file["syms"]): + if symbol >= end: + break + if x + 1 < len(file["syms"]): + next_symbol = file["syms"][x + 1] + elif i + 1 < len(file_syms): + next_symbol = file_syms[i + 1]["first_sym"] + else: + next_symbol = end + + data_base = symbol - info["base"] + data_offset = symbol - vram + data_size = next_symbol - symbol + + if data_offset == len(data): + continue + + r = f"\nglabel {proper_name(symbol, True)}\n" + + if symbol % 8 == 0 and data_size % 8 == 0 and symbol in doubles: + r += ( + "\n".join( + [ + f"/* {data_base + j * 8:06X} {symbol + j * 8:08X} {dbl_dwd:016X} */ {format_f64(dbl_dwd)}" + for j, dbl_dwd in enumerate( + as_dword_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + elif symbol % 8 == 0 and data_size % 8 == 0 and symbol in dwords: + r += ( + "\n".join( + [ + f"/* {data_base + j * 8:06X} {symbol + j * 8:08X} */ .quad 0x{dword:08X}" + for j, dword in enumerate( + as_dword_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + elif symbol % 4 == 0 and data_size % 4 == 0: + if symbol in floats: + r += ( + "\n".join( + [ + f"/* {data_base + j * 4:06X} {symbol + j * 4:08X} {flt_wd:08X} */ {format_f32(flt_wd)}" + for j, flt_wd in enumerate( + as_word_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + else: + r += ( + "\n".join( + [ + f"/* {data_base + j * 4:06X} {symbol + j * 4:08X} */ .word {lookup_name(symbol, word)}" + for j, word in enumerate( + as_word_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + elif symbol % 2 == 0 and data_size % 2 == 0: + r += ( + "\n".join( + [ + f"/* {data_base + j * 2:06X} {symbol + j * 2:08X} */ .half 0x{hword:04X}" + for j, hword in enumerate( + as_hword_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + else: + r += ( + "\n".join( + [ + f"/* {data_base + j:06X} {symbol + j:08X} */ .byte 0x{byte:02X}" + for j, byte in enumerate( + data[data_offset : data_offset + data_size], 0 + ) + ] + ) + + "\n" + ) + result.append(r) + + if len(result) > 1: + with open( + f"{DATA_OUT}/{segment_dirname}/{file['name']}.data.s", "w" + ) as outfile: + outfile.write("".join(result)) + + +def disassemble_rodata(data, vram, end, info): + section_symbols = [sym for sym in symbols.values() if sym >= vram and sym < end] + section_symbols.append(vram) + section_symbols.extend([sym for sym in data_labels if sym >= vram and sym < end]) + section_symbols.extend( + [sym for sym in variables_ast.keys() if sym >= vram and sym < end] + ) + # TODO temp hack, move + section_symbols.extend( + [sym for sym in info["syms"].keys() if sym >= vram and sym < end] + ) + + # remove symbols that are addends of other symbols + section_symbols = [ + sym + for sym in section_symbols + if " + 0x" not in proper_name(sym, True) + and " - 0x" not in proper_name(sym, True) + ] + + section_symbols = list(set(section_symbols)) + + if len(section_symbols) == 0: + return + + section_symbols.sort() + + segment_dirname = info["name"] + if info["type"] in ("boot", "code"): + segment_dirname = info["type"] + os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) + + if info["type"] in ("boot", "code"): + sym_list = full_file_list[info["type"]] + else: + sym_list = full_file_list[info["name"]] + + force_ascii_str = False # hack for non-null-terminated strings in .data + + file_syms = [] + syms = [] + file_name = "" + for i, sym in enumerate(section_symbols): + if i == 0: + if info["type"] == "overlay": + file_name = info["name"] + else: + file_name = sym_list[sym] + + if sym in sym_list: + new_file = sym_list[sym] + if file_name != new_file: + file_syms.append( + {"name": file_name, "first_sym": syms[0], "syms": syms} + ) + syms = [] + file_name = new_file + syms.append(sym) + if len(syms) > 0: + file_syms.append({"name": file_name, "first_sym": syms[0], "syms": syms}) + + for i, file in enumerate(file_syms): + if file["first_sym"] not in info["syms"]: + continue + + result = [asm_header(".rodata")] + + for x, symbol in enumerate(file["syms"]): + if symbol >= end: + break + if x + 1 < len(file["syms"]): + next_symbol = file["syms"][x + 1] + elif i + 1 < len(file_syms): + next_symbol = file_syms[i + 1]["first_sym"] + else: + next_symbol = end + + data_base = symbol - info["base"] + data_offset = symbol - vram + data_size = next_symbol - symbol + + if data_offset == len(data): + continue + + force_ascii_str = symbol in [0x801D0708] + + r = f"\nglabel {proper_name(symbol, True)}\n" + + if symbol in strings: + string_data = data[data_offset : data_offset + data_size] + string_data = string_data[: string_data.index(0)] + # ensure strings don't have a null char midway through + assert all( + [b != 0 for b in string_data[:-1]] + ), f"{symbol:08X} , {data_size:X} , {string_data}" + r += f"/* {data_base:06X} {symbol:08X} */ {try_decode_string(string_data, force_ascii=force_ascii_str)}\n{STR_INDENT}.balign 4\n" + elif symbol % 8 == 0 and data_size % 8 == 0 and symbol in doubles: + r += ( + "\n".join( + [ + f"/* {data_base + j * 8:06X} {symbol + j * 8:08X} {dbl_dwd:016X} */ {format_f64(dbl_dwd)}" + for j, dbl_dwd in enumerate( + as_dword_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + elif symbol % 4 == 0 and data_size % 4 == 0: + if symbol in floats: + r += ( + "\n".join( + [ + f"/* {data_base + j * 4:06X} {symbol + j * 4:08X} {flt_wd:08X} */ {format_f32(flt_wd)}" + for j, flt_wd in enumerate( + as_word_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + else: + r += ( + "\n".join( + [ + f"/* {data_base + j * 4:06X} {symbol + j * 4:08X} */ .word {lookup_name(symbol, word)}" + for j, word in enumerate( + as_word_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + elif symbol % 2 == 0 and data_size % 2 == 0: + r += ( + "\n".join( + [ + f"/* {data_base + j * 2:06X} {symbol + j * 2:08X} */ .half 0x{hword:04X}" + for j, hword in enumerate( + as_hword_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + else: + r += ( + "\n".join( + [ + f"/* {data_base + j:06X} {symbol + j:08X} */ .byte 0x{byte:02X}" + for j, byte in enumerate( + data[data_offset : data_offset + data_size], 0 + ) + ] + ) + + "\n" + ) + + result.append(r) + + if len(result) > 1: + with open( + f"{DATA_OUT}/{segment_dirname}/{file['name']}.rodata.s", "w" + ) as outfile: + outfile.write("".join(result)) + + +def disassemble_bss(vram, end, info): + section_symbols = [sym for sym in symbols.values() if sym >= vram and sym < end] + section_symbols.append(vram) + section_symbols.extend([sym for sym in data_labels if sym >= vram and sym < end]) + section_symbols.extend( + [sym for sym in variables_ast.keys() if sym >= vram and sym < end] + ) + # TODO temp hack, move + section_symbols.extend( + [sym for sym in info["syms"].keys() if sym >= vram and sym < end] + ) + + # remove symbols that are addends of other symbols + section_symbols = [ + sym + for sym in section_symbols + if " + 0x" not in proper_name(sym, True) + and " - 0x" not in proper_name(sym, True) + ] + + section_symbols = list(set(section_symbols)) + + section_symbols.sort() + + # ("" if info["type"] != "overlay" else "overlays/" + segment_dirname = ( + info["name"] if info["type"] not in ("boot", "code") else info["type"] + ) + os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) + + if info["type"] in ("boot", "code"): + sym_list = full_file_list[info["type"]] + else: + sym_list = full_file_list[info["name"]] + + file_syms = [] + syms = [] + file_name = "" + for i, sym in enumerate(section_symbols): + if i == 0: + if info["type"] == "overlay": + file_name = info["name"] + else: + file_name = sym_list[sym] + + if sym in sym_list: + new_file = sym_list[sym] + if file_name != new_file: + file_syms.append( + {"name": file_name, "first_sym": syms[0], "syms": syms} + ) + syms = [] + file_name = new_file + syms.append(sym) + if len(syms) > 0: + file_syms.append({"name": file_name, "first_sym": syms[0], "syms": syms}) + + for i, file in enumerate(file_syms): + if file["first_sym"] not in info["syms"]: + continue + + result = [asm_header(".bss")] + + for x, symbol in enumerate(file["syms"]): + if symbol >= end: + break + if x + 1 < len(file["syms"]): + next_symbol = file["syms"][x + 1] + elif i + 1 < len(file_syms): + next_symbol = file_syms[i + 1]["first_sym"] + else: + next_symbol = end + + result.append(f"\nglabel {proper_name(symbol, True)}\n") + result.append( + f"/* {symbol - vram:06X} {symbol:08X} */ .space 0x{next_symbol - symbol:X}\n" + ) + + if len(result) > 1: + with open( + f"{DATA_OUT}/{segment_dirname}/{file['name']}.bss.s", "w" + ) as outfile: + outfile.write("".join(result)) + def get_overlay_sections(vram, overlay): header_loc = len(overlay) - as_word_list(overlay)[-1] - text_size, data_size, rodata_size, bss_size, n_relocs = as_word_list(overlay[header_loc:header_loc + 0x14]) + text_size, data_size, rodata_size, bss_size, n_relocs = as_word_list( + overlay[header_loc : header_loc + 0x14] + ) text_vram = vram data_vram = vram + text_size rodata_vram = data_vram + data_size @@ -1092,154 +1864,66 @@ def get_overlay_sections(vram, overlay): bss_vram = vram + len(overlay) bss_end_vram = bss_vram + bss_size - reloc = as_word_list(overlay[header_loc + 0x14: header_loc + 0x14 + n_relocs * 4]) - reloc = [((rel >> 30) & ((1 << 2) - 1), (rel >> 24) & ((1 << 6) - 1), (rel) & ((1 << 24) - 1)) for rel in reloc] + reloc = as_word_list(overlay[header_loc + 0x14 : header_loc + 0x14 + n_relocs * 4]) + reloc = [ + ( + (rel >> 30) & ((1 << 2) - 1), + (rel >> 24) & ((1 << 6) - 1), + (rel) & ((1 << 24) - 1), + ) + for rel in reloc + ] rel_text = [r for r in reloc if r[0] == 1] rel_data = [r for r in reloc if r[0] == 2] rel_rodata = [r for r in reloc if r[0] == 3] rel_bss = [r for r in reloc if r[0] == 4] - return [[text_vram, data_vram, 'text', None, overlay[0:text_size], rel_text], \ - [data_vram, rodata_vram, 'data', None, overlay[text_size:text_size+data_size], rel_data], \ - [rodata_vram, bss_vram, 'rodata', None, overlay[text_size+data_size:text_size+data_size+rodata_size], rel_rodata], \ - [bss_vram, bss_end_vram, 'bss', None, None, rel_bss], \ - [bss_end_vram, bss_end_vram, 'reloc', None, overlay[header_loc:], None]] + return [ + [text_vram, data_vram, "text", None, overlay[0:text_size], rel_text], + [ + data_vram, + rodata_vram, + "data", + None, + overlay[text_size : text_size + data_size], + rel_data, + ], + [ + rodata_vram, + bss_vram, + "rodata", + None, + overlay[text_size + data_size : text_size + data_size + rodata_size], + rel_rodata, + ], + [bss_vram, bss_end_vram, "bss", None, None, rel_bss], + [bss_end_vram, bss_end_vram, "reloc", None, overlay[header_loc:], None], + ] -# -print("Setting Up") - -files_spec = None -with open("tools/disasm/files.txt", "r") as infile: - files_spec = ast.literal_eval(infile.read()) - -with open("tools/disasm/functions.txt", "r") as infile: - functions_ast = ast.literal_eval(infile.read()) - -with open("tools/disasm/variables.txt", "r") as infile: - variables_ast = ast.literal_eval(infile.read()) - -# Find floats, doubles, and strings -for var in sorted(variables_ast.keys()): - var_type = variables_ast[var][1] - - if var_type == "f64": - doubles.add(var) - elif var_type == "f32": - floats.add(var) - elif var_type == "char" and variables_ast[var][2].startswith("["): - strings.add(var) - -# Read in binary and relocation data for each segment -for segment in files_spec: - binary = None - with open(segment[1] + "/" + segment[0],"rb") as infile: - binary = bytes(infile.read()) - - if segment[2] == "overlay": - segment_start = list(segment[4])[0] # start addr of first file in segment - segment[3] = get_overlay_sections(segment_start, binary) - segment[4] = {} - for section in segment[3]: - segment[4].update({ section[0] : segment[0] }) - else: - segment_start = segment[3][0][0] # start addr of first section of segment's sections - # read section binary regions - for section in segment[3]: - if section[2] == 'bss': - continue - section.append(binary[section[0] - segment_start:section[1] - segment_start]) # section[4] - section.append(None) # section[5] - -print(f"Finding Symbols") - -for segment in files_spec: - if segment[2] == 'makerom': - continue - - print(f"Finding segment positions in {segment[0]}") - - # vram segment start - if segment[3][0][0] not in variables_ast: - variables_ast.update({segment[3][0][0] : (f"_{segment[0]}SegmentStart","u8","[]",0x1)}) - # vram segment end - if segment[3][-1][1] not in variables_ast: - variables_ast.update({segment[3][-1][1] : (f"_{segment[0]}SegmentEnd","u8","[]",0x1)}) - -# Construct variable_addrs, now that variable_addrs is fully constructed -variable_addrs = sorted(variables_ast.keys()) - -pool = Pool(jobs) -# Find symbols for each segment -for segment in files_spec: - if segment[2] == 'makerom': - continue - - #print(f"Finding symbols from .text and .data in {segment[0]}") - - for section in segment[3]: - if section[2] == 'text': - data_regions = [] - if section[3] is not None: - for override_region in section[3]: - if override_region[2] == 'data': - data_regions.append((override_region[0], override_region[1])) - # try find a rodata section - for find_section in segment[3]: - if find_section[2] == 'rodata' and find_section[1] != find_section[0]: - rodata_section = find_section - break - else: - rodata_section = None - pool.apply_async(find_symbols_in_text, args=(section[4], rodata_section[4] if rodata_section is not None else None, - section[0], rodata_section[0] if rodata_section is not None else None, data_regions, section[5], segment[0]), callback=update_symbols_from_dict) - elif section[2] == 'data': - pool.apply_async(find_symbols_in_data, args=(section[4], section[0], section[1], section[5], segment[0]), callback=update_symbols_from_dict) - -pool.close() -pool.join() - -for segment in files_spec: - if segment[2] == 'makerom': - continue - - print(f"Finding symbols from .rodata and .dmadata in {segment[0]}") - - for section in segment[3]: - if section[2] == 'rodata': - find_symbols_in_rodata(section[4], section[0], section[1], section[5], segment) - elif section[2] == 'dmadata': - filenames = [] - with open("tools/disasm/dma_filenames.txt","r") as infile: - filenames = ast.literal_eval(infile.read()) - - dmadata = segment[3][0][4] - i = 0 - dmadata_entry = dmadata[i*0x10:(i+1)*0x10] - while any([word != 0 for word in as_word_list(dmadata_entry)]): - vrom_start,vrom_end,prom_start,prom_end = as_word_list(dmadata_entry) - # print(f"{vrom_start:08X},{vrom_end:08X},{prom_start:08X},{prom_end:08X} : {filenames[i]}") - vrom_variables.append(("_" + filenames[i] + "SegmentRomStart", vrom_start)) - vrom_variables.append(("_" + filenames[i] + "SegmentRomEnd", vrom_end)) - i += 1 - dmadata_entry = dmadata[i*0x10:(i+1)*0x10] - -# Construct vrom_addrs, now that vrom_variables is fully constructed -vrom_addrs = {addr for _, addr in vrom_variables} - -def disassemble_makerom(segment): +def disassemble_makerom(section): os.makedirs(f"{ASM_OUT}/makerom/", exist_ok=True) - rom_header = segment[3][0][4] - ipl3 = segment[3][1][4] - entry = segment[3][2][4] - pi_dom1_reg, clockrate, entrypoint, revision, \ - chksum1, chksum2, pad1, pad2, \ - rom_name, pad3, cart, cart_id, \ - region, version = struct.unpack(">IIIIIIII20sII2s1sB", rom_header) + if section[2] == "rom_header": + ( + pi_dom1_reg, + clockrate, + entrypoint, + revision, + chksum1, + chksum2, + pad1, + pad2, + rom_name, + pad3, + cart, + cart_id, + region, + version, + ) = struct.unpack(">IIIIIIII20sII2s1sB", section[4]) - out = f"""/* + out = f"""/* * The Legend of Zelda: Majora's Mask ROM header */ @@ -1258,49 +1942,51 @@ def disassemble_makerom(segment): .ascii "{region.decode('ascii')}" /* Region */ .byte 0x{version:02X} /* Version */ """ - with open(ASM_OUT + "/makerom/rom_header.s", "w") as outfile: - outfile.write(out) + with open(ASM_OUT + "/makerom/rom_header.s", "w") as outfile: + outfile.write(out) - # TODO disassemble this eventually, low priority - out = f"{asm_header('.text')}\n.incbin \"baserom/makerom\", 0x40, 0xFC0\n" + elif section[-1]["type"] == "ipl3": + # TODO disassemble this eventually, low priority + out = f"{asm_header('.text')}\n.incbin \"baserom/makerom\", 0x40, 0xFC0\n" - with open(ASM_OUT + "/makerom/ipl3.s", "w") as outfile: - outfile.write(out) + with open(ASM_OUT + "/makerom/ipl3.s", "w") as outfile: + outfile.write(out) - # hack: add symbol relocations manually - entry_addr = 0x80080000 + elif section[-1]["type"] == "entry": + # hack: add symbol relocations manually + entry_addr = 0x80080000 - functions.add(entry_addr) - symbols.update({entry_addr + 0x00 : 0x80099500, - entry_addr + 0x04 : 0x80099500, - entry_addr + 0x20 : 0x80080060, - entry_addr + 0x24 : 0x80099EF0, - entry_addr + 0x28 : 0x80080060, - entry_addr + 0x30 : 0x80099EF0}) - branch_labels.add(entry_addr + 0xC) + functions.add(entry_addr) + symbols.update( + { + entry_addr + 0x00: 0x80099500, + entry_addr + 0x04: 0x80099500, + entry_addr + 0x20: 0x80080060, + entry_addr + 0x24: 0x80099EF0, + entry_addr + 0x28: 0x80080060, + entry_addr + 0x30: 0x80099EF0, + } + ) + branch_labels.add(entry_addr + 0xC) + disassemble_text(section[4], entry_addr, [], section[-1]) - disassemble_text(entry, entry_addr, [], segment) + # manually set boot bss size... + entry_asm = "" + with open(f"{ASM_OUT}/makerom/entry.text.s") as infile: + entry_asm = infile.read() - # manually set boot bss size... - entry_asm = "" - with open(f"{ASM_OUT}/makerom/entry.text.s") as infile: - entry_asm = infile.read() + entry_asm = entry_asm.replace("0x63b0", "%lo(_bootSegmentBssSize)") + with open(f"{ASM_OUT}/makerom/entry.s", "w") as outfile: + outfile.write(entry_asm) - entry_asm = entry_asm.replace("0x63b0", "%lo(_bootSegmentBssSize)") - with open(f"{ASM_OUT}/makerom/entry.s", "w") as outfile: - outfile.write(entry_asm) + os.remove(f"{ASM_OUT}/makerom/entry.text.s") - os.remove(f"{ASM_OUT}/makerom/entry.text.s") - #out = f"{asm_header('.text')}\n.incbin \"baserom/makerom\", 0x1000, 0x60\n" - - #with open(ASM_OUT + "/makerom/entry.s", "w") as outfile: - # outfile.write(out) - -def disassemble_segment(segment): - if segment[2] == 'dmadata': - os.makedirs(f"{ASM_OUT}/dmadata/", exist_ok=True) - out = f""".include "macro.inc" +def disassemble_dmadata(section): + if section[2] == "bss": + return + os.makedirs(f"{ASM_OUT}/dmadata/", exist_ok=True) + out = f""".include "macro.inc" .macro DMA_TABLE_ENTRY segment .4byte _\segment\()SegmentRomStart @@ -1318,137 +2004,132 @@ def disassemble_segment(segment): glabel {variables_ast[0x8009F8B0][0]} """ - filenames = [] - with open("tools/disasm/dma_filenames.txt","r") as infile: - filenames = ast.literal_eval(infile.read()) + filenames = [] + with open("tools/disasm/dma_filenames.txt", "r") as infile: + filenames = ast.literal_eval(infile.read()) - dmadata = segment[3][0][4] - i = 0 - dmadata_entry = dmadata[i*0x10:(i+1)*0x10] - while any([word != 0 for word in as_word_list(dmadata_entry)]): - vrom_start,vrom_end,prom_start,prom_end = as_word_list(dmadata_entry) - if prom_start == 0xFFFFFFFF and prom_end == 0xFFFFFFFF: - out += f"DMA_TABLE_ENTRY_UNSET {filenames[i]}\n" - else: - out += f"DMA_TABLE_ENTRY {filenames[i]}\n" - i += 1 - dmadata_entry = dmadata[i*0x10:(i+1)*0x10] + dmadata = section[4] + i = 0 + dmadata_entry = dmadata[i * 0x10 : (i + 1) * 0x10] + while any([word != 0 for word in as_word_list(dmadata_entry)]): + vrom_start, vrom_end, prom_start, prom_end = as_word_list(dmadata_entry) + if prom_start == 0xFFFFFFFF and prom_end == 0xFFFFFFFF: + out += f"DMA_TABLE_ENTRY_UNSET {filenames[i]}\n" + else: + out += f"DMA_TABLE_ENTRY {filenames[i]}\n" - out += """ + vrom_variables.append(("_" + filenames[i] + "SegmentRomStart", vrom_start)) + vrom_variables.append(("_" + filenames[i] + "SegmentRomEnd", vrom_end)) + + i += 1 + dmadata_entry = dmadata[i * 0x10 : (i + 1) * 0x10] + + out += """ .space 0x100 .section .bss .space 0x10 """ - with open(ASM_OUT + "/dmadata/dmadata.s", "w") as outfile: - outfile.write(out) + with open(ASM_OUT + "/dmadata/dmadata.s", "w") as outfile: + outfile.write(out) + + +def disassemble_segment(section): + if section[-1]["name"] == "[PADDING]": return - for section in segment[3]: - if (section[0] == section[1] and section[2] != 'reloc') or (section[2] != 'bss' and len(section[4]) == 0): - continue - print(f"Disassembling {segment[0]} .{section[2]}") - if section[2] == 'text': - data_regions = [] - if section[3] is not None: - for override_region in section[3]: - if override_region[2] == 'data': - data_regions.append((override_region[0], override_region[1])) + print(f"Disassembling {section[-1]['name']} .{section[2]}") - disassemble_text(section[4], section[0], data_regions, segment) - elif section[2] == 'data': - disassemble_data(section[4], section[0], section[1], segment) - elif section[2] == 'rodata': - disassemble_rodata(section[4], section[0], section[1], segment) - elif section[2] == 'bss': - disassemble_bss(section[0], section[1], segment) - elif section[2] == 'reloc': - words = as_word_list(section[4]) + if section[2] == "text": + fixup_text_symbols(section[4], section[0], data_regions, section[-1]) + elif section[2] == "data": + disassemble_data(section[4], section[0], section[1], section[-1]) + elif section[2] == "rodata": + disassemble_rodata(section[4], section[0], section[1], section[-1]) + elif section[2] == "bss": + disassemble_bss(section[0], section[1], section[-1]) + elif section[2] == "reloc": + words = as_word_list(section[4]) - # ("" if segment[2] != "overlay" else "overlays/") + - segment_dirname = segment[0] + segment_dirname = section[-1]["name"] - result = asm_header(".rodata") - result += f"\nglabel {segment[0]}_Reloc\n" + result = asm_header(".rodata") + result += f"\nglabel {section[-1]['name']}_Reloc\n" - lines = [words[i*8:(i+1)*8] for i in range(0, (len(words) // 8) + 1)] - for line in [line for line in lines if len(line) != 0]: - result += f" .word {', '.join([f'0x{word:08X}' for word in line])}\n" + lines = [words[i * 8 : (i + 1) * 8] for i in range(0, (len(words) // 8) + 1)] + for line in [line for line in lines if len(line) != 0]: + result += f" .word {', '.join([f'0x{word:08X}' for word in line])}\n" - os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) - with open(f"{DATA_OUT}/{segment_dirname}/{segment[0]}.reloc.s", "w") as outfile: - outfile.write(result) + os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) + with open( + f"{DATA_OUT}/{segment_dirname}/{section[-1]['name']}.reloc.s", "w" + ) as outfile: + outfile.write(result) -print("Disassembling Segments") - -disassemble_makerom(next(segment for segment in files_spec if segment[2] == 'makerom')) - -# Textual disassembly for each segment -with Pool(jobs) as p: - p.map(disassemble_segment, (segment for segment in files_spec if segment[2] != 'makerom')) - -print("Splitting text and migrating rodata") - -func_regex = re.compile(r'\n\nglabel \S+\n') -rodata_symbols_regex = re.compile(r'(?<=\n)glabel (.+)(?=\n)') -asm_symbols_regex = re.compile(r'%(?:lo|hi)\((.+?)\)') def rodata_block_size(block): def align(x, n): - while (x % n != 0): + while x % n != 0: x += 1 return x accumulator = 0 - for part in block.split(' */ .'): + for part in block.split(" */ ."): part = part.strip() - if part.startswith('# '): + if part.startswith("# "): continue - elif part.startswith('asciz '): - part = part[len('asciz '):] - string = part[1:-1].encode('utf-8', 'ignore').decode('unicode_escape') - accumulator += len(string.encode('euc-jp') + b'\x00') - elif part.startswith('ascii'): - part = part[len('ascii '):] - string = part[1:-1].encode('utf-8', 'ignore').decode('unicode_escape') - accumulator += len(string.encode('euc-jp')) - elif part.startswith('balign '): - part = part[len('balign '):] - accumulator = align(accumulator, int(part, 16 if part.startswith('0x') else 10)) - elif part.startswith('double '): - part = part[len('double '):] + elif part.startswith("asciz "): + part = part[len("asciz ") :] + string = part[1:-1].encode("utf-8", "ignore").decode("unicode_escape") + accumulator += len(string.encode("euc-jp") + b"\x00") + elif part.startswith("ascii"): + part = part[len("ascii ") :] + string = part[1:-1].encode("utf-8", "ignore").decode("unicode_escape") + accumulator += len(string.encode("euc-jp")) + elif part.startswith("balign "): + part = part[len("balign ") :] + accumulator = align( + accumulator, int(part, 16 if part.startswith("0x") else 10) + ) + elif part.startswith("double "): + part = part[len("double ") :] accumulator = align(accumulator, 8) - accumulator += 8 * (part.count(',') + 1) - elif part.startswith('float '): - part = part[len('float '):] + accumulator += 8 * (part.count(",") + 1) + elif part.startswith("float "): + part = part[len("float ") :] accumulator = align(accumulator, 4) - accumulator += 4 * (part.count(',') + 1) - elif part.startswith('word '): - part = part[len('word '):] + accumulator += 4 * (part.count(",") + 1) + elif part.startswith("word "): + part = part[len("word ") :] accumulator = align(accumulator, 4) - accumulator += 4 * (part.count(',') + 1) - elif part.startswith('half '): - part = part[len('half '):] + accumulator += 4 * (part.count(",") + 1) + elif part.startswith("half "): + part = part[len("half ") :] accumulator = align(accumulator, 2) - accumulator += 2 * (part.count(',') + 1) - elif part.startswith('byte '): - part = part[len('byte '):] - accumulator += 1 * (part.count(',') + 1) + accumulator += 2 * (part.count(",") + 1) + elif part.startswith("byte "): + part = part[len("byte ") :] + accumulator += 1 * (part.count(",") + 1) return accumulator + def late_rodata_size(blocks): return sum([rodata_block_size(block) for block in blocks]) + def text_block_size(asm): - return 4*len([line for line in asm.split("\n") if line.startswith("/*")]) + return 4 * len([line for line in asm.split("\n") if line.startswith("/*")]) + def rodata_syms(rodata): return re.findall(rodata_symbols_regex, rodata) + def rodata_blocks(rodata): return ["glabel" + b for b in rodata.split("glabel")[1:]] + def find_late_rodata_start(rodata): """ Returns the symbol that is the first late_rodata symbol, or None if there is no late_rodata @@ -1460,7 +2141,7 @@ def find_late_rodata_start(rodata): """ first = None - for sym,body in rodata: + for sym, body in rodata: if sym.startswith("jtbl_") and ".word L" in body: # jump tables are always late_rodata, so we can return early # floats and doubles are very rarely not late_rodata, this is mostly seen in libultra, so we cannot return early for those @@ -1472,25 +2153,281 @@ def find_late_rodata_start(rodata): # may be late_rodata, but we aren't sure yet # it is confirmed either by reaching the end or by finding a jumptable, and it is proven wrong if something that is not late_rodata occurs after it first = sym - elif (".asciz" in body or (".word " in body and ".float" not in body) or ".half " in body or ".byte " in body) and first is not None: + elif ( + ".asciz" in body + or (".word " in body and ".float" not in body) + or ".half " in body + or ".byte " in body + ) and first is not None: # reset first if something that is definitely not late_rodata is found # word and not float is due to some floats needing to be output as words either due to being a specific NaN value, or GAS can't convert it properly first = None # May still be None at this point, that just means there is no late_rodata return first + +# ==========================================# + +print("Setting Up") + +files_spec = None +with open("tools/disasm/files.txt", "r") as infile: + files_spec = ast.literal_eval(infile.read()) + +with open("tools/disasm/functions.txt", "r") as infile: + functions_ast = ast.literal_eval(infile.read()) + +with open("tools/disasm/variables.txt", "r") as infile: + variables_ast = ast.literal_eval(infile.read()) + +# We need to keep a full list of original file offsets to know where to split files later +full_file_list = {} +for segment in files_spec: + new = {} + for offset, name in segment[4].items(): + if name == "": + name = f"{segment[2]}_{offset:08X}" + new[offset] = name + full_file_list[segment[0]] = new + +if args.full: + for segment in files_spec: + for offset, name in segment[4].items(): + if name == "": + name = f"{segment[2]}_{offset:08X}" + segment[4][offset] = name +else: + # Prune + old_file_count = sum([len(f[4].keys()) for f in files_spec]) + + files_spec = discard_decomped_files(files_spec) + + new_file_count = sum([len(f[4].keys()) for f in files_spec]) + + pruned = old_file_count - new_file_count + print(f"Pruned {pruned}/{old_file_count} files ({pruned / old_file_count:.02%})") + +# Find floats, doubles, and strings +for var in sorted(variables_ast.keys()): + var_type = variables_ast[var][1] + + if var_type == "f64": + doubles.add(var) + elif var_type == "f32": + floats.add(var) + elif var_type == "char" and variables_ast[var][2].startswith("["): + strings.add(var) + +# Read in binary and relocation data for each segment +for seg, segment in enumerate(files_spec): + binary = None + with open(segment[1] + "/" + segment[0], "rb") as infile: + binary = bytes(infile.read()) + + if segment[2] == "overlay": + segment_start = list(segment[4])[0] # start addr of first file in segment + segment[3] = get_overlay_sections(segment_start, binary) + segment[4] = {} + for section in segment[3]: + segment[4].update({section[0]: segment[0]}) + else: + # start addr of first section of segment's sections + segment_start = segment[3][0][0] + # read section binary regions + for i, section in enumerate(segment[3]): + if section[2] == "bss": + continue + # section[4] + section.append( + binary[section[0] - segment_start : section[1] - segment_start] + ) + section.append(None) # section[5] + +print(f"Finding segment positions") + +for segment in files_spec: + if segment[2] == "makerom": + continue + + print(f"Finding segment positions in {segment[0]}") + + # vram segment start + if segment[3][0][0] not in variables_ast: + variables_ast.update( + {segment[3][0][0]: (f"_{segment[0]}SegmentStart", "u8", "[]", 0x1)} + ) + # vram segment end + if segment[3][-2][1] not in variables_ast: + variables_ast.update( + {segment[3][-2][1]: (f"_{segment[0]}SegmentEnd", "u8", "[]", 0x1)} + ) + +# Construct variable_addrs, now that variable_addrs is fully constructed +variable_addrs = sorted(variables_ast.keys()) + +# Flatten out files_spec so we can process everything evenly +# Otherwise the entire code and boot sections are done by a single thread +all_sections = [] +for segment in files_spec: + if segment[0] == "boot" or segment[0] == "code": + file_list = list(full_file_list[segment[0]]) + section_starts = [x[0] for x in segment[3]] + + for off, name in segment[4].items(): + # loop over the vram starts for this segment's sections to find where it belongs (text, data, etc) + for i, s in enumerate(section_starts): + if off < s: + break + else: + i = len(section_starts) + i -= 1 + + # Calculate the offset and size of this section relative to the section + data_offset = off - segment[3][i][0] + full_index = file_list.index(off) + if segment[0] == "code" and name == "buffers" and segment[3][i][2] == "bss": + # This is the end of code, hardcode it + data_size = 0x80800000 - file_list[full_index] + elif segment[0] == "boot" and name == "vimgr" and segment[3][i][2] == "bss": + # This is the end of boot, hardcode it + data_size = 0x800A5AC0 - file_list[full_index] + else: + data_size = file_list[full_index + 1] - file_list[full_index] + + # Create the section entry for this file + new_entry = [ + off, + off + data_size, + segment[3][i][2], + None, + segment[3][i][4][data_offset : data_offset + data_size] + if segment[3][i][2] not in ("bss") + else None, + None if segment[3][i][2] in ["text", "reloc", "data"] else [], + { + "name": name, + "type": segment[2], + "base": segment[3][0][0], + "syms": { + x: name for x in segment[4] if x >= off and x < off + data_size + }, + }, + ] + + all_sections.append(new_entry) + + # I don't remember what this is for but it's still needed + for i, entry in enumerate(segment[3]): + if segment[0] == "makerom" and i == 1: + segment[2] = "ipl3" + elif segment[0] == "makerom" and i == 2: + segment[2] = "entry" + entry.append( + { + "name": segment[0], + "type": segment[2], + "base": segment[3][0][0], + "syms": segment[4], + } + ) + + all_sections.extend(segment[3]) + +del files_spec[:] + +pool = get_context("fork").Pool(jobs) +# Find symbols for each segment +for section in all_sections: + if section[-1]["name"] == "makerom": + continue + + if section[2] == "text": + data_regions = [] + if section[3] is not None: + for override_region in section[3]: + if override_region[2] == "data": + data_regions.append((override_region[0], override_region[1])) + # try find a rodata section + for s in all_sections: + if ( + s[-1]["name"] == section[-1]["name"] + and s[2] == "rodata" + and s[0] != s[1] + ): + rodata_section = s + break + else: + rodata_section = None + pool.apply_async( + find_symbols_in_text, + args=(section, rodata_section if rodata_section else None, data_regions), + callback=update_symbols_from_dict, + ) + elif section[2] == "data": + pool.apply_async( + find_symbols_in_data, args=(section), callback=update_symbols_from_dict + ) + +pool.close() +pool.join() + +pool = get_context("fork").Pool(jobs) +for section in all_sections: + if section[-1]["type"] == "makerom": + continue + + if section[2] == "rodata": + pool.apply_async( + find_symbols_in_rodata, args=(section), callback=update_symbols_from_dict + ) + +pool.close() +pool.join() + +for section in all_sections: + if section[-1]["name"] == "makerom": + print(f"Disassembling makerom") + disassemble_makerom(section) + elif section[-1]["name"] == "dmadata": + print(f"Disassembling dmadata") + disassemble_dmadata(section) + +# Construct vrom_addrs, now that vrom_variables is fully constructed +vrom_addrs = {addr for _, addr in vrom_variables} + +# Textual disassembly for each segment +with get_context("fork").Pool(jobs) as p: + p.map( + disassemble_segment, + [ + sec + for sec in all_sections + if sec[-1]["name"] not in ("boot", "code", "makerom", "dmadata") + ], + ) + +print("Splitting text and migrating rodata") + +func_regex = re.compile(r"\n\nglabel \S+\n") +rodata_symbols_regex = re.compile(r"(?<=\n)glabel (.+)(?=\n)") +asm_symbols_regex = re.compile(r"%(?:lo|hi)\((.+?)\)") + # Split files and migrate rodata that should be migrated -for root,dirs,files in os.walk(ASM_OUT): +for root, dirs, files in os.walk(ASM_OUT): for f in files: if "non_matchings" in root: continue - asm_path = os.path.join(root,f) - rodata_path = asm_path.replace(ASM_OUT + "overlays/", DATA_OUT).replace(ASM_OUT, DATA_OUT).replace(".text.s", ".rodata.s") + asm_path = os.path.join(root, f) + rodata_path = ( + asm_path.replace(ASM_OUT + "overlays/", DATA_OUT) + .replace(ASM_OUT, DATA_OUT) + .replace(".text.s", ".rodata.s") + ) print(asm_path) asm = "" - with open(asm_path,"r") as infile: + with open(asm_path, "r") as infile: asm = infile.read() rodata = "" @@ -1505,15 +2442,21 @@ for root,dirs,files in os.walk(ASM_OUT): first_late_rodata = find_late_rodata_start(rodata_info) rdata_info = [] late_rodata_info = [] - target = rdata_info # first populate rdata - for sym,block in rodata_info: - if sym == first_late_rodata: # now populate late_rodata, if there is any + target = rdata_info # first populate rdata + for sym, block in rodata_info: + # now populate late_rodata, if there is any + if sym == first_late_rodata: target = late_rodata_info - target.append((sym,block)) + target.append((sym, block)) # print([(sym,block.split("\n")[1:]) for sym,block in zip(rdata_syms,rdata_blocks)]) - function_info = list(zip([s.replace("glabel","").strip() for s in func_regex.findall(asm)], func_regex.split(asm)[1:])) + function_info = list( + zip( + [s.replace("glabel", "").strip() for s in func_regex.findall(asm)], + func_regex.split(asm)[1:], + ) + ) rdata_map = {} late_rodata_map = {} @@ -1522,18 +2465,20 @@ for root,dirs,files in os.walk(ASM_OUT): if rodata != "": last_fn = None - referenced_in = {} # key=rodata label , value=function label + referenced_in = {} # key=rodata label , value=function label - for sym,_ in rodata_info: - all_refs = [label for label,body in function_info if "%lo(" + sym + ")" in body] + for sym, _ in rodata_info: + all_refs = [ + label for label, body in function_info if "%lo(" + sym + ")" in body + ] # ignore multiple refs, take only the first - referenced_in.update({ sym : all_refs[0] if len(all_refs) != 0 else None }) + referenced_in.update({sym: all_refs[0] if len(all_refs) != 0 else None}) def do_splits(out_dict, info): first = True last_ref = None cr = None - for sym,block in info: + for sym, block in info: ref = referenced_in[sym] if first: cr = ref or sym @@ -1545,11 +2490,11 @@ for root,dirs,files in os.walk(ASM_OUT): elif last_ref is not None: # new GLOBAL_ASM cr = sym - + # add to output if cr not in out_dict.keys(): - out_dict.update({cr : []}) - out_dict[cr].append((sym,block)) + out_dict.update({cr: []}) + out_dict[cr].append((sym, block)) # setup next iter last_ref = ref @@ -1559,7 +2504,9 @@ for root,dirs,files in os.walk(ASM_OUT): do_splits(late_rodata_map, late_rodata_info) # all output files, order is irrelevant at this point - all_output = set([label for label,_ in function_info]).union(set(rdata_map.keys()),set(late_rodata_map.keys())) + all_output = set([label for label, _ in function_info]).union( + set(rdata_map.keys()), set(late_rodata_map.keys()) + ) # pass 2 to output splits for label in all_output: @@ -1567,7 +2514,7 @@ for root,dirs,files in os.walk(ASM_OUT): text_out = "" rodata_out = "" - + if fn_body is not None: text_out = "glabel " + label.strip() + "\n" + fn_body.strip() + "\n" @@ -1578,43 +2525,81 @@ for root,dirs,files in os.walk(ASM_OUT): # check for late_rodata_alignment late_rodata_alignment = "" if fn_body is not None and late_rodata is not None: - ratio = late_rodata_size([block for _,block in late_rodata]) / text_block_size(fn_body) - if ratio > 1./3: + ratio = late_rodata_size( + [block for _, block in late_rodata] + ) / text_block_size(fn_body) + if ratio > 1.0 / 3: # print(f"{label} : {ratio}") # TODO hack: getting the address from a comment first_block_split = late_rodata[0][1].split(" */ .") vaddr = None - if first_block_split[1].startswith("float") or first_block_split[1].startswith("double"): + if first_block_split[1].startswith( + "float" + ) or first_block_split[1].startswith("double"): vaddr = first_block_split[0].split(" ")[-2] else: vaddr = first_block_split[0].split(" ")[-1] assert vaddr is not None - vaddr = int(vaddr,16) - if vaddr not in [0x801E0E28, 0x80C1C2B0, 0x80AA7820, 0x80AA3CC0, - 0x80AA418C, 0x80BE0160, 0x80B591D8, 0x80B59610, - 0x80B59780, 0x80964E00, 0x80964F10, 0x80BB40A0, - 0x80952038, 0x80AFB920, 0x80AFBBFC, 0x80AFBE28, - 0x80983320]: # hacks for especially badly behaved rodata, TODO these are ALL jumptables associated with - # comparatively tiny functions, can we swat these programmatically? + vaddr = int(vaddr, 16) + if vaddr not in [ + 0x801E0E28, + 0x80C1C2B0, + 0x80AA7820, + 0x80AA3CC0, + 0x80AA418C, + 0x80BE0160, + 0x80B591D8, + 0x80B59610, + 0x80B59780, + 0x80964E00, + 0x80964F10, + 0x80BB40A0, + 0x80952038, + 0x80AFB920, + 0x80AFBBFC, + 0x80AFBE28, + 0x80983320, + ]: + # hacks for especially badly behaved rodata, TODO these are ALL jumptables associated with + # comparatively tiny functions, can we swat these programmatically? late_rodata_alignment = f".late_rodata_alignment {'8' if vaddr % 8 == 0 else '4'}\n" rdata_out = "" if rdata is not None: - rdata_out = ".rdata\n" + "".join([block for _,block in rdata]) + rdata_out = ".rdata\n" + "".join([block for _, block in rdata]) late_rodata_out = "" if late_rodata is not None: - late_rodata_out = ".late_rodata\n" + late_rodata_alignment + "".join([block for _,block in late_rodata]) + late_rodata_out = ( + ".late_rodata\n" + + late_rodata_alignment + + "".join([block for _, block in late_rodata]) + ) - rodata_out = rdata_out + late_rodata_out + ("\n.text\n" if ((rdata is not None or late_rodata is not None) and fn_body is not None) else "") + rodata_out = ( + rdata_out + + late_rodata_out + + ( + "\n.text\n" + if ( + (rdata is not None or late_rodata is not None) + and fn_body is not None + ) + else "" + ) + ) all_out = rodata_out + text_out # write it out - out_path = root.replace(ASM_OUT, f"{ASM_OUT}/non_matchings/") + "/" + ((f.replace(".text.s","") + "/") if "overlays" not in root else "") + out_path = ( + root.replace(ASM_OUT, f"{ASM_OUT}/non_matchings/") + + "/" + + ((f.replace(".text.s", "") + "/") if "overlays" not in root else "") + ) os.makedirs(out_path, exist_ok=True) with open(out_path + label + ".s", "w") as outfile: outfile.write(all_out.strip() + "\n") - + # remove rodata and unsplit file # TODO diff --git a/tools/disasm/dma_filenames.txt b/tools/disasm/dma_filenames.txt index ecd43c82be..e9a743615f 100644 --- a/tools/disasm/dma_filenames.txt +++ b/tools/disasm/dma_filenames.txt @@ -37,7 +37,7 @@ 'ovl_file_choose', 'ovl_daytelop', 'ovl_kaleido_scope', - 'ovl_Player_Actor', + 'ovl_player_actor', 'ovl_En_Test', 'ovl_En_GirlA', 'ovl_En_Part', diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index 52d498397e..175365f8e8 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -378,7 +378,7 @@ 0x800EA060 : "z_demo", 0x800EE320 : "z_draw", 0x800EFE60 : "z_eff_footmark", - 0x800F0390 : "code_800F0390", + 0x800F0390 : "z_sound_source", 0x800F05C0 : "z_elf_message", 0x800F07C0 : "z_en_hy", 0x800F1250 : "z_face_reaction", @@ -483,7 +483,7 @@ 0x8018B0F0 : "audio_heap", 0x8018EB60 : "audio_load", 0x80192BE0 : "code_80192BE0", - 0x80194710 : "code_80194710", + 0x80194710 : "audio_dcache", 0x80194790 : "code_80194790", 0x80194930 : "audio_playback", 0x80196A00 : "audio_effects", @@ -511,6 +511,7 @@ 0x801AE330 : "", 0x801AE3A0 : "z_effect_soft_sprite", 0x801AE3B0 : "z_effect_soft_sprite_old_init", + 0x801AE4A0 : "z_effect_soft_sprite_dlftbls", 0x801AE8F0 : "flg_set_table", 0x801AEC70 : "flg_set", 0x801AEC80 : "z_actor", @@ -678,6 +679,7 @@ # .bss section 0x801E3FA0 : "code_801E3FA0", 0x801E3FB0 : "z_effect", + 0x801ED890 : "flg_set", 0x801ED8A0 : "z_actor", 0x801ED930 : "z_actor_dlftbls", 0x801ED950 : "z_bgcheck", @@ -740,7 +742,7 @@ ['ovl_file_choose', 'baserom/', 'overlay', [], { 0x80804010 : "ovl_file_choose" }], ['ovl_daytelop', 'baserom/', 'overlay', [], { 0x80814EB0 : "ovl_daytelop" }], ['ovl_kaleido_scope', 'baserom/', 'overlay', [], { 0x808160A0 : "ovl_kaleido_scope" }], - ['ovl_Player_Actor', 'baserom/', 'overlay', [], { 0x8082DA90 : "ovl_Player_Actor" }], + ['ovl_player_actor', 'baserom/', 'overlay', [], { 0x8082DA90 : "ovl_player_actor" }], ['ovl_En_Test', 'baserom/', 'overlay', [], { 0x80862B70 : "ovl_En_Test" }], ['ovl_En_GirlA', 'baserom/', 'overlay', [], { 0x80863870 : "ovl_En_GirlA" }], ['ovl_En_Part', 'baserom/', 'overlay', [], { 0x80865370 : "ovl_En_Part" }], diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index f6d6cec53b..7e88356aa8 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -204,7 +204,7 @@ 0x80086E20:("SystemArena_Realloc",), 0x80086E50:("SystemArena_Free",), 0x80086E78:("SystemArena_Calloc",), - 0x80086ECC:("SystemArena_AnalyzeArena",), + 0x80086ECC:("SystemArena_GetSizes",), 0x80086F04:("SystemArena_CheckArena",), 0x80086F28:("SystemArena_InitArena",), 0x80086F58:("SystemArena_Cleanup",), @@ -222,14 +222,14 @@ 0x800871B4:("ArenaImpl_Unlock",), 0x800871DC:("ArenaImpl_GetLastBlock",), 0x8008720C:("__osMallocInit",), - 0x8008725C:("__osMallocAddBlock",), + 0x8008725C:("__osMallocAddHeap",), 0x800872FC:("__osMallocCleanup",), 0x8008731C:("__osMallocIsInitalized",), 0x80087324:("__osMalloc",), 0x80087408:("__osMallocR",), 0x800874EC:("__osFree",), 0x800875E4:("__osRealloc",), - 0x80087714:("__osAnalyzeArena",), + 0x80087714:("__osGetSizes",), 0x800877C4:("__osCheckArena",), 0x80087830:("proutSprintf",), 0x80087854:("vsprintf",), @@ -511,28 +511,28 @@ 0x800A8150:("func_800A8150",), 0x800A817C:("func_800A817C",), 0x800A81A4:("func_800A81A4",), - 0x800A81F0:("func_800A81F0",), - 0x800A8514:("func_800A8514",), - 0x800A8558:("EffectBlure_Initcommon",), + 0x800A81F0:("EffectBlure_AddVertex",), + 0x800A8514:("EffectBlure_AddSpace",), + 0x800A8558:("EffectBlure_InitElements",), 0x800A8610:("EffectBlure_Init1",), 0x800A8720:("EffectBlure_Init2",), 0x800A8854:("EffectBlure_Destroy",), 0x800A8860:("EffectBlure_Update",), - 0x800A8C78:("func_800A8C78",), - 0x800A8DE8:("func_800A8DE8",), - 0x800A92FC:("func_800A92FC",), - 0x800A9330:("func_800A9330",), - 0x800A9804:("func_800A9804",), - 0x800AA190:("func_800AA190",), - 0x800AA460:("func_800AA460",), - 0x800AA498:("func_800AA498",), - 0x800AA700:("func_800AA700",), - 0x800AABE0:("func_800AABE0",), + 0x800A8C78:("EffectBlure_UpdateFlags",), + 0x800A8DE8:("EffectBlure_GetComputedValues",), + 0x800A92FC:("EffectBlure_SetupSmooth",), + 0x800A9330:("EffectBlure_DrawElemNoInterpolation",), + 0x800A9804:("EffectBlure_DrawElemHermiteInterpolation",), + 0x800AA190:("EffectBlure_DrawSmooth",), + 0x800AA460:("EffectBlure_SetupSimple",), + 0x800AA498:("EffectBlure_SetupSimpleAlt",), + 0x800AA700:("EffectBlure_DrawSimpleVertices",), + 0x800AABE0:("EffectBlure_DrawSimple",), 0x800AB0EC:("EffectBlure_Draw",), 0x800AB5D0:("EffectShieldParticle_Init",), 0x800AB808:("EffectShieldParticle_Destroy",), 0x800AB894:("EffectShieldParticle_Update",), - 0x800AB9F8:("EffectShieldParticle_CalculateColors",), + 0x800AB9F8:("EffectShieldParticle_GetColors",), 0x800AC718:("EffectShieldParticle_Draw",), 0x800ACBF0:("EffectSpark_Init",), 0x800ACFCC:("EffectSpark_Destroy",), @@ -546,15 +546,15 @@ 0x800AE8EC:("func_800AE8EC",), 0x800AE930:("func_800AE930",), 0x800AEF44:("func_800AEF44",), - 0x800AEF70:("EffectTireMark_InitParticle",), + 0x800AEF70:("EffectTireMark_InitElement",), 0x800AEFA0:("EffectTireMark_Init",), 0x800AF044:("EffectTireMark_Destroy",), 0x800AF050:("EffectTireMark_Update",), - 0x800AF284:("EffectTireMark_InitVertices",), + 0x800AF284:("EffectTireMark_SetVertices",), 0x800AF310:("EffectTireMark_Draw",), - 0x800AF710:("Effect_GetContext",), - 0x800AF720:("Effect_GetParams",), - 0x800AF87C:("Effect_InitCommon",), + 0x800AF710:("Effect_GetGlobalCtx",), + 0x800AF720:("Effect_GetByIndex",), + 0x800AF87C:("Effect_InitStatus",), 0x800AF890:("Effect_Init",), 0x800AF960:("Effect_Add",), 0x800AFB24:("Effect_DrawAll",), @@ -659,42 +659,42 @@ 0x800B3AD0:("Actor_PrintLists",), 0x800B3BA4:("ActorShape_Init",), 0x800B3BC8:("ActorShadow_Draw",), - 0x800B3FC0:("func_800B3FC0",), - 0x800B4024:("func_800B4024",), - 0x800B4088:("func_800B4088",), - 0x800B40B8:("func_800B40B8",), - 0x800B40E0:("func_800B40E0",), - 0x800B42F8:("func_800B42F8",), - 0x800B4A98:("func_800B4A98",), + 0x800B3FC0:("ActorShadow_DrawCircle",), + 0x800B4024:("ActorShadow_DrawSquare",), + 0x800B4088:("ActorShadow_DrawWhiteCircle",), + 0x800B40B8:("ActorShadow_DrawHorse",), + 0x800B40E0:("ActorShadow_DrawFoot",), + 0x800B42F8:("ActorShadow_DrawFeet",), + 0x800B4A98:("Actor_SetFeetPos",), 0x800B4AEC:("func_800B4AEC",), 0x800B4B50:("func_800B4B50",), - 0x800B4EDC:("func_800B4EDC",), - 0x800B4F40:("func_800B4F40",), + 0x800B4EDC:("Actor_GetProjectedPos",), + 0x800B4F40:("Target_SetPos",), 0x800B4F78:("func_800B4F78",), - 0x800B5040:("func_800B5040",), + 0x800B5040:("Target_SetColors",), 0x800B51A4:("Actor_TargetContextInit",), - 0x800B5208:("func_800B5208",), + 0x800B5208:("Actor_DrawZTarget",), 0x800B5814:("func_800B5814",), 0x800B5BB0:("Flags_GetSwitch",), - 0x800B5BF4:("Actor_SetSwitchFlag",), - 0x800B5C34:("Actor_UnsetSwitchFlag",), - 0x800B5C78:("Actor_GetChestFlag",), - 0x800B5C90:("Actor_SetChestFlag",), - 0x800B5CAC:("Actor_SetAllChestFlag",), - 0x800B5CB8:("Actor_GetAllChestFlag",), - 0x800B5CC4:("Actor_GetRoomCleared",), - 0x800B5CDC:("Actor_SetRoomCleared",), - 0x800B5CF8:("Actor_UnsetRoomCleared",), - 0x800B5D18:("Actor_GetRoomClearedTemp",), - 0x800B5D30:("Actor_SetRoomClearedTemp",), - 0x800B5D4C:("Actor_UnsetRoomClearedTemp",), - 0x800B5D6C:("Actor_GetCollectibleFlag",), - 0x800B5DB0:("Actor_SetCollectibleFlag",), - 0x800B5DF0:("Actor_TitleCardContextInit",), - 0x800B5E0C:("Actor_TitleCardCreate",), - 0x800B5E50:("Actor_Nop800B5E50",), - 0x800B5E68:("Actor_TitleCardUpdate",), - 0x800B5F24:("Actor_TitleCardDraw",), + 0x800B5BF4:("Flags_SetSwitch",), + 0x800B5C34:("Flags_UnsetSwitch",), + 0x800B5C78:("Flags_GetTreasure",), + 0x800B5C90:("Flags_SetTreasure",), + 0x800B5CAC:("Flags_SetAllTreasure",), + 0x800B5CB8:("Flags_GetAllTreasure",), + 0x800B5CC4:("Flags_GetClear",), + 0x800B5CDC:("Flags_SetClear",), + 0x800B5CF8:("Flags_UnsetClear",), + 0x800B5D18:("Flags_GetClearTemp",), + 0x800B5D30:("Flags_SetClearTemp",), + 0x800B5D4C:("Flags_UnsetClearTemp",), + 0x800B5D6C:("Flags_GetCollectible",), + 0x800B5DB0:("Flags_SetCollectible",), + 0x800B5DF0:("TitleCard_ContextInit",), + 0x800B5E0C:("TitleCard_InitBossName",), + 0x800B5E50:("TitleCard_InitPlaceName",), + 0x800B5E68:("TitleCard_Update",), + 0x800B5F24:("TitleCard_Draw",), 0x800B6434:("func_800B6434",), 0x800B6468:("func_800B6468",), 0x800B6474:("func_800B6474",), @@ -704,24 +704,24 @@ 0x800B6608:("func_800B6608",), 0x800B6680:("func_800B6680",), 0x800B670C:("Actor_MarkForDeath",), - 0x800B672C:("Actor_InitCurrPosition",), - 0x800B675C:("Actor_SetHeight",), - 0x800B67A0:("Actor_SetRotationFromDrawRotation",), - 0x800B67C0:("Actor_InitDrawRotation",), + 0x800B672C:("Actor_SetWorldToHome",), + 0x800B675C:("Actor_SetFocus",), + 0x800B67A0:("Actor_SetWorldRotToShape",), + 0x800B67C0:("Actor_SetShapeRotToWorld",), 0x800B67E0:("Actor_SetScale",), - 0x800B67FC:("Actor_SetObjectSegment",), - 0x800B6834:("Actor_InitToDefaultValues",), - 0x800B6948:("Actor_FiniActor",), + 0x800B67FC:("Actor_SetObjectDependency",), + 0x800B6834:("Actor_Init",), + 0x800B6948:("Actor_Destroy",), 0x800B6988:("Actor_SetMovementScale",), - 0x800B69AC:("Actor_ApplyMovement",), - 0x800B6A10:("Actor_SetVelocityYRotationAndGravity",), - 0x800B6A88:("Actor_SetVelocityAndMoveYRotationAndGravity",), - 0x800B6AB4:("Actor_SetVelocityXYRotation",), - 0x800B6B24:("Actor_SetVelocityAndMoveXYRotation",), - 0x800B6B50:("Actor_SetVelocityXYRotationReverse",), - 0x800B6BD8:("Actor_SetVelocityAndMoveXYRotationReverse",), - 0x800B6C04:("func_800B6C04",), - 0x800B6C58:("func_800B6C58",), + 0x800B69AC:("Actor_UpdatePos",), + 0x800B6A10:("Actor_UpdateVelocityWithGravity",), + 0x800B6A88:("Actor_MoveWithGravity",), + 0x800B6AB4:("Actor_UpdateVelocityWithoutGravity",), + 0x800B6B24:("Actor_MoveWithoutGravity",), + 0x800B6B50:("Actor_UpdateVelocityWithoutGravityReverse",), + 0x800B6BD8:("Actor_MoveWithoutGravityReverse",), + 0x800B6C04:("Actor_SetSpeeds",), + 0x800B6C58:("Actor_UpdatePosFromSkelAnime",), 0x800B6CD4:("Actor_YawBetweenActors",), 0x800B6D00:("Actor_YawBetweenActorsTop",), 0x800B6D2C:("Actor_YawToPoint",), @@ -732,76 +732,76 @@ 0x800B6DF8:("Actor_DistanceToPoint",), 0x800B6E1C:("Actor_XZDistanceBetweenActors",), 0x800B6E48:("Actor_XZDistanceToPoint",), - 0x800B6E6C:("Actor_CalcOffsetOrientedToDrawRotation",), - 0x800B6F0C:("Actor_YDistance",), + 0x800B6E6C:("Actor_OffsetOfPointInActorCoords",), + 0x800B6F0C:("Actor_HeightDiff",), 0x800B6F20:("func_800B6F20",), - 0x800B6FC8:("func_800B6FC8",), - 0x800B7090:("func_800B7090",), + 0x800B6FC8:("Player_GetHeight",), + 0x800B7090:("Player_GetRunSpeedLimit",), 0x800B7118:("func_800B7118",), 0x800B7128:("func_800B7128",), 0x800B715C:("func_800B715C",), - 0x800B7170:("func_800B7170",), - 0x800B71DC:("func_800B71DC",), + 0x800B7170:("Actor_SetCameraHorseSetting",), + 0x800B71DC:("Actor_MountHorse",), 0x800B7200:("func_800B7200",), 0x800B722C:("func_800B722C",), 0x800B724C:("func_800B724C",), 0x800B7298:("func_800B7298",), 0x800B72E0:("func_800B72E0",), 0x800B72F8:("func_800B72F8",), - 0x800B7320:("Actor_IsLinkFacingActor",), - 0x800B7378:("Actor_IsActorFacedByActor",), - 0x800B73E0:("Actor_IsActorFacingLink",), - 0x800B742C:("Actor_IsActorFacingActor",), - 0x800B748C:("Actor_IsActorFacingLinkAndWithinRange",), - 0x800B750C:("Actor_IsActorFacingActorAndWithinRange",), + 0x800B7320:("Player_IsFacingActor",), + 0x800B7378:("Actor_ActorBIsFacingActorA",), + 0x800B73E0:("Actor_IsFacingPlayer",), + 0x800B742C:("Actor_ActorAIsFacingActorB",), + 0x800B748C:("Actor_IsFacingAndNearPlayer",), + 0x800B750C:("Actor_ActorAIsFacingAndNearActorB",), 0x800B75A0:("func_800B75A0",), 0x800B761C:("func_800B761C",), 0x800B7678:("func_800B7678",), 0x800B78B8:("Actor_UpdateBgCheckInfo",), - 0x800B7E04:("func_800B7E04",), - 0x800B7FE0:("func_800B7FE0",), - 0x800B8018:("func_800B8018",), + 0x800B7E04:("Hilite_Draw",), + 0x800B7FE0:("Hilite_DrawOpa",), + 0x800B8018:("Hilite_DrawXlu",), 0x800B8050:("func_800B8050",), 0x800B8118:("func_800B8118",), - 0x800B81E0:("func_800B81E0",), - 0x800B8214:("func_800B8214",), - 0x800B8248:("func_800B8248",), + 0x800B81E0:("Actor_GetFocus",), + 0x800B8214:("Actor_GetWorld",), + 0x800B8248:("Actor_GetWorldPosShapeRot",), 0x800B82EC:("func_800B82EC",), 0x800B83BC:("func_800B83BC",), 0x800B83F8:("func_800B83F8",), - 0x800B84D0:("func_800B84D0",), + 0x800B84D0:("Actor_ProcessTalkRequest",), 0x800B8500:("func_800B8500",), 0x800B85E0:("func_800B85E0",), 0x800B8614:("func_800B8614",), 0x800B863C:("func_800B863C",), - 0x800B867C:("func_800B867C",), - 0x800B86C8:("func_800B86C8",), - 0x800B8708:("func_800B8708",), + 0x800B867C:("Actor_TextboxIsClosing",), + 0x800B86C8:("Actor_ChangeFocus",), + 0x800B8708:("Player_GetExchangeItemId",), 0x800B8718:("func_800B8718",), 0x800B874C:("func_800B874C",), 0x800B8804:("func_800B8804",), 0x800B882C:("func_800B882C",), 0x800B886C:("func_800B886C",), - 0x800B8898:("func_800B8898",), + 0x800B8898:("Actor_GetScreenPos",), 0x800B8934:("func_800B8934",), 0x800B89F8:("Actor_HasParent",), - 0x800B8A1C:("func_800B8A1C",), - 0x800B8B84:("func_800B8B84",), - 0x800B8BB0:("func_800B8BB0",), - 0x800B8BD0:("func_800B8BD0",), + 0x800B8A1C:("Actor_PickUp",), + 0x800B8B84:("Actor_PickUpNearby",), + 0x800B8BB0:("Actor_LiftActor",), + 0x800B8BD0:("Actor_PickUpFar",), 0x800B8BFC:("Actor_HasNoParent",), 0x800B8C20:("func_800B8C20",), 0x800B8C50:("func_800B8C50",), - 0x800B8C78:("func_800B8C78",), - 0x800B8C9C:("func_800B8C9C",), - 0x800B8CEC:("func_800B8CEC",), + 0x800B8C78:("Actor_HasRider",), + 0x800B8C9C:("Actor_SetRideActor",), + 0x800B8CEC:("Actor_HasNoRider",), 0x800B8D10:("func_800B8D10",), 0x800B8D50:("func_800B8D50",), 0x800B8D98:("func_800B8D98",), 0x800B8DD4:("func_800B8DD4",), 0x800B8E1C:("func_800B8E1C",), 0x800B8E58:("func_800B8E58",), - 0x800B8EC8:("Audio_PlayActorSound2",), + 0x800B8EC8:("Actor_PlaySfxAtPos",), 0x800B8EF4:("func_800B8EF4",), 0x800B8F98:("func_800B8F98",), 0x800B8FC0:("func_800B8FC0",), @@ -813,11 +813,11 @@ 0x800B90AC:("func_800B90AC",), 0x800B90F4:("func_800B90F4",), 0x800B9120:("func_800B9120",), - 0x800B9170:("Actor_Init",), - 0x800B9334:("func_800B9334",), + 0x800B9170:("Actor_InitContext",), + 0x800B9334:("Actor_SpawnSetupActors",), 0x800B948C:("Actor_UpdateActor",), 0x800B9780:("Actor_UpdateAll",), - 0x800B9A04:("Actor_DrawActor",), + 0x800B9A04:("Actor_Draw",), 0x800B9D1C:("func_800B9D1C",), 0x800B9E3C:("Actor_DrawAllSetup",), 0x800B9E4C:("Actor_RecordUndrawnActor",), @@ -829,17 +829,17 @@ 0x800BA6FC:("func_800BA6FC",), 0x800BA798:("func_800BA798",), 0x800BA8B8:("func_800BA8B8",), - 0x800BA9B4:("func_800BA9B4",), - 0x800BAAB4:("Actor_InsertIntoTypeList",), - 0x800BAB24:("Actor_RemoveFromTypeList",), + 0x800BA9B4:("Actor_CleanupContext",), + 0x800BAAB4:("Actor_AddToCategory",), + 0x800BAB24:("Actor_RemoveFromCategory",), 0x800BABFC:("Actor_FreeOverlay",), 0x800BAC60:("Actor_Spawn",), 0x800BACD4:("Actor_LoadOverlay",), 0x800BAE14:("Actor_SpawnAsChildAndCutscene",), 0x800BB0C0:("Actor_SpawnAsChild",), 0x800BB140:("Actor_SpawnTransitionActors",), - 0x800BB2D0:("func_800BB2D0",), - 0x800BB498:("func_800BB498",), + 0x800BB2D0:("Actor_SpawnEntry",), + 0x800BB498:("Actor_Delete",), 0x800BB59C:("func_800BB59C",), 0x800BB604:("func_800BB604",), 0x800BB8EC:("func_800BB8EC",), @@ -847,24 +847,24 @@ 0x800BBAC0:("func_800BBAC0",), 0x800BBB74:("func_800BBB74",), 0x800BBC20:("func_800BBC20",), - 0x800BBCEC:("func_800BBCEC",), - 0x800BBDAC:("func_800BBDAC",), + 0x800BBCEC:("Actor_SpawnBodyParts",), + 0x800BBDAC:("Actor_SpawnFloorDustRing",), 0x800BBFB0:("func_800BBFB0",), 0x800BC154:("func_800BC154",), 0x800BC188:("func_800BC188",), 0x800BC1B4:("func_800BC1B4",), 0x800BC270:("func_800BC270",), 0x800BC444:("func_800BC444",), - 0x800BC4EC:("func_800BC4EC",), - 0x800BC5B8:("func_800BC5B8",), - 0x800BC5EC:("func_800BC5EC",), + 0x800BC4EC:("Actor_TestFloorInDirection",), + 0x800BC5B8:("Actor_IsTargeted",), + 0x800BC5EC:("Actor_OtherIsTargeted",), 0x800BC620:("func_800BC620",), 0x800BC770:("func_800BC770",), 0x800BC7D8:("func_800BC7D8",), 0x800BC848:("func_800BC848",), - 0x800BC8B8:("func_800BC8B8",), - 0x800BCB50:("func_800BCB50",), - 0x800BCB70:("func_800BCB70",), + 0x800BC8B8:("Actor_DrawDoorLock",), + 0x800BCB50:("Actor_SpawnShieldParticlesMetal",), + 0x800BCB70:("Actor_SetColorFilter",), 0x800BCBF4:("func_800BCBF4",), 0x800BCC68:("func_800BCC68",), 0x800BCCDC:("func_800BCCDC",), @@ -877,16 +877,16 @@ 0x800BD9E0:("func_800BD9E0",), 0x800BDAA0:("func_800BDAA0",), 0x800BDB6C:("func_800BDB6C",), - 0x800BDC5C:("func_800BDC5C",), + 0x800BDC5C:("Actor_ChangeAnimation",), 0x800BDCF4:("func_800BDCF4",), 0x800BDFB0:("Actor_Noop",), - 0x800BDFC0:("func_800BDFC0",), - 0x800BE03C:("func_800BE03C",), - 0x800BE0B8:("func_800BE0B8",), + 0x800BDFC0:("Gfx_DrawDListOpa",), + 0x800BE03C:("Gfx_DrawDListXlu",), + 0x800BE0B8:("Actor_FindNearby",), 0x800BE184:("func_800BE184",), 0x800BE22C:("Actor_ApplyDamage",), - 0x800BE258:("func_800BE258",), - 0x800BE2B8:("func_800BE2B8",), + 0x800BE258:("Actor_SetDropFlag",), + 0x800BE2B8:("Actor_SetDropFlagJntSph",), 0x800BE33C:("func_800BE33C",), 0x800BE3D0:("func_800BE3D0",), 0x800BE504:("func_800BE504",), @@ -894,7 +894,7 @@ 0x800BE5CC:("func_800BE5CC",), 0x800BE63C:("func_800BE63C",), 0x800BE680:("func_800BE680",), - 0x800BF7CC:("func_800BF7CC",), + 0x800BF7CC:("Actor_SpawnIceEffects",), 0x800BF9A0:("ActorOverlayTable_FaultPrint",), 0x800BFA78:("ActorOverlayTable_FaultAddrConv",), 0x800BFAE8:("ActorOverlayTable_Init",), @@ -1268,7 +1268,7 @@ 0x800DE9B0:("Camera_Update",), 0x800DF498:("func_800DF498",), 0x800DF4D0:("Camera_SetMode",), - 0x800DF840:("func_800DF840",), + 0x800DF840:("Camera_ChangeMode",), 0x800DF86C:("func_800DF86C",), 0x800DF8EC:("func_800DF8EC",), 0x800DFAC8:("func_800DFAC8",), @@ -1610,11 +1610,11 @@ 0x800EFF04:("EffFootmark_Add",), 0x800F00BC:("EffFootmark_Update",), 0x800F01C8:("EffFootmark_Draw",), - 0x800F0390:("func_800F0390",), - 0x800F03C0:("func_800F03C0",), - 0x800F048C:("func_800F048C",), - 0x800F0568:("Audio_PlaySoundAtPosition",), - 0x800F0590:("func_800F0590",), + 0x800F0390:("SoundSource_InitAll",), + 0x800F03C0:("SoundSource_UpdateAll",), + 0x800F048C:("SoundSource_Add",), + 0x800F0568:("SoundSource_PlaySfxAtFixedWorldPos",), + 0x800F0590:("SoundSource_PlaySfxEachFrameAtFixedWorldPos",), 0x800F05C0:("ElfMessage_GetFirstCycleHint",), 0x800F07C0:("EnHy_ChangeAnim",), 0x800F0888:("EnHy_FindNearestDoor",), @@ -1700,8 +1700,8 @@ 0x800F470C:("Jpeg_Decode",), 0x800F4A10:("func_800F4A10",), 0x800F4C0C:("func_800F4C0C",), - 0x800F4E20:("func_800F4E20",), - 0x800F4F28:("func_800F4F28",), + 0x800F4E20:("KaleidoSetup_Init",), + 0x800F4F28:("KaleidoSetup_Destroy",), 0x800F4F40:("Font_LoadChar",), 0x800F4F54:("Font_LoadCharNES",), 0x800F4FC0:("Font_LoadMessageBoxEndIcon",), @@ -1847,7 +1847,7 @@ 0x8010007C:("Color_RGBA8_Copy",), 0x801000A4:("func_801000A4",), 0x801000CC:("func_801000CC",), - 0x801000F4:("func_801000F4",), + 0x801000F4:("Lib_PlaySfxAtPos",), 0x8010011C:("Lib_Vec3f_TranslateAndRotateY",), 0x801001B8:("Lib_LerpRGB",), 0x80100448:("Math_Vec3f_StepTo",), @@ -2191,7 +2191,7 @@ 0x8012301C:("func_8012301C",), 0x80123140:("func_80123140",), 0x80123358:("func_80123358",), - 0x801233E4:("func_801233E4",), + 0x801233E4:("Player_InCsMode",), 0x80123420:("func_80123420",), 0x80123434:("func_80123434",), 0x80123448:("func_80123448",), @@ -2229,7 +2229,7 @@ 0x801241E0:("func_801241E0",), 0x8012420C:("func_8012420C",), 0x8012422C:("func_8012422C",), - 0x80124258:("func_80124258",), + 0x80124258:("Player_GetExplosiveHeld",), 0x80124278:("func_80124278",), 0x801242B4:("func_801242B4",), 0x801242DC:("func_801242DC",), @@ -2655,7 +2655,7 @@ 0x8013A4C4:("func_8013A4C4",), 0x8013A504:("func_8013A504",), 0x8013A530:("func_8013A530",), - 0x8013A7C0:("func_8013A7C0",), + 0x8013A7C0:("SubS_FindDoor",), 0x8013A860:("func_8013A860",), 0x8013AB00:("func_8013AB00",), 0x8013AD6C:("func_8013AD6C",), @@ -2668,7 +2668,7 @@ 0x8013B6B0:("func_8013B6B0",), 0x8013B878:("func_8013B878",), 0x8013BB34:("func_8013BB34",), - 0x8013BB7C:("func_8013BB7C",), + 0x8013BB7C:("SubS_FindNearestActor",), 0x8013BC6C:("func_8013BC6C",), 0x8013BD40:("func_8013BD40",), 0x8013BEDC:("func_8013BEDC",), @@ -2689,7 +2689,7 @@ 0x8013D83C:("func_8013D83C",), 0x8013D8DC:("func_8013D8DC",), 0x8013D924:("func_8013D924",), - 0x8013D960:("func_ActorCategoryIterateById",), + 0x8013D960:("SubS_FindActor",), 0x8013D9C8:("func_8013D9C8",), 0x8013DB90:("func_8013DB90",), 0x8013DC40:("func_8013DC40",), @@ -2705,7 +2705,7 @@ 0x8013E3B8:("func_8013E3B8",), 0x8013E4B0:("func_8013E4B0",), 0x8013E5CC:("func_8013E5CC",), - 0x8013E640:("func_8013E640",), + 0x8013E640:("SubS_FindActorCustom",), 0x8013E748:("func_8013E748",), 0x8013E7C0:("func_8013E7C0",), 0x8013E8F8:("func_8013E8F8",), @@ -2860,7 +2860,7 @@ 0x80151DA4:("func_80151DA4",), 0x80152434:("func_80152434",), 0x80152464:("func_80152464",), - 0x80152498:("func_80152498",), + 0x80152498:("Message_GetState",), 0x8015268C:("func_8015268C",), 0x80152C64:("func_80152C64",), 0x80152CAC:("func_80152CAC",), @@ -2925,17 +2925,17 @@ 0x801631DC:("func_801631DC",), 0x80163334:("func_80163334",), 0x80163660:("func_80163660",), - 0x80163700:("func_80163700",), - 0x80163758:("func_80163758",), - 0x801637B4:("func_801637B4",), - 0x80163804:("func_80163804",), - 0x8016388C:("func_8016388C",), - 0x801638D8:("func_801638D8",), - 0x801639A0:("func_801639A0",), - 0x801639EC:("func_801639EC",), - 0x80163A38:("func_80163A38",), - 0x80163A58:("func_80163A58",), - 0x80163C0C:("func_80163C0C",), + 0x80163700:("KaleidoManager_FaultAddrConvFunc",), + 0x80163758:("KaleidoManager_LoadOvl",), + 0x801637B4:("KaleidoManager_ClearOvl",), + 0x80163804:("KaleidoManager_Init",), + 0x8016388C:("KaleidoManager_Destroy",), + 0x801638D8:("KaleidoManager_GetRamAddr",), + 0x801639A0:("KaleidoScopeCall_LoadPlayer",), + 0x801639EC:("KaleidoScopeCall_Init",), + 0x80163A38:("KaleidoScopeCall_Destroy",), + 0x80163A58:("KaleidoScopeCall_Update",), + 0x80163C0C:("KaleidoScopeCall_Draw",), 0x80163C90:("func_80163C90",), 0x80163D80:("func_80163D80",), 0x80163DC0:("func_80163DC0",), @@ -3324,7 +3324,7 @@ 0x8017D404:("func_8017D404",), 0x8017D568:("Math3D_TriSetCoords",), 0x8017D618:("Math3D_IsPointInSphere",), - 0x8017D668:("func_8017D668",), + 0x8017D668:("Math3D_PointDistToLine2D",), 0x8017D7C0:("func_8017D7C0",), 0x8017D814:("func_8017D814",), 0x8017D91C:("func_8017D91C",), @@ -3720,8 +3720,8 @@ 0x80194568:("func_80194568",), 0x80194668:("func_80194668",), 0x801946E4:("func_801946E4",), - 0x80194710:("func_80194710",), - 0x80194750:("func_80194750",), + 0x80194710:("Audio_InvalDCache",), + 0x80194750:("Audio_WritebackDCache",), 0x80194790:("func_80194790",), 0x80194804:("func_80194804",), 0x80194840:("func_80194840",), @@ -3870,7 +3870,7 @@ 0x8019F0C8:("play_sound",), 0x8019F128:("func_8019F128",), 0x8019F170:("func_8019F170",), - 0x8019F1C0:("func_8019F1C0",), + 0x8019F1C0:("Audio_PlaySfxAtPos",), 0x8019F208:("func_8019F208",), 0x8019F230:("func_8019F230",), 0x8019F258:("func_8019F258",), @@ -4033,7 +4033,7 @@ 0x801A5BD0:("func_801A5BD0",), 0x801A5C28:("func_801A5C28",), 0x801A5C8C:("func_801A5C8C",), - 0x801A5CFC:("func_801A5CFC",), + 0x801A5CFC:("Audio_PlaySfxGeneral",), 0x801A5DDC:("func_801A5DDC",), 0x801A5F7C:("func_801A5F7C",), 0x801A6430:("func_801A6430",), @@ -4042,7 +4042,7 @@ 0x801A7084:("func_801A7084",), 0x801A7168:("func_801A7168",), 0x801A7284:("func_801A7284",), - 0x801A72CC:("func_801A72CC",), + 0x801A72CC:("Audio_StopSfxByPos",), 0x801A7328:("func_801A7328",), 0x801A7484:("func_801A7484",), 0x801A75E8:("func_801A75E8",), @@ -4240,10 +4240,10 @@ 0x808274DC:("func_808274DC",), 0x80827A8C:("func_80827A8C",), 0x80827E08:("func_80827E08",), - 0x808283D8:("func_808283D8",), + 0x808283D8:("KaleidoScope_Draw",), 0x808286D8:("func_808286D8",), 0x80828788:("func_80828788",), - 0x8082895C:("func_8082895C",), + 0x8082895C:("KaleidoScope_Update",), 0x8082DA90:("func_8082DA90",), 0x8082DABC:("func_8082DABC",), 0x8082DAD4:("func_8082DAD4",), @@ -4991,8 +4991,8 @@ 0x80869D90:("EnPametfrog_Init",), 0x80869F90:("EnPametfrog_Destroy",), 0x80869FBC:("EnPametfrog_Vec3fNormalize",), - 0x8086A024:("EnPametfrog_ChangeColliderFreeze",), - 0x8086A068:("EnPametfrog_ChangeColliderThaw",), + 0x8086A024:("EnPametfrog_Freeze",), + 0x8086A068:("EnPametfrog_Thaw",), 0x8086A0F4:("EnPametfrog_JumpWaterEffects",), 0x8086A1A0:("EnPametfrog_IdleWaterEffects",), 0x8086A238:("func_8086A238",), @@ -5419,7 +5419,7 @@ 0x8088FE64:("func_8088FE64",), 0x8089010C:("func_8089010C",), 0x80890438:("EnElf_Update",), - 0x80890494:("func_80890494",), + 0x80890494:("EnElf_OverrideLimbDraw",), 0x808905B8:("EnElf_Draw",), 0x808908D0:("func_808908D0",), 0x80891060:("EnNiw_Init",), @@ -5527,8 +5527,8 @@ 0x808986A4:("func_808986A4",), 0x8089874C:("func_8089874C",), 0x80898A28:("EnPeehat_Update",), - 0x80898E74:("func_80898E74",), - 0x80899024:("func_80899024",), + 0x80898E74:("EnPeehat_OverrideLimbDraw",), + 0x80899024:("EnPeehat_PostLimbDraw",), 0x80899218:("EnPeehat_Draw",), 0x80899960:("EnHoll_SetupAction",), 0x808999B0:("EnHoll_SetPlayerSide",), @@ -5736,7 +5736,7 @@ 0x808A7138:("EnSt_Init",), 0x808A71D0:("EnSt_Destroy",), 0x808A7230:("EnSt_Update",), - 0x808A73E8:("func_808A73E8",), + 0x808A73E8:("EnSt_OverrideLimbDraw",), 0x808A7478:("func_808A7478",), 0x808A7930:("ObjWturn_Init",), 0x808A7954:("func_808A7954",), @@ -6671,7 +6671,7 @@ 0x808EC990:("func_808EC990",), 0x808ECD14:("func_808ECD14",), 0x808ED07C:("func_808ED07C",), - 0x808ED138:("EnBigslime_Draw",), + 0x808ED138:("EnBigslime_DrawGekko",), 0x808ED3F4:("func_808ED3F4",), 0x808F1200:("EnKarebaba_Init",), 0x808F1334:("EnKarebaba_Destroy",), @@ -6818,52 +6818,52 @@ 0x808FC550:("EnFr_Init",), 0x808FC5AC:("EnFr_Destroy",), 0x808FC5BC:("EnFr_Update",), - 0x808FC6C0:("func_808FC6C0",), - 0x808FC770:("func_808FC770",), - 0x808FC790:("func_808FC790",), - 0x808FC8B8:("func_808FC8B8",), - 0x808FC964:("func_808FC964",), - 0x808FCABC:("func_808FCABC",), - 0x808FCC0C:("func_808FCC0C",), - 0x808FCDBC:("func_808FCDBC",), - 0x808FCF60:("func_808FCF60",), - 0x808FD054:("func_808FD054",), + 0x808FC6C0:("EnFishing_SetColliderElement",), + 0x808FC770:("EnFishing_SeedRand",), + 0x808FC790:("EnFishing_RandZeroOne",), + 0x808FC8B8:("EnFishing_SmoothStepToS",), + 0x808FC964:("EnFishing_SpawnRipple",), + 0x808FCABC:("EnFishing_SpawnDustSplash",), + 0x808FCC0C:("EnFishing_SpawnWaterDust",), + 0x808FCDBC:("EnFishing_SpawnBubble",), + 0x808FCF60:("EnFishing_SpawnRainDrop",), + 0x808FD054:("EnFishing_InitPondProps",), 0x808FD368:("EnFishing_Init",), 0x808FDC64:("EnFishing_Destroy",), - 0x808FDCDC:("func_808FDCDC",), - 0x808FE3F8:("func_808FE3F8",), - 0x808FEE1C:("func_808FEE1C",), + 0x808FDCDC:("EnFishing_UpdateEffects",), + 0x808FE3F8:("EnFishing_DrawEffects",), + 0x808FEE1C:("EnFishing_DrawStreamSplash",), 0x808FEF70:("func_808FEF70",), - 0x808FF064:("func_808FF064",), - 0x808FF5E0:("func_808FF5E0",), - 0x808FF750:("func_808FF750",), - 0x808FFC44:("func_808FFC44",), - 0x808FFF3C:("func_808FFF3C",), - 0x80900228:("func_80900228",), - 0x80900A04:("func_80900A04",), - 0x80901480:("func_80901480",), + 0x808FF064:("EnFishing_UpdateLine",), + 0x808FF5E0:("EnFishing_UpdateLinePos",), + 0x808FF750:("EnFishing_DrawLureHook",), + 0x808FFC44:("EnFishing_UpdateSinkingLure",), + 0x808FFF3C:("EnFishing_DrawSinkingLure",), + 0x80900228:("EnFishing_DrawLureAndLine",), + 0x80900A04:("EnFishing_DrawRod",), + 0x80901480:("EnFishing_UpdateLure",), 0x809033F0:("func_809033F0",), 0x809036BC:("func_809036BC",), 0x809038A4:("func_809038A4",), 0x80903C60:("func_80903C60",), - 0x80903E20:("func_80903E20",), - 0x80903FE0:("EnFishing_Update",), - 0x80908554:("func_80908554",), - 0x80908674:("func_80908674",), - 0x809086B4:("func_809086B4",), - 0x80908734:("func_80908734",), - 0x80908774:("EnFishing_Draw",), - 0x809089B8:("func_809089B8",), - 0x80908A64:("func_80908A64",), - 0x80908B4C:("func_80908B4C",), - 0x80908E08:("func_80908E08",), - 0x80909234:("func_80909234",), - 0x80909AD0:("func_80909AD0",), - 0x80909CC0:("func_80909CC0",), - 0x8090AB6C:("func_8090AB6C",), - 0x8090C884:("func_8090C884",), - 0x8090C8BC:("func_8090C8BC",), - 0x8090C96C:("func_8090C96C",), + 0x80903E20:("EnFishing_HandleAquariumDialog",), + 0x80903FE0:("EnFishing_UpdateFish",), + 0x80908554:("EnFishing_FishOverrideLimbDraw",), + 0x80908674:("EnFishing_FishPostLimbDraw",), + 0x809086B4:("EnFishing_LoachOverrideLimbDraw",), + 0x80908734:("EnFishing_LoachPostLimbDraw",), + 0x80908774:("EnFishing_DrawFish",), + 0x809089B8:("EnFishing_HandleReedContact",), + 0x80908A64:("EnFishing_HandleLilyPadContact",), + 0x80908B4C:("EnFishing_UpdatePondProps",), + 0x80908E08:("EnFishing_DrawPondProps",), + 0x80909234:("EnFishing_UpdateGroupFishes",), + 0x80909AD0:("EnFishing_DrawGroupFishes",), + 0x80909CC0:("EnFishing_HandleOwnerDialog",), + 0x8090AB6C:("EnFishing_UpdateOwner",), + 0x8090C884:("EnFishing_OwnerOverrideLimbDraw",), + 0x8090C8BC:("EnFishing_OwnerPostLimbDraw",), + 0x8090C96C:("EnFishing_DrawOwner",), 0x80917290:("func_80917290",), 0x809172E4:("func_809172E4",), 0x8091734C:("func_8091734C",), @@ -8077,51 +8077,51 @@ 0x80973DE0:("func_80973DE0",), 0x80973E60:("ObjRoomtimer_Update",), 0x80973EF0:("EnSsh_SetupAction",), - 0x80973EFC:("func_80973EFC",), - 0x80973F84:("func_80973F84",), - 0x80974080:("func_80974080",), - 0x80974118:("func_80974118",), - 0x80974220:("func_80974220",), - 0x8097424C:("func_8097424C",), - 0x80974374:("func_80974374",), - 0x809744A8:("func_809744A8",), - 0x809744C8:("func_809744C8",), - 0x809744FC:("func_809744FC",), - 0x80974540:("func_80974540",), - 0x80974590:("func_80974590",), - 0x809745BC:("func_809745BC",), - 0x80974730:("func_80974730",), - 0x8097480C:("func_8097480C",), - 0x809748DC:("func_809748DC",), - 0x8097497C:("func_8097497C",), - 0x809749B8:("func_809749B8",), - 0x80974A24:("func_80974A24",), - 0x80974B0C:("func_80974B0C",), - 0x80974B44:("func_80974B44",), - 0x80974B84:("func_80974B84",), - 0x80974CC8:("func_80974CC8",), - 0x80974D3C:("func_80974D3C",), - 0x80974E44:("func_80974E44",), - 0x80974EA0:("func_80974EA0",), - 0x80974F78:("func_80974F78",), - 0x8097502C:("func_8097502C",), - 0x80975070:("func_80975070",), - 0x80975128:("func_80975128",), - 0x80975300:("func_80975300",), + 0x80973EFC:("EnSsh_SpawnShockwave",), + 0x80973F84:("EnSsh_CreateBlureEffect",), + 0x80974080:("EnSsh_CheckCeilingPos",), + 0x80974118:("EnSsh_AddBlureVertex",), + 0x80974220:("EnSsh_AddBlureSpace",), + 0x8097424C:("EnSsh_InitColliders",), + 0x80974374:("EnSsh_SetAnimation",), + 0x809744A8:("EnSsh_SetWaitAnimation",), + 0x809744C8:("EnSsh_SetReturnAnimation",), + 0x809744FC:("EnSsh_SetLandAnimation",), + 0x80974540:("EnSsh_SetDropAnimation",), + 0x80974590:("EnSsh_SetStunned",), + 0x809745BC:("EnSsh_SetColliderScale",), + 0x80974730:("EnSsh_Damaged",), + 0x8097480C:("EnSsh_Turn",), + 0x809748DC:("EnSsh_Stunned",), + 0x8097497C:("EnSsh_UpdateYaw",), + 0x809749B8:("EnSsh_Bob",), + 0x80974A24:("EnSsh_IsCloseToLink",), + 0x80974B0C:("EnSsh_IsCloseToHome",), + 0x80974B44:("EnSsh_IsCloseToGround",), + 0x80974B84:("EnSsh_Sway",), + 0x80974CC8:("EnSsh_CheckBodyStickHit",), + 0x80974D3C:("EnSsh_CheckHitPlayer",), + 0x80974E44:("EnSsh_CheckHitFront",), + 0x80974EA0:("EnSsh_CheckHitBack",), + 0x80974F78:("EnSsh_CollisionCheck",), + 0x8097502C:("EnSsh_SetBodyCylinderAC",), + 0x80975070:("EnSsh_SetLegsCylinderAC",), + 0x80975128:("EnSsh_SetCylinderOC",), + 0x80975300:("EnSsh_SetColliders",), 0x809753C8:("EnSsh_Init",), 0x80975540:("EnSsh_Destroy",), - 0x809755C0:("func_809755C0",), - 0x8097561C:("func_8097561C",), + 0x809755C0:("EnSsh_Wait",), + 0x8097561C:("EnSsh_Talk",), 0x809756D0:("func_809756D0",), - 0x80975720:("func_80975720",), - 0x809758B0:("func_809758B0",), - 0x80975998:("func_80975998",), - 0x80975A98:("func_80975A98",), - 0x80975B6C:("func_80975B6C",), - 0x80975C14:("func_80975C14",), + 0x80975720:("EnSsh_Idle",), + 0x809758B0:("EnSsh_Land",), + 0x80975998:("EnSsh_Drop",), + 0x80975A98:("EnSsh_Return",), + 0x80975B6C:("EnSsh_UpdateColliderScale",), + 0x80975C14:("EnSsh_Start",), 0x80975C9C:("EnSsh_Update",), - 0x80975DBC:("func_80975DBC",), - 0x80975EB8:("func_80975EB8",), + 0x80975DBC:("EnSsh_OverrideLimbDraw",), + 0x80975EB8:("EnSsh_PostLimbDraw",), 0x80975F38:("EnSsh_Draw",), 0x809764B0:("OceffWipe_Init",), 0x8097650C:("OceffWipe_Destroy",), @@ -8678,8 +8678,8 @@ 0x809A1E60:("EnZl4_Draw",), 0x809A2030:("EnMm2_Init",), 0x809A2070:("EnMm2_Destroy",), - 0x809A2080:("func_809A2080",), - 0x809A20FC:("func_809A20FC",), + 0x809A2080:("EnMm2_Reading",), + 0x809A20FC:("EnMm2_WaitForRead",), 0x809A2194:("EnMm2_Update",), 0x809A21B8:("EnMm2_Draw",), 0x809A2B60:("DoorSpiral_SetupAction",), @@ -9031,9 +9031,9 @@ 0x809C3190:("EnAob01_Init",), 0x809C3350:("EnAob01_Destroy",), 0x809C339C:("EnAob01_Update",), - 0x809C33D8:("func_809C33D8",), - 0x809C35B4:("func_809C35B4",), - 0x809C35F4:("func_809C35F4",), + 0x809C33D8:("EnAob01_OverrideLimbDraw",), + 0x809C35B4:("EnAob01_PostLimbDraw",), + 0x809C35F4:("EnAob01_UnkDraw",), 0x809C3608:("EnAob01_Draw",), 0x809C3D80:("EnBoj01_Init",), 0x809C3D90:("EnBoj01_Destroy",), @@ -9375,8 +9375,8 @@ 0x809ED45C:("func_809ED45C",), 0x809ED50C:("func_809ED50C",), 0x809ED8BC:("Boss04_Update",), - 0x809EDCCC:("func_809EDCCC",), - 0x809EDECC:("func_809EDECC",), + 0x809EDCCC:("Boss04_OverrideLimbDraw",), + 0x809EDECC:("Boss04_PostLimbDraw",), 0x809EDF58:("Boss04_Draw",), 0x809EE4E0:("func_809EE4E0",), 0x809EE668:("func_809EE668",), @@ -9742,8 +9742,8 @@ 0x80A15960:("EnGo_Destroy",), 0x80A159B0:("EnGo_Update",), 0x80A15B80:("func_80A15B80",), - 0x80A15D04:("func_80A15D04",), - 0x80A15E38:("func_80A15E38",), + 0x80A15D04:("EnGo_OverrideLimbDraw",), + 0x80A15E38:("EnGo_UnkDraw",), 0x80A15FEC:("func_80A15FEC",), 0x80A16D40:("func_80A16D40",), 0x80A16D6C:("func_80A16D6C",), @@ -10907,37 +10907,37 @@ 0x80A6B0D8:("func_80A6B0D8",), 0x80A6B3F8:("EnMushi2_Update",), 0x80A6B8D0:("EnMushi2_Draw",), - 0x80A6BF90:("func_80A6BF90",), - 0x80A6C1DC:("func_80A6C1DC",), + 0x80A6BF90:("EnFall_Moon_AdjustScaleAndPosition",), + 0x80A6C1DC:("EnFall_RisingDebris_ResetParticles",), 0x80A6C22C:("EnFall_Init",), 0x80A6C39C:("EnFall_Destroy",), - 0x80A6C3AC:("func_80A6C3AC",), - 0x80A6C3FC:("func_80A6C3FC",), - 0x80A6C7C0:("func_80A6C7C0",), - 0x80A6C9A8:("func_80A6C9A8",), - 0x80A6CA9C:("func_80A6CA9C",), - 0x80A6CB74:("func_80A6CB74",), - 0x80A6CD38:("func_80A6CD38",), - 0x80A6CD74:("func_80A6CD74",), - 0x80A6CECC:("func_80A6CECC",), - 0x80A6CF60:("func_80A6CF60",), - 0x80A6CF70:("func_80A6CF70",), + 0x80A6C3AC:("EnFall_MoonsTear_GetTerminaFieldMoon",), + 0x80A6C3FC:("EnFall_Setup",), + 0x80A6C7C0:("EnFall_CrashingMoon_HandleGiantsCutscene",), + 0x80A6C9A8:("EnFall_CrashingMoon_PerformCutsceneActions",), + 0x80A6CA9C:("EnFall_StoppedOpenMouthMoon_PerformCutsceneActions",), + 0x80A6CB74:("EnFall_StoppedClosedMouthMoon_PerformCutsceneActions",), + 0x80A6CD38:("EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions",), + 0x80A6CD74:("EnFall_Moon_PerformDefaultActions",), + 0x80A6CECC:("EnFall_MoonsTear_Initialize",), + 0x80A6CF60:("EnFall_DoNothing",), + 0x80A6CF70:("EnFall_MoonsTear_Fall",), 0x80A6D0DC:("EnFall_Update",), - 0x80A6D100:("func_80A6D100",), - 0x80A6D220:("func_80A6D220",), - 0x80A6D444:("func_80A6D444",), - 0x80A6D504:("func_80A6D504",), - 0x80A6D698:("func_80A6D698",), - 0x80A6D75C:("func_80A6D75C",), - 0x80A6D88C:("func_80A6D88C",), - 0x80A6D98C:("func_80A6D98C",), - 0x80A6DA7C:("func_80A6DA7C",), - 0x80A6DC20:("func_80A6DC20",), - 0x80A6DC40:("func_80A6DC40",), - 0x80A6DD3C:("func_80A6DD3C",), - 0x80A6E07C:("func_80A6E07C",), - 0x80A6E214:("func_80A6E214",), - 0x80A6E37C:("func_80A6E37C",), + 0x80A6D100:("EnFall_FireBall_SetPerVertexAlpha",), + 0x80A6D220:("EnFall_FireBall_Update",), + 0x80A6D444:("EnFall_RisingDebris_UpdateParticles",), + 0x80A6D504:("EnFall_RisingDebris_InitializeParticles",), + 0x80A6D698:("EnFall_RisingDebris_Update",), + 0x80A6D75C:("EnFall_FireRing_Update",), + 0x80A6D88C:("EnFall_Moon_Draw",), + 0x80A6D98C:("EnFall_OpenMouthMoon_Draw",), + 0x80A6DA7C:("EnFall_LodMoon_Draw",), + 0x80A6DC20:("EnFall_LodMoon_DrawWithoutLerp",), + 0x80A6DC40:("EnFall_LodMoon_DrawWithLerp",), + 0x80A6DD3C:("EnFall_FireBall_Draw",), + 0x80A6E07C:("EnFall_RisingDebris_Draw",), + 0x80A6E214:("EnFall_FireRing_Draw",), + 0x80A6E37C:("EnFall_MoonsTear_Draw",), 0x80A6F0A0:("EnMm3_Init",), 0x80A6F1EC:("EnMm3_Destroy",), 0x80A6F22C:("func_80A6F22C",), @@ -11100,10 +11100,10 @@ 0x80A7BC70:("ObjEtcetera_Init",), 0x80A7BD80:("ObjEtcetera_Destroy",), 0x80A7BDC8:("ObjEtcetera_DoNormalOscillation",), - 0x80A7BE8C:("ObjEtcetera_StartSmallFlutterAnimation",), + 0x80A7BE8C:("ObjEtcetera_StartRustleAnimation",), 0x80A7BF08:("ObjEtcetera_Idle",), - 0x80A7C168:("ObjEtcetera_PlaySmallFlutterAnimation",), - 0x80A7C1F0:("ObjEtcetera_DoIntenseOscillation",), + 0x80A7C168:("ObjEtcetera_PlayRustleAnimation",), + 0x80A7C1F0:("ObjEtcetera_DoBounceOscillation",), 0x80A7C308:("ObjEtcetera_Setup",), 0x80A7C5EC:("ObjEtcetera_Update",), 0x80A7C690:("ObjEtcetera_DrawIdle",), @@ -11667,45 +11667,45 @@ 0x80AB2544:("DmChar09_Update",), 0x80AB25D8:("func_80AB25D8",), 0x80AB261C:("DmChar09_Draw",), - 0x80AB2790:("func_80AB2790",), - 0x80AB27B4:("func_80AB27B4",), - 0x80AB2834:("func_80AB2834",), - 0x80AB28C8:("func_80AB28C8",), - 0x80AB29F8:("func_80AB29F8",), - 0x80AB2BBC:("func_80AB2BBC",), + 0x80AB2790:("ObjTokeidai_GetTargetSunMoonDiskRotation",), + 0x80AB27B4:("ObjTokeidai_SetupClockOrGear",), + 0x80AB2834:("ObjTokeidai_Clock_Init",), + 0x80AB28C8:("ObjTokeidai_TowerGear_Init",), + 0x80AB29F8:("ObjTokeidai_TowerClock_Init",), + 0x80AB2BBC:("ObjTokeidai_Counterweight_Init",), 0x80AB2DEC:("ObjTokeidai_Init",), 0x80AB3000:("ObjTokeidai_Destroy",), - 0x80AB3010:("func_80AB3010",), - 0x80AB319C:("func_80AB319C",), - 0x80AB3240:("func_80AB3240",), - 0x80AB32F0:("func_80AB32F0",), - 0x80AB3370:("func_80AB3370",), - 0x80AB34CC:("func_80AB34CC",), - 0x80AB3544:("func_80AB3544",), - 0x80AB3598:("func_80AB3598",), - 0x80AB363C:("func_80AB363C",), - 0x80AB365C:("func_80AB365C",), - 0x80AB36C4:("func_80AB36C4",), - 0x80AB3808:("func_80AB3808",), - 0x80AB3880:("func_80AB3880",), - 0x80AB38B0:("func_80AB38B0",), - 0x80AB39BC:("func_80AB39BC",), - 0x80AB3A7C:("func_80AB3A7C",), - 0x80AB3B34:("func_80AB3B34",), - 0x80AB3BB0:("func_80AB3BB0",), - 0x80AB3BD8:("func_80AB3BD8",), - 0x80AB3BE8:("func_80AB3BE8",), - 0x80AB3C50:("func_80AB3C50",), - 0x80AB3CCC:("func_80AB3CCC",), - 0x80AB3ED0:("func_80AB3ED0",), - 0x80AB4040:("func_80AB4040",), - 0x80AB4080:("func_80AB4080",), - 0x80AB4160:("func_80AB4160",), + 0x80AB3010:("ObjTokeidai_RotateOnMinuteChange",), + 0x80AB319C:("ObjTokeidai_TowerGear_Collapse",), + 0x80AB3240:("ObjTokeidai_TowerGear_OpenedIdle",), + 0x80AB32F0:("ObjTokeidai_TowerClock_Fall",), + 0x80AB3370:("ObjTokeidai_TowerClock_SlideOff",), + 0x80AB34CC:("ObjTokeidai_TowerClock_OpenedIdle",), + 0x80AB3544:("ObjTokeidai_Counterweight_Collapse",), + 0x80AB3598:("ObjTokeidai_Counterweight_OpenedIdle",), + 0x80AB363C:("ObjTokeidai_Walls_Collapse",), + 0x80AB365C:("ObjTokeidai_Walls_Idle",), + 0x80AB36C4:("ObjTokeidai_TowerTransformation_EndCutscene",), + 0x80AB3808:("ObjTokeidai_TowerOpening_FinishOpening",), + 0x80AB3880:("ObjTokeidai_TowerOpening_Wait",), + 0x80AB38B0:("ObjTokeidai_TowerOpening_DropCounterweight",), + 0x80AB39BC:("ObjTokeidai_TowerOpening_FinishRaise",), + 0x80AB3A7C:("ObjTokeidai_TowerOpening_RaiseTower",), + 0x80AB3B34:("ObjTokeidai_TowerOpening_Start",), + 0x80AB3BB0:("ObjTokeidai_SetupTowerOpening",), + 0x80AB3BD8:("ObjTokeidai_DoNothing",), + 0x80AB3BE8:("ObjTokeidai_StaircaseIntoTower_Idle",), + 0x80AB3C50:("ObjTokeidai_IsPostFirstCycleFinalHours",), + 0x80AB3CCC:("ObjTokeidai_RotateOnHourChange",), + 0x80AB3ED0:("ObjTokeidai_TowerClock_Idle",), + 0x80AB4040:("ObjTokeidai_WallClock_Idle",), + 0x80AB4080:("ObjTokeidai_TowerGear_Idle",), + 0x80AB4160:("ObjTokeidai_Counterweight_Idle",), 0x80AB4278:("ObjTokeidai_Update",), 0x80AB429C:("ObjTokeidai_Draw",), - 0x80AB4394:("func_80AB4394",), - 0x80AB4664:("func_80AB4664",), - 0x80AB4894:("func_80AB4894",), + 0x80AB4394:("ObjTokeidai_Clock_Draw",), + 0x80AB4664:("ObjTokeidai_Counterweight_Draw",), + 0x80AB4894:("ObjTokeidai_TowerGear_Draw",), 0x80AB4D10:("func_80AB4D10",), 0x80AB4E34:("func_80AB4E34",), 0x80AB4E58:("func_80AB4E58",), @@ -12276,7 +12276,7 @@ 0x80AD8A48:("func_80AD8A48",), 0x80AD8AF8:("func_80AD8AF8",), 0x80AD8BC0:("EnKame_Draw",), - 0x80AD8CEC:("func_80AD8CEC",), + 0x80AD8CEC:("Enkame_OverrideLimbDraw",), 0x80AD8D64:("func_80AD8D64",), 0x80AD9240:("func_80AD9240",), 0x80AD92FC:("func_80AD92FC",), @@ -12805,7 +12805,7 @@ 0x80AFDD34:("EnColMan_Destroy",), 0x80AFDD60:("func_80AFDD60",), 0x80AFDE00:("func_80AFDE00",), - 0x80AFDF00:("func_80AFDF00",), + 0x80AFDF00:("EnColMan_SetHeartPieceCollectedAndKill",), 0x80AFDF60:("func_80AFDF60",), 0x80AFDFB4:("func_80AFDFB4",), 0x80AFE234:("func_80AFE234",), @@ -12817,53 +12817,53 @@ 0x80AFE650:("func_80AFE650",), 0x80AFE8A0:("EnTalkGibud_Init",), 0x80AFEB0C:("EnTalkGibud_Destroy",), - 0x80AFEB38:("func_80AFEB38",), - 0x80AFEB7C:("func_80AFEB7C",), - 0x80AFEC08:("func_80AFEC08",), - 0x80AFEC4C:("func_80AFEC4C",), - 0x80AFED08:("func_80AFED08",), - 0x80AFED7C:("func_80AFED7C",), - 0x80AFEFD4:("func_80AFEFD4",), - 0x80AFF030:("func_80AFF030",), - 0x80AFF22C:("func_80AFF22C",), - 0x80AFF288:("func_80AFF288",), - 0x80AFF330:("func_80AFF330",), - 0x80AFF378:("func_80AFF378",), - 0x80AFF45C:("func_80AFF45C",), - 0x80AFF4AC:("func_80AFF4AC",), - 0x80AFF618:("func_80AFF618",), - 0x80AFF6A0:("func_80AFF6A0",), - 0x80AFF700:("func_80AFF700",), - 0x80AFF76C:("func_80AFF76C",), - 0x80AFF880:("func_80AFF880",), - 0x80AFF8E4:("func_80AFF8E4",), - 0x80AFF9CC:("func_80AFF9CC",), - 0x80AFFA68:("func_80AFFA68",), - 0x80AFFAB0:("func_80AFFAB0",), - 0x80AFFC10:("func_80AFFC10",), - 0x80AFFC9C:("func_80AFFC9C",), - 0x80AFFD3C:("func_80AFFD3C",), - 0x80AFFE3C:("func_80AFFE3C",), - 0x80AFFE94:("func_80AFFE94",), - 0x80AFFFA4:("func_80AFFFA4",), - 0x80AFFFBC:("func_80AFFFBC",), - 0x80B000FC:("func_80B000FC",), - 0x80B00158:("func_80B00158",), - 0x80B00384:("func_80B00384",), - 0x80B0040C:("func_80B0040C",), - 0x80B00484:("func_80B00484",), - 0x80B004D0:("func_80B004D0",), - 0x80B005EC:("func_80B005EC",), - 0x80B00760:("func_80B00760",), - 0x80B008BC:("func_80B008BC",), - 0x80B008FC:("func_80B008FC",), - 0x80B0094C:("func_80B0094C",), - 0x80B00B8C:("func_80B00B8C",), - 0x80B00C94:("func_80B00C94",), - 0x80B00D9C:("func_80B00D9C",), + 0x80AFEB38:("EnTalkGibud_SetupIdle",), + 0x80AFEB7C:("EnTalkGibud_Idle",), + 0x80AFEC08:("EnTalkGibud_SetupAttemptPlayerStun",), + 0x80AFEC4C:("EnTalkGibud_AttemptStun",), + 0x80AFED08:("EnTalkGibud_SetupWalkToPlayer",), + 0x80AFED7C:("EnTalkGibud_WalkToPlayer",), + 0x80AFEFD4:("EnTalkGibud_SetupGrab",), + 0x80AFF030:("EnTalkGibud_Grab",), + 0x80AFF22C:("EnTalkGibud_SetupGrabFail",), + 0x80AFF288:("EnTalkGibud_GrabFail",), + 0x80AFF330:("EnTalkGibud_SetupTurnAwayAndShakeHead",), + 0x80AFF378:("EnTalkGibud_TurnAwayAndShakeHead",), + 0x80AFF45C:("EnTalkGibud_SetupWalkToHome",), + 0x80AFF4AC:("EnTalkGibud_WalkToHome",), + 0x80AFF618:("EnTalkGibud_SetupStunned",), + 0x80AFF6A0:("EnTalkGibud_Stunned",), + 0x80AFF700:("EnTalkGibud_SetupDamage",), + 0x80AFF76C:("EnTalkGibud_Damage",), + 0x80AFF880:("EnTalkGibud_SetupDead",), + 0x80AFF8E4:("EnTalkGibud_Dead",), + 0x80AFF9CC:("EnTalkGibud_SetupRevive",), + 0x80AFFA68:("EnTalkGibud_Revive",), + 0x80AFFAB0:("EnTalkGibud_GetTextIdForRequestedItem",), + 0x80AFFC10:("EnTalkGibud_GetNextTextBoxId",), + 0x80AFFC9C:("EnTalkGibud_PresentedItemMatchesRequest",), + 0x80AFFD3C:("EnTalkGibud_CheckPresentedItem",), + 0x80AFFE3C:("EnTalkGibud_SetupPassiveIdle",), + 0x80AFFE94:("EnTalkGibud_PassiveIdle",), + 0x80AFFFA4:("EnTalkGibud_SetupTalk",), + 0x80AFFFBC:("EnTalkGibud_Talk",), + 0x80B000FC:("EnTalkGibud_SetupDisappear",), + 0x80B00158:("EnTalkGibud_Disappear",), + 0x80B00384:("EnTalkGibud_FacePlayerWhenTalking",), + 0x80B0040C:("EnTalkGibud_PlayerInRangeWithCorrectState",), + 0x80B00484:("EnTalkGibud_PlayerOutOfRange",), + 0x80B004D0:("EnTalkGibud_CheckForGibdoMask",), + 0x80B005EC:("EnTalkGibud_TurnTowardsPlayer",), + 0x80B00760:("EnTalkGibud_MoveToIdealGrabPositionAndRotation",), + 0x80B008BC:("EnTalkGibud_PlayAnimation",), + 0x80B008FC:("EnTalkGibud_MoveWithGravity",), + 0x80B0094C:("EnTalkGibud_CheckDamageEffect",), + 0x80B00B8C:("EnTalkGibud_CheckCollision",), + 0x80B00C94:("EnTalkGibud_MoveGrabbedPlayerAwayFromWall",), + 0x80B00D9C:("EnTalkGibud_UpdateEffect",), 0x80B00E48:("EnTalkGibud_Update",), - 0x80B00F08:("func_80B00F08",), - 0x80B00F64:("func_80B00F64",), + 0x80B00F08:("EnTalkGibud_OverrideLimbDraw",), + 0x80B00F64:("EnTalkGibud_PostLimbDraw",), 0x80B01040:("EnTalkGibud_Draw",), 0x80B01990:("EnGiant_ChangeAnimation",), 0x80B01A74:("EnGiant_IsImprisoned",), @@ -13021,8 +13021,8 @@ 0x80B1137C:("EnGb2_Init",), 0x80B116E4:("EnGb2_Destroy",), 0x80B11710:("EnGb2_Update",), - 0x80B1179C:("func_80B1179C",), - 0x80B117FC:("func_80B117FC",), + 0x80B1179C:("EnGb2_OverrideLimbDraw",), + 0x80B117FC:("EnGb2_PostLimbDraw",), 0x80B11858:("EnGb2_Draw",), 0x80B11E60:("EnOnpuman_Init",), 0x80B11F18:("EnOnpuman_Destroy",), @@ -14161,7 +14161,7 @@ 0x80B610B8:("ObjDora_Draw",), 0x80B615E0:("EnBigpo_Init",), 0x80B6186C:("EnBigpo_Destroy",), - 0x80B61914:("func_80B61914",), + 0x80B61914:("EnBigpo_RotateSpawnCutsceneFires",), 0x80B619B4:("func_80B619B4",), 0x80B619FC:("func_80B619FC",), 0x80B61AC8:("EnBigPo_InitWellBigPo",), @@ -14404,8 +14404,8 @@ 0x80B72880:("func_80B72880",), 0x80B72970:("func_80B72970",), 0x80B72DBC:("EnRailSkb_Update",), - 0x80B72E88:("func_80B72E88",), - 0x80B7302C:("func_80B7302C",), + 0x80B72E88:("EnRailSkb_OverrideLimbDraw",), + 0x80B7302C:("EnRailSkb_PostLimbDraw",), 0x80B731EC:("EnRailSkb_Draw",), 0x80B73A90:("func_80B73A90",), 0x80B73AE4:("func_80B73AE4",), @@ -15324,9 +15324,9 @@ 0x80BB3650:("EnGeg_Destroy",), 0x80BB36A0:("EnGeg_Update",), 0x80BB3728:("func_80BB3728",), - 0x80BB3860:("func_80BB3860",), - 0x80BB387C:("func_80BB387C",), - 0x80BB39F8:("func_80BB39F8",), + 0x80BB3860:("EnGeg_OverrideLimbDraw",), + 0x80BB387C:("EnGeg_PostLimbDraw",), + 0x80BB39F8:("EnGeg_UnkDraw",), 0x80BB3BE0:("func_80BB3BE0",), 0x80BB3CB4:("func_80BB3CB4",), 0x80BB3E0C:("EnGeg_Draw",), @@ -16272,9 +16272,9 @@ 0x80BEFD98:("EnAkindonuts_Init",), 0x80BEFF08:("EnAkindonuts_Destroy",), 0x80BEFF34:("EnAkindonuts_Update",), - 0x80BEFFB4:("func_80BEFFB4",), - 0x80BF0178:("func_80BF0178",), - 0x80BF0190:("func_80BF0190",), + 0x80BEFFB4:("EnAkindonuts_OverrideLimbDraw",), + 0x80BF0178:("EnAkindonuts_PostLimbDraw",), + 0x80BF0190:("EnAkindonuts_UnkActorDraw",), 0x80BF0258:("EnAkindonuts_Draw",), 0x80BF0D90:("EffStk_Init",), 0x80BF0DD0:("EffStk_Destroy",), @@ -16483,7 +16483,7 @@ 0x80C00234:("func_80C00234",), 0x80C00284:("func_80C00284",), 0x80C00644:("EnBomjima_Update",), - 0x80C007F4:("func_80C007F4",), + 0x80C007F4:("EnBomjima_OverrideLimbDraw",), 0x80C008B4:("EnBomjima_Draw",), 0x80C00EA0:("EnBomjimb_Init",), 0x80C01110:("EnBomjimb_Destroy",), @@ -16515,7 +16515,7 @@ 0x80C02CA4:("func_80C02CA4",), 0x80C02DAC:("func_80C02DAC",), 0x80C02DC4:("EnBomjimb_Update",), - 0x80C02FA8:("func_80C02FA8",), + 0x80C02FA8:("EnBomjimb_OverrideLimbDraw",), 0x80C03034:("EnBomjimb_Draw",), 0x80C03530:("EnBombers_Init",), 0x80C037F8:("EnBombers_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 8e75b9cbd4..73afcda755 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -397,8 +397,8 @@ 0x801AE2CC:("D_801AE2CC","UNK_TYPE4","",0x4), 0x801AE2DC:("D_801AE2DC","UNK_TYPE4","",0x4), 0x801AE2F0:("sEffectShieldParticleVertices","F3DVertex","[4]",0x40), - 0x801AE330:("sEffInfoTable","EffInfo","[5]",0x64), - 0x801AE3A0:("EffectSS2Info","EffectSsInfo","",0xc), + 0x801AE330:("sEffectInfoTable","EffectInfo","[5]",0x64), + 0x801AE3A0:("sEffectSsInfo","EffectSsInfo","",0xc), 0x801AE3B0:("D_801AE3B0","Color_RGBA8","",0x4), 0x801AE3B4:("D_801AE3B4","Color_RGBA8","",0x4), 0x801AE3B8:("D_801AE3B8","Color_RGBA8","",0x4), @@ -419,32 +419,28 @@ 0x801AE480:("D_801AE480","Color_RGBA8","",0x4), 0x801AE484:("D_801AE484","Color_RGBA8","",0x4), 0x801AE488:("D_801AE488","Color_RGBA8","",0x4), - 0x801AE489:("D_801AE489","UNK_TYPE1","",0x1), - 0x801AE48A:("D_801AE48A","UNK_TYPE1","",0x1), 0x801AE48C:("D_801AE48C","Color_RGBA8","",0x4), 0x801AE490:("D_801AE490","Color_RGBA8","[4]",0x10), - 0x801AE4A0:("particleOverlayTable","EffectSsOverlay","[39]",0x444), + 0x801AE4A0:("gParticleOverlayTable","EffectSsOverlay","[39]",0x444), 0x801AE8F0:("sFlagEntries","FlagSetEntry","[112]",0x8), 0x801AEC70:("sEntryIndex","s32","",0x4), 0x801AEC74:("sCurrentBit","u32","",0x4), 0x801AEC78:("sTimer","s32","",0x4), 0x801AEC80:("D_801AEC80","Color_RGBA8","",0x4), - 0x801AEC84:("D_801AEC84","s801AEC84","[13]",0x68), + 0x801AEC84:("sTatlColorList","TatlColor","[13]",0x68), 0x801AECEC:("actorMovementScale","f32","",0x4), - 0x801AECF0:("D_801AECF0","f32","",0x4), - 0x801AECF4:("D_801AECF4","f32","",0x4), - 0x801AED48:("D_801AED48","UNK_TYPE1","",0x1), + 0x801AECF0:("gTargetRanges","f32","[]",0x58), + 0x801AED48:("D_801AED48","s16","[8]",0x10), 0x801AED58:("D_801AED58","UNK_TYPE4","",0x4), 0x801AED88:("actorDefaultHitColor","Color_RGBA8","",0x4), 0x801AED8C:("D_801AED8C","UNK_TYPE1","",0x1), - 0x801AED98:("D_801AED98","UNK_TYPE4","",0x4), + 0x801AED98:("D_801AED98","Vec3f","",0xC), 0x801AEDA4:("D_801AEDA4","UNK_TYPE4","",0x4), 0x801AEDB0:("D_801AEDB0","UNK_TYPE1","",0x1), 0x801AEDD4:("D_801AEDD4","UNK_TYPE4","",0x4), 0x801AEE28:("D_801AEE28","UNK_TYPE4","",0x4), 0x801AEE30:("D_801AEE30","UNK_TYPE4","",0x4), - 0x801AEE38:("D_801AEE38","UNK_TYPE4","",0x4), - 0x801AEE4C:("D_801AEE4C","UNK_TYPE2","",0x2), + 0x801AEE38:("D_801AEE38","struct_801AEE38","[14]",0x150), 0x801AEF88:("D_801AEF88","UNK_TYPE1","",0x1), 0x801AEFA0:("D_801AEFA0","UNK_TYPE1","",0x1), 0x801AEFA8:("D_801AEFA8","UNK_TYPE1","",0x1), @@ -882,8 +878,8 @@ 0x801BA484:("defaultColChkInfo","CollisionCheckInfo","",0x1c), 0x801BA4A0:("sApplyDamageFuncs","ColChkApplyFunc","",0x14), 0x801BA4B4:("sOCLineCheckFuncs","ColChkLineFunc","",0x14), - 0x801BA4C8:("shieldParticleInitMetal","EffShieldParticleInit","",0x40), - 0x801BA508:("shieldParticleInitWood","EffShieldParticleInit","",0x40), + 0x801BA4C8:("shieldParticleInitMetal","EffectShieldParticleInit","",0x40), + 0x801BA508:("shieldParticleInitWood","EffectShieldParticleInit","",0x40), 0x801BA550:("D_801BA550","UNK_TYPE1","",0x1), 0x801BA750:("D_801BA750","UNK_TYPE1","",0x1), 0x801BA790:("sDebugDisplay1DL","UNK_TYPE1","",0x1), @@ -2169,9 +2165,9 @@ 0x801D08E8:("D_801D08E8","UNK_TYPE1","",0x1), 0x801D0900:("D_801D0900","UNK_TYPE1","",0x1), 0x801D0B50:("Player_InitVars","ActorInit","",0x20), - 0x801D0B70:("D_801D0B70","UNK_TYPE1","",0x38), - 0x801D0BA8:("D_801D0BA8","UNK_TYPE4","",0x4), - 0x801D0BAC:("D_801D0BAC","UNK_TYPE4","",0x4), + 0x801D0B70:("gKaleidoMgrOverlayTable","KaleidoMgrOverlay","",0x38), + 0x801D0BA8:("sKaleidoAreaPtr","void*","",0x4), + 0x801D0BAC:("gKaleidoMgrCurOvl","KaleidoMgrOverlay*","",0x4), 0x801D0BB0:("D_801D0BB0","UNK_TYPE4","",0x4), 0x801D0C80:("D_801D0C80","UNK_TYPE1","",0x1), 0x801D0CB0:("D_801D0CB0","UNK_TYPE1","",0x1), @@ -2245,11 +2241,11 @@ 0x801D1538:("D_801D1538","UNK_TYPE4","",0x4), 0x801D1540:("D_801D1540","UNK_PTR","",0x4), 0x801D1570:("D_801D1570","f32","[13]",0x34), - 0x801D15B0:("D_801D15B0","Vec3f","",0xC), - 0x801D15BC:("D_801D15BC","UNK_TYPE4","",0x4), + 0x801D15B0:("gZeroVec3f","Vec3f","",0xC), + 0x801D15BC:("gZeroVec3s","Vec3s","",0x6), 0x801D15D0:("sATan2Tbl","s16","[1025]",0x802), - 0x801D1DE0:("D_801D1DE0","Mtx","",0x40), - 0x801D1E20:("D_801D1E20","MtxF","",0x40), + 0x801D1DE0:("gIdentityMtx","Mtx","",0x40), + 0x801D1E20:("gIdentityMtxF","MtxF","",0x40), 0x801D1E60:("initialgspUcodeText","UNK_PTR","",0x4), 0x801D1E64:("initialgspUcodeData","UNK_PTR","",0x4), 0x801D1E70:("D_801D1E70","UNK_TYPE1","",0x1), @@ -3887,10 +3883,10 @@ 0x801E3BB0:("D_801E3BB0","UNK_TYPE1","",0x1), 0x801E3F40:("gJpegUCodeData","UNK_TYPE1","",0x1), 0x801E3FA0:("D_801E3FA0","UNK_TYPE1","",0x1), - 0x801E3FB0:("sEffTable","EffTables","",0x98E0), + 0x801E3FB0:("sEffectContext","EffectContext","",0x98E0), 0x801ED890:("D_801ED890","UNK_TYPE1","",0x1), 0x801ED894:("D_801ED894","UNK_TYPE1","",0x1), - 0x801ED8A0:("D_801ED8A0","UNK_TYPE1","",0x1), + 0x801ED8A0:("sActorFaultClient","UNK_TYPE1","",0x1), 0x801ED8B0:("D_801ED8B0","UNK_TYPE1","",0x1), 0x801ED8B4:("D_801ED8B4","UNK_TYPE1","",0x1), 0x801ED8B8:("D_801ED8B8","UNK_TYPE1","",0x1), @@ -3898,7 +3894,7 @@ 0x801ED8C0:("D_801ED8C0","UNK_TYPE1","",0x1), 0x801ED8C4:("D_801ED8C4","UNK_TYPE1","",0x1), 0x801ED8C8:("D_801ED8C8","f32","",0x4), - 0x801ED8CC:("D_801ED8CC","f32","",0x4), + 0x801ED8CC:("sBgmEnemyDistSq","f32","",0x4), 0x801ED8D0:("D_801ED8D0","f32","",0x4), 0x801ED8D4:("D_801ED8D4","UNK_TYPE1","",0x1), 0x801ED8D8:("D_801ED8D8","UNK_TYPE1","",0x1), @@ -3972,12 +3968,12 @@ 0x801EE1D0:("D_801EE1D0","Vec3f","",0xc), 0x801EE1E0:("D_801EE1E0","Vec3f","",0xc), 0x801EE1F0:("D_801EE1F0","Vec3f","",0xc), - 0x801EE200:("D_801EE200","EffSparkParams","",0x4c4), + 0x801EE200:("D_801EE200","EffectSparkInit","",0x4c4), 0x801EE6C8:("D_801EE6C8","TriNorm","",0x34), 0x801EE700:("D_801EE700","TriNorm","",0x34), - 0x801EE738:("D_801EE738","EffSparkParams","",0x4c4), - 0x801EEC00:("D_801EEC00","EffSparkParams","",0x4c4), - 0x801EF0C8:("D_801EF0C8","EffSparkParams","",0x4c4), + 0x801EE738:("D_801EE738","EffectSparkInit","",0x4c4), + 0x801EEC00:("D_801EEC00","EffectSparkInit","",0x4c4), + 0x801EF0C8:("D_801EF0C8","EffectSparkInit","",0x4c4), 0x801EF590:("D_801EF590","UNK_TYPE1","",0x1), 0x801EF5C8:("D_801EF5C8","UNK_TYPE1","",0x1), 0x801EF600:("D_801EF600","TriNorm","",0x34), @@ -4117,9 +4113,9 @@ 0x801F6B44:("gShrinkWindowContextPtr","ShrinkWindowContext*","",0x4), 0x801F6B50:("D_801F6B50","UNK_TYPE4","",0x4), 0x801F6B58:("D_801F6B58","UNK_TYPE1","",0x1), - 0x801F6BF0:("D_801F6BF0","UNK_TYPE1","",0x1), - 0x801F6C00:("D_801F6C00","UNK_TYPE1","",0x1), - 0x801F6C04:("D_801F6C04","UNK_TYPE1","",0x1), + 0x801F6BF0:("sKaleidoAreaFaultClient","FaultAddrConvClient","",0xC), + 0x801F6C00:("sKaleidoScopeUpdateFunc","void*","",0x4), + 0x801F6C04:("sKaleidoScopeDrawFunc","void*","",0x4), 0x801F6C10:("D_801F6C10","UNK_TYPE1","",0x1), 0x801F6C18:("D_801F6C18","Input","",0x18), 0x801F6C30:("D_801F6C30","UNK_TYPE1","",0x1), @@ -5321,8 +5317,8 @@ 0x8085D2C0:("D_8085D2C0","ActorInitVar","",0x4), 0x8085D2C4:("D_8085D2C4","UNK_TYPE4","",0x4), 0x8085D2CC:("D_8085D2CC","UNK_PTR","",0x4), - 0x8085D30C:("D_8085D30C","EffBlureInit2","",0x24), - 0x8085D330:("D_8085D330","EffTireMarkInit","",0x8), + 0x8085D30C:("D_8085D30C","EffectBlureInit2","",0x24), + 0x8085D330:("D_8085D330","EffectTireMarkInit","",0x8), 0x8085D338:("D_8085D338","UNK_TYPE4","",0x4), 0x8085D33C:("D_8085D33C","UNK_TYPE4","",0x4), 0x8085D340:("D_8085D340","UNK_TYPE1","",0x1), @@ -5972,7 +5968,7 @@ 0x808792D4:("D_808792D4","UNK_TYPE1","",0x1), 0x808792F4:("D_808792F4","UNK_TYPE1","",0x1), 0x808792FC:("D_808792FC","UNK_TYPE1","",0x1), - 0x80879308:("D_80879308","EffBlureInit2","",0x24), + 0x80879308:("D_80879308","EffectBlureInit2","",0x24), 0x8087932C:("D_8087932C","UNK_TYPE1","",0x1), 0x80879330:("D_80879330","UNK_TYPE1","",0x1), 0x80879334:("D_80879334","UNK_TYPE1","",0x1), @@ -6197,10 +6193,10 @@ 0x8088C1C0:("En_Arrow_InitVars","UNK_TYPE1","",0x1), 0x8088C1E0:("D_8088C1E0","UNK_TYPE1","",0x1), 0x8088C230:("D_8088C230","UNK_TYPE1","",0x1), - 0x8088C234:("D_8088C234","EffBlureInit2","",0x24), - 0x8088C258:("D_8088C258","EffBlureInit2","",0x24), - 0x8088C27C:("D_8088C27C","EffBlureInit2","",0x24), - 0x8088C2A0:("D_8088C2A0","EffBlureInit2","",0x24), + 0x8088C234:("D_8088C234","EffectBlureInit2","",0x24), + 0x8088C258:("D_8088C258","EffectBlureInit2","",0x24), + 0x8088C27C:("D_8088C27C","EffectBlureInit2","",0x24), + 0x8088C2A0:("D_8088C2A0","EffectBlureInit2","",0x24), 0x8088C2C4:("D_8088C2C4","UNK_TYPE4","",0x4), 0x8088C2CC:("D_8088C2CC","UNK_TYPE1","",0x1), 0x8088C2D8:("D_8088C2D8","UNK_TYPE1","",0x1), @@ -6409,7 +6405,7 @@ 0x8089E350:("D_8089E350","UNK_TYPE4","",0x4), 0x8089E354:("D_8089E354","UNK_TYPE1","",0x1), 0x8089E364:("D_8089E364","UNK_TYPE4","",0x4), - 0x8089E368:("D_8089E368","EffBlureInit2","",0x24), + 0x8089E368:("D_8089E368","EffectBlureInit2","",0x24), 0x8089E38C:("D_8089E38C","UNK_TYPE1","",0x1), 0x8089E398:("D_8089E398","UNK_TYPE1","",0x1), 0x8089E3A4:("D_8089E3A4","UNK_TYPE1","",0x1), @@ -6735,10 +6731,8 @@ 0x808BBB20:("Door_Warp1_InitVars","UNK_TYPE1","",0x1), 0x808BBB40:("D_808BBB40","UNK_TYPE1","",0x1), 0x808BBB50:("D_808BBB50","UNK_TYPE4","",0x4), - 0x808BBB5C:("D_808BBB5C","f32","",0x4), - 0x808BBB64:("D_808BBB64","f32","",0x4), - 0x808BBB68:("D_808BBB68","UNK_TYPE1","",0x1), - 0x808BBB6C:("D_808BBB6C","f32","",0x4), + 0x808BBB5C:("D_808BBB5C","Vec3f","",0xC), + 0x808BBB68:("D_808BBB68","Vec3f","",0xC), 0x808BBB80:("jtbl_808BBB80","UNK_PTR","",0x4), 0x808BBB98:("jtbl_808BBB98","UNK_PTR","",0x4), 0x808BBBB4:("D_808BBBB4","f32","",0x4), @@ -6898,7 +6892,7 @@ 0x808C99C0:("D_808C99C0","UNK_TYPE1","",0x1), 0x808C9A10:("D_808C9A10","UNK_TYPE1","",0x1), 0x808C9A30:("D_808C9A30","UNK_TYPE1","",0x1), - 0x808C9A3C:("D_808C9A3C","EffBlureInit2","",0x24), + 0x808C9A3C:("D_808C9A3C","EffectBlureInit2","",0x24), 0x808C9A60:("D_808C9A60","UNK_TYPE1","",0x1), 0x808C9A70:("D_808C9A70","UNK_TYPE1","",0x1), 0x808C9A7C:("D_808C9A7C","UNK_TYPE1","",0x1), @@ -7473,7 +7467,7 @@ 0x808F88C0:("En_Bom_Chu_InitVars","UNK_TYPE1","",0x1), 0x808F88E0:("D_808F88E0","UNK_TYPE1","",0x1), 0x808F8908:("D_808F8908","UNK_TYPE2","",0x2), - 0x808F8914:("D_808F8914","EffBlureInit2","",0x24), + 0x808F8914:("D_808F8914","EffectBlureInit2","",0x24), 0x808F8938:("D_808F8938","UNK_TYPE1","",0x1), 0x808F8944:("D_808F8944","UNK_TYPE1","",0x1), 0x808F8950:("D_808F8950","UNK_TYPE1","",0x1), @@ -7549,12 +7543,11 @@ 0x808FC670:("En_Fr_InitVars","UNK_TYPE1","",0x1), 0x8090CCB0:("En_Fishing_InitVars","UNK_TYPE1","",0x1), 0x8090CCD0:("D_8090CCD0","f32","",0x4), - 0x8090CCD4:("D_8090CCD4","UNK_TYPE1","",0x1), + 0x8090CCD4:("D_8090CCD4","u8","",0x1), 0x8090CCD8:("D_8090CCD8","f32","",0x4), - 0x8090CCDC:("D_8090CCDC","UNK_TYPE1","",0x1), - 0x8090CCE4:("D_8090CCE4","UNK_TYPE4","",0x4), - 0x8090CCE8:("D_8090CCE8","UNK_TYPE4","",0x4), - 0x8090CCEC:("D_8090CCEC","UNK_TYPE1","",0x1), + 0x8090CCDC:("D_8090CCDC","Vec3f","",0xC), + 0x8090CCE8:("D_8090CCE8","f32","",0x4), + 0x8090CCEC:("sSinkingLureLocation","u8","",0x1), 0x8090CCF0:("D_8090CCF0","f32","",0x4), 0x8090CCF4:("D_8090CCF4","UNK_TYPE1","",0x1), 0x8090CCF8:("D_8090CCF8","UNK_TYPE2","",0x2), @@ -7565,18 +7558,17 @@ 0x8090CD0C:("D_8090CD0C","UNK_TYPE1","",0x1), 0x8090CD10:("D_8090CD10","UNK_TYPE1","",0x1), 0x8090CD14:("D_8090CD14","UNK_TYPE2","",0x2), - 0x8090CD18:("D_8090CD18","UNK_TYPE1","",0x1), - 0x8090CD1C:("D_8090CD1C","f32","",0x4), + 0x8090CD18:("sFishMouthOffset","Vec3f","",0xC), 0x8090CD24:("D_8090CD24","UNK_TYPE1","",0x1), 0x8090CD28:("D_8090CD28","f32","",0x4), 0x8090CD2C:("D_8090CD2C","f32","",0x4), 0x8090CD30:("D_8090CD30","f32","",0x4), 0x8090CD34:("D_8090CD34","f32","",0x4), - 0x8090CD38:("D_8090CD38","UNK_TYPE4","",0x4), + 0x8090CD38:("D_8090CD38","f32","",0x4), 0x8090CD3C:("D_8090CD3C","f32","",0x4), 0x8090CD40:("D_8090CD40","f32","",0x4), - 0x8090CD44:("D_8090CD44","UNK_TYPE2","",0x2), - 0x8090CD48:("D_8090CD48","UNK_TYPE2","",0x2), + 0x8090CD44:("D_8090CD44","s16","",0x2), + 0x8090CD48:("D_8090CD48","s16","",0x2), 0x8090CD4C:("D_8090CD4C","UNK_TYPE1","",0x1), 0x8090CD50:("D_8090CD50","UNK_TYPE1","",0x1), 0x8090CD54:("D_8090CD54","UNK_TYPE1","",0x1), @@ -7586,7 +7578,8 @@ 0x8090CD8C:("D_8090CD8C","UNK_TYPE1","",0x1), 0x8090CF08:("D_8090CF08","UNK_TYPE1","",0x1), 0x8090CF18:("D_8090CF18","UNK_TYPE1","",0x1), - 0x8090CF1C:("D_8090CF1C","UNK_TYPE4","",0x4), + 0x8090CF1C:("sZeroVec","Vec3f","",0xC), + 0x8090CF28:("D_8090CF28","Vec3f","",0xC), 0x8090CF34:("D_8090CF34","UNK_TYPE4","",0x4), 0x8090CF40:("D_8090CF40","UNK_TYPE4","",0x4), 0x8090CF4C:("D_8090CF4C","UNK_TYPE4","",0x4), @@ -7600,14 +7593,14 @@ 0x8090D508:("D_8090D508","UNK_TYPE1","",0x1), 0x8090D558:("D_8090D558","UNK_TYPE1","",0x1), 0x8090D5B0:("D_8090D5B0","UNK_TYPE4","",0x4), - 0x8090D608:("D_8090D608","UNK_TYPE1","",0x1), - 0x8090D614:("D_8090D614","UNK_TYPE1","",0x1), - 0x8090D620:("D_8090D620","UNK_TYPE4","",0x4), + 0x8090D608:("sRodTipOffset","Vec3f","",0xC), + 0x8090D614:("D_8090D614","Vec3f","",0xC), + 0x8090D620:("D_8090D620","Vec3f","",0xC), 0x8090D62C:("D_8090D62C","UNK_TYPE1","",0x1), 0x8090D638:("D_8090D638","UNK_TYPE1","",0x1), - 0x8090D644:("D_8090D644","UNK_TYPE1","",0x1), - 0x8090D650:("D_8090D650","UNK_TYPE1","",0x1), - 0x8090D65C:("D_8090D65C","UNK_TYPE1","",0x1), + 0x8090D644:("D_8090D644","s16","[5]",0xA), + 0x8090D650:("sStreamSoundPos","Vec3f","",0xC), + 0x8090D65C:("sSinkingLureLocationPos","Vec3s","[4]",0x18), 0x8090D674:("D_8090D674","UNK_TYPE1","",0x1), 0x8090D680:("D_8090D680","f32","",0x4), 0x8090D684:("D_8090D684","f32","",0x4), @@ -7893,46 +7886,37 @@ 0x809101C8:("D_809101C8","f32","",0x4), 0x809101CC:("D_809101CC","UNK_TYPE1","",0x1), 0x809101D0:("D_809101D0","UNK_TYPE1","",0x1), - 0x809101D8:("D_809101D8","UNK_TYPE1","",0x1), - 0x809101E8:("D_809101E8","UNK_TYPE1","",0x1), - 0x80910B3C:("D_80910B3C","f32","",0x4), - 0x80910B40:("D_80910B40","f32","",0x4), - 0x80910B44:("D_80910B44","f32","",0x4), - 0x80910B48:("D_80910B48","UNK_TYPE1","",0x1), - 0x809114A8:("D_809114A8","UNK_TYPE1","",0x1), - 0x80911E08:("D_80911E08","UNK_TYPE1","",0x1), - 0x80911E14:("D_80911E14","UNK_TYPE1","",0x1), - 0x80911E20:("D_80911E20","UNK_TYPE1","",0x1), + 0x809101D8:("sRodTipPos","Vec3f","",0xC), + 0x809101E8:("sReelLinePos","Vec3f","[200]",0x960), + 0x80910B48:("sReelLineRot","Vec3f","[200]",0x960), + 0x809114A8:("sReelLineUnk","Vec3f","[200]",0x960), + 0x80911E08:("sLureHookRefPos","Vec3f","[2]",0x18), + 0x80911E20:("sLureHookRotY","f32","[2]",0x8), 0x80911E28:("D_80911E28","UNK_TYPE1","",0x1), - 0x80911E30:("D_80911E30","UNK_TYPE1","",0x1), - 0x80911E3C:("D_80911E3C","UNK_TYPE1","",0x1), + 0x80911E30:("sSinkingLurePos","Vec3f","[20]",0xF0), 0x80911F20:("D_80911F20","UNK_TYPE1","",0x1), - 0x80911F24:("D_80911F24","UNK_TYPE1","",0x1), - 0x80911F28:("D_80911F28","f32","",0x4), - 0x80911F2C:("D_80911F2C","f32","",0x4), - 0x80911F30:("D_80911F30","UNK_TYPE1","",0x1), - 0x80911F38:("D_80911F38","f32","",0x4), - 0x80911F3C:("D_80911F3C","f32","",0x4), - 0x80911F40:("D_80911F40","f32","",0x4), - 0x80911F44:("D_80911F44","UNK_TYPE1","",0x1), + 0x80911F24:("sProjectedW","f32","",0x4), + 0x80911F28:("sCameraEye","Vec3f","",0xC), + 0x80911F38:("sCameraAt","Vec3f","",0xC), + 0x80911F44:("sCameraId","s32","",0x4), 0x80911F48:("D_80911F48","f32","",0x4), 0x80911F4C:("D_80911F4C","f32","",0x4), 0x80911F50:("D_80911F50","UNK_TYPE1","",0x1), - 0x80911F58:("D_80911F58","UNK_TYPE1","",0x1), + 0x80911F58:("sSinkingLureBasePos","Vec3f","",0xC), 0x80911F64:("D_80911F64","f32","",0x4), - 0x80911F68:("D_80911F68","UNK_TYPE1","",0x1), - 0x80911F6C:("D_80911F6C","UNK_TYPE1","",0x1), - 0x80911F70:("D_80911F70","UNK_TYPE1","",0x1), - 0x80911F78:("D_80911F78","UNK_TYPE1","",0x1), - 0x80914048:("D_80914048","UNK_TYPE1","",0x1), - 0x80915128:("D_80915128","f32","",0x4), - 0x8091512C:("D_8091512C","f32","",0x4), - 0x80915130:("D_80915130","UNK_TYPE1","",0x1), - 0x80915138:("D_80915138","UNK_TYPE1","",0x1), - 0x809171B8:("D_809171B8","UNK_TYPE1","",0x1), - 0x809171C4:("D_809171C4","UNK_TYPE1","",0x1), + 0x80911F68:("sRandSeed0","s32","",0x4), + 0x80911F6C:("sRandSeed1","s32","",0x4), + 0x80911F70:("sRandSeed2","s32","",0x4), + 0x80911F78:("sPondProps","UNK_TYPE1","[140]",0x20D0), + 0x80914048:("sGroupFishes","UNK_TYPE1","[60]",0x10E0), + 0x80915128:("sFishGroupAngle1","f32","",0x4), + 0x8091512C:("sFishGroupAngle2","f32","",0x4), + 0x80915130:("sFishGroupAngle3","f32","",0x4), + 0x80915138:("sFishingEffects","UNK_TYPE1","[130]",0x2080), + 0x809171B8:("sStreamSoundProjectedPos","Vec3f","",0xC), + 0x809171C4:("sFishingMain","UNK_TYPE","",0x4), 0x809171C8:("D_809171C8","UNK_TYPE1","",0x1), - 0x809171C9:("D_809171C9","UNK_TYPE1","",0x1), + 0x809171C9:("sLinkAge","UNK_TYPE1","",0x1), 0x809171CA:("D_809171CA","UNK_TYPE1","",0x1), 0x809171CB:("D_809171CB","UNK_TYPE1","",0x1), 0x809171CC:("D_809171CC","f32","",0x4), @@ -7944,29 +7928,23 @@ 0x809171D8:("D_809171D8","UNK_TYPE1","",0x1), 0x809171DA:("D_809171DA","UNK_TYPE1","",0x1), 0x809171DC:("D_809171DC","UNK_TYPE1","",0x1), - 0x809171E0:("D_809171E0","UNK_TYPE1","",0x1), - 0x809171EC:("D_809171EC","UNK_TYPE1","",0x1), - 0x809171EE:("D_809171EE","UNK_TYPE1","",0x1), - 0x809171F0:("D_809171F0","UNK_TYPE1","",0x1), + 0x809171E0:("sOwnerHeadPos","Vec3f","",0xC), + 0x809171EC:("sEffOwnerHatRot","Vec3s","",0x6), 0x809171F2:("D_809171F2","UNK_TYPE1","",0x1), 0x809171F4:("D_809171F4","UNK_TYPE1","",0x1), 0x809171F6:("D_809171F6","UNK_TYPE1","",0x1), - 0x809171F8:("D_809171F8","UNK_TYPE1","",0x1), + 0x809171F8:("sFishingHookedFish","UNK_TYPE","",0x4), 0x809171FC:("D_809171FC","UNK_TYPE1","",0x1), 0x809171FE:("D_809171FE","UNK_TYPE1","",0x1), 0x80917200:("D_80917200","UNK_TYPE1","",0x1), 0x80917202:("D_80917202","UNK_TYPE1","",0x1), 0x80917204:("D_80917204","UNK_TYPE1","",0x1), 0x80917206:("D_80917206","UNK_TYPE1","",0x1), - 0x80917208:("D_80917208","f32","",0x4), - 0x8091720C:("D_8091720C","f32","",0x4), - 0x80917210:("D_80917210","UNK_TYPE1","",0x1), + 0x80917208:("sLurePos","Vec3f","",0xC), 0x80917218:("D_80917218","UNK_TYPE1","",0x1), - 0x80917228:("D_80917228","UNK_TYPE1","",0x1), - 0x8091722C:("D_8091722C","UNK_TYPE1","",0x1), - 0x80917238:("D_80917238","UNK_TYPE1","",0x1), - 0x8091723C:("D_8091723C","UNK_TYPE1","",0x1), - 0x80917248:("D_80917248","UNK_TYPE1","",0x1), + 0x80917228:("sLureRot","Vec3f","",0xC), + 0x80917238:("D_80917238","Vec3f","",0xC), + 0x80917248:("D_80917248","Vec3f","",0xC), 0x80917254:("D_80917254","f32","",0x4), 0x80917258:("D_80917258","UNK_TYPE1","",0x1), 0x8091725C:("D_8091725C","f32","",0x4), @@ -7978,8 +7956,7 @@ 0x80917270:("D_80917270","UNK_TYPE1","",0x1), 0x80917272:("D_80917272","UNK_TYPE1","",0x1), 0x80917274:("D_80917274","UNK_TYPE1","",0x1), - 0x80917278:("D_80917278","UNK_TYPE1","",0x1), - 0x8091727C:("D_8091727C","UNK_TYPE1","",0x1), + 0x80917278:("D_80917278","Vec3f","",0xC), 0x80918830:("Obj_Oshihiki_InitVars","UNK_TYPE1","",0x1), 0x80918850:("D_80918850","UNK_TYPE1","",0x1), 0x80918868:("D_80918868","UNK_TYPE1","",0x1), @@ -8282,7 +8259,7 @@ 0x8092C140:("D_8092C140","UNK_TYPE1","",0x1), 0x8092C160:("D_8092C160","UNK_TYPE1","",0x1), 0x8092C168:("D_8092C168","UNK_TYPE1","",0x1), - 0x8092C174:("D_8092C174","EffBlureInit2","",0x24), + 0x8092C174:("D_8092C174","EffectBlureInit2","",0x24), 0x8092C198:("D_8092C198","UNK_TYPE4","",0x4), 0x8092C19C:("D_8092C19C","UNK_TYPE1","",0x1), 0x8092C1A8:("D_8092C1A8","UNK_TYPE1","",0x1), @@ -8594,7 +8571,7 @@ 0x80942E60:("D_80942E60","UNK_TYPE1","",0x1), 0x80942E6C:("D_80942E6C","UNK_TYPE1","",0x1), 0x80942E78:("D_80942E78","UNK_TYPE1","",0x1), - 0x80942E8C:("D_80942E8C","EffTireMarkInit","",0x8), + 0x80942E8C:("D_80942E8C","EffectTireMarkInit","",0x8), 0x80942E94:("D_80942E94","UNK_TYPE1","",0x1), 0x80942E9C:("D_80942E9C","UNK_TYPE1","",0x1), 0x80942EAC:("D_80942EAC","UNK_TYPE1","",0x1), @@ -8805,14 +8782,14 @@ 0x809548A0:("Bg_Ingate_InitVars","UNK_TYPE1","",0x1), 0x809572E0:("En_Kanban_InitVars","UNK_TYPE1","",0x1), 0x80957300:("D_80957300","UNK_TYPE1","",0x1), - 0x8095732C:("D_8095732C","UNK_TYPE2","",0x2), + 0x8095732C:("sPartFlags","UNK_TYPE2","",0x2), 0x8095732E:("D_8095732E","UNK_TYPE2","",0x2), 0x80957330:("D_80957330","UNK_TYPE2","",0x2), 0x80957332:("D_80957332","UNK_TYPE2","",0x2), - 0x80957344:("D_80957344","UNK_TYPE4","",0x4), - 0x80957428:("D_80957428","UNK_TYPE4","",0x4), - 0x8095750C:("D_8095750C","UNK_TYPE1","",0x1), - 0x80957530:("D_80957530","UNK_TYPE1","",0x1), + 0x80957344:("sPieceOffsets","UNK_TYPE4","",0x4), + 0x80957428:("sPieceSizes","UNK_TYPE4","",0x4), + 0x8095750C:("sCutTypes","UNK_TYPE1","",0x1), + 0x80957530:("sCutFlags","UNK_TYPE1","",0x1), 0x8095753C:("D_8095753C","UNK_TYPE4","",0x4), 0x80957548:("D_80957548","UNK_TYPE4","",0x4), 0x8095754C:("D_8095754C","UNK_TYPE4","",0x4), @@ -10700,8 +10677,8 @@ 0x80A07F0C:("D_80A07F0C","UNK_TYPE1","",0x1), 0x80A07F3C:("D_80A07F3C","UNK_TYPE1","",0x1), 0x80A07F54:("D_80A07F54","UNK_TYPE2","",0x2), - 0x80A07F5C:("D_80A07F5C","EffTireMarkInit","",0x8), - 0x80A07F64:("D_80A07F64","EffTireMarkInit","",0x8), + 0x80A07F5C:("D_80A07F5C","EffectTireMarkInit","",0x8), + 0x80A07F64:("D_80A07F64","EffectTireMarkInit","",0x8), 0x80A07F6C:("D_80A07F6C","UNK_TYPE4","",0x4), 0x80A07FA8:("D_80A07FA8","UNK_TYPE4","",0x4), 0x80A07FB4:("D_80A07FB4","UNK_TYPE4","",0x4), @@ -11024,7 +11001,7 @@ 0x80A166B0:("D_80A166B0","UNK_TYPE1","",0x1), 0x80A166BC:("D_80A166BC","UNK_TYPE1","",0x1), 0x80A166D4:("D_80A166D4","UNK_TYPE1","",0x1), - 0x80A166DC:("D_80A166DC","EffTireMarkInit","",0x8), + 0x80A166DC:("D_80A166DC","EffectTireMarkInit","",0x8), 0x80A166E4:("D_80A166E4","UNK_TYPE4","",0x4), 0x80A16704:("D_80A16704","UNK_TYPE1","",0x1), 0x80A1670C:("D_80A1670C","UNK_TYPE1","",0x1), @@ -11685,8 +11662,8 @@ 0x80A4169C:("D_80A4169C","UNK_PTR","",0x4), 0x80A416C0:("D_80A416C0","UNK_PTR","",0x4), 0x80A416E0:("D_80A416E0","UNK_TYPE1","",0x1), - 0x80A417BC:("D_80A417BC","EffBlureInit2","",0x24), - 0x80A417E0:("D_80A417E0","EffTireMarkInit","",0x8), + 0x80A417BC:("D_80A417BC","EffectBlureInit2","",0x24), + 0x80A417E0:("D_80A417E0","EffectTireMarkInit","",0x8), 0x80A417E8:("D_80A417E8","UNK_TYPE1","",0x1), 0x80A417EC:("D_80A417EC","UNK_PTR","",0x4), 0x80A41828:("D_80A41828","UNK_TYPE1","",0x1), @@ -11992,7 +11969,7 @@ 0x80A5844C:("D_80A5844C","UNK_TYPE1","",0x1), 0x80A58454:("D_80A58454","UNK_TYPE4","",0x4), 0x80A58464:("D_80A58464","UNK_TYPE1","",0x1), - 0x80A58470:("D_80A58470","EffBlureInit2","",0x24), + 0x80A58470:("D_80A58470","EffectBlureInit2","",0x24), 0x80A58494:("D_80A58494","UNK_TYPE4","",0x4), 0x80A58498:("D_80A58498","UNK_TYPE1","",0x1), 0x80A584A4:("D_80A584A4","UNK_TYPE1","",0x1), @@ -12053,10 +12030,8 @@ 0x80A5EAFE:("D_80A5EAFE","UNK_TYPE2","",0x2), 0x80A5EB00:("D_80A5EB00","UNK_TYPE2","",0x2), 0x80A5EB04:("D_80A5EB04","UNK_TYPE2","",0x2), - 0x80A5EB0C:("D_80A5EB0C","f32","",0x4), - 0x80A5EB14:("D_80A5EB14","f32","",0x4), - 0x80A5EB18:("D_80A5EB18","f32","",0x4), - 0x80A5EB20:("D_80A5EB20","f32","",0x4), + 0x80A5EB0C:("D_80A5EB0C","Vec3f","",0xC), + 0x80A5EB18:("D_80A5EB18","Vec3f","",0xC), 0x80A5EB24:("D_80A5EB24","UNK_TYPE1","",0x1), 0x80A5EB48:("D_80A5EB48","UNK_TYPE4","",0x4), 0x80A5EB4C:("D_80A5EB4C","UNK_TYPE1","",0x1), @@ -12302,10 +12277,7 @@ 0x80A6BB00:("D_80A6BB00","f32","",0x4), 0x80A6E490:("En_Fall_InitVars","UNK_TYPE1","",0x1), 0x80A6E4B0:("D_80A6E4B0","UNK_TYPE4","",0x4), - 0x80A6E4B4:("D_80A6E4B4","UNK_TYPE1","",0x1), - 0x80A6E4B5:("D_80A6E4B5","UNK_TYPE1","",0x1), - 0x80A6E584:("D_80A6E584","UNK_TYPE1","",0x1), - 0x80A6E585:("D_80A6E585","UNK_TYPE1","",0x1), + 0x80A6E4B4:("D_80A6E4B4","s8","[0xD1]",0xD0), 0x80A6E588:("D_80A6E588","UNK_TYPE1","",0x1), 0x80A6E594:("D_80A6E594","UNK_TYPE1","",0x1), 0x80A6E5A0:("D_80A6E5A0","f32","",0x4), @@ -12337,8 +12309,6 @@ 0x80A6E650:("D_80A6E650","f32","",0x4), 0x80A6E654:("D_80A6E654","f32","",0x4), 0x80A6E990:("D_80A6E990","UNK_TYPE1","",0x1), - 0x80A6E9B4:("D_80A6E9B4","UNK_TYPE1","",0x1), - 0x80A6E9D8:("D_80A6E9D8","UNK_TYPE1","",0x1), 0x80A6F098:("D_80A6F098","UNK_TYPE1","",0x1), 0x80A703D0:("En_Mm3_InitVars","UNK_TYPE1","",0x1), 0x80A703F0:("D_80A703F0","UNK_TYPE1","",0x1), @@ -14585,7 +14555,7 @@ 0x80B40780:("D_80B40780","UNK_TYPE1","",0x1), 0x80B43250:("En_Kgy_InitVars","UNK_TYPE1","",0x1), 0x80B43270:("D_80B43270","UNK_TYPE1","",0x1), - 0x80B43298:("D_80B43298","EffShieldParticleInit","",0x40), + 0x80B43298:("D_80B43298","EffectShieldParticleInit","",0x40), 0x80B432C6:("D_80B432C6","UNK_TYPE1","",0x1), 0x80B432C8:("D_80B432C8","UNK_TYPE1","",0x1), 0x80B432CA:("D_80B432CA","UNK_TYPE1","",0x1), @@ -15797,7 +15767,7 @@ 0x80BB3ED4:("D_80BB3ED4","UNK_TYPE1","",0x1), 0x80BB3EF4:("D_80BB3EF4","UNK_TYPE1","",0x1), 0x80BB4044:("D_80BB4044","UNK_TYPE1","",0x1), - 0x80BB405C:("D_80BB405C","EffTireMarkInit","",0x8), + 0x80BB405C:("D_80BB405C","EffectTireMarkInit","",0x8), 0x80BB4064:("D_80BB4064","UNK_TYPE4","",0x4), 0x80BB4070:("D_80BB4070","UNK_TYPE4","",0x4), 0x80BB407C:("D_80BB407C","UNK_TYPE1","",0x1), @@ -16449,7 +16419,7 @@ 0x80BF5954:("D_80BF5954","UNK_TYPE1","",0x1), 0x80BF5960:("D_80BF5960","UNK_TYPE1","",0x1), 0x80BF596C:("D_80BF596C","UNK_TYPE1","",0x1), - 0x80BF59F0:("D_80BF59F0","EffTireMarkInit","",0x8), + 0x80BF59F0:("D_80BF59F0","EffectTireMarkInit","",0x8), 0x80BF59F8:("D_80BF59F8","UNK_TYPE1","",0x1), 0x80BF5A10:("D_80BF5A10","f32","",0x4), 0x80BF5A14:("D_80BF5A14","f32","",0x4), diff --git a/tools/extract_baserom.py b/tools/extract_baserom.py index a2734d9003..bf9829bcb3 100755 --- a/tools/extract_baserom.py +++ b/tools/extract_baserom.py @@ -44,7 +44,7 @@ FILE_NAMES = [ 'ovl_file_choose', 'ovl_daytelop', 'ovl_kaleido_scope', - 'ovl_Player_Actor', + 'ovl_player_actor', 'ovl_En_Test', 'ovl_En_GirlA', 'ovl_En_Part', diff --git a/tools/filelists/mm.us.rev1/all.csv b/tools/filelists/mm.us.rev1/all.csv index 836f6d1722..b76d241e19 100644 --- a/tools/filelists/mm.us.rev1/all.csv +++ b/tools/filelists/mm.us.rev1/all.csv @@ -36,7 +36,7 @@ 35,ovl_file_choose 36,ovl_daytelop 37,ovl_kaleido_scope -38,ovl_Player_Actor +38,ovl_player_actor 39,ovl_En_Test 40,ovl_En_GirlA 41,ovl_En_Part diff --git a/tools/filelists/mm.us.rev1/interface.csv b/tools/filelists/mm.us.rev1/interface.csv index db78965de0..726df54678 100644 --- a/tools/filelists/mm.us.rev1/interface.csv +++ b/tools/filelists/mm.us.rev1/interface.csv @@ -9,3 +9,5 @@ 26,message_static 27,message_texture_static 28,nes_font_static +1126,parameter_static +1127,week_static diff --git a/tools/filelists/mm.us.rev1/misc.csv b/tools/filelists/mm.us.rev1/misc.csv index caebc3bb1b..1d2c8bfa3a 100644 --- a/tools/filelists/mm.us.rev1/misc.csv +++ b/tools/filelists/mm.us.rev1/misc.csv @@ -12,8 +12,6 @@ 1123,title_static 1124,memerrmsg 1125,locerrmsg -1126,parameter_static -1127,week_static 1128,daytelop_static 1129,ger_daytelop_static 1130,fra_daytelop_static @@ -21,4 +19,3 @@ 1132,d2_fine_static 1133,d2_cloud_static 1134,d2_fine_pal_static -1538,bump_texture_static diff --git a/tools/filelists/mm.us.rev1/overlay.csv b/tools/filelists/mm.us.rev1/overlay.csv index 84943c7942..a0ec8a58db 100644 --- a/tools/filelists/mm.us.rev1/overlay.csv +++ b/tools/filelists/mm.us.rev1/overlay.csv @@ -4,7 +4,7 @@ 35,ovl_file_choose 36,ovl_daytelop 37,ovl_kaleido_scope -38,ovl_Player_Actor +38,ovl_player_actor 39,ovl_En_Test 40,ovl_En_GirlA 41,ovl_En_Part diff --git a/tools/filelists/mm.us.rev1/segments.csv b/tools/filelists/mm.us.rev1/segments.csv index b22534d94e..4362b8db6f 100644 --- a/tools/filelists/mm.us.rev1/segments.csv +++ b/tools/filelists/mm.us.rev1/segments.csv @@ -1,4 +1,5 @@ 652,gameplay_object_exchange_static +1538,bump_texture_static 1539,anime_model_1_static 1540,anime_model_2_static 1541,anime_model_3_static diff --git a/tools/ido_recomp/linux/5.3/as1 b/tools/ido_recomp/linux/5.3/as1 index 17ff2aa7c1..41c2545afb 100755 Binary files a/tools/ido_recomp/linux/5.3/as1 and b/tools/ido_recomp/linux/5.3/as1 differ diff --git a/tools/ido_recomp/linux/5.3/cc b/tools/ido_recomp/linux/5.3/cc index 6dbb85eb10..3dcc537985 100755 Binary files a/tools/ido_recomp/linux/5.3/cc and b/tools/ido_recomp/linux/5.3/cc differ diff --git a/tools/ido_recomp/linux/5.3/cfe b/tools/ido_recomp/linux/5.3/cfe index d742f7b2ed..e9594fafcb 100755 Binary files a/tools/ido_recomp/linux/5.3/cfe and b/tools/ido_recomp/linux/5.3/cfe differ diff --git a/tools/ido_recomp/linux/5.3/ugen b/tools/ido_recomp/linux/5.3/ugen index 692086f0ca..b2b662f1d3 100755 Binary files a/tools/ido_recomp/linux/5.3/ugen and b/tools/ido_recomp/linux/5.3/ugen differ diff --git a/tools/ido_recomp/linux/5.3/ujoin b/tools/ido_recomp/linux/5.3/ujoin new file mode 100644 index 0000000000..f9c90b8bec Binary files /dev/null and b/tools/ido_recomp/linux/5.3/ujoin differ diff --git a/tools/ido_recomp/linux/5.3/uld b/tools/ido_recomp/linux/5.3/uld new file mode 100644 index 0000000000..f227222bce Binary files /dev/null and b/tools/ido_recomp/linux/5.3/uld differ diff --git a/tools/ido_recomp/linux/5.3/umerge b/tools/ido_recomp/linux/5.3/umerge new file mode 100644 index 0000000000..00a8281d23 Binary files /dev/null and b/tools/ido_recomp/linux/5.3/umerge differ diff --git a/tools/ido_recomp/linux/5.3/uopt b/tools/ido_recomp/linux/5.3/uopt index 49558be9f8..5afe7a11c1 100755 Binary files a/tools/ido_recomp/linux/5.3/uopt and b/tools/ido_recomp/linux/5.3/uopt differ diff --git a/tools/ido_recomp/linux/5.3/usplit b/tools/ido_recomp/linux/5.3/usplit new file mode 100644 index 0000000000..a1c5ebad62 Binary files /dev/null and b/tools/ido_recomp/linux/5.3/usplit differ diff --git a/tools/ido_recomp/linux/7.1/as1 b/tools/ido_recomp/linux/7.1/as1 index a7bb3adc37..01dbc6f6b4 100755 Binary files a/tools/ido_recomp/linux/7.1/as1 and b/tools/ido_recomp/linux/7.1/as1 differ diff --git a/tools/ido_recomp/linux/7.1/cc b/tools/ido_recomp/linux/7.1/cc index e926b545e1..a7f06afa8a 100755 Binary files a/tools/ido_recomp/linux/7.1/cc and b/tools/ido_recomp/linux/7.1/cc differ diff --git a/tools/ido_recomp/linux/7.1/cfe b/tools/ido_recomp/linux/7.1/cfe index 3a3e983131..2c6767e69d 100755 Binary files a/tools/ido_recomp/linux/7.1/cfe and b/tools/ido_recomp/linux/7.1/cfe differ diff --git a/tools/ido_recomp/linux/7.1/ugen b/tools/ido_recomp/linux/7.1/ugen index e8e875635a..f5c1a2e20c 100755 Binary files a/tools/ido_recomp/linux/7.1/ugen and b/tools/ido_recomp/linux/7.1/ugen differ diff --git a/tools/ido_recomp/linux/7.1/umerge b/tools/ido_recomp/linux/7.1/umerge new file mode 100644 index 0000000000..b0c8c1778b Binary files /dev/null and b/tools/ido_recomp/linux/7.1/umerge differ diff --git a/tools/ido_recomp/linux/7.1/uopt b/tools/ido_recomp/linux/7.1/uopt index fd93d2dc5e..ecf7eab725 100755 Binary files a/tools/ido_recomp/linux/7.1/uopt and b/tools/ido_recomp/linux/7.1/uopt differ diff --git a/tools/ido_recomp/macos/5.3/acpp b/tools/ido_recomp/macos/5.3/acpp new file mode 100755 index 0000000000..0431627703 Binary files /dev/null and b/tools/ido_recomp/macos/5.3/acpp differ diff --git a/tools/ido_recomp/macos/5.3/as0 b/tools/ido_recomp/macos/5.3/as0 new file mode 100755 index 0000000000..9cff1dcd78 Binary files /dev/null and b/tools/ido_recomp/macos/5.3/as0 differ diff --git a/tools/ido_recomp/macos/5.3/as1 b/tools/ido_recomp/macos/5.3/as1 index 692fe600c2..df0142e869 100755 Binary files a/tools/ido_recomp/macos/5.3/as1 and b/tools/ido_recomp/macos/5.3/as1 differ diff --git a/tools/ido_recomp/macos/5.3/cc b/tools/ido_recomp/macos/5.3/cc index 90ffc74096..e9b599bdad 100755 Binary files a/tools/ido_recomp/macos/5.3/cc and b/tools/ido_recomp/macos/5.3/cc differ diff --git a/tools/ido_recomp/macos/5.3/cfe b/tools/ido_recomp/macos/5.3/cfe index 753be0d6c7..30e514947f 100755 Binary files a/tools/ido_recomp/macos/5.3/cfe and b/tools/ido_recomp/macos/5.3/cfe differ diff --git a/tools/ido_recomp/macos/5.3/copt b/tools/ido_recomp/macos/5.3/copt new file mode 100755 index 0000000000..243c37a291 Binary files /dev/null and b/tools/ido_recomp/macos/5.3/copt differ diff --git a/tools/ido_recomp/macos/5.3/err.english.cc b/tools/ido_recomp/macos/5.3/err.english.cc old mode 100755 new mode 100644 diff --git a/tools/ido_recomp/macos/5.3/ugen b/tools/ido_recomp/macos/5.3/ugen index c7020aa493..7f18bf44bb 100755 Binary files a/tools/ido_recomp/macos/5.3/ugen and b/tools/ido_recomp/macos/5.3/ugen differ diff --git a/tools/ido_recomp/macos/5.3/ujoin b/tools/ido_recomp/macos/5.3/ujoin new file mode 100755 index 0000000000..30503f95d0 Binary files /dev/null and b/tools/ido_recomp/macos/5.3/ujoin differ diff --git a/tools/ido_recomp/macos/5.3/uld b/tools/ido_recomp/macos/5.3/uld new file mode 100755 index 0000000000..13aa261f5a Binary files /dev/null and b/tools/ido_recomp/macos/5.3/uld differ diff --git a/tools/ido_recomp/macos/5.3/umerge b/tools/ido_recomp/macos/5.3/umerge new file mode 100755 index 0000000000..c31c866d53 Binary files /dev/null and b/tools/ido_recomp/macos/5.3/umerge differ diff --git a/tools/ido_recomp/macos/5.3/uopt b/tools/ido_recomp/macos/5.3/uopt index e23f6beda8..7bbaac2986 100755 Binary files a/tools/ido_recomp/macos/5.3/uopt and b/tools/ido_recomp/macos/5.3/uopt differ diff --git a/tools/ido_recomp/macos/5.3/usplit b/tools/ido_recomp/macos/5.3/usplit new file mode 100755 index 0000000000..a959848032 Binary files /dev/null and b/tools/ido_recomp/macos/5.3/usplit differ diff --git a/tools/ido_recomp/macos/7.1/as1 b/tools/ido_recomp/macos/7.1/as1 index 358712e331..88b9f1f7ec 100755 Binary files a/tools/ido_recomp/macos/7.1/as1 and b/tools/ido_recomp/macos/7.1/as1 differ diff --git a/tools/ido_recomp/macos/7.1/cc b/tools/ido_recomp/macos/7.1/cc index fb68103471..ae54cdbcde 100755 Binary files a/tools/ido_recomp/macos/7.1/cc and b/tools/ido_recomp/macos/7.1/cc differ diff --git a/tools/ido_recomp/macos/7.1/cfe b/tools/ido_recomp/macos/7.1/cfe index 1e13228628..6c468c3360 100755 Binary files a/tools/ido_recomp/macos/7.1/cfe and b/tools/ido_recomp/macos/7.1/cfe differ diff --git a/tools/ido_recomp/macos/7.1/err.english.cc b/tools/ido_recomp/macos/7.1/err.english.cc old mode 100755 new mode 100644 diff --git a/tools/ido_recomp/macos/7.1/ugen b/tools/ido_recomp/macos/7.1/ugen index fe90904a43..3fa7d48fc5 100755 Binary files a/tools/ido_recomp/macos/7.1/ugen and b/tools/ido_recomp/macos/7.1/ugen differ diff --git a/tools/ido_recomp/macos/7.1/umerge b/tools/ido_recomp/macos/7.1/umerge new file mode 100755 index 0000000000..3a9d5440cb Binary files /dev/null and b/tools/ido_recomp/macos/7.1/umerge differ diff --git a/tools/ido_recomp/macos/7.1/uopt b/tools/ido_recomp/macos/7.1/uopt index bb68f5d53a..b025fa2c5b 100755 Binary files a/tools/ido_recomp/macos/7.1/uopt and b/tools/ido_recomp/macos/7.1/uopt differ diff --git a/tools/m2ctx.py b/tools/m2ctx.py index 16087885b3..c2e50d59fd 100755 --- a/tools/m2ctx.py +++ b/tools/m2ctx.py @@ -41,7 +41,7 @@ def custom_replacements(output): actorList.append(actorListText.replace("first;", f"{actorCats[x]};") + "\n") if x == 2: actorList[x] = actorList[x].replace("Actor*", "Player*") - elif "ActorListEntry actorList[12];" in line: + elif "ActorListEntry actorLists[ACTORCAT_MAX];" in line: output[i] = "struct {\n" + "".join(actorList) + "};" ######################################################## diff --git a/tools/overlayhelpers/actor_symbols.py b/tools/overlayhelpers/actor_symbols.py index 88aa8aa402..e3f079ad92 100755 --- a/tools/overlayhelpers/actor_symbols.py +++ b/tools/overlayhelpers/actor_symbols.py @@ -3,7 +3,7 @@ import argparse, os, struct actor_names = [ - "ovl_Player_Actor", + "ovl_player_actor", "ovl_En_Test", "ovl_En_GirlA", "ovl_En_Part", @@ -719,7 +719,7 @@ def read_actor_ovl_tbl(): actortbl.append((actor_names[i], entry[0], entry[1], entry[2], entry[3])) entry = as_word_list(codefile.read(0x20)) i += 1 - actortbl[0] = ['ovl_Player_Actor', 0xCA7F00, 0xCDCF60, 0x8082DA90, 0x80862B70 ] + actortbl[0] = ['ovl_player_actor', 0xCA7F00, 0xCDCF60, 0x8082DA90, 0x80862B70 ] return actortbl actor_tbl = read_actor_ovl_tbl() diff --git a/tools/permuter_settings.toml b/tools/permuter_settings.toml index f5805056b5..eb2f1ac4b0 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -13,6 +13,7 @@ SQ = "int" CLAMP = "int" CLOCK_TIME = "int" CURRENT_DAY = "int" +NULL = "int" [decompme.compilers] "tools/ido_recomp/linux/7.1/cc" = "ido7.1" diff --git a/tools/rename_sym.sh b/tools/rename_sym.sh index e68966ca7a..227db4df72 100755 --- a/tools/rename_sym.sh +++ b/tools/rename_sym.sh @@ -10,4 +10,4 @@ fi #echo "Replace $1 with $2?" #read -grep -rl "$1" asm/**/*.s src/**/*.{c,h} include/**/*.h tools/disasm/functions.txt tools/disasm/variables.txt | xargs sed -i "s/\b$1\b/$2/g" \ No newline at end of file +grep -rl "$1" asm/**/*.s src/**/*.{c,h} include/**/*.h tools/disasm/functions.txt tools/disasm/variables.txt tools/sizes/*.csv | xargs sed -i "s/\b$1\b/$2/g" diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index 46e57b75c8..3685e3fa9c 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -201,7 +201,7 @@ asm/non_matchings/boot/system_malloc/SystemArena_MallocR.s,SystemArena_MallocR,0 asm/non_matchings/boot/system_malloc/SystemArena_Realloc.s,SystemArena_Realloc,0x80086E20,0xC asm/non_matchings/boot/system_malloc/SystemArena_Free.s,SystemArena_Free,0x80086E50,0xA asm/non_matchings/boot/system_malloc/SystemArena_Calloc.s,SystemArena_Calloc,0x80086E78,0x15 -asm/non_matchings/boot/system_malloc/SystemArena_AnalyzeArena.s,SystemArena_AnalyzeArena,0x80086ECC,0xE +asm/non_matchings/boot/system_malloc/SystemArena_GetSizes.s,SystemArena_GetSizes,0x80086ECC,0xE asm/non_matchings/boot/system_malloc/SystemArena_CheckArena.s,SystemArena_CheckArena,0x80086F04,0x9 asm/non_matchings/boot/system_malloc/SystemArena_InitArena.s,SystemArena_InitArena,0x80086F28,0xC asm/non_matchings/boot/system_malloc/SystemArena_Cleanup.s,SystemArena_Cleanup,0x80086F58,0x9 @@ -219,14 +219,14 @@ asm/non_matchings/boot/__osMalloc/ArenaImpl_Lock.s,ArenaImpl_Lock,0x8008718C,0xA asm/non_matchings/boot/__osMalloc/ArenaImpl_Unlock.s,ArenaImpl_Unlock,0x800871B4,0xA asm/non_matchings/boot/__osMalloc/ArenaImpl_GetLastBlock.s,ArenaImpl_GetLastBlock,0x800871DC,0xC asm/non_matchings/boot/__osMalloc/__osMallocInit.s,__osMallocInit,0x8008720C,0x14 -asm/non_matchings/boot/__osMalloc/__osMallocAddBlock.s,__osMallocAddBlock,0x8008725C,0x28 +asm/non_matchings/boot/__osMalloc/__osMallocAddHeap.s,__osMallocAddHeap,0x8008725C,0x28 asm/non_matchings/boot/__osMalloc/__osMallocCleanup.s,__osMallocCleanup,0x800872FC,0x8 asm/non_matchings/boot/__osMalloc/__osMallocIsInitalized.s,__osMallocIsInitalized,0x8008731C,0x2 asm/non_matchings/boot/__osMalloc/__osMalloc.s,__osMalloc,0x80087324,0x39 asm/non_matchings/boot/__osMalloc/__osMallocR.s,__osMallocR,0x80087408,0x39 asm/non_matchings/boot/__osMalloc/__osFree.s,__osFree,0x800874EC,0x3E asm/non_matchings/boot/__osMalloc/__osRealloc.s,__osRealloc,0x800875E4,0x4C -asm/non_matchings/boot/__osMalloc/__osAnalyzeArena.s,__osAnalyzeArena,0x80087714,0x2C +asm/non_matchings/boot/__osMalloc/__osGetSizes.s,__osGetSizes,0x80087714,0x2C asm/non_matchings/boot/__osMalloc/__osCheckArena.s,__osCheckArena,0x800877C4,0x1B asm/non_matchings/boot/sprintf/proutSprintf.s,proutSprintf,0x80087830,0x9 asm/non_matchings/boot/sprintf/vsprintf.s,vsprintf,0x80087854,0x14 diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 8a0090f845..ea6a1c6b87 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -25,28 +25,28 @@ asm/non_matchings/code/z_en_item00/Item_DropCollectibleRandom.s,Item_DropCollect asm/non_matchings/code/z_en_item00/func_800A8150.s,func_800A8150,0x800A8150,0xB asm/non_matchings/code/z_en_item00/func_800A817C.s,func_800A817C,0x800A817C,0xA asm/non_matchings/code/z_en_item00/func_800A81A4.s,func_800A81A4,0x800A81A4,0x13 -asm/non_matchings/code/z_eff_blure/func_800A81F0.s,func_800A81F0,0x800A81F0,0xC9 -asm/non_matchings/code/z_eff_blure/func_800A8514.s,func_800A8514,0x800A8514,0x11 -asm/non_matchings/code/z_eff_blure/EffectBlure_Initcommon.s,EffectBlure_Initcommon,0x800A8558,0x2E +asm/non_matchings/code/z_eff_blure/EffectBlure_AddVertex.s,EffectBlure_AddVertex,0x800A81F0,0xC9 +asm/non_matchings/code/z_eff_blure/EffectBlure_AddSpace.s,EffectBlure_AddSpace,0x800A8514,0x11 +asm/non_matchings/code/z_eff_blure/EffectBlure_InitElements.s,EffectBlure_InitElements,0x800A8558,0x2E asm/non_matchings/code/z_eff_blure/EffectBlure_Init1.s,EffectBlure_Init1,0x800A8610,0x44 asm/non_matchings/code/z_eff_blure/EffectBlure_Init2.s,EffectBlure_Init2,0x800A8720,0x4D asm/non_matchings/code/z_eff_blure/EffectBlure_Destroy.s,EffectBlure_Destroy,0x800A8854,0x3 asm/non_matchings/code/z_eff_blure/EffectBlure_Update.s,EffectBlure_Update,0x800A8860,0x106 -asm/non_matchings/code/z_eff_blure/func_800A8C78.s,func_800A8C78,0x800A8C78,0x5C -asm/non_matchings/code/z_eff_blure/func_800A8DE8.s,func_800A8DE8,0x800A8DE8,0x145 -asm/non_matchings/code/z_eff_blure/func_800A92FC.s,func_800A92FC,0x800A92FC,0xD -asm/non_matchings/code/z_eff_blure/func_800A9330.s,func_800A9330,0x800A9330,0x135 -asm/non_matchings/code/z_eff_blure/func_800A9804.s,func_800A9804,0x800A9804,0x263 -asm/non_matchings/code/z_eff_blure/func_800AA190.s,func_800AA190,0x800AA190,0xB4 -asm/non_matchings/code/z_eff_blure/func_800AA460.s,func_800AA460,0x800AA460,0xE -asm/non_matchings/code/z_eff_blure/func_800AA498.s,func_800AA498,0x800AA498,0x9A -asm/non_matchings/code/z_eff_blure/func_800AA700.s,func_800AA700,0x800AA700,0x138 -asm/non_matchings/code/z_eff_blure/func_800AABE0.s,func_800AABE0,0x800AABE0,0x143 +asm/non_matchings/code/z_eff_blure/EffectBlure_UpdateFlags.s,EffectBlure_UpdateFlags,0x800A8C78,0x5C +asm/non_matchings/code/z_eff_blure/EffectBlure_GetComputedValues.s,EffectBlure_GetComputedValues,0x800A8DE8,0x145 +asm/non_matchings/code/z_eff_blure/EffectBlure_SetupSmooth.s,EffectBlure_SetupSmooth,0x800A92FC,0xD +asm/non_matchings/code/z_eff_blure/EffectBlure_DrawElemNoInterpolation.s,EffectBlure_DrawElemNoInterpolation,0x800A9330,0x135 +asm/non_matchings/code/z_eff_blure/EffectBlure_DrawElemHermiteInterpolation.s,EffectBlure_DrawElemHermiteInterpolation,0x800A9804,0x263 +asm/non_matchings/code/z_eff_blure/EffectBlure_DrawSmooth.s,EffectBlure_DrawSmooth,0x800AA190,0xB4 +asm/non_matchings/code/z_eff_blure/EffectBlure_SetupSimple.s,EffectBlure_SetupSimple,0x800AA460,0xE +asm/non_matchings/code/z_eff_blure/EffectBlure_SetupSimpleAlt.s,EffectBlure_SetupSimpleAlt,0x800AA498,0x9A +asm/non_matchings/code/z_eff_blure/EffectBlure_DrawSimpleVertices.s,EffectBlure_DrawSimpleVertices,0x800AA700,0x138 +asm/non_matchings/code/z_eff_blure/EffectBlure_DrawSimple.s,EffectBlure_DrawSimple,0x800AABE0,0x143 asm/non_matchings/code/z_eff_blure/EffectBlure_Draw.s,EffectBlure_Draw,0x800AB0EC,0x139 asm/non_matchings/code/z_eff_shield_particle/EffectShieldParticle_Init.s,EffectShieldParticle_Init,0x800AB5D0,0x8E asm/non_matchings/code/z_eff_shield_particle/EffectShieldParticle_Destroy.s,EffectShieldParticle_Destroy,0x800AB808,0x23 asm/non_matchings/code/z_eff_shield_particle/EffectShieldParticle_Update.s,EffectShieldParticle_Update,0x800AB894,0x59 -asm/non_matchings/code/z_eff_shield_particle/EffectShieldParticle_CalculateColors.s,EffectShieldParticle_CalculateColors,0x800AB9F8,0x348 +asm/non_matchings/code/z_eff_shield_particle/EffectShieldParticle_GetColors.s,EffectShieldParticle_GetColors,0x800AB9F8,0x348 asm/non_matchings/code/z_eff_shield_particle/EffectShieldParticle_Draw.s,EffectShieldParticle_Draw,0x800AC718,0x136 asm/non_matchings/code/z_eff_spark/EffectSpark_Init.s,EffectSpark_Init,0x800ACBF0,0xF7 asm/non_matchings/code/z_eff_spark/EffectSpark_Destroy.s,EffectSpark_Destroy,0x800ACFCC,0x3 @@ -60,15 +60,15 @@ asm/non_matchings/code/z_eff_ss_dead/func_800AE778.s,func_800AE778,0x800AE778,0x asm/non_matchings/code/z_eff_ss_dead/func_800AE8EC.s,func_800AE8EC,0x800AE8EC,0x11 asm/non_matchings/code/z_eff_tire_mark/func_800AE930.s,func_800AE930,0x800AE930,0x185 asm/non_matchings/code/z_eff_tire_mark/func_800AEF44.s,func_800AEF44,0x800AEF44,0xB -asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_InitParticle.s,EffectTireMark_InitParticle,0x800AEF70,0xC +asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_InitElement.s,EffectTireMark_InitElement,0x800AEF70,0xC asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_Init.s,EffectTireMark_Init,0x800AEFA0,0x29 asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_Destroy.s,EffectTireMark_Destroy,0x800AF044,0x3 asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_Update.s,EffectTireMark_Update,0x800AF050,0x8D -asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_InitVertices.s,EffectTireMark_InitVertices,0x800AF284,0x23 +asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_SetVertices.s,EffectTireMark_SetVertices,0x800AF284,0x23 asm/non_matchings/code/z_eff_tire_mark/EffectTireMark_Draw.s,EffectTireMark_Draw,0x800AF310,0x100 -asm/non_matchings/code/z_effect/Effect_GetContext.s,Effect_GetContext,0x800AF710,0x4 -asm/non_matchings/code/z_effect/Effect_GetParams.s,Effect_GetParams,0x800AF720,0x57 -asm/non_matchings/code/z_effect/Effect_InitCommon.s,Effect_InitCommon,0x800AF87C,0x5 +asm/non_matchings/code/z_effect/Effect_GetGlobalCtx.s,Effect_GetGlobalCtx,0x800AF710,0x4 +asm/non_matchings/code/z_effect/Effect_GetByIndex.s,Effect_GetByIndex,0x800AF720,0x57 +asm/non_matchings/code/z_effect/Effect_InitStatus.s,Effect_InitStatus,0x800AF87C,0x5 asm/non_matchings/code/z_effect/Effect_Init.s,Effect_Init,0x800AF890,0x34 asm/non_matchings/code/z_effect/Effect_Add.s,Effect_Add,0x800AF960,0x71 asm/non_matchings/code/z_effect/Effect_DrawAll.s,Effect_DrawAll,0x800AFB24,0x4F @@ -173,42 +173,42 @@ asm/non_matchings/code/z_DLF/Overlay_FreeGameState.s,Overlay_FreeGameState,0x800 asm/non_matchings/code/z_actor/Actor_PrintLists.s,Actor_PrintLists,0x800B3AD0,0x35 asm/non_matchings/code/z_actor/ActorShape_Init.s,ActorShape_Init,0x800B3BA4,0x9 asm/non_matchings/code/z_actor/ActorShadow_Draw.s,ActorShadow_Draw,0x800B3BC8,0xFE -asm/non_matchings/code/z_actor/func_800B3FC0.s,func_800B3FC0,0x800B3FC0,0x19 -asm/non_matchings/code/z_actor/func_800B4024.s,func_800B4024,0x800B4024,0x19 -asm/non_matchings/code/z_actor/func_800B4088.s,func_800B4088,0x800B4088,0xC -asm/non_matchings/code/z_actor/func_800B40B8.s,func_800B40B8,0x800B40B8,0xA -asm/non_matchings/code/z_actor/func_800B40E0.s,func_800B40E0,0x800B40E0,0x86 -asm/non_matchings/code/z_actor/func_800B42F8.s,func_800B42F8,0x800B42F8,0x1E8 -asm/non_matchings/code/z_actor/func_800B4A98.s,func_800B4A98,0x800B4A98,0x15 +asm/non_matchings/code/z_actor/ActorShadow_DrawCircle.s,ActorShadow_DrawCircle,0x800B3FC0,0x19 +asm/non_matchings/code/z_actor/ActorShadow_DrawSquare.s,ActorShadow_DrawSquare,0x800B4024,0x19 +asm/non_matchings/code/z_actor/ActorShadow_DrawWhiteCircle.s,ActorShadow_DrawWhiteCircle,0x800B4088,0xC +asm/non_matchings/code/z_actor/ActorShadow_DrawHorse.s,ActorShadow_DrawHorse,0x800B40B8,0xA +asm/non_matchings/code/z_actor/ActorShadow_DrawFoot.s,ActorShadow_DrawFoot,0x800B40E0,0x86 +asm/non_matchings/code/z_actor/ActorShadow_DrawFeet.s,ActorShadow_DrawFeet,0x800B42F8,0x1E8 +asm/non_matchings/code/z_actor/Actor_SetFeetPos.s,Actor_SetFeetPos,0x800B4A98,0x15 asm/non_matchings/code/z_actor/func_800B4AEC.s,func_800B4AEC,0x800B4AEC,0x19 asm/non_matchings/code/z_actor/func_800B4B50.s,func_800B4B50,0x800B4B50,0xE3 -asm/non_matchings/code/z_actor/func_800B4EDC.s,func_800B4EDC,0x800B4EDC,0x19 -asm/non_matchings/code/z_actor/func_800B4F40.s,func_800B4F40,0x800B4F40,0xE +asm/non_matchings/code/z_actor/Actor_GetProjectedPos.s,Actor_GetProjectedPos,0x800B4EDC,0x19 +asm/non_matchings/code/z_actor/Target_SetPos.s,Target_SetPos,0x800B4F40,0xE asm/non_matchings/code/z_actor/func_800B4F78.s,func_800B4F78,0x800B4F78,0x32 -asm/non_matchings/code/z_actor/func_800B5040.s,func_800B5040,0x800B5040,0x59 +asm/non_matchings/code/z_actor/Target_SetColors.s,Target_SetColors,0x800B5040,0x59 asm/non_matchings/code/z_actor/Actor_TargetContextInit.s,Actor_TargetContextInit,0x800B51A4,0x19 -asm/non_matchings/code/z_actor/func_800B5208.s,func_800B5208,0x800B5208,0x183 +asm/non_matchings/code/z_actor/Actor_DrawZTarget.s,Actor_DrawZTarget,0x800B5208,0x183 asm/non_matchings/code/z_actor/func_800B5814.s,func_800B5814,0x800B5814,0xE7 asm/non_matchings/code/z_actor/Flags_GetSwitch.s,Flags_GetSwitch,0x800B5BB0,0x11 -asm/non_matchings/code/z_actor/Actor_SetSwitchFlag.s,Actor_SetSwitchFlag,0x800B5BF4,0x10 -asm/non_matchings/code/z_actor/Actor_UnsetSwitchFlag.s,Actor_UnsetSwitchFlag,0x800B5C34,0x11 -asm/non_matchings/code/z_actor/Actor_GetChestFlag.s,Actor_GetChestFlag,0x800B5C78,0x6 -asm/non_matchings/code/z_actor/Actor_SetChestFlag.s,Actor_SetChestFlag,0x800B5C90,0x7 -asm/non_matchings/code/z_actor/Actor_SetAllChestFlag.s,Actor_SetAllChestFlag,0x800B5CAC,0x3 -asm/non_matchings/code/z_actor/Actor_GetAllChestFlag.s,Actor_GetAllChestFlag,0x800B5CB8,0x3 -asm/non_matchings/code/z_actor/Actor_GetRoomCleared.s,Actor_GetRoomCleared,0x800B5CC4,0x6 -asm/non_matchings/code/z_actor/Actor_SetRoomCleared.s,Actor_SetRoomCleared,0x800B5CDC,0x7 -asm/non_matchings/code/z_actor/Actor_UnsetRoomCleared.s,Actor_UnsetRoomCleared,0x800B5CF8,0x8 -asm/non_matchings/code/z_actor/Actor_GetRoomClearedTemp.s,Actor_GetRoomClearedTemp,0x800B5D18,0x6 -asm/non_matchings/code/z_actor/Actor_SetRoomClearedTemp.s,Actor_SetRoomClearedTemp,0x800B5D30,0x7 -asm/non_matchings/code/z_actor/Actor_UnsetRoomClearedTemp.s,Actor_UnsetRoomClearedTemp,0x800B5D4C,0x8 -asm/non_matchings/code/z_actor/Actor_GetCollectibleFlag.s,Actor_GetCollectibleFlag,0x800B5D6C,0x11 -asm/non_matchings/code/z_actor/Actor_SetCollectibleFlag.s,Actor_SetCollectibleFlag,0x800B5DB0,0x10 -asm/non_matchings/code/z_actor/Actor_TitleCardContextInit.s,Actor_TitleCardContextInit,0x800B5DF0,0x7 -asm/non_matchings/code/z_actor/Actor_TitleCardCreate.s,Actor_TitleCardCreate,0x800B5E0C,0x11 -asm/non_matchings/code/z_actor/Actor_Nop800B5E50.s,Actor_Nop800B5E50,0x800B5E50,0x6 -asm/non_matchings/code/z_actor/Actor_TitleCardUpdate.s,Actor_TitleCardUpdate,0x800B5E68,0x2F -asm/non_matchings/code/z_actor/Actor_TitleCardDraw.s,Actor_TitleCardDraw,0x800B5F24,0x144 +asm/non_matchings/code/z_actor/Flags_SetSwitch.s,Flags_SetSwitch,0x800B5BF4,0x10 +asm/non_matchings/code/z_actor/Flags_UnsetSwitch.s,Flags_UnsetSwitch,0x800B5C34,0x11 +asm/non_matchings/code/z_actor/Flags_GetTreasure.s,Flags_GetTreasure,0x800B5C78,0x6 +asm/non_matchings/code/z_actor/Flags_SetTreasure.s,Flags_SetTreasure,0x800B5C90,0x7 +asm/non_matchings/code/z_actor/Flags_SetAllTreasure.s,Flags_SetAllTreasure,0x800B5CAC,0x3 +asm/non_matchings/code/z_actor/Flags_GetAllTreasure.s,Flags_GetAllTreasure,0x800B5CB8,0x3 +asm/non_matchings/code/z_actor/Flags_GetClear.s,Flags_GetClear,0x800B5CC4,0x6 +asm/non_matchings/code/z_actor/Flags_SetClear.s,Flags_SetClear,0x800B5CDC,0x7 +asm/non_matchings/code/z_actor/Flags_UnsetClear.s,Flags_UnsetClear,0x800B5CF8,0x8 +asm/non_matchings/code/z_actor/Flags_GetClearTemp.s,Flags_GetClearTemp,0x800B5D18,0x6 +asm/non_matchings/code/z_actor/Flags_SetClearTemp.s,Flags_SetClearTemp,0x800B5D30,0x7 +asm/non_matchings/code/z_actor/Flags_UnsetClearTemp.s,Flags_UnsetClearTemp,0x800B5D4C,0x8 +asm/non_matchings/code/z_actor/Flags_GetCollectible.s,Flags_GetCollectible,0x800B5D6C,0x11 +asm/non_matchings/code/z_actor/Flags_SetCollectible.s,Flags_SetCollectible,0x800B5DB0,0x10 +asm/non_matchings/code/z_actor/TitleCard_ContextInit.s,TitleCard_ContextInit,0x800B5DF0,0x7 +asm/non_matchings/code/z_actor/TitleCard_InitBossName.s,TitleCard_InitBossName,0x800B5E0C,0x11 +asm/non_matchings/code/z_actor/TitleCard_InitPlaceName.s,TitleCard_InitPlaceName,0x800B5E50,0x6 +asm/non_matchings/code/z_actor/TitleCard_Update.s,TitleCard_Update,0x800B5E68,0x2F +asm/non_matchings/code/z_actor/TitleCard_Draw.s,TitleCard_Draw,0x800B5F24,0x144 asm/non_matchings/code/z_actor/func_800B6434.s,func_800B6434,0x800B6434,0xD asm/non_matchings/code/z_actor/func_800B6468.s,func_800B6468,0x800B6468,0x3 asm/non_matchings/code/z_actor/func_800B6474.s,func_800B6474,0x800B6474,0x6 @@ -218,24 +218,24 @@ asm/non_matchings/code/z_actor/func_800B6584.s,func_800B6584,0x800B6584,0x21 asm/non_matchings/code/z_actor/func_800B6608.s,func_800B6608,0x800B6608,0x1E asm/non_matchings/code/z_actor/func_800B6680.s,func_800B6680,0x800B6680,0x23 asm/non_matchings/code/z_actor/Actor_MarkForDeath.s,Actor_MarkForDeath,0x800B670C,0x8 -asm/non_matchings/code/z_actor/Actor_InitCurrPosition.s,Actor_InitCurrPosition,0x800B672C,0xC -asm/non_matchings/code/z_actor/Actor_SetHeight.s,Actor_SetHeight,0x800B675C,0x11 -asm/non_matchings/code/z_actor/Actor_SetRotationFromDrawRotation.s,Actor_SetRotationFromDrawRotation,0x800B67A0,0x8 -asm/non_matchings/code/z_actor/Actor_InitDrawRotation.s,Actor_InitDrawRotation,0x800B67C0,0x8 +asm/non_matchings/code/z_actor/Actor_SetWorldToHome.s,Actor_SetWorldToHome,0x800B672C,0xC +asm/non_matchings/code/z_actor/Actor_SetFocus.s,Actor_SetFocus,0x800B675C,0x11 +asm/non_matchings/code/z_actor/Actor_SetWorldRotToShape.s,Actor_SetWorldRotToShape,0x800B67A0,0x8 +asm/non_matchings/code/z_actor/Actor_SetShapeRotToWorld.s,Actor_SetShapeRotToWorld,0x800B67C0,0x8 asm/non_matchings/code/z_actor/Actor_SetScale.s,Actor_SetScale,0x800B67E0,0x7 -asm/non_matchings/code/z_actor/Actor_SetObjectSegment.s,Actor_SetObjectSegment,0x800B67FC,0xE -asm/non_matchings/code/z_actor/Actor_InitToDefaultValues.s,Actor_InitToDefaultValues,0x800B6834,0x45 -asm/non_matchings/code/z_actor/Actor_FiniActor.s,Actor_FiniActor,0x800B6948,0x10 +asm/non_matchings/code/z_actor/Actor_SetObjectDependency.s,Actor_SetObjectDependency,0x800B67FC,0xE +asm/non_matchings/code/z_actor/Actor_Init.s,Actor_Init,0x800B6834,0x45 +asm/non_matchings/code/z_actor/Actor_Destroy.s,Actor_Destroy,0x800B6948,0x10 asm/non_matchings/code/z_actor/Actor_SetMovementScale.s,Actor_SetMovementScale,0x800B6988,0x9 -asm/non_matchings/code/z_actor/Actor_ApplyMovement.s,Actor_ApplyMovement,0x800B69AC,0x19 -asm/non_matchings/code/z_actor/Actor_SetVelocityYRotationAndGravity.s,Actor_SetVelocityYRotationAndGravity,0x800B6A10,0x1E -asm/non_matchings/code/z_actor/Actor_SetVelocityAndMoveYRotationAndGravity.s,Actor_SetVelocityAndMoveYRotationAndGravity,0x800B6A88,0xB -asm/non_matchings/code/z_actor/Actor_SetVelocityXYRotation.s,Actor_SetVelocityXYRotation,0x800B6AB4,0x1C -asm/non_matchings/code/z_actor/Actor_SetVelocityAndMoveXYRotation.s,Actor_SetVelocityAndMoveXYRotation,0x800B6B24,0xB -asm/non_matchings/code/z_actor/Actor_SetVelocityXYRotationReverse.s,Actor_SetVelocityXYRotationReverse,0x800B6B50,0x22 -asm/non_matchings/code/z_actor/Actor_SetVelocityAndMoveXYRotationReverse.s,Actor_SetVelocityAndMoveXYRotationReverse,0x800B6BD8,0xB -asm/non_matchings/code/z_actor/func_800B6C04.s,func_800B6C04,0x800B6C04,0x15 -asm/non_matchings/code/z_actor/func_800B6C58.s,func_800B6C58,0x800B6C58,0x1F +asm/non_matchings/code/z_actor/Actor_UpdatePos.s,Actor_UpdatePos,0x800B69AC,0x19 +asm/non_matchings/code/z_actor/Actor_UpdateVelocityWithGravity.s,Actor_UpdateVelocityWithGravity,0x800B6A10,0x1E +asm/non_matchings/code/z_actor/Actor_MoveWithGravity.s,Actor_MoveWithGravity,0x800B6A88,0xB +asm/non_matchings/code/z_actor/Actor_UpdateVelocityWithoutGravity.s,Actor_UpdateVelocityWithoutGravity,0x800B6AB4,0x1C +asm/non_matchings/code/z_actor/Actor_MoveWithoutGravity.s,Actor_MoveWithoutGravity,0x800B6B24,0xB +asm/non_matchings/code/z_actor/Actor_UpdateVelocityWithoutGravityReverse.s,Actor_UpdateVelocityWithoutGravityReverse,0x800B6B50,0x22 +asm/non_matchings/code/z_actor/Actor_MoveWithoutGravityReverse.s,Actor_MoveWithoutGravityReverse,0x800B6BD8,0xB +asm/non_matchings/code/z_actor/Actor_SetSpeeds.s,Actor_SetSpeeds,0x800B6C04,0x15 +asm/non_matchings/code/z_actor/Actor_UpdatePosFromSkelAnime.s,Actor_UpdatePosFromSkelAnime,0x800B6C58,0x1F asm/non_matchings/code/z_actor/Actor_YawBetweenActors.s,Actor_YawBetweenActors,0x800B6CD4,0xB asm/non_matchings/code/z_actor/Actor_YawBetweenActorsTop.s,Actor_YawBetweenActorsTop,0x800B6D00,0xB asm/non_matchings/code/z_actor/Actor_YawToPoint.s,Actor_YawToPoint,0x800B6D2C,0x9 @@ -246,76 +246,76 @@ asm/non_matchings/code/z_actor/Actor_DistanceBetweenActors.s,Actor_DistanceBetwe asm/non_matchings/code/z_actor/Actor_DistanceToPoint.s,Actor_DistanceToPoint,0x800B6DF8,0x9 asm/non_matchings/code/z_actor/Actor_XZDistanceBetweenActors.s,Actor_XZDistanceBetweenActors,0x800B6E1C,0xB asm/non_matchings/code/z_actor/Actor_XZDistanceToPoint.s,Actor_XZDistanceToPoint,0x800B6E48,0x9 -asm/non_matchings/code/z_actor/Actor_CalcOffsetOrientedToDrawRotation.s,Actor_CalcOffsetOrientedToDrawRotation,0x800B6E6C,0x28 -asm/non_matchings/code/z_actor/Actor_YDistance.s,Actor_YDistance,0x800B6F0C,0x5 +asm/non_matchings/code/z_actor/Actor_OffsetOfPointInActorCoords.s,Actor_OffsetOfPointInActorCoords,0x800B6E6C,0x28 +asm/non_matchings/code/z_actor/Actor_HeightDiff.s,Actor_HeightDiff,0x800B6F0C,0x5 asm/non_matchings/code/z_actor/func_800B6F20.s,func_800B6F20,0x800B6F20,0x2A -asm/non_matchings/code/z_actor/func_800B6FC8.s,func_800B6FC8,0x800B6FC8,0x32 -asm/non_matchings/code/z_actor/func_800B7090.s,func_800B7090,0x800B7090,0x22 +asm/non_matchings/code/z_actor/Player_GetHeight.s,Player_GetHeight,0x800B6FC8,0x32 +asm/non_matchings/code/z_actor/Player_GetRunSpeedLimit.s,Player_GetRunSpeedLimit,0x800B7090,0x22 asm/non_matchings/code/z_actor/func_800B7118.s,func_800B7118,0x800B7118,0x4 asm/non_matchings/code/z_actor/func_800B7128.s,func_800B7128,0x800B7128,0xD asm/non_matchings/code/z_actor/func_800B715C.s,func_800B715C,0x800B715C,0x5 -asm/non_matchings/code/z_actor/func_800B7170.s,func_800B7170,0x800B7170,0x1B -asm/non_matchings/code/z_actor/func_800B71DC.s,func_800B71DC,0x800B71DC,0x9 +asm/non_matchings/code/z_actor/Actor_SetCameraHorseSetting.s,Actor_SetCameraHorseSetting,0x800B7170,0x1B +asm/non_matchings/code/z_actor/Actor_MountHorse.s,Actor_MountHorse,0x800B71DC,0x9 asm/non_matchings/code/z_actor/func_800B7200.s,func_800B7200,0x800B7200,0xB asm/non_matchings/code/z_actor/func_800B722C.s,func_800B722C,0x800B722C,0x8 asm/non_matchings/code/z_actor/func_800B724C.s,func_800B724C,0x800B724C,0x13 asm/non_matchings/code/z_actor/func_800B7298.s,func_800B7298,0x800B7298,0x12 asm/non_matchings/code/z_actor/func_800B72E0.s,func_800B72E0,0x800B72E0,0x6 asm/non_matchings/code/z_actor/func_800B72F8.s,func_800B72F8,0x800B72F8,0xA -asm/non_matchings/code/z_actor/Actor_IsLinkFacingActor.s,Actor_IsLinkFacingActor,0x800B7320,0x16 -asm/non_matchings/code/z_actor/Actor_IsActorFacedByActor.s,Actor_IsActorFacedByActor,0x800B7378,0x1A -asm/non_matchings/code/z_actor/Actor_IsActorFacingLink.s,Actor_IsActorFacingLink,0x800B73E0,0x13 -asm/non_matchings/code/z_actor/Actor_IsActorFacingActor.s,Actor_IsActorFacingActor,0x800B742C,0x18 -asm/non_matchings/code/z_actor/Actor_IsActorFacingLinkAndWithinRange.s,Actor_IsActorFacingLinkAndWithinRange,0x800B748C,0x20 -asm/non_matchings/code/z_actor/Actor_IsActorFacingActorAndWithinRange.s,Actor_IsActorFacingActorAndWithinRange,0x800B750C,0x25 +asm/non_matchings/code/z_actor/Player_IsFacingActor.s,Player_IsFacingActor,0x800B7320,0x16 +asm/non_matchings/code/z_actor/Actor_ActorBIsFacingActorA.s,Actor_ActorBIsFacingActorA,0x800B7378,0x1A +asm/non_matchings/code/z_actor/Actor_IsFacingPlayer.s,Actor_IsFacingPlayer,0x800B73E0,0x13 +asm/non_matchings/code/z_actor/Actor_ActorAIsFacingActorB.s,Actor_ActorAIsFacingActorB,0x800B742C,0x18 +asm/non_matchings/code/z_actor/Actor_IsFacingAndNearPlayer.s,Actor_IsFacingAndNearPlayer,0x800B748C,0x20 +asm/non_matchings/code/z_actor/Actor_ActorAIsFacingAndNearActorB.s,Actor_ActorAIsFacingAndNearActorB,0x800B750C,0x25 asm/non_matchings/code/z_actor/func_800B75A0.s,func_800B75A0,0x800B75A0,0x1F asm/non_matchings/code/z_actor/func_800B761C.s,func_800B761C,0x800B761C,0x17 asm/non_matchings/code/z_actor/func_800B7678.s,func_800B7678,0x800B7678,0x90 asm/non_matchings/code/z_actor/Actor_UpdateBgCheckInfo.s,Actor_UpdateBgCheckInfo,0x800B78B8,0x153 -asm/non_matchings/code/z_actor/func_800B7E04.s,func_800B7E04,0x800B7E04,0x77 -asm/non_matchings/code/z_actor/func_800B7FE0.s,func_800B7FE0,0x800B7FE0,0xE -asm/non_matchings/code/z_actor/func_800B8018.s,func_800B8018,0x800B8018,0xE +asm/non_matchings/code/z_actor/Hilite_Draw.s,Hilite_Draw,0x800B7E04,0x77 +asm/non_matchings/code/z_actor/Hilite_DrawOpa.s,Hilite_DrawOpa,0x800B7FE0,0xE +asm/non_matchings/code/z_actor/Hilite_DrawXlu.s,Hilite_DrawXlu,0x800B8018,0xE asm/non_matchings/code/z_actor/func_800B8050.s,func_800B8050,0x800B8050,0x32 asm/non_matchings/code/z_actor/func_800B8118.s,func_800B8118,0x800B8118,0x32 -asm/non_matchings/code/z_actor/func_800B81E0.s,func_800B81E0,0x800B81E0,0xD -asm/non_matchings/code/z_actor/func_800B8214.s,func_800B8214,0x800B8214,0xD -asm/non_matchings/code/z_actor/func_800B8248.s,func_800B8248,0x800B8248,0x29 +asm/non_matchings/code/z_actor/Actor_GetFocus.s,Actor_GetFocus,0x800B81E0,0xD +asm/non_matchings/code/z_actor/Actor_GetWorld.s,Actor_GetWorld,0x800B8214,0xD +asm/non_matchings/code/z_actor/Actor_GetWorldPosShapeRot.s,Actor_GetWorldPosShapeRot,0x800B8248,0x29 asm/non_matchings/code/z_actor/func_800B82EC.s,func_800B82EC,0x800B82EC,0x34 asm/non_matchings/code/z_actor/func_800B83BC.s,func_800B83BC,0x800B83BC,0xF asm/non_matchings/code/z_actor/func_800B83F8.s,func_800B83F8,0x800B83F8,0x36 -asm/non_matchings/code/z_actor/func_800B84D0.s,func_800B84D0,0x800B84D0,0xC +asm/non_matchings/code/z_actor/Actor_ProcessTalkRequest.s,Actor_ProcessTalkRequest,0x800B84D0,0xC asm/non_matchings/code/z_actor/func_800B8500.s,func_800B8500,0x800B8500,0x38 asm/non_matchings/code/z_actor/func_800B85E0.s,func_800B85E0,0x800B85E0,0xD asm/non_matchings/code/z_actor/func_800B8614.s,func_800B8614,0x800B8614,0xA asm/non_matchings/code/z_actor/func_800B863C.s,func_800B863C,0x800B863C,0x10 -asm/non_matchings/code/z_actor/func_800B867C.s,func_800B867C,0x800B867C,0x13 -asm/non_matchings/code/z_actor/func_800B86C8.s,func_800B86C8,0x800B86C8,0x10 -asm/non_matchings/code/z_actor/func_800B8708.s,func_800B8708,0x800B8708,0x4 +asm/non_matchings/code/z_actor/Actor_TextboxIsClosing.s,Actor_TextboxIsClosing,0x800B867C,0x13 +asm/non_matchings/code/z_actor/Actor_ChangeFocus.s,Actor_ChangeFocus,0x800B86C8,0x10 +asm/non_matchings/code/z_actor/Player_GetExchangeItemId.s,Player_GetExchangeItemId,0x800B8708,0x4 asm/non_matchings/code/z_actor/func_800B8718.s,func_800B8718,0x800B8718,0xD asm/non_matchings/code/z_actor/func_800B874C.s,func_800B874C,0x800B874C,0x2E asm/non_matchings/code/z_actor/func_800B8804.s,func_800B8804,0x800B8804,0xA asm/non_matchings/code/z_actor/func_800B882C.s,func_800B882C,0x800B882C,0x10 asm/non_matchings/code/z_actor/func_800B886C.s,func_800B886C,0x800B886C,0xB -asm/non_matchings/code/z_actor/func_800B8898.s,func_800B8898,0x800B8898,0x27 +asm/non_matchings/code/z_actor/Actor_GetScreenPos.s,Actor_GetScreenPos,0x800B8898,0x27 asm/non_matchings/code/z_actor/func_800B8934.s,func_800B8934,0x800B8934,0x31 asm/non_matchings/code/z_actor/Actor_HasParent.s,Actor_HasParent,0x800B89F8,0x9 -asm/non_matchings/code/z_actor/func_800B8A1C.s,func_800B8A1C,0x800B8A1C,0x5A -asm/non_matchings/code/z_actor/func_800B8B84.s,func_800B8B84,0x800B8B84,0xB -asm/non_matchings/code/z_actor/func_800B8BB0.s,func_800B8BB0,0x800B8BB0,0x8 -asm/non_matchings/code/z_actor/func_800B8BD0.s,func_800B8BD0,0x800B8BD0,0xB +asm/non_matchings/code/z_actor/Actor_PickUp.s,Actor_PickUp,0x800B8A1C,0x5A +asm/non_matchings/code/z_actor/Actor_PickUpNearby.s,Actor_PickUpNearby,0x800B8B84,0xB +asm/non_matchings/code/z_actor/Actor_LiftActor.s,Actor_LiftActor,0x800B8BB0,0x8 +asm/non_matchings/code/z_actor/Actor_PickUpFar.s,Actor_PickUpFar,0x800B8BD0,0xB asm/non_matchings/code/z_actor/Actor_HasNoParent.s,Actor_HasNoParent,0x800B8BFC,0x9 asm/non_matchings/code/z_actor/func_800B8C20.s,func_800B8C20,0x800B8C20,0xC asm/non_matchings/code/z_actor/func_800B8C50.s,func_800B8C50,0x800B8C50,0xA -asm/non_matchings/code/z_actor/func_800B8C78.s,func_800B8C78,0x800B8C78,0x9 -asm/non_matchings/code/z_actor/func_800B8C9C.s,func_800B8C9C,0x800B8C9C,0x14 -asm/non_matchings/code/z_actor/func_800B8CEC.s,func_800B8CEC,0x800B8CEC,0x9 +asm/non_matchings/code/z_actor/Actor_HasRider.s,Actor_HasRider,0x800B8C78,0x9 +asm/non_matchings/code/z_actor/Actor_SetRideActor.s,Actor_SetRideActor,0x800B8C9C,0x14 +asm/non_matchings/code/z_actor/Actor_HasNoRider.s,Actor_HasNoRider,0x800B8CEC,0x9 asm/non_matchings/code/z_actor/func_800B8D10.s,func_800B8D10,0x800B8D10,0x10 asm/non_matchings/code/z_actor/func_800B8D50.s,func_800B8D50,0x800B8D50,0x12 asm/non_matchings/code/z_actor/func_800B8D98.s,func_800B8D98,0x800B8D98,0xF asm/non_matchings/code/z_actor/func_800B8DD4.s,func_800B8DD4,0x800B8DD4,0x12 asm/non_matchings/code/z_actor/func_800B8E1C.s,func_800B8E1C,0x800B8E1C,0xF asm/non_matchings/code/z_actor/func_800B8E58.s,func_800B8E58,0x800B8E58,0x1C -asm/non_matchings/code/z_actor/Audio_PlayActorSound2.s,Audio_PlayActorSound2,0x800B8EC8,0xB +asm/non_matchings/code/z_actor/Actor_PlaySfxAtPos.s,Actor_PlaySfxAtPos,0x800B8EC8,0xB asm/non_matchings/code/z_actor/func_800B8EF4.s,func_800B8EF4,0x800B8EF4,0x29 asm/non_matchings/code/z_actor/func_800B8F98.s,func_800B8F98,0x800B8F98,0xA asm/non_matchings/code/z_actor/func_800B8FC0.s,func_800B8FC0,0x800B8FC0,0xA @@ -327,11 +327,11 @@ asm/non_matchings/code/z_actor/func_800B9098.s,func_800B9098,0x800B9098,0x5 asm/non_matchings/code/z_actor/func_800B90AC.s,func_800B90AC,0x800B90AC,0x12 asm/non_matchings/code/z_actor/func_800B90F4.s,func_800B90F4,0x800B90F4,0xB asm/non_matchings/code/z_actor/func_800B9120.s,func_800B9120,0x800B9120,0x14 -asm/non_matchings/code/z_actor/Actor_Init.s,Actor_Init,0x800B9170,0x71 -asm/non_matchings/code/z_actor/func_800B9334.s,func_800B9334,0x800B9334,0x56 +asm/non_matchings/code/z_actor/Actor_InitContext.s,Actor_InitContext,0x800B9170,0x71 +asm/non_matchings/code/z_actor/Actor_SpawnSetupActors.s,Actor_SpawnSetupActors,0x800B9334,0x56 asm/non_matchings/code/z_actor/Actor_UpdateActor.s,Actor_UpdateActor,0x800B948C,0xBD asm/non_matchings/code/z_actor/Actor_UpdateAll.s,Actor_UpdateAll,0x800B9780,0xA1 -asm/non_matchings/code/z_actor/Actor_DrawActor.s,Actor_DrawActor,0x800B9A04,0xC6 +asm/non_matchings/code/z_actor/Actor_Draw.s,Actor_Draw,0x800B9A04,0xC6 asm/non_matchings/code/z_actor/func_800B9D1C.s,func_800B9D1C,0x800B9D1C,0x48 asm/non_matchings/code/z_actor/Actor_DrawAllSetup.s,Actor_DrawAllSetup,0x800B9E3C,0x4 asm/non_matchings/code/z_actor/Actor_RecordUndrawnActor.s,Actor_RecordUndrawnActor,0x800B9E4C,0xE @@ -343,17 +343,17 @@ asm/non_matchings/code/z_actor/Actor_DrawAll.s,Actor_DrawAll,0x800BA42C,0xB4 asm/non_matchings/code/z_actor/func_800BA6FC.s,func_800BA6FC,0x800BA6FC,0x27 asm/non_matchings/code/z_actor/func_800BA798.s,func_800BA798,0x800BA798,0x48 asm/non_matchings/code/z_actor/func_800BA8B8.s,func_800BA8B8,0x800BA8B8,0x3F -asm/non_matchings/code/z_actor/func_800BA9B4.s,func_800BA9B4,0x800BA9B4,0x40 -asm/non_matchings/code/z_actor/Actor_InsertIntoTypeList.s,Actor_InsertIntoTypeList,0x800BAAB4,0x1C -asm/non_matchings/code/z_actor/Actor_RemoveFromTypeList.s,Actor_RemoveFromTypeList,0x800BAB24,0x36 +asm/non_matchings/code/z_actor/Actor_CleanupContext.s,Actor_CleanupContext,0x800BA9B4,0x40 +asm/non_matchings/code/z_actor/Actor_AddToCategory.s,Actor_AddToCategory,0x800BAAB4,0x1C +asm/non_matchings/code/z_actor/Actor_RemoveFromCategory.s,Actor_RemoveFromCategory,0x800BAB24,0x36 asm/non_matchings/code/z_actor/Actor_FreeOverlay.s,Actor_FreeOverlay,0x800BABFC,0x19 asm/non_matchings/code/z_actor/Actor_Spawn.s,Actor_Spawn,0x800BAC60,0x1D asm/non_matchings/code/z_actor/Actor_LoadOverlay.s,Actor_LoadOverlay,0x800BACD4,0x50 asm/non_matchings/code/z_actor/Actor_SpawnAsChildAndCutscene.s,Actor_SpawnAsChildAndCutscene,0x800BAE14,0xAB asm/non_matchings/code/z_actor/Actor_SpawnAsChild.s,Actor_SpawnAsChild,0x800BB0C0,0x20 asm/non_matchings/code/z_actor/Actor_SpawnTransitionActors.s,Actor_SpawnTransitionActors,0x800BB140,0x64 -asm/non_matchings/code/z_actor/func_800BB2D0.s,func_800BB2D0,0x800BB2D0,0x72 -asm/non_matchings/code/z_actor/func_800BB498.s,func_800BB498,0x800BB498,0x41 +asm/non_matchings/code/z_actor/Actor_SpawnEntry.s,Actor_SpawnEntry,0x800BB2D0,0x72 +asm/non_matchings/code/z_actor/Actor_Delete.s,Actor_Delete,0x800BB498,0x41 asm/non_matchings/code/z_actor/func_800BB59C.s,func_800BB59C,0x800BB59C,0x1A asm/non_matchings/code/z_actor/func_800BB604.s,func_800BB604,0x800BB604,0xBA asm/non_matchings/code/z_actor/func_800BB8EC.s,func_800BB8EC,0x800BB8EC,0x67 @@ -361,24 +361,24 @@ asm/non_matchings/code/z_actor/Enemy_StartFinishingBlow.s,Enemy_StartFinishingBl asm/non_matchings/code/z_actor/func_800BBAC0.s,func_800BBAC0,0x800BBAC0,0x2D asm/non_matchings/code/z_actor/func_800BBB74.s,func_800BBB74,0x800BBB74,0x2B asm/non_matchings/code/z_actor/func_800BBC20.s,func_800BBC20,0x800BBC20,0x33 -asm/non_matchings/code/z_actor/func_800BBCEC.s,func_800BBCEC,0x800BBCEC,0x30 -asm/non_matchings/code/z_actor/func_800BBDAC.s,func_800BBDAC,0x800BBDAC,0x81 +asm/non_matchings/code/z_actor/Actor_SpawnBodyParts.s,Actor_SpawnBodyParts,0x800BBCEC,0x30 +asm/non_matchings/code/z_actor/Actor_SpawnFloorDustRing.s,Actor_SpawnFloorDustRing,0x800BBDAC,0x81 asm/non_matchings/code/z_actor/func_800BBFB0.s,func_800BBFB0,0x800BBFB0,0x69 asm/non_matchings/code/z_actor/func_800BC154.s,func_800BC154,0x800BC154,0xD asm/non_matchings/code/z_actor/func_800BC188.s,func_800BC188,0x800BC188,0xB asm/non_matchings/code/z_actor/func_800BC1B4.s,func_800BC1B4,0x800BC1B4,0x2F asm/non_matchings/code/z_actor/func_800BC270.s,func_800BC270,0x800BC270,0x75 asm/non_matchings/code/z_actor/func_800BC444.s,func_800BC444,0x800BC444,0x2A -asm/non_matchings/code/z_actor/func_800BC4EC.s,func_800BC4EC,0x800BC4EC,0x33 -asm/non_matchings/code/z_actor/func_800BC5B8.s,func_800BC5B8,0x800BC5B8,0xD -asm/non_matchings/code/z_actor/func_800BC5EC.s,func_800BC5EC,0x800BC5EC,0xD +asm/non_matchings/code/z_actor/Actor_TestFloorInDirection.s,Actor_TestFloorInDirection,0x800BC4EC,0x33 +asm/non_matchings/code/z_actor/Actor_IsTargeted.s,Actor_IsTargeted,0x800BC5B8,0xD +asm/non_matchings/code/z_actor/Actor_OtherIsTargeted.s,Actor_OtherIsTargeted,0x800BC5EC,0xD asm/non_matchings/code/z_actor/func_800BC620.s,func_800BC620,0x800BC620,0x54 asm/non_matchings/code/z_actor/func_800BC770.s,func_800BC770,0x800BC770,0x1A asm/non_matchings/code/z_actor/func_800BC7D8.s,func_800BC7D8,0x800BC7D8,0x1C asm/non_matchings/code/z_actor/func_800BC848.s,func_800BC848,0x800BC848,0x1C -asm/non_matchings/code/z_actor/func_800BC8B8.s,func_800BC8B8,0x800BC8B8,0xA6 -asm/non_matchings/code/z_actor/func_800BCB50.s,func_800BCB50,0x800BCB50,0x8 -asm/non_matchings/code/z_actor/func_800BCB70.s,func_800BCB70,0x800BCB70,0x21 +asm/non_matchings/code/z_actor/Actor_DrawDoorLock.s,Actor_DrawDoorLock,0x800BC8B8,0xA6 +asm/non_matchings/code/z_actor/Actor_SpawnShieldParticlesMetal.s,Actor_SpawnShieldParticlesMetal,0x800BCB50,0x8 +asm/non_matchings/code/z_actor/Actor_SetColorFilter.s,Actor_SetColorFilter,0x800BCB70,0x21 asm/non_matchings/code/z_actor/func_800BCBF4.s,func_800BCBF4,0x800BCBF4,0x1D asm/non_matchings/code/z_actor/func_800BCC68.s,func_800BCC68,0x800BCC68,0x1D asm/non_matchings/code/z_actor/func_800BCCDC.s,func_800BCCDC,0x800BCCDC,0x176 @@ -391,16 +391,16 @@ asm/non_matchings/code/z_actor/func_800BD9A0.s,func_800BD9A0,0x800BD9A0,0x10 asm/non_matchings/code/z_actor/func_800BD9E0.s,func_800BD9E0,0x800BD9E0,0x30 asm/non_matchings/code/z_actor/func_800BDAA0.s,func_800BDAA0,0x800BDAA0,0x33 asm/non_matchings/code/z_actor/func_800BDB6C.s,func_800BDB6C,0x800BDB6C,0x3C -asm/non_matchings/code/z_actor/func_800BDC5C.s,func_800BDC5C,0x800BDC5C,0x26 +asm/non_matchings/code/z_actor/Actor_ChangeAnimation.s,Actor_ChangeAnimation,0x800BDC5C,0x26 asm/non_matchings/code/z_actor/func_800BDCF4.s,func_800BDCF4,0x800BDCF4,0xAF asm/non_matchings/code/z_actor/Actor_Noop.s,Actor_Noop,0x800BDFB0,0x4 -asm/non_matchings/code/z_actor/func_800BDFC0.s,func_800BDFC0,0x800BDFC0,0x1F -asm/non_matchings/code/z_actor/func_800BE03C.s,func_800BE03C,0x800BE03C,0x1F -asm/non_matchings/code/z_actor/func_800BE0B8.s,func_800BE0B8,0x800BE0B8,0x33 +asm/non_matchings/code/z_actor/Gfx_DrawDListOpa.s,Gfx_DrawDListOpa,0x800BDFC0,0x1F +asm/non_matchings/code/z_actor/Gfx_DrawDListXlu.s,Gfx_DrawDListXlu,0x800BE03C,0x1F +asm/non_matchings/code/z_actor/Actor_FindNearby.s,Actor_FindNearby,0x800BE0B8,0x33 asm/non_matchings/code/z_actor/func_800BE184.s,func_800BE184,0x800BE184,0x2A asm/non_matchings/code/z_actor/Actor_ApplyDamage.s,Actor_ApplyDamage,0x800BE22C,0xB -asm/non_matchings/code/z_actor/func_800BE258.s,func_800BE258,0x800BE258,0x18 -asm/non_matchings/code/z_actor/func_800BE2B8.s,func_800BE2B8,0x800BE2B8,0x21 +asm/non_matchings/code/z_actor/Actor_SetDropFlag.s,Actor_SetDropFlag,0x800BE258,0x18 +asm/non_matchings/code/z_actor/Actor_SetDropFlagJntSph.s,Actor_SetDropFlagJntSph,0x800BE2B8,0x21 asm/non_matchings/code/z_actor/func_800BE33C.s,func_800BE33C,0x800BE33C,0x25 asm/non_matchings/code/z_actor/func_800BE3D0.s,func_800BE3D0,0x800BE3D0,0x4D asm/non_matchings/code/z_actor/func_800BE504.s,func_800BE504,0x800BE504,0x19 @@ -408,7 +408,7 @@ asm/non_matchings/code/z_actor/func_800BE568.s,func_800BE568,0x800BE568,0x19 asm/non_matchings/code/z_actor/func_800BE5CC.s,func_800BE5CC,0x800BE5CC,0x1C asm/non_matchings/code/z_actor/func_800BE63C.s,func_800BE63C,0x800BE63C,0x11 asm/non_matchings/code/z_actor/func_800BE680.s,func_800BE680,0x800BE680,0x453 -asm/non_matchings/code/z_actor/func_800BF7CC.s,func_800BF7CC,0x800BF7CC,0x75 +asm/non_matchings/code/z_actor/Actor_SpawnIceEffects.s,Actor_SpawnIceEffects,0x800BF7CC,0x75 asm/non_matchings/code/z_actor_dlftbls/ActorOverlayTable_FaultPrint.s,ActorOverlayTable_FaultPrint,0x800BF9A0,0x36 asm/non_matchings/code/z_actor_dlftbls/ActorOverlayTable_FaultAddrConv.s,ActorOverlayTable_FaultAddrConv,0x800BFA78,0x1C asm/non_matchings/code/z_actor_dlftbls/ActorOverlayTable_Init.s,ActorOverlayTable_Init,0x800BFAE8,0x16 @@ -782,7 +782,7 @@ asm/non_matchings/code/z_camera/func_800DE954.s,func_800DE954,0x800DE954,0x17 asm/non_matchings/code/z_camera/Camera_Update.s,Camera_Update,0x800DE9B0,0x2BA asm/non_matchings/code/z_camera/func_800DF498.s,func_800DF498,0x800DF498,0xE asm/non_matchings/code/z_camera/Camera_SetMode.s,Camera_SetMode,0x800DF4D0,0xDC -asm/non_matchings/code/z_camera/func_800DF840.s,func_800DF840,0x800DF840,0xB +asm/non_matchings/code/z_camera/Camera_ChangeMode.s,Camera_ChangeMode,0x800DF840,0xB asm/non_matchings/code/z_camera/func_800DF86C.s,func_800DF86C,0x800DF86C,0x20 asm/non_matchings/code/z_camera/func_800DF8EC.s,func_800DF8EC,0x800DF8EC,0x77 asm/non_matchings/code/z_camera/func_800DFAC8.s,func_800DFAC8,0x800DFAC8,0x13 @@ -1124,11 +1124,11 @@ asm/non_matchings/code/z_eff_footmark/EffFootmark_Init.s,EffFootmark_Init,0x800E asm/non_matchings/code/z_eff_footmark/EffFootmark_Add.s,EffFootmark_Add,0x800EFF04,0x6E asm/non_matchings/code/z_eff_footmark/EffFootmark_Update.s,EffFootmark_Update,0x800F00BC,0x43 asm/non_matchings/code/z_eff_footmark/EffFootmark_Draw.s,EffFootmark_Draw,0x800F01C8,0x72 -asm/non_matchings/code/code_800F0390/func_800F0390.s,func_800F0390,0x800F0390,0xC -asm/non_matchings/code/code_800F0390/func_800F03C0.s,func_800F03C0,0x800F03C0,0x33 -asm/non_matchings/code/code_800F0390/func_800F048C.s,func_800F048C,0x800F048C,0x37 -asm/non_matchings/code/code_800F0390/Audio_PlaySoundAtPosition.s,Audio_PlaySoundAtPosition,0x800F0568,0xA -asm/non_matchings/code/code_800F0390/func_800F0590.s,func_800F0590,0x800F0590,0xC +asm/non_matchings/code/z_sound_source/SoundSource_InitAll.s,SoundSource_InitAll,0x800F0390,0xC +asm/non_matchings/code/z_sound_source/SoundSource_UpdateAll.s,SoundSource_UpdateAll,0x800F03C0,0x33 +asm/non_matchings/code/z_sound_source/SoundSource_Add.s,SoundSource_Add,0x800F048C,0x37 +asm/non_matchings/code/z_sound_source/SoundSource_PlaySfxAtFixedWorldPos.s,SoundSource_PlaySfxAtFixedWorldPos,0x800F0568,0xA +asm/non_matchings/code/z_sound_source/SoundSource_PlaySfxEachFrameAtFixedWorldPos.s,SoundSource_PlaySfxEachFrameAtFixedWorldPos,0x800F0590,0xC asm/non_matchings/code/z_elf_message/func_800F05C0.s,func_800F05C0,0x800F05C0,0x80 asm/non_matchings/code/code_800F07C0/func_800F07C0.s,func_800F07C0,0x800F07C0,0x32 asm/non_matchings/code/code_800F07C0/func_800F0888.s,func_800F0888,0x800F0888,0x2F @@ -1361,7 +1361,7 @@ asm/non_matchings/code/z_lib/Math_ApproachS.s,Math_ApproachS,0x800FFFD8,0x29 asm/non_matchings/code/z_lib/Color_RGBA8_Copy.s,Color_RGBA8_Copy,0x8010007C,0xA asm/non_matchings/code/z_lib/func_801000A4.s,func_801000A4,0x801000A4,0xA asm/non_matchings/code/z_lib/func_801000CC.s,func_801000CC,0x801000CC,0xA -asm/non_matchings/code/z_lib/func_801000F4.s,func_801000F4,0x801000F4,0xA +asm/non_matchings/code/z_lib/Lib_PlaySfxAtPos.s,Lib_PlaySfxAtPos,0x801000F4,0xA asm/non_matchings/code/z_lib/Lib_Vec3f_TranslateAndRotateY.s,Lib_Vec3f_TranslateAndRotateY,0x8010011C,0x27 asm/non_matchings/code/z_lib/Lib_LerpRGB.s,Lib_LerpRGB,0x801001B8,0xA4 asm/non_matchings/code/z_lib/Math_Vec3f_StepTo.s,Math_Vec3f_StepTo,0x80100448,0x2D @@ -1705,7 +1705,7 @@ asm/non_matchings/code/z_player_lib/func_8012300C.s,func_8012300C,0x8012300C,0x4 asm/non_matchings/code/z_player_lib/func_8012301C.s,func_8012301C,0x8012301C,0x49 asm/non_matchings/code/z_player_lib/func_80123140.s,func_80123140,0x80123140,0x86 asm/non_matchings/code/z_player_lib/func_80123358.s,func_80123358,0x80123358,0x23 -asm/non_matchings/code/z_player_lib/func_801233E4.s,func_801233E4,0x801233E4,0xF +asm/non_matchings/code/z_player_lib/Player_InCsMode.s,Player_InCsMode,0x801233E4,0xF asm/non_matchings/code/z_player_lib/func_80123420.s,func_80123420,0x80123420,0x5 asm/non_matchings/code/z_player_lib/func_80123434.s,func_80123434,0x80123434,0x5 asm/non_matchings/code/z_player_lib/func_80123448.s,func_80123448,0x80123448,0x1A @@ -1743,7 +1743,7 @@ asm/non_matchings/code/z_player_lib/func_801241B4.s,func_801241B4,0x801241B4,0xB asm/non_matchings/code/z_player_lib/func_801241E0.s,func_801241E0,0x801241E0,0xB asm/non_matchings/code/z_player_lib/func_8012420C.s,func_8012420C,0x8012420C,0x8 asm/non_matchings/code/z_player_lib/func_8012422C.s,func_8012422C,0x8012422C,0xB -asm/non_matchings/code/z_player_lib/func_80124258.s,func_80124258,0x80124258,0x8 +asm/non_matchings/code/z_player_lib/Player_GetExplosiveHeld.s,Player_GetExplosiveHeld,0x80124258,0x8 asm/non_matchings/code/z_player_lib/func_80124278.s,func_80124278,0x80124278,0xF asm/non_matchings/code/z_player_lib/func_801242B4.s,func_801242B4,0x801242B4,0xA asm/non_matchings/code/z_player_lib/func_801242DC.s,func_801242DC,0x801242DC,0x51 @@ -2169,7 +2169,7 @@ asm/non_matchings/code/z_snap/func_8013A46C.s,func_8013A46C,0x8013A46C,0x16 asm/non_matchings/code/z_snap/func_8013A4C4.s,func_8013A4C4,0x8013A4C4,0x10 asm/non_matchings/code/z_snap/func_8013A504.s,func_8013A504,0x8013A504,0xB asm/non_matchings/code/z_snap/func_8013A530.s,func_8013A530,0x8013A530,0xA4 -asm/non_matchings/code/z_sub_s/func_8013A7C0.s,func_8013A7C0,0x8013A7C0,0x28 +asm/non_matchings/code/z_sub_s/SubS_FindDoor.s,SubS_FindDoor,0x8013A7C0,0x28 asm/non_matchings/code/z_sub_s/func_8013A860.s,func_8013A860,0x8013A860,0xA8 asm/non_matchings/code/z_sub_s/func_8013AB00.s,func_8013AB00,0x8013AB00,0x9B asm/non_matchings/code/z_sub_s/func_8013AD6C.s,func_8013AD6C,0x8013AD6C,0xC @@ -2182,7 +2182,7 @@ asm/non_matchings/code/z_sub_s/func_8013B350.s,func_8013B350,0x8013B350,0xD8 asm/non_matchings/code/z_sub_s/func_8013B6B0.s,func_8013B6B0,0x8013B6B0,0x72 asm/non_matchings/code/z_sub_s/func_8013B878.s,func_8013B878,0x8013B878,0xAF asm/non_matchings/code/z_sub_s/func_8013BB34.s,func_8013BB34,0x8013BB34,0x12 -asm/non_matchings/code/z_sub_s/func_8013BB7C.s,func_8013BB7C,0x8013BB7C,0x3C +asm/non_matchings/code/z_sub_s/SubS_FindNearestActor.s,SubS_FindNearestActor,0x8013BB7C,0x3C asm/non_matchings/code/z_sub_s/func_8013BC6C.s,func_8013BC6C,0x8013BC6C,0x35 asm/non_matchings/code/z_sub_s/func_8013BD40.s,func_8013BD40,0x8013BD40,0x67 asm/non_matchings/code/z_sub_s/func_8013BEDC.s,func_8013BEDC,0x8013BEDC,0x63 @@ -2203,7 +2203,7 @@ asm/non_matchings/code/z_sub_s/func_8013D768.s,func_8013D768,0x8013D768,0x35 asm/non_matchings/code/z_sub_s/func_8013D83C.s,func_8013D83C,0x8013D83C,0x28 asm/non_matchings/code/z_sub_s/func_8013D8DC.s,func_8013D8DC,0x8013D8DC,0x12 asm/non_matchings/code/z_sub_s/func_8013D924.s,func_8013D924,0x8013D924,0xF -asm/non_matchings/code/z_sub_s/func_ActorCategoryIterateById.s,func_ActorCategoryIterateById,0x8013D960,0x1A +asm/non_matchings/code/z_sub_s/SubS_FindActor.s,SubS_FindActor,0x8013D960,0x1A asm/non_matchings/code/z_sub_s/func_8013D9C8.s,func_8013D9C8,0x8013D9C8,0x72 asm/non_matchings/code/z_sub_s/func_8013DB90.s,func_8013DB90,0x8013DB90,0x2C asm/non_matchings/code/z_sub_s/func_8013DC40.s,func_8013DC40,0x8013DC40,0x23 @@ -2219,7 +2219,7 @@ asm/non_matchings/code/z_sub_s/func_8013E2D4.s,func_8013E2D4,0x8013E2D4,0x39 asm/non_matchings/code/z_sub_s/func_8013E3B8.s,func_8013E3B8,0x8013E3B8,0x3E asm/non_matchings/code/z_sub_s/func_8013E4B0.s,func_8013E4B0,0x8013E4B0,0x47 asm/non_matchings/code/z_sub_s/func_8013E5CC.s,func_8013E5CC,0x8013E5CC,0x1D -asm/non_matchings/code/z_sub_s/func_8013E640.s,func_8013E640,0x8013E640,0x42 +asm/non_matchings/code/z_sub_s/SubS_FindActorCustom.s,SubS_FindActorCustom,0x8013E640,0x42 asm/non_matchings/code/z_sub_s/func_8013E748.s,func_8013E748,0x8013E748,0x1E asm/non_matchings/code/z_sub_s/func_8013E7C0.s,func_8013E7C0,0x8013E7C0,0x4E asm/non_matchings/code/z_sub_s/func_8013E8F8.s,func_8013E8F8,0x8013E8F8,0x16 @@ -2374,7 +2374,7 @@ asm/non_matchings/code/z_message/func_80151C9C.s,func_80151C9C,0x80151C9C,0x42 asm/non_matchings/code/z_message/func_80151DA4.s,func_80151DA4,0x80151DA4,0x1A4 asm/non_matchings/code/z_message/func_80152434.s,func_80152434,0x80152434,0xC asm/non_matchings/code/z_message/func_80152464.s,func_80152464,0x80152464,0xD -asm/non_matchings/code/z_message/func_80152498.s,func_80152498,0x80152498,0x7D +asm/non_matchings/code/z_message/Message_GetState.s,Message_GetState,0x80152498,0x7D asm/non_matchings/code/z_message/func_8015268C.s,func_8015268C,0x8015268C,0x176 asm/non_matchings/code/z_message/func_80152C64.s,func_80152C64,0x80152C64,0x12 asm/non_matchings/code/z_message/func_80152CAC.s,func_80152CAC,0x80152CAC,0x85 @@ -2838,7 +2838,7 @@ asm/non_matchings/code/sys_math3d/func_8017D2FC.s,func_8017D2FC,0x8017D2FC,0x42 asm/non_matchings/code/sys_math3d/func_8017D404.s,func_8017D404,0x8017D404,0x59 asm/non_matchings/code/sys_math3d/Math3D_TriSetCoords.s,Math3D_TriSetCoords,0x8017D568,0x2C asm/non_matchings/code/sys_math3d/Math3D_IsPointInSphere.s,Math3D_IsPointInSphere,0x8017D618,0x14 -asm/non_matchings/code/sys_math3d/func_8017D668.s,func_8017D668,0x8017D668,0x56 +asm/non_matchings/code/sys_math3d/Math3D_PointDistToLine2D.s,Math3D_PointDistToLine2D,0x8017D668,0x56 asm/non_matchings/code/sys_math3d/func_8017D7C0.s,func_8017D7C0,0x8017D7C0,0x15 asm/non_matchings/code/sys_math3d/func_8017D814.s,func_8017D814,0x8017D814,0x42 asm/non_matchings/code/sys_math3d/func_8017D91C.s,func_8017D91C,0x8017D91C,0x42 @@ -3238,8 +3238,8 @@ asm/non_matchings/code/code_80192BE0/func_80194548.s,func_80194548,0x80194548,0x 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_80194710/func_80194710.s,func_80194710,0x80194710,0x10 -asm/non_matchings/code/code_80194710/func_80194750.s,func_80194750,0x80194750,0x10 +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 asm/non_matchings/code/code_80194710/func_80194804.s,func_80194804,0x80194804,0xF asm/non_matchings/code/code_80194710/func_80194840.s,func_80194840,0x80194840,0x1C @@ -3388,7 +3388,7 @@ asm/non_matchings/code/code_8019AF00/func_8019F05C.s,func_8019F05C,0x8019F05C,0x asm/non_matchings/code/code_8019AF00/play_sound.s,play_sound,0x8019F0C8,0x18 asm/non_matchings/code/code_8019AF00/func_8019F128.s,func_8019F128,0x8019F128,0x12 asm/non_matchings/code/code_8019AF00/func_8019F170.s,func_8019F170,0x8019F170,0x14 -asm/non_matchings/code/code_8019AF00/func_8019F1C0.s,func_8019F1C0,0x8019F1C0,0x12 +asm/non_matchings/code/code_8019AF00/Audio_PlaySfxAtPos.s,Audio_PlaySfxAtPos,0x8019F1C0,0x12 asm/non_matchings/code/code_8019AF00/func_8019F208.s,func_8019F208,0x8019F208,0xA asm/non_matchings/code/code_8019AF00/func_8019F230.s,func_8019F230,0x8019F230,0xA asm/non_matchings/code/code_8019AF00/func_8019F258.s,func_8019F258,0x8019F258,0x2A @@ -3551,7 +3551,7 @@ asm/non_matchings/code/code_801A51F0/func_801A5A1C.s,func_801A5A1C,0x801A5A1C,0x asm/non_matchings/code/code_801A5BD0/func_801A5BD0.s,func_801A5BD0,0x801A5BD0,0x16 asm/non_matchings/code/code_801A5BD0/func_801A5C28.s,func_801A5C28,0x801A5C28,0x19 asm/non_matchings/code/code_801A5BD0/func_801A5C8C.s,func_801A5C8C,0x801A5C8C,0x1C -asm/non_matchings/code/code_801A5BD0/func_801A5CFC.s,func_801A5CFC,0x801A5CFC,0x38 +asm/non_matchings/code/code_801A5BD0/Audio_PlaySfxGeneral.s,Audio_PlaySfxGeneral,0x801A5CFC,0x38 asm/non_matchings/code/code_801A5BD0/func_801A5DDC.s,func_801A5DDC,0x801A5DDC,0x68 asm/non_matchings/code/code_801A5BD0/func_801A5F7C.s,func_801A5F7C,0x801A5F7C,0x12D asm/non_matchings/code/code_801A5BD0/func_801A6430.s,func_801A6430,0x801A6430,0x66 @@ -3560,7 +3560,7 @@ asm/non_matchings/code/code_801A5BD0/func_801A6D0C.s,func_801A6D0C,0x801A6D0C,0x asm/non_matchings/code/code_801A5BD0/func_801A7084.s,func_801A7084,0x801A7084,0x39 asm/non_matchings/code/code_801A5BD0/func_801A7168.s,func_801A7168,0x801A7168,0x47 asm/non_matchings/code/code_801A5BD0/func_801A7284.s,func_801A7284,0x801A7284,0x12 -asm/non_matchings/code/code_801A5BD0/func_801A72CC.s,func_801A72CC,0x801A72CC,0x17 +asm/non_matchings/code/code_801A5BD0/Audio_StopSfxByPos.s,Audio_StopSfxByPos,0x801A72CC,0x17 asm/non_matchings/code/code_801A5BD0/func_801A7328.s,func_801A7328,0x801A7328,0x57 asm/non_matchings/code/code_801A5BD0/func_801A7484.s,func_801A7484,0x801A7484,0x59 asm/non_matchings/code/code_801A5BD0/func_801A75E8.s,func_801A75E8,0x801A75E8,0x4E diff --git a/tools/vtxdis.c b/tools/vtxdis.c index 1ba6969635..8debd89e0c 100644 --- a/tools/vtxdis.c +++ b/tools/vtxdis.c @@ -254,4 +254,4 @@ int main(int argc, char **argv) } return 0; -} \ No newline at end of file +} diff --git a/undefined_syms.txt b/undefined_syms.txt index ba74050c01..9cca916c00 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -403,7 +403,6 @@ D_0401A590 = 0x0401A590; D_0401A620 = 0x0401A620; D_0401ACF0 = 0x0401ACF0; D_0401ED00 = 0x0401ED00; -D_0401F0F0 = 0x0401F0F0; D_0401F740 = 0x0401F740; D_0401F7C0 = 0x0401F7C0; D_0401F8C0 = 0x0401F8C0; @@ -521,14 +520,11 @@ D_04073F00 = 0x04073F00; D_04074330 = 0x04074330; D_04075400 = 0x04075400; D_04075A40 = 0x04075A40; -D_04075B30 = 0x04075B30; D_04076BC0 = 0x04076BC0; -D_04077480 = 0x04077480; D_04079B10 = 0x04079B10; D_0407AB10 = 0x0407AB10; D_0407AB58 = 0x0407AB58; D_0407AB70 = 0x0407AB70; -D_0407AE00 = 0x0407AE00; D_0407AFB0 = 0x0407AFB0; D_0407D590 = 0x0407D590; D_0407D650 = 0x0407D650; @@ -549,6 +545,10 @@ D_0408F3E0 = 0x0408F3E0; D_0408F7E0 = 0x0408F7E0; D_04091BE0 = 0x04091BE0; D_04091CE0 = 0x04091CE0; +D_04091DE0 = 0x04091DE0; +D_04091FE0 = 0x04091FE0; +D_040921E0 = 0x040921E0; +D_040923E0 = 0x040923E0; // segment 0x05 @@ -881,6 +881,15 @@ D_06013058 = 0x06013058; D_060006B0 = 0x060006B0; D_060016DC = 0x060016DC; +// ovl_Bg_Inibs_Movebg + +D_06001C10 = 0x06001C10; +D_06001DC0 = 0x06001DC0; +D_06002598 = 0x06002598; +D_06006140 = 0x06006140; +D_060062D8 = 0x060062D8; +D_06006858 = 0x06006858; + // ovl_Bg_Keikoku_Saku D_06001640 = 0x06001640; @@ -1078,13 +1087,6 @@ D_06009C14 = 0x06009C14; D_06009CF8 = 0x06009CF8; D_0600A6C8 = 0x0600A6C8; -// ovl_Boss_04 - -D_0600004C = 0x0600004C; -D_06004510 = 0x06004510; -D_06004550 = 0x06004550; -D_060045E8 = 0x060045E8; - // ovl_Boss_05 D_060006A4 = 0x060006A4; @@ -1479,17 +1481,12 @@ D_06013EA8 = 0x06013EA8; // ovl_Door_Warp1 -D_060001A0 = 0x060001A0; -D_06001374 = 0x06001374; -D_06002CA8 = 0x06002CA8; D_06003230 = 0x06003230; D_060044D8 = 0x060044D8; D_06004690 = 0x06004690; D_060057D8 = 0x060057D8; D_060058C8 = 0x060058C8; D_06007238 = 0x06007238; -D_060076C0 = 0x060076C0; -D_06008BD4 = 0x06008BD4; // ovl_Effect_En_Ice_Block @@ -1537,13 +1534,6 @@ D_06000F38 = 0x06000F38; D_06009E70 = 0x06009E70; -// ovl_En_Akindonuts - -D_06001350 = 0x06001350; -D_06005488 = 0x06005488; -D_06008290 = 0x06008290; -D_0600AC70 = 0x0600AC70; - // ovl_En_Al D_0600A0D8 = 0x0600A0D8; @@ -1579,11 +1569,6 @@ D_060028A0 = 0x060028A0; D_06009220 = 0x06009220; D_06009D34 = 0x06009D34; -// ovl_En_Aob_01 - -D_06000180 = 0x06000180; -D_06003D18 = 0x06003D18; - // ovl_En_Attack_Niw D_060000E8 = 0x060000E8; @@ -1603,13 +1588,6 @@ D_06005EF0 = 0x06005EF0; D_06006B10 = 0x06006B10; D_060092A0 = 0x060092A0; -// ovl_En_Baguo - -D_060014C8 = 0x060014C8; -D_060018C8 = 0x060018C8; -D_06001CC8 = 0x06001CC8; -D_060020E8 = 0x060020E8; - // ovl_En_Baisen D_060008B4 = 0x060008B4; @@ -1676,49 +1654,6 @@ D_06004210 = 0x06004210; D_06007C70 = 0x06007C70; D_0600823C = 0x0600823C; -// ovl_En_Bigpo - -D_06000454 = 0x06000454; -D_06000924 = 0x06000924; -D_06001360 = 0x06001360; -D_06001BB0 = 0x06001BB0; -D_060041A0 = 0x060041A0; -D_060042C8 = 0x060042C8; -D_060043F8 = 0x060043F8; -D_060058B8 = 0x060058B8; -D_06005C18 = 0x06005C18; - -// ovl_En_Bigslime - -D_060010F4 = 0x060010F4; -D_06001B08 = 0x06001B08; -D_0600276C = 0x0600276C; -D_06002E0C = 0x06002E0C; -D_0600347C = 0x0600347C; -D_060039C4 = 0x060039C4; -D_06003F28 = 0x06003F28; -D_060066B4 = 0x060066B4; -D_060069FC = 0x060069FC; -D_060070C4 = 0x060070C4; -D_06007790 = 0x06007790; -D_0600DF98 = 0x0600DF98; -D_0600F048 = 0x0600F048; -D_0600F3F0 = 0x0600F3F0; -D_0600F990 = 0x0600F990; -D_0600F9D0 = 0x0600F9D0; -D_0600FB40 = 0x0600FB40; -D_06010530 = 0x06010530; -D_060105E8 = 0x060105E8; -D_06010B80 = 0x06010B80; -D_06010C48 = 0x06010C48; -D_06010DB0 = 0x06010DB0; -D_06010EC8 = 0x06010EC8; -D_06010F20 = 0x06010F20; -D_06010FE0 = 0x06010FE0; -D_06011008 = 0x06011008; -D_06011050 = 0x06011050; -D_060113B0 = 0x060113B0; - // ovl_En_Bji_01 D_0600066C = 0x0600066C; @@ -1755,11 +1690,6 @@ D_06000340 = 0x06000340; D_06000408 = 0x06000408; D_06000530 = 0x06000530; -// ovl_En_Bomjima - -D_060064B8 = 0x060064B8; -D_0600F82C = 0x0600F82C; - // ovl_En_Bomjimb D_060064B8 = 0x060064B8; @@ -2235,21 +2165,6 @@ D_0600A490 = 0x0600A490; D_06010240 = 0x06010240; -// ovl_En_Fall - -D_06000198 = 0x06000198; -D_06000400 = 0x06000400; -D_060004C0 = 0x060004C0; -D_060004C8 = 0x060004C8; -D_060010E0 = 0x060010E0; -D_06001158 = 0x06001158; -D_060011D0 = 0x060011D0; -D_06001220 = 0x06001220; -D_06002970 = 0x06002970; -D_06003C30 = 0x06003C30; -D_06004E38 = 0x06004E38; -D_060077F0 = 0x060077F0; - // ovl_En_Fall2 D_06005EF4 = 0x06005EF4; @@ -2290,48 +2205,8 @@ D_06006190 = 0x06006190; // ovl_En_Fishing -D_0600007C = 0x0600007C; -D_060029C0 = 0x060029C0; -D_06003230 = 0x06003230; -D_06003460 = 0x06003460; -D_060034C0 = 0x060034C0; -D_06003610 = 0x06003610; -D_06003680 = 0x06003680; -D_06003710 = 0x06003710; -D_06003760 = 0x06003760; -D_060039A8 = 0x060039A8; -D_06003A18 = 0x06003A18; -D_0600453C = 0x0600453C; -D_06007350 = 0x06007350; -D_060074C8 = 0x060074C8; -D_060085F8 = 0x060085F8; -D_06008610 = 0x06008610; -D_06008678 = 0x06008678; -D_060088C0 = 0x060088C0; -D_06008970 = 0x06008970; -D_0600B950 = 0x0600B950; -D_0600B9C0 = 0x0600B9C0; -D_0600C220 = 0x0600C220; -D_0600C298 = 0x0600C298; D_0600CFE0 = 0x0600CFE0; D_06011058 = 0x06011058; -D_06011070 = 0x06011070; -D_06011170 = 0x06011170; -D_06011270 = 0x06011270; -D_060113D0 = 0x060113D0; -D_06011410 = 0x06011410; -D_06012160 = 0x06012160; -D_060121F0 = 0x060121F0; -D_06013330 = 0x06013330; -D_060133B0 = 0x060133B0; -D_06013590 = 0x06013590; -D_06013610 = 0x06013610; -D_06013F50 = 0x06013F50; -D_06013FD0 = 0x06013FD0; -D_06014030 = 0x06014030; -D_060140B0 = 0x060140B0; -D_060153D0 = 0x060153D0; -D_06015470 = 0x06015470; // ovl_En_Floormas @@ -2396,11 +2271,6 @@ D_060015C0 = 0x060015C0; D_060023D4 = 0x060023D4; D_06002720 = 0x06002720; -// ovl_En_Gb2 - -D_0600049C = 0x0600049C; -D_06007230 = 0x06007230; - // ovl_En_Ge1 D_06002B98 = 0x06002B98; @@ -2421,13 +2291,6 @@ D_0600A344 = 0x0600A344; D_06001EFC = 0x06001EFC; D_0600A808 = 0x0600A808; -// ovl_En_Geg - -D_06004DB0 = 0x06004DB0; -D_060091A8 = 0x060091A8; -D_06011AC8 = 0x06011AC8; -D_06012DE0 = 0x06012DE0; - // ovl_En_Gg D_0600F578 = 0x0600F578; @@ -2438,30 +2301,6 @@ D_0600F6C0 = 0x0600F6C0; D_0600F578 = 0x0600F578; D_0600F6C0 = 0x0600F6C0; -// ovl_En_Giant - -D_06002168 = 0x06002168; -D_06005A80 = 0x06005A80; -D_06006280 = 0x06006280; -D_06006A80 = 0x06006A80; -D_06007610 = 0x06007610; -D_060079B0 = 0x060079B0; -D_06008394 = 0x06008394; -D_060096E4 = 0x060096E4; -D_0600A1C4 = 0x0600A1C4; -D_0600ACA4 = 0x0600ACA4; -D_0600B784 = 0x0600B784; -D_0600C5D4 = 0x0600C5D4; -D_0600D040 = 0x0600D040; -D_0600DE84 = 0x0600DE84; -D_060102A4 = 0x060102A4; -D_060116E4 = 0x060116E4; -D_06012A38 = 0x06012A38; -D_06013004 = 0x06013004; -D_06013FE8 = 0x06013FE8; -D_06015334 = 0x06015334; -D_06017944 = 0x06017944; - // ovl_En_Ginko_Man D_060008C0 = 0x060008C0; @@ -2500,22 +2339,6 @@ D_0600B990 = 0x0600B990; D_0600BA80 = 0x0600BA80; D_0600C03C = 0x0600C03C; -// ovl_En_Go - -D_060003D0 = 0x060003D0; -D_06000458 = 0x06000458; -D_060008C0 = 0x060008C0; -D_06000948 = 0x06000948; -D_06000D50 = 0x06000D50; -D_06000DD8 = 0x06000DD8; -D_06001560 = 0x06001560; -D_060031A0 = 0x060031A0; -D_06003258 = 0x06003258; -D_060091A8 = 0x060091A8; -D_06011AC8 = 0x06011AC8; -D_06014CF0 = 0x06014CF0; -D_06014D00 = 0x06014D00; - // ovl_En_Goroiwa D_060032E0 = 0x060032E0; @@ -2777,10 +2600,6 @@ D_06012FC8 = 0x06012FC8; D_06013928 = 0x06013928; D_06016588 = 0x06016588; -// ovl_En_Ishi - -D_060009B0 = 0x060009B0; - // ovl_En_Ja D_0600BA30 = 0x0600BA30; @@ -2840,23 +2659,6 @@ D_0600686C = 0x0600686C; D_060081A4 = 0x060081A4; D_06000214 = 0x06000214; -// ovl_En_Kame - -D_060008B4 = 0x060008B4; -D_06000AF4 = 0x06000AF4; -D_06000B30 = 0x06000B30; -D_06001A50 = 0x06001A50; -D_06001C68 = 0x06001C68; -D_06002510 = 0x06002510; -D_060027D8 = 0x060027D8; -D_06002F88 = 0x06002F88; -D_060031DC = 0x060031DC; -D_060035EC = 0x060035EC; -D_060039C0 = 0x060039C0; -D_06004210 = 0x06004210; -D_06007C70 = 0x06007C70; -D_0600823C = 0x0600823C; - // ovl_En_Kanban D_06000C30 = 0x06000C30; @@ -3261,42 +3063,10 @@ D_06006EE8 = 0x06006EE8; D_060072E8 = 0x060072E8; D_060073E8 = 0x060073E8; -// ovl_En_Pametfrog - -D_06000994 = 0x06000994; -D_06001B08 = 0x06001B08; -D_06001E14 = 0x06001E14; -D_06001F20 = 0x06001F20; -D_060030E4 = 0x060030E4; -D_0600347C = 0x0600347C; -D_060039C4 = 0x060039C4; -D_06003F28 = 0x06003F28; -D_06004298 = 0x06004298; -D_06004680 = 0x06004680; -D_06004894 = 0x06004894; -D_06004D50 = 0x06004D50; -D_060050B8 = 0x060050B8; -D_060052EC = 0x060052EC; -D_06005694 = 0x06005694; -D_06005D54 = 0x06005D54; -D_060066B4 = 0x060066B4; -D_060070C4 = 0x060070C4; -D_0600DF98 = 0x0600DF98; -D_0600F048 = 0x0600F048; -D_0600F990 = 0x0600F990; - // ovl_En_Paper D_0600D5A0 = 0x0600D5A0; -// ovl_En_Peehat - -D_06000350 = 0x06000350; -D_060005C4 = 0x060005C4; -D_06000844 = 0x06000844; -D_060009C4 = 0x060009C4; -D_06001C80 = 0x06001C80; - // ovl_En_Pm D_06008348 = 0x06008348; @@ -3430,11 +3200,6 @@ D_06001600 = 0x06001600; D_060009C4 = 0x060009C4; D_06000F1C = 0x06000F1C; -// ovl_En_Rail_Skb - -D_06005EF8 = 0x06005EF8; -D_060064E0 = 0x060064E0; - // ovl_En_Rat D_06000174 = 0x06000174; @@ -3494,11 +3259,6 @@ D_06009220 = 0x06009220; D_0600C700 = 0x0600C700; -// ovl_En_Ruppecrow - -D_060000F0 = 0x060000F0; -D_060010C0 = 0x060010C0; - // ovl_En_Rz D_06003A20 = 0x06003A20; @@ -3612,17 +3372,7 @@ D_06011038 = 0x06011038; // ovl_En_Ssh -D_060000D8 = 0x060000D8; D_06000304 = 0x06000304; -D_06001494 = 0x06001494; -D_06005210 = 0x06005210; -D_06005850 = 0x06005850; -D_06005F78 = 0x06005F78; -D_06006470 = 0x06006470; - -// ovl_En_St - -D_06005298 = 0x06005298; // ovl_En_Sth @@ -3645,10 +3395,6 @@ D_0600D640 = 0x0600D640; D_06006C18 = 0x06006C18; D_0600D640 = 0x0600D640; -// ovl_En_Stream - -D_06000950 = 0x06000950; - // ovl_En_Suttari D_0600071C = 0x0600071C; @@ -3732,13 +3478,6 @@ D_06009890 = 0x06009890; D_0600A280 = 0x0600A280; D_0600AD98 = 0x0600AD98; -// ovl_En_Talk_Gibud - -D_060053E8 = 0x060053E8; -D_06009298 = 0x06009298; -D_0600ABE0 = 0x0600ABE0; -D_06010B88 = 0x06010B88; - // ovl_En_Tanron2 D_06003450 = 0x06003450; @@ -3870,27 +3609,8 @@ D_0600FEF0 = 0x0600FEF0; // ovl_En_Tru -D_06001F90 = 0x06001F90; -D_060020C8 = 0x060020C8; -D_06002BD8 = 0x06002BD8; -D_06003698 = 0x06003698; -D_0600446C = 0x0600446C; -D_06007FA0 = 0x06007FA0; -D_06009348 = 0x06009348; -D_0600EEDC = 0x0600EEDC; -D_0600F9A0 = 0x0600F9A0; -D_060108AC = 0x060108AC; -D_06011F88 = 0x06011F88; -D_06014728 = 0x06014728; -D_06015CA0 = 0x06015CA0; -D_06016B4C = 0x06016B4C; -D_06018FA0 = 0x06018FA0; -D_060197A0 = 0x060197A0; -D_06019FA0 = 0x06019FA0; D_0601A820 = 0x0601A820; D_0601A830 = 0x0601A830; -D_0601AA60 = 0x0601AA60; -D_0601B5C4 = 0x0601B5C4; // ovl_En_Tru_Mt @@ -3933,22 +3653,6 @@ D_0600A054 = 0x0600A054; D_06000EC0 = 0x06000EC0; -// ovl_En_Water_Effect - -D_06000420 = 0x06000420; -D_06000730 = 0x06000730; -D_06000A48 = 0x06000A48; -D_06000CD8 = 0x06000CD8; -D_06000DE0 = 0x06000DE0; -D_06000E0C = 0x06000E0C; -D_06000E40 = 0x06000E40; -D_06000E58 = 0x06000E58; -D_06004260 = 0x06004260; -D_060042B0 = 0x060042B0; -D_060042F8 = 0x060042F8; -D_06004340 = 0x06004340; -D_060043E8 = 0x060043E8; - // ovl_En_Wdhand D_060000F4 = 0x060000F4; @@ -3993,18 +3697,6 @@ D_06001690 = 0x06001690; D_06005870 = 0x06005870; D_06005C64 = 0x06005C64; -// ovl_En_Wiz_Fire - -D_06000E70 = 0x06000E70; -D_06000FD8 = 0x06000FD8; -D_06002630 = 0x06002630; -D_06002B40 = 0x06002B40; -D_06003120 = 0x06003120; -D_06003640 = 0x06003640; -D_06003FC0 = 0x06003FC0; -D_06005190 = 0x06005190; -D_06005750 = 0x06005750; - // ovl_En_Wood02 D_06000700 = 0x06000700; @@ -4033,12 +3725,6 @@ D_06000D94 = 0x06000D94; D_06007650 = 0x06007650; D_0600D658 = 0x0600D658; -// ovl_En_Zog - -D_0600FC0C = 0x0600FC0C; -D_060280A8 = 0x060280A8; -D_06029170 = 0x06029170; - // ovl_En_Zoraegg D_060005D4 = 0x060005D4; @@ -4210,13 +3896,6 @@ D_06003440 = 0x06003440; D_06000158 = 0x06000158; D_06001C00 = 0x06001C00; -// ovl_Obj_Flowerpot - -D_060012E0 = 0x060012E0; -D_06001408 = 0x06001408; -D_060014F0 = 0x060014F0; -D_060015B0 = 0x060015B0; - // ovl_Obj_Funen D_060000D0 = 0x060000D0; @@ -4259,14 +3938,6 @@ D_06001D10 = 0x06001D10; D_060003B8 = 0x060003B8; D_060011B0 = 0x060011B0; -// ovl_Obj_Hugebombiwa - -D_060009E0 = 0x060009E0; -D_06001820 = 0x06001820; -D_06001990 = 0x06001990; -D_06002F60 = 0x06002F60; -D_06003110 = 0x06003110; - // ovl_Obj_Hunsui D_06000220 = 0x06000220; @@ -4275,14 +3946,6 @@ D_06000C74 = 0x06000C74; D_06000EC0 = 0x06000EC0; D_06001888 = 0x06001888; -// ovl_Obj_Iceblock - -D_060001A0 = 0x060001A0; -D_06000328 = 0x06000328; -D_06000438 = 0x06000438; -D_060007F0 = 0x060007F0; -D_060009D0 = 0x060009D0; - // ovl_Obj_Jgame_Light D_060003A0 = 0x060003A0; @@ -4301,17 +3964,6 @@ D_06000180 = 0x06000180; D_06003478 = 0x06003478; D_0600805C = 0x0600805C; -// ovl_Obj_Kibako - -D_06001180 = 0x06001180; -D_06001A70 = 0x06001A70; - -// ovl_Obj_Kibako2 - -D_06000960 = 0x06000960; -D_06000B70 = 0x06000B70; -D_06001040 = 0x06001040; - // ovl_Obj_Kzsaku D_06000040 = 0x06000040; @@ -4383,11 +4035,6 @@ D_060011E0 = 0x060011E0; D_06001C00 = 0x06001C00; -// ovl_Obj_Snowball - -D_060082D0 = 0x060082D0; -D_06008B90 = 0x06008B90; - // ovl_Obj_Snowball2 D_06008B90 = 0x06008B90; @@ -4421,26 +4068,6 @@ D_06001CB0 = 0x06001CB0; D_06001400 = 0x06001400; -// ovl_Obj_Tokeidai - -D_06009A08 = 0x06009A08; -D_0600B0C0 = 0x0600B0C0; -D_0600B208 = 0x0600B208; -D_0600BA78 = 0x0600BA78; -D_0600BEE8 = 0x0600BEE8; -D_0600C368 = 0x0600C368; -D_0600CF28 = 0x0600CF28; -D_0600D388 = 0x0600D388; -D_0600D8E0 = 0x0600D8E0; -D_0600D8E8 = 0x0600D8E8; -D_0600E818 = 0x0600E818; -D_0600F518 = 0x0600F518; - -// ovl_Obj_Tokei_Step - -D_06000088 = 0x06000088; -D_06000968 = 0x06000968; - // ovl_Obj_Tokei_Turret D_06002508 = 0x06002508; @@ -4499,7 +4126,7 @@ D_060012E8 = 0x060012E8; D_06000360 = 0x06000360; D_06001428 = 0x06001428; -// ovl_Player_Actor +// ovl_player_actor D_06008860 = 0x06008860; D_0600BDD8 = 0x0600BDD8;