diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..94b8cdfa2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM ubuntu:22.04 as build +ENV TZ=UTC + +# Install Required Dependencies +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \ + apt-get update && apt-get install -y \ + curl \ + build-essential \ + binutils-mips-linux-gnu \ + pkg-config \ + python3 \ + python3-pip \ + git \ + wget \ + unzip \ + vbindiff \ + vim \ + clang-tidy-11 \ + clang-format-11 \ + libpng-dev && \ + apt clean && \ + rm -rf /var/lib/apt/lists/* + +# Install practicerom +RUN curl https://practicerom.com/public/packages/debian/pgp.pub | \ + apt-key add - && echo deb http://practicerom.com/public/packages/debian staging main >/etc/apt/sources.list.d/practicerom.list && apt update + +RUN apt-get install -y practicerom-dev + +COPY requirements.txt requirements.txt + +RUN python3 -m pip install --no-cache-dir -r requirements.txt + +ENV LANG C.UTF-8 + +RUN mkdir /mm + +WORKDIR /mm + +RUN git config --global --add safe.directory /mm + +ENTRYPOINT ["/bin/bash", "-c"] diff --git a/Jenkinsfile b/Jenkinsfile index fb60f0aca..29c3721b2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,6 +20,12 @@ pipeline { sh 'bash -c "tools/reloc_spec_check.sh"' } } + stage('Install Python dependencies') { + steps { + echo 'Installing Python dependencies' + sh 'python3 -m pip install -r requirements.txt' + } + } stage('Copy ROM') { steps { echo 'Setting up ROM...' diff --git a/README.md b/README.md index f48230b90..badca09fd 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ This is a WIP **decompilation** of ***The Legend of Zelda: Majora's Mask***. The The only version currently supported is N64 US, but we intend to eventually support every retail version of the original game (i.e. not versions of MM3D, which is a totally different game). 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.** @@ -38,7 +39,6 @@ Please refer to the following for more information: - [Discord](https://discord.zelda64.dev/) - [How to Contribute](CONTRIBUTING.md) - ## Installation ### Windows @@ -47,11 +47,13 @@ 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 20.04 Linux distributions. - ### MacOS Preparation is covered in a [separate document](docs/BUILDING_MACOS.md). +### Docker + +Preparation is covered in [Building Docker](docs/BUILDING_DOCKER.md). ### Linux (Native or under WSL / VM) @@ -127,13 +129,12 @@ md5sum: WARNING: 1 computed checksum did NOT match This means that something is wrong with the ROM's contents. Either the baserom files are incorrect due to a bad ROM, or some of the code is not matching. -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 ` +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 run with this command: `./tools/asm-differ/diff.py -wmo3 ` -**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`). +**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.) - ## Contributing All contributions are welcome. This is a group effort, and even small contributions can make a difference. diff --git a/assets/xml/objects/gameplay_dangeon_keep.xml b/assets/xml/objects/gameplay_dangeon_keep.xml index 9d5a9901a..7e4d2d201 100644 --- a/assets/xml/objects/gameplay_dangeon_keep.xml +++ b/assets/xml/objects/gameplay_dangeon_keep.xml @@ -67,7 +67,7 @@ - + @@ -87,7 +87,7 @@ - + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index e1a35f83b..d87ef3f31 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -786,17 +786,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -810,17 +810,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -854,8 +854,8 @@ - - + + @@ -871,7 +871,7 @@ - + @@ -924,12 +924,14 @@ - + + - + + @@ -1004,46 +1006,46 @@ - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + diff --git a/assets/xml/objects/object_al.xml b/assets/xml/objects/object_al.xml index d0f6a6cbb..dc28bcf6b 100644 --- a/assets/xml/objects/object_al.xml +++ b/assets/xml/objects/object_al.xml @@ -1,71 +1,71 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bat.xml b/assets/xml/objects/object_bat.xml index 35a5c158d..5a685024e 100644 --- a/assets/xml/objects/object_bat.xml +++ b/assets/xml/objects/object_bat.xml @@ -1,17 +1,21 @@  + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bba.xml b/assets/xml/objects/object_bba.xml index 144c685e4..c3c5a5c1b 100644 --- a/assets/xml/objects/object_bba.xml +++ b/assets/xml/objects/object_bba.xml @@ -18,7 +18,7 @@ - + diff --git a/assets/xml/objects/object_bh.xml b/assets/xml/objects/object_bh.xml index 84f3050c0..56b7de5f9 100644 --- a/assets/xml/objects/object_bh.xml +++ b/assets/xml/objects/object_bh.xml @@ -1,18 +1,18 @@  - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bjt.xml b/assets/xml/objects/object_bjt.xml index 6266711ab..59a71dcee 100644 --- a/assets/xml/objects/object_bjt.xml +++ b/assets/xml/objects/object_bjt.xml @@ -1,23 +1,28 @@  - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss04.xml b/assets/xml/objects/object_boss04.xml index d5d0f728a..ce54c25b4 100644 --- a/assets/xml/objects/object_boss04.xml +++ b/assets/xml/objects/object_boss04.xml @@ -1,30 +1,46 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_d_hsblock.xml b/assets/xml/objects/object_d_hsblock.xml index e9f90c011..b43647dc3 100644 --- a/assets/xml/objects/object_d_hsblock.xml +++ b/assets/xml/objects/object_d_hsblock.xml @@ -1,10 +1,11 @@  + - - - - - - + + + + + + diff --git a/assets/xml/objects/object_d_lift.xml b/assets/xml/objects/object_d_lift.xml index bcd707d68..475f7fd3e 100644 --- a/assets/xml/objects/object_d_lift.xml +++ b/assets/xml/objects/object_d_lift.xml @@ -3,9 +3,9 @@ - - - - + + + + diff --git a/assets/xml/objects/object_dog.xml b/assets/xml/objects/object_dog.xml index 89eba9c96..6941cb36c 100644 --- a/assets/xml/objects/object_dog.xml +++ b/assets/xml/objects/object_dog.xml @@ -17,7 +17,7 @@ - + diff --git a/assets/xml/objects/object_ds2n.xml b/assets/xml/objects/object_ds2n.xml index 8cee6b22e..721eec677 100644 --- a/assets/xml/objects/object_ds2n.xml +++ b/assets/xml/objects/object_ds2n.xml @@ -1,55 +1,93 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_f53_obj.xml b/assets/xml/objects/object_f53_obj.xml index 8fef96ac8..424d7c003 100644 --- a/assets/xml/objects/object_f53_obj.xml +++ b/assets/xml/objects/object_f53_obj.xml @@ -4,7 +4,7 @@ - + diff --git a/assets/xml/objects/object_fall2.xml b/assets/xml/objects/object_fall2.xml index 4e58e9fd3..25439a50a 100644 --- a/assets/xml/objects/object_fall2.xml +++ b/assets/xml/objects/object_fall2.xml @@ -11,7 +11,11 @@ - + + + + + @@ -25,5 +29,6 @@ + diff --git a/assets/xml/objects/object_fsn.xml b/assets/xml/objects/object_fsn.xml index f90bf4e4d..2ed2b5d08 100644 --- a/assets/xml/objects/object_fsn.xml +++ b/assets/xml/objects/object_fsn.xml @@ -53,7 +53,8 @@ - + + diff --git a/assets/xml/objects/object_fu_kaiten.xml b/assets/xml/objects/object_fu_kaiten.xml index bce80f68c..37a7ec4bc 100644 --- a/assets/xml/objects/object_fu_kaiten.xml +++ b/assets/xml/objects/object_fu_kaiten.xml @@ -12,6 +12,7 @@ - + + diff --git a/assets/xml/objects/object_fwall.xml b/assets/xml/objects/object_fwall.xml index 1f7fb575b..1bbb5d572 100644 --- a/assets/xml/objects/object_fwall.xml +++ b/assets/xml/objects/object_fwall.xml @@ -1,6 +1,24 @@  - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_icefloe.xml b/assets/xml/objects/object_icefloe.xml index cb9b321a3..2427052af 100644 --- a/assets/xml/objects/object_icefloe.xml +++ b/assets/xml/objects/object_icefloe.xml @@ -1,7 +1,7 @@  - - - + + + diff --git a/assets/xml/objects/object_ik.xml b/assets/xml/objects/object_ik.xml index 0b68303da..7042bf10b 100644 --- a/assets/xml/objects/object_ik.xml +++ b/assets/xml/objects/object_ik.xml @@ -1,106 +1,105 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ikana_obj.xml b/assets/xml/objects/object_ikana_obj.xml index 6040495ab..e0490a349 100644 --- a/assets/xml/objects/object_ikana_obj.xml +++ b/assets/xml/objects/object_ikana_obj.xml @@ -17,15 +17,15 @@ - + - - + + - + - - + + @@ -39,7 +39,7 @@ - + @@ -51,11 +51,11 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_iknv_obj.xml b/assets/xml/objects/object_iknv_obj.xml index 1e10d813c..58926c0e3 100644 --- a/assets/xml/objects/object_iknv_obj.xml +++ b/assets/xml/objects/object_iknv_obj.xml @@ -33,6 +33,7 @@ + @@ -58,7 +59,7 @@ - + diff --git a/assets/xml/objects/object_kamejima.xml b/assets/xml/objects/object_kamejima.xml index 9b45ad478..425e4643d 100644 --- a/assets/xml/objects/object_kamejima.xml +++ b/assets/xml/objects/object_kamejima.xml @@ -1,5 +1,8 @@  + + + diff --git a/assets/xml/objects/object_keikoku_demo.xml b/assets/xml/objects/object_keikoku_demo.xml index 994b682f3..3a0a20b65 100644 --- a/assets/xml/objects/object_keikoku_demo.xml +++ b/assets/xml/objects/object_keikoku_demo.xml @@ -1,21 +1,65 @@  + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_lastday.xml b/assets/xml/objects/object_lastday.xml index 9988ec1f8..e447edfbf 100644 --- a/assets/xml/objects/object_lastday.xml +++ b/assets/xml/objects/object_lastday.xml @@ -1,5 +1,8 @@  + + + diff --git a/assets/xml/objects/object_link_goron.xml b/assets/xml/objects/object_link_goron.xml index 2fe3906fb..1aa57c010 100644 --- a/assets/xml/objects/object_link_goron.xml +++ b/assets/xml/objects/object_link_goron.xml @@ -35,7 +35,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -72,7 +72,7 @@ - + diff --git a/assets/xml/objects/object_link_zora.xml b/assets/xml/objects/object_link_zora.xml index d36aaa420..fe5c50ea6 100644 --- a/assets/xml/objects/object_link_zora.xml +++ b/assets/xml/objects/object_link_zora.xml @@ -56,7 +56,14 @@ - + + + + + + + + diff --git a/assets/xml/objects/object_rotlift.xml b/assets/xml/objects/object_rotlift.xml index 403f7d3dd..da5db27d7 100644 --- a/assets/xml/objects/object_rotlift.xml +++ b/assets/xml/objects/object_rotlift.xml @@ -1,16 +1,20 @@  + - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_sekihig.xml b/assets/xml/objects/object_sekihig.xml index dab91d71b..bb995bed4 100644 --- a/assets/xml/objects/object_sekihig.xml +++ b/assets/xml/objects/object_sekihig.xml @@ -1,16 +1,16 @@  - - - - - + + + + + - - - - - - + + + + + + diff --git a/assets/xml/objects/object_sekihil.xml b/assets/xml/objects/object_sekihil.xml index e3c7bcc42..fb9903875 100644 --- a/assets/xml/objects/object_sekihil.xml +++ b/assets/xml/objects/object_sekihil.xml @@ -1,16 +1,16 @@  - + - + - - - - - - - + + + + + + + diff --git a/assets/xml/objects/object_sekihin.xml b/assets/xml/objects/object_sekihin.xml index f2982169b..104f5f133 100644 --- a/assets/xml/objects/object_sekihin.xml +++ b/assets/xml/objects/object_sekihin.xml @@ -1,17 +1,17 @@  - - - - + + + + - + - - - - - - + + + + + + diff --git a/assets/xml/objects/object_sekihiz.xml b/assets/xml/objects/object_sekihiz.xml index 0f8ef7c43..9563d8b42 100644 --- a/assets/xml/objects/object_sekihiz.xml +++ b/assets/xml/objects/object_sekihiz.xml @@ -1,9 +1,9 @@  - - - - - + + + + + diff --git a/assets/xml/objects/object_uch.xml b/assets/xml/objects/object_uch.xml index a58af5654..e61be5042 100644 --- a/assets/xml/objects/object_uch.xml +++ b/assets/xml/objects/object_uch.xml @@ -1,46 +1,64 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zog.xml b/assets/xml/objects/object_zog.xml index 627bb676a..15265596d 100644 --- a/assets/xml/objects/object_zog.xml +++ b/assets/xml/objects/object_zog.xml @@ -9,17 +9,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Sth2.xml b/assets/xml/overlays/ovl_En_Sth2.xml new file mode 100644 index 000000000..23140ad71 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Sth2.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Jgame_Light.xml b/assets/xml/overlays/ovl_Obj_Jgame_Light.xml new file mode 100644 index 000000000..e6b740aca --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Jgame_Light.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Toudai.xml b/assets/xml/overlays/ovl_Obj_Toudai.xml new file mode 100644 index 000000000..989c47a72 --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Toudai.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/docs/BUILDING_DOCKER.md b/docs/BUILDING_DOCKER.md new file mode 100644 index 000000000..5fa7b4865 --- /dev/null +++ b/docs/BUILDING_DOCKER.md @@ -0,0 +1,47 @@ +# Building using Docker + +## Dependencies + +You will need [Docker](https://docs.docker.com/get-docker/) Follow the instructions for your operating system. + +## 1. Clone the Repository + +You will need to prepare a local version of the project with a copied base ROM (see steps [2](../README.md#2-clone-the-repository) and [4](../README.md#4-prepare-a-base-rom) of the Linux instructions). + +## 2. Create the Docker image + +From inside your local project, run the following command: + +```bash +docker build . -t mm +``` + +This will build a docker image with the name of `mm`, to verify the image was made you can run the command + +```bash +docker image ls +``` + +and look for `mm` under the "REPOSITORY" column. + +## 3. Start the container + +To start the container, you can mount your local filesystem into the Docker container and run an interactive bash session. + +```bash +docker run -it --rm --mount type=bind,source="$(pwd)",destination=/mm mm /bin/bash +``` + +- The `-it` flags Keep STDIN open even if not attached to the container and allocates a pseudo-tty terminal. +- The `--rm` flags causes Docker to automatically remove the container when it exits. +- The `--mount` flag allows you to mount volumes and host-directories in a container. By specifying the type to be a bind, we are saying there are files to be mounted from the host machine (the one that runs your docker daemon) onto the container. Source is specifying where we are mounting the files from in this case, we want the `mm` folder created earlier. The $(pwd) sub-command expands to the current working directory. The destination takes as its value the path where the file or directory is mounted in the container. This makes it so that the image should rarely change and will reduce the need to rebuild with any change to the codebase. + +## 4. Setup and Build the ROM + +Once inside the container, you will need to set the repository as a trusted repository with the following command: + +```bash +git config --global --add safe.directory /mm +``` + +After that continue with step [5. Make and Build the ROM](../README.md#5-make-and-build-the-rom) of the Linux instructions to setup and build the ROM, or run any other command you need. diff --git a/docs/BUILDING_MACOS.md b/docs/BUILDING_MACOS.md index 77f1d839e..8a5aa20a3 100644 --- a/docs/BUILDING_MACOS.md +++ b/docs/BUILDING_MACOS.md @@ -2,7 +2,6 @@ **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: @@ -23,59 +22,66 @@ 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. diff --git a/CONTRIBUTING.md b/docs/CONTRIBUTING.md similarity index 91% rename from CONTRIBUTING.md rename to docs/CONTRIBUTING.md index 0cc5b0375..493486e79 100644 --- a/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -1,7 +1,6 @@ # Contributing to the Majora's Mask Decompilation Project - -Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask* for the N64! +Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask* for the N64! 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. This document is meant to be a set of tips and guidelines for contributing to the project. @@ -9,19 +8,17 @@ For general information about the project, see [our readme](https://github.com/z 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. - ## Useful Links - [Installation guide](https://github.com/zeldaret/mm/blob/master/README.md#installation) - Instructions for getting this repository set up and built on your machine. -- [Style Guide](docs/STYLE.md) - Description of the project style that we ask contributors to adhere to. -- [Code Review Guidelines](docs/REVIEWING.md) - These are the guidelines that reviewers will be using when reviewing your code. Good to be familiar with these before submitting your code. +- [Style Guide](STYLE.md) - Description of the project style that we ask contributors to adhere to. +- [Code Review Guidelines](REVIEWING.md) - These are the guidelines that reviewers will be using when reviewing your code. Good to be familiar with these before submitting your code. - [Zelda 64 Reverse Engineering Website](https://zelda64.dev/mm) - Our homepage, with FAQ and progress graph :chart_with_upwards_trend:. -- [MM decomp tutorial](docs/tutorial/contents.md) Detailed tutorial for learning in general how decomp works and how to decompile a small, simple file. +- [MM decomp tutorial](tutorial/contents.md) Detailed tutorial for learning in general how decomp works and how to decompile a small, simple file. - [Introduction to OOT decomp](https://github.com/zeldaret/oot/blob/master/docs/tutorial/contents.md) - The tutorial the MM one was based on. For OOT, but largely applicable to MM as well. Covers slightly different topics, including how to get your data OK with `vbindiff`. - The `#resources` channel on the Discord contains many more links on specific details of decompiling IDO MIPS code. - ## Getting Started ### What should I know to take part? @@ -36,7 +33,6 @@ The [OoT Decompilation Project](https://github.com/zeldaret/oot) is farther alon This project only uses *publicly available code*. - **N.B.** 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. ### Environment Setup @@ -46,27 +42,27 @@ You should be able to build a matching ROM before you start making any changes. ### First Contribution -Usually, the best place to get started is to decompile an actor overlay. +Usually, the best place to get started is to decompile an actor overlay. An *actor* is any thing in the game that moves or performs actions or interactions. This includes things like Link, enemies, NPCs, doors, pots, etc. Actors are good for a first file because they are generally small, self-contained systems. We recommend that you [join the Discord](https://discord.zelda64.dev/) to say hello and get suggestions on where to start on the `#mm-decomp` channel. We track who is working on what on some Google Sheets available in the Discord. Once you've decided on or been recommended a good first file, mark it as Reserved. -The workflow is: -- Reserve a file, -- decompile it, -- submit a PR, +The workflow is: + +- Reserve a file, +- decompile it, +- submit a PR, - repeat while addressing review comments. The expectation is that one reservation goes to one file which ends up in a one file PR, although naturally some files are more sensibly worked on as a group, for example two actors that work together. This also does not apply to large asset files like `gameplay_keep`: you can just reserve the parts that are used in your files. If possible, we expect reserved files to be completed. If you find you cannot complete a file, because it is intractable for one reason or another, or real-life circumstances get in the way, please talk to one of the leads in Discord; we may find someone else interested in helping you finish, or who is happy to take over the file from you completely. If you unreserve a file on which you have useful progress, please leave a link to your branch in the Notes column on the Google Sheet that the next person who works on the file can use. - ## Style Guide & Conventions -See the [Style Guide](docs/STYLE.md). +See the [Style Guide](STYLE.md). ## `NON_MATCHING` and `NON_EQUIVALENT` @@ -84,7 +80,8 @@ void CollisionCheck_SpawnWaterDroplets(PlayState* play, Vec3f* v); ``` Before PRing with a `NON_MATCHING`, you can try -- using the [decomp-permuter](tools/decomp-permuter) to find a closer match, + +- using the [decomp-permuter](https://github.com/simonlindholm/decomp-permuter) to find a closer match, - Asking in `#mm-decomp-help` in Discord; the easiest way to allow other people to play around with the function you are stuck on is to make a scratch on [decomp.me](http://decomp.me). `NON_EQUIVALENT` can be used with the same syntax as `NON_MATCHING`, but it is used to mark sections of code which do not match *and* do not have the same behavior as the original code. @@ -104,8 +101,7 @@ Documenting is more than just adding comments. Documenting also includes: Overlays are not required to be documented at this time, but files from `code/` and `boot/` should be documented. When documentation on a file has been started it should be as complete as reasonable. -See the [Style Guide](docs/STYLE.md) for more details on documentation style. - +See the [Style Guide](STYLE.md) for more details on documentation style. ## Pull Requests (PRs) @@ -125,13 +121,15 @@ Feel free to reach out on the Discord if you have any questions about these step ### Pull Request Process After opening a PR, the Jenkins agent will test formatting, the contents of the spec, build the rom and check for warnings. -If there is an error, double-check that you can successfully +If there is an error, double-check that you can successfully + ```bash make disasm ./extract_assets.py -f make clean make ``` + locally. If the build is `OK`, the next thing to check is that all added/modified files were `git add`-ed to your commit. The final check before posting on Discord for help is that there are no new warnings added to the code causing Jenkins to fail. You can check this by running: `tools/warnings_count/check_new_warnings.sh`. Each PR needs a review from two reviewers, at least one a project lead, and final approval from Kenix. diff --git a/docs/REVIEWING.md b/docs/REVIEWING.md index 11545fb27..8b70f2711 100644 --- a/docs/REVIEWING.md +++ b/docs/REVIEWING.md @@ -1,6 +1,6 @@ # Reviewing Pull Requests to the Majora's Mask Decompilation Project -Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask*! +Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask*! We encourage all contributors to participate in code review: this is your codebase too! Every review submitted helps us keep code quality high and code merged in more quickly. @@ -11,13 +11,11 @@ Most discussions happen on our [Discord Server](https://discord.zelda64.dev) whe Other links are available in the [CONTRIBUTING.md](CONTRIBUTING.md) - ## Getting Started ### What should I know to take part in the review process? -You should first famiiarise yourself with our [Contributing guide](CONTRIBUTING.md) and [Style guide](docs/STYLE.md). It is also recommended that you have already successfully submitted a merged pull request to understand how the process works before submitting a review. - +You should first famiiarise yourself with our [Contributing guide](CONTRIBUTING.md) and [Style guide](STYLE.md). It is also recommended that you have already successfully submitted a merged pull request to understand how the process works before submitting a review. ## Pull Requests (PRs) @@ -29,6 +27,7 @@ You should first famiiarise yourself with our [Contributing guide](CONTRIBUTING. - If someone does not address your comments and expresses that a different way is better than yours, look for feedback from other contributors (we encourage discussing this sort of thing in Discord, since long GitHub conversations get hard to read). The project leads will have final say in these situations. All decisions are generally guided by a consensus of contributors. ### Reviewer Checklist + - [ ] Jenkins build is successful. - [ ] `make` builds a matching ROM. - [ ] `format.sh` was run. diff --git a/docs/STYLE.md b/docs/STYLE.md index d66c22c81..4ac0525db 100644 --- a/docs/STYLE.md +++ b/docs/STYLE.md @@ -44,26 +44,31 @@ A lot of formatting is done by clang-format, such as There are various other conventions that it does not catch, though: - Blank line between declarations and code: + ```c s32 var; func(); ``` + - combine declarations and definitions if possible: + ```c s32 var = 0; func(); ``` + instead of + ```c s32 var; var = 0; func(); ``` -- blank lines between switch cases if they're long (use your judgement). +- blank lines between switch cases if they're long (use your judgement). ## Numbers @@ -98,6 +103,7 @@ Floats usually need an `f` on the end to match, or IDO will use doubles. Our flo - When conditions are `&&`d or `||`d together, use brackets around each that includes an arithmetic comparison or bitwise operator (i.e. not `!var` or `func()`, but ones with `==` or `&` etc.) - Flag checks or functions that return booleans do not need the `== 0`/`!= 0`. - Prefer `if-else` over `if { return; }`, i.e. + ```c if (cond) { foo(); @@ -105,7 +111,9 @@ Floats usually need an `f` on the end to match, or IDO will use doubles. Our flo bar(); } ``` + over + ```c if (cond) { foo(); @@ -113,6 +121,7 @@ Floats usually need an `f` on the end to match, or IDO will use doubles. Our flo } bar(); ``` + **Exception**: After `Actor_MarkForDeath` or sometimes setting the action function, if it makes sense to do so (this expresses the finality a bit better). ## Macros and enums @@ -120,8 +129,8 @@ Floats usually need an `f` on the end to match, or IDO will use doubles. Our flo Become familiar with the various defines and enums we have available. There are too many to list all of them here, but the following are common: - Those in `macros.h` - - `ABS`, `ABS_ALT`, - - `CLAMP` and friends, + - `ABS`, `ABS_ALT`, + - `CLAMP` and friends, - `BINANG_*`, which are used for angles, especially when there's a lot of `s16` casts around - `MTXMODE` for many of the `sys_matrix` functions - CollisionCheck flags: `AT_ON` and so on. Pick the appropriate one for the collider type. @@ -149,6 +158,7 @@ void EnFirefly_Update(Actor* thisx, PlayState* play2) { ``` In other places the cast is actually not explictly needed, but a stack `pad` variable is still needed. For this there should just be a stack variable called `pad` of type `s32` before the actor `THIS` cast. For example in `z_bg_goron_oyu` + ```c void BgGoronOyu_Init(Actor* thisx, PlayState* play) { s32 pad; @@ -158,10 +168,10 @@ void BgGoronOyu_Init(Actor* thisx, PlayState* play) { In general, pads should be `s32`, or `s16`/`s8` if required. - ## Documentation and Comments Documentation includes: + - Naming functions - Naming struct variables - Naming data @@ -175,13 +185,16 @@ Documentation includes: If you are not sure what something does, it is better to leave it unnamed than name it wrongly. It is fine to make a note of something you are not sure about when PRing, it means the reviewers will pay special attention to it. We use comments for: + - Top of file: a short description of the system. For actors there is already a brief description of our current understanding, but feel free to add to it. -- For function descriptions, we use multiline comments, +- For function descriptions, we use multiline comments, + ```c /** * Describe what the function does */ ``` + These are *optional*: if you think the code is clear enough, you do not need to put a comment. You can use Doxygen formatting if you think it adds something, but it is also not required. - If something in a function is strange, or unintuitive, do leave a comment explaining what's going on. We use `//` for this. - We also use `//` for temporary comments above a function. Feel free to use `TODO:` in these if appropriate. @@ -199,7 +212,7 @@ All functions should go in the main C file in the same order as the assembly (th - If in doubt, leave all the data at the top of the file. Reviewers will decide for you. - Data must go in the same order as in the assembly files, but is only constrained by other data, not functions or rodata. -- Some data has to be inline static to match. Generally it's better to not use `static` on data outside funtions until the file is matching, since `static` data is left out of the mapfile and this makes debugging harder. +- Some data has to be inline static to match. Generally it's better to not use `static` on data outside funtions until the file is matching, since `static` data is left out of the mapfile and this makes debugging harder. - *This is even more true of bss, where we have trouble with IDO unpredictably reordering it in certain files.* - For small arrays or simple data that is used in only one function, we usually inline it, if it fits in the ordering. - Generally data that is only used by the draw functions is put down near them: this is one of the few consistencies in ordering of actors' functions. @@ -207,15 +220,19 @@ All functions should go in the main C file in the same order as the assembly (th ### Enums and defines - Actors that bitpack params should have macros made for each access or write that is made. `z_en_dg.h` has an undocumented example, + ```c #define ENDG_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) #define ENDG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) ``` + while `z_en_firefly.h` has a documented one, + ```c #define KEESE_INVISIBLE (1 << 0xF) #define KEESE_GET_MAIN_TYPE(thisx) ((thisx)->params & 0x7FFF) ``` + - In a similar manner, actors that use `home.rot.(x|y|z)` like params should also macros made for accesses and writes. (See, e.g. `z_obj_bean.h`.) - Stuff that only the actor itself will use goes in the C file unless needed in the header. - Anything actor-specific that might be used by another file goes in the header, in particular params access macros. diff --git a/docs/tools.md b/docs/tools.md index 6fec9caf8..149fba9ae 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -286,6 +286,6 @@ We use a [Google Sheet](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0 - **Function size statistics**: Intended as a crude estimate of how hard a file will be. Beginners should look for small largest function size and total size; the columns give a rough estimate of the distribution of function sizes without getting unnecessarily statistically descriptive. As you become more experienced, you should work on larger files to leave the smaller ones for other beginners. - **Description**: What the file is. It's helpful if you can fill this in if you know! They should be synchronised with the short top-of-file descriptions. - **Status**: (Free)/Reserved/PR/Merged. To be kept up-to-date by the reserver. -- **Reserved**: To reserve a file, put your Discord name in the "Reserved" column. It is common courtesy to not work on a file that is being worked on by another contributor, so ensure the "Reserved" column is blank before working on a file. If it is not, you can ask the reserver(s) if they want to release it or collaborate on it, but don't expect them to agree. More information on what is expected when you reserve a file is available in the [CONTRIBUTING.md](../CONTRIBUTING.md). +- **Reserved**: To reserve a file, put your Discord name in the "Reserved" column. It is common courtesy to not work on a file that is being worked on by another contributor, so ensure the "Reserved" column is blank before working on a file. If it is not, you can ask the reserver(s) if they want to release it or collaborate on it, but don't expect them to agree. More information on what is expected when you reserve a file is available in the [CONTRIBUTING.md](CONTRIBUTING.md). - **Interested**: If you would like to work on a file, but don't want to reserve it, or would be interested in collaboration, etc. You should talk to any Interested people if you want to work on the file. - **Notes**: Any other useful information: partial progress by someone unable to finish the file, other files it works with, etc. diff --git a/docs/tutorial/advanced_control_flow.md b/docs/tutorial/advanced_control_flow.md index ee6c13aa7..3ad2a9d4f 100644 --- a/docs/tutorial/advanced_control_flow.md +++ b/docs/tutorial/advanced_control_flow.md @@ -199,7 +199,7 @@ void func_809527F8(EnMs* this, PlayState* play) { } func_8019F208(); Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } } @@ -220,8 +220,7 @@ which is long, messy, and contains some rather nasty-looking control flow, inclu } ``` -If you read the OoT tutorial, you'll know these nested negated ifs all using the same variable are a good indicator that there's a switch. The problem is working out how to write it. - +If you read the OoT tutorial, you'll know these nested negated ifs all using the same variable are a good indicator that there's a switch. The problem is working out how to write it. ## Goto-only mode @@ -291,7 +290,7 @@ block_13: block_15: func_8019F208(); Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; return; block_16: @@ -303,6 +302,7 @@ block_17: ``` which in many ways looks worse: you can see why the use of gotos in code is strongly discouraged. However, if you throw this in `diff.py`, you'll find it's rather closer than you'd have thought. Goto-only mode has the advantages that + - code is always in the right order: mips2c has not had to reorder anything to get the ifs to work out - it is often possible to get quite close with gotos, then start removing them, checking the matching status at each point. This is usually easier than trying to puzzle out the way it's trying to jump out of an `if ( || )` or similar. - if you're trying to keep track of where you are in the code, the gotos mean that it is closer to the assembly in the first place. @@ -391,7 +391,7 @@ block_11: func_8019F208(); Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; return; block_16: @@ -404,7 +404,6 @@ block_17: We can't apply this rule any more, so we need to move on to the next: `block_17` just contains a `return`. So we can replace it by `return` everywhere it appears. - ```C void func_809527F8(EnMs* this, PlayState* play) { u8 temp_v0; @@ -461,7 +460,7 @@ block_11: func_8019F208(); Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; return; block_16: @@ -486,6 +485,7 @@ Now let's start thinking about switches. A good indicator of a switch in goto-on ``` because + - there are multiple ifs that are simple numeric comparisons of the same argument - the goto blocks are in the same order as the ifs - there is one last goto at the end that triggers if none of the ifs does: this sounds an awful lot like a `default`! @@ -510,7 +510,7 @@ So let us rewrite the entire second half as a switch: func_8019F208(); Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; return; break; @@ -523,7 +523,8 @@ So let us rewrite the entire second half as a switch: } ``` -There's a couple of other obvious things here: +There's a couple of other obvious things here: + - the last `return` in `case 0` is unnecessary since there is no other code after the switch, so breaking is equivalent to the return` - a common pattern everywhere, a sequence of ifs with returns as the last thing inside is the same as an if-else chain, so we can rewrite these as @@ -541,7 +542,7 @@ There's a couple of other obvious things here: } else { func_8019F208(); Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } break; @@ -606,7 +607,7 @@ block_7: } else { func_8019F208(); Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } break; @@ -622,6 +623,7 @@ block_7: ``` Now, the top of the function also looks like a switch: + ```C temp_v0 = Message_GetState(&play->msgCtx); if (temp_v0 == 4) { @@ -670,7 +672,7 @@ void func_809527F8(EnMs* this, PlayState* play) { } else { func_8019F208(); Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } break; @@ -722,7 +724,7 @@ void func_809527F8(EnMs* this, PlayState* play) { } else { func_8019F208(); Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); - func_801159EC(-0xA); + Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } break; @@ -742,6 +744,6 @@ void func_809527F8(EnMs* this, PlayState* play) { } ``` -And this matches! +And this matches! We will not document this now, although even with so few function named it seems pretty clear that it's to do with buying beans (and indeed, Magic Beans cost 10 Rupees and have Get Item ID `0x35`) You might like to try to match this function without using goto-only mode, to compare. It is also an interesting exercise to see what each elimination does to the diff: sometimes it will stray surprisingly far for a small change. diff --git a/docs/tutorial/beginning_decomp.md b/docs/tutorial/beginning_decomp.md index 3a4337deb..eadfa9adc 100644 --- a/docs/tutorial/beginning_decomp.md +++ b/docs/tutorial/beginning_decomp.md @@ -6,7 +6,6 @@ Open the C file and the H file with your actor's name from the appropriate direc Each actor has associated to it a data file and one assembly file per function. During the process, we will transfer the contents of all or most of these into the main C file. VSCode's search feature usually makes it quite easy to find the appropriate files without troubling the directory tree. - ## Anatomy of the C file The actor file starts off looking like: @@ -102,7 +101,6 @@ It is currently divided into six sections as follows: 6. List of functions. Each `#pragma GLOBAL_ASM` is letting the compiler use the corresponding assembly file while we do not have decompiled C code for that function. The majority of the decompilation work is converting these functions into C that it looks like a human wrote. - ## Header file The header file looks like this at the moment: @@ -133,10 +131,10 @@ The struct currently contains a variable that is the `Actor` struct, which all a The header file is also used to declare structs and other information about the actor that is needed by other files (e.g. by other actors): one can simply `#include` the header rather than `extern`ing it. - ## Order of decompilation The general rule for order of decompilation is + - Start with `Init`, because it usually contains the most information about the structure of the actor. You can also do `Destroy`, which is generally simpler than `Init`. - Next, decompile any other functions from the actor you have found in `Init`. You generally start with the action functions, because they return nothing and all take the same arguments, @@ -158,20 +156,19 @@ The above is a rough ordering for the beginner. As you become more experienced, Associated to each actor is a `.data` file, containing data that the actor uses. This ranges from spawn positions, to animation information, to even assets that we have to extract from the ROM. Since the structure of the data is very inconsistent between actors, automatic importing has been very limited, so the vast majority must be done manually. -There are two ways of transfering the data into an actor: we can either -- import it all naively as words (`s32`s), which will still allow it to compile, and sort out the actual types later, or +There are two ways of transfering the data into an actor: we can either + +- import it all naively as words (`s32`s), which will still allow it to compile, and sort out the actual types later, or - we can extern each piece of data as we come across it, and come back to it later when we have a better idea of what it is. We will concentrate on the second here; the other is covered in [the document about data](data.md). Thankfully this means we essentially don't have to do anything to the data yet. Nevertheless, it is often quite helpful to copy over at least some of the data and leave it commented out for later replacement. *Data must go in the same order as in the data file, and data is "all or nothing": you cannot only import some of it*. - **WARNING** The way in which the data was extracted from the ROM means that there are sometimes "fake symbols" in the data, which have to be removed to avoid confusing the compiler. Thankfully it will turn out that this is not the case here. (Sometimes it is useful to import the data in the middle of doing functions: you just have to choose an appropriate moment.) Some actors also have a `.bss` file. This is just data that is initialised to 0, and can be imported immediately once you know what type it is, by declaring it without giving it a value. (bss is a significant problem for code files, but not *usually* for actors.) - ## Init The Init function sets up the various components of the actor when it is first loaded. It is hence usually very useful for finding out what is in the actor struct, and so we usually start with it. (Some people like starting with Destroy, which is usually shorter and simpler, but gives some basic information about the actor, but Init is probably best for beginners.) @@ -183,15 +180,19 @@ The first stage of decompilation is done by a program called mips_to_c, often re The web version of mips2c can be found [here](https://simonsoftware.se/other/mips_to_c.py). This was [covered in the OoT tutorial](https://github.com/zeldaret/oot/blob/master/docs/tutorial/beginning_decomp.md). We shall instead use the repository. Clone [the mips_to_c repository](https://github.com/matt-kempster/mips_to_c) into a separate directory (we will assume on the same level as the `mm/` directory). Since it's Python, we don't have to do any compilation or anything in the mips_to_c directory. Since the actor depends on the rest of the codebase, we can't expect to get much intelligible out of mips2c without giving it some context. We make this using a Python script in the `tools` directory called `m2ctx.py`, so run + ``` $ ./tools/m2ctx.py ``` + from the main directory of the repository. In this case, the C file is `src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c`. This generates a file called `ctx.c` in the main directory of the repository. To get mips_to_c to decompile a function, the bare minimum is to run + ``` $ ../mips_to_c/mips_to_c.py ``` + (from the root directory of `mm`). We can tell mips2c to use the context file we just generated by adding `--context ctx.c`. If we have data, mips2c may be able to assist with that as well. In this case, we want the assembly file for `EnRecepgirl_Init`. You can copy the path to the file in VSCode or similar, or just tab-complete it once you know the directory structure well enough: it turns out to be `asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Init.s`. @@ -199,6 +200,7 @@ In this case, we want the assembly file for `EnRecepgirl_Init`. You can copy the **N.B.** You want the file in `nonmatchings`! the files in the other directories in `asm/` are the *unsplit* asm, which can be used, but is less convenient (you would need to include the rodata, for example, and it will do the whole file at once. This is sometimes useful, but we'll go one function at a time today to keep things simple). We shall also include the data file, which is located at `data/overlays/ovl_En_Recepgirl/ovl_En_Recepgirl.data.s`. Hence the whole command will be + ``` $ ../mips_to_c/mips_to_c.py asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Init.s data/ovl_En_Recepgirl/ovl_En_Recepgirl.data.s --context ctx.c ? func_80C10148(EnRecepgirl *); // extern @@ -233,6 +235,7 @@ void EnRecepgirl_Init(EnRecepgirl* this, PlayState* play) { func_80C10148(this); } ``` + Comment out the `GLOBAL_ASM` line for `Init`, and paste all of this into the file just underneath it: ```C @@ -271,6 +274,7 @@ void EnRecepgirl_Init(Actor* thisx, PlayState* play) { } [...] ``` + Typically for all but the simplest functions, there is a lot that needs fixing before we are anywhere near seeing how close we are to the original code. You will notice that mips2c creates a lot of temporary variables. Usually most of these will turn out to not be real, and we need to remove the right ones to get the code to match. @@ -364,7 +368,6 @@ extern s32 D_80C106C8; **N.B.** As is covered in more detail in [the document about data](data.md), the data *must* be declared in the same order in C as it was in the data assembly file: notice that the order in this example is `En_Recepgirl_InitVars`, `D_80C106B0`, `D_80C106C0`, `D_80C106C8`, the same as in `data/ovl_En_Recepgirl/ovl_En_Recepgirl.data.s`. - In the next sections, we shall sort out the various initialisation functions that occur in Init. This actor contains several of the most common ones, but it does not have, for example, a collider. The process is similar to what we discuss below, or you can check the OoT tutorial. ### Init chains - + Almost always, one of the first items in `Init` is a function that looks like ```C @@ -381,10 +384,10 @@ Actor_ProcessInitChain(&this->actor, D_80C106C0); which initialises common properties of actor using an InitChain, which is usually somewhere near the top of the data, in this case in the variable `D_80C106C0`. This is already included in the `#if`'d out data at the top if the file, so we don't have to do anything for now. We can correct the mips2c output for the extern, though: I actually did this when moving the rest of the data in the previous section. - ### SkelAnime This is the combined system that handles actors' skeletons and their animations. It is the other significant part of most actor structs. We see its initialisation in this part of the code: + ```C Actor_ProcessInitChain(&this->actor, D_80C106C0); ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f); @@ -394,12 +397,15 @@ This is the combined system that handles actors' skeletons and their animations. An actor with SkelAnime has three structs in the Actor struct that handle it: one called SkelAnime, and two arrays of `Vec3s`, called `jointTable` and `morphTable`. Usually, although not always, they are next to one another. -There are two different sorts of SkelAnime, although for decompilation purposes there is not much difference between them. Looking at the prototype of `SkelAnime_InitFlex` from `functions.h` (or even the definition in `z_skelanime.c`), +There are two different sorts of SkelAnime, although for decompilation purposes there is not much difference between them. Looking at the prototype of `SkelAnime_InitFlex` from `functions.h` (or even the definition in `z_skelanime.c`), + ```C void SkelAnime_InitFlex(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); ``` + we can read off the types of the various arguments: + - The `SkelAnime` struct is at `this + 0x144` - The `jointTable` is at `this + 0x188` - The `morphTable` is at `this + 0x218` @@ -407,6 +413,7 @@ we can read off the types of the various arguments: - Because of how SkelAnime works, this means that the `jointTable` and `morphTable` both have `24` elements Looking in `z64animation.h`, we find that `SkelAnime` has size `0x44`, and looking in `z64math.h`, that `Vec3s` has size `0x6`. Since ` 0x144 + 0x44 = 0x188 `, `jointTable` is immediately after the `SkelAnime`, and since `0x188 + 0x6 * 0x18 = 0x218`, `morphTable` is immediately after the `jointTable`. Finally, `0x218 + 0x6 * 0x18 = 0x2A8`, and we have filled all the space between the `actor` and `actionFunc`. Therefore the struct now looks like + ```C typedef struct EnRecepgirl { /* 0x0000 */ Actor actor; @@ -428,36 +435,46 @@ extern AnimationHeader D_06009890; extern UNK_TYPE D_0600A280; extern FlexSkeletonHeader D_06011B60; ``` + As with the data, these externed symbols should be kept in increasing address order. They are both passed to the function as pointers, so need `&` to pass the address instead of the actual data. Hence we end up with + ```C SkelAnime_InitFlex(play, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24); ``` + note that `this->jointTable` and `this->morphTable` are arrays, so are already effectively pointers and don't need a `&`. ### More struct variables: a brief detour into reading some assembly This function also gives us information about other things in the struct. The only other reference to `this` (rather than `this->actor` or similar) is in + ```C this->unk_2AC = 2; ``` + This doesn't tell us much except that at `this + 0x2AC` is a number of some kind. What sort of number? For that we will have to look in the assembly code. This will probably look quite intimidating the first time, but it's usually not too bad if you use functions as signposts: IDO will never change the order of function calls, and tends to keep code between functions in roughly the same place, so you can usually guess where you are. In this case, we are looking for `this + 0x2AC`. `0x2AC` is not a very common number, so hopefully the only mention of it is in referring to this struct variable. Indeed, if we search the file, we find that the only instruction mentioning `0x2AC` is here: + ```mips /* 0000B0 80C10080 24090002 */ addiu $t1, $zero, 2 /* 0000B4 80C10084 A24902AC */ sb $t1, 0x2ac($s2) ``` + `addiu` ("add unsigned immediate") adds the last two things and puts the result in the register in the first position. So this says `$t1 = 0 + 2`. The next instruction, `sb` ("store byte") puts the value in the register in the first position in the memory location in the second, which in this case says `$s2 + 0x2ac = $t1`. We can go and find out what is in `$s2` is: it is set *all* the way at the top of the function, in this line: + ```mips /* 000008 80C0FFD8 00809025 */ move $s2, $a0 ``` + This simply copies the contents of the second register into the first one. In this case, it is copying the contents of the function's first argument into `$s2` (because it wants to use it later, and the `$a` registers are assumed to be cleared after a function call). In this case, the first argument is a pointer to `this` (well, `thisx`, but the struct starts with an `Actor`, so it's the same address). So line `B4` of the asm really is saving `2` into the memory location `this + 0x2AC`. Anyway, this tells us that the variable is a byte of some kind, so `s8` or `u8`: if it was an `s16/u16` it would have said `sh`, and if it was an `s32/u32` it would have said `sw`. Unfortunately this is all we can determine from this function: MIPS does not have separate instructions for saving signed and unsigned bytes. At this point you have two options: guess based on statistics/heuristics, or go and look in the other functions in the actor to find out more information. The useful statistic here is that `u8` is far more common than `s8`, but let's look in the other functions, since we're pretty confident after finding `0x2ac` so easily in `Init`. So, let us grep the actor's assembly folder: + ``` $ grep -r '0x2ac' asm/non_matchings/overlays/ovl_En_Recepgirl/ asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Draw.s:/* 00065C 80C1062C 921902AC */ lbu $t9, 0x2ac($s0) @@ -468,7 +485,9 @@ asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C100DC.s:/* 00015C 80C1012C 9 asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C100DC.s:/* 000164 80C10134 A09902AC */ sb $t9, 0x2ac($a0) asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Init.s:/* 0000B4 80C10084 A24902AC */ sb $t1, 0x2ac($s2) ``` + in which we clearly see `lbu` ("load byte unsigned"), and hence this variable really is a `u8`. Hence we can add this to the actor struct too: + ```C typedef struct EnRecepgirl { /* 0x0000 */ Actor actor; @@ -484,6 +503,7 @@ typedef struct EnRecepgirl { You might think that was a lot of work for one variable, but it's pretty quick when you know what to do. Obviously this would be more difficult with a more common number, but it's often still worth trying. Removing some of the declarations for data that we have accounted for, the function now looks like this: + ```C ? func_80C10148(EnRecepgirl *); // extern @@ -525,6 +545,7 @@ mips2c likes casting a lot: this is useful for getting types, less so when the t ### Functions called One minor problem is what `func_80C10148` is: C needs a prototype to compile it properly. mips2c has offered us `? func_80C10148(EnRecepgirl *); // extern`, but this is obviously incomplete: there's no `?` type in C! We shall guess for now that this function returns `void`, for two reasons: + 1. It's not used as a condition in a conditional or anything 2. It's not used to assign a value @@ -532,6 +553,7 @@ To this experience will add a third reason: 3. This is probably a setup function for an actionFunc, which are usually either `void (*)(ActorType*)` or `void (*)(ActorType*, PlayState*)`. The upshot of all this is to remove mips2c's `? func_80C10148(EnRecepgirl *); // extern`, and add a `void func_80C10148(EnRecepgirl* this);` underneath the declarations for the main four functions: + ```C void EnRecepgirl_Init(Actor* thisx, PlayState* play); void EnRecepgirl_Destroy(Actor* thisx, PlayState* play); @@ -543,12 +565,12 @@ void func_80C10148(EnRecepgirl* this); (we usually leave a blank line after the main four, and put all further declarations in address order). - ### Loops Loops are often some of the hardest things to decompile, because there are many ways to write a loop, only some of which will generate the same assembly. mips2c has had a go at the one in this function, but it usually struggles with loops: don't expect it to get a loop correct, well, at all. The code in question is + ```C void **temp_s0; void **phi_s0; @@ -567,46 +589,55 @@ The code in question is ``` `D_80C106B0` is the array that mips2c has declared above the function, a set of 8-digit hex numbers starting `0x06`. These are likely to be *segmented pointers*, but this is not a very useful piece of information yet. `D_80C106C0` is the InitChain, though, and it seems pretty unlikely that it would be seriously involved in any sort of loop. Indeed, if you tried to compile this now, you would get an error: + ``` cfe: Error: src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c, line 61: Unacceptable operand of == or != } while (temp_s0 != D_80C106C0); -------------------------^ ``` + so this can't possibly be right. So what on earth is this loop doing? Probably the best thing to do is manually unroll it and see what it's doing each time. -0. `phi_s0 = D_80C106B0`, aka `&D_80C106B0[0]`, to `temp_s0 = D_80C106B0 + 4`, i.e. `&D_80C106B0[1]`. But then `temp_s0->unk-4` is 4 backwards from `&D_80C106B0[1]`, which is back at `&D_80C106B0[0]`; the `->` means to look at what is at this address, so `temp_s0->unk-4` is `D_80C106B0[0]`. Equally, `*phi_s0` is the thing at `&D_80C106B0[0]`, i.e. `D_80C106B0[0]`. So the actual thing the first pass does is +1. `phi_s0 = D_80C106B0`, aka `&D_80C106B0[0]`, to `temp_s0 = D_80C106B0 + 4`, i.e. `&D_80C106B0[1]`. But then `temp_s0->unk-4` is 4 backwards from `&D_80C106B0[1]`, which is back at `&D_80C106B0[0]`; the `->` means to look at what is at this address, so `temp_s0->unk-4` is `D_80C106B0[0]`. Equally, `*phi_s0` is the thing at `&D_80C106B0[0]`, i.e. `D_80C106B0[0]`. So the actual thing the first pass does is + ```C D_80C106B0[0] = Lib_SegmentedToVirtual(D_80C106B0[0]); ``` + it then proceeds to set `phi_s0 = &D_80C106B0[1]` for the next iteration. -1. We go through the same reasoning and find the inside of the loop is +2. We go through the same reasoning and find the inside of the loop is + ```C temp_s0 = &D_80C106B0[2]; D_80C106B0[1] = Lib_SegmentedToVirtual(D_80C106B0[1]); phi_s0 = &D_80C106B0[2]; ``` -2. +3. + ```C temp_s0 = &D_80C106B0[3]; D_80C106B0[2] = Lib_SegmentedToVirtual(D_80C106B0[2]); phi_s0 = &D_80C106B0[3]; ``` -3. +4. + ```C temp_s0 = &D_80C106B0[4]; D_80C106B0[3] = Lib_SegmentedToVirtual(D_80C106B0[3]); phi_s0 = &D_80C106B0[4]; ``` + But now, `&D_80C106B0[4] = D_80C106B0 + 4 * 4 = D_80C106B0 + 0x10`, and `0x10` after this array's starting address is `D_80C106C0`, i.e. the InitChhain. Hence at this point the looping ends. So what this loop actually does is run `Lib_SegmentedToVirtual` on each element of the array `D_80C106B0`. At this point, I confess that I guessed what this loop does, and rewrote it how I would have written it, namely how one usually iterates over an array: + ```C s32 i; [...] @@ -650,6 +681,7 @@ void EnRecepgirl_Init(Actor* thisx, PlayState* play) { func_80C10148(this); } ``` + as our first guess. This doesn't look unreasonable... the question is, does it match? ## Diff @@ -659,9 +691,11 @@ Once preliminary cleanup and struct filling is done, most time spent matching fu In order to use `diff.py` with the symbol names, we need a copy of the code to compare against. In MM this is done as part of `make init`, and you can regenerate the `expected` directory (which is simply a known-good copy of `build` directory) by running `make diff-init`, which will check for an OK ROM and copy the build directory over. (Of course you need an OK ROM to do this; worst-case, you can checkout master and do a complete rebuild to get it). (You need to remake `expected` if you want to diff a function you have renamed: `diff.py` looks in the mapfiles for the function name, which won't work if the name has changed!) Now, we run diff on the function name: in the main directory, + ``` $ ./diff.py -mwo3 EnRecepgirl_Init ``` + (To see what these arguments do, run it with `./diff.py -h` or look in the scripts documentation.) ![FeelsOKMan completely white diff](images/EnRecepgirl_Init_diff_matching.png) diff --git a/docs/tutorial/contents.md b/docs/tutorial/contents.md index 0435becb4..bb703f5c7 100644 --- a/docs/tutorial/contents.md +++ b/docs/tutorial/contents.md @@ -1,12 +1,15 @@ # Getting started ## [Introduction to decomp](introduction.md) + - What we are doing - Structure of the code ## Pre-decompilation + +- [Introduction to git](intro_to_git.md) - Building the repo (follow the instructions in the [README.md](../../README.md)) -- Most of us use VSCode. Some useful information is [here](vscode.md). +- Most of us use VSCode. Some useful information is [here](vscode.md). - Choosing a first actor (You want something small that has simple interactions with the environment. A simple NPC can also work, and is what we will use as an illustration for most of the tutorial. There is a collection of actors we think are suitable for beginners on the spreadsheet or Trello) @@ -35,15 +38,17 @@ - [Documenting a decompiled file](documenting.md) ## [Object Decompilation](object_decomp.md) + - Object files - How we decompile objects ## After Decompilation -- See the [CONTRIBUTING.md](../../CONTRIBUTING.md) for most of the details for submitting PRs. Remember to format again after making adjustments from reviews! +- See the [CONTRIBUTING.md](../CONTRIBUTING.md) for most of the details for submitting PRs. Remember to format again after making adjustments from reviews! - More information about specific preparations is in [this document](merging.md). ## Appendices + - [Types, Structs and Padding](types_structs_padding.md) (a miscellany of useful stuff) - [Advanced control flow](advanced_control_flow.md) (an example of a more complex function which mips2c is not so good at) - [Using the diff script and the permuter](diff_and_permuter.md) (using the diff script and the permuter to match something) diff --git a/docs/tutorial/data.md b/docs/tutorial/data.md index 972451b07..0a19113e4 100644 --- a/docs/tutorial/data.md +++ b/docs/tutorial/data.md @@ -5,16 +5,20 @@ ## Table of Contents -- [Data first](#data-first) -- [Extern and data last](#extern-and-data-last) -- [Segmented pointers and object symbols](#segmented-pointers-and-object-symbols) -- [Fake symbols](#fake-symbols) -- [Inlining](#inlining) +- [Data](#data) + - [Table of Contents](#table-of-contents) + - [Data first](#data-first) + - [Extern and data last](#extern-and-data-last) + - [Segmented pointers and object symbols](#segmented-pointers-and-object-symbols) + - [Fake symbols](#fake-symbols) + - [Inlining](#inlining) +- [Finally: .bss](#finally-bss) Each actor's data is stored in a separate file. EnRecepgirl's data is in `data/overlays/ovl_En_Recepgirl/ovl_En_Recepgirl.data.s`, for example. At some point in the decompilation process we need to convert this raw data into recognisable information for the C to use. -There are two main ways to do this: either -1. import the data first and type it later, or +There are two main ways to do this: either + +1. import the data first and type it later, or 2. wait until the data appears in functions, extern it, then import it at the end Sometimes something between these two is appropriate: wait until the largest or strangest bits of data appear in functions, get some typing information out of that, and then import it, but for now, let's stick to both of these. @@ -25,16 +29,18 @@ Both approaches have their advantages and disadvantages. This way is good for smaller actors with little data. The OoT tutorial [covers this in plenty of detail](https://github.com/zeldaret/oot/blob/master/docs/tutorial/data.md), and the process in MM is essentially identical, so we won't go over it here. - ## Extern and data last Externing is explained in detail in the document about the [Init function](beginning_decomp.md). To summarize, every time a `D_address` appears that is in the data file, we put a + ```C extern UNK_TYPE D_address; ``` + at the top of the file, in the same order that the data appears in the data file. We can also give it a type if we know what the type actually is (e.g. for colliders, initchains, etc.), and convert the actual data and place it commented-out under the corresponding line. This means we don't have to do everything at once at the end. Once we have decompiled enough things to know what the data is, we can import it. The advantage of doing it this way is we should know what type everything is already: in our work on EnRecepgirl, for example, we ended up with the following data at the top of the file + ```C #if 0 const ActorInit En_Recepgirl_InitVars = { @@ -61,11 +67,13 @@ static s32 D_80C106C8 = 0; #endif ``` + and the main thing we need to understand is `D_80C106B0` *Before doing anything else, make sure `make` gives `OK`.* First, we tell the compiler to ignore the original data file. To do this, open the file called `spec` in the main directory of the repository, and search for the actor name. You will find a section that looks like + ``` beginseg name "ovl_En_Recepgirl" @@ -75,7 +83,9 @@ beginseg include "build/data/ovl_En_Recepgirl/ovl_En_Recepgirl.reloc.o" endseg ``` + We will eventually remove both of the bottom two lines and replace them with our own reloc file, but for now, just comment out the data line: + ``` beginseg name "ovl_En_Recepgirl" @@ -87,6 +97,7 @@ endseg ``` Next remove all the externs, and uncomment their corresponding commented data: + ```C const ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, @@ -111,20 +122,22 @@ static InitChainEntry D_80C106C0[] = { static s32 D_80C106C8 = 0; ``` -That should be everything, and we should now be able to `make` without the data file with no issues. - +That should be everything, and we should now be able to `make` without the data file with no issues. ## Segmented pointers and object symbols The game has a convenient system that allows it to sometimes effectively use offsets into a file instead of raw memory addresses to reference things. This is done by setting a file address to a *segment*. A segmented address is of the form `0x0XYYYYYY`, where `X` is the segment number. There are 16 available segments, and actors always set segment 6 to their object file, which is a file containing assets (skeleton, animations, textures, etc.) that they use. This is what all those `D_06...` are, and it is also what the entries in `D_80C106B0` are: they are currently raw numbers instead of symbols, though, and we would like to replace them. -There is an obvious problem here, which is that is that these symbols have to be defined *somewhere*, or the linker will complain (indeed, if we change the ones in the array to `D_...`, even if we extern them, we get +There is an obvious problem here, which is that is that these symbols have to be defined *somewhere*, or the linker will complain (indeed, if we change the ones in the array to `D_...`, even if we extern them, we get + ``` mips-linux-gnu-ld: build/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.o:(.data+0x20): undefined reference to `D_0600F8F0' -```` +``` + As we'd expect, of course: we didn't fulfil our promise that they were defined elsewhere.) For actors which have yet to be decompiled, this is mitigated by use of the file `undefined_syms.txt`, which feeds the linker the raw addresses to use as the symbol definitions. However, we want to replace these segmented addresses with proper object symbols whenever possible. In `En_Recepgirl_InitVars`, we can see that this actor uses the object `OBJECT_BG`: + ```c const ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, @@ -135,6 +148,7 @@ const ActorInit En_Recepgirl_InitVars = { ``` If we open up `assets/objects/object_bg.h`, we can see a bunch of different names corresponding to every asset in the object. You may notice that some of these names look a bit familiar; `object_bg_Tex_00F8F0` seems very close to the segmented address `(void*)0x600F8F0`. This is the proper object symbol for this segmented address, so we should `#include` this header in our actor and use these object symbols like so: + ```c static void* D_80C106B0[4] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` @@ -143,21 +157,19 @@ After replacing every segmented pointer with an object symbol, you should go ahe We will come back and name these later when we do the object. - ## Fake symbols Some symbols in the data have been decompiled wrongly, being incorrectly separated from the previous symbol due to how it was accessed by the actor's functions. However, most of these have now been fixed. Some more detail is given in [Types, structs and padding](types_structs_padding.md) If you are unsure, ask! - ## Inlining After the file is finished, it is possible to move some static data into functions. This requires that: + 1. The data is used in only one function 2. The ordering of the data can be maintained Additionally, we prefer to keep larger data (more than a line or two) out of functions anyway. - # Finally: .bss A .bss contains data that is uninitialised (actually initialised to `0`). For most actors all you need to do is declare it at the top of the actor file without giving it a value, once you find out what type it is. In `code`, it's much more of a problem. diff --git a/docs/tutorial/disassembly_quirks.md b/docs/tutorial/disassembly_quirks.md index dacfb78d8..34a01a6f3 100644 --- a/docs/tutorial/disassembly_quirks.md +++ b/docs/tutorial/disassembly_quirks.md @@ -10,12 +10,10 @@ Variables must be renamed in `tools/disasm/variables.txt`. It may also be necess You can avoid having to redisassemble every time by running `rename_global_asm.py`, which will rename the individual functions' assembly files in `asm/nonmatchings/` to the name of the function they contain. - ## Fake and incorrect symbols TODO - ## Resplitting a file The files `boot` and `code` are each divided up into dozens of separate files, that are all joined together into one text, data, rodata and bss section when building the ROM. As such, it has been necessary to guess where the file boundaries are, and not every file contains the correct functions or the correct data (rodata is mostly the exception since it is automatically split). @@ -31,6 +29,3 @@ To change a split for a file, find its entry in `tools/disasm/files.txt`, and ch to the file will extract it correctly as a separate file. It also is necessary to make a new C file and move the `GLOBAL_ASM` declaration into it. Unfortunately you essentially have to redisassemble after telling the disassembler to resplit a file. - - -## diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index ad990af4e..2e98e1efd 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -17,14 +17,12 @@ If you want to use `diff.py` after renaming anything, particularly functions, re Finally, *if you are not sure what something does, either ask or leave it unnamed: it will be less confusing later if things are unnamed than if they are wrongly named* - ## Renaming things Because MM needs to regenerate the assembly code, it is necessary to tell the disassembler the names of functions and variables, so it knows what symbols to assign in the code. This is done via `functions.txt` and `variables.txt`. The best way to rename functions and symbols is via global rename in an editor like VSCode. The next best way is to run `tools/rename_sym.sh`. You should be careful with this script: it has no error-checking! Renaming symbols in theory requires re-disassembly. This can often be avoided in the case of functions by running `tools/rename_global_asm.py`, which will rename any individual functions' assembly files with the wrong names, so that the `GLOBAL_ASM`s can spot them. Renaming variables *may* require redisassembly (and if fake symbols are removed, it *will*). - ## EnRecepgirl Currently, the file looks like this: @@ -262,12 +260,15 @@ void EnRecepgirl_Draw(Actor* thisx, PlayState* play) { (We can delete the `GLOBAL_ASM` lines now.) The worst part of documentation is finding somewhere to start. We have a decent place to start here, though, in that we already know the function (or rather, the use) of a couple of the functions, namely the LimbDraws. So we can rename `func_80C10558` to `EnRecepgirl_OverrideLimbDraw` and `func_80C10590` to `EnRecepgirl_TransformLimbDraw`. Remember to do a global rename so that the functions in the assembly are renamed, use `rename_global_asm`, + ``` $ ./tools/rename_global_asm.py asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10558.s --> asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_OverrideLimbDraw.s asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10590.s --> asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_UnkLimbDraw.s ``` + as well as the mentions in this chunk of `functions.txt`: + ``` 0x80C0FFD0:("EnRecepgirl_Init",), 0x80C100CC:("EnRecepgirl_Destroy",), @@ -283,6 +284,7 @@ as well as the mentions in this chunk of `functions.txt`: ``` That's probably as much as we can do on functions for now. Next let's think about some of the variables. We have essentially 3 sorts of variable here + - struct variables - data/bss - intrafunction/stack variables @@ -290,6 +292,7 @@ That's probably as much as we can do on functions for now. Next let's think abou and this is roughly the order of preference for naming them (although not necessarily the logical order to determine what they do). This actor is quite limited in the last category: only `sp30` is unnamed at the moment. Even though `Actor_TrackPlayer` is decomped, the purpose of the argument in which `sp30` is placed is not clear (and, indeed, is not named), so it's probably best to leave it unnamed for now. (With greater experience, you might analyse `Actor_TrackPlayer` to work out what this argument is for, but let's not worry about that for now.) As for the struct, there are two unnamed variables at the moment: + ```C typedef struct EnRecepgirl { /* 0x000 */ Actor actor; @@ -303,12 +306,15 @@ typedef struct EnRecepgirl { ``` Let's start with `unk_2AC`. This is set to `2` in `Init`, something interesting happens to it in `func_80C100DC`, but it is used in the `Draw`, here: + ```C gSPSegment(POLY_OPA_DISP++, 0x08, D_80C106B0[this->unk_2AC]); ``` + So it is used as an index into the array `D_80C106B0`, and the element with that index is placed on segment `8`. So we need to work out what this array is to name `unk_2AC`. As we discussed last time, `D_80C106B0` is an array of [segmented pointers](data.md#segmented-pointers). Since they are in segment `6`, they are in the actor's object file. Which object? The InitVars tell us: namely, + ```C const ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, @@ -316,8 +322,8 @@ const ActorInit En_Recepgirl_InitVars = { FLAGS, OBJECT_BG, ``` -the fourth element is the object (it is actually an enum, but the file itself has the same name as the object enum). So, we need to look at the object file. We are very lucky that a custom tool has been written for such a thing: Z64Utils. +the fourth element is the object (it is actually an enum, but the file itself has the same name as the object enum). So, we need to look at the object file. We are very lucky that a custom tool has been written for such a thing: Z64Utils. ## Z64Utils @@ -336,14 +342,17 @@ Go to "Analysis -> Find Dlists" and press OK (the defaults are usually fine). Th ![Z64Utils, with an analyzed object](images/z64utils_object_analyzed.png) We will talk about what all these types of data are next time, but for now, all we want to know is what + ```C static void* D_80C106B0[4] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` + actually are. We know they are set on segment 8, so we need to find where the skeleton uses them. We know from `object_bg_Skel_011B60` that this is at `0x06011B60`, so scroll down to it, right-click on it, and choose "Open in Skeleton Viewer". Pick an animation that we know it uses (sometimes Z64Utils misidentifies other things for animations), such as `object_bg_Anim_000968`, and you will get this error: ![Z64Utils, error when viewing skeleton](images/z64utils_skeleton_error.png) It needs something to be set to segment `8`. Well, that's good, we know that the code does that! Let's find out what. Z64Utils tells you the address, so we can look up the displaylist that wants it: the relevant block is + ```C [...] // Multi Command Macro Found (6 instructions) @@ -374,11 +383,13 @@ so we see that segment `8` is expecting a texture (we'll go into more detail abo But what sort of textures? This is an NPC, so what textures on the model would it want to change? The answer is of course the eyes: most NPCs have eye textures, with some sort of routine for changing them to appear to blink. We can set the different textures onto segment `8` and see which is which, but this is enough to know that `D_80C106B0` can be `sEyeTextures` (`s` for `static`: they essentially have to be static so that we can name them like this without the names clashing), and that `unk_2AC` is `eyeTexIndex` (these names are not completely standard, but it's best to be as consistent as possible). **N.B.** static data should not be renamed in the assembly or `variables.txt`, since assembly has no notion of file locality and there can be symbol clashes. Therefore it should only be renamed in its respective file, not globally. + ```C static TexturePtr sEyeTextures[] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` And now it's rather more obvious what + ```C void func_80C100DC(EnRecepgirl* this) { if (this->eyeTexIndex != 0) { @@ -391,11 +402,13 @@ void func_80C100DC(EnRecepgirl* this) { } } ``` + is doing: it's running a kind of blink routine. This is slightly nonstandard: usually there is a separate timer, but this one simply perturbs the index away from `0` every frame with a 2% chance. This sort of function is usually called `Blink` or `UpdateEyes`. Since it is explicitly called in `Update`, we'll call it `UpdateEyes`, but either is fine; we'll standardise later. We have two other pieces of data. There is a suggested name for the InitChain in the code already; just replace it and replace the first line in the definition. This leaves one piece of data unnamed, `D_80C106C8`. This is initially set to `0`, checked in `Init` to decide whether to run the loop, and then set to `1` after the loop is finished: + ```C if (D_80C106C8 == 0) { for (i = 0; i < 4; i++) { @@ -404,13 +417,15 @@ This leaves one piece of data unnamed, `D_80C106C8`. This is initially set to `0 D_80C106C8 = 1; } ``` + What is this doing? We need to understand that to name this variable. -The N64's processors cannot use segmented addresses: they need actual RAM addresses. Therefore the segmented addresses have to be converted before being placed on a segment: this is what `Lib_SegmentedToVirtual` does. So (somewhat unusually) this loop is modifying the addresses in the actor's actual data in RAM. Having converted the addresses once, it wouldn't make any sense to convert them again, but `Init` would run every time an instantiation of the actor is created. Therefore `D_80C106C8` is present to ensure that the addresses only get converted once: it is really a boolean that indicates if the addresses have been converted. So let's call it `texturesDesegmented`, and replace its values by `true` and `false`. +The N64's processors cannot use segmented addresses: they need actual RAM addresses. Therefore the segmented addresses have to be converted before being placed on a segment: this is what `Lib_SegmentedToVirtual` does. So (somewhat unusually) this loop is modifying the addresses in the actor's actual data in RAM. Having converted the addresses once, it wouldn't make any sense to convert them again, but `Init` would run every time an instantiation of the actor is created. Therefore `D_80C106C8` is present to ensure that the addresses only get converted once: it is really a boolean that indicates if the addresses have been converted. So let's call it `sTexturesDesegmented`, and replace its values by `true` and `false`. Finally, clearly `4` is linked to the data over which we're iterating: namely it's the size of the array. We have a macro for this, `ARRAY_COUNT(sEyeTextures)`. We've got one struct variable left. To find out what it does, we can look at a function that uses it, for example + ```C s32 EnRecepgirl_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { @@ -431,6 +446,7 @@ void EnRecepgirl_UnkLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } } ``` + It is used to do a rotation of whatever limb `5` is. (The `+=` is because `rot->x` is the base rotation of the limb, and we have to add the same thing to it every frame to keep the angle changed and constant.) We can use Z64Utils to : setting segment `8` to one of what we know now are the eye textures, we can view the model in the skeleton viewer. The limb numbers in the object are one smaller than those in the actor (the root limb is only a concept for the code, not the object), so we find limb 4: ![Z64Utils highlighting a limb](images/z64utils_skeleton_head.png) @@ -530,15 +546,16 @@ void func_80C102D4(EnRecepgirl* this, PlayState* play) { ``` 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, &play->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(&play->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 +For more complex actors, we have a tool called `graphovl.py` that can produce function flow graphs for actors: running + ``` $ ./tools/graphovl/graphovl.py En_Recepgirl ``` + produces ![EnRecepgirl's function flow graph](images/En_Recepgirl.gv.png) - ## Miscellaneous other documentation We like to make macros for reading an actor's `params` (indeed, this is required even if you don't know what the params are for). A simple example is `ObjTree`, which has the following code in its `Init` function: @@ -577,7 +594,6 @@ Notice that we use `thisx`: this makes the form of every one of these macros the Much clearer! - We have now essentially documented this as far as we can without the object, so we'd better do that next. Next: [Analysing object files](object_decomp.md) diff --git a/docs/tutorial/draw_functions.md b/docs/tutorial/draw_functions.md index 2e8948268..ccc738219 100644 --- a/docs/tutorial/draw_functions.md +++ b/docs/tutorial/draw_functions.md @@ -38,7 +38,6 @@ void EnRecepgirl_Draw(Actor* thisx, PlayState* play) { } ``` - Notable features are the GraphicsContext temps, and blocks of the form ```C @@ -54,14 +53,15 @@ Each of these blocks converts into a graphics macro. They are usually (but not a For our purposes, we only need one of the programs this provides: `gfxdis.f3dex2`. - Graphics are actually 64-bit on the Nintendo 64. This code block is a result of instructions telling the processor what to do with the graphics pointer. There are two main types of graphics pointer (there are a couple of others used in `code`, but actors will only use these two), + - polyOpa ("opaque") for solid textures - polyXlu ("Xlucent" i.e. "translucent") for translucent textures Our example is polyOpa, not surprisingly since our receptionist is solid. `words.w0` and `words.w1` contain the actual graphics instruction, in hex format. Usually, `w0` is constant and `w1` contains the arguments. To find out what sort of macro we are dealing with, we use `gfxdis.f3dex2`. `w1` is variable, but we need to give the program a constant placeholder. A common word to use is 12345678, so in this case we run + ``` gfxdis.f3dex2 -x -g "POLY_OPA_DISP++" -d DB06002012345678 ``` @@ -73,6 +73,7 @@ gfxdis.f3dex2 -x -g "POLY_OPA_DISP++" -d DB06002012345678 Our standard now is to use decimal colors. If you have a constant second argument rather than a variable one, you can also use `-dc` to get decimal colors instead of the default hex. The output looks like + ``` gSPSegment(POLY_OPA_DISP++, 0x08, 0x12345678); ``` @@ -90,6 +91,7 @@ You repeat this for every block in the function. If you have worked on OoT, you will be aware of the functions `Graph_OpenDisps` and `Graph_CloseDisps`, and might be surprised to see them missing here. These functions are actually a debug feature: the `OPEN_DISPS` and `CLOSE_DISPS` macros still exist, but they don't expand to functions. Of course this means you have to guess where they go. A sensible guess for `OPEN_DISPS` is where the `gfxCtx` temp assignment first happens; `CLOSE_DISPS` is a bit harder, although it's basically just a `}`, so it *shouldn't* matter as much. It's sensible to eliminate all the `gfxCtx` temps and reintroduce as needed. Also remember to change the prototype and function definition back! + ```C s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *actor); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10558.s") @@ -116,11 +118,14 @@ void EnRecepgirl_Draw(Actor* thisx, PlayState* play) { And this matches. The last two functions in the actor are used as arguments in `SkelAnime_DrawTransformFlexOpa`. This is a `SkelAnime` function, except unlike the OoT ones, it has three function callback arguments instead of two: in `functions.h` or `z_skelanime.c`, we find + ```C void SkelAnime_DrawTransformFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor) ``` + The typedefs of the callbacks it uses are in `z64animation.h`: + ```C typedef s32 (*OverrideLimbDrawOpa)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, struct Actor* thisx); @@ -132,6 +137,7 @@ typedef void (*PostLimbDrawOpa)(struct PlayState* play, s32 limbIndex, Gfx** dLi typedef void (*TransformLimbDrawOpa)(struct PlayState* play, s32 limbIndex, struct Actor* thisx); ``` + which is where mips2c got them from. In this case, only two of them are used, and it is these that are the last functions standing between us and a decompiled actor. @@ -139,6 +145,7 @@ In this case, only two of them are used, and it is these that are the last funct ## OverrideLimbDraw, PostLimbDraw, TransformLimbDraw Well, we don't have a PostLimbDraw here, but as we see from the prototype, it's much the same as the OverrideLimbDraw but without the `pos` argument and no return value. + ```C s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *actor) { if (limbIndex == 5) { @@ -147,7 +154,9 @@ s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s return 0; } ``` + Only two things to do here: we need to use `EnRecepgirl` to get to `actor + 0x2B0`, and the return value is used as a boolean, so we replace `0` by `false` (`true` means "don't draw the limb", and is hardly ever used). + ```C s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *thisx) { EnRecepgirl* this = THIS; @@ -160,6 +169,7 @@ s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s ``` As for the TransformLimbDraw, it has a much simpler prototype. mips2c gives + ```C void func_80C10590(PlayState* play, s32 limbIndex, Actor *actor) { if (limbIndex == 5) { @@ -168,10 +178,13 @@ void func_80C10590(PlayState* play, s32 limbIndex, Actor *actor) { } } ``` -There is only minor cleanup needed here: + +There is only minor cleanup needed here: + - recasting the last argument, - replacing the last argument of `Matrix_RotateYS` by the enum `MTXMODE_APPLY` (which means "use the current matrix instead of starting from a new identity matrix"), and the first argument by `0x400 - this->unk_2AE.x`. - `(Vec3f *) &actor->focus` to `&actor->focus.pos` (this is the same issue as `(Actor*)this`, where mips2c doesn't climb deep enough into the struct). + ```C void func_80C10590(PlayState* play, s32 limbIndex, Actor *thisx) { EnRecepgirl* this = THIS; @@ -186,6 +199,7 @@ void func_80C10590(PlayState* play, s32 limbIndex, Actor *thisx) { ## Some more examples: ObjTree Since EnRecepgirl was a bit light on graphics macros, we will look at an example that has a few more. A nice simple one is `ObjTree_Draw`: the original mips2c output is + ```C void ObjTree_Draw(Actor* thisx, PlayState* play) { s16 sp36; @@ -225,7 +239,9 @@ void ObjTree_Draw(Actor* thisx, PlayState* play) { temp_v0_4->words.w0 = 0xDE000000; } ``` + We can see there are four blocks here, although only two different macros: + ```C temp_v0 = temp_s0->polyOpa.p; temp_s0->polyOpa.p = temp_v0 + 8; @@ -233,12 +249,16 @@ We can see there are four blocks here, although only two different macros: sp28 = temp_v0; sp28->words.w1 = Matrix_NewMtx(play->state.gfxCtx); ``` + gfxdis gives + ``` $ gfxdis.f3dex2 -x -g POLY_OPA_DISP++ -d DA38000312345678 gSPMatrix(POLY_OPA_DISP++, 0x12345678, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); ``` + so it becomes + ```C gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); ``` @@ -249,11 +269,14 @@ gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_M temp_v0_2->words.w1 = (u32) &D_06000680; temp_v0_2->words.w0 = 0xDE000000; ``` + ``` $ gfxdis.f3dex2 -x -g POLY_OPA_DISP++ -d DE00000012345678 gSPDisplayList(POLY_OPA_DISP++, 0x12345678); ``` + so this one is + ```C gSPDisplayList(POLY_OPA_DISP++, D_06000680); ``` @@ -265,16 +288,20 @@ gSPDisplayList(POLY_OPA_DISP++, D_06000680); sp20 = temp_v0_3; sp20->words.w1 = Matrix_NewMtx(play->state.gfxCtx); ``` + This is the same as the first one. Indeed, it's identical. + ```C temp_v0_4 = temp_s0->polyOpa.p; temp_s0->polyOpa.p = temp_v0_4 + 8; temp_v0_4->words.w1 = (u32) &D_060007C8; temp_v0_4->words.w0 = 0xDE000000; ``` + This is the same as the second one, but with a different second word. Tidying up and inserting `OPEN_DISPS` and `CLOSE_DISPS`, we end up with + ```C void ObjTree_Draw(Actor* thisx, PlayState* play) { s16 sp36 = (f32) thisx->shape.rot.x; diff --git a/docs/tutorial/intro_to_git.md b/docs/tutorial/intro_to_git.md new file mode 100644 index 000000000..59262a2d5 --- /dev/null +++ b/docs/tutorial/intro_to_git.md @@ -0,0 +1,402 @@ +# Introduction to git for decomp + +`git` is a version control system: it allows you to keep different versions of files at the same time. It does this using a tree system: + +- A *repository* is directory containing files managed by git. +- A repository has one or more *branches*. A branch can be thought of as a pointer to a specific commit. +- A *commit* is one set of changes, the most basic "unit" when working with git. The key point about git is that it is possible to have several commits based on the same one +- A *remote* is another copy of the same repository, usually on another computer or the Internet. + +For example, + +```bash +Remote +---o---o---o---o + +Local + master + v +---o---o---o---o + \ + o---o + ^ + A +``` + +Each `o` is a commit. The lines show the commit that each commit was based on: we can see in the local there is one commit with two commits based on it. The local has two branches, `master` and `A`, and they currently both point to the commits furthest along their respective chains. + +Throughout this guide, stuff in `SCREAMING_SNAKE_CASE` represents fields for you to fill in with the appropriate text, e.g. FILE should be replaced with a particular filename. + +## Setting up git + +If you are on an ordinary Linux distribution (i.e. not Arch or similar) or WSL, you probably already have git installed, and if not, can get it by running `sudo apt install git` in a terminal window. + +git commits are signed with the committer's name and email (if you don't want an actual email address attached to it, GitHub will generate a fake one for you). To set these up for any repository you work on, run + +```bash +git config --global user.name "NAME" +git config --global user.email "EMAIL_ADDRESS" +``` + +(omitting `--global` will set these only for the repository in the current folder). + +To make a new repository in a directory: + +```bash +git init +``` + +The repository is considered to have the same name as the directory in which it lives. + +The default branch is set to be called `master`. If you want to call it something else, do + +```bash +git init -b DEFAULT_BRANCH_NAME +``` + +Usually when working on decomp you will instead be cloning a repository from GitHub, though. + +## Cloning a repository from GitHub + +```bash +git clone REMOTE_URL +``` + +This will clone the repository associated with that URL into a subdirectory of the one you are currently in, with a name based on the repository name. For example, + +```bash +git clone git@github.com:zeldaret/mm.git +``` + +will clone the MM repository into the subdirectory `mm`. + +git will automatically name the original remote as `origin`, so for decomp you probably want to use a different name so your own fork on GitHub is `origin`. You can do this: + +```bash +git clone -o REMOTE_NAME REMOTE_URL +``` + +so + +```bash +git clone -o upstream git@github.com:zeldaret/mm.git +``` + +## Configuring remotes + +View all remotes associated to this repository. Each remote has a name and an address. + +```bash +git remote -v +``` + +Rename remote `OLD` to `NEW` + +```bash +git remote rename OLD NEW +``` + +Add a new remote + +```bash +git remote add NAME URL +``` + +For example, a typical workflow to get a repository from GitHub is to fork it, then + +```bash +git clone -o upstream git@github.com:zeldaret/mm.git +cd mm +git add git@github.com:yourgithubaccount/mm.git +``` + +## Managing branches + +You should always work on a branch, to retain a clean copy of the repository that you know works on the master/main branch, and to enable you to switch between unrelated work easily. + +To list the branches you currently have: + +```bash +git branch +``` + +To make a new branch: + +```bash +git branch NEW_BRANCH_NAME +``` + +To change branch: + +```bash +git checkout BRANCH_NAME +``` + +To make a new branch and change to it in one command: + +```bash +git checkout -b NEW_BRANCH_NAME +``` + +To delete a branch (e.g. if definitely no longer needed) + +```bash +git branch -d BRANCH_NAME +``` + +## Committing + +To make git remember your changes, you need to make a commit. Ordinarily a commit applies to only files that are *staged*. + +To add files to staging: + +```bash +git add FILES +``` + +To commit staged files: + +```bash +git commit +``` + +This will open a text editor to write a commit message. It is generally expected that commit messages are informative and short. If you want to write the commit message in the terminal instead, + +```bash +git commit -m "COMMIT_MESSAGE" +``` + +To unstage a file (but keep the changes) + +```bash +git reset FILE +``` + +(To unstage everything, `git reset`) + +To revert a file to its state at the last commit: + +```bash +git reset --hard FILE +``` + +## Merging and Rebasing + +Having worked separately on a branch A, you often want to incorporate changes from branch B into branch A. Considering the tree/commit structure, there are two possible ways to do this: + +- Stick the two branches back together at their current commits. This is called *merging* B into A: diagrammatically, + +```bash +---o---o---o---o A + \ + o---o---o B +``` + +to + +```bash +---o---o---o---o---m A + \ / + o-----o-----o B +``` + +where `m` is a *merge commit*. + +- Go back to the common ancestor of A and B, take all the commits on A since then, and attempt to apply them to the tip of B. This is called *rebasing* A on B. + +```bash +---o---o---o---o A + \ + o---o---o B +``` + +to + +```bash +---o + \ + o---o---o---o---o---o A + ^ + B +``` + +(Notice that in neither case is B itself destroyed.) + +Both have advantages and disadvantages. + +- Merging is conceptually simpler, but generates an additional commit. +- Rebasing results in cleaner history and is usually easier to do because there are fewer changes in each commit, but makes it much harder to follow what has changed between commits before and after: *you should not rebase a branch other people are looking at* (e.g. in GitHub reviews, but also in other collaboration). + +If you realise you have made a mistake while still merging, you can run + +```bash +git merge --abort +``` + +or + +```bash +git rebase --abort +``` + +as appropriate to stop attempting to merge/rebase. + +As such, if you only want to learn one of these, learn merging. + +### Conflict resolution + +If the two branches have both touched the same or nearby lines, git will not know which you want to keep. It will therefore pause the merge/rebase and tell you to decide. You will find a section of the file that looks like this: + +```bash +<<<<<<< A +Some code +======= +Some other code +>>>>>>> B +``` + +from which you should pick one (or combine parts of both as appropriate), then delete the rest. (You definitely do not want the git artefacts left in!) + +Notice also that the changes are applied in opposite ways in each case: merging B into A, the incoming changes are from B, whereas when rebasing, they come from A. *This means the conflict resolution in one is in the opposite order from the other.* + +## Keeping up to date with remotes + +To update git's information about remotes: + +```bash +git fetch REMOTE_NAME +``` + +Not specifying `REMOTE_NAME` will fetch from the remote with the branch that tracks the current one. + +To fetch a remote branch's changes and merge them into the current branch: + +```bash +git pull REMOTE_NAME BRANCH_NAME +``` + +To fetch and rebase the current branch on a remote branch: + +```bash +git pull --rebase REMOTE_NAME BRANCH_NAME +``` + +It's generally better to use fetch and then merge/rebase separately, though, at least until you're more experienced with git. + +To update a remote with changes from the current branch: + +```bash +git push +``` + +To send changes ignoring any changes to the remote branch since local and remote went out of sync, + +```bash +git push --force +``` + +To push a new branch to a remote and set up a branch that *tracks* it on there, you need to specify which remote to push it to: + +```bash +git branch -u REMOTE_NAME +``` + +## Stashing + +You may want to store your current changes without actually committing thhem, for example if you're halfway through something but want new changes from a remote. Running + +```bash +git stash +``` + +will save changes to a "stash" that can be applied later, even to a different branch, with + +```bash +git stash apply +``` + +which keeps the stash, or + +```bash +git stash pop +``` + +which applies, and deletes it if application was successful. + +You can also name and delete stashes and so on. + +## Repository information + +To get general information about what branch you are on, staged and modified files: + +```bash +git status +``` + +This will also indicate any files with merge conflicts. + +To see a line-by-line description of the changes currently made: + +```bash +git diff +``` + +(you can also diff 2 branches or 2 commits) + +git's most general and powerful information command is `log`, which is far too extensive to cover here. + +## GitHub + +Things are a little different on GitHub compared to working locally. + +To make your own copy of a repository, click `Fork`. + +Most repositories do not let people push to them directly. Instead, you make a Pull Request (PR) for merging your branch into one of theirs: this also allows other people to review your work. A Pull Request cannot be merged unless it has no conflicting files. We also use a continuous integration system called Jenkins to ensure that the branch's files are correctly formatted, the it builds the rom correctly, and produces no new warnings; this will usually automatically run whenever you push new changes. + +*A branch used for a PR is a public branch, so do not rebase it.* Apart from the usual problems with other people looking at your changes, it will detach all the GitHub review comments from where they are in the code. + +It is possible to fix merge conflicts on GitHub, but not recommended. GitHub can do a few other git-related things, but most of the time it's just simpler to do it locally. + +### Fetch and Merge + +To fetch and merge on GitHub, navigate to your personal fork of the repository `(e.g. github.com//mm)`. On this page there is a bar that will state whether or not the repository is up to date or not. If it is not up to date it will inform what is different. On the right side of that bar there is a drop down menu labeled "Fetch upstream", you can click this and there will be a button to "Fetch and Merge". Once this is done a `git pull` can be done locally to get all the new changes. + +### Code Reviews + +GitHub has the ability to review changes in a pull request one file at a time. When reviewing, you can review specific changes or comment on the file overall. To start a review: + +- Go to the repository and click "Pull Requests" + +- Click on a pull request to review + +On the conversation tab you can leave general comments and reply to any other comments that have been made. + +On the "Files changed" tab you will see the files changed in the pull request. You can change the format of the diff view in this tab by clicking the gear and choosing the unified or split view. + +To leave a comment, hover over the line of code where you'd like to add a comment, and click the blue "+" icon. To comment on a block of multiple lines, click and drag the range of lines you wish to comment, then click the blue icon. + +Optionally, to suggest a specific change to the line(s) , click the `+/-` icon then edit the text within the suggestion block. + +Once finished, click the "Review changes" and type a comment summarizing proposed changes and comments. + +### Giving credit to others + +If you want to credit other people who have contributed to a PR you have made, you can use the "Co-authored-by" + +```bash +NORMAL_COMMIT_MESSAGE + +Co-authored-by: GITHUB_USERNAME +``` + +Note the blank line and the `<>` around the email. More information on precisely how to do this can be found in GitHub's own docs: + +## More information + +This guide has only covered the basics that are required to work with git on a decomp repository. For more information + +- Run a command with `--help` +- Ask in Discord +- consult a reference such as https://git-scm.com/docs or https://www.atlassian.com/git/tutorials + +*Always ask or research before doing anything drastic, git is sophisticated enough that usually it has a way to resolve problems itself* diff --git a/docs/tutorial/introduction.md b/docs/tutorial/introduction.md index 99625364d..2115faace 100644 --- a/docs/tutorial/introduction.md +++ b/docs/tutorial/introduction.md @@ -73,12 +73,14 @@ A lot of work has already been done on the code to bring it into a format that i An *actor* is any thing in the game that moves or performs actions or interactions: Link is an actor, enemies are actors, NPCs are actors, props like grass are actors. The vast majority of actors are *overlays*, which means they are loaded only when the game needs them. -In the code, each actor is associated to several files: there is +In the code, each actor is associated to several files: there is + - the main .c file, e.g. `src/overlays/actors/ovl_En_Ms/z_en_ms.c` - the actor's Header file, e.g. `src/overlays/actors/ovl_En_Ms/z_en_ms.h` -- various .o files that tell the `make` script how to incorporate it into building the ROM, +- various .o files that tell the `make` script how to incorporate it into building the ROM, + +and then for undecompiled actors, various assembly (.s) files, generally including: -and then for undecompiled actors, various assembly (.s) files, generally including: - one for the actor's *data* (this usually includes things like its collision information about how to draw it, and various other stuff that is used in it), e.g. `data/overlays/actors/ovl_En_Ms.data.s` - one for each function in the actor, e.g. `asm/non_matchings/overlays/actors/ovl_En_Ms/func_809529AC.s` diff --git a/docs/tutorial/merging.md b/docs/tutorial/merging.md index 79e1386cc..b7745b509 100644 --- a/docs/tutorial/merging.md +++ b/docs/tutorial/merging.md @@ -3,7 +3,6 @@ - Up: [Contents](contents.md) - Previous: [Documenting](documenting.md) - ## Preparing to PR ### Change the `spec` @@ -73,7 +72,6 @@ Run the formatting script `format.sh`, to format the C files in the standard way To make sure the PR builds correctly with the current master, you need to merge `upstream/master` before you make the PR. This tends to break things, that you have to fix to get it to compile correctly again. - ## Pull Requests Push commits to your fork of the repository on GitHub, and then open a pull request. Name the PR something sensible, like @@ -87,7 +85,6 @@ and so on, although these four tend to cover most cases. Feel free to add a comm Please also update the status of the file on Trello/the spreadsheet. - ### Reviews Pull requests may be reviewed by anyone (who knows enough about the conventions of the project), and all must be reviewed and approved by two leads and one extra contributor. diff --git a/docs/tutorial/object_decomp.md b/docs/tutorial/object_decomp.md index f210dd446..90ed70405 100644 --- a/docs/tutorial/object_decomp.md +++ b/docs/tutorial/object_decomp.md @@ -74,7 +74,6 @@ The first argument of `gsDPLoadTextureBlock` tells you the offset, the second th The following is a list of the texture formats the Nintendo 64 supports, with their gfxdis names and ZAPD format names. - | Format name | Typing in `gsDPLoadTextureBlock` | "Format" in xml | | ----------------------------------------------- | -------------------------------- | --------------- | | 4-bit intensity (I) | `G_IM_FMT_I, G_IM_SIZ_4b` | i4 | @@ -111,6 +110,7 @@ If in doubt, look at completed objects in the repo, and if still in doubt, ask. ## Tools We are very fortunate that several nice tools have been written recently that are excellent for documenting asset files: + - [Z64Utils](https://github.com/Random06457/Z64Utils/releases), for looking at displaylists, textures they reference, the skeleton, animations, etc. - [Texture64](https://github.com/queueRAM/Texture64/releases), for looking at textures in all the common N64 formats (needed since Z64Utils cannot interpret textures not explicitly referenced in displaylists currently) @@ -149,6 +149,7 @@ For CI4 and CI8 textures, you might see improper-looking textures like so: ![An improper-looking CI8 texture](images/broken_texture.png) The reason this happens is because ZAPD couldn't determine the TLUT for the texture, so it couldn't use the proper palette. To fix this, you can supply a `TlutOffset` to the texture like so: + ```xml ``` @@ -157,4 +158,4 @@ The reason this happens is because ZAPD couldn't determine the TLUT for the text Texture animations are new to Majora's Mask, and they can be pretty tricky to understand. Luckily, there's some extensive documentation on how they're structured [here](https://github.com/zeldaret/mm/blob/master/tools/ZAPD/ZAPD/ZTextureAnimation.cpp). One useful thing to remember is that empty texture animations take the form of `00 00 00 06 00 00 00 00`. The process that automatically generated all the object XMLs sometimes failed to recognize this as an empty texture animation, so it puts it in various blobs or fails to account for it at all. -Next: [The merging process](merging.md) \ No newline at end of file +Next: [The merging process](merging.md) diff --git a/docs/tutorial/object_decomp_example.md b/docs/tutorial/object_decomp_example.md index 8de89d075..0917ebdd4 100644 --- a/docs/tutorial/object_decomp_example.md +++ b/docs/tutorial/object_decomp_example.md @@ -15,6 +15,7 @@ In the resulting window, go to "Analysis -> Find Dlists" and press OK (the defau ![Finding object_dns's SkeletonHeader in Z64Utils](images/z64utils_dns_skeletonheader.png) When you open the Skeleton Viewer, you'll see a list of animations off to the side. Selecting one of them will display an error that says something like `RENDER ERROR AT 0x06001A98! (Could not read 0x80 bytes at address 08000000)`. This is because one of the display lists in the skeleton is expecting something to be set at segment 8. From the actor, we know that it's expecting the eye textures to be loaded into segment 8 like so: + ```c static TexturePtr D_8092DE1C[] = { &D_060028E8, &D_06002968, &D_060029E8, &D_06002968 }; [...] @@ -32,6 +33,7 @@ Now that we've gotten around the error, we can see what each limb in the skeleto Note that some limbs don't actually render anything, so sometimes clicking on a limb will not turn anything red; this may indicate a "Root" limb that has no associated display list, or it may indicate something like an eye limb that doesn't have the right textures loaded to display anything in Z64Utils. It may be useful to skip ahead to [Step #5](#step-5-naming-limb-display-lists) to learn how to check if the limb has a display list. If it doesn't have a display list, then it's a "Root" limb that will never be highlighted. We can now start naming the skeleton and individual limbs. Since we know this particular skeleton is the King's Chamber Deku Guard, we can name the skeleton `gKingsChamberDekuGuardSkel`. For the LimbNone name, we can call it something like `KINGS_CHAMBER_DEKU_GUARD_LIMB_NONE`, and we can name the LimbMax similarly. For the EnumName, we can name it `KingsChamberDekuGuardLimbs`. For each individual limb, we can name them based on what we see in Z64Utils; just make sure to update both the Name and the EnumName. After naming everything, we have something that looks like this: + ```xml @@ -49,22 +51,26 @@ We can now start naming the skeleton and individual limbs. Since we know this pa ``` Now we can run `./extract_assets.py -s objects/object_dns` to extract the object again, this time with our new names. What can we do with this? Quite a bit actually. In `z_en_dns.h`, we can add this to the top of the file to start using these new names in our code: + ```c #include "objects/object_dns/object_dns.h" ``` Now, we can redefine the `jointTable` and `morphTable` in terms of the limb enum we defined before, like so: + ```c /* 0x22A */ Vec3s jointTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; /* 0x278 */ Vec3s morphTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; ``` We can also use our new skeleton name and limb enum when initialization the skeleton like so: + ```c SkelAnime_Init(play, &this->skelAnime, &gKingsChamberDekuGuardSkel, NULL, this->jointTable, this->morphTable, KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX); ``` Lastly, we can use our limb enum in `EnDns_PostLimbDraw`. Where the code originally had: + ```c if (limbIndex == 2) { [...] @@ -72,6 +78,7 @@ if (limbIndex == 2) { ``` We can instead write: + ```c if (limbIndex == KINGS_CHAMBER_DEKU_GUARD_LIMB_HEAD) { [...] @@ -81,11 +88,13 @@ if (limbIndex == KINGS_CHAMBER_DEKU_GUARD_LIMB_HEAD) { ## Step 2: Naming the animations Now that we have the skeleton figured out, it's time to name all the animations. In the Skeleton Viewer, you can hit the "play" button on any animation to see what it looks like. Note that some objects have multiple skeletons, and selecting an animation that is associated with a different skeleton than the one you're looking at can cause odd behavior. Try to give each animation a descriptive name based on what it looks like. If you're struggling; + - Try viewing the animation in game. In what contexts does this animation play? - Try analyzing the code for the actor to see when the animation is used. Is this animation ever referenced? - If you're still really struggling, Majora's Mask 3D contains the original animation names for the majority of animations in the game. These original names can help you figure out what the developers were originally intending. Explaining how to find these animations in MM3D is outside of the scope of this document, so just ask in Discord if you want to try this. After naming the animations, the end result will look something like this: + ```xml @@ -99,6 +108,7 @@ After naming the animations, the end result will look something like this: ``` Once again, we can run `./extract_assets.py -s objects/object_dns` to extract the object, and we can update the animation names in `z_en_dns.c` to use our new names like so: + ```c static AnimationInfoS sAnimations[] = { { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, @@ -117,16 +127,19 @@ static AnimationInfoS sAnimations[] = { ## Step 3: Identifying the blob In the XML, you may notice undefined blobs like this: + ```xml ``` You might already have an idea as to what this is based on what you've seen before. Recall that the eye textures are referenced in the actor's code like this: + ```c static TexturePtr D_8092DE1C[] = { &D_060028E8, &D_06002968, &D_060029E8, &D_06002968 }; ``` Do you notice how the "28E8" in `D_060028E8` also appears as the Offset in that blob? That's because the blob is just the eye textures; the process for automatically creating the XML wasn't able to figure it out on its own, so we'll need to do it ourselves. But how should we define these textures in the XML? Recall that the eye textures were loaded into segment 8; let's take a look in `object_dns.c` and see if we can find something that uses this segment. This display list has the answer: + ```c Gfx object_dns_DL_001A50[] = { [...] @@ -137,6 +150,7 @@ Gfx object_dns_DL_001A50[] = { ``` Using `0x08000000` with `gsDPLoadTextureBlock` signals that this display list is expecting a texture in segment 8. What kind of texture is it expecting? We can look at the arguments after the `0x08000000`. It's looking for an RBGA16 texture with dimensions of 8x8, so we can define these textures in the XML like so: + ```xml @@ -144,6 +158,7 @@ Using `0x08000000` with `gsDPLoadTextureBlock` signals that this display list is ``` Now, we just have to name them. In [Step #1](#step-1-naming-the-skeleton-and-limbs), we set segment 8 to one of the eye textures; we can use that same technique with the other two eye textures to see what they are. Like most NPCs, these various eye textures are used for handling blinking, so we can name them based on how open the eye is: + ```xml @@ -151,6 +166,7 @@ Now, we just have to name them. In [Step #1](#step-1-naming-the-skeleton-and-lim ``` Like with previous steps, we can run `./extract_assets.py -s objects/object_dns` and then update `z_en_dns.c` with our new names: + ```c static TexturePtr sEyeTextures[] = { gKingsChamberDekuGuardEyeOpenTex, @@ -165,6 +181,7 @@ Note that this step might be tricky to do if multiple things in the actor use th ## Step #4: Naming anything else in the actor For some actors, there may be a few other things left to name that are directly referenced in the actor's code. In our case, there is one display list that we still need to name: + ```c gSPDisplayList(POLY_OPA_DISP++, &D_06002C48); ``` @@ -178,11 +195,13 @@ We can see this is the guard's Deku Flower: ![Showing the guard's Deku Flower in Z64Utils](images/z64utils_dns_deku_flower.png) We can name the display list as such in the XML: + ```xml ``` Then, like all steps before, we can run `./extract_assets.py -s objects/object_dns` and then update `z_en_dns.c` with our new name: + ```c gSPDisplayList(POLY_OPA_DISP++, gKingsChamberDekuGuardDekuFlower); ``` @@ -194,6 +213,7 @@ Now that we've named everything that's used externally by the actor, we just nee ![Showing the head limb's display list in Z64Utils](images/z64utils_dns_limb_dlist.png) Another way is to simply check `object_dns.c`. Each limb lists its own display list like this: + ```c StandardLimb gKingsChamberDekuGuardHeadLimb = { { 0, 1300, 0 }, KINGS_CHAMBER_DEKU_GUARD_LIMB_STALK - 1, KINGS_CHAMBER_DEKU_GUARD_LIMB_LEFT_FOOT - 1, @@ -202,6 +222,7 @@ StandardLimb gKingsChamberDekuGuardHeadLimb = { ``` Either way you go about it, you should be able to name all the limb display lists like so: + ```xml @@ -222,6 +243,7 @@ Run `./extract_assets.py -s objects/object_dns` once again, since it will help i ### Step #6: Naming remaining textures With every display list named, it's now a lot easier to name the remaining textures. In the `assets/objects/object_dns/` folder, you can see all the textures in the object as various PNG files. For some of the textures, just looking at them will give you a good idea as to what they should be named. For other textures, it may help to see how the texture is used in the object's display lists. Let's take a look at `object_dns_Tex_002868`, which is only used in one display list: + ```c Gfx gKingsChamberDekuGuardSnoutDL[] = { [...] @@ -240,6 +262,7 @@ Now, rebuild the game using [the steps described here](object_decomp.md#building ![Our custom mouth texture being shown in-game](images/custom_texture_in_game.png) This confirms our suspicion that this is indeed the mouth texture, so we can name it as such. We can use similar strategies to name all the other textures like so: + ```xml @@ -249,10 +272,11 @@ This confirms our suspicion that this is indeed the mouth texture, so we can nam ### Step #7: Finishing up If you have any other unnamed assets, now's the time to identify them. Otherwise, finish up the file by putting a comment at the top above the `` node: + ```xml ``` -And we're done! Hopefully, you found this example helpful when decompiling your own objects. \ No newline at end of file +And we're done! Hopefully, you found this example helpful when decompiling your own objects. diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index f85bf7ad8..255ae9eb4 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -10,6 +10,7 @@ At this point we have a choice to make. Either we could follow the main function ## Destroy Destroy will be a dead end, but we might as well do it now. Usually we would regenerate the context first and apply it to mips2c as with `Init`, but if we look at the assembly... + ```mips glabel EnRecepgirl_Destroy /* 0000FC 80C100CC AFA40000 */ sw $a0, ($sp) @@ -17,24 +18,30 @@ glabel EnRecepgirl_Destroy /* 000104 80C100D4 03E00008 */ jr $ra /* 000108 80C100D8 00000000 */ nop ``` + It doesn't seem to do anything. Indeed, chucking it in mips2c, + ``` $ ../mips_to_c/mips_to_c.py asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Destroy.s void EnRecepgirl_Destroy(s32 arg0, ? arg1) { } ``` + so it really does do nothing. It is worth staying on this briefly to understand what is is doing, though. Even with no context, mips2c knows it takes two arguments because it does two saves onto the stack: the calling convention the N64 uses requires the first four arguments be saved from the registers onto the stack, since the registers are expected to be cleared when a function call happens. It's done a bad job of guessing what they are, but that's to be expected: the assembly only tells us they're words. Thankfully we already know in this case, so we can just replace the `GLOBAL_ASM` by + ```C void EnRecepgirl_Destroy(Actor* thisx, PlayState* play) { } ``` + and cross this function off. ## `func_80C10148` We don't really have a choice now, we have to look at this function. Remake the context (no need to change the function type this time), and run mips2c on the function's assembly file: + ``` $ ../mips_to_c/mips_to_c.py asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10148.s data/ovl_En_Recepgirl/ovl_En_Recepgirl.data.s --context ctx.c extern AnimationHeader D_0600AD98; @@ -53,16 +60,21 @@ void func_80C10148(EnRecepgirl *this) { ``` This gives us some information immediately: `D_0600AD98` is an `AnimationHeader`, and `func_80C1019C` is set as the action function. This means that we know its type, even though mips2c does not: looking in the header, we see the typedef is + ```C typedef void (*EnRecepgirlActionFunc)(struct EnRecepgirl*, PlayState*); ``` + and so we prototype `func_80C1019C` as + ```C void func_80C1019C(EnRecepgirl* this, PlayState* play); ``` + at the top (were it above the function we're currently working on, the prototype could eventually be replaced by the function definition itself, but since it isn't, it goes at the top with the others). -There are several rather odd things going on here: +There are several rather odd things going on here: + - `temp_a0` is only used once. As such it's probably fake. - There's a weird `this = this` that does nothing - `if (&D_06001384 == this->skelAnime.animation)` is a bit of a funny way to write the condition: it seems more likely it would be the other way round. @@ -70,6 +82,7 @@ There are several rather odd things going on here: - `func_80C1019C` is already a pointer, so the `&` is ineffectual. Our style is to not use `&` on function pointers. If we tackle these, we end up with + ```C void func_80C10148(EnRecepgirl* this); @@ -92,14 +105,15 @@ void func_80C10148(EnRecepgirl *this) { this->actionFunc = func_80C1019C; } ``` + This is a common type of function called a setup (action) function. It runs once and prepares the ground for its corresponding actionfunction to run, whereas the actionfunction is usually run every frame by `Update` (but more on that later). Running `make`, we get OK again. Again we have only one way to go - ## `func_80C1019C` Remake the context and run mips2c on this function's assembly file. We get + ```C ? func_80C10290(EnRecepgirl *); // extern @@ -135,7 +149,9 @@ void func_80C1019C(EnRecepgirl* this, PlayState* play) { } } ``` + This is a bit juicier! We can do some preliminary cleanup, then worry about the control flow. + - `sp24` does nothing, so is almost certainly fake. - `temp_a0` is used in 3 different places, but they're all right next to one another and are unlikely to be required since there's no nontrivial calculation or anything happening. Let's remove it too and see what happens. - We've got another reversed comparison, `&D_0600A280 == this->skelAnime.animation`. @@ -145,6 +161,7 @@ This is a bit juicier! We can do some preliminary cleanup, then worry about the - Prototype `func_80C10290`: it is reasonable to guess it's another setup function, so `void func_80C10290(EnRecepgirl* this);`. Changing all these, we end up with + ```C void func_80C10148(EnRecepgirl* this); void func_80C1019C(EnRecepgirl* this, PlayState* play); @@ -187,12 +204,15 @@ void func_80C1019C(EnRecepgirl* this, PlayState* play) { } } ``` + If we look with diff.py, we find this matches. But we can replace some of the `return`s by `else`s: generally, we use elses unless + - After an `Actor_Kill` - Sometimes after setting an actionfunction - There's no way to avoid an early return Here, it's debatable whether to keep the first, since `func_80C10290` is likely a setup function. The latter two should be changed to elses, though. For now, let's replace all of them. This leaves us with + ```C void func_80C1019C(EnRecepgirl* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime) != 0) { @@ -217,7 +237,9 @@ void func_80C1019C(EnRecepgirl* this, PlayState* play) { } } ``` + which still matches. Lastly, we have an enum for the output of `Player_GetMask` and other mask-related things: in `z64player.h` we find + ```C typedef enum { /* 0x00 */ PLAYER_MASK_NONE, @@ -231,10 +253,10 @@ and so we can write the last if as `Player_GetMask(play) == PLAYER_MASK_KAFEIS_M Again, we have no choice in what to do next. - ## `func_80C10290` Remaking the context and running mips2c gives + ```C void func_80C102D4(EnRecepgirl*, PlayState*); // extern @@ -243,8 +265,8 @@ void func_80C10290(EnRecepgirl *this) { this->actionFunc = func_80C102D4; } ``` -so all we have to do is add the function prototype for the newest action function. Not surprisingly, this matches without changing anything. +so all we have to do is add the function prototype for the newest action function. Not surprisingly, this matches without changing anything. ## `func_80C102D4` @@ -320,6 +342,7 @@ void func_80C102D4(EnRecepgirl* this, PlayState* play) { Well, this is a big one! We get one more extern, for `D_06000968`. A lot of the temps used in the conditionals look fake, with the exception of `temp_v0_2`: because the function is only called once but the temp is used twice, the temp must be real. Removing the others and switching the `animation` conditionals, + ```C void func_80C102D4(EnRecepgirl* this, PlayState* play) { u8 temp_v0_2; @@ -373,11 +396,14 @@ void func_80C102D4(EnRecepgirl* this, PlayState* play) { } } ``` + There remains one thing we need to fix before trying to compile it, namely `*(&gSaveContext + 0xF37) & 0x80`. This is really a funny way of writing an array access, because mips2c will get confused about arrays in structs. Opening up `z64save.h`, we find in the `SaveContext` struct that + ```C /* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg" /* 0x0F5C */ u32 mapsVisited; // "area_arrival" ``` + so it's somewhere in `weekEventReg`. `0xF37 - 0xEF8 = 0x3F = 63`, and it's a byte array, so the access is actually `gSaveContext.save.weekEventReg[63] & 0x80`. Now it will compile. We also don't use `!= 0` for flag comparisons: just `if (gSaveContext.save.weekEventReg[63] & 0x80)` will do. Running `./diff.py -mwo3 func_80C102D4` and scrolling down, we discover that this doesn't match! @@ -385,10 +411,13 @@ Running `./diff.py -mwo3 func_80C102D4` and scrolling down, we discover that thi ![First run of diff.py on func_80C102D4](images/func_80C102D4_diff1.png) The yellow shows registers that don't match, the different colours on the registers help you to estimate where the problems are. Usually it's best to start at the top and work down if possible: any regalloc problems at the top tend to propagate most of the way down. In our case, the first problem is + ``` 3f0: andi t0,v0,0xff r 153 3f0: andi t1,v0,0xff ``` + 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 = Message_GetState(&play->msgCtx); if (temp_v0_2 == 2) { @@ -408,12 +437,12 @@ Notice that indeed the subsequent regalloc, which might have looked like a bigge And now we've run out of functions. Time for `Update`. - ## Update Update runs every frame and usually is responsible for the actor's common logic updates: for example, updating timers, blinking, updating collision, running the `actionFunc`, and so on, either directly or through other functions it calls. A lot of subsidiary functions that are not common to every state (e.g. updating position, or the text when talking, etc.) are carried out by one of the action functions we have already decomped. Remake the context and run mips2c: + ```C ? func_80C100DC(EnRecepgirl *); // extern @@ -426,9 +455,11 @@ void EnRecepgirl_Update(Actor* thisx, PlayState* play) { func_80C100DC(this); } ``` + If we search for `func_80C100DC`, we find that this is the only time it is used. Hence we can be almost certain that its prototype is `void func_80C100DC(EnRecepgirl* this);`. This function occurs above `Update`, so you can put the prototype next to the `GLOBAL_ASM` and remove it when we decompile that function. Change the function and the prototype back to `Actor* thisx`, and add the casting temp: + ```C void func_80C100DC(EnRecepgirl *); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C100DC.s") @@ -444,16 +475,21 @@ void EnRecepgirl_Update(Actor* thisx, PlayState* play) { func_80C100DC(this); } ``` + Now, our problem is `Actor_TrackPlayer`. The arguments all look terrible! Indeed, if we look at the actual function in `src/code/code_800E8EA0.c` (found by searching), we find that it should be + ```C s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos) ``` + So mips2c has made a bit of a mess here: + - the third argument should be a `Vec3s`. Hence `this + 0x2AE` is a `Vec3s*`, and so `this->unk_2AE` is a `Vec3s` - `&sp30` is a `Vec3s*`, so `sp30` is a `Vec3s` (it's clearly not used for anything, just used to "dump" a side-effect of the function) - The last argument is supposed to be an actual `Vec3f` Fixing all of this, we end up with + ```C void EnRecepgirl_Update(EnRecepgirl* this, PlayState* play) { EnRecepgirl* this = THIS; @@ -464,7 +500,9 @@ void EnRecepgirl_Update(EnRecepgirl* this, PlayState* play) { func_80C100DC(this); } ``` + and can fill in the top end of the struct: + ```C typedef struct EnRecepgirl { /* 0x0000 */ Actor actor; @@ -494,6 +532,7 @@ void EnRecepgirl_Update(Actor* thisx, PlayState* play) { func_80C100DC(this); } ``` + and this now matches. **N.B.** sometimes using an actual `PlayState* play` temp is required for matching: add it to your bag o' matching memes. @@ -516,6 +555,7 @@ Anyway, back to EnRecepgirl. 4 functions to go... ## `func_80C100DC` This is the final non-draw function. You know what to do now: remake the context and run mips2c: + ```C void func_80C100DC(EnRecepgirl *this) { u8 temp_t6; @@ -547,24 +587,30 @@ Well, it's still *pretty* close. But the registers are all wrong. Firstly, `temp ![func_80C100DC, second diff](images/func_80C100DC_diff2.png) It's not obvious that did much: it even looks a bit worse. + ```C temp_v0 = this->unk_2AC; temp_t6 = temp_v0 + 1; if (temp_v0 != 0) { this->unk_2AC = temp_t6; ``` + may remind you of that loop we decompiled, where mips2c unnecessarily made two temps. Let's walk through what this does. + - First, it saves the value of `this->unk_2AC` into `v0` - Then, it adds one to it and stores it in `t6`. - It checks if the first saved value is zero - If it is, it sets `this->unk_2AC` to the incremented value and carries on. Well, if we allow ourselves to bend the order of operations a little, there's a much simpler way to write this with no temps, namely + ```C if (this->unk_2AC != 0) { this->unk_2AC++; ``` + So let's try removing both temps: + ```C void func_80C100DC(EnRecepgirl *this) { if (this->unk_2AC != 0) { @@ -586,6 +632,7 @@ void func_80C100DC(EnRecepgirl *this) { There we go. Even though this matches, it is not quite according to our style: remember what was said earlier about early returns. Here, both of them can be removed and replaced by a single else without affecting matching: + ```C void func_80C100DC(EnRecepgirl *this) { if (this->unk_2AC != 0) { @@ -598,6 +645,7 @@ void func_80C100DC(EnRecepgirl *this) { } } ``` + and this is how we prefer it to be written. With that, the last remaining function is `EnJj_Draw`. Draw functions have an extra layer of macroing that is required, so we shall cover them separately. diff --git a/docs/tutorial/types_structs_padding.md b/docs/tutorial/types_structs_padding.md index 2e1d4d8b9..93492d3e1 100644 --- a/docs/tutorial/types_structs_padding.md +++ b/docs/tutorial/types_structs_padding.md @@ -1,10 +1,10 @@ # Types, structs, and padding Reminders: + - In N64 MIPS, 1 word is 4 bytes (yes, the N64 is meant to be 64-bit, but it mostly isn't used like it in MM or OoT) - A byte is 8 bits, or 2 hex digits - ## Types The following are the common data types used everywhere: @@ -14,7 +14,7 @@ The following are the common data types used everywhere: | char | 1 byte | character | | u8 | 1 byte | unsigned byte | | s8 | 1 byte | signed byte | -| u16 | 2 bytes | unsigned short | +| u16 | 2 bytes | unsigned short | | s16 | 2 bytes | signed short | | u32 | 4 bytes/1 word | unsigned int | | s32 | 4 bytes/1 word | signed int | @@ -27,16 +27,18 @@ A pointer is sometimes mistaken for an `s32`. The last two, marked with `^`, are `s32` is the default thing to use in the absence of any other information about the data. Useful data for guessing types: + - `u8` is about 7 times more common than `s8` - `s16` is about 16 times more common than `u16` - `s32` is about 8 times more common than `u32` Another useful thing to put here: the typedef for an action function is + ```C typedef void (*ActorNameActionFunc)(struct ActorName*, PlayState*); ``` -where you replace `ActorName` by the actual actor name as used elsewhere in the actor, e.g. `EnRecepgirl`. In MM these typedefs have been automatically generated, so you don't need to constantly copy from here or another actor any more. +where you replace `ActorName` by the actual actor name as used elsewhere in the actor, e.g. `EnRecepgirl`. In MM these typedefs have been automatically generated, so you don't need to constantly copy from here or another actor any more. ## Some Common Structs @@ -45,8 +47,8 @@ Here are the usual names and the sizes of some of the most common structs used i | ----------------------- | --------------------- | --------------- | | `Actor` | `actor` | 0x144 | | `DynaPolyActor` | `dyna` | 0x15C | -| `Vec3f` | | 0xC | -| `Vec3s` | | 0x6 | +| `Vec3f` | | 0xC | +| `Vec3s` | | 0x6 | | `SkelAnime` | `skelAnime` | 0x44 | | `Vec3s[limbCount]` | `jointTable` | 0x6 * limbCount | | `Vec3s[limbCount]` | `morphTable` | 0x6 * limbCount | @@ -59,7 +61,6 @@ Here are the usual names and the sizes of some of the most common structs used i Note that `Actor` and `DynaPolyActor` have changed size from OoT. - ## Padding ### Alignment @@ -70,7 +71,7 @@ The clearest example of this is that variables with types that are 1 word in siz ### Struct padding -In actor structs, this manifests as some of the char arrays not being completely replaced by actual variables. +In actor structs, this manifests as some of the char arrays not being completely replaced by actual variables. ```C typedef struct EnRecepgirl { @@ -123,7 +124,8 @@ Each section is 0x10/16-aligned (qword aligned), i.e. each new section begins at #### Padding at the end of .text (function instructions) In function instructions, this manifests as a set of `nop`s at the end of the last function: for example, in EnRecepGirl, -``` + +```mips /* 0006B0 80C10680 27BD0038 */ addiu $sp, $sp, 0x38 /* 0006B4 80C10684 03E00008 */ jr $ra /* 0006B8 80C10688 00000000 */ nop @@ -139,7 +141,8 @@ Once the rest of the functions match, this is automatic. So you never need to wo In data, the last entry may contain up to 3 words of 0s as padding. These can safely be removed when migrating data, but make sure that you don't remove something that actually is accessed by the function and happens to be 0! For example, in `ObjTree` we found that the last symbol in the data, -``` + +```mips glabel D_80B9A5BC /* 00006C 80B9A5BC */ .word 0x08000000 /* 000070 80B9A5C0 */ .word 0x00000000 @@ -147,6 +150,7 @@ glabel D_80B9A5BC /* 000078 80B9A5C8 */ .word 0x00000000 /* 00007C 80B9A5CC */ .word 0x00000000 ``` + had 2 words of padding: only the first 3 words are actually used in the `CollisionCheckInfoInit2`. ### Padding within the .data section diff --git a/docs/tutorial/vscode.md b/docs/tutorial/vscode.md index 91f2f659c..288bf0e48 100644 --- a/docs/tutorial/vscode.md +++ b/docs/tutorial/vscode.md @@ -1,6 +1,6 @@ # VSCode -A lot of people on this project use VSCode as their coding environment. +A lot of people on this project use VSCode as their coding environment. ## Extensions @@ -13,10 +13,7 @@ There are a number of useful extensions available to make work more efficient: - ~~bracket pair colorizer 2~~ (now obsolete due to VSCode's built-in bracket colouring) - Better MIPS Support - - - -## Useful stuff to know: +## Useful stuff to know - Ctrl + Alt + Up/Down (on Windows, on Linux it's Ctrl + Shift + Up/Down or Shift + Alt + Up/Down) gives multicursors across consecutive lines. If you want several cursors in a more diverse arrangement, middle clicking works, at least on Windows. - Alt + Up/Down moves lines up/down. diff --git a/include/color.h b/include/color.h index 438d857ad..b0b4d2cb0 100644 --- a/include/color.h +++ b/include/color.h @@ -19,6 +19,12 @@ typedef struct { /* 0x3 */ u8 a; } Color_RGBA8; // size = 0x4 +typedef struct { + /* 0x0 */ s16 r; + /* 0x2 */ s16 g; + /* 0x4 */ s16 b; +} Color_RGB16; // size = 0x6 + // only use when necessary for alignment purposes typedef union { struct { diff --git a/include/functions.h b/include/functions.h index 36e124fcd..59afb49d2 100644 --- a/include/functions.h +++ b/include/functions.h @@ -542,20 +542,19 @@ void EffectSsDFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* ac void EffectSsBubble_Spawn(PlayState* play, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale, f32 scale); void EffectSsGRipple_Spawn(PlayState* play, Vec3f* pos, s16 radius, s16 radiusMax, s16 life); void EffectSsGSplash_Spawn(PlayState* play, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 type, s16 scale); -// void EffectSsGFire_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2); +void EffectSsGFire_Spawn(PlayState* play, Vec3f* pos); // 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_SpawnColorProfile(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 life, s16 colorProfile, s16 randXZ); void EffectSsDtBubble_SpawnCustomColor(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 life, s16 randXZ); -void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16 scale, s16 objId, s16 life, Gfx* dList); -void EffectSsHahen_SpawnBurst(PlayState* play, Vec3f* pos, f32 burstScale, s16 unused, s16 scale, s16 randScaleRange, s16 count, s16 objId, s16 life, Gfx* dList); +void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 flags, s16 scale, s16 objId, s16 life, Gfx* dList); +void EffectSsHahen_SpawnBurst(PlayState* play, Vec3f* pos, f32 burstScale, s16 flags, 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); void EffectSsSibuki_SpawnBurst(PlayState* play, Vec3f* pos); void EffectSsStone1_Spawn(PlayState* play, Vec3f* pos, s32 reg0); -// void EffectSsHitMark_Spawn(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, UNK_TYPE2 uParm3, Vec3f* pzParm4); -void EffectSsHitMark_SpawnFixedScale(PlayState* play, s32 type, Vec3f* pos); -void EffectSsHitMark_SpawnCustomScale(PlayState* play, s32 type, s16 scale, Vec3f* pos); +void EffectSsHitmark_SpawnFixedScale(PlayState* play, s32 type, Vec3f* pos); +void EffectSsHitmark_SpawnCustomScale(PlayState* play, s32 type, s16 scale, Vec3f* pos); // void EffectSsFhgFlash_SpawnShock(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE2 uParm4, UNK_TYPE1 param_5); // void EffectSsKFire_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE1 param_6); void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16* linkDetected, s16 drawFlag); @@ -1115,23 +1114,23 @@ u32 Camera_SetMode(Camera* camera, s16 mode, s8 param_3); s32 Camera_ChangeMode(Camera* camera, s16 mode); // void func_800DF86C(void); // void func_800DF8EC(void); -s32 func_800DFAC8(Camera* camera, s16 param_2); +s32 Camera_ChangeSetting(Camera* camera, s16 setting); u32 Camera_ChangeDataIdx(Camera* camera, u32 camDataIdx); // void func_800DFC1C(void); // void func_800DFC40(void); s32 Camera_GetInputDirYaw(Camera* camera); -void func_800DFC90(Vec3s* arg0, Camera* camera); +void Camera_GetCamDir(Vec3s* dst, Camera* camera); s16 Camera_GetCamDirPitch(Camera* camera); s16 Camera_GetCamDirYaw(Camera* camera); -void func_800DFD04(Camera* camera, s32 arg1, s32 arg2, s32 arg3); -// void func_800DFD78(void); +void Camera_AddQuake(Camera* camera, s32 arg1, s16 y, s32 countdown); +void func_800DFD78(Camera* camera, s32 paramFlag, void* value); // UNK_TYPE4 func_800DFEF0(s32 param_1, u16 param_2); // UNK_TYPE4 func_800DFF18(Camera* iParm1, UNK_TYPE2 uParm2); // UNK_TYPE4 func_800DFF34(s32 param_1); // UNK_TYPE4 func_800DFF44(void); s16 Camera_SetFlags(Camera* iParm1, s16 flags); s16 Camera_ClearFlags(Camera* camera, s16 flags); -s32 func_800DFFAC(Camera* camera, Actor* doorActor, s16 bgCamDataId, f32 arg3, s16 timer1, s16 timer2, s16 timer3); +s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 bgCamDataId, f32 arg3, s16 timer1, s16 timer2, s16 timer3); // UNK_TYPE4 func_800E007C(Camera* param_1, Camera* param_2); // UNK_TYPE4 func_800E01AC(void); Vec3f* Camera_GetQuakeOffset(Vec3f* dst, Camera* camera); @@ -1450,7 +1449,7 @@ s16 ActorCutscene_GetAdditionalCutscene(s16 index); s16 ActorCutscene_GetLength(s16 index); s32 func_800F2138(s8 arg0); s32 func_800F2178(s16 arg0); -s16 ActorCutscene_GetCurrentCamera(s16 index); +s16 ActorCutscene_GetCurrentSubCamId(s16 index); s16 func_800F21CC(void); s32 func_800F22C4(s16 param_1, Actor* actor); void ActorCutscene_SetReturnCamera(s16 index); @@ -1622,7 +1621,7 @@ void Color_RGBA8_Copy(Color_RGBA8* dst, Color_RGBA8* src); void func_801000A4(u16 sfxId); void func_801000CC(u16 sfxId); void Lib_PlaySfxAtPos(Vec3f* pos, u16 sfxId); -void Lib_Vec3f_TranslateAndRotateY(Vec3f* translation, s16 a, Vec3f* src, Vec3f* dst); +void Lib_Vec3f_TranslateAndRotateY(Vec3f* translation, s16 rotAngle, 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); void Lib_Nop801004FC(void); @@ -1680,7 +1679,7 @@ u8 ZeldaArena_IsInitialized(); // void func_80102EA4(void); void func_80102EB4(u32 param_1); void func_80102ED0(u32 param_1); -// void func_80102EF0(void); +s32 func_80102EF0(PlayState* play); // void func_80102F9C(void); // void func_80103090(void); // void func_801030B4(void); @@ -1695,23 +1694,23 @@ void func_80102ED0(u32 param_1); // void func_80104C80(void); void func_80104CF4(PlayState* play); // void func_80104F34(void); -// void func_80105294(void); -// void func_80105318(void); +s32 func_80105294(void); +s16 func_80105318(void); // void func_80105328(void); // void func_8010534C(void); void func_8010549C(PlayState* play, void* segmentAddress); void func_8010565C(PlayState* play, u8 num, void* segmentAddress); void func_80105818(PlayState* play, u32 uParm2, TransitionActorEntry* puParm3); -// void func_80105A40(void); -// void func_80105B34(void); -// void func_80105C40(void); +void func_80105A40(void); +void func_80105B34(PlayState* play); +void func_80105C40(s16 arg0); // void func_80105FE0(void); // void func_80106408(void); // void func_80106450(void); // void func_801064CC(void); -// void func_80106530(void); +s32 func_80106530(PlayState* play); // void func_8010657C(void); -// void func_80106644(void); +void func_80106644(PlayState* play, s32 x, s32 z, s32 rot); // void func_8010683C(void); // void func_801068B4(void); // void func_801068D8(void); @@ -1726,7 +1725,7 @@ void func_80105818(PlayState* play, u32 uParm2, TransitionActorEntry* puParm3); // void func_80108A64(void); // void func_80108AF8(void); // void func_801090B0(void); -// void func_80109124(void); +s32 func_80109124(s16 arg0); // void func_801091F0(void); // void func_80109428(void); // void func_801094A0(void); @@ -1768,21 +1767,21 @@ void func_80105818(PlayState* play, u32 uParm2, TransitionActorEntry* puParm3); // void func_80109E70(void); // void func_80109EF8(void); // void func_80109F78(void); -s32 func_8010A000(PlayState* play); -s32 func_8010A074(PlayState* play); +s32 Map_GetDungeonOrBossAreaIndex(PlayState* play); +s32 Map_IsInDungeonOrBossArea(PlayState* play); s32 func_8010A0A4(PlayState* play); -// void func_8010A0F0(void); -// void func_8010A164(void); -// void func_8010A194(void); -s32 func_8010A208(PlayState* play); +// void Map_GetDungeonAreaIndex(PlayState* play); +// void Map_IsInDungeonArea(PlayState* play); +// void Map_GetBossAreaIndex(PlayState* play); +s32 Map_IsInBossArea(PlayState* play); // void func_8010A238(void); // void func_8010A2AC(void); -void func_8010A2DC(PlayState* play); -void func_8010A33C(PlayState* play, s16 param_2); -// void func_8010A410(void); -// void func_8010A430(void); -// void func_8010A54C(void); -// void func_8010A580(void); +void Minimap_SavePlayerRoomInitInfo(PlayState* play); +void Map_InitRoomData(PlayState* play, s16 room); +// void Map_Destroy(void); +// void Map_Init(PlayState* play); +// void Minimap_Draw(PlayState* play); +// void Map_Update(PlayState* play); // void func_8010A760(void); // void func_8010A7CC(void); // void func_8010A814(void); @@ -1882,31 +1881,30 @@ void Interface_ChangeAlpha(u16 param_1); // void func_80111CB4(void); // void func_801129E4(void); void func_80112AFC(PlayState* play); -void func_80112B40(PlayState* play, u8 arg1); -// void func_80112BE4(void); +void Interface_LoadItemIconImpl(PlayState* play, u8 btn); +void Interface_LoadItemIcon(PlayState* play, u8 btn); // void func_80112C0C(void); -u32 Item_Give(PlayState* play, u8 param_2); -// void func_801143CC(void); -UNK_TYPE func_80114978(UNK_TYPE arg0); -void func_801149A0(s32 itemId, s16 slotId); -// void func_80114A9C(void); -// void func_80114B84(void); -// void func_80114CA0(void); -s32 Interface_HasEmptyBottle(void); -s32 Interface_HasItemInBottle(u8 itemId); -// void func_80114FD0(void); -// void func_80115130(void); -// void func_801152B8(void); +u8 Item_Give(PlayState* play, u8 item); +u8 Item_CheckObtainability(u8 item); +void Inventory_DeleteItem(s16 item, s16 slot); +void Inventory_UnequipItem(s16 item); +s32 Inventory_ReplaceItem(PlayState* play, u8 oldItem, u8 newItem); +void Inventory_UpdateDeitySwordEquip(PlayState* play) ; +s32 Inventory_HasEmptyBottle(void); +s32 Inventory_HasItemInBottle(u8 item); +void Inventory_UpdateBottleItem(PlayState* play, u8 item, u8 btn); +s32 Inventory_ConsumeFairy(PlayState* play); +void Inventory_UpdateItem(PlayState* play, s16 slot, s16 item); // void func_801153C8(void); // void func_80115428(void); void func_8011552C(PlayState* play, s16 arg1); // void func_801155B4(void); // void func_80115764(void); void func_80115844(PlayState* play, s16 param_2); -s32 func_80115908(PlayState* play, u8 param_2); -void func_801159c0(s16 param_1); -void func_801159EC(s16 arg0); -void func_80115A14(s16 arg0, s16 arg1); +s32 Health_ChangeBy(PlayState* play, s16 healthChange); +void Health_GiveHearts(s16 hearts); +void Rupees_ChangeBy(s16 rupeeChange); +void Inventory_ChangeAmmo(s16 item, s16 ammoChange); void Parameter_AddMagic(PlayState* play, s16 arg1); void func_80115D5C(GameState* gamestate); // void func_80115DB4(void); @@ -1944,108 +1942,86 @@ void func_80121FC4(PlayState* play); Path* Path_GetByIndex(PlayState* play, s16 index, s16 max); f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw); void Path_CopyLastPoint(Path* path, Vec3f* dest); + void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx); s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input); -void func_801226E0(PlayState* play, s8 arg1); -void func_80122744(PlayState* play, UNK_PTR arg1, u32 arg2, Vec3s* arg3); -s32 func_80122760(PlayState* play, UNK_PTR arg1, f32 arg2); + +s32 func_801226E0(PlayState* play, s32 arg1); +s32 func_80122744(PlayState* play, struct_80122744_arg1* arg1, u32 arg2, Vec3s* arg3); +s32 func_80122760(PlayState* play, struct_80122744_arg1* arg1, f32 arg2); void func_80122868(PlayState* play, Player* player); void func_801229A0(PlayState* play, Player* player); -// void func_801229EC(void); -// void func_801229FC(void); -// void func_80122BA4(void); -// void func_80122C20(void); -// void func_80122D44(void); -// void func_80122ED8(void); -// void func_80122EEC(void); +void func_801229EC(UNK_TYPE arg0, UNK_TYPE arg1); +void func_801229FC(Player* player); +void func_80122BA4(PlayState* play, struct_80122D44_arg1* arg1, s32 arg2, s32 alpha); +void func_80122C20(PlayState* play, struct_80122D44_arg1* arg1); +void func_80122D44(PlayState* play, struct_80122D44_arg1* arg1); +u8 Player_MaskIdToItemId(s32 maskIdMinusOne); +u8 Player_GetCurMaskItemId(PlayState* play); void func_80122F28(Player* player); s32 func_80122F9C(PlayState* play); s32 func_80122FCC(PlayState* play); void func_8012300C(PlayState* play, s32 arg1); -void func_8012301C(s32 iParm1, PlayState* play); +void func_8012301C(Player* player, PlayState* play); void func_80123140(PlayState* play, Player* player); -u32 func_80123358(PlayState* play, Player* player); -s32 Player_InCsMode(GameState* gameState); -// void func_80123420(void); -// void func_80123434(void); -// void func_80123448(void); -// void func_801234B0(void); -// void func_801234D4(void); +s32 Player_InBlockingCsMode(PlayState* play, Player* player); +s32 Player_InCsMode(PlayState* play); +s32 func_80123420(Player* player); +s32 func_80123434(Player* player); +s32 func_80123448(PlayState* play); +s32 Player_IsGoronOrDeku(Player* player); +s32 func_801234D4(PlayState* play); s32 func_80123590(PlayState* play, Actor* actor); -// void func_8012364C(void); +s32 func_8012364C(PlayState* play, Player* player, s32 arg2); s32 func_80123810(PlayState* play); -// void func_80123960(void); -// void func_801239AC(void); -void func_80123AA4(Player* player, s32 arg1); -// void func_80123BD4(void); -// void func_80123C58(void); -void Player_SetEquipmentData(PlayState* play, Player* this); -void func_80123D50(PlayState* play, Player* player, UNK_TYPE arg2, UNK_TYPE arg3); +s32 Player_ActionToModelGroup(Player* player, s32 actionParam); +void func_801239AC(Player* player); +void Player_SetModels(Player* player, s32 arg1); +void Player_SetModelGroup(Player* player, s32 modelGroup); +void func_80123C58(Player* player); +void Player_SetEquipmentData(PlayState* play, Player* this); +void func_80123D50(PlayState* play, Player* player, s32 itemId, s32 actionParam); void func_80123DA4(Player* player); -// void func_80123DC0(void); +void func_80123DC0(Player* player); void func_80123E90(PlayState* play, Actor* actor); -void func_80123F2C(PlayState* play, s32 arg1); -s32 func_80123F48(PlayState* play, Vec3f* arg1, f32 arg2, f32 arg3); -s32 func_80124020(void); +s32 func_80123F2C(PlayState* play, s32 ammo); +s32 Player_IsBurningStickInRange(PlayState* play, Vec3f* pos, f32 xzRange, f32 yRange); +u8 Player_GetStrength(void); u8 Player_GetMask(PlayState* play); void Player_RemoveMask(PlayState* play); -s32 func_8012405C(PlayState* play); -s32 func_80124088(PlayState* play); -s32 func_801240C8(Player* player); -// void func_801240DC(void); -// void func_80124110(void); -// void func_80124148(void); -// void func_80124168(void); -s32 func_80124190(Player* player); -// void func_801241B4(void); -// void func_801241E0(void); -// void func_8012420C(void); -// void func_8012422C(void); +s32 Player_HasMirrorShieldEquipped(PlayState* play); +s32 Player_IsHoldingMirrorShield(PlayState* play); +s32 Player_IsHoldingHookshot(Player* player); +s32 func_801240DC(Player* player); +s32 func_80124110(Player* player, s32 actionParam); +s32 func_80124148(Player* player); +s32 Player_ActionToMeleeWeapon(s32 actionParam); +s32 Player_GetMeleeWeaponHeld(Player* player); +s32 Player_IsHoldingTwoHandedWeapon(Player* player); +s32 Player_ActionToBottle(Player* player, s32 actionParam); +s32 Player_GetBottleHeld(Player* Player); +s32 Player_ActionToExplosive(Player* player, s32 actionParam); s32 Player_GetExplosiveHeld(Player* player); -// void func_80124278(void); +s32 func_80124278(Actor* actor, s32 arg1); s32 func_801242B4(Player* player); -// void func_801242DC(void); -// void func_80124420(void); -// void func_80124618(void); -// void func_801246F4(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_TYPE1 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); -// void func_80124870(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_80124CC4(void); -// void func_80124F18(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80124FF0(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_TYPE2 param_10); -// void func_801251C4(void); -// void func_80125318(void); -// void func_80125340(void); -// void func_8012536C(void); -// void func_801253A4(void); -// void func_80125500(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80125580(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_80125CE0(void); -// void func_80125D4C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_801262C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_801263FC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +s32 func_801242DC(PlayState* play); +void func_80124420(Player* player); +void func_80124618(struct_80124618 arg0[], f32 curFrame, Vec3f* arg2); +void func_801246F4(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, s32 lod, s32 tunic, s32 boots, s32 face, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor); +void func_80125318(Vec3f* arg0, Vec3s* arg1); +void Player_DrawZoraShield(PlayState* play, Player* player); +void func_80125500(PlayState* play, Player* player, s32 limbIndex, Vec3f* pos, Vec3s* rot); +s32 func_80125D4C(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* actor); +s32 func_801262C8(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* actor); +s32 func_801263FC(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); s32 func_80126440(PlayState* play, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* arg3, Vec3f* arg4); -// void func_801265C8(void); -// void func_8012669C(void); -// void func_80126808(void); -void func_8012697C(PlayState* play, Player* player); -// void func_80126AB4(void); -// void func_80126B8C(void); -// void func_80126BD0(void); -// void func_801271B0(void); -// void func_80127438(void); -// void func_80127488(void); -// void func_8012754C(void); -// void func_80127594(void); -// void func_801278F8(void); -// void func_80127A60(void); -// void func_80127B64(void); -// void func_80127BE8(void); -// void func_80127DA4(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_80128388(void); -// void func_801284A0(void); -// void func_80128640(void); -// void func_80128B74(void); -// void func_80128BD0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE4 param_6); +void Player_DrawGetItem(PlayState* play, Player* player); +void func_80126B8C(PlayState* play, Player* player); +s32 func_80127438(PlayState* play, Player* player, s32 maskId); +s32 func_80128640(PlayState* play, Player* player, Gfx* dlist); +void func_80128B74(PlayState* play, Player* player, s32 limbIndex); +void func_80128BD0(PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot, Actor* actor); + void PreNMI_Stop(PreNMIContext* prenmiCtx); void PreNMI_Update(PreNMIContext* prenmiCtx); void PreNMI_Draw(PreNMIContext* prenmiCtx); @@ -2271,7 +2247,7 @@ s32 Entrance_GetSceneNum(u16 entranceIndex); s32 Entrance_GetSceneNumAbsolute(u16 entranceIndex); s32 Entrance_GetSpawnNum(u16 entranceIndex); s32 Entrance_GetTransitionFlags(u16 entranceIndex); -s32 Schedule_RunScript(PlayState* play, u8* script, ScheduleResult* result); +s32 Schedule_RunScript(PlayState* play, u8* script, ScheduleOutput* output); void SkelAnime_DrawLimbLod(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); void SkelAnime_DrawLod(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); void SkelAnime_DrawFlexLimbLod(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod, Mtx** mtx); @@ -2647,7 +2623,7 @@ s32 Play_CreateSubCamera(PlayState* play); s32 Play_GetActiveCamId(PlayState* play); void Play_CameraChangeStatus(PlayState* play, s16 camId, s16 status); void Play_ClearCamera(PlayState* play, s16 camId); -Camera* Play_GetCamera(PlayState* play, s16 index); +Camera* Play_GetCamera(PlayState* play, s16 camId); s32 Play_CameraSetAtEye(PlayState* play, s16 camId, Vec3f* at, Vec3f* eye); void Play_CameraSetAtEyeUp(PlayState* play, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up); void Play_CameraSetFov(PlayState* play, s16 camId, f32 fov); @@ -2742,7 +2718,7 @@ u32 THA_IsCrash(TwoHeadArena* tha); void THA_Init(TwoHeadArena* tha); void THA_Ct(TwoHeadArena* tha, void* ptr, size_t size); void THA_Dt(TwoHeadArena* tha); -void func_80172BC0(void); +void AudioMgr_StopAllSfxExceptSystem(void); void func_80172C30(AudioMgr* audioMgr); void AudioMgr_HandleRetrace(AudioMgr* audioMgr); void AudioMgr_HandlePRENMI(AudioMgr* audioMgr); @@ -2757,9 +2733,9 @@ void Game_UpdateFramerateVariables(s32 divisor); void Game_SetFramerateDivisor(GameState* gameState, s32 divisor); void GameState_SetFBFilter(Gfx** gfx, u32 arg1); void Game_Nop80173534(GameState* gameState); -void GameState_Draw(GameState* gameState, GraphicsContext* gCtxt); -void GameState_SetFrameBuffer(GraphicsContext* gCtxt); -void func_801736DC(GraphicsContext* gCtxt); +void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx); +void GameState_SetFrameBuffer(GraphicsContext* gfxCtx); +void func_801736DC(GraphicsContext* gfxCtx); void Game_UpdateInput(GameState* gameState); void Game_Update(GameState* gameState); void Game_IncrementFrameCount(GameState* gameState); @@ -3002,7 +2978,7 @@ void func_80183070(void); // void func_801832B0(void); // void func_8018332C(void); // void func_8018340C(void); -void func_80183430(SkeletonInfo* skeletonInfo, void* arg1, void* arg2, Vec3s* arg3, s16* arg4, UnkKeyframeCallback* callbacks); +void func_80183430(SkeletonInfo* skeletonInfo, void* arg1, void* arg2, Vec3s* arg3, Vec3s* arg4, UnkKeyframeCallback* callbacks); void func_8018349C(UNK_PTR arg0); void func_801834A8(SkeletonInfo* skeletonInfo, void* arg1); // void func_80183510(void); @@ -3148,8 +3124,8 @@ void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* ret u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts); void AudioLoad_DiscardSeqFonts(s32 seqId); void func_8018FA60(u32 tableType, u32 id, s32 arg2, s32 arg3); -s32 AudioLoad_SyncIniPlayer(s32 playerIdx, s32 seqId, s32 arg2); -s32 AudioLoad_SyncInitSetSeqqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks); +s32 AudioLoad_SyncInitSeqPlayer(s32 playerIndex, s32 seqId, s32 arg2); +s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIndex, s32 seqId, s32 skipTicks); void AudioLoad_ProcessLoads(s32 resetStatus); void AudioLoad_SetDmaHandler(DmaHandler callback); void AudioLoad_Init(void* heap, u32 heapSize); @@ -3222,43 +3198,17 @@ void AudioEffects_SequencePlayerProcessSound(SequencePlayer* seqPlayer); void AudioEffects_NoteVibratoUpdate(Note* note); void AudioEffects_NoteVibratoInit(Note* note); void AudioEffects_NotePortamentoInit(Note* note); -void AudioEffects_AdsrInit(AdsrState* adsr, AdsrEnvelope* envelope, s16* volOut); +void AudioEffects_AdsrInit(AdsrState* adsr, EnvelopePoint* envelope, s16* volOut); f32 AudioEffects_AdsrUpdate(AdsrState* adsr); -// void func_801974D0(void); -// void func_80197538(void); -// void func_80197714(void); -// void func_80197880(void); -// void func_801979D8(void); -// void func_80197A54(void); void AudioSeq_SequenceChannelDisable(SequenceChannel* channel); -// void func_80197B14(void); -// void func_80197C0C(void); -// void func_80197C8C(void); void AudioSeq_SequencePlayerDisableAsFinished(SequencePlayer* seqPlayer); void AudioSeq_SequencePlayerDisable(SequencePlayer* seqPlayer); void AudioSeq_AudioListPushBack(AudioListItem* list, AudioListItem* item); void* AudioSeq_AudioListPopBack(AudioListItem* list); -// void func_80197E88(void); -// void func_80197F28(void); -// void func_80197F3C(void); -// void func_80197F74(void); -// void func_80197FB4(void); -// void func_801980D0(void); -// void func_8019815C(void); -// void func_8019825C(void); -// void func_80198640(void); -// void func_80198CE0(void); -// void func_801990F4(void); -// void func_80199124(void); -// void func_80199198(void); -// void func_80199244(void); -void func_80199268(s32* param_1); -// void func_8019A0BC(void); -// void func_8019AA3C(void); -// void func_8019AAF0(void); +void AudioSeq_ProcessSequences(s32 arg0); +void AudioSeq_SkipForwardSequence(SequencePlayer* seqPlayer); void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer); -void AudioSeq_InitSequencePlayerChannels(s32 playerIdx); -// void func_8019ACEC(void); +void AudioSeq_InitSequencePlayerChannels(s32 playerIndex); void AudioSeq_InitSequencePlayers(void); void func_8019AE40(s32 param_1, s32 param_2, u32 param_3, s32 param_4); void func_8019AEC0(UNK_PTR param_1, UNK_PTR param_2); @@ -3380,7 +3330,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(u8 playerIdx, Vec3f* pos, u16 seqId, f32 maxDist); +void func_801A1FB4(u8 playerIndex, Vec3f* pos, u16 seqId, f32 maxDist); // void func_801A2090(void); void func_801A246C(u8 param_1, u8 param_2); // void func_801A2544(void); @@ -3478,7 +3428,7 @@ void Audio_PlaySfxGeneral(u16 sfxId, Vec3f* param_2, u8 param_3, f32* param_4, f // void func_801A6430(void); // void func_801A65C8(void); // void func_801A6D0C(void); -// void func_801A7084(void); +void func_801A7084(u8 bankId); // void func_801A7168(void); // void func_801A7284(void); void Audio_StopSfxByPos(Vec3f* pos); @@ -3498,7 +3448,7 @@ void Audio_QueueSeqCmd(u32 cmd); // void func_801A89D0(void); s32 func_801A8A50(s32 param1); // void func_801A8ABC(void); -void Audio_SetVolumeScale(u8 playerIdx, u8 scaleIdx, u8 targetVol, u8 volFadeTimer); +void Audio_SetVolumeScale(u8 playerIndex, u8 scaleIndex, u8 targetVol, u8 volFadeTimer); // void func_801A8D5C(void); // void func_801A8E90(void); // void func_801A9768(void); diff --git a/include/libc/math.h b/include/libc/math.h index c6756d959..1cdac0fb3 100644 --- a/include/libc/math.h +++ b/include/libc/math.h @@ -9,7 +9,6 @@ #define FLT_MAX 340282346638528859811704183484516925440.0f #define SHT_MAX 32767.0f #define SHT_MINV (1.0f / SHT_MAX) -#define DEGTORAD(x) ((x) * (M_PI / 180.0f)) typedef union { f64 d; diff --git a/include/macros.h b/include/macros.h index f1837e3d8..fd6f0e62a 100644 --- a/include/macros.h +++ b/include/macros.h @@ -16,28 +16,15 @@ // TODO: After uintptr_t cast change should have an AVOID_UB target that just toggles the KSEG0 bit in the address rather than add/sub 0x80000000 #define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr) + RDRAM_CACHED) -#define PHYSICAL_TO_VIRTUAL2(addr) ((uintptr_t)(addr) - RDRAM_CACHED) #define VIRTUAL_TO_PHYSICAL(addr) (uintptr_t)((u8*)(addr) - RDRAM_CACHED) #define SEGMENTED_TO_VIRTUAL(addr) (void*)(PHYSICAL_TO_VIRTUAL(gSegments[SEGMENT_NUMBER(addr)]) + SEGMENT_OFFSET(addr)) -#define GET_ACTIVE_CAM(play) ((play)->cameraPtrs[(play)->activeCamera]) -#define CAM_ID_MAIN 0 +#define GET_ACTIVE_CAM(play) ((play)->cameraPtrs[(play)->activeCamId]) #define SET_NEXT_GAMESTATE(curState, newInit, newStruct) \ (curState)->nextGameStateInit = (GameStateFunc)newInit; \ (curState)->nextGameStateSize = sizeof(newStruct) -#define SET_FULLSCREEN_VIEWPORT(view) \ - { \ - Viewport viewport; \ - viewport.bottomY = SCREEN_HEIGHT; \ - viewport.rightX = SCREEN_WIDTH; \ - viewport.topY = 0; \ - viewport.leftX = 0; \ - View_SetViewport(view, &viewport); \ - } \ - (void)0 - #define GET_PLAYER(play) ((Player*)(play)->actorCtx.actorLists[ACTORCAT_PLAYER].first) #define GET_FIRST_ENEMY(play) ((Actor*)(play)->actorCtx.actorLists[ACTORCAT_ENEMY].first) @@ -82,21 +69,32 @@ #define C_SLOT_EQUIP(form, button) (gSaveContext.save.equips.cButtonSlots[form][button]) #define CHECK_QUEST_ITEM(item) (GET_SAVE_INVENTORY_QUEST_ITEMS & gBitFlags[item]) +#define SET_QUEST_ITEM(item) (gSaveContext.save.inventory.questItems = (GET_SAVE_INVENTORY_QUEST_ITEMS | gBitFlags[item])) #define REMOVE_QUEST_ITEM(item) (gSaveContext.save.inventory.questItems = (GET_SAVE_INVENTORY_QUEST_ITEMS & (-1 - gBitFlags[item]))) #define CHECK_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.save.inventory.dungeonItems[(void)0, dungeonIndex] & gBitFlags[item]) +#define SET_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.save.inventory.dungeonItems[(void)0, dungeonIndex] |= (u8)gBitFlags[item]) #define DUNGEON_KEY_COUNT(dungeonIndex) (gSaveContext.save.inventory.dungeonKeys[(void)0, dungeonIndex]) #define GET_CUR_FORM_BTN_ITEM(btn) ((u8)((btn) == EQUIP_SLOT_B ? BUTTON_ITEM_EQUIP(CUR_FORM, btn) : BUTTON_ITEM_EQUIP(0, btn))) +#define GET_CUR_FORM_BTN_SLOT(btn) ((u8)((btn) == EQUIP_SLOT_B ? C_SLOT_EQUIP(CUR_FORM, btn) : C_SLOT_EQUIP(0, btn))) -#define SET_CUR_FORM_BTN_ITEM(btn, item) \ - do { \ - if ((btn) == EQUIP_SLOT_B) { \ - BUTTON_ITEM_EQUIP(CUR_FORM, (btn)) = (item); \ - } else { \ - BUTTON_ITEM_EQUIP(0, (btn)) = (item); \ - } \ - } while (0) + +#define SET_CUR_FORM_BTN_ITEM(btn, item) \ + if ((btn) == EQUIP_SLOT_B) { \ + BUTTON_ITEM_EQUIP(CUR_FORM, (btn)) = (item); \ + } else { \ + BUTTON_ITEM_EQUIP(0, (btn)) = (item); \ + } \ + (void)0 + +#define SET_CUR_FORM_BTN_SLOT(btn, item) \ + if ((btn) == EQUIP_SLOT_B) { \ + C_SLOT_EQUIP(CUR_FORM, (btn)) = (item); \ + } else { \ + C_SLOT_EQUIP(0, (btn)) = (item); \ + } \ + (void)0 #define STOLEN_ITEM_NONE (0) diff --git a/include/message_data_static.h b/include/message_data_static.h index f69e17232..d139c4621 100644 --- a/include/message_data_static.h +++ b/include/message_data_static.h @@ -3,7 +3,7 @@ #include "PR/ultratypes.h" -typedef struct MessageTableEntry{ +typedef struct MessageTableEntry { /* 0x0 */ u16 textId; /* 0x2 */ u8 typePos; /* 0x4 */ const char* segment; diff --git a/include/regs.h b/include/regs.h index 9942242a7..f8ce4ca86 100644 --- a/include/regs.h +++ b/include/regs.h @@ -74,10 +74,10 @@ #define R_MAGIC_BAR_X XREG(49) #define R_MAGIC_BAR_LARGE_Y XREG(50) #define R_MAGIC_FILL_X XREG(51) +#define R_MINIMAP_DISABLED XREG(95) #define R_B_LABEL_DD WREG(0) #define R_OW_MINIMAP_X WREG(29) #define R_OW_MINIMAP_Y WREG(30) -#define R_MINIMAP_TOGGLED WREG(31) #define R_B_LABEL_X(i) WREG(40 + i) #define R_B_LABEL_Y(i) WREG(43 + i) #define R_DGN_MINIMAP_X WREG(68) diff --git a/include/variables.h b/include/variables.h index 41e8fde42..0f1324135 100644 --- a/include/variables.h +++ b/include/variables.h @@ -815,10 +815,10 @@ extern BgSpecialSceneMaxObjects sCustomDynapolyMem[]; // extern UNK_TYPE1 D_801B969C; // extern UNK_TYPE1 D_801B976C; // extern UNK_TYPE1 D_801B979C; -extern CameraStateParams cameraStates[91]; +// extern CameraStateParams cameraStates[91]; // extern UNK_TYPE1 D_801B9CE2; -extern UNK_PTR D_801B9CE4; -extern camera_update_func cameraUpdateFuncs[71]; +// extern UNK_PTR D_801B9CE4; +// extern camera_update_func cameraUpdateFuncs[71]; // extern UNK_TYPE2 D_801B9E04; // extern UNK_TYPE4 D_801B9E08; // extern UNK_TYPE4 D_801B9E0C; @@ -1160,31 +1160,18 @@ extern UNK_PTR D_801BF5C0; // extern UNK_TYPE1 D_801BFD8C; // extern UNK_TYPE1 D_801BFD94; // extern UNK_TYPE2 D_801BFD98; -// extern UNK_TYPE1 D_801BFD9E; + // extern UNK_TYPE1 D_801BFDD0; -// extern UNK_TYPE1 D_801BFDE8; // extern UNK_TYPE1 D_801BFE00; // extern UNK_TYPE1 D_801BFE14; // extern UNK_TYPE2 D_801BFF34; -// extern UNK_TYPE1 D_801BFF3C; // extern UNK_TYPE1 D_801BFF90; -// extern UNK_TYPE1 D_801BFF98; -// extern UNK_TYPE1 D_801BFFA0; -// extern UNK_TYPE1 D_801BFFB0; +extern u8 gPlayerModelTypes[][5]; // extern UNK_TYPE1 D_801BFFFC; -// extern UNK_TYPE1 D_801C0000; -// extern UNK_TYPE1 D_801C0001; -// extern UNK_TYPE1 D_801C0002; -// extern UNK_TYPE1 D_801C0008; -// extern UNK_TYPE1 D_801C0010; // extern UNK_TYPE1 D_801C0024; // extern UNK_TYPE1 D_801C0034; -// extern UNK_TYPE1 D_801C0040; // extern UNK_TYPE1 D_801C005C; -// extern UNK_TYPE1 D_801C0060; -// extern UNK_TYPE1 D_801C0070; // extern UNK_TYPE1 D_801C0084; -// extern UNK_TYPE1 D_801C00A0; // extern UNK_TYPE1 D_801C00AC; // extern UNK_TYPE1 D_801C00BC; // extern UNK_TYPE1 D_801C00D4; @@ -1204,7 +1191,6 @@ extern UNK_PTR D_801BF5C0; // extern UNK_TYPE1 D_801C02BC; // extern UNK_TYPE1 D_801C02D0; // extern UNK_TYPE1 D_801C02E4; -extern UNK_PTR D_801C02F8; // extern UNK_TYPE1 D_801C0340; // extern UNK_TYPE1 D_801C0368; // extern UNK_TYPE1 D_801C03A0; @@ -1222,8 +1208,6 @@ extern UNK_PTR D_801C02F8; // extern UNK_TYPE1 D_801C05C8; // extern UNK_TYPE1 D_801C05D8; // extern UNK_TYPE1 D_801C05F0; -// extern UNK_TYPE2 D_801C05F2; -// extern UNK_TYPE1 D_801C05FA; // extern UNK_TYPE1 D_801C0608; // extern UNK_TYPE1 D_801C0628; // extern UNK_TYPE1 D_801C0678; @@ -1247,14 +1231,12 @@ extern Gfx D_801C0850[]; extern UNK_PTR D_801C0870; // extern UNK_TYPE1 D_801C0890; // extern UNK_TYPE1 D_801C08A0; -// extern UNK_TYPE1 D_801C08A1; // extern UNK_TYPE1 D_801C08C0; // extern UNK_TYPE1 D_801C08FC; // extern UNK_TYPE1 D_801C0910; // extern UNK_TYPE1 D_801C0924; // extern UNK_TYPE1 D_801C0938; // extern UNK_TYPE1 D_801C094C; -// extern UNK_TYPE4 D_801C0954; // extern UNK_TYPE4 D_801C0958; extern UNK_PTR D_801C095C; // extern UNK_TYPE1 D_801C0964; @@ -1281,26 +1263,17 @@ extern UNK_PTR D_801C0B0C; // extern UNK_TYPE1 D_801C0B20; // extern UNK_TYPE1 D_801C0B90; // extern UNK_TYPE4 D_801C0BA8; -// extern UNK_TYPE4 D_801C0BAC; -// extern UNK_TYPE4 D_801C0BB0; // extern UNK_TYPE1 D_801C0BB4; -// extern UNK_TYPE4 D_801C0BB8; // extern UNK_TYPE1 D_801C0BC0; // extern UNK_TYPE1 D_801C0BD0; // extern UNK_TYPE4 D_801C0BE0; -// extern UNK_TYPE4 D_801C0BE4; -// extern UNK_TYPE4 D_801C0BE8; // extern UNK_TYPE4 D_801C0BEC; -// extern UNK_TYPE4 D_801C0BF0; -// extern UNK_TYPE4 D_801C0BF4; // extern UNK_TYPE1 D_801C0BF8; // extern UNK_TYPE1 D_801C0BFC; // extern UNK_TYPE1 D_801C0C00; // extern UNK_TYPE4 D_801C0C0C; // extern UNK_TYPE1 D_801C0C30; // extern UNK_TYPE1 D_801C0C54; -// extern UNK_TYPE1 D_801C0C78; -// extern UNK_TYPE1 D_801C0C94; // extern UNK_TYPE1 D_801C0CA8; // extern UNK_TYPE4 D_801C0CE8; // extern UNK_TYPE1 D_801C0D24; @@ -1323,6 +1296,7 @@ extern UNK_PTR D_801C0B0C; // extern UNK_TYPE1 D_801C0EA0; // extern UNK_TYPE1 D_801C0EAC; // extern UNK_TYPE1 D_801C0EB8; + extern Gfx sSetupDL[438]; extern Gfx sFillSetupDL[12]; extern Gfx gEmptyDL[1]; @@ -1343,8 +1317,8 @@ extern u8 gItemSlots[]; extern s16 gItemPrices[]; extern u16 gScenesPerRegion[11][27]; extern u32 D_801C2410[]; -extern s16 gLinkFormObjectIndexes[8]; -extern RomFile objectFileTable[643]; +extern s16 gPlayerFormObjectIndices[8]; +extern RomFile gObjectTable[643]; extern SceneTableEntry gSceneTable[]; extern UNK_PTR D_801C5C50; // extern UNK_TYPE1 D_801C5C9C; @@ -1580,16 +1554,12 @@ extern s16 gHighPassFilterData[]; extern s16 gBandStopFilterData[]; extern s16 gBandPassFilterData[]; extern s16* gWaveSamples[9]; -extern UNK_PTR D_801D4D98; -extern UNK_PTR D_801D4DB0; extern f32 gBendPitchOneOctaveFrequencies[256]; -// extern UNK_TYPE1 D_801D4FB4; -// extern UNK_TYPE4 gBendPitchTwoSemitonesFrequencies; -// extern UNK_TYPE4 D_801D53B4; -// extern UNK_TYPE1 gPitchFrequencies; -// extern UNK_TYPE1 gDefaultShortNoteVelocityTable; -// extern UNK_TYPE1 gDefaultShortNoteGateTimeTable; -// extern UNK_TYPE1 gDefaultEnvelope; +extern f32 gBendPitchTwoSemitonesFrequencies[]; +extern f32 gPitchFrequencies[]; +extern u8 gDefaultShortNoteVelocityTable[]; +extern u8 gDefaultShortNoteGateTimeTable[]; +extern EnvelopePoint gDefaultEnvelope[]; extern NoteSubEu gZeroNoteSub; extern NoteSubEu gDefaultNoteSub; extern u16 gHeadsetPanQuantization[]; @@ -3212,8 +3182,6 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F59E0; // extern UNK_TYPE1 D_801F59E4; // extern UNK_TYPE1 D_801F59E8; -// extern UNK_TYPE1 D_801F59EC; -// extern UNK_TYPE1 D_801F59F0; // extern UNK_TYPE1 D_801F59F4; // extern UNK_TYPE1 D_801F59F8; // extern UNK_TYPE1 sSkyboxDrawMatrix; diff --git a/include/z64.h b/include/z64.h index 7970c73e7..06204a172 100644 --- a/include/z64.h +++ b/include/z64.h @@ -29,6 +29,7 @@ #include "z64animation.h" #include "z64audio.h" #include "z64bgcheck.h" +#include "z64camera.h" #include "z64collision_check.h" #include "z64curve.h" #include "z64cutscene.h" @@ -36,7 +37,9 @@ #include "z64effect.h" #include "z64item.h" #include "z64light.h" +#include "z64map.h" #include "z64math.h" +#include "z64message.h" #include "z64object.h" #include "z64ocarina.h" #include "z64player.h" @@ -46,6 +49,7 @@ #include "z64skin.h" #include "z64subs.h" #include "z64transition.h" +#include "z64view.h" #include "regs.h" #define Z_THREAD_ID_IDLE 1 @@ -66,10 +70,13 @@ #define Z_PRIORITY_DMAMGR 17 #define Z_PRIORITY_IRQMGR 18 -#define EQUIP_SLOT_B 0 -#define EQUIP_SLOT_C_LEFT 1 -#define EQUIP_SLOT_C_DOWN 2 -#define EQUIP_SLOT_C_RIGHT 3 +typedef enum { + /* 0 */ EQUIP_SLOT_B, + /* 1 */ EQUIP_SLOT_C_LEFT, + /* 2 */ EQUIP_SLOT_C_DOWN, + /* 3 */ EQUIP_SLOT_C_RIGHT, + /* 4 */ EQUIP_SLOT_A +} EquipSlot; typedef struct { /* 0x0 */ s16 priority; // Lower means higher priority. -1 means it ignores priority @@ -163,25 +170,6 @@ typedef struct FireObjLightParams { /* 0x5 */ Color_RGB8 maxColorAdj; } FireObjLightParams; // size = 0x8 -#define FONT_CHAR_TEX_WIDTH 16 -#define FONT_CHAR_TEX_HEIGHT 16 -//! @TODO: Make this use `sizeof(AnyFontTextureSymbol)` -#define FONT_CHAR_TEX_SIZE ((16 * 16) / 2) // 16x16 I4 texture - -// Font textures are loaded into here -typedef struct { - /* 0x00000 */ u8 charBuf[2][FONT_CHAR_TEX_SIZE * 120]; - /* 0x07800 */ u8 iconBuf[FONT_CHAR_TEX_SIZE]; - /* 0x07880 */ u8 fontBuf[FONT_CHAR_TEX_SIZE * 320]; - /* 0x11880 */ union { - u8 schar[640]; - u16 wchar[640]; - } msgBuf; - /* 0x11D80 */ u8* messageStart; - /* 0x11D84 */ u8* messageEnd; - /* 0x11D88 */ u8 unk_11D88; // current Char Buffer ? -} Font; // size = 0x11D8C - // Game Info aka. Static Context // Data normally accessed through REG macros (see regs.h) typedef struct { @@ -305,13 +293,6 @@ typedef struct { /* 0x3 */ s8 pillarboxMagnitude; } ShrinkWindowContext; // size = 0x4 -typedef struct { - /* 0x0 */ s32 topY; - /* 0x4 */ s32 bottomY; - /* 0x8 */ s32 leftX; - /* 0xC */ s32 rightX; -} Viewport; // size = 0x10 - typedef void(*osCreateThread_func)(void*); typedef enum { @@ -417,34 +398,6 @@ typedef struct { /* 0x10 */ Vec3f projectedPos; } SoundSource; // size = 0x1C -typedef struct { - /* 0x000 */ u32 magic; - /* 0x004 */ GraphicsContext* gfxCtx; - /* 0x008 */ Viewport viewport; - /* 0x018 */ f32 fovy; - /* 0x01C */ f32 zNear; - /* 0x020 */ f32 zFar; - /* 0x024 */ f32 scale; - /* 0x028 */ Vec3f eye; - /* 0x034 */ Vec3f at; - /* 0x040 */ Vec3f up; - /* 0x04C */ UNK_TYPE1 pad4C[0x4]; - /* 0x050 */ Vp vp; - /* 0x060 */ Mtx projection; - /* 0x0A0 */ Mtx viewing; - /* 0x0E0 */ Mtx unkE0; - /* 0x120 */ Mtx* projectionPtr; - /* 0x124 */ Mtx* viewingPtr; - /* 0x128 */ Vec3f distortionDirRot; - /* 0x134 */ Vec3f distortionScale; - /* 0x140 */ f32 distortionSpeed; - /* 0x144 */ Vec3f curDistortionDirRot; - /* 0x150 */ Vec3f curDistortionScale; - /* 0x15C */ u16 normal; - /* 0x160 */ u32 flags; // bit 3: Render to an orthographic perspective - /* 0x164 */ UNK_TYPE4 unk164; -} View; // size = 0x168 - typedef void(*fault_update_input_func)(Input* input); typedef struct { @@ -498,7 +451,7 @@ typedef struct { /* 0x258 */ s16 unk_258; /* 0x25A */ s16 unk_25A; /* 0x25C */ u16 unk_25C; - /* 0x25E */ u16 unk_25E[5]; // ItemId + /* 0x25E */ u16 cursorItem[5]; /* 0x268 */ u16 unk_268[5]; /* 0x272 */ u16 equipTargetItem; /* 0x274 */ u16 equipTargetSlot; @@ -551,7 +504,7 @@ typedef struct { /* 0x214 */ u16 unk_214; /* 0x218 */ f32 unk_218; /* 0x21C */ s16 unk_21C; - /* 0x21E */ s16 unk_21E; + /* 0x21E */ s16 bButtonDoAction; /* 0x220 */ s16 unk_220; /* 0x222 */ s16 unk_222; /* 0x224 */ s16 unk_224; @@ -587,7 +540,7 @@ typedef struct { /* 0x274 */ s16 minimapAlpha; /* 0x276 */ s16 startAlpha; /* 0x278 */ s16 unk_278; - /* 0x27A */ s16 unk_27A; + /* 0x27A */ s16 dungeonOrBossAreaMapIndex; /* 0x27C */ s16 mapRoomNum; /* 0x27E */ u8 unk_27E; /* 0x27F */ u8 unk_27F; @@ -786,102 +739,63 @@ typedef struct { /* 0x24 */ u32 flags; } PreRenderParams; // size = 0x28 -typedef struct { - /* 0x00 */ u8 unk00; - /* 0x01 */ u8 unk01; -} MsgCtx11F00; +#define TRANS_TRIGGER_OFF 0 // transition is not active +#define TRANS_TRIGGER_START 20 // start transition (exiting an area) +#define TRANS_TRIGGER_END -20 // transition is ending (arriving in a new area) -typedef struct { - /* 0x00000 */ View view; - /* 0x00168 */ Font font; - /* 0x11EF4 */ char unk_11EF4[0x4]; - /* 0x11EF8 */ UNK_PTR unk11EF8; - /* 0x11EFC */ UNK_TYPE1 unk11EFC[0x4]; - /* 0x11F00 */ MsgCtx11F00* unk11F00; - /* 0x11F04 */ u16 currentTextId; - /* 0x11F06 */ UNK_TYPE1 pad11F06[0x4]; - /* 0x11F0A */ u8 unk11F0A; - /* 0x11F0B */ UNK_TYPE1 pad11F0B[0x5]; - /* 0x11F10 */ s32 unk11F10; - /* 0x11F14 */ UNK_TYPE1 pad11F14[0x6]; - /* 0x11F1A */ s16 unk11F1A[3]; - /* 0x11F20 */ UNK_TYPE1 pad11F20[0x2]; - /* 0x11F22 */ u8 msgMode; - /* 0x11F23 */ UNK_TYPE1 pad11F23; - /* 0x11F24 */ union { - u8 schar[206]; - u16 wchar[103]; - } decodedBuffer; - /* 0x11FF2 */ u16 unk11FF2; - /* 0x11FF4 */ s16 unk11FF4; - /* 0x11FF6 */ s16 unk11FF6; - /* 0x11FF8 */ UNK_TYPE1 unk11FF8[0x6]; - /* 0x11FFE */ s16 unk11FFE[0x3]; - /* 0x12004 */ s16 unk12004; - /* 0x12006 */ s16 unk12006; - /* 0x12008 */ u8 unk12008[0x16]; - /* 0x1201E */ s16 unk1201E; - /* 0x12020 */ u8 unk12020; - /* 0x12021 */ u8 choiceIndex; - /* 0x12022 */ u8 unk12022; - /* 0x12023 */ u8 unk12023; - /* 0x12024 */ s16 unk12024; - /* 0x12026 */ u16 unk12026; - /* 0x12028 */ u16 songPlayed; - /* 0x1202A */ u16 ocarinaMode; - /* 0x1202C */ u16 ocarinaAction; - /* 0x1202E */ u16 unk1202E; - /* 0x12030 */ s16 unk_12030; - /* 0x12032 */ UNK_TYPE1 unk_12032[0x2]; - /* 0x12034 */ UNK_TYPE1 pad12034[0x6]; - /* 0x1203A */ s16 unk1203A; - /* 0x1203C */ s16 unk1203C; - /* 0x1203E */ s16 pad1203E; - /* 0x12040 */ Actor* unkActor; - /* 0x12044 */ s16 unk12044; - /* 0x12046 */ s16 unk12046; - /* 0x12048 */ u8 unk12048; // EnKakasi - /* 0x12049 */ UNK_TYPE1 pad12049[0x1]; - /* 0x1204A */ s16 unk1204A[0x5]; - /* 0x12054 */ s16 unk12054[3]; // First, second and third digits in lottery code guess - /* 0x1205A */ UNK_TYPE1 pad1205A[0xE]; - /* 0x12068 */ s16 unk12068; - /* 0x1206A */ s16 unk1206A; - /* 0x1206C */ s32 unk1206C; - /* 0x12070 */ s32 unk12070; - /* 0x12074 */ UNK_TYPE1 pad12074[0x4]; - /* 0x12078 */ s32 bankRupeesSelected; - /* 0x1207C */ s32 bankRupees; - /* 0x12080 */ MessageTableEntry* messageEntryTable; - /* 0x12084 */ MessageTableEntry* messageEntryTableNes; - /* 0x12088 */ UNK_TYPE4 unk12088; - /* 0x1208C */ MessageTableEntry* messageTableStaff; - /* 0x12090 */ s16 unk12090; - /* 0x12092 */ s16 unk12092; - /* 0x12094 */ s8 unk12094; - /* 0x12095 */ UNK_TYPE1 unk12095[0x3]; - /* 0x12098 */ f32 unk12098; // Text_Scale? - /* 0x1209C */ s16 unk1209C; - /* 0x1209E */ UNK_TYPE1 unk1209E[0x2]; - /* 0x120A0 */ s32 unk120A0; - /* 0x120A4 */ UNK_TYPE1 unk120A4[0xC]; - /* 0x120B0 */ u8 unk120B0; - /* 0x120B1 */ u8 unk120B1; - /* 0x120B2 */ u8 unk120B2[0xC]; - /* 0x120BE */ s16 unk120BE; - /* 0x120C0 */ s16 unk120C0; - /* 0x120C2 */ s16 unk120C2; - /* 0x120C4 */ s32 unk120C4; - /* 0x120C8 */ s16 unk120C8; - /* 0x120CA */ s16 unk120CA; - /* 0x120CC */ s16 unk120CC; - /* 0x120CE */ s16 unk120CE; - /* 0x120D0 */ s16 unk120D0; - /* 0x120D2 */ s16 unk120D2; - /* 0x120D4 */ s16 unk120D4; - /* 0x120D6 */ s16 unk120D6; - /* 0x120D8 */ UNK_TYPE1 pad120D8[0x8]; -} MessageContext; // size = 0x120E0 +typedef enum { + /* 0 */ TRANS_MODE_OFF, + /* 1 */ TRANS_MODE_01, + /* 2 */ TRANS_MODE_02, + /* 3 */ TRANS_MODE_03, + /* 4 */ TRANS_MODE_04, + /* 5 */ TRANS_MODE_05, + /* 6 */ TRANS_MODE_06, + /* 7 */ TRANS_MODE_07, + /* 8 */ TRANS_MODE_08, + /* 9 */ TRANS_MODE_09, + /* 10 */ TRANS_MODE_10, + /* 11 */ TRANS_MODE_11, + /* 12 */ TRANS_MODE_12, + /* 13 */ TRANS_MODE_13, + /* 14 */ TRANS_MODE_14, + /* 15 */ TRANS_MODE_15, + /* 16 */ TRANS_MODE_16, + /* 17 */ TRANS_MODE_17 +} TransitionMode; + +typedef enum { + /* 0 */ TRANS_TYPE_00, + /* 1 */ TRANS_TYPE_01, + /* 2 */ TRANS_TYPE_02, + /* 3 */ TRANS_TYPE_03, + /* 4 */ TRANS_TYPE_04, + /* 5 */ TRANS_TYPE_05, + /* 6 */ TRANS_TYPE_06, + /* 7 */ TRANS_TYPE_07, + /* 8 */ TRANS_TYPE_08, + /* 9 */ TRANS_TYPE_09, + /* 10 */ TRANS_TYPE_10, + /* 11 */ TRANS_TYPE_11, + /* 12 */ TRANS_TYPE_12, + /* 13 */ TRANS_TYPE_13, + /* 14 */ TRANS_TYPE_14, + /* 15 */ TRANS_TYPE_15, + /* 16 */ TRANS_TYPE_16, + /* 17 */ TRANS_TYPE_17, + /* 18 */ TRANS_TYPE_18, + /* 19 */ TRANS_TYPE_19, + /* 20 */ TRANS_TYPE_20, + /* 21 */ TRANS_TYPE_21, + /* 64 */ TRANS_TYPE_64 = 64, + /* 70 */ TRANS_TYPE_70 = 70, + /* 72 */ TRANS_TYPE_72 = 72, + /* 73 */ TRANS_TYPE_73, + /* 80 */ TRANS_TYPE_80 = 80, + /* 86 */ TRANS_TYPE_86 = 86 +} TransitionType; + +#define TRANS_NEXT_TYPE_DEFAULT 0xFF typedef struct FaultAddrConvClient { /* 0x0 */ struct FaultAddrConvClient* next; @@ -1003,73 +917,6 @@ typedef struct { /* 0x20 */ u32 unk20; } s801BB170; // size = 0x24 -typedef struct Camera { - /* 0x000 */ char paramData[0x50]; - /* 0x050 */ Vec3f at; - /* 0x05C */ Vec3f eye; - /* 0x068 */ Vec3f up; - /* 0x074 */ Vec3f eyeNext; - /* 0x080 */ Vec3f skyboxOffset; - /* 0x08C */ struct PlayState* play; - /* 0x090 */ struct Player* player; - /* 0x094 */ PosRot playerPosRot; - /* 0x0A8 */ struct Actor* target; - /* 0x0AC */ PosRot targetPosRot; - /* 0x0C0 */ f32 rUpdateRateInv; - /* 0x0C4 */ f32 pitchUpdateRateInv; - /* 0x0C8 */ f32 yawUpdateRateInv; - /* 0x0CC */ f32 yOffsetUpdateRate; - /* 0x0D0 */ f32 xzOffsetUpdateRate; - /* 0x0D4 */ f32 fovUpdateRate; - /* 0x0D8 */ f32 xzSpeed; - /* 0x0DC */ f32 dist; - /* 0x0E0 */ f32 speedRatio; - /* 0x0E4 */ Vec3f posOffset; - /* 0x0F0 */ Vec3f playerPosDelta; - /* 0x0FC */ f32 fov; - /* 0x100 */ f32 atLERPStepScale; - /* 0x104 */ f32 playerGroundY; - /* 0x108 */ Vec3f floorNorm; - /* 0x114 */ f32 waterYPos; - /* 0x118 */ s32 waterPrevCamIdx; - /* 0x11C */ s32 waterPrevCamSetting; - /* 0x120 */ s16 waterQuakeId; - /* 0x122 */ s16 unk122; - /* 0x124 */ void* data0; - /* 0x128 */ void* data1; - /* 0x12C */ s16 data2; - /* 0x12E */ s16 data3; - /* 0x130 */ s16 uid; - /* 0x132 */ UNK_TYPE1 pad132[2]; - /* 0x134 */ Vec3s inputDir; - /* 0x13A */ Vec3s camDir; - /* 0x140 */ s16 status; - /* 0x142 */ s16 setting; - /* 0x144 */ s16 mode; - /* 0x146 */ s16 bgCheckId; - /* 0x148 */ s16 camDataIdx; - /* 0x14A */ s16 flags1; - /* 0x14C */ s16 flags2; - /* 0x14E */ s16 childCamIdx; - /* 0x150 */ s16 unk150; - /* 0x152 */ s16 unk152; - /* 0x154 */ s16 prevSetting; - /* 0x156 */ s16 nextCamDataIdx; - /* 0x158 */ s16 nextBGCheckId; - /* 0x15A */ s16 roll; - /* 0x15C */ s16 paramFlags; - /* 0x15E */ s16 animState; - /* 0x160 */ s16 unk160; - /* 0x162 */ s16 timer; - /* 0x164 */ s16 camId; - /* 0x166 */ s16 prevCamDataIdx; - /* 0x168 */ s16 unk168; - /* 0x16A */ s16 unk16A; - /* 0x16C */ Vec3f meshActorPos; -} Camera; // size = 0x178 - -typedef s32(*camera_update_func)(Camera* camera); - typedef struct { /* 0x00 */ Vec3f atOffset; /* 0x0C */ Vec3f eyeOffset; @@ -1265,9 +1112,9 @@ struct PlayState { /* 0x000B4 */ char unk_B4[0x4]; /* 0x000B8 */ View view; /* 0x00220 */ Camera mainCamera; - /* 0x00398 */ Camera subCameras[3]; - /* 0x00800 */ Camera* cameraPtrs[4]; - /* 0x00810 */ s16 activeCamera; + /* 0x00398 */ Camera subCameras[NUM_CAMS - CAM_ID_SUB_FIRST]; + /* 0x00800 */ Camera* cameraPtrs[NUM_CAMS]; + /* 0x00810 */ s16 activeCamId; /* 0x00812 */ s16 nextCamera; /* 0x00814 */ SoundContext soundCtx; /* 0x00818 */ LightContext lightCtx; @@ -1299,7 +1146,7 @@ struct PlayState { /* 0x18788 */ void (*talkWithPlayer)(struct PlayState* play, Actor* actor); /* 0x1878C */ void (*unk_1878C)(struct PlayState* play); /* 0x18790 */ void (*unk_18790)(struct PlayState* play, s16 arg1, Actor* actor); - /* 0x18794 */ void* unk_18794; //! @TODO: Determine function prototype + /* 0x18794 */ s32 (*unk_18794)(struct PlayState* play, Player* player, s32 arg2, s32 arg3); /* 0x18798 */ s32 (*setPlayerTalkAnim)(struct PlayState* play, void* talkAnim, s32 arg2); /* 0x1879C */ s16 playerActorCsIds[10]; /* 0x187B0 */ MtxF viewProjectionMtxF; @@ -1322,20 +1169,20 @@ struct PlayState { /* 0x1886C */ AnimatedMaterial* sceneMaterialAnims; /* 0x18870 */ void* specialEffects; /* 0x18874 */ u8 skyboxId; - /* 0x18875 */ s8 sceneLoadFlag; // "fade_direction" + /* 0x18875 */ s8 transitionTrigger; // "fade_direction" /* 0x18876 */ s16 unk_18876; /* 0x18878 */ s16 bgCoverAlpha; /* 0x1887A */ u16 nextEntranceIndex; - /* 0x1887C */ s8 unk_1887C; + /* 0x1887C */ s8 unk_1887C; // shootingGalleryStatus? /* 0x1887D */ s8 unk_1887D; /* 0x1887E */ s8 unk_1887E; - /* 0x1887F */ u8 unk_1887F; // fadeTransition + /* 0x1887F */ u8 transitionType; // fadeTransition /* 0x18880 */ u8 unk_18880; /* 0x18884 */ CollisionCheckContext colChkCtx; /* 0x18B20 */ u16 envFlags[20]; /* 0x18B48 */ u8 curSpawn; /* 0x18B49 */ u8 unk_18B49; - /* 0x18B4A */ u8 unk_18B4A; + /* 0x18B4A */ u8 transitionMode; /* 0x18B4C */ PreRender pauseBgPreRender; /* 0x18B9C */ char unk_18B9C[0x2B8]; /* 0x18E54 */ SceneTableEntry* loadedScene; diff --git a/include/z64actor.h b/include/z64actor.h index 8412e735d..866b92dbb 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -80,6 +80,11 @@ typedef struct { /* 0x3A */ s16 unk3A; } ActorEnTest20C; // size = 0x3C +typedef struct { + /* 0x0 */ s16 unk_0; // frame? + /* 0x2 */ Vec3s unk_2; // pos? +} struct_80124618; // size = 0x8 + typedef struct { /* 0x00 */ s16 id; /* 0x02 */ u8 type; @@ -1133,7 +1138,7 @@ typedef enum { #define ACTOR_FLAG_2000 (1 << 13) // #define ACTOR_FLAG_4000 (1 << 14) -// +//! Carried by arrow #define ACTOR_FLAG_8000 (1 << 15) // #define ACTOR_FLAG_10000 (1 << 16) diff --git a/include/z64audio.h b/include/z64audio.h index 5dd78f73a..af104b6c2 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -8,9 +8,16 @@ #define TATUMS_PER_BEAT 48 #define IS_SEQUENCE_CHANNEL_VALID(ptr) ((uintptr_t)(ptr) != (uintptr_t)&gAudioContext.sequenceChannelNone) +#define SEQ_NUM_CHANNELS 16 #define MAX_CHANNELS_PER_BANK 3 +#define MUTE_FLAGS_3 (1 << 3) // prevent further noteSubEus from playing +#define MUTE_FLAGS_4 (1 << 4) // stop something in seqLayer scripts +#define MUTE_FLAGS_SOFTEN (1 << 5) // lower volume, by default to half +#define MUTE_FLAGS_STOP_NOTES (1 << 6) // prevent further notes from playing +#define MUTE_FLAGS_STOP_SCRIPT (1 << 7) // stop processing sequence/channel scripts + #define AUDIO_LERPIMP(v0, v1, t) (v0 + ((v1 - v0) * t)) #define ADSR_DISABLE 0 @@ -86,12 +93,12 @@ typedef enum { } AudioCacheType; typedef enum { - /* 0 */ LOAD_STATUS_0, - /* 1 */ LOAD_STATUS_1, - /* 2 */ LOAD_STATUS_2, // Samples/Seqplayer - /* 3 */ LOAD_STATUS_3, // Sequences - /* 4 */ LOAD_STATUS_4, // SoundFonts - /* 5 */ LOAD_STATUS_5 // Permanent + /* 0 */ LOAD_STATUS_NOT_LOADED, + /* 1 */ LOAD_STATUS_IN_PROGRESS, + /* 2 */ LOAD_STATUS_COMPLETE, + /* 3 */ LOAD_STATUS_DISCARDABLE, + /* 4 */ LOAD_STATUS_MAYBE_DISCARDABLE, + /* 5 */ LOAD_STATUS_PERMANENT } AudioLoadStatus; typedef s32 (*DmaHandler)(OSPiHandle* handle, OSIoMesg* mb, s32 direction); @@ -139,7 +146,7 @@ typedef struct { typedef struct { /* 0x0 */ s16 delay; /* 0x2 */ s16 arg; -} AdsrEnvelope; // size = 0x4 +} EnvelopePoint; // size = 0x4 typedef struct { /* 0x00 */ u32 start; @@ -231,19 +238,19 @@ typedef struct { /* 0x00 */ u8 loaded; /* 0x01 */ u8 normalRangeLo; /* 0x02 */ u8 normalRangeHi; - /* 0x03 */ u8 releaseRate; - /* 0x04 */ AdsrEnvelope* envelope; + /* 0x03 */ u8 adsrDecayIndex; // index used to obtain adsr decay rate from adsrDecayTable + /* 0x04 */ EnvelopePoint* envelope; /* 0x08 */ SoundFontSound lowNotesSound; /* 0x10 */ SoundFontSound normalNotesSound; /* 0x18 */ SoundFontSound highNotesSound; } Instrument; // size = 0x20 typedef struct { - /* 0x00 */ u8 releaseRate; + /* 0x00 */ u8 adsrDecayIndex; // index used to obtain adsr decay rate from adsrDecayTable /* 0x01 */ u8 pan; /* 0x02 */ u8 loaded; /* 0x04 */ SoundFontSound sound; - /* 0x14 */ AdsrEnvelope* envelope; + /* 0x14 */ EnvelopePoint* envelope; } Drum; // size = 0x18 typedef struct { @@ -277,11 +284,11 @@ typedef struct { /* 0x000 */ u8 applyBend : 1; /* 0x001 */ u8 state; /* 0x002 */ u8 noteAllocPolicy; - /* 0x003 */ u8 muteBehavior; + /* 0x003 */ u8 muteFlags; /* 0x004 */ u8 seqId; /* 0x005 */ u8 defaultFont; /* 0x006 */ u8 unk_06[1]; - /* 0x007 */ s8 playerIdx; + /* 0x007 */ s8 playerIndex; /* 0x008 */ u16 tempo; // tatums per minute /* 0x00A */ u16 tempoAcc; /* 0x00C */ s16 unk_0C; @@ -289,7 +296,7 @@ typedef struct { /* 0x010 */ u16 delay; /* 0x012 */ u16 fadeTimer; /* 0x014 */ u16 fadeTimerUnkEu; - /* 0x016 */ u16 unk_16; // New to MM + /* 0x016 */ u16 unk_16; union { /* 0x018 */ u8* seqData; /* 0x018 */ u16* seqData16; @@ -313,9 +320,9 @@ typedef struct { } SequencePlayer; // size = 0x160 typedef struct { - /* 0x0 */ u8 releaseRate; + /* 0x0 */ u8 decayIndex; // index used to obtain adsr decay rate from adsrDecayTable /* 0x1 */ u8 sustain; - /* 0x4 */ AdsrEnvelope* envelope; + /* 0x4 */ EnvelopePoint* envelope; } AdsrSettings; // size = 0x8 typedef struct { @@ -337,7 +344,7 @@ typedef struct { /* 0x10 */ f32 current; /* 0x14 */ f32 target; /* 0x18 */ char unk_18[4]; - /* 0x1C */ AdsrEnvelope* envelope; + /* 0x1C */ EnvelopePoint* envelope; } AdsrState; // size = 0x20 typedef struct { @@ -356,7 +363,7 @@ typedef union { typedef struct { /* 0x00 */ u8 reverb; - /* 0x01 */ u8 unk_1; + /* 0x01 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number /* 0x02 */ u8 pan; /* 0x03 */ u8 unk_3; // Possibly part of stereo? /* 0x04 */ Stereo stereo; @@ -397,7 +404,7 @@ typedef struct SequenceChannel { /* 0x01 */ u8 asByte; } changes; /* 0x02 */ u8 noteAllocPolicy; - /* 0x03 */ u8 muteBehavior; + /* 0x03 */ u8 muteFlags; /* 0x04 */ u8 reverb; // or dry/wet mix /* 0x05 */ u8 notePriority; // 0-3 /* 0x06 */ u8 someOtherPriority; @@ -406,12 +413,12 @@ typedef struct SequenceChannel { /* 0x09 */ u8 bookOffset; /* 0x0A */ u8 newPan; /* 0x0B */ u8 panChannelWeight; // proportion of pan that comes from the channel (0..128) - /* 0x0C */ u8 unk_0C; + /* 0x0C */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number /* 0x0D */ u8 velocityRandomVariance; /* 0x0E */ u8 gateTimeRandomVariance; /* 0x0F */ u8 unk_0F; - /* 0x10 */ u8 unk_10; // New to MM - /* 0x11 */ u8 unk_11; // New to MM + /* 0x10 */ u8 unk_10; + /* 0x11 */ u8 unk_11; /* 0x12 */ VibratoSubStruct vibrato; /* 0x20 */ u16 delay; /* 0x22 */ u16 unk_20; @@ -434,11 +441,11 @@ typedef struct SequenceChannel { /* 0x80 */ AdsrSettings adsr; /* 0x88 */ NotePool notePool; /* 0xC8 */ s8 soundScriptIO[8]; // bridge between sound script and audio lib, "io ports" - /* 0xD0 */ u8* unk_D0; // New to MM + /* 0xD0 */ u8* sfxState; /* 0xD4 */ s16* filter; /* 0xD8 */ Stereo stereo; - /* 0xDC */ s32 unk_DC; // New to MM - /* 0xE0 */ s32 unk_E0; // New to MM + /* 0xDC */ s32 unk_DC; + /* 0xE0 */ s32 unk_E0; } SequenceChannel; // size = 0xE4 // Might also be known as a Track, according to sm64 debug strings (?). @@ -531,7 +538,7 @@ typedef struct { /* 0x04 */ u8 reverbVol; /* 0x05 */ u8 numParts; /* 0x06 */ u16 samplePosFrac; - /* 0x08 */ u16 unk_08; // New to MM + /* 0x08 */ u16 unk_08; /* 0x0C */ s32 samplePosInt; /* 0x10 */ NoteSynthesisBuffers* synthesisBuffers; /* 0x14 */ s16 curVolLeft; @@ -596,7 +603,7 @@ typedef struct { /* 0x01 */ u8 hasTwoParts : 1; /* 0x01 */ u8 usesHeadsetPanEffects2 : 1; } bitField1; - /* 0x02 */ u8 unk_2; + /* 0x02 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number /* 0x03 */ u8 headsetPanRight; /* 0x04 */ u8 headsetPanLeft; /* 0x05 */ u8 reverbVol; @@ -611,8 +618,8 @@ typedef struct { /* 0x10 */ s16* samples; // used for synthetic waves } sound; /* 0x14 */ s16* filter; - /* 0x18 */ u8 unk_18; // New to MM - /* 0x19 */ u8 unk_19; // New to MM + /* 0x18 */ u8 unk_18; + /* 0x19 */ u8 unk_19; /* 0x1A */ UNK_TYPE1 pad_1A[0x6]; } NoteSubEu; // size = 0x20 @@ -965,7 +972,7 @@ typedef struct { /* 0x4448 */ volatile u8 resetStatus; /* 0x4449 */ u8 audioResetSpecIdToLoad; /* 0x444C */ s32 audioResetFadeOutFramesLeft; - /* 0x4450 */ f32* unk_3520; // fadeOutVelocities for ADSR + /* 0x4450 */ f32* adsrDecayTable; // A table on the audio heap that stores decay rates used for ADSR /* 0x4454 */ u8* audioHeap; /* 0x4458 */ size_t audioHeapSize; /* 0x445C */ Note* notes; @@ -994,7 +1001,7 @@ typedef struct { typedef struct { /* 0x00 */ u8 reverbVol; - /* 0x01 */ u8 unk_1; + /* 0x01 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number /* 0x02 */ u8 pan; /* 0x03 */ u8 unk_3; /* 0x04 */ Stereo stereo; @@ -1050,7 +1057,7 @@ typedef struct { /* 0x218 */ u8 unk_4C; /* 0x219 */ u8 unk_4D; /* 0x21A */ u8 unk_4E; - /* 0x21B */ u8 unk_21B; // New to MM + /* 0x21B */ u8 unk_21B; } unk_D_8016E750; // size = 0x21C typedef struct { diff --git a/include/z64camera.h b/include/z64camera.h new file mode 100644 index 000000000..e3b3a4483 --- /dev/null +++ b/include/z64camera.h @@ -0,0 +1,387 @@ +#ifndef Z64CAMERA_H +#define Z64CAMERA_H + +#include "ultra64.h" + +// these two angle conversion macros are slightly inaccurate +#define CAM_DEG_TO_BINANG(degrees) (s16)((degrees) * ((f32)0xFFFF / 360) + .5f) +#define CAM_BINANG_TO_DEG(binang) ((f32)(binang) * (360.0001525f / 0xFFFF)) + +#define NUM_CAMS 4 + +// Camera IDs are indices into `cameraPtrs` +#define CAM_ID_MAIN 0 // The index of the main camera +#define CAM_ID_SUB_FIRST 1 // The index sub cameras start at +#define CAM_ID_NONE -1 // Used to indicate no camera. Can be used to default to the active camera in some scenarios + +#define SUB_CAM_ID_DONE 0 // Used in some actors for variables holding sub camera IDs to indicate "subcam is finished" + +// Camera behaviorFlags. Flags specifically for settings, modes, and bgCam +// Used to store current state, only CAM_BEHAVIOR_SETTING_1 and CAM_BEHAVIOR_BG_2 are read from and used in logic +// Setting (0x1, 0x10) +#define CAM_BEHAVIOR_SETTING_USE_PRIORITY (1 << 0) // Use settings priority system +#define CAM_BEHAVIOR_SETTING_2 (1 << 4) +// Mode (0x2, 0x20) +#define CAM_BEHAVIOR_MODE_1 (1 << 1) +#define CAM_BEHAVIOR_MODE_2 (1 << 5) +// bgCam (0x4, 0x40) +#define CAM_BEHAVIOR_BGCAM_1 (1 << 2) +#define CAM_BEHAVIOR_BGCAM_2 (1 << 6) + +// Camera stateFlags. Variety of generic flags +#define CAM_STATE_0 (1 << 0) // Must be set for the camera from changing settings based on the bg surface +#define CAM_STATE_1 (1 << 1) +#define CAM_STATE_2 (1 << 2) +#define CAM_STATE_3 (1 << 3) +#define CAM_STATE_4 (1 << 4) +#define CAM_STATE_5 (1 << 5) +#define CAM_STATE_6 (1 << 6) +#define CAM_STATE_7 (1 << 7) +#define CAM_STATE_UNDERWATER (1 << 8) +#define CAM_STATE_9 (1 << 9) +#define CAM_STATE_10 (1 << 10) // Surpresses the camera from changing settings based on the bg surface +#define CAM_STATE_11 (1 << 11) +#define CAM_STATE_12 (1 << 12) +#define CAM_STATE_13 (1 << 13) +#define CAM_STATE_14 (1 << 14) +#define CAM_STATE_15 ((s16)(1 << 15)) + +// Camera viewFlags. Set params related to view +#define CAM_VIEW_AT (1 << 0) // camera->at +#define CAM_VIEW_EYE (1 << 1) // camera->eye and camera->eyeNext +#define CAM_VIEW_UP (1 << 2) // camera->up +#define CAM_VIEW_TARGET (1 << 3) // camera->target +#define CAM_VIEW_TARGET_POS (1 << 4) // camera->targetPosRot.pos +#define CAM_VIEW_FOV (1 << 5) // camera->fov +#define CAM_VIEW_ROLL (1 << 6) // camera->roll + +/** + * Camera Status type + * Determines how much the camera is updated each frame + * Higher values represents higher levels of activity + */ +// Camera is on +#define CAM_STATUS_CUT 0 // The camera is not updated at all +#define CAM_STATUS_WAIT 1 // There is minimally/partially updated, action function is not run +#define CAM_STATUS_UNK3 3 // The camera is mostly updated including running its action function, but data is not set to view +#define CAM_STATUS_ACTIVE 7 // The camera is fully updated, info is sent to view +// Camera is off +#define CAM_STATUS_INACTIVE 0x100 + +typedef enum { + /* 0x00 */ CAM_SET_NONE, + /* 0x01 */ CAM_SET_NORMAL0, // Generic camera 0, used in various places "NORMAL0" + /* 0x02 */ CAM_SET_NORMAL3, // Generic camera 3, used in various places "NORMAL3" + /* 0x03 */ CAM_SET_PIVOT_DIVING, // Player diving from the surface of the water to underwater not as zora "CIRCLE5" + /* 0x04 */ CAM_SET_HORSE, // Reiding a horse "HORSE0" + /* 0x05 */ CAM_SET_ZORA_DIVING, // Parallel's Pivot Diving, but as Zora. However, Zora does not dive like a human. So this setting appears to not be used "ZORA0" + /* 0x06 */ CAM_SET_PREREND_FIXED, // Unused remnant of OoT: camera is fixed in position and rotation "PREREND0" + /* 0x07 */ CAM_SET_PREREND_PIVOT, // Unused remnant of OoT: Camera is fixed in position with fixed pitch, but is free to rotate in the yaw direction 360 degrees "PREREND1" + /* 0x08 */ CAM_SET_DOORC, // Generic room door transitions, camera moves and follows player as the door is open and closed "DOORC" + /* 0x09 */ CAM_SET_DEMO0, // Unknown, possibly related to treasure chest game as goron? "DEMO0" + /* 0x0A */ CAM_SET_FREE0, // Free Camera, manual control is given, no auto-updating eye or at "FREE0" + /* 0x0B */ CAM_SET_BIRDS_EYE_VIEW_0, // Appears unused. Camera is a top-down view "FUKAN0" + /* 0x0C */ CAM_SET_NORMAL1, // Generic camera 1, used in various places "NORMAL1" + /* 0x0D */ CAM_SET_NANAME, // Unknown, slanted or tilted. Behaves identical to Normal0 except with added roll "NANAME" + /* 0x0E */ CAM_SET_CIRCLE0, // Used in Curiosity Shop, Pirates Fortress, Mayor's Residence "CIRCLE0" + /* 0x0F */ CAM_SET_FIXED0, // Used in Sakon's Hideout puzzle rooms, milk bar stage "FIXED0" + /* 0x10 */ CAM_SET_SPIRAL_DOOR, // Exiting a Spiral Staircase "SPIRAL" + /* 0x11 */ CAM_SET_DUNGEON0, // Generic dungeon camera 0, used in various places "DUNGEON0" + /* 0x12 */ CAM_SET_ITEM0, // Getting an item and holding it above Player's head (from small chest, freestanding, npc, ...) "ITEM0" + /* 0x13 */ CAM_SET_ITEM1, // Looking at player while playing the ocarina "ITEM1" + /* 0x14 */ CAM_SET_ITEM2, // Bottles: drinking, releasing fairy, dropping fish "ITEM2" + /* 0x15 */ CAM_SET_ITEM3, // Bottles: catching fish or bugs, showing an item "ITEM3" + /* 0x16 */ CAM_SET_NAVI, // Song of Soaring, variations of playing Song of Time "NAVI" + /* 0x17 */ CAM_SET_WARP_PAD_MOON, // Warp circles from Goron Trial on the moon "WARP0" + /* 0x18 */ CAM_SET_DEATH, // Player death animation when health goes to 0 "DEATH" + /* 0x19 */ CAM_SET_REBIRTH, // Unknown set with camDataId = -9 (it's not being revived by a fairy) "REBIRTH" + /* 0x1A */ CAM_SET_LONG_CHEST_OPENING, // Long cutscene when opening a big chest with a major item "TREASURE" + /* 0x1B */ CAM_SET_MASK_TRANSFORMATION, // Putting on a transformation mask "TRANSFORM" + /* 0x1C */ CAM_SET_ATTENTION, // Unknown, set with camDataId = -15 "ATTENTION" + /* 0x1D */ CAM_SET_WARP_PAD_ENTRANCE, // Warp pad from start of a dungeon to the boss-room "WARP1" + /* 0x1E */ CAM_SET_DUNGEON1, // Generic dungeon camera 1, used in various places "DUNGEON1" + /* 0x1F */ CAM_SET_FIXED1, // Fixes camera in place, used in various places eg. entering Stock Pot Inn, hiting a switch, giving witch a red potion, shop browsing "FIXED1" + /* 0x20 */ CAM_SET_FIXED2, // Used in Pinnacle Rock after defeating Sea Monsters, and by Tatl in Fortress "FIXED2" + /* 0x21 */ CAM_SET_MAZE, // Unused. Set to use Camera_Parallel2(), which is only Camera_Noop() "MAZE" + /* 0x22 */ CAM_SET_REMOTEBOMB, // Unused. Set to use Camera_Parallel2(), which is only Camera_Noop(). But also related to Play_ChangeCameraSetting? "REMOTEBOMB" + /* 0x23 */ CAM_SET_CIRCLE1, // Unknown "CIRCLE1" + /* 0x24 */ CAM_SET_CIRCLE2, // Looking at far-away NPCs eg. Garo in Road to Ikana, Hungry Goron, Tingle "CIRCLE2" + /* 0x25 */ CAM_SET_CIRCLE3, // Used in curiosity shop, goron racetrack, final room in Sakon's hideout, other places "CIRCLE3" + /* 0x26 */ CAM_SET_CIRCLE4, // Used during the races on the doggy racetrack "CIRCLE4" + /* 0x27 */ CAM_SET_FIXED3, // Used in Stock Pot Inn Toilet and Tatl cutscene after woodfall "FIXED3" + /* 0x28 */ CAM_SET_TOWER_ASCENT, // Various climbing structures (Snowhead climb to the temple entrance) "TOWER0" + /* 0x29 */ CAM_SET_PARALLEL0, // Unknown "PARALLEL0" + /* 0x2A */ CAM_SET_NORMALD, // Unknown, set with camDataId = -20 "NORMALD" + /* 0x2B */ CAM_SET_SUBJECTD, // Unknown, set with camDataId = -21 "SUBJECTD" + /* 0x2C */ CAM_SET_START0, // Entering a room, either Dawn of a New Day reload, or entering a door where the camera is fixed on the other end "START0" + /* 0x2D */ CAM_SET_START2, // Entering a scene, camera is put at a low angle eg. Grottos, Deku Palace, Stock Pot Inn "START2" + /* 0x2E */ CAM_SET_STOP0, // Called in z_play "STOP0" + /* 0x2F */ CAM_SET_BOAT_CRUISE, // Koume's boat cruise "JCRUISING" + /* 0x30 */ CAM_SET_VERTICAL_CLIMB, // Large vertical climbs, such as Mountain Village wall or Pirates Fortress ladder. "CLIMBMAZE" + /* 0x31 */ CAM_SET_SIDED, // Unknown, set with camDataId = -24 "SIDED" + /* 0x32 */ CAM_SET_DUNGEON2, // Generic dungeon camera 2, used in various places "DUNGEON2" + /* 0x33 */ CAM_SET_BOSS_ODOLWA, // Odolwa's Lair, also used in GBT entrance: "BOSS_SHIGE" + /* 0x34 */ CAM_SET_KEEPBACK, // Unknown. Possibly related to climbing something? "KEEPBACK" + /* 0x35 */ CAM_SET_CIRCLE6, // Used in select regions from Ikana "CIRCLE6" + /* 0x36 */ CAM_SET_CIRCLE7, // Unknown "CIRCLE7" + /* 0x37 */ CAM_SET_MINI_BOSS, // Used during the various minibosses of the "CHUBOSS" + /* 0x38 */ CAM_SET_RFIXED1, // Talking to Koume stuck on the floor in woods of mystery "RFIXED1" + /* 0x39 */ CAM_SET_TREASURE_CHEST_MINIGAME, // Treasure Chest Shop in East Clock Town, minigame location "TRESURE1" + /* 0x3A */ CAM_SET_HONEY_AND_DARLING_1, // Honey and Darling Minigames "BOMBBASKET" + /* 0x3B */ CAM_SET_CIRCLE8, // Used by Stone Tower moving platforms, Falling eggs in Marine Lab, Bugs into soilpatch cutscene "CIRCLE8" + /* 0x3C */ CAM_SET_BIRDS_EYE_VIEW_1, // Camera is a top-down view. Used in Fisherman's minigame and Deku Palace "FUKAN1" + /* 0x3D */ CAM_SET_DUNGEON3, // Generic dungeon camera 3, used in various places "DUNGEON3" + /* 0x3E */ CAM_SET_TELESCOPE, // Observatory telescope and Curiosity Shop Peep-Hole "TELESCOPE" + /* 0x3F */ CAM_SET_ROOM0, // Certain rooms eg. inside the clock tower "ROOM0" + /* 0x40 */ CAM_SET_RCIRC0, // Used by a few NPC cutscenes, focus close on the NPC "RCIRC0" + /* 0x41 */ CAM_SET_CIRCLE9, // Used by Sakon Hideout entrance and Deku Palace Maze "CIRCLE9" + /* 0x42 */ CAM_SET_ONTHEPOLE, // Somewhere in Snowhead Temple and Woodfall Temple "ONTHEPOLE" + /* 0x43 */ CAM_SET_INBUSH, // Various bush environments eg. grottos, Swamp Spider House, Termina Field grass bushes, Deku Palace near bean "INBUSH" + /* 0x44 */ CAM_SET_BOSS_MAJORA, // Majora's Lair: "BOSS_LAST" + /* 0x45 */ CAM_SET_BOSS_TWINMOLD, // Twinmold's Lair: "BOSS_INI" + /* 0x46 */ CAM_SET_BOSS_GOHT, // Goht's Lair: "BOSS_HAK" + /* 0x47 */ CAM_SET_BOSS_GYORG, // Gyorg's Lair: "BOSS_KON" + /* 0x48 */ CAM_SET_CONNECT0, // Smoothly and gradually return camera to Player after a cutscene "CONNECT0" + /* 0x49 */ CAM_SET_PINNACLE_ROCK, // Pinnacle Rock pit "MORAY" + /* 0x4A */ CAM_SET_NORMAL2, // Generic camera 2, used in various places "NORMAL2" + /* 0x4B */ CAM_SET_HONEY_AND_DARLING_2, // "BOMBBOWL" + /* 0x4C */ CAM_SET_CIRCLEA, // Unknown, Circle 10 "CIRCLEA" + /* 0x4D */ CAM_SET_WHIRLPOOL, // Great Bay Temple Central Room Whirlpool "WHIRLPOOL" + /* 0x4E */ CAM_SET_CUCCO_SHACK, // "KOKKOGAME" + /* 0x4F */ CAM_SET_GIANT, // Giants Mask in Twinmold's Lair "GIANT" + /* 0x50 */ CAM_SET_SCENE0, // Entering doors to a new scene "SCENE0" + /* 0x51 */ CAM_SET_ROOM1, // Certain rooms eg. some rooms in Stock Pot Inn "ROOM1" + /* 0x52 */ CAM_SET_WATER2, // Swimming as Zora in Great Bay Temple "WATER2" + /* 0x53 */ CAM_SET_WOODFALL_SWAMP, // Woodfall inside the swamp, but not on the platforms, "SOKONASI" + /* 0x54 */ CAM_SET_FORCEKEEP, // Unknown "FORCEKEEP" + /* 0x55 */ CAM_SET_PARALLEL1, // Unknown "PARALLEL1" + /* 0x56 */ CAM_SET_START1, // Used when entering the lens cave "START1" + /* 0x57 */ CAM_SET_ROOM2, // Certain rooms eg. Deku King's Chamber, Ocean Spider House "ROOM2" + /* 0x58 */ CAM_SET_NORMAL4, // Generic camera 4, used in Ikana Graveyard "NORMAL4" + /* 0x59 */ CAM_SET_ELEGY_SHELL, // cutscene after playing elegy of emptyness and spawning a shell "SHELL" + /* 0x5A */ CAM_SET_DUNGEON4, // Used in Pirates Fortress Interior, hidden room near hookshot "DUNGEON4" + /* 0x5B */ CAM_SET_MAX +} CameraSettingType; + +typedef enum { + /* 0x00 */ CAM_MODE_NORMAL, // "NORMAL" + /* 0x01 */ CAM_MODE_JUMP, // "JUMP" + /* 0x02 */ CAM_MODE_GORONDASH, // "GORONDASH" + /* 0x03 */ CAM_MODE_DEKUSHOOT, // "NUTSSHOT" + /* 0x04 */ CAM_MODE_BOWARROWZ, // "BOWARROWZ" + /* 0x05 */ CAM_MODE_DEKUFLY, // "NUTSFLY" + /* 0x06 */ CAM_MODE_FIRSTPERSON, // "SUBJECT" + /* 0x07 */ CAM_MODE_FOLLOWBOOMERANG, // "BOOKEEPON" + /* 0x08 */ CAM_MODE_ZORAFIN, // "ZORAFIN" + /* 0x09 */ CAM_MODE_FOLLOWTARGET, // "KEEPON" + /* 0x0A */ CAM_MODE_TARGET, // "PARALLEL" + /* 0x0B */ CAM_MODE_TALK, // "TALK" + /* 0x0C */ CAM_MODE_SLINGSHOT, // "PACHINCO" + /* 0x0D */ CAM_MODE_BOWARROW, // "BOWARROW" + /* 0x0E */ CAM_MODE_BATTLE, // "BATTLE" + /* 0x0F */ CAM_MODE_DEKUHIDE, // "NUTSHIDE" + /* 0x10 */ CAM_MODE_STILL, // "STILL" + /* 0x11 */ CAM_MODE_CHARGE, // "CHARGE" + /* 0x12 */ CAM_MODE_CLIMB, // "CLIMB" + /* 0x13 */ CAM_MODE_CLIMBZ, // "CLIMBZ" + /* 0x14 */ CAM_MODE_HOOKSHOT, // "FOOKSHOT" + /* 0x15 */ CAM_MODE_FREEFALL, // "FREEFALL" + /* 0x16 */ CAM_MODE_HANG, // "HANG" + /* 0x17 */ CAM_MODE_HANGZ, // "HANGZ + /* 0x18 */ CAM_MODE_PUSHPULL, // "PUSHPULL" + /* 0x19 */ CAM_MODE_DEKUFLYZ, // "CNUTSFLYZ" + /* 0x1A */ CAM_MODE_GORONJUMP, // "GORONJUMP" + /* 0x1B */ CAM_MODE_BOOMERANG, // "BOOMERANG" + /* 0x1C */ CAM_MODE_CHARGEZ, // "CHARGEZ" + /* 0x1D */ CAM_MODE_ZORAFINZ, // "ZORAFINZ" + /* 0x1E */ CAM_MODE_MAX +} CameraModeType; + +typedef enum { + /* 0x00 */ CAM_FUNC_NONE, + /* 0x01 */ CAM_FUNC_NORMAL0, + /* 0x02 */ CAM_FUNC_NORMAL1, + /* 0x03 */ CAM_FUNC_NORMAL2, + /* 0x04 */ CAM_FUNC_NORMAL3, + /* 0x05 */ CAM_FUNC_NORMAL4, + /* 0x06 */ CAM_FUNC_PARALLEL0, + /* 0x07 */ CAM_FUNC_PARALLEL1, + /* 0x08 */ CAM_FUNC_PARALLEL2, + /* 0x09 */ CAM_FUNC_PARALLEL3, + /* 0x0A */ CAM_FUNC_PARALLEL4, + /* 0x0B */ CAM_FUNC_KEEPON0, + /* 0x0C */ CAM_FUNC_KEEPON1, + /* 0x0D */ CAM_FUNC_KEEPON2, + /* 0x0E */ CAM_FUNC_KEEPON3, + /* 0x0F */ CAM_FUNC_KEEPON4, + /* 0x10 */ CAM_FUNC_SUBJECT0, + /* 0x11 */ CAM_FUNC_SUBJECT1, + /* 0x12 */ CAM_FUNC_SUBJECT2, + /* 0x13 */ CAM_FUNC_SUBJECT3, + /* 0x14 */ CAM_FUNC_SUBJECT4, + /* 0x15 */ CAM_FUNC_JUMP0, + /* 0x16 */ CAM_FUNC_JUMP1, + /* 0x17 */ CAM_FUNC_JUMP2, + /* 0x18 */ CAM_FUNC_JUMP3, + /* 0x19 */ CAM_FUNC_JUMP4, + /* 0x1A */ CAM_FUNC_BATTLE0, + /* 0x1B */ CAM_FUNC_BATTLE1, + /* 0x1C */ CAM_FUNC_BATTLE2, + /* 0x1D */ CAM_FUNC_BATTLE3, + /* 0x1E */ CAM_FUNC_BATTLE4, + /* 0x1F */ CAM_FUNC_FIXED0, + /* 0x20 */ CAM_FUNC_FIXED1, + /* 0x21 */ CAM_FUNC_FIXED2, + /* 0x22 */ CAM_FUNC_FIXED3, + /* 0x23 */ CAM_FUNC_FIXED4, + /* 0x24 */ CAM_FUNC_DATA0, + /* 0x25 */ CAM_FUNC_DATA1, + /* 0x26 */ CAM_FUNC_DATA2, + /* 0x27 */ CAM_FUNC_DATA3, + /* 0x28 */ CAM_FUNC_DATA4, + /* 0x29 */ CAM_FUNC_UNIQUE0, + /* 0x2A */ CAM_FUNC_UNIQUE1, + /* 0x2B */ CAM_FUNC_UNIQUE2, + /* 0x2C */ CAM_FUNC_UNIQUE3, + /* 0x2D */ CAM_FUNC_UNIQUE4, + /* 0x2E */ CAM_FUNC_UNIQUE5, + /* 0x2F */ CAM_FUNC_UNIQUE6, + /* 0x30 */ CAM_FUNC_UNIQUE7, + /* 0x31 */ CAM_FUNC_UNIQUE8, + /* 0x32 */ CAM_FUNC_UNIQUE9, + /* 0x33 */ CAM_FUNC_DEMO0, + /* 0x34 */ CAM_FUNC_DEMO1, + /* 0x35 */ CAM_FUNC_DEMO2, + /* 0x36 */ CAM_FUNC_DEMO3, + /* 0x37 */ CAM_FUNC_DEMO4, + /* 0x38 */ CAM_FUNC_DEMO5, + /* 0x39 */ CAM_FUNC_DEMO6, + /* 0x3A */ CAM_FUNC_DEMO7, + /* 0x3B */ CAM_FUNC_DEMO8, + /* 0x3C */ CAM_FUNC_DEMO9, + /* 0x3D */ CAM_FUNC_SPECIAL0, + /* 0x3E */ CAM_FUNC_SPECIAL1, + /* 0x3F */ CAM_FUNC_SPECIAL2, + /* 0x40 */ CAM_FUNC_SPECIAL3, + /* 0x41 */ CAM_FUNC_SPECIAL4, + /* 0x42 */ CAM_FUNC_SPECIAL5, + /* 0x43 */ CAM_FUNC_SPECIAL6, + /* 0x44 */ CAM_FUNC_SPECIAL7, + /* 0x45 */ CAM_FUNC_SPECIAL8, + /* 0x46 */ CAM_FUNC_SPECIAL9, + /* 0x47 */ CAM_FUNC_MAX +} CameraFuncType; + +typedef enum { + /* 0x00 */ CAM_DATA_00, + /* 0x01 */ CAM_DATA_01, + /* 0x02 */ CAM_DATA_02, + /* 0x03 */ CAM_DATA_03, + /* 0x04 */ CAM_DATA_04, + /* 0x05 */ CAM_DATA_05, + /* 0x06 */ CAM_DATA_06, + /* 0x07 */ CAM_DATA_07, + /* 0x08 */ CAM_DATA_08, + /* 0x09 */ CAM_DATA_09, + /* 0x0A */ CAM_DATA_10, + /* 0x0B */ CAM_DATA_11, + /* 0x0C */ CAM_DATA_12, + /* 0x0D */ CAM_DATA_13, + /* 0x0E */ CAM_DATA_14, + /* 0x0F */ CAM_DATA_15, + /* 0x10 */ CAM_DATA_16, + /* 0x11 */ CAM_DATA_17, + /* 0x12 */ CAM_DATA_18, + /* 0x13 */ CAM_DATA_19, + /* 0x14 */ CAM_DATA_20, + /* 0x15 */ CAM_DATA_21, +} CameraDataType; + +typedef struct { + /* 0x0 */ s16 val; + /* 0x2 */ s16 param; +} CameraModeValue; // size = 0x4 + +typedef struct { + /* 0x0 */ s16 funcId; + /* 0x2 */ s16 numValues; + /* 0x4 */ CameraModeValue* values; +} CameraMode; // size = 0x8 + +/** + * Flags: + * (flags & 0xF): Priority (lower value has higher priority) + * (flags & 0x40000000): Store previous setting and bgCamData, also ignores water checks + * (flags & 0x80000000): Set camera setting based on bg/scene data and reset action function state + */ +typedef struct { + /* 0x0 */ u32 validModes; + /* 0x4 */ u32 flags; + /* 0x8 */ CameraMode* cameraModes; +} CameraSetting; // size = 0xC + +typedef struct Camera { + /* 0x000 */ u8 paramData[0x50]; // function Data, acts like a heap that's reset every time a new action function is switched to + /* 0x050 */ Vec3f at; + /* 0x05C */ Vec3f eye; + /* 0x068 */ Vec3f up; + /* 0x074 */ Vec3f eyeNext; + /* 0x080 */ Vec3f quakeOffset; + /* 0x08C */ struct PlayState* play; + /* 0x090 */ Actor* focalActor; // the actor the camera is focused on. Most often Player, but can be any actor + /* 0x094 */ PosRot focalActorPosRot; + /* 0x0A8 */ Actor* target; // the actor that is being z-targeted + /* 0x0AC */ PosRot targetPosRot; + /* 0x0C0 */ f32 rUpdateRateInv; + /* 0x0C4 */ f32 pitchUpdateRateInv; + /* 0x0C8 */ f32 yawUpdateRateInv; + /* 0x0CC */ f32 yOffsetUpdateRate; + /* 0x0D0 */ f32 xzOffsetUpdateRate; + /* 0x0D4 */ f32 fovUpdateRate; + /* 0x0D8 */ f32 xzSpeed; + /* 0x0DC */ f32 dist; + /* 0x0E0 */ f32 speedRatio; + /* 0x0E4 */ Vec3f atActorOffset; + /* 0x0F0 */ Vec3f focalActorOffset; + /* 0x0FC */ f32 fov; + /* 0x100 */ f32 atLerpStepScale; + /* 0x104 */ f32 playerFloorHeight; + /* 0x108 */ Vec3f floorNorm; + /* 0x114 */ f32 waterYPos; + /* 0x118 */ s32 waterPrevBgCamDataId; + /* 0x11C */ s32 waterPrevCamSetting; + /* 0x120 */ s16 waterQuakeId; + /* 0x122 */ s16 unk122; + /* 0x124 */ void* data0; + /* 0x128 */ void* data1; + /* 0x12C */ s16 data2; + /* 0x12E */ s16 data3; + /* 0x130 */ s16 uid; + /* 0x132 */ UNK_TYPE1 unk_132[2]; + /* 0x134 */ Vec3s inputDir; + /* 0x13A */ Vec3s camDir; + /* 0x140 */ s16 status; + /* 0x142 */ s16 setting; + /* 0x144 */ s16 mode; + /* 0x146 */ s16 bgId; + /* 0x148 */ s16 bgCamDataId; + /* 0x14A */ s16 behaviorFlags; + /* 0x14C */ s16 stateFlags; + /* 0x14E */ s16 childCamId; + /* 0x150 */ s16 doorTimer1; // a door timer used when door cam is indexed from bgCamDataId + /* 0x152 */ s16 unk152; + /* 0x154 */ s16 prevSetting; + /* 0x156 */ s16 nextCamSceneDataId; + /* 0x158 */ s16 nextBgId; + /* 0x15A */ s16 roll; + /* 0x15C */ s16 viewFlags; + /* 0x15E */ s16 animState; // Determines the current state of the current camera behavior function + /* 0x160 */ s16 unk160; + /* 0x162 */ s16 doorTimer2; // a door timer used when door cam is indexed from bgCamDataId + /* 0x164 */ s16 camId; + /* 0x166 */ s16 prevBgCamDataId; + /* 0x168 */ s16 unk168; + /* 0x16C */ Vec3f meshActorPos; +} Camera; // size = 0x178 + +#endif diff --git a/include/z64cutscene.h b/include/z64cutscene.h index 41518505a..aa0681de5 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -178,7 +178,7 @@ typedef struct { /* 0x0C */ f32 unk_0C; /* 0x10 */ u16 frames; /* 0x12 */ u16 currentCsIndex; - /* 0x14 */ s32 csCamId; + /* 0x14 */ s32 subCamId; /* 0x18 */ u16 unk_18; /* 0x1A */ u8 unk_1A; /* 0x1B */ u8 unk_1B; diff --git a/include/z64effect.h b/include/z64effect.h index 937c55958..fb9d9e159 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -19,9 +19,9 @@ struct PlayState; /* G Effect Regs */ -#define rgTexIdx regs[0] +#define rgTexIndex regs[0] #define rgScale regs[1] -#define rgTexIdxStep regs[2] +#define rgTexIndexStep regs[2] #define rgPrimColorR regs[3] #define rgPrimColorG regs[4] #define rgPrimColorB regs[5] @@ -30,7 +30,7 @@ struct PlayState; #define rgEnvColorG regs[8] #define rgEnvColorB regs[9] #define rgEnvColorA regs[10] -#define rgObjBankIdx regs[11] +#define rgObjBankIndex regs[11] typedef struct { /* 0x00 */ u8 active; diff --git a/include/z64item.h b/include/z64item.h index 43c538a3f..cc05b528e 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -7,10 +7,27 @@ // TODO fill out these enums typedef enum { - /* 0x0 */ EQUIP_SWORD, - /* 0x1 */ EQUIP_SHIELD + /* 0x0 */ EQUIP_TYPE_SWORD, + /* 0x1 */ EQUIP_TYPE_SHIELD, + /* 0x2 */ EQUIP_TYPE_MAX } EquipmentType; +typedef enum { + /* 0 */ EQUIP_VALUE_SWORD_NONE, + /* 1 */ EQUIP_VALUE_SWORD_KOKIRI, + /* 2 */ EQUIP_VALUE_SWORD_RAZOR, + /* 3 */ EQUIP_VALUE_SWORD_GILDED, + /* 4 */ EQUIP_VALUE_SWORD_DIETY, + /* 5 */ EQUIP_VALUE_SWORD_MAX, +} EquipValueSword; + +typedef enum { + /* 0 */ EQUIP_VALUE_SHIELD_NONE, + /* 1 */ EQUIP_VALUE_SHIELD_HERO, + /* 2 */ EQUIP_VALUE_SHIELD_MIRROR, + /* 3 */ EQUIP_VALUE_SHIELD_MAX +} EquipValueShield; + typedef enum { /* 0x00 */ UPG_QUIVER, /* 0x01 */ UPG_BOMB_BAG, @@ -41,9 +58,11 @@ typedef enum { /* 0x0F */ QUEST_SONG_SOARING, /* 0x10 */ QUEST_SONG_STORMS, /* 0x11 */ QUEST_SONG_SUN, - /* 0x12 */ QUEST_BOMBERS_NOTEBOOK, + /* 0x12 */ QUEST_BOMBERS_NOTEBOOK, // Obtained Bombers Notebook + /* 0x13 */ QUEST_SKULL_TOKEN, /* 0x18 */ QUEST_SONG_LULLABY_INTRO = 0x18, - /* 0x19 */ QUEST_UNK_19 // Related to PictoBox + /* 0x19 */ QUEST_PICTOGRAPH, // A photo from the pictograph box is saved + /* 0x1C */ QUEST_HEART_PIECE_COUNT = 0x1C } QuestItem; typedef enum { @@ -261,10 +280,16 @@ typedef enum { /* 0xA1 */ ITEM_GOLD_DUST_2, /* 0xA2 */ ITEM_HYLIAN_LOACH_2, /* 0xA3 */ ITEM_SEA_HORSE_CAUGHT, - /* 0xFD */ ITEM_UNK_FD = 0xFD, + /* 0xF0 */ ITEM_F0 = 0xF0, + /* 0xF1 */ ITEM_F1, + /* 0xF2 */ ITEM_F2, + /* 0xFD */ ITEM_FD = 0xFD, /* 0xFF */ ITEM_NONE = 0xFF } ItemID; +#define BOTTLE_FIRST 0 +#define BOTTLE_MAX 6 + typedef enum { /* 0x00 */ GI_NONE, /* 0x01 */ GI_RUPEE_GREEN, @@ -307,6 +332,7 @@ typedef enum { /* 0x3D */ GI_KEY_BOSS, /* 0x3E */ GI_MAP, /* 0x3F */ GI_COMPASS, + /* 0x4C */ GI_OCARINA = 0x4C, /* 0x50 */ GI_50 = 0x50, /* 0x52 */ GI_SCALE_GOLD = 0x52, // Assumed, used in En_Fishing /* 0x59 */ GI_BOTTLE_POTION_RED = 0x59, @@ -404,20 +430,30 @@ typedef enum { /* 0x66 */ GID_SWORD_RAZOR = 0x66, /* 0x67 */ GID_SWORD_GILDED, /* 0x68 */ GID_SWORD_GREAT_FAIRY, - /* 0x6A */ GID_6A = 0x6A, + /* 0x6A */ GID_MASK_GREAT_FAIRY = 0x6A, /* 0x6B */ GID_6B, /* 0x70 */ GID_70 = 0x70, /* 0x71 */ GID_71 } GetItemDrawID; +// This enum may not be real, and actionparam is just used directly. +// Keep using it for now. // TODO: fill typedef enum { /* -1 */ EXCH_ITEM_MINUS1 = -1, // Unknown usage or function /* 0x00 */ EXCH_ITEM_NONE, /* 0x13 */ EXCH_ITEM_13 = 0x13, /* 0x1E */ EXCH_ITEM_1E = 0x1E, // BOTTLE_MUSHROOM - /* 0x2A */ EXCH_ITEM_2A = 0x2A, // MOON_TEAR? - /* 0x2E */ EXCH_ITEM_2E = 0x2E + /* 0x2A */ EXCH_ITEM_MOON_TEAR = 0x2A, + /* 0x2B */ EXCH_ITEM_DEED_LAND, + /* 0x2C */ EXCH_ITEM_ROOM_KEY, + /* 0x2D */ EXCH_ITEM_LETTER_TO_KAFEI, + /* 0x2E */ EXCH_ITEM_2E, + /* 0x2F */ EXCH_ITEM_DEED_SWAMP, + /* 0x30 */ EXCH_ITEM_DEED_MOUNTAIN, + /* 0x31 */ EXCH_ITEM_DEED_OCEAN, + /* 0x32 */ EXCH_ITEM_32, + /* 0x33 */ EXCH_ITEM_LETTER_MAMA } ExchangeItemID; #endif diff --git a/include/z64map.h b/include/z64map.h index 075f4dc6e..bbb37600f 100644 --- a/include/z64map.h +++ b/include/z64map.h @@ -1,7 +1,28 @@ -#ifndef Z64_MAP_D_H -#define Z64_MAP_D_H +#ifndef Z64MAP_H +#define Z64MAP_H #include "ultra64.h" +#define FLOOR_INDEX_MAX 4 + +/* z_scene */ +typedef struct { + /* 0x00 */ u16 unk0; + /* 0x02 */ s16 unk2; + /* 0x04 */ UNK_TYPE2 unk4; + /* 0x06 */ s16 unk6; + /* 0x08 */ u16 unk8; +} MinimapEntry; // size = 0xA + +typedef struct { + /* 0x00 */ MinimapEntry* entry; + /* 0x04 */ s32 unk4; +} MinimapList; // size = 0x8 + +typedef struct { + /* 0x00 */ MinimapEntry* entry; + /* 0x04 */ s16 unk4; +} MinimapList2; // size = 0x8 + /* z_map_data */ typedef struct { @@ -45,7 +66,7 @@ typedef struct { } T_801BEBB8_unk48; typedef struct { - /* 0x00 */ MinimapList* unk0; //unk0 -> sub1 -> s16[5] + /* 0x00 */ MinimapList2* unk0; //unk0 -> sub1 -> s16[5] /* 0x04 */ s32 unk4; /* 0x08 */ s16 unk8; /* 0x0A */ s16 unkA; diff --git a/include/z64math.h b/include/z64math.h index 0095e12ab..3732222cc 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -111,11 +111,9 @@ typedef struct { // Angle conversion macros #define DEG_TO_BINANG(degrees) (s16)((degrees) * (0x8000 / 180.0f)) -#define DEGF_TO_BINANG(degreesf) (s16)((degreesf) * 182.04167f + .5f) #define RADF_TO_BINANG(radf) (s16)((radf) * (0x8000 / M_PI)) #define RADF_TO_DEGF(radf) ((radf) * (180.0f / M_PI)) #define DEGF_TO_RADF(degf) ((degf) * (M_PI / 180.0f)) -#define BINANG_TO_DEGF(binang) ((f32)binang * (360.0001525f / 65535.0f)) #define BINANG_TO_RAD(binang) (((f32)binang / 0x8000) * M_PI) // Angle arithmetic macros diff --git a/include/z64message.h b/include/z64message.h new file mode 100644 index 000000000..19657d838 --- /dev/null +++ b/include/z64message.h @@ -0,0 +1,179 @@ +#ifndef Z64MESSAGE_H +#define Z64MESSAGE_H + +#include "PR/ultratypes.h" +#include "z64view.h" +#include "unk.h" + +struct Actor; +struct MessageTableEntry; +struct OcarinaStaff; + +typedef enum TextState { + /* 0 */ TEXT_STATE_NONE, + /* 1 */ TEXT_STATE_1, + /* 2 */ TEXT_STATE_CLOSING, + /* 3 */ TEXT_STATE_3, + /* 4 */ TEXT_STATE_CHOICE, + /* 5 */ TEXT_STATE_5, + /* 6 */ TEXT_STATE_DONE, + /* 7 */ TEXT_STATE_7, + /* 8 */ TEXT_STATE_8, + /* 9 */ TEXT_STATE_9, + /* 10 */ TEXT_STATE_10, + /* 11 */ TEXT_STATE_11, + /* 12 */ TEXT_STATE_12, + /* 13 */ TEXT_STATE_13, + /* 14 */ TEXT_STATE_14, + /* 15 */ TEXT_STATE_15, + /* 16 */ TEXT_STATE_16, + /* 17 */ TEXT_STATE_17, + /* 18 */ TEXT_STATE_18 +} TextState; + + +#define FONT_CHAR_TEX_WIDTH 16 +#define FONT_CHAR_TEX_HEIGHT 16 +//! @TODO: Make this use `sizeof(AnyFontTextureSymbol)` +#define FONT_CHAR_TEX_SIZE ((16 * 16) / 2) // 16x16 I4 texture + +// TODO: should Font be in its own header or is it fine to have it here? +// Font textures are loaded into here +typedef struct { + /* 0x00000 */ union { + u8 charBuf[2][FONT_CHAR_TEX_SIZE * 120]; + u64 force_structure_alignment_charTex; + }; + /* 0x07800 */ union { + u8 iconBuf[FONT_CHAR_TEX_SIZE]; + u64 force_structure_alignment_icon; + }; + /* 0x07880 */ union { + u8 fontBuf[FONT_CHAR_TEX_SIZE * 320]; + u64 force_structure_alignment_font; + }; + /* 0x11880 */ union { + char schar[1280]; // msgBuf + u16 wchar[640]; // msgBufWide + u64 force_structure_alignment_msg; + } msgBuf; + /* 0x11D80 */ u8* messageStart; + /* 0x11D84 */ u8* messageEnd; + /* 0x11D88 */ u8 unk_11D88; // current Char Buffer ? +} Font; // size = 0x11D90 + +typedef struct MessageContext { + /* 0x00000 */ View view; + /* 0x00168 */ Font font; + /* 0x11EF8 */ UNK_PTR unk11EF8; + /* 0x11EFC */ UNK_TYPE1 unk11EFC[0x4]; + /* 0x11F00 */ struct OcarinaStaff* unk11F00; + /* 0x11F04 */ u16 currentTextId; + /* 0x11F06 */ UNK_TYPE1 unk11F06[0x2]; + /* 0x11F08 */ u16 unk11F08; + /* 0x11F0A */ u8 unk11F0A; + /* 0x11F0B */ s8 unk11F0B; + /* 0x11F0C */ s8 unk11F0C; + /* 0x11F0B */ UNK_TYPE1 unk11F0D[0x3]; + /* 0x11F10 */ s32 msgLength; + /* 0x11F14 */ u16 unk11F14; + /* 0x11F16 */ u16 unk11F16; + /* 0x11F18 */ s8 unk11F18; + /* 0x11F19 */ UNK_TYPE1 unk11F19[0x1]; + /* 0x11F1A */ s16 unk11F1A[3]; + /* 0x11F20 */ UNK_TYPE1 unk11F20[0x2]; + /* 0x11F22 */ u8 msgMode; // TODO: MessageMode enum + /* 0x11F23 */ UNK_TYPE1 unk11F23; + /* 0x11F24 */ union { + char schar[200]; + u16 wchar[100]; + } decodedBuffer; + /* 0x11FEC */ u16 msgBufPos; + /* 0x11FEE */ s16 unk11FEE; + /* 0x11FF0 */ s16 unk11FF0; + /* 0x11FF2 */ u16 unk11FF2; + /* 0x11FF4 */ s16 unk11FF4; + /* 0x11FF6 */ s16 unk11FF6; + /* 0x11FF8 */ s16 unk11FF8; + /* 0x11FFA */ s16 unk11FFA; + /* 0x11FFC */ s16 unk11FFC; + /* 0x11FFE */ s16 unk11FFE[0x3]; + /* 0x12004 */ s16 unk12004; + /* 0x12006 */ s16 unk12006; + /* 0x12008 */ s16 unk12008; + /* 0x1200A */ UNK_TYPE2 unk1200A; + /* 0x1200C */ s16 unk1200C; + /* 0x1200E */ s16 unk1200E; + /* 0x12010 */ s16 unk12010; + /* 0x12012 */ s16 unk12012; + /* 0x12014 */ s16 unk12014; + /* 0x12014 */ s16 unk12016; + /* 0x12018 */ s16 unk12018; // messageR + /* 0x1201A */ s16 unk1201A; // messageG + /* 0x1201C */ s16 unk1201C; // messageB + /* 0x1201E */ s16 unk1201E; // messageA + /* 0x12020 */ u8 unk12020; // probably textboxEndType + /* 0x12021 */ u8 choiceIndex; + /* 0x12022 */ u8 unk12022; + /* 0x12023 */ u8 stateTimer; + /* 0x12024 */ s16 unk12024; + /* 0x12026 */ u16 unk12026; + /* 0x12028 */ u16 songPlayed; + /* 0x1202A */ u16 ocarinaMode; + /* 0x1202C */ u16 ocarinaAction; + /* 0x1202E */ u16 unk1202E; + /* 0x12030 */ s16 unk_12030; + /* 0x12032 */ UNK_TYPE1 unk_12032[0x2]; + /* 0x12034 */ s16 unk12034; + /* 0x12036 */ s16 unk12036; + /* 0x12038 */ s16 unk12038; + /* 0x1203A */ s16 unk1203A; + /* 0x1203C */ s16 unk1203C; + /* 0x1203E */ s16 unk1203E; + /* 0x12040 */ struct Actor* unkActor; + /* 0x12044 */ s16 unk12044; + /* 0x12046 */ s16 unk12046; + /* 0x12048 */ u8 unk12048; // EnKakasi + /* 0x12049 */ UNK_TYPE1 unk12049[0x1]; + /* 0x1204A */ s16 unk1204A[0x5]; + /* 0x12054 */ s16 unk12054[6]; // First, second and third digits in lottery code guess + /* 0x1205A */ UNK_TYPE1 unk12060[0x8]; + /* 0x12068 */ s16 unk12068; + /* 0x1206A */ s16 unk1206A; + /* 0x1206C */ s32 unk1206C; + /* 0x12070 */ s32 unk12070; + /* 0x12074 */ s32 unk12074; + /* 0x12078 */ s32 bankRupeesSelected; + /* 0x1207C */ s32 bankRupees; + /* 0x12080 */ struct MessageTableEntry* messageEntryTable; + /* 0x12084 */ struct MessageTableEntry* messageEntryTableNes; + /* 0x12088 */ UNK_TYPE4 unk12088; + /* 0x1208C */ struct MessageTableEntry* messageTableStaff; + /* 0x12090 */ s16 unk12090; + /* 0x12092 */ s16 unk12092; + /* 0x12094 */ s8 unk12094; + /* 0x12095 */ UNK_TYPE1 unk12095[0x3]; + /* 0x12098 */ f32 unk12098; // Text_Scale? + /* 0x1209C */ s16 unk1209C; + /* 0x1209E */ UNK_TYPE1 unk1209E[0x2]; + /* 0x120A0 */ s32 unk120A0; + /* 0x120A4 */ s16 unk120A4[6]; + /* 0x120B0 */ u8 unk120B0; + /* 0x120B1 */ u8 unk120B1; + /* 0x120B2 */ u8 unk120B2[0xC]; + /* 0x120BE */ s16 unk120BE; + /* 0x120C0 */ s16 unk120C0; + /* 0x120C2 */ s16 unk120C2; + /* 0x120C4 */ s32 unk120C4; + /* 0x120C8 */ s16 unk120C8; + /* 0x120CA */ s16 unk120CA; + /* 0x120CC */ s16 unk120CC; + /* 0x120CE */ s16 unk120CE; + /* 0x120D0 */ s16 unk120D0; + /* 0x120D2 */ s16 unk120D2; + /* 0x120D4 */ s16 unk120D4; + /* 0x120D6 */ s16 unk120D6; + /* 0x120D8 */ UNK_TYPE1 unk120D8[0x8]; +} MessageContext; // size = 0x120E0 + +#endif diff --git a/include/z64ocarina.h b/include/z64ocarina.h index 56ab48312..8cc82b51a 100644 --- a/include/z64ocarina.h +++ b/include/z64ocarina.h @@ -116,7 +116,7 @@ typedef struct { /* 0x1 */ u8 buttonIndex[8]; } OcarinaSongButtons; // size = 0x9 -typedef struct { +typedef struct OcarinaStaff { /* 0x0 */ u8 buttonIndex; /* 0x1 */ u8 state; // original name: "status" /* 0x2 */ u8 pos; // original name: "locate" diff --git a/include/z64player.h b/include/z64player.h index b37a5335f..86adaea1e 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -24,6 +24,14 @@ typedef enum { /* 0x07 */ PLAYER_BOOTS_MAX } PlayerBoots; +typedef enum { + /* 0x00 */ PLAYER_STRENGTH_DEKU, + /* 0x01 */ PLAYER_STRENGTH_HUMAN, + /* 0x02 */ PLAYER_STRENGTH_ZORA, + /* 0x03 */ PLAYER_STRENGTH_GORON, + /* 0x04 */ PLAYER_STRENGTH_MAX +} PlayerStrength; + typedef enum { /* 0x00 */ PLAYER_FORM_FIERCE_DEITY, /* 0x01 */ PLAYER_FORM_GORON, @@ -64,14 +72,14 @@ typedef enum { typedef enum { /* 0x00 */ PLAYER_AP_NONE, - /* 0x01 */ PLAYER_AP_UNK_1, - /* 0x02 */ PLAYER_AP_UNK_2, + /* 0x01 */ PLAYER_AP_LAST_USED, + /* 0x02 */ PLAYER_AP_FISHING_POLE, /* 0x03 */ PLAYER_AP_SWORD_KOKIRI, /* 0x04 */ PLAYER_AP_SWORD_RAZOR, /* 0x05 */ PLAYER_AP_SWORD_GILDED, /* 0x06 */ PLAYER_AP_SWORD_GREAT_FAIRY, /* 0x07 */ PLAYER_AP_STICK, - /* 0x08 */ PLAYER_AP_UNK_8, + /* 0x08 */ PLAYER_AP_ZORA_FINS, /* 0x09 */ PLAYER_AP_BOW, /* 0x0A */ PLAYER_AP_BOW_FIRE, /* 0x0B */ PLAYER_AP_BOW_ICE, @@ -141,6 +149,44 @@ typedef enum { /* 0xFD */ PLAYER_AP_MAX = 0xFD } PlayerActionParam; +typedef enum { + /* 0 */ PLAYER_MWA_FORWARD_SLASH_1H, // Vertical one-handed slash + /* 1 */ PLAYER_MWA_FORWARD_SLASH_2H, // Vertical two-handed slash + /* 2 */ PLAYER_MWA_FORWARD_COMBO_1H, // Third vertical one-handed slash + /* 3 */ PLAYER_MWA_FORWARD_COMBO_2H, // Third vertical two-handed slash + /* 4 */ PLAYER_MWA_RIGHT_SLASH_1H, // Horizontal one-handed slash + /* 5 */ PLAYER_MWA_RIGHT_SLASH_2H, // Horizontal two-handed slash + /* 6 */ PLAYER_MWA_RIGHT_COMBO_1H, // Third horizontal one-handed slash + /* 7 */ PLAYER_MWA_RIGHT_COMBO_2H, // Third horizontal two-handed slash + /* 8 */ PLAYER_MWA_LEFT_SLASH_1H, // Targeted one-handed rightwalk slash + /* 9 */ PLAYER_MWA_LEFT_SLASH_2H, // Targeted two-handed rightwalk slash + /* 10 */ PLAYER_MWA_LEFT_COMBO_1H, // Third targeted one-handed rightwalk slash + /* 11 */ PLAYER_MWA_LEFT_COMBO_2H, // Third targeted two-handed rightwalk slash + /* 12 */ PLAYER_MWA_STAB_1H, // Crouch stab/targeted one-handed stab + /* 13 */ PLAYER_MWA_STAB_2H, // Targeted two-handed stab + /* 14 */ PLAYER_MWA_STAB_COMBO_1H, // Third targeted one-handed stab + /* 15 */ PLAYER_MWA_STAB_COMBO_2H, // Third targeted two-handed stab + /* 16 */ PLAYER_MWA_FLIPSLASH_START, // unused + /* 17 */ PLAYER_MWA_JUMPSLASH_START, // Start of jumpslash + /* 18 */ PLAYER_MWA_ZORA_JUMPKICK_START, // Start of Zora jump attack + /* 19 */ PLAYER_MWA_FLIPSLASH_FINISH, // unused + /* 20 */ PLAYER_MWA_JUMPSLASH_FINISH, // End of jumpslash + /* 21 */ PLAYER_MWA_ZORA_JUMPKICK_FINISH, // End of Zora jump attack + /* 22 */ PLAYER_MWA_BACKSLASH_RIGHT, // unused + /* 23 */ PLAYER_MWA_BACKSLASH_LEFT, // unused + /* 24 */ PLAYER_MWA_GORON_PUNCH_LEFT, // Goron punch + /* 25 */ PLAYER_MWA_GORON_PUNCH_RIGHT, // Second Goron punch + /* 26 */ PLAYER_MWA_GORON_PUNCH_BUTT, // Goron butt punch + /* 27 */ PLAYER_MWA_ZORA_PUNCH_LEFT, // Zora punch + /* 28 */ PLAYER_MWA_ZORA_PUNCH_COMBO, // Second Zora punch + /* 29 */ PLAYER_MWA_ZORA_PUNCH_KICK, // Zora kick + /* 30 */ PLAYER_MWA_SPIN_ATTACK_1H, // Half-charged one-handed spin + /* 31 */ PLAYER_MWA_SPIN_ATTACK_2H, // Half-charged two-handed spin + /* 32 */ PLAYER_MWA_BIG_SPIN_1H, // Fully-charged one-handed spin + /* 33 */ PLAYER_MWA_BIG_SPIN_2H, // Fully-charged two-handed spin + /* 34 */ PLAYER_MWA_MAX +} PlayerMeleeWeaponAnimation; + typedef struct { /* 0x00 */ f32 unk_00; /* 0x04 */ f32 unk_04; @@ -178,7 +224,6 @@ typedef struct { /* 0xD4 */ LinkAnimationHeader* unk_D4[2]; } PlayerAgeProperties; // size = 0xDC - typedef struct { /* 0x00 */ s32 active; /* 0x04 */ Vec3f tip; @@ -188,6 +233,226 @@ typedef struct { typedef void (*PlayerFuncD58)(struct PlayState*, struct Player*); +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 alpha; + /* 0x02 */ char unk_02[2]; // probably alignment padding + /* 0x04 */ MtxF mf; +} struct_80122D44_arg1_unk_04; // size = 0x44 + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ s8 unk_01; + /* 0x02 */ char unk_02[2]; // probably alignment padding + /* 0x04 */ struct_80122D44_arg1_unk_04 unk_04[4]; +} struct_80122D44_arg1; // size >= 0x114 + +typedef struct struct_80122744_arg1 { + /* 0x00 */ s8 unk_00; + /* 0x01 */ s8 unk_01; + /* 0x02 */ s8 unk_02; + /* 0x03 */ s8 unk_03; + /* 0x04 */ Vec3s* unk_04; +} struct_80122744_arg1; // size = 0x08 + +// +#define PLAYER_STATE1_1 (1 << 0) +// +#define PLAYER_STATE1_2 (1 << 1) +// +#define PLAYER_STATE1_4 (1 << 2) +// +#define PLAYER_STATE1_8 (1 << 3) +// +#define PLAYER_STATE1_10 (1 << 4) +// +#define PLAYER_STATE1_20 (1 << 5) +// +#define PLAYER_STATE1_40 (1 << 6) +// +#define PLAYER_STATE1_80 (1 << 7) +// +#define PLAYER_STATE1_100 (1 << 8) +// +#define PLAYER_STATE1_200 (1 << 9) +// +#define PLAYER_STATE1_400 (1 << 10) +// +#define PLAYER_STATE1_800 (1 << 11) +// +#define PLAYER_STATE1_1000 (1 << 12) +// +#define PLAYER_STATE1_2000 (1 << 13) +// +#define PLAYER_STATE1_4000 (1 << 14) +// +#define PLAYER_STATE1_8000 (1 << 15) +// +#define PLAYER_STATE1_10000 (1 << 16) +// +#define PLAYER_STATE1_20000 (1 << 17) +// +#define PLAYER_STATE1_40000 (1 << 18) +// +#define PLAYER_STATE1_80000 (1 << 19) +// +#define PLAYER_STATE1_100000 (1 << 20) +// +#define PLAYER_STATE1_200000 (1 << 21) +// +#define PLAYER_STATE1_400000 (1 << 22) +// +#define PLAYER_STATE1_800000 (1 << 23) +// +#define PLAYER_STATE1_1000000 (1 << 24) +// +#define PLAYER_STATE1_2000000 (1 << 25) +// +#define PLAYER_STATE1_4000000 (1 << 26) +// Swimming? +#define PLAYER_STATE1_8000000 (1 << 27) +// +#define PLAYER_STATE1_10000000 (1 << 28) +// +#define PLAYER_STATE1_20000000 (1 << 29) +// +#define PLAYER_STATE1_40000000 (1 << 30) +// +#define PLAYER_STATE1_80000000 (1 << 31) + + +// +#define PLAYER_STATE2_1 (1 << 0) +// +#define PLAYER_STATE2_2 (1 << 1) +// +#define PLAYER_STATE2_4 (1 << 2) +// +#define PLAYER_STATE2_8 (1 << 3) +// +#define PLAYER_STATE2_10 (1 << 4) +// +#define PLAYER_STATE2_20 (1 << 5) +// +#define PLAYER_STATE2_40 (1 << 6) +// +#define PLAYER_STATE2_80 (1 << 7) +// +#define PLAYER_STATE2_100 (1 << 8) +// +#define PLAYER_STATE2_200 (1 << 9) +// +#define PLAYER_STATE2_400 (1 << 10) +// +#define PLAYER_STATE2_800 (1 << 11) +// +#define PLAYER_STATE2_1000 (1 << 12) +// +#define PLAYER_STATE2_2000 (1 << 13) +// +#define PLAYER_STATE2_4000 (1 << 14) +// +#define PLAYER_STATE2_8000 (1 << 15) +// +#define PLAYER_STATE2_10000 (1 << 16) +// +#define PLAYER_STATE2_20000 (1 << 17) +// +#define PLAYER_STATE2_40000 (1 << 18) +// +#define PLAYER_STATE2_80000 (1 << 19) +// +#define PLAYER_STATE2_100000 (1 << 20) +// +#define PLAYER_STATE2_200000 (1 << 21) +// +#define PLAYER_STATE2_400000 (1 << 22) +// +#define PLAYER_STATE2_800000 (1 << 23) +// +#define PLAYER_STATE2_1000000 (1 << 24) +// +#define PLAYER_STATE2_2000000 (1 << 25) +// +#define PLAYER_STATE2_4000000 (1 << 26) +// +#define PLAYER_STATE2_8000000 (1 << 27) +// +#define PLAYER_STATE2_10000000 (1 << 28) +// +#define PLAYER_STATE2_20000000 (1 << 29) +// +#define PLAYER_STATE2_40000000 (1 << 30) +// +#define PLAYER_STATE2_80000000 (1 << 31) + + +// +#define PLAYER_STATE3_1 (1 << 0) +// +#define PLAYER_STATE3_2 (1 << 1) +// +#define PLAYER_STATE3_4 (1 << 2) +// +#define PLAYER_STATE3_8 (1 << 3) +// +#define PLAYER_STATE3_10 (1 << 4) +// +#define PLAYER_STATE3_20 (1 << 5) +// +#define PLAYER_STATE3_40 (1 << 6) +// +#define PLAYER_STATE3_80 (1 << 7) +// +#define PLAYER_STATE3_100 (1 << 8) +// +#define PLAYER_STATE3_200 (1 << 9) +// +#define PLAYER_STATE3_400 (1 << 10) +// +#define PLAYER_STATE3_800 (1 << 11) +// +#define PLAYER_STATE3_1000 (1 << 12) +// +#define PLAYER_STATE3_2000 (1 << 13) +// +#define PLAYER_STATE3_4000 (1 << 14) +// +#define PLAYER_STATE3_8000 (1 << 15) +// +#define PLAYER_STATE3_10000 (1 << 16) +// +#define PLAYER_STATE3_20000 (1 << 17) +// +#define PLAYER_STATE3_40000 (1 << 18) +// +#define PLAYER_STATE3_80000 (1 << 19) +// +#define PLAYER_STATE3_100000 (1 << 20) +// +#define PLAYER_STATE3_200000 (1 << 21) +// +#define PLAYER_STATE3_400000 (1 << 22) +// +#define PLAYER_STATE3_800000 (1 << 23) +// +#define PLAYER_STATE3_1000000 (1 << 24) +// +#define PLAYER_STATE3_2000000 (1 << 25) +// +#define PLAYER_STATE3_4000000 (1 << 26) +// +#define PLAYER_STATE3_8000000 (1 << 27) +// +#define PLAYER_STATE3_10000000 (1 << 28) +// breman mask march? +#define PLAYER_STATE3_20000000 (1 << 29) +// +#define PLAYER_STATE3_40000000 (1 << 30) +// +#define PLAYER_STATE3_80000000 (1 << 31) + + typedef struct Player { /* 0x000 */ Actor actor; /* 0x144 */ s8 currentShield; @@ -238,7 +503,7 @@ typedef struct Player { /* 0x1DC */ OSMesgQueue giObjectLoadQueue; /* 0x1F4 */ OSMesg giObjectLoadMsg; /* 0x1F8 */ void* giObjectSegment; - /* 0x1FC */ u8 maskObjectLoading; + /* 0x1FC */ u8 maskObjectLoadState; /* 0x1FD */ s8 maskId; /* 0x200 */ DmaRequest maskDmaRequest; /* 0x220 */ OSMesgQueue maskObjectLoadQueue; @@ -266,7 +531,7 @@ typedef struct Player { /* 0x38C */ s8 mountSide; /* 0x390 */ Actor* rideActor; /* 0x394 */ u8 csMode; - /* 0x395 */ u8 unk_395; + /* 0x395 */ u8 unk_395; // prevCsMode? /* 0x396 */ u8 unk_396; /* 0x397 */ u8 unk_397; /* 0x398 */ Actor* unk_398; @@ -282,15 +547,16 @@ typedef struct Player { /* 0x3CC */ s16 unk_3CC; /* 0x3CE */ s8 unk_3CE; /* 0x3CF */ u8 unk_3CF; - /* 0x3D0 */ char unk_3D0[0x148]; + /* 0x3D0 */ struct_80122D44_arg1 unk_3D0; + /* 0x404 */ UNK_TYPE1 unk_404[0x34]; /* 0x518 */ ColliderCylinder cylinder; - /* 0x564 */ ColliderQuad swordQuads[2]; + /* 0x564 */ ColliderQuad meleeWeaponQuads[2]; /* 0x664 */ ColliderQuad shieldQuad; /* 0x6E4 */ ColliderCylinder shieldCylinder; /* 0x730 */ Actor* unk_730; /* 0x734 */ char unk_734[4]; /* 0x738 */ s32 unk_738; - /* 0x73C */ s32 blureEffectIndex[3]; + /* 0x73C */ s32 meleeWeaponEffectIndex[3]; /* 0x748 */ char unk_748[0x320]; /* 0xA68 */ PlayerAgeProperties* ageProperties; // repurposed as "transformation properties"? /* 0xA6C */ u32 stateFlags1; @@ -328,8 +594,8 @@ typedef struct Player { /* 0xAD4 */ s16 currentYaw; /* 0xAD6 */ s16 targetYaw; /* 0xAD8 */ u16 unk_AD8; - /* 0xADA */ s8 swordAnimation; - /* 0xADB */ s8 swordState; + /* 0xADA */ s8 meleeWeaponAnimation; + /* 0xADB */ s8 meleeWeaponState; /* 0xADC */ s8 unk_ADC; /* 0xADD */ s8 unk_ADD; /* 0xADE */ u8 unk_ADE; @@ -389,7 +655,7 @@ typedef struct Player { /* 0xB92 */ s16 unk_B92; /* 0xB94 */ s16 unk_B94; /* 0xB96 */ s16 unk_B96; - /* 0xB98 */ WeaponInfo swordInfo[3]; + /* 0xB98 */ WeaponInfo meleeWeaponInfo[3]; /* 0xBEC */ Vec3f bodyPartsPos[18]; /* 0xCC4 */ MtxF mf_CC4; /* 0xD04 */ MtxF shieldMf; diff --git a/include/z64save.h b/include/z64save.h index 28c426bdd..d0b5d7fd2 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -11,10 +11,10 @@ struct FileChooseContext; // TODO: properly name DOWN, RETURN and TOP typedef enum RespawnMode { - /* 0 */ RESTART_MODE_DOWN, // "RESTART_MODE_DOWN" - /* 1 */ RESTART_MODE_RETURN, // "RESTART_MODE_RETURN" - /* 2 */ RESTART_MODE_TOP, // "RESTART_MODE_TOP" - /* 3 */ RESPAWN_MODE_UNK_3, // Maybe related to grottos + /* 0 */ RESPAWN_MODE_DOWN, // "RESTART_MODE_DOWN" + /* 1 */ RESPAWN_MODE_RETURN, // "RESTART_MODE_RETURN" + /* 2 */ RESPAWN_MODE_TOP, // "RESTART_MODE_TOP" + /* 3 */ RESPAWN_MODE_UNK_3, // Related to grottos /* 4 */ RESPAWN_MODE_GORON, // "RESTART_MODE_GORON" /* 5 */ RESPAWN_MODE_ZORA, // "RESTART_MODE_ZORA" /* 6 */ RESPAWN_MODE_DEKU, // "RESTART_MODE_NUTS" @@ -78,8 +78,8 @@ typedef struct PermanentSceneFlags { /* 0x08 */ u32 switch1; /* 0x0C */ u32 clearedRoom; /* 0x10 */ u32 collectible; - /* 0x14 */ u32 unk_14; - /* 0x18 */ u32 unk_18; + /* 0x14 */ u32 unk_14; // varies based on scene. For dungeons, floors visited. + /* 0x18 */ u32 rooms; } PermanentSceneFlags; // size = 0x1C typedef struct CycleSceneFlags { @@ -240,16 +240,16 @@ typedef struct SaveContext { /* 0x3F3F */ u8 unk_3F3F; // "flash_flag" /* 0x3F40 */ SaveOptions options; /* 0x3F46 */ u16 unk_3F46; // "NottoriBgm" - /* 0x3F48 */ u8 unk_3F48; // "fade_go" + /* 0x3F48 */ u8 cutsceneTransitionControl; // "fade_go" /* 0x3F4A */ u16 nextCutsceneIndex; // "next_daytime" /* 0x3F4C */ u8 cutsceneTrigger; // "doukidemo" /* 0x3F4D */ u8 unk_3F4D; // "Kenjya_no" /* 0x3F4E */ u16 nextDayTime; // "next_zelda_time" - /* 0x3F50 */ u8 fadeDuration; // "fade_speed" - /* 0x3F51 */ u8 fadeSpeed; // "wipe_speed" transition related + /* 0x3F50 */ u8 transFadeDuration; // "fade_speed" + /* 0x3F51 */ u8 transWipeSpeed; // "wipe_speed" transition related /* 0x3F52 */ u16 environmentTime; // "kankyo_time" /* 0x3F54 */ u8 dogIsLost; // "dog_event_flag" - /* 0x3F55 */ u8 nextTransition; // "next_wipe" + /* 0x3F55 */ u8 nextTransitionType; // "next_wipe" /* 0x3F56 */ s16 worldMapArea; // "area_type" /* 0x3F58 */ s16 sunsSongState; // "sunmoon_flag" /* 0x3F5A */ s16 healthAccumulator; // "life_mode" @@ -257,7 +257,7 @@ typedef struct SaveContext { /* 0x3F60 */ u8 screenScaleFlag; // "framescale_flag" /* 0x3F64 */ f32 screenScale; // "framescale_scale" /* 0x3F68 */ CycleSceneFlags cycleSceneFlags[120]; // Scene flags that are temporarily stored over the duration of a single 3-day cycle - /* 0x48C8 */ u16 unk_48C8; // "scene_id_mix" + /* 0x48C8 */ u16 dungeonIndex; // "scene_id_mix" /* 0x48CA */ u8 maskMaskBit[27]; // "mask_mask_bit", masks given away on the Moon } SaveContext; // size = 0x48C8 @@ -273,6 +273,13 @@ typedef enum SunsSongState { /* 3 */ SUNSSONG_SPECIAL // time does not advance, but signals the song was played. used for freezing redeads } SunsSongState; +typedef enum { + /* 0 */ DUNGEON_INDEX_WOODFALL_TEMPLE, + /* 1 */ DUNGEON_INDEX_SNOWHEAD_TEMPLE, + /* 2 */ DUNGEON_INDEX_GREAT_BAY_TEMPLE, + /* 3 */ DUNGEON_INDEX_STONE_TOWER_TEMPLE, // Also applies to Inverted Stone Tower Temple +} DungeonIndex; + void Sram_ActivateOwl(u8 owlId); void Sram_ClearFlagsAtDawnOfTheFirstDay(void); void Sram_SaveEndOfCycle(struct PlayState* play); diff --git a/include/z64scene.h b/include/z64scene.h index 446506ee3..d35aa9e6e 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -4,6 +4,7 @@ #include "ultra64.h" #include "z64dma.h" #include "z64cutscene.h" +#include "z64map.h" #include "unk.h" #define SPAWN_ROT_FLAGS(rotation, flags) (((rotation) << 7) | (flags)) @@ -260,7 +261,7 @@ typedef union { typedef struct { /* 0x00 */ s8 num; /* 0x01 */ u8 unk1; - /* 0x02 */ u8 unk2; + /* 0x02 */ u8 unk2; // 3: Room is hot /* 0x03 */ u8 unk3; /* 0x04 */ s8 echo; /* 0x05 */ u8 unk5; @@ -377,7 +378,7 @@ typedef struct { typedef struct { /* 0x0 */ u16 keyFrameLength; - /* 0x4 */ void* textureList; + /* 0x4 */ TexturePtr* textureList; /* 0x8 */ u8* textureIndexList; } AnimatedMatTexCycleParams; // size = 0xC @@ -468,19 +469,6 @@ typedef struct { /* 0x04 */ Vec3s* points; // Segment Address to the array of points } Path; // size = 0x8 -typedef struct { - /* 0x00 */ u16 unk0; - /* 0x02 */ s16 unk2; - /* 0x04 */ UNK_TYPE2 unk4; - /* 0x06 */ s16 unk6; - /* 0x08 */ u16 unk8; -} MinimapEntry; // size = 0xA - -typedef struct { - /* 0x00 */ MinimapEntry* entry; - /* 0x04 */ s16 unk4; -} MinimapList; // size = 0x8 - typedef struct { /* 0x00 */ UNK_TYPE2 unk0; /* 0x02 */ UNK_TYPE2 unk2; diff --git a/include/z64schedule.h b/include/z64schedule.h index f5dfb2be8..8dba85d4d 100644 --- a/include/z64schedule.h +++ b/include/z64schedule.h @@ -3,37 +3,45 @@ #include "ultra64.h" -/* - Schedule is a subsystem that acts as a way to make decisions based on the - time and scene (and a limited selection of items). It is utilized by writing - a script that is encoded into bytecode and ran, returning the result in a - struct. The returned result can be a value or a encoded time value. +/** + * Schedule is a subsystem that acts as a way to make decisions based on the + * time and scene (and a limited selection of items). It is utilized by writing + * a script that is encoded into bytecode and run, returning the result in a + * struct. The returned result can be a value or a encoded time value. + * + * The scripts contain 2 kinds of instructions: + * - Checks with branches (relative offsets, either 1-byte offsets (short, *_S), + * or 2-byte offsets (long, *_L)) + * - Returns + * + * Scripts are stored as u8[]. They are built using the macros are the bottom of + * this file. The scheduledis.py script can be used to convert any scripts in + * actor data into the macros. + */ - The scripts contain 2 kinds of instructions: - - Checks with branches (relative offsets, either 1-byte offsets (short, *_S), - or 2-byte offsets (long, *_L)) - - Returns - - Scripts are stored as u8[]. They are built using the macros are the bottom of - this file. The scheduledis.py script can be used to convert any scripts in - actor data into the macros. -*/ +/** + * Actors that use this system generally create 3 functions to interact with it. + * + * - FollowSchedule: The action function an actor sets to follow the schedule. + * - ProcessScheduleOutput: Holds the logic of processing the output received by running the schedule script, called by FollowSchedule + * - HandleSchedule: Holds the actual logic of how to actually follow the schedule based on the processed output, called by FollowSchedule + */ // Macro to convert the time format used in the save struct into the format used in Schedule #define SCHEDULE_CONVERT_TIME(time) ((time) - 0x10000 / 360 * 90) #define SCHEDULE_TIME_NOW SCHEDULE_CONVERT_TIME(gSaveContext.save.time) typedef enum { - /* 00 */ SCHEDULE_CMD_ID_CHECK_FLAG_S, // Checks if a weekEventReg flag is set and branches if so, short range branch - /* 01 */ SCHEDULE_CMD_ID_CHECK_FLAG_L, // Checks if a weekEventReg flag is set and branches if so, long range branch - /* 02 */ SCHEDULE_CMD_ID_CHECK_TIME_RANGE_S, // Checks if the current time is within the range of the two provided times and branches if so, short range branch - /* 03 */ SCHEDULE_CMD_ID_CHECK_TIME_RANGE_L, // Checks if the current time is within the range of the two provided times and branches if so, long range branch - /* 04 */ SCHEDULE_CMD_ID_RET_VAL_L, // Ends script and returns 2-byte value (Note: bugged as the return value size is only 1 byte in the struct) - /* 05 */ SCHEDULE_CMD_ID_RET_NONE, // Ends script without returning anything - /* 06 */ SCHEDULE_CMD_ID_RET_EMPTY, // Ends script and indicates return without changing existing value - /* 07 */ SCHEDULE_CMD_ID_NOP, // No-Op - /* 08 */ SCHEDULE_CMD_ID_CHECK_MISC_S, // Special check based on items or masks and branches if check passes, short range branch - /* 09 */ SCHEDULE_CMD_ID_RET_VAL_S, // Ends script and returns byte value + /* 0 */ SCHEDULE_CMD_ID_CHECK_FLAG_S, // Checks if a weekEventReg flag is set and branches if so, short range branch + /* 1 */ SCHEDULE_CMD_ID_CHECK_FLAG_L, // Checks if a weekEventReg flag is set and branches if so, long range branch + /* 2 */ SCHEDULE_CMD_ID_CHECK_TIME_RANGE_S, // Checks if the current time is within the range of the two provided times and branches if so, short range branch + /* 3 */ SCHEDULE_CMD_ID_CHECK_TIME_RANGE_L, // Checks if the current time is within the range of the two provided times and branches if so, long range branch + /* 4 */ SCHEDULE_CMD_ID_RET_VAL_L, // Ends script and returns 2-byte value (Note: bugged as the return value size is only 1 byte in the struct) + /* 5 */ SCHEDULE_CMD_ID_RET_NONE, // Ends script without returning anything + /* 6 */ SCHEDULE_CMD_ID_RET_EMPTY, // Ends script and indicates return without changing existing value + /* 7 */ SCHEDULE_CMD_ID_NOP, // No-Op + /* 8 */ SCHEDULE_CMD_ID_CHECK_MISC_S, // Special check based on items or masks and branches if check passes, short range branch + /* 9 */ SCHEDULE_CMD_ID_RET_VAL_S, // Ends script and returns byte value /* 10 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_S, // Checks if the current scene is not SceneNum and branches if so, short range branch /* 11 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_L, // Checks if the current scene is not SceneNum and branches if so, long range branch /* 12 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_S, // Checks if the current day is not Day and branches if so, short range branch @@ -56,7 +64,7 @@ typedef struct { /* 0x4 */ s32 time0; /* 0x8 */ s32 time1; /* 0xC */ s32 hasResult; -} ScheduleResult; // size = 0x10 +} ScheduleOutput; // size = 0x10 typedef struct { /* 0x0 */ u8 cmd; diff --git a/include/z64subs.h b/include/z64subs.h index 60c3e7151..ff9404e9d 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -122,7 +122,7 @@ void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween void SubS_DrawShadowTex(Actor* actor, struct GameState* gameState, u8* tex); s16 SubS_ComputeTrackPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); -s32 SubS_TrackPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TrackOptionsSet* options); +s32 SubS_TrackPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* trackTarget, Vec3s* headRot, Vec3s* torsoRot, TrackOptionsSet* options); s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); diff --git a/include/z64view.h b/include/z64view.h new file mode 100644 index 000000000..98ca1ab19 --- /dev/null +++ b/include/z64view.h @@ -0,0 +1,57 @@ +#ifndef Z64VIEW_H +#define Z64VIEW_H + +#include "PR/ultratypes.h" +#include "PR/gbi.h" +#include "z64math.h" +#include "unk.h" + +struct GraphicsContext; + +typedef struct Viewport { + /* 0x00 */ s32 topY; // uly (upper left y) + /* 0x04 */ s32 bottomY; // lry (lower right y) + /* 0x08 */ s32 leftX; // ulx (upper left x) + /* 0x0C */ s32 rightX; // lrx (lower right x) +} Viewport; // size = 0x10 + +typedef struct View { + /* 0x000 */ u32 magic; // string literal "VIEW" / 0x56494557 + /* 0x004 */ struct GraphicsContext* gfxCtx; + /* 0x008 */ Viewport viewport; + /* 0x018 */ f32 fovy; // vertical field of view in degrees + /* 0x01C */ f32 zNear; // distance to near clipping plane + /* 0x020 */ f32 zFar; // distance to far clipping plane + /* 0x024 */ f32 scale; // scale for matrix elements + /* 0x028 */ Vec3f eye; + /* 0x034 */ Vec3f at; + /* 0x040 */ Vec3f up; + /* 0x04C */ UNK_TYPE1 pad4C[0x4]; + /* 0x050 */ Vp vp; + /* 0x060 */ Mtx projection; + /* 0x0A0 */ Mtx viewing; + /* 0x0E0 */ Mtx unkE0; + /* 0x120 */ Mtx* projectionPtr; + /* 0x124 */ Mtx* viewingPtr; + /* 0x128 */ Vec3f distortionDirRot; + /* 0x134 */ Vec3f distortionScale; + /* 0x140 */ f32 distortionSpeed; + /* 0x144 */ Vec3f curDistortionDirRot; + /* 0x150 */ Vec3f curDistortionScale; + /* 0x15C */ u16 normal; // used to normalize the projection matrix + /* 0x160 */ u32 flags; // bit 3: Render to an orthographic perspective + /* 0x164 */ s32 unk164; +} View; // size = 0x168 + +#define SET_FULLSCREEN_VIEWPORT(view) \ + { \ + Viewport viewport; \ + viewport.bottomY = SCREEN_HEIGHT; \ + viewport.rightX = SCREEN_WIDTH; \ + viewport.topY = 0; \ + viewport.leftX = 0; \ + View_SetViewport(view, &viewport); \ + } \ + (void)0 + +#endif diff --git a/include/z_en_hy_code.h b/include/z_en_hy_code.h index b8391a7d9..724b8c570 100644 --- a/include/z_en_hy_code.h +++ b/include/z_en_hy_code.h @@ -39,7 +39,7 @@ typedef void (*EnHyActionFunc)(struct EnHy*, PlayState*); typedef struct EnHy { /* 0x000 */ Actor actor; /* 0x144 */ EnHyActionFunc actionFunc; - /* 0x148 */ EnHyActionFunc tmpActionFunc; + /* 0x148 */ EnHyActionFunc prevActionFunc; /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ s8 headObjIndex; // Limb 15 /* 0x191 */ s8 skelUpperObjIndex; // Limbs 8-14 @@ -60,9 +60,9 @@ typedef struct EnHy { /* 0x2C6 */ Vec3s trackTarget; /* 0x2CC */ Vec3s headRot; /* 0x2D2 */ Vec3s torsoRot; - /* 0x2D8 */ Vec3s tmptrackTarget; - /* 0x2DE */ Vec3s tmpHeadRot; - /* 0x2E4 */ Vec3s tmpTorsoRot; + /* 0x2D8 */ Vec3s prevTrackTarget; + /* 0x2DE */ Vec3s prevHeadRot; + /* 0x2E4 */ Vec3s prevTorsoRot; /* 0x2EA */ s16 limbRotTableY[16]; /* 0x30A */ s16 limbRotTableZ[16]; /* 0x32C */ Vec3f bodyPartsPos[15]; diff --git a/requirements.txt b/requirements.txt index d76027c1c..d410bc853 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,12 @@ +# Setup libyaz0>=0.5 -pyelftools>=0.26 colorama>=0.4.3 -ansiwrap>=0.8.4 -attrs>=18.2.0 + +# disasm +rabbitizer>=1.0.0,<2.0.0 + +# diff watchdog>=0.10.2 -GitPython>=3.1.14 +argcomplete +python-Levenshtein +cxxfilt diff --git a/spec b/spec index 251581be3..209727c3d 100644 --- a/spec +++ b/spec @@ -493,7 +493,6 @@ beginseg include "build/data/code/z_map_disp.bss.o" include "build/src/code/z_map_data.o" include "build/src/code/z_map_exp.o" - include "build/data/code/z_map_exp.data.o" include "build/src/code/z_msgevent.o" include "build/data/code/z_msgevent.data.o" include "build/src/code/z_nmi_buff.o" @@ -501,8 +500,6 @@ beginseg include "build/src/code/z_olib.o" pad_text include "build/src/code/z_parameter.o" - include "build/data/code/z_parameter.data.o" - include "build/data/code/z_parameter.bss.o" include "build/src/code/z_path.o" include "build/src/code/z_pause.o" include "build/src/code/z_player_lib.o" @@ -623,7 +620,6 @@ beginseg include "build/src/code/audio/audio_playback.o" include "build/src/code/audio/audio_effects.o" include "build/src/code/audio/audio_seqplayer.o" - include "build/data/code/audio_seqplayer.data.o" include "build/data/code/audio_dramStack.data.o" include "build/asm/code/code_8019AE40.text.o" // handwritten pad_text @@ -744,8 +740,7 @@ beginseg name "ovl_En_Part" compress include "build/src/overlays/actors/ovl_En_Part/z_en_part.o" - include "build/data/ovl_En_Part/ovl_En_Part.data.o" - include "build/data/ovl_En_Part/ovl_En_Part.reloc.o" + include "build/src/overlays/actors/ovl_En_Part/ovl_En_Part_reloc.o" endseg beginseg @@ -1129,8 +1124,7 @@ beginseg name "ovl_Bg_F40_Flift" compress include "build/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.o" - include "build/data/ovl_Bg_F40_Flift/ovl_Bg_F40_Flift.data.o" - include "build/data/ovl_Bg_F40_Flift/ovl_Bg_F40_Flift.reloc.o" + include "build/src/overlays/actors/ovl_Bg_F40_Flift/ovl_Bg_F40_Flift_reloc.o" endseg beginseg @@ -1375,8 +1369,7 @@ beginseg name "ovl_En_Ik" compress include "build/src/overlays/actors/ovl_En_Ik/z_en_ik.o" - include "build/data/ovl_En_Ik/ovl_En_Ik.data.o" - include "build/data/ovl_En_Ik/ovl_En_Ik.reloc.o" + include "build/src/overlays/actors/ovl_En_Ik/ovl_En_Ik_reloc.o" endseg beginseg @@ -1397,8 +1390,7 @@ beginseg name "ovl_Elf_Msg" compress include "build/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.o" - include "build/data/ovl_Elf_Msg/ovl_Elf_Msg.data.o" - include "build/data/ovl_Elf_Msg/ovl_Elf_Msg.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg/ovl_Elf_Msg_reloc.o" endseg beginseg @@ -1462,16 +1454,14 @@ beginseg name "ovl_Obj_Lift" compress include "build/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.o" - include "build/data/ovl_Obj_Lift/ovl_Obj_Lift.data.o" - include "build/data/ovl_Obj_Lift/ovl_Obj_Lift.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Lift/ovl_Obj_Lift_reloc.o" endseg beginseg name "ovl_Obj_Hsblock" compress include "build/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.o" - include "build/data/ovl_Obj_Hsblock/ovl_Obj_Hsblock.data.o" - include "build/data/ovl_Obj_Hsblock/ovl_Obj_Hsblock.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hsblock/ovl_Obj_Hsblock_reloc.o" endseg beginseg @@ -1689,8 +1679,7 @@ beginseg name "ovl_Elf_Msg2" compress include "build/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.o" - include "build/data/ovl_Elf_Msg2/ovl_Elf_Msg2.data.o" - include "build/data/ovl_Elf_Msg2/ovl_Elf_Msg2.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg2/ovl_Elf_Msg2_reloc.o" endseg beginseg @@ -1797,8 +1786,7 @@ beginseg name "ovl_Effect_Ss_G_Spk" compress include "build/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.o" - include "build/data/ovl_Effect_Ss_G_Spk/ovl_Effect_Ss_G_Spk.data.o" - include "build/data/ovl_Effect_Ss_G_Spk/ovl_Effect_Ss_G_Spk.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_G_Spk/ovl_Effect_Ss_G_Spk_reloc.o" endseg beginseg @@ -1820,24 +1808,21 @@ beginseg name "ovl_Effect_Ss_G_Ripple" compress include "build/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.o" - include "build/data/ovl_Effect_Ss_G_Ripple/ovl_Effect_Ss_G_Ripple.data.o" - include "build/data/ovl_Effect_Ss_G_Ripple/ovl_Effect_Ss_G_Ripple.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_G_Ripple/ovl_Effect_Ss_G_Ripple_reloc.o" endseg beginseg name "ovl_Effect_Ss_G_Splash" compress include "build/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.o" - include "build/data/ovl_Effect_Ss_G_Splash/ovl_Effect_Ss_G_Splash.data.o" - include "build/data/ovl_Effect_Ss_G_Splash/ovl_Effect_Ss_G_Splash.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_G_Splash/ovl_Effect_Ss_G_Splash_reloc.o" endseg beginseg name "ovl_Effect_Ss_G_Fire" compress include "build/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.o" - include "build/data/ovl_Effect_Ss_G_Fire/ovl_Effect_Ss_G_Fire.data.o" - include "build/data/ovl_Effect_Ss_G_Fire/ovl_Effect_Ss_G_Fire.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_G_Fire/ovl_Effect_Ss_G_Fire_reloc.o" endseg beginseg @@ -1859,8 +1844,7 @@ beginseg name "ovl_Effect_Ss_Hahen" compress include "build/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.o" - include "build/data/ovl_Effect_Ss_Hahen/ovl_Effect_Ss_Hahen.data.o" - include "build/data/ovl_Effect_Ss_Hahen/ovl_Effect_Ss_Hahen.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Hahen/ovl_Effect_Ss_Hahen_reloc.o" endseg beginseg @@ -1888,8 +1872,7 @@ beginseg name "ovl_Effect_Ss_Hitmark" compress include "build/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.o" - include "build/data/ovl_Effect_Ss_Hitmark/ovl_Effect_Ss_Hitmark.data.o" - include "build/data/ovl_Effect_Ss_Hitmark/ovl_Effect_Ss_Hitmark.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Hitmark/ovl_Effect_Ss_Hitmark_reloc.o" endseg beginseg @@ -1996,8 +1979,7 @@ beginseg name "ovl_Obj_Demo" compress include "build/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.o" - include "build/data/ovl_Obj_Demo/ovl_Obj_Demo.data.o" - include "build/data/ovl_Obj_Demo/ovl_Obj_Demo.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Demo/ovl_Obj_Demo_reloc.o" endseg beginseg @@ -2257,8 +2239,7 @@ beginseg name "ovl_Bg_Fire_Wall" compress include "build/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.o" - include "build/data/ovl_Bg_Fire_Wall/ovl_Bg_Fire_Wall.data.o" - include "build/data/ovl_Bg_Fire_Wall/ovl_Bg_Fire_Wall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Fire_Wall/ovl_Bg_Fire_Wall_reloc.o" endseg beginseg @@ -2288,8 +2269,7 @@ beginseg name "ovl_Obj_Chikuwa" compress include "build/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.o" - include "build/data/ovl_Obj_Chikuwa/ovl_Obj_Chikuwa.data.o" - include "build/data/ovl_Obj_Chikuwa/ovl_Obj_Chikuwa.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Chikuwa/ovl_Obj_Chikuwa_reloc.o" endseg beginseg @@ -2618,8 +2598,7 @@ beginseg name "ovl_Elf_Msg3" compress include "build/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.o" - include "build/data/ovl_Elf_Msg3/ovl_Elf_Msg3.data.o" - include "build/data/ovl_Elf_Msg3/ovl_Elf_Msg3.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg3/ovl_Elf_Msg3_reloc.o" endseg beginseg @@ -2663,8 +2642,7 @@ beginseg name "ovl_Obj_Toudai" compress include "build/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.o" - include "build/data/ovl_Obj_Toudai/ovl_Obj_Toudai.data.o" - include "build/data/ovl_Obj_Toudai/ovl_Obj_Toudai.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Toudai/ovl_Obj_Toudai_reloc.o" endseg beginseg @@ -2692,8 +2670,7 @@ beginseg name "ovl_Obj_Shutter" compress include "build/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.o" - include "build/data/ovl_Obj_Shutter/ovl_Obj_Shutter.data.o" - include "build/data/ovl_Obj_Shutter/ovl_Obj_Shutter.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Shutter/ovl_Obj_Shutter_reloc.o" endseg beginseg @@ -2775,17 +2752,14 @@ beginseg name "ovl_En_Bat" compress include "build/src/overlays/actors/ovl_En_Bat/z_en_bat.o" - include "build/data/ovl_En_Bat/ovl_En_Bat.data.o" - include "build/data/ovl_En_Bat/ovl_En_Bat.bss.o" - include "build/data/ovl_En_Bat/ovl_En_Bat.reloc.o" + include "build/src/overlays/actors/ovl_En_Bat/ovl_En_Bat_reloc.o" endseg beginseg name "ovl_En_Sekihi" compress include "build/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.o" - include "build/data/ovl_En_Sekihi/ovl_En_Sekihi.data.o" - include "build/data/ovl_En_Sekihi/ovl_En_Sekihi.reloc.o" + include "build/src/overlays/actors/ovl_En_Sekihi/ovl_En_Sekihi_reloc.o" endseg beginseg @@ -2814,8 +2788,7 @@ beginseg name "ovl_Eff_Change" compress include "build/src/overlays/actors/ovl_Eff_Change/z_eff_change.o" - include "build/data/ovl_Eff_Change/ovl_Eff_Change.data.o" - include "build/data/ovl_Eff_Change/ovl_Eff_Change.reloc.o" + include "build/src/overlays/actors/ovl_Eff_Change/ovl_Eff_Change_reloc.o" endseg beginseg @@ -2851,8 +2824,7 @@ beginseg name "ovl_Demo_Getitem" compress include "build/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.o" - include "build/data/ovl_Demo_Getitem/ovl_Demo_Getitem.data.o" - include "build/data/ovl_Demo_Getitem/ovl_Demo_Getitem.reloc.o" + include "build/src/overlays/actors/ovl_Demo_Getitem/ovl_Demo_Getitem_reloc.o" endseg beginseg @@ -2931,8 +2903,7 @@ beginseg name "ovl_Bg_Spout_Fire" compress include "build/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.o" - include "build/data/ovl_Bg_Spout_Fire/ovl_Bg_Spout_Fire.data.o" - include "build/data/ovl_Bg_Spout_Fire/ovl_Bg_Spout_Fire.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Spout_Fire/ovl_Bg_Spout_Fire_reloc.o" endseg beginseg @@ -3065,8 +3036,7 @@ beginseg name "ovl_Obj_Purify" compress include "build/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.o" - include "build/data/ovl_Obj_Purify/ovl_Obj_Purify.data.o" - include "build/data/ovl_Obj_Purify/ovl_Obj_Purify.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Purify/ovl_Obj_Purify_reloc.o" endseg beginseg @@ -3157,8 +3127,7 @@ beginseg name "ovl_Dm_Char02" compress include "build/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.o" - include "build/data/ovl_Dm_Char02/ovl_Dm_Char02.data.o" - include "build/data/ovl_Dm_Char02/ovl_Dm_Char02.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char02/ovl_Dm_Char02_reloc.o" endseg beginseg @@ -3173,8 +3142,7 @@ beginseg name "ovl_Dm_Char04" compress include "build/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.o" - include "build/data/ovl_Dm_Char04/ovl_Dm_Char04.data.o" - include "build/data/ovl_Dm_Char04/ovl_Dm_Char04.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char04/ovl_Dm_Char04_reloc.o" endseg beginseg @@ -3310,9 +3278,7 @@ beginseg name "ovl_Bg_Icefloe" compress include "build/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.o" - include "build/data/ovl_Bg_Icefloe/ovl_Bg_Icefloe.data.o" - include "build/data/ovl_Bg_Icefloe/ovl_Bg_Icefloe.bss.o" - include "build/data/ovl_Bg_Icefloe/ovl_Bg_Icefloe.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Icefloe/ovl_Bg_Icefloe_reloc.o" endseg beginseg @@ -3366,8 +3332,7 @@ beginseg name "ovl_Obj_Ocarinalift" compress include "build/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.o" - include "build/data/ovl_Obj_Ocarinalift/ovl_Obj_Ocarinalift.data.o" - include "build/data/ovl_Obj_Ocarinalift/ovl_Obj_Ocarinalift.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Ocarinalift/ovl_Obj_Ocarinalift_reloc.o" endseg beginseg @@ -3381,8 +3346,7 @@ beginseg name "ovl_Bg_Open_Shutter" compress include "build/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.o" - include "build/data/ovl_Bg_Open_Shutter/ovl_Bg_Open_Shutter.data.o" - include "build/data/ovl_Bg_Open_Shutter/ovl_Bg_Open_Shutter.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Open_Shutter/ovl_Bg_Open_Shutter_reloc.o" endseg beginseg @@ -3489,8 +3453,7 @@ beginseg name "ovl_Bg_Fu_Mizu" compress include "build/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.o" - include "build/data/ovl_Bg_Fu_Mizu/ovl_Bg_Fu_Mizu.data.o" - include "build/data/ovl_Bg_Fu_Mizu/ovl_Bg_Fu_Mizu.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Fu_Mizu/ovl_Bg_Fu_Mizu_reloc.o" endseg beginseg @@ -3534,8 +3497,7 @@ beginseg name "ovl_En_Ds2n" compress include "build/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.o" - include "build/data/ovl_En_Ds2n/ovl_En_Ds2n.data.o" - include "build/data/ovl_En_Ds2n/ovl_En_Ds2n.reloc.o" + include "build/src/overlays/actors/ovl_En_Ds2n/ovl_En_Ds2n_reloc.o" endseg beginseg @@ -3593,8 +3555,7 @@ beginseg name "ovl_Obj_Lupygamelift" compress include "build/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.o" - include "build/data/ovl_Obj_Lupygamelift/ovl_Obj_Lupygamelift.data.o" - include "build/data/ovl_Obj_Lupygamelift/ovl_Obj_Lupygamelift.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Lupygamelift/ovl_Obj_Lupygamelift_reloc.o" endseg beginseg @@ -3631,8 +3592,7 @@ beginseg name "ovl_En_Gamelupy" compress include "build/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.o" - include "build/data/ovl_En_Gamelupy/ovl_En_Gamelupy.data.o" - include "build/data/ovl_En_Gamelupy/ovl_En_Gamelupy.reloc.o" + include "build/src/overlays/actors/ovl_En_Gamelupy/ovl_En_Gamelupy_reloc.o" endseg beginseg @@ -3669,16 +3629,14 @@ beginseg name "ovl_Elf_Msg4" compress include "build/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.o" - include "build/data/ovl_Elf_Msg4/ovl_Elf_Msg4.data.o" - include "build/data/ovl_Elf_Msg4/ovl_Elf_Msg4.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg4/ovl_Elf_Msg4_reloc.o" endseg beginseg name "ovl_Elf_Msg5" compress include "build/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.o" - include "build/data/ovl_Elf_Msg5/ovl_Elf_Msg5.data.o" - include "build/data/ovl_Elf_Msg5/ovl_Elf_Msg5.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg5/ovl_Elf_Msg5_reloc.o" endseg beginseg @@ -3728,8 +3686,7 @@ beginseg name "ovl_En_Onpuman" compress include "build/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.o" - include "build/data/ovl_En_Onpuman/ovl_En_Onpuman.data.o" - include "build/data/ovl_En_Onpuman/ovl_En_Onpuman.reloc.o" + include "build/src/overlays/actors/ovl_En_Onpuman/ovl_En_Onpuman_reloc.o" endseg beginseg @@ -3843,8 +3800,7 @@ beginseg name "ovl_Bg_Botihasira" compress include "build/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.o" - include "build/data/ovl_Bg_Botihasira/ovl_Bg_Botihasira.data.o" - include "build/data/ovl_Bg_Botihasira/ovl_Bg_Botihasira.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Botihasira/ovl_Bg_Botihasira_reloc.o" endseg beginseg @@ -4137,8 +4093,7 @@ beginseg name "ovl_Bg_Ikana_Mirror" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.o" - include "build/data/ovl_Bg_Ikana_Mirror/ovl_Bg_Ikana_Mirror.data.o" - include "build/data/ovl_Bg_Ikana_Mirror/ovl_Bg_Ikana_Mirror.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikana_Mirror/ovl_Bg_Ikana_Mirror_reloc.o" endseg beginseg @@ -4534,9 +4489,7 @@ beginseg name "ovl_Eff_Kamejima_Wave" compress include "build/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.o" - include "build/data/ovl_Eff_Kamejima_Wave/ovl_Eff_Kamejima_Wave.data.o" - include "build/data/ovl_Eff_Kamejima_Wave/ovl_Eff_Kamejima_Wave.bss.o" - include "build/data/ovl_Eff_Kamejima_Wave/ovl_Eff_Kamejima_Wave.reloc.o" + include "build/src/overlays/actors/ovl_Eff_Kamejima_Wave/ovl_Eff_Kamejima_Wave_reloc.o" endseg beginseg @@ -4603,8 +4556,11 @@ beginseg name "ovl_Bg_Haka_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.o" - include "build/data/ovl_Bg_Haka_Bombwall/ovl_Bg_Haka_Bombwall.data.o" - include "build/data/ovl_Bg_Haka_Bombwall/ovl_Bg_Haka_Bombwall.reloc.o" + #ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Bg_Haka_Bombwall/ovl_Bg_Haka_Bombwall_reloc.o" + #else + include "build/data/ovl_Bg_Haka_Bombwall/ovl_Bg_Haka_Bombwall.reloc.o" + #endif endseg beginseg @@ -4625,8 +4581,7 @@ beginseg name "ovl_Bg_Iknv_Doukutu" compress include "build/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.o" - include "build/data/ovl_Bg_Iknv_Doukutu/ovl_Bg_Iknv_Doukutu.data.o" - include "build/data/ovl_Bg_Iknv_Doukutu/ovl_Bg_Iknv_Doukutu.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Iknv_Doukutu/ovl_Bg_Iknv_Doukutu_reloc.o" endseg beginseg @@ -4789,8 +4744,7 @@ beginseg name "ovl_Eff_Lastday" compress include "build/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.o" - include "build/data/ovl_Eff_Lastday/ovl_Eff_Lastday.data.o" - include "build/data/ovl_Eff_Lastday/ovl_Eff_Lastday.reloc.o" + include "build/src/overlays/actors/ovl_Eff_Lastday/ovl_Eff_Lastday_reloc.o" endseg beginseg @@ -4840,8 +4794,7 @@ beginseg name "ovl_En_Sth2" compress include "build/src/overlays/actors/ovl_En_Sth2/z_en_sth2.o" - include "build/data/ovl_En_Sth2/ovl_En_Sth2.data.o" - include "build/data/ovl_En_Sth2/ovl_En_Sth2.reloc.o" + include "build/src/overlays/actors/ovl_En_Sth2/ovl_En_Sth2_reloc.o" endseg beginseg @@ -4870,8 +4823,7 @@ beginseg name "ovl_En_Bjt" compress include "build/src/overlays/actors/ovl_En_Bjt/z_en_bjt.o" - include "build/data/ovl_En_Bjt/ovl_En_Bjt.data.o" - include "build/data/ovl_En_Bjt/ovl_En_Bjt.reloc.o" + include "build/src/overlays/actors/ovl_En_Bjt/ovl_En_Bjt_reloc.o" endseg beginseg @@ -4935,8 +4887,7 @@ beginseg name "ovl_Eff_Zoraband" compress include "build/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.o" - include "build/data/ovl_Eff_Zoraband/ovl_Eff_Zoraband.data.o" - include "build/data/ovl_Eff_Zoraband/ovl_Eff_Zoraband.reloc.o" + include "build/src/overlays/actors/ovl_Eff_Zoraband/ovl_Eff_Zoraband_reloc.o" endseg beginseg @@ -5030,8 +4981,7 @@ beginseg name "ovl_Obj_Jgame_Light" compress include "build/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.o" - include "build/data/ovl_Obj_Jgame_Light/ovl_Obj_Jgame_Light.data.o" - include "build/data/ovl_Obj_Jgame_Light/ovl_Obj_Jgame_Light.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Jgame_Light/ovl_Obj_Jgame_Light_reloc.o" endseg beginseg @@ -5100,16 +5050,14 @@ beginseg name "ovl_En_Fall2" compress include "build/src/overlays/actors/ovl_En_Fall2/z_en_fall2.o" - include "build/data/ovl_En_Fall2/ovl_En_Fall2.data.o" - include "build/data/ovl_En_Fall2/ovl_En_Fall2.reloc.o" + include "build/src/overlays/actors/ovl_En_Fall2/ovl_En_Fall2_reloc.o" endseg beginseg name "ovl_Dm_Al" compress include "build/src/overlays/actors/ovl_Dm_Al/z_dm_al.o" - include "build/data/ovl_Dm_Al/ovl_Dm_Al.data.o" - include "build/data/ovl_Dm_Al/ovl_Dm_Al.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Al/ovl_Dm_Al_reloc.o" endseg beginseg @@ -5182,8 +5130,7 @@ beginseg name "ovl_En_Bh" compress include "build/src/overlays/actors/ovl_En_Bh/z_en_bh.o" - include "build/data/ovl_En_Bh/ovl_En_Bh.data.o" - include "build/data/ovl_En_Bh/ovl_En_Bh.reloc.o" + include "build/src/overlays/actors/ovl_En_Bh/ovl_En_Bh_reloc.o" endseg beginseg diff --git a/src/boot_O2_g3/fault.c b/src/boot_O2_g3/fault.c index 1f5503445..bc7e8d34a 100644 --- a/src/boot_O2_g3/fault.c +++ b/src/boot_O2_g3/fault.c @@ -29,7 +29,7 @@ const char* sFpuExceptions[] = { }; void Fault_SleepImpl(u32 duration) { - u64 value = (duration * OS_CPU_COUNTER) / 1000ull; + u64 value = (duration * OS_CPU_COUNTER) / 1000ULL; Sleep_Cycles(value); } @@ -702,8 +702,9 @@ void Fault_ResumeThread(OSThread* t) { osStartThread(t); } -void Fault_CommitFB() { +void Fault_CommitFB(void) { u16* fb; + osViSetYScale(1.0f); osViSetMode(&osViModeNtscLan1); osViSetSpecialFeatures(0x42); // gama_disable|dither_fliter_enable_aa_mode3_disable diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index da93f13fd..942435fa7 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" u8 D_80096B20 = 1; diff --git a/src/boot_O2_g3/yaz0.c b/src/boot_O2_g3/yaz0.c index 80d819acc..5f8e5a0ed 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 d9c7fb221..10d84dcb0 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/code/audio/audio_data.c b/src/code/audio/audio_data.c index c43018922..7238a4bfa 100644 --- a/src/code/audio/audio_data.c +++ b/src/code/audio/audio_data.c @@ -850,11 +850,11 @@ u8 gDefaultShortNoteGateTimeTable[] = { 229, 203, 177, 151, 139, 126, 113, 100, 87, 74, 61, 48, 36, 23, 10, 0, }; -AdsrEnvelope gDefaultEnvelope[] = { +EnvelopePoint gDefaultEnvelope[] = { { 1, 32000 }, { 1000, 32000 }, - { -1, 0 }, - { 0, 0 }, + { ADSR_HANG, 0 }, + { ADSR_DISABLE, 0 }, }; NoteSubEu gZeroNoteSub = { 0 }; diff --git a/src/code/audio/audio_effects.c b/src/code/audio/audio_effects.c index 2dcef2237..ab9228bbf 100644 --- a/src/code/audio/audio_effects.c +++ b/src/code/audio/audio_effects.c @@ -7,7 +7,7 @@ void AudioEffects_SequenceChannelProcessSound(SequenceChannel* channel, s32 reca if (channel->changes.s.volume || recalculateVolume) { channelVolume = channel->volume * channel->volumeScale * channel->seqPlayer->appliedFadeVolume; - if (channel->seqPlayer->muted && (channel->muteBehavior & 0x20)) { + if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_SOFTEN)) { channelVolume = channel->seqPlayer->muteVolumeScale * channelVolume; } channel->appliedVolume = channelVolume * channelVolume; @@ -218,7 +218,7 @@ void AudioEffects_NotePortamentoInit(Note* note) { note->playbackState.portamento = note->playbackState.parentLayer->portamento; } -void AudioEffects_AdsrInit(AdsrState* adsr, AdsrEnvelope* envelope, s16* volOut) { +void AudioEffects_AdsrInit(AdsrState* adsr, EnvelopePoint* envelope, s16* volOut) { adsr->action.asByte = 0; adsr->delay = 0; adsr->envelope = envelope; diff --git a/src/code/audio/audio_heap.c b/src/code/audio/audio_heap.c index b06f6a577..7d3ea8ba6 100644 --- a/src/code/audio/audio_heap.c +++ b/src/code/audio/audio_heap.c @@ -21,45 +21,45 @@ f32 func_8018B0F0(f32 arg0) { void func_8018B10C(void) { s32 i; - gAudioContext.unk_3520[255] = func_8018B0F0(0.25f); - gAudioContext.unk_3520[254] = func_8018B0F0(0.33f); - gAudioContext.unk_3520[253] = func_8018B0F0(0.5f); - gAudioContext.unk_3520[252] = func_8018B0F0(0.66f); - gAudioContext.unk_3520[251] = func_8018B0F0(0.75f); + gAudioContext.adsrDecayTable[255] = func_8018B0F0(0.25f); + gAudioContext.adsrDecayTable[254] = func_8018B0F0(0.33f); + gAudioContext.adsrDecayTable[253] = func_8018B0F0(0.5f); + gAudioContext.adsrDecayTable[252] = func_8018B0F0(0.66f); + gAudioContext.adsrDecayTable[251] = func_8018B0F0(0.75f); for (i = 128; i < 251; i++) { - gAudioContext.unk_3520[i] = func_8018B0F0(251 - i); + gAudioContext.adsrDecayTable[i] = func_8018B0F0(251 - i); } for (i = 16; i < 128; i++) { - gAudioContext.unk_3520[i] = func_8018B0F0(4 * (143 - i)); + gAudioContext.adsrDecayTable[i] = func_8018B0F0(4 * (143 - i)); } for (i = 1; i < 16; i++) { - gAudioContext.unk_3520[i] = func_8018B0F0(60 * (23 - i)); + gAudioContext.adsrDecayTable[i] = func_8018B0F0(60 * (23 - i)); } - gAudioContext.unk_3520[0] = 0.0f; + gAudioContext.adsrDecayTable[0] = 0.0f; } void AudioHeap_ResetLoadStatus(void) { s32 i; for (i = 0; i < ARRAY_COUNT(gAudioContext.fontLoadStatus); i++) { - if (gAudioContext.fontLoadStatus[i] != LOAD_STATUS_5) { - gAudioContext.fontLoadStatus[i] = LOAD_STATUS_0; + if (gAudioContext.fontLoadStatus[i] != LOAD_STATUS_PERMANENT) { + gAudioContext.fontLoadStatus[i] = LOAD_STATUS_NOT_LOADED; } } for (i = 0; i < ARRAY_COUNT(gAudioContext.sampleFontLoadStatus); i++) { - if (gAudioContext.sampleFontLoadStatus[i] != LOAD_STATUS_5) { - gAudioContext.sampleFontLoadStatus[i] = LOAD_STATUS_0; + if (gAudioContext.sampleFontLoadStatus[i] != LOAD_STATUS_PERMANENT) { + gAudioContext.sampleFontLoadStatus[i] = LOAD_STATUS_NOT_LOADED; } } for (i = 0; i < ARRAY_COUNT(gAudioContext.seqLoadStatus); i++) { - if (gAudioContext.seqLoadStatus[i] != LOAD_STATUS_5) { - gAudioContext.seqLoadStatus[i] = LOAD_STATUS_0; + if (gAudioContext.seqLoadStatus[i] != LOAD_STATUS_PERMANENT) { + gAudioContext.seqLoadStatus[i] = LOAD_STATUS_NOT_LOADED; } } } @@ -302,7 +302,7 @@ void AudioHeap_PopCache(s32 tableType) { AudioHeap_DiscardFont(persistent->entries[persistent->numEntries - 1].id); } - loadStatus[persistent->entries[persistent->numEntries - 1].id] = LOAD_STATUS_0; + loadStatus[persistent->entries[persistent->numEntries - 1].id] = LOAD_STATUS_NOT_LOADED; persistent->numEntries--; } @@ -409,12 +409,12 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { } loadStatusEntry0 = - (temporaryCache->entries[0].id == -1) ? LOAD_STATUS_0 : loadStatus[temporaryCache->entries[0].id]; + (temporaryCache->entries[0].id == -1) ? LOAD_STATUS_NOT_LOADED : loadStatus[temporaryCache->entries[0].id]; loadStatusEntry1 = - (temporaryCache->entries[1].id == -1) ? LOAD_STATUS_0 : loadStatus[temporaryCache->entries[1].id]; + (temporaryCache->entries[1].id == -1) ? LOAD_STATUS_NOT_LOADED : loadStatus[temporaryCache->entries[1].id]; if (tableType == FONT_TABLE) { - if (loadStatusEntry0 == LOAD_STATUS_4) { + if (loadStatusEntry0 == LOAD_STATUS_MAYBE_DISCARDABLE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && gAudioContext.notes[i].noteSubEu.bitField0.enabled) { @@ -423,12 +423,12 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { } if (i == gAudioContext.numNotes) { - AudioLoad_SetFontLoadStatus(temporaryCache->entries[0].id, LOAD_STATUS_3); - loadStatusEntry0 = LOAD_STATUS_3; + AudioLoad_SetFontLoadStatus(temporaryCache->entries[0].id, LOAD_STATUS_DISCARDABLE); + loadStatusEntry0 = LOAD_STATUS_DISCARDABLE; } } - if (loadStatusEntry1 == LOAD_STATUS_4) { + if (loadStatusEntry1 == LOAD_STATUS_MAYBE_DISCARDABLE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && gAudioContext.notes[i].noteSubEu.bitField0.enabled) { @@ -437,26 +437,26 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { } if (i == gAudioContext.numNotes) { - AudioLoad_SetFontLoadStatus(temporaryCache->entries[1].id, LOAD_STATUS_3); - loadStatusEntry1 = LOAD_STATUS_3; + AudioLoad_SetFontLoadStatus(temporaryCache->entries[1].id, LOAD_STATUS_DISCARDABLE); + loadStatusEntry1 = LOAD_STATUS_DISCARDABLE; } } } - if (loadStatusEntry0 == LOAD_STATUS_0) { + if (loadStatusEntry0 == LOAD_STATUS_NOT_LOADED) { temporaryCache->nextSide = 0; - } else if (loadStatusEntry1 == LOAD_STATUS_0) { + } else if (loadStatusEntry1 == LOAD_STATUS_NOT_LOADED) { temporaryCache->nextSide = 1; - } else if ((loadStatusEntry0 == LOAD_STATUS_3) && (loadStatusEntry1 == LOAD_STATUS_3)) { + } else if ((loadStatusEntry0 == LOAD_STATUS_DISCARDABLE) && (loadStatusEntry1 == LOAD_STATUS_DISCARDABLE)) { // Use the opposite side from last time. - } else if (loadStatusEntry0 == LOAD_STATUS_3) { + } else if (loadStatusEntry0 == LOAD_STATUS_DISCARDABLE) { temporaryCache->nextSide = 0; - } else if (loadStatusEntry1 == LOAD_STATUS_3) { + } else if (loadStatusEntry1 == LOAD_STATUS_DISCARDABLE) { temporaryCache->nextSide = 1; } else { // Check if there is a side which isn't in active use, if so, evict that one. if (tableType == SEQUENCE_TABLE) { - if (loadStatusEntry0 == LOAD_STATUS_2) { + if (loadStatusEntry0 == LOAD_STATUS_COMPLETE) { for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { if (gAudioContext.seqPlayers[i].enabled && gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[0].id) { @@ -470,7 +470,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { } } - if (loadStatusEntry1 == LOAD_STATUS_2) { + if (loadStatusEntry1 == LOAD_STATUS_COMPLETE) { for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { if (gAudioContext.seqPlayers[i].enabled && gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[1].id) { @@ -484,7 +484,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { } } } else if (tableType == FONT_TABLE) { - if (loadStatusEntry0 == LOAD_STATUS_2) { + if (loadStatusEntry0 == LOAD_STATUS_COMPLETE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && gAudioContext.notes[i].noteSubEu.bitField0.enabled) { @@ -497,7 +497,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { } } - if (loadStatusEntry1 == LOAD_STATUS_2) { + if (loadStatusEntry1 == LOAD_STATUS_COMPLETE) { for (i = 0; i < gAudioContext.numNotes; i++) { if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && gAudioContext.notes[i].noteSubEu.bitField0.enabled) { @@ -514,15 +514,15 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { // No such luck. Evict the side that wasn't chosen last time, except // if it is being loaded into. if (temporaryCache->nextSide == 0) { - if (loadStatusEntry0 == LOAD_STATUS_1) { - if (loadStatusEntry1 == LOAD_STATUS_1) { + if (loadStatusEntry0 == LOAD_STATUS_IN_PROGRESS) { + if (loadStatusEntry1 == LOAD_STATUS_IN_PROGRESS) { goto fail; } temporaryCache->nextSide = 1; } } else { - if (loadStatusEntry1 == LOAD_STATUS_1) { - if (loadStatusEntry0 == LOAD_STATUS_1) { + if (loadStatusEntry1 == LOAD_STATUS_IN_PROGRESS) { + if (loadStatusEntry0 == LOAD_STATUS_IN_PROGRESS) { goto fail; } temporaryCache->nextSide = 0; @@ -544,7 +544,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { AudioHeap_DiscardSampleBank(temporaryCache->entries[side].id); } - loadStatus[temporaryCache->entries[side].id] = LOAD_STATUS_0; + loadStatus[temporaryCache->entries[side].id] = LOAD_STATUS_NOT_LOADED; if (tableType == FONT_TABLE) { AudioHeap_DiscardFont(temporaryCache->entries[side].id); @@ -564,7 +564,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { AudioHeap_DiscardSampleBank(temporaryCache->entries[1].id); } - loadStatus[temporaryCache->entries[1].id] = LOAD_STATUS_0; + loadStatus[temporaryCache->entries[1].id] = LOAD_STATUS_NOT_LOADED; switch (tableType) { case SEQUENCE_TABLE: @@ -594,7 +594,7 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { AudioHeap_DiscardSampleBank(temporaryCache->entries[0].id); } - loadStatus[temporaryCache->entries[0].id] = LOAD_STATUS_0; + loadStatus[temporaryCache->entries[0].id] = LOAD_STATUS_NOT_LOADED; switch (tableType) { case SEQUENCE_TABLE: @@ -1042,8 +1042,8 @@ void AudioHeap_Init(void) { AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, gAudioContext.maxAudioCmds * sizeof(u64)); } - // Initialize unk_3520 (fadeOutVelocities for ADSR) - gAudioContext.unk_3520 = AudioHeap_Alloc(&gAudioContext.miscPool, 0x100 * sizeof(f32)); + // Initialize adsrDecayTable (fadeOutVelocities for ADSR) + gAudioContext.adsrDecayTable = AudioHeap_Alloc(&gAudioContext.miscPool, 0x100 * sizeof(f32)); func_8018B10C(); // Initialize reverbs diff --git a/src/code/audio/audio_load.c b/src/code/audio/audio_load.c index 8faf565ea..b4997a94e 100644 --- a/src/code/audio/audio_load.c +++ b/src/code/audio/audio_load.c @@ -29,7 +29,7 @@ typedef struct { } AudioRelocInfo; // size = 0x18 void AudioLoad_DiscardFont(s32 fontId); -s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2); +s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIndex, s32 seqId, s32 arg2); u8* AudioLoad_SyncLoadSeq(s32 seqId); u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad); SoundFontData* AudioLoad_SyncLoadFont(u32 fontId); @@ -277,7 +277,7 @@ void AudioLoad_InitSampleDmaBuffers(s32 numNotes) { } else { AudioHeap_WritebackDCache(dma->ramAddr, gAudioContext.sampleDmaBufSize); dma->size = gAudioContext.sampleDmaBufSize; - dma->devAddr = 0U; + dma->devAddr = 0; dma->sizeUnused = 0; dma->unused = 0; dma->ttl = 0; @@ -301,9 +301,9 @@ void AudioLoad_InitSampleDmaBuffers(s32 numNotes) { s32 AudioLoad_IsFontLoadComplete(s32 fontId) { if (fontId == 0xFF) { return true; - } else if (gAudioContext.fontLoadStatus[fontId] >= LOAD_STATUS_2) { + } else if (gAudioContext.fontLoadStatus[fontId] >= LOAD_STATUS_COMPLETE) { return true; - } else if (gAudioContext.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= LOAD_STATUS_2) { + } else if (gAudioContext.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= LOAD_STATUS_COMPLETE) { return true; } else { return false; @@ -313,9 +313,10 @@ s32 AudioLoad_IsFontLoadComplete(s32 fontId) { s32 AudioLoad_IsSeqLoadComplete(s32 seqId) { if (seqId == 0xFF) { return true; - } else if (gAudioContext.seqLoadStatus[seqId] >= LOAD_STATUS_2) { + } else if (gAudioContext.seqLoadStatus[seqId] >= LOAD_STATUS_COMPLETE) { return true; - } else if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] >= LOAD_STATUS_2) { + } else if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] >= + LOAD_STATUS_COMPLETE) { return true; } else { return false; @@ -325,10 +326,10 @@ s32 AudioLoad_IsSeqLoadComplete(s32 seqId) { s32 AudioLoad_IsSampleLoadComplete(s32 sampleBankId) { if (sampleBankId == 0xFF) { return true; - } else if (gAudioContext.sampleFontLoadStatus[sampleBankId] >= LOAD_STATUS_2) { + } else if (gAudioContext.sampleFontLoadStatus[sampleBankId] >= LOAD_STATUS_COMPLETE) { return true; } else if (gAudioContext.sampleFontLoadStatus[AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId)] >= - LOAD_STATUS_2) { + LOAD_STATUS_COMPLETE) { return true; } else { return false; @@ -336,32 +337,32 @@ s32 AudioLoad_IsSampleLoadComplete(s32 sampleBankId) { } void AudioLoad_SetFontLoadStatus(s32 fontId, s32 loadStatus) { - if ((fontId != 0xFF) && (gAudioContext.fontLoadStatus[fontId] != LOAD_STATUS_5)) { + if ((fontId != 0xFF) && (gAudioContext.fontLoadStatus[fontId] != LOAD_STATUS_PERMANENT)) { gAudioContext.fontLoadStatus[fontId] = loadStatus; } } void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 loadStatus) { - if ((seqId != 0xFF) && (gAudioContext.seqLoadStatus[seqId] != LOAD_STATUS_5)) { + if ((seqId != 0xFF) && (gAudioContext.seqLoadStatus[seqId] != LOAD_STATUS_PERMANENT)) { gAudioContext.seqLoadStatus[seqId] = loadStatus; } } void AudioLoad_SetSampleFontLoadStatusAndApplyCaches(s32 sampleBankId, s32 loadStatus) { if (sampleBankId != 0xFF) { - if (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5) { + if (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_PERMANENT) { gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus; } - if ((gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_5) || - (gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_2)) { + if ((gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_PERMANENT) || + (gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_COMPLETE)) { AudioHeap_ApplySampleBankCache(sampleBankId); } } } void AudioLoad_SetSampleFontLoadStatus(s32 sampleBankId, s32 loadStatus) { - if ((sampleBankId != 0xFF) && (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5)) { + if ((sampleBankId != 0xFF) && (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_PERMANENT)) { gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus; } } @@ -510,7 +511,7 @@ void AudioLoad_DiscardSeqFonts(s32 seqId) { fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.sequenceFontTable[index++]); if (AudioHeap_SearchPermanentCache(FONT_TABLE, fontId) == NULL) { AudioLoad_DiscardFont(fontId); - AudioLoad_SetFontLoadStatus(fontId, LOAD_STATUS_0); + AudioLoad_SetFontLoadStatus(fontId, LOAD_STATUS_NOT_LOADED); } } } @@ -553,31 +554,31 @@ void func_8018FA60(u32 tableType, u32 id, s32 type, s32 data) { } } -s32 AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2) { +s32 AudioLoad_SyncInitSeqPlayer(s32 playerIndex, s32 seqId, s32 arg2) { if (gAudioContext.resetTimer != 0) { return 0; } - gAudioContext.seqPlayers[playerIdx].skipTicks = 0; - AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, arg2); + gAudioContext.seqPlayers[playerIndex].skipTicks = 0; + AudioLoad_SyncInitSeqPlayerInternal(playerIndex, seqId, arg2); // Intentionally missing return. Returning the result of the above function // call matches but is UB because it too is missing a return, and using the // result of a non-void function that has failed to return a value is UB. // The callers of this function do not use the return value, so it's fine. } -s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks) { +s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIndex, s32 seqId, s32 skipTicks) { if (gAudioContext.resetTimer != 0) { return 0; } - gAudioContext.seqPlayers[playerIdx].skipTicks = skipTicks; - AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, 0); + gAudioContext.seqPlayers[playerIndex].skipTicks = skipTicks; + AudioLoad_SyncInitSeqPlayerInternal(playerIndex, seqId, 0); // Missing return, see above. } -s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { - SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIdx]; +s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIndex, s32 seqId, s32 arg2) { + SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIndex]; u8* seqData; s32 index; s32 numFonts; @@ -620,7 +621,7 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { seqPlayer->scriptState.depth = 0; seqPlayer->delay = 0; seqPlayer->finished = false; - seqPlayer->playerIdx = playerIdx; + seqPlayer->playerIndex = playerIndex; //! @bug missing return (but the return value is not used so it's not UB) } @@ -628,7 +629,7 @@ u8* AudioLoad_SyncLoadSeq(s32 seqId) { s32 pad; s32 didAllocate; - if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] == LOAD_STATUS_1) { + if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] == LOAD_STATUS_IN_PROGRESS) { return NULL; } @@ -649,8 +650,8 @@ u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad addr = AudioLoad_SearchCaches(SAMPLE_TABLE, realTableId); if (addr != NULL) { - if (gAudioContext.sampleFontLoadStatus[realTableId] != LOAD_STATUS_1) { - AudioLoad_SetSampleFontLoadStatus(realTableId, LOAD_STATUS_2); + if (gAudioContext.sampleFontLoadStatus[realTableId] != LOAD_STATUS_IN_PROGRESS) { + AudioLoad_SetSampleFontLoadStatus(realTableId, LOAD_STATUS_COMPLETE); } *outMedium = MEDIUM_RAM; @@ -682,7 +683,7 @@ SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) { AudioRelocInfo relocInfo; s32 realFontId = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId); - if (gAudioContext.fontLoadStatus[realFontId] == LOAD_STATUS_1) { + if (gAudioContext.fontLoadStatus[realFontId] == LOAD_STATUS_IN_PROGRESS) { return NULL; } @@ -730,7 +731,7 @@ void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate) { ramAddr = AudioLoad_SearchCaches(tableType, realId); if (ramAddr != NULL) { *didAllocate = false; - loadStatus = LOAD_STATUS_2; + loadStatus = LOAD_STATUS_COMPLETE; } else { table = AudioLoad_GetLoadTable(tableType); size = table->entries[realId].size; @@ -793,7 +794,7 @@ void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate) { AudioLoad_SyncDma(romAddr, ramAddr, size, medium); } - loadStatus = (cachePolicy == CACHE_LOAD_PERMANENT) ? LOAD_STATUS_5 : LOAD_STATUS_2; + loadStatus = (cachePolicy == CACHE_LOAD_PERMANENT) ? LOAD_STATUS_PERMANENT : LOAD_STATUS_COMPLETE; } switch (tableType) { @@ -1032,19 +1033,19 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, switch (tableType) { case SEQUENCE_TABLE: - if (gAudioContext.seqLoadStatus[realId] == LOAD_STATUS_1) { + if (gAudioContext.seqLoadStatus[realId] == LOAD_STATUS_IN_PROGRESS) { return NULL; } break; case FONT_TABLE: - if (gAudioContext.fontLoadStatus[realId] == LOAD_STATUS_1) { + if (gAudioContext.fontLoadStatus[realId] == LOAD_STATUS_IN_PROGRESS) { return NULL; } break; case SAMPLE_TABLE: - if (gAudioContext.sampleFontLoadStatus[realId] == LOAD_STATUS_1) { + if (gAudioContext.sampleFontLoadStatus[realId] == LOAD_STATUS_IN_PROGRESS) { return NULL; } break; @@ -1052,8 +1053,8 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, ramAddr = AudioLoad_SearchCaches(tableType, realId); if (ramAddr != NULL) { - loadStatus = LOAD_STATUS_2; - osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, LOAD_STATUS_0), OS_MESG_NOBLOCK); + loadStatus = LOAD_STATUS_COMPLETE; + osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, LOAD_STATUS_NOT_LOADED), OS_MESG_NOBLOCK); } else { table = AudioLoad_GetLoadTable(tableType); size = table->entries[realId].size; @@ -1061,7 +1062,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, medium = table->entries[id].medium; cachePolicy = table->entries[id].cachePolicy; romAddr = table->entries[realId].romAddr; - loadStatus = LOAD_STATUS_2; + loadStatus = LOAD_STATUS_COMPLETE; switch (cachePolicy) { case CACHE_LOAD_PERMANENT: @@ -1069,7 +1070,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, if (ramAddr == NULL) { return ramAddr; } - loadStatus = LOAD_STATUS_5; + loadStatus = LOAD_STATUS_PERMANENT; break; case CACHE_LOAD_PERSISTENT: @@ -1119,7 +1120,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, MK_ASYNC_MSG(retData, tableType, realId, loadStatus)); } - loadStatus = LOAD_STATUS_1; + loadStatus = LOAD_STATUS_IN_PROGRESS; } switch (tableType) { diff --git a/src/code/audio/audio_playback.c b/src/code/audio/audio_playback.c index 6ae5696f1..c7789bd36 100644 --- a/src/code/audio/audio_playback.c +++ b/src/code/audio/audio_playback.c @@ -98,7 +98,7 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* at sub->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f)); sub->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f)); - sub->unk_2 = attrs->unk_1; + sub->gain = attrs->gain; sub->filter = attrs->filter; sub->unk_07 = attrs->unk_14; sub->unk_0E = attrs->unk_16; @@ -125,7 +125,7 @@ void AudioPlayback_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRat } void AudioPlayback_NoteInit(Note* note) { - if (note->playbackState.parentLayer->adsr.releaseRate == 0) { + if (note->playbackState.parentLayer->adsr.decayIndex == 0) { AudioEffects_AdsrInit(¬e->playbackState.adsr, note->playbackState.parentLayer->channel->adsr.envelope, ¬e->playbackState.adsrVolScaleUnused); } else { @@ -189,7 +189,7 @@ void AudioPlayback_ProcessNotes(void) { playbackState->unk_04 = 1; continue; } else if (playbackState->parentLayer->channel->seqPlayer->muted && - (playbackState->parentLayer->channel->muteBehavior & 0x40)) { + (playbackState->parentLayer->channel->muteFlags & MUTE_FLAGS_STOP_NOTES)) { // do nothing } else { goto out; @@ -257,7 +257,7 @@ void AudioPlayback_ProcessNotes(void) { subAttrs.pan = attrs->pan; subAttrs.reverbVol = attrs->reverb; subAttrs.stereo = attrs->stereo; - subAttrs.unk_1 = attrs->unk_1; + subAttrs.gain = attrs->gain; subAttrs.filter = attrs->filter; subAttrs.unk_14 = attrs->unk_4; subAttrs.unk_16 = attrs->unk_6; @@ -290,9 +290,9 @@ void AudioPlayback_ProcessNotes(void) { } if (layer->unk_0A.s.bit_9 == 1) { - subAttrs.unk_1 = channel->unk_0C; + subAttrs.gain = channel->gain; } else { - subAttrs.unk_1 = 0; + subAttrs.gain = 0; if (1) {} } @@ -301,7 +301,7 @@ void AudioPlayback_ProcessNotes(void) { subAttrs.unk_16 = channel->unk_20; bookOffset = channel->bookOffset & 0x7; - if (channel->seqPlayer->muted && (channel->muteBehavior & 8)) { + if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_3)) { subAttrs.frequency = 0.0f; subAttrs.velocity = 0.0f; } @@ -506,9 +506,9 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { } if (layer->unk_0A.s.bit_9 == 1) { - attrs->unk_1 = chan->unk_0C; + attrs->gain = chan->gain; } else { - attrs->unk_1 = 0; + attrs->gain = 0; } attrs->filter = chan->filter; @@ -522,7 +522,7 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { attrs->unk_6 = chan->unk_20; attrs->unk_4 = chan->unk_0F; - if (chan->seqPlayer->muted && (chan->muteBehavior & 8)) { + if (chan->seqPlayer->muted && (chan->muteFlags & MUTE_FLAGS_3)) { note->noteSubEu.bitField0.finished = true; } @@ -546,10 +546,10 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { } else { note->playbackState.unk_04 = 1; note->playbackState.adsr.action.s.decay = true; - if (layer->adsr.releaseRate == 0) { - note->playbackState.adsr.fadeOutVel = gAudioContext.unk_3520[layer->channel->adsr.releaseRate]; + if (layer->adsr.decayIndex == 0) { + note->playbackState.adsr.fadeOutVel = gAudioContext.adsrDecayTable[layer->channel->adsr.decayIndex]; } else { - note->playbackState.adsr.fadeOutVel = gAudioContext.unk_3520[layer->adsr.releaseRate]; + note->playbackState.adsr.fadeOutVel = gAudioContext.adsrDecayTable[layer->adsr.decayIndex]; } note->playbackState.adsr.sustain = ((f32)(s32)(layer->channel->adsr.sustain) * note->playbackState.adsr.current) / 256.0f; diff --git a/src/code/audio/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c index e57ad19b5..d504f9f3a 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/code/audio/audio_seqplayer.c @@ -1,73 +1,2312 @@ +/** + * @file audio_seqplayer.c + * + * Manages audio sequence players, interprets and executes sequence instructions used to write .seq files + * + * Sequence Instructions: + * - A customized assembly language based on MIDI + * - All sequences are written using these instructions + * - There are 3 different sets of instructions + * 1) Sequence Instructions + * 2) Channel Instructions + * 3) Layer Instruction + * - All three sets share a common pool of control flow instructions (>= 0xF2). + * Otherwise, each set of instructions has its own command interpreter + */ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_801974D0.s") +#define PORTAMENTO_IS_SPECIAL(x) ((x).mode & 0x80) +#define PORTAMENTO_MODE(x) ((x).mode & ~0x80) -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197538.s") +#define PROCESS_SCRIPT_END -1 -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197714.s") +typedef enum { + /* 0 */ PORTAMENTO_MODE_OFF, + /* 1 */ PORTAMENTO_MODE_1, + /* 2 */ PORTAMENTO_MODE_2, + /* 3 */ PORTAMENTO_MODE_3, + /* 4 */ PORTAMENTO_MODE_4, + /* 5 */ PORTAMENTO_MODE_5 +} PortamentoMode; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197880.s") +u8 AudioSeq_ScriptReadU8(SeqScriptState* state); +s16 AudioSeq_ScriptReadS16(SeqScriptState* state); +u16 AudioSeq_ScriptReadCompressedU16(SeqScriptState* state); +void AudioSeq_SeqLayerProcessScriptStep1(SequenceLayer* layer); +s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameSound); +s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer); +s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd); +s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd); +u8 AudioSeq_GetInstrument(SequenceChannel* channel, u8 instId, Instrument** instOut, AdsrSettings* adsr); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_801979D8.s") +/** + * sSeqInstructionArgsTable is a table for each sequence instruction + * that contains both how many arguments an instruction takes, as well + * as the type of each argument + * + * sSeqInstructionArgsTable is bitpacked as follows: + * abcUUUnn + * + * n - number of arguments that the sequence instruction takes + * + * a - bitFlag for the type of arg0 if it exists + * b - bitFlag for the type of arg1 if it exists + * c - bitFlag for the type of arg2 if it exists + * + * bitFlag on - argument is s16 + * bitFlag off - argument is u8 + * + * U - Unused + */ -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197A54.s") +// CMD_ARGS_(NUMBER_OF_ARGS) +#define CMD_ARGS_0() 0 +#define CMD_ARGS_1(arg0Type) (((sizeof(arg0Type) - 1) << 7) | 1) +#define CMD_ARGS_2(arg0Type, arg1Type) (((sizeof(arg0Type) - 1) << 7) | ((sizeof(arg1Type) - 1) << 6) | 2) +#define CMD_ARGS_3(arg0Type, arg1Type, arg2Type) \ + (((sizeof(arg0Type) - 1) << 7) | ((sizeof(arg1Type) - 1) << 6) | ((sizeof(arg2Type) - 1) << 5) | 3) -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelDisable.s") +u8 sSeqInstructionArgsTable[] = { + CMD_ARGS_1(s16), // 0xA0 (channel:) + CMD_ARGS_0(), // 0xA1 (channel:) + CMD_ARGS_1(s16), // 0xA2 (channel:) + CMD_ARGS_0(), // 0xA3 (channel:) + CMD_ARGS_1(u8), // 0xA4 (channel:) + CMD_ARGS_0(), // 0xA5 (channel:) + CMD_ARGS_2(u8, s16), // 0xA6 (channel:) + CMD_ARGS_1(u8), // 0xA7 (channel:) + CMD_ARGS_2(s16, s16), // 0xA8 (channel: random range large) + CMD_ARGS_0(), // 0xA9 () + CMD_ARGS_0(), // 0xAA () + CMD_ARGS_0(), // 0xAB () + CMD_ARGS_0(), // 0xAC () + CMD_ARGS_0(), // 0xAD () + CMD_ARGS_0(), // 0xAE () + CMD_ARGS_0(), // 0xAF () + CMD_ARGS_1(s16), // 0xB0 (channel: set filter) + CMD_ARGS_0(), // 0xB1 (channel: clear filter) + CMD_ARGS_1(s16), // 0xB2 (channel: dynread sequence large) + CMD_ARGS_1(u8), // 0xB3 (channel: load filter) + CMD_ARGS_0(), // 0xB4 (channel: set dyntable large) + CMD_ARGS_0(), // 0xB5 (channel: read dyntable large) + CMD_ARGS_0(), // 0xB6 (channel: read dyntable) + CMD_ARGS_1(s16), // 0xB7 (channel: random large) + CMD_ARGS_1(u8), // 0xB8 (channel: random) + CMD_ARGS_1(u8), // 0xB9 (channel: set velocity random variance) + CMD_ARGS_1(u8), // 0xBA (channel: set gatetime random variance) + CMD_ARGS_2(u8, s16), // 0xBB (channel:) + CMD_ARGS_1(s16), // 0xBC (channel: add large) + CMD_ARGS_1(s16), // 0xBD (channel:) + CMD_ARGS_1(u8), // 0xBE (channel:) + CMD_ARGS_0(), // 0xBF () + CMD_ARGS_0(), // 0xC0 () + CMD_ARGS_1(u8), // 0xC1 (channel: set instrument) + CMD_ARGS_1(s16), // 0xC2 (channel: set dyntable) + CMD_ARGS_0(), // 0xC3 (channel: large notes off) + CMD_ARGS_0(), // 0xC4 (channel: large notes on) + CMD_ARGS_0(), // 0xC5 (channel: dyn set dyntable) + CMD_ARGS_1(u8), // 0xC6 (channel: set soundFont) + CMD_ARGS_2(u8, s16), // 0xC7 (channel: write into sequence script) + CMD_ARGS_1(u8), // 0xC8 (channel: subtract -> set value) + CMD_ARGS_1(u8), // 0xC9 (channel: `bit and` -> set value) + CMD_ARGS_1(u8), // 0xCA (channel: set mute behavior) + CMD_ARGS_1(s16), // 0xCB (channel: read sequence -> set value) + CMD_ARGS_1(u8), // 0xCC (channel: set value) + CMD_ARGS_1(u8), // 0xCD (channel: disable channel) + CMD_ARGS_1(s16), // 0xCE (channel:) + CMD_ARGS_1(s16), // 0xCF (channel: write large into sequence script) + CMD_ARGS_1(u8), // 0xD0 (channel: stereo headset effects) + CMD_ARGS_1(u8), // 0xD1 (channel: set note allocation policy) + CMD_ARGS_1(u8), // 0xD2 (channel: set sustain) + CMD_ARGS_1(u8), // 0xD3 (channel: large bend pitch) + CMD_ARGS_1(u8), // 0xD4 (channel: set reverb) + CMD_ARGS_1(u8), // 0xD5 () + CMD_ARGS_1(u8), // 0xD6 () + CMD_ARGS_1(u8), // 0xD7 (channel: set vibrato rate) + CMD_ARGS_1(u8), // 0xD8 (channel: set vibrato extent) + CMD_ARGS_1(u8), // 0xD9 (channel: set decay index) + CMD_ARGS_1(s16), // 0xDA (channel: set envelope) + CMD_ARGS_1(u8), // 0xDB (channel: transpose) + CMD_ARGS_1(u8), // 0xDC (channel: set pan mix) + CMD_ARGS_1(u8), // 0xDD (channel: set pan) + CMD_ARGS_1(s16), // 0xDE (channel: set freqscale) + CMD_ARGS_1(u8), // 0xDF (channel: set volume) + CMD_ARGS_1(u8), // 0xE0 (channel: set volume scale) + CMD_ARGS_3(u8, u8, u8), // 0xE1 (channel: set vibratorate linear) + CMD_ARGS_3(u8, u8, u8), // 0xE2 (channel: set vibrato extent linear) + CMD_ARGS_1(u8), // 0xE3 (channel: set vibrato delay) + CMD_ARGS_0(), // 0xE4 (channel: dyncall) + CMD_ARGS_1(u8), // 0xE5 (channel: set reverb index) + CMD_ARGS_1(u8), // 0xE6 (channel: set book offset) + CMD_ARGS_1(s16), // 0xE7 (channel:) + CMD_ARGS_3(u8, u8, u8), // 0xE8 (channel:) + CMD_ARGS_1(u8), // 0xE9 (channel: set note priority) + CMD_ARGS_0(), // 0xEA (channel: stop script) + CMD_ARGS_2(u8, u8), // 0xEB (channel: set soundFont and instrument) + CMD_ARGS_0(), // 0xEC (channel: reset vibrato) + CMD_ARGS_1(u8), // 0xED (channel: set hilo gain) + CMD_ARGS_1(u8), // 0xEE (channel: small bend pitch) + CMD_ARGS_2(s16, u8), // 0xEF () + CMD_ARGS_0(), // 0xF0 (channel: unreserve notes) + CMD_ARGS_1(u8), // 0xF1 (channel: reserve notes) + // Control flow instructions (>= 0xF2) can only have 0 or 1 args + CMD_ARGS_1(u8), // 0xF2 (branch relative if less than zero) + CMD_ARGS_1(u8), // 0xF3 (branch relative if equal to zero) + CMD_ARGS_1(u8), // 0xF4 (jump relative) + CMD_ARGS_1(s16), // 0xF5 (branch if greater than or equal to zero) + CMD_ARGS_0(), // 0xF6 (break) + CMD_ARGS_0(), // 0xF7 (loop end) + CMD_ARGS_1(u8), // 0xF8 (loop) + CMD_ARGS_1(s16), // 0xF9 (branch if less than zero) + CMD_ARGS_1(s16), // 0xFA (branch if equal to zero) + CMD_ARGS_1(s16), // 0xFB (jump) + CMD_ARGS_1(s16), // 0xFC (call and jump to a function) + CMD_ARGS_0(), // 0xFD (delay n frames) + CMD_ARGS_0(), // 0xFE (delay 1 frame) + CMD_ARGS_0(), // 0xFF (end script) +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197B14.s") +/** + * Read and return the argument from the sequence script for a control flow instruction. + * Control flow instructions (>= 0xF2) can only have 0 or 1 args. + * + * @return the argument value for a control flow instruction, or 0 if there is no argument + */ +u16 AudioSeq_GetScriptControlFlowArgument(SeqScriptState* state, u8 cmd) { + u8 highBits = sSeqInstructionArgsTable[cmd - 0xA0]; + u8 lowBits = highBits & 3; + u16 cmdArg = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197C0C.s") + // only 1 argument + if (lowBits == 1) { + if (!(highBits & 0x80)) { + cmdArg = AudioSeq_ScriptReadU8(state); + } else { + cmdArg = AudioSeq_ScriptReadS16(state); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197C8C.s") + return cmdArg; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableAsFinished.s") +/** + * Read and execute the control flow sequence instructions + * + * @return number of frames until next instruction. -1 signals termination + */ +s32 AudioSeq_HandleScriptFlowControl(SequencePlayer* seqPlayer, SeqScriptState* state, s32 cmd, s32 cmdArg) { + u32 depth; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisable.s") + switch (cmd) { + case 0xFF: // end script + if (state->depth == 0) { + return PROCESS_SCRIPT_END; + } + state->pc = state->stack[--state->depth]; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPushBack.s") + case 0xFD: // delay n frames + return AudioSeq_ScriptReadCompressedU16(state); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPopBack.s") + case 0xFE: // delay 1 frame + return 1; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197E88.s") + case 0xFC: // call and jump to a function + state->stack[depth = state->depth++] = state->pc; + state->pc = seqPlayer->seqData + (u16)cmdArg; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197F28.s") + case 0xF8: // loop + state->remLoopIters[depth = state->depth] = cmdArg; + state->stack[state->depth++] = state->pc; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197F3C.s") + case 0xF7: // loop end + state->remLoopIters[state->depth - 1]--; + if (state->remLoopIters[state->depth - 1] != 0) { + state->pc = state->stack[state->depth - 1]; + } else { + state->depth--; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197F74.s") + case 0xF6: // break + state->depth--; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197FB4.s") + case 0xF5: // branch if greater than or equal to zero + case 0xF9: // branch if less than zero + case 0xFA: // branch if equal to zero + case 0xFB: // jump + if ((cmd == 0xFA) && (state->value != 0)) { + break; + } + if ((cmd == 0xF9) && (state->value >= 0)) { + break; + } + if ((cmd == 0xF5) && (state->value < 0)) { + break; + } + state->pc = seqPlayer->seqData + (u16)cmdArg; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_801980D0.s") + case 0xF2: // branch relative if less than zero + case 0xF3: // branch relative if equal to zero + case 0xF4: // jump relative + if ((cmd == 0xF3) && (state->value != 0)) { + break; + } + if ((cmd == 0xF2) && (state->value >= 0)) { + break; + } + state->pc += (s8)(cmdArg & 0xFF); + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019815C.s") + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019825C.s") +void AudioSeq_InitSequenceChannel(SequenceChannel* channel) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80198640.s") + if (channel == &gAudioContext.sequenceChannelNone) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80198CE0.s") + channel->enabled = false; + channel->finished = false; + channel->stopScript = false; + channel->stopSomething2 = false; + channel->hasInstrument = false; + channel->stereoHeadsetEffects = false; + channel->transposition = 0; + channel->largeNotes = false; + channel->bookOffset = 0; + channel->stereo.asByte = 0; + channel->changes.asByte = 0xFF; + channel->scriptState.depth = 0; + channel->newPan = 0x40; + channel->panChannelWeight = 0x80; + channel->unk_10 = 0xFF; + channel->velocityRandomVariance = 0; + channel->gateTimeRandomVariance = 0; + channel->noteUnused = NULL; + channel->reverbIndex = 0; + channel->reverb = 0; + channel->gain = 0; + channel->notePriority = 3; + channel->someOtherPriority = 1; + channel->delay = 0; + channel->adsr.envelope = gDefaultEnvelope; + channel->adsr.decayIndex = 0xF0; + channel->adsr.sustain = 0; + channel->vibrato.vibratoRateTarget = 0x800; + channel->vibrato.vibratoRateStart = 0x800; + channel->vibrato.vibratoExtentTarget = 0; + channel->vibrato.vibratoExtentStart = 0; + channel->vibrato.vibratoRateChangeDelay = 0; + channel->vibrato.vibratoExtentChangeDelay = 0; + channel->vibrato.vibratoDelay = 0; + channel->filter = NULL; + channel->unk_20 = 0; + channel->unk_0F = 0; + channel->volume = 1.0f; + channel->volumeScale = 1.0f; + channel->freqScale = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_801990F4.s") + for (i = 0; i < ARRAY_COUNT(channel->soundScriptIO); i++) { + channel->soundScriptIO[i] = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80199124.s") + channel->unused = false; + AudioPlayback_InitNoteLists(&channel->notePool); + channel->unk_DC = 0; + channel->unk_E0 = 0; + channel->sfxState = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80199198.s") +s32 AudioSeq_SeqChannelSetLayer(SequenceChannel* channel, s32 layerIndex) { + SequenceLayer* layer; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80199244.s") + if (channel->layers[layerIndex] == NULL) { + layer = AudioSeq_AudioListPopBack(&gAudioContext.layerFreeList); + channel->layers[layerIndex] = layer; + if (layer == NULL) { + channel->layers[layerIndex] = NULL; + return -1; + } + } else { + AudioPlayback_SeqLayerNoteDecay(channel->layers[layerIndex]); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80199268.s") + layer = channel->layers[layerIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019A0BC.s") + layer->channel = channel; + layer->adsr = channel->adsr; + layer->adsr.decayIndex = 0; + layer->unk_09 = channel->reverb; + layer->enabled = true; + layer->finished = false; + layer->stopSomething = false; + layer->continuousNotes = false; + layer->bit3 = false; + layer->ignoreDrumPan = false; + layer->bit1 = false; + layer->notePropertiesNeedInit = false; + layer->gateTime = 0x80; + layer->unk_08 = 0x80; + layer->stereo.asByte = 0; + layer->portamento.mode = PORTAMENTO_MODE_OFF; + layer->scriptState.depth = 0; + layer->pan = 0x40; + layer->transposition = 0; + layer->delay = 0; + layer->gateDelay = 0; + layer->delay2 = 0; + layer->note = NULL; + layer->instrument = NULL; + layer->instOrWave = 0xFF; + layer->unk_0A.asByte = 0xFFFF; + layer->vibrato.vibratoRateTarget = 0x800; + layer->vibrato.vibratoRateStart = 0x800; + layer->vibrato.vibratoExtentTarget = 0; + layer->vibrato.vibratoExtentStart = 0; + layer->vibrato.vibratoRateChangeDelay = 0; + layer->vibrato.vibratoExtentChangeDelay = 0; + layer->vibrato.vibratoDelay = 0; + layer->freqScale = 1.0f; + layer->bend = 1.0f; + layer->velocitySquare2 = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AA3C.s") + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AAF0.s") +void AudioSeq_SeqLayerDisable(SequenceLayer* layer) { + if (layer != NULL) { + if ((layer->channel != &gAudioContext.sequenceChannelNone) && (layer->channel->seqPlayer->finished == true)) { + AudioPlayback_SeqLayerNoteRelease(layer); + } else { + AudioPlayback_SeqLayerNoteDecay(layer); + } + layer->enabled = false; + layer->finished = true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_ResetSequencePlayer.s") +void AudioSeq_SeqLayerFree(SequenceChannel* channel, s32 layerIndex) { + SequenceLayer* layer = channel->layers[layerIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayerChannels.s") + if (layer != NULL) { + AudioSeq_AudioListPushBack(&gAudioContext.layerFreeList, &layer->listItem); + AudioSeq_SeqLayerDisable(layer); + channel->layers[layerIndex] = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019ACEC.s") +void AudioSeq_SequenceChannelDisable(SequenceChannel* channel) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayers.s") + channel->finished = true; + + for (i = 0; i < 4; i++) { + AudioSeq_SeqLayerFree(channel, i); + } + + AudioPlayback_NotePoolClear(&channel->notePool); + channel->enabled = false; +} + +void AudioSeq_SequencePlayerSetupChannels(SequencePlayer* seqPlayer, u16 channelBits) { + SequenceChannel* channel; + s32 i; + + for (i = 0; i < SEQ_NUM_CHANNELS; i++) { + if (channelBits & 1) { + channel = seqPlayer->channels[i]; + channel->fontId = seqPlayer->defaultFont; + channel->muteFlags = seqPlayer->muteFlags; + channel->noteAllocPolicy = seqPlayer->noteAllocPolicy; + } + channelBits = channelBits >> 1; + } +} + +void AudioSeq_SequencePlayerDisableChannels(SequencePlayer* seqPlayer, u16 channelBitsUnused) { + SequenceChannel* channel; + s32 i; + + for (i = 0; i < SEQ_NUM_CHANNELS; i++) { + channel = seqPlayer->channels[i]; + if (IS_SEQUENCE_CHANNEL_VALID(channel) == 1) { + AudioSeq_SequenceChannelDisable(channel); + } + } +} + +void AudioSeq_SequenceChannelEnable(SequencePlayer* seqPlayer, u8 channelIndex, void* script) { + SequenceChannel* channel = seqPlayer->channels[channelIndex]; + s32 i; + + channel->enabled = true; + channel->finished = false; + channel->scriptState.depth = 0; + channel->scriptState.pc = script; + channel->delay = 0; + + for (i = 0; i < ARRAY_COUNT(channel->layers); i++) { + if (channel->layers[i] != NULL) { + AudioSeq_SeqLayerFree(channel, i); + } + } +} + +void AudioSeq_SequencePlayerDisableAsFinished(SequencePlayer* seqPlayer) { + seqPlayer->finished = true; + AudioSeq_SequencePlayerDisable(seqPlayer); +} + +void AudioSeq_SequencePlayerDisable(SequencePlayer* seqPlayer) { + AudioSeq_SequencePlayerDisableChannels(seqPlayer, 0xFFFF); + AudioPlayback_NotePoolClear(&seqPlayer->notePool); + if (!seqPlayer->enabled) { + return; + } + + seqPlayer->enabled = false; + seqPlayer->finished = true; + + if (AudioLoad_IsSeqLoadComplete(seqPlayer->seqId)) { + AudioLoad_SetSeqLoadStatus(seqPlayer->seqId, LOAD_STATUS_DISCARDABLE); + } + + if (AudioLoad_IsFontLoadComplete(seqPlayer->defaultFont)) { + AudioLoad_SetFontLoadStatus(seqPlayer->defaultFont, LOAD_STATUS_MAYBE_DISCARDABLE); + } + + if (seqPlayer->defaultFont == gAudioContext.fontCache.temporary.entries[0].id) { + gAudioContext.fontCache.temporary.nextSide = 1; + } else if (seqPlayer->defaultFont == gAudioContext.fontCache.temporary.entries[1].id) { + gAudioContext.fontCache.temporary.nextSide = 0; + } +} + +void AudioSeq_AudioListPushBack(AudioListItem* list, AudioListItem* item) { + if (item->prev == NULL) { + list->prev->next = item; + item->prev = list->prev; + item->next = list; + list->prev = item; + list->u.count++; + item->pool = list->pool; + } +} + +void* AudioSeq_AudioListPopBack(AudioListItem* list) { + AudioListItem* item = list->prev; + + if (item == list) { + return NULL; + } + + item->prev->next = list; + list->prev = item->prev; + item->prev = NULL; + list->u.count--; + + return item->u.value; +} + +void AudioSeq_InitLayerFreelist(void) { + s32 i; + + gAudioContext.layerFreeList.prev = &gAudioContext.layerFreeList; + gAudioContext.layerFreeList.next = &gAudioContext.layerFreeList; + gAudioContext.layerFreeList.u.count = 0; + gAudioContext.layerFreeList.pool = NULL; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.sequenceLayers); i++) { + gAudioContext.sequenceLayers[i].listItem.u.value = &gAudioContext.sequenceLayers[i]; + gAudioContext.sequenceLayers[i].listItem.prev = NULL; + AudioSeq_AudioListPushBack(&gAudioContext.layerFreeList, &gAudioContext.sequenceLayers[i].listItem); + } +} + +u8 AudioSeq_ScriptReadU8(SeqScriptState* state) { + return *(state->pc++); +} + +s16 AudioSeq_ScriptReadS16(SeqScriptState* state) { + s16 ret = *(state->pc++) << 8; + + ret = *(state->pc++) | ret; + return ret; +} + +u16 AudioSeq_ScriptReadCompressedU16(SeqScriptState* state) { + u16 ret = *(state->pc++); + + if (ret & 0x80) { + ret = (ret << 8) & 0x7F00; + ret = *(state->pc++) | ret; + } + return ret; +} + +void AudioSeq_SeqLayerProcessScript(SequenceLayer* layer) { + s32 cmd; + + if (!layer->enabled) { + return; + } + + if (layer->delay > 1) { + layer->delay--; + if (!layer->stopSomething && (layer->delay <= layer->gateDelay)) { + AudioPlayback_SeqLayerNoteDecay(layer); + layer->stopSomething = true; + } + return; + } + + AudioSeq_SeqLayerProcessScriptStep1(layer); + + do { + cmd = AudioSeq_SeqLayerProcessScriptStep2(layer); + if (cmd == PROCESS_SCRIPT_END) { + return; + } + + cmd = AudioSeq_SeqLayerProcessScriptStep3(layer, cmd); + + } while ((cmd == -1) && (layer->delay == 0)); + + if (cmd != PROCESS_SCRIPT_END) { + // returns `sameSound` instead of a command + cmd = AudioSeq_SeqLayerProcessScriptStep4(layer, cmd); + } + + if (cmd != PROCESS_SCRIPT_END) { + AudioSeq_SeqLayerProcessScriptStep5(layer, cmd); + } + + if (layer->stopSomething == true) { + if ((layer->note != NULL) || layer->continuousNotes) { + AudioPlayback_SeqLayerNoteDecay(layer); + } + } +} + +void AudioSeq_SeqLayerProcessScriptStep1(SequenceLayer* layer) { + if (!layer->continuousNotes) { + AudioPlayback_SeqLayerNoteDecay(layer); + } else if ((layer->note != NULL) && (layer->note->playbackState.wantedParentLayer == layer)) { + AudioPlayback_SeqLayerNoteDecay(layer); + } + + if ((PORTAMENTO_MODE(layer->portamento) == PORTAMENTO_MODE_1) || + (PORTAMENTO_MODE(layer->portamento) == PORTAMENTO_MODE_2)) { + layer->portamento.mode = PORTAMENTO_MODE_OFF; + } + layer->notePropertiesNeedInit = true; +} + +s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameSound) { + Note* note; + + if ((layer->continuousNotes == true) && (layer->bit1 == true)) { + return 0; + } + + if ((layer->continuousNotes == true) && (layer->note != NULL) && layer->bit3 && (sameSound == true) && + (layer->note->playbackState.parentLayer == layer)) { + if (layer->sound == NULL) { + AudioPlayback_InitSyntheticWave(layer->note, layer); + } + } else { + if (!sameSound) { + AudioPlayback_SeqLayerNoteDecay(layer); + } + + layer->note = AudioPlayback_AllocNote(layer); + + if (layer->note != NULL) { + note = layer->note; + + if (note->playbackState.parentLayer == layer) { + AudioEffects_NoteVibratoInit(note); + } + } + } + + if ((layer->note != NULL) && (layer->note->playbackState.parentLayer == layer)) { + note = layer->note; + + AudioEffects_NotePortamentoInit(note); + } + + return 0; +} + +s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { + SequenceChannel* channel = layer->channel; + SeqScriptState* state = &layer->scriptState; + SequencePlayer* seqPlayer = channel->seqPlayer; + u8 cmd; + u8 cmdArg8; + u16 cmdArg16; + u16 velocity; + + while (true) { + cmd = AudioSeq_ScriptReadU8(state); + + // Note Commands + // To be processed in AudioSeq_SeqLayerProcessScriptStep3 + if (cmd <= 0xC0) { + return cmd; + } + + // Control Flow Commands + if (cmd >= 0xF2) { + cmdArg16 = AudioSeq_GetScriptControlFlowArgument(state, cmd); + + if (AudioSeq_HandleScriptFlowControl(seqPlayer, state, cmd, cmdArg16) == 0) { + continue; + } + AudioSeq_SeqLayerDisable(layer); + return PROCESS_SCRIPT_END; + } + + switch (cmd) { + case 0xC1: // layer: set short note velocity + case 0xCA: // layer: set pan + cmdArg8 = *(state->pc++); + if (cmd == 0xC1) { + layer->velocitySquare = SQ(cmdArg8) / SQ(127.0f); + } else { + layer->pan = cmdArg8; + } + break; + + case 0xC9: // layer: set short note gatetime + case 0xC2: // layer: set transposition in semitones + cmdArg8 = *(state->pc++); + if (cmd == 0xC9) { + layer->gateTime = cmdArg8; + } else { + layer->transposition = cmdArg8; + } + break; + + case 0xC4: // layer: continuous notes on + case 0xC5: // layer: continuous notes off + if (cmd == 0xC4) { + layer->continuousNotes = true; + } else { + layer->continuousNotes = false; + } + layer->bit1 = false; + AudioPlayback_SeqLayerNoteDecay(layer); + break; + + case 0xC3: // layer: set short note default delay + cmdArg16 = AudioSeq_ScriptReadCompressedU16(state); + layer->shortNoteDefaultDelay = cmdArg16; + break; + + case 0xC6: // layer: set instrument + cmd = AudioSeq_ScriptReadU8(state); + if (cmd >= 0x7E) { + if (cmd == 0x7E) { + // Sfxs + layer->instOrWave = 1; + } else if (cmd == 0x7F) { + // Drums + layer->instOrWave = 0; + } else { + // Synthetic Wave + layer->instOrWave = cmd; + layer->instrument = NULL; + } + + if (cmd == 0xFF) { + layer->adsr.decayIndex = 0; + } + } else { + // Instrument + if ((layer->instOrWave = AudioSeq_GetInstrument(channel, cmd, &layer->instrument, &layer->adsr)) == + 0) { + layer->instOrWave = 0xFF; + } + } + break; + + case 0xC7: // layer: enable portamento + layer->portamento.mode = AudioSeq_ScriptReadU8(state); + + cmd = AudioSeq_ScriptReadU8(state); + cmd += channel->transposition; + cmd += layer->transposition; + cmd += seqPlayer->transposition; + + if (cmd >= 0x80) { + cmd = 0; + } + + layer->portamentoTargetNote = cmd; + + // If special, the next param is u8 instead of var + if (PORTAMENTO_IS_SPECIAL(layer->portamento)) { + layer->portamentoTime = *(state->pc++); + break; + } + + cmdArg16 = AudioSeq_ScriptReadCompressedU16(state); + layer->portamentoTime = cmdArg16; + break; + + case 0xC8: // layer: disable portamento + layer->portamento.mode = PORTAMENTO_MODE_OFF; + break; + + case 0xCB: // layer: set envelope and decay index + cmdArg16 = AudioSeq_ScriptReadS16(state); + layer->adsr.envelope = (EnvelopePoint*)(seqPlayer->seqData + cmdArg16); + // fallthrough + case 0xCF: // layer: set decay index + layer->adsr.decayIndex = AudioSeq_ScriptReadU8(state); + break; + + case 0xCC: // layer: ignore drum pan + layer->ignoreDrumPan = true; + break; + + case 0xCD: // layer: stereo effects + layer->stereo.asByte = AudioSeq_ScriptReadU8(state); + break; + + case 0xCE: // layer: bend pitch + cmdArg8 = AudioSeq_ScriptReadU8(state); + layer->bend = gBendPitchTwoSemitonesFrequencies[(u8)(cmdArg8 + 0x80)]; + break; + + case 0xF0: // layer: + cmdArg16 = AudioSeq_ScriptReadS16(state); + layer->unk_0A.asByte &= (cmdArg16 ^ 0xFFFF); + break; + + case 0xF1: // layer: + layer->unk_08 = AudioSeq_ScriptReadU8(state); + break; + + default: + switch (cmd & 0xF0) { + case 0xD0: // layer: set short note velocity from table + velocity = seqPlayer->shortNoteVelocityTable[cmd & 0xF]; + layer->velocitySquare = SQ(velocity) / SQ(127.0f); + break; + + case 0xE0: // layer: set short note gatetime from table + layer->gateTime = seqPlayer->shortNoteGateTimeTable[cmd & 0xF]; + break; + } + } + } +} + +s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { + s32 sameSound = true; + s32 instOrWave; + s32 speed; + f32 temp_f14; + f32 temp_f2; + Portamento* portamento; + f32 freqScale; + f32 freqScale2; + SoundFontSound* sound; + Instrument* instrument; + Drum* drum; + s32 pad; + SequenceChannel* channel; + SequencePlayer* seqPlayer; + u8 semitone = cmd; + u16 sfxId; + s32 semitone2; + s32 vel; + f32 time; + f32 tuning; + s32 speed2; + + instOrWave = layer->instOrWave; + channel = layer->channel; + seqPlayer = channel->seqPlayer; + + if (instOrWave == 0xFF) { + if (!channel->hasInstrument) { + return PROCESS_SCRIPT_END; + } + instOrWave = channel->instOrWave; + } + + switch (instOrWave) { + case 0: + // Drums + semitone += channel->transposition + layer->transposition; + layer->semitone = semitone; + + drum = AudioPlayback_GetDrum(channel->fontId, semitone); + if (drum == NULL) { + layer->stopSomething = true; + layer->delay2 = layer->delay; + return PROCESS_SCRIPT_END; + } + + sound = &drum->sound; + layer->adsr.envelope = drum->envelope; + layer->adsr.decayIndex = drum->adsrDecayIndex; + if (!layer->ignoreDrumPan) { + layer->pan = drum->pan; + } + + layer->sound = sound; + layer->freqScale = sound->tuning; + break; + + case 1: + // Sfxs + layer->semitone = semitone; + sfxId = (layer->transposition << 6) + semitone; + + sound = AudioPlayback_GetSfx(channel->fontId, sfxId); + if (sound == NULL) { + layer->stopSomething = true; + layer->delay2 = layer->delay + 1; + return PROCESS_SCRIPT_END; + } + + layer->sound = sound; + layer->freqScale = sound->tuning; + break; + + default: + semitone += seqPlayer->transposition + channel->transposition + layer->transposition; + semitone2 = semitone; + + layer->semitone = semitone; + if (semitone >= 0x80) { + layer->stopSomething = true; + return PROCESS_SCRIPT_END; + } + + if (layer->instOrWave == 0xFF) { + instrument = channel->instrument; + } else { + instrument = layer->instrument; + } + + if (layer->portamento.mode != PORTAMENTO_MODE_OFF) { + portamento = &layer->portamento; + vel = (semitone > layer->portamentoTargetNote) ? semitone : layer->portamentoTargetNote; + + if (instrument != NULL) { + sound = AudioPlayback_InstrumentGetSound(instrument, vel); + sameSound = (layer->sound == sound); + layer->sound = sound; + tuning = sound->tuning; + } else { + layer->sound = NULL; + tuning = 1.0f; + if (instOrWave >= 0xC0) { + layer->sound = &gAudioContext.synthesisReverbs[instOrWave - 0xC0].sound; + } + } + + temp_f2 = gPitchFrequencies[semitone2] * tuning; + temp_f14 = gPitchFrequencies[layer->portamentoTargetNote] * tuning; + + switch (PORTAMENTO_MODE(*portamento)) { + case PORTAMENTO_MODE_1: + case PORTAMENTO_MODE_3: + case PORTAMENTO_MODE_5: + freqScale2 = temp_f2; + freqScale = temp_f14; + break; + + case PORTAMENTO_MODE_2: + case PORTAMENTO_MODE_4: + freqScale = temp_f2; + freqScale2 = temp_f14; + break; + + default: + freqScale = temp_f2; + freqScale2 = temp_f2; + break; + } + + portamento->extent = (freqScale2 / freqScale) - 1.0f; + + if (PORTAMENTO_IS_SPECIAL(*portamento)) { + speed = seqPlayer->tempo * 0x8000 / gAudioContext.tempoInternalToExternal; + if (layer->delay != 0) { + speed = speed * 0x100 / (layer->delay * layer->portamentoTime); + } + } else { + speed = 0x20000 / (layer->portamentoTime * gAudioContext.audioBufferParameters.updatesPerFrame); + } + + if (speed >= 0x7FFF) { + speed = 0x7FFF; + } else if (speed < 1) { + speed = 1; + } + + portamento->speed = speed; + portamento->cur = 0; + layer->freqScale = freqScale; + if (PORTAMENTO_MODE(*portamento) == PORTAMENTO_MODE_5) { + layer->portamentoTargetNote = semitone; + } + break; + } + + if (instrument != NULL) { + sound = AudioPlayback_InstrumentGetSound(instrument, semitone); + sameSound = (sound == layer->sound); + layer->sound = sound; + layer->freqScale = gPitchFrequencies[semitone2] * sound->tuning; + } else { + layer->sound = NULL; + layer->freqScale = gPitchFrequencies[semitone2]; + if (instOrWave >= 0xC0) { + layer->sound = &gAudioContext.synthesisReverbs[instOrWave - 0xC0].sound; + } + } + break; + } + + layer->delay2 = layer->delay; + layer->freqScale *= layer->bend; + + if (layer->delay == 0) { + if (layer->sound != NULL) { + time = layer->sound->sample->loop->end; + } else { + time = 0.0f; + } + time *= seqPlayer->tempo; + time *= gAudioContext.unk_2870; + time /= layer->freqScale; + if (1) {} + if (time > 0x7FFE) { + time = 0x7FFE; + } + + layer->gateDelay = 0; + layer->delay = (u16)(s32)time + 1; + + if (layer->portamento.mode != PORTAMENTO_MODE_OFF) { + // (It's a bit unclear if 'portamento' has actually always been + // set when this is reached...) + if (PORTAMENTO_IS_SPECIAL(*portamento)) { + speed2 = seqPlayer->tempo * 0x8000 / gAudioContext.tempoInternalToExternal; + speed2 = speed2 * 0x100 / (layer->delay * layer->portamentoTime); + if (speed2 >= 0x7FFF) { + speed2 = 0x7FFF; + } else if (speed2 < 1) { + speed2 = 1; + } + portamento->speed = speed2; + } + } + } + return sameSound; +} + +s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd) { + SeqScriptState* state = &layer->scriptState; + u16 delay; + s32 velocity; + SequenceChannel* channel = layer->channel; + SequencePlayer* seqPlayer = channel->seqPlayer; + s32 intDelta; + f32 floatDelta; + + if (cmd == 0xC0) { // layer: delay + layer->delay = AudioSeq_ScriptReadCompressedU16(state); + layer->stopSomething = true; + layer->bit1 = false; + return PROCESS_SCRIPT_END; + } + + layer->stopSomething = false; + + if (channel->largeNotes == true) { + switch (cmd & 0xC0) { + case 0x00: // layer: large note 0 + delay = AudioSeq_ScriptReadCompressedU16(state); + velocity = *(state->pc++); + layer->gateTime = *(state->pc++); + layer->lastDelay = delay; + break; + + case 0x40: // layer: large note 1 + delay = AudioSeq_ScriptReadCompressedU16(state); + velocity = *(state->pc++); + layer->gateTime = 0; + layer->lastDelay = delay; + break; + + case 0x80: // layer: large note 2 + delay = layer->lastDelay; + velocity = *(state->pc++); + layer->gateTime = *(state->pc++); + break; + } + + if ((velocity > 0x7F) || (velocity < 0)) { + velocity = 0x7F; + } + layer->velocitySquare = SQ((f32)velocity) / SQ(127.0f); + cmd -= (cmd & 0xC0); + } else { + switch (cmd & 0xC0) { + case 0x00: // layer: small note 0 + delay = AudioSeq_ScriptReadCompressedU16(state); + layer->lastDelay = delay; + break; + + case 0x40: // layer: small note 1 + delay = layer->shortNoteDefaultDelay; + break; + + case 0x80: // layer: small note 2 + delay = layer->lastDelay; + break; + } + cmd -= (cmd & 0xC0); + } + + if (channel->velocityRandomVariance != 0) { + floatDelta = layer->velocitySquare * (gAudioContext.audioRandom % channel->velocityRandomVariance) / 100.0f; + if ((gAudioContext.audioRandom & 0x8000) != 0) { + floatDelta = -floatDelta; + } + + layer->velocitySquare2 = layer->velocitySquare + floatDelta; + + if (layer->velocitySquare2 < 0.0f) { + layer->velocitySquare2 = 0.0f; + } else if (layer->velocitySquare2 > 1.0f) { + layer->velocitySquare2 = 1.0f; + } + } else { + layer->velocitySquare2 = layer->velocitySquare; + } + + layer->delay = delay; + layer->gateDelay = (layer->gateTime * delay) >> 8; + + if (channel->gateTimeRandomVariance != 0) { + //! @bug should probably be gateTimeRandomVariance + intDelta = (layer->gateDelay * (gAudioContext.audioRandom % channel->velocityRandomVariance)) / 100; + if ((gAudioContext.audioRandom & 0x4000) != 0) { + intDelta = -intDelta; + } + + layer->gateDelay += intDelta; + if (layer->gateDelay < 0) { + layer->gateDelay = 0; + } else if (layer->gateDelay > layer->delay) { + layer->gateDelay = layer->delay; + } + } + + if ((seqPlayer->muted && (channel->muteFlags & (MUTE_FLAGS_STOP_NOTES | MUTE_FLAGS_4))) || + channel->stopSomething2) { + layer->stopSomething = true; + return PROCESS_SCRIPT_END; + } + + if (seqPlayer->skipTicks != 0) { + layer->stopSomething = true; + return PROCESS_SCRIPT_END; + } + + return cmd; +} + +void AudioSeq_SetChannelPriorities(SequenceChannel* channel, u8 priority) { + if ((priority & 0xF) != 0) { + channel->notePriority = priority & 0xF; + } + + priority = priority >> 4; + if (priority != 0) { + channel->someOtherPriority = priority; + } +} + +u8 AudioSeq_GetInstrument(SequenceChannel* channel, u8 instId, Instrument** instOut, AdsrSettings* adsr) { + Instrument* inst = AudioPlayback_GetInstrumentInner(channel->fontId, instId); + + if (inst == NULL) { + *instOut = NULL; + return 0; + } + + adsr->envelope = inst->envelope; + adsr->decayIndex = inst->adsrDecayIndex; + + *instOut = inst; + + // temporarily offset instrument id by 2 so that instId 0, 1 + // can be reserved by drums and sfxs respectively. + instId += 2; + + return instId; +} + +void AudioSeq_SetInstrument(SequenceChannel* channel, u8 instId) { + if (instId >= 0x80) { + // Synthetic Waves + channel->instOrWave = instId; + channel->instrument = NULL; + } else if (instId == 0x7F) { + // Drums + channel->instOrWave = 0; + channel->instrument = (Instrument*)1; // invalid pointer, never dereferenced + } else if (instId == 0x7E) { + // Sfxs + channel->instOrWave = 1; + channel->instrument = (Instrument*)2; // invalid pointer, never dereferenced + } else { + // Instruments + if ((channel->instOrWave = AudioSeq_GetInstrument(channel, instId, &channel->instrument, &channel->adsr)) == + 0) { + channel->hasInstrument = false; + return; + } + } + + channel->hasInstrument = true; +} + +void AudioSeq_SequenceChannelSetVolume(SequenceChannel* channel, u8 volume) { + channel->volume = (s32)volume / 127.0f; +} + +void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { + s32 i; + u8* data; + u32 rand; + SequencePlayer* seqPlayer; + + if (channel->stopScript) { + goto exit_loop; + } + + seqPlayer = channel->seqPlayer; + if (seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_STOP_SCRIPT)) { + return; + } + + if (channel->delay >= 2) { + channel->delay--; + goto exit_loop; + } + + while (true) { + SeqScriptState* scriptState = &channel->scriptState; + s32 param; + s16 temp1; + u16 cmdArgU16; + u32 cmdArgs[3]; + s8 cmdArgS8; + u8 cmd = AudioSeq_ScriptReadU8(scriptState); + u8 lowBits; + u8 highBits; + s32 delay; + s32 temp2; + u8 phi_v0_3; + u8 new_var; + u8 depth; + u8* seqData = seqPlayer->seqData; + u32 new_var2; + + // Commands 0xA0 - 0xFF + if (cmd >= 0xA0) { + highBits = sSeqInstructionArgsTable[cmd - 0xA0]; + lowBits = highBits & 3; + + // read in arguments for the instruction + for (i = 0; i < lowBits; i++, highBits <<= 1) { + if (!(highBits & 0x80)) { + cmdArgs[i] = AudioSeq_ScriptReadU8(scriptState); + } else { + cmdArgs[i] = AudioSeq_ScriptReadS16(scriptState); + } + } + + // Control Flow Commands + if (cmd >= 0xF2) { + delay = AudioSeq_HandleScriptFlowControl(seqPlayer, scriptState, cmd, cmdArgs[0]); + + if (delay != 0) { + if (delay == PROCESS_SCRIPT_END) { + AudioSeq_SequenceChannelDisable(channel); + } else { + channel->delay = delay; + } + break; + } + continue; + } + + switch (cmd) { + case 0xEA: // channel: stop script + channel->stopScript = true; + goto exit_loop; + + case 0xF1: // channel: reserve notes + AudioPlayback_NotePoolClear(&channel->notePool); + cmd = (u8)cmdArgs[0]; + AudioPlayback_NotePoolFill(&channel->notePool, cmd); + break; + + case 0xF0: // channel: unreserve notes + AudioPlayback_NotePoolClear(&channel->notePool); + break; + + case 0xC2: // channel: set dyntable + cmdArgU16 = (u16)cmdArgs[0]; + channel->dynTable = (void*)&seqPlayer->seqData[cmdArgU16]; + break; + + case 0xC5: // channel: dyn set dyntable + if (scriptState->value != -1) { + data = (*channel->dynTable)[scriptState->value]; + cmdArgU16 = (u16)((data[0] << 8) + data[1]); + scriptState->pc = (void*)&seqPlayer->seqData[cmdArgU16]; + } + break; + + case 0xEB: // channel: set soundFont and instrument + cmd = (u8)cmdArgs[0]; + + if (seqPlayer->defaultFont != 0xFF) { + cmdArgU16 = ((u16*)gAudioContext.sequenceFontTable)[seqPlayer->seqId]; + lowBits = gAudioContext.sequenceFontTable[cmdArgU16]; + cmd = gAudioContext.sequenceFontTable[cmdArgU16 + lowBits - cmd]; + } + + if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, cmd)) { + channel->fontId = cmd; + } + + cmdArgs[0] = cmdArgs[1]; + // fallthrough + case 0xC1: // channel: set instrument + cmd = (u8)cmdArgs[0]; + AudioSeq_SetInstrument(channel, cmd); + break; + + case 0xC3: // channel: large notes off + channel->largeNotes = false; + break; + + case 0xC4: // channel: large notes on + channel->largeNotes = true; + break; + + case 0xDF: // channel: set volume + cmd = (u8)cmdArgs[0]; + AudioSeq_SequenceChannelSetVolume(channel, cmd); + channel->changes.s.volume = true; + break; + + case 0xE0: // channel: set volume scale + cmd = (u8)cmdArgs[0]; + channel->volumeScale = (f32)(s32)cmd / 128.0f; + channel->changes.s.volume = true; + break; + + case 0xDE: // channel: set freqscale + cmdArgU16 = (u16)cmdArgs[0]; + channel->freqScale = (f32)(s32)cmdArgU16 / 0x8000; + channel->changes.s.freqScale = true; + break; + + case 0xD3: // channel: large bend pitch + cmd = (u8)cmdArgs[0]; + cmd += 0x80; + channel->freqScale = gBendPitchOneOctaveFrequencies[cmd]; + channel->changes.s.freqScale = true; + break; + + case 0xEE: // channel: small bend pitch + cmd = (u8)cmdArgs[0]; + cmd += 0x80; + channel->freqScale = gBendPitchTwoSemitonesFrequencies[cmd]; + channel->changes.s.freqScale = true; + break; + + case 0xDD: // channel: set pan + cmd = (u8)cmdArgs[0]; + channel->newPan = cmd; + channel->changes.s.pan = true; + break; + + case 0xDC: // channel: set pan mix + cmd = (u8)cmdArgs[0]; + channel->panChannelWeight = cmd; + channel->changes.s.pan = true; + break; + + case 0xDB: // channel: transpose + cmdArgS8 = (s8)cmdArgs[0]; + channel->transposition = cmdArgS8; + break; + + case 0xDA: // channel: set envelope + cmdArgU16 = (u16)cmdArgs[0]; + channel->adsr.envelope = (EnvelopePoint*)&seqPlayer->seqData[cmdArgU16]; + break; + + case 0xD9: // channel: set decay index + cmd = (u8)cmdArgs[0]; + channel->adsr.decayIndex = cmd; + break; + + case 0xD8: // channel: set vibrato extent + cmd = (u8)cmdArgs[0]; + channel->vibrato.vibratoExtentTarget = cmd * 8; + channel->vibrato.vibratoExtentStart = 0; + channel->vibrato.vibratoExtentChangeDelay = 0; + break; + + case 0xD7: // channel: set vibrato rate + cmd = (u8)cmdArgs[0]; + channel->vibrato.vibratoRateChangeDelay = 0; + channel->vibrato.vibratoRateTarget = cmd * 32; + channel->vibrato.vibratoRateStart = cmd * 32; + break; + + case 0xE2: // channel: set vibrato extent linear + cmd = (u8)cmdArgs[0]; + channel->vibrato.vibratoExtentStart = cmd * 8; + cmd = (u8)cmdArgs[1]; + channel->vibrato.vibratoExtentTarget = cmd * 8; + cmd = (u8)cmdArgs[2]; + channel->vibrato.vibratoExtentChangeDelay = cmd * 16; + break; + + case 0xE1: // channel: set vibratorate linear + cmd = (u8)cmdArgs[0]; + channel->vibrato.vibratoRateStart = cmd * 32; + cmd = (u8)cmdArgs[1]; + channel->vibrato.vibratoRateTarget = cmd * 32; + cmd = (u8)cmdArgs[2]; + channel->vibrato.vibratoRateChangeDelay = cmd * 16; + break; + + case 0xE3: // channel: set vibrato delay + cmd = (u8)cmdArgs[0]; + channel->vibrato.vibratoDelay = cmd * 16; + break; + + case 0xD4: // channel: set reverb + cmd = (u8)cmdArgs[0]; + channel->reverb = cmd; + break; + + case 0xC6: // channel: set soundFont + cmd = (u8)cmdArgs[0]; + + if (seqPlayer->defaultFont != 0xFF) { + cmdArgU16 = ((u16*)gAudioContext.sequenceFontTable)[seqPlayer->seqId]; + lowBits = gAudioContext.sequenceFontTable[cmdArgU16]; + cmd = gAudioContext.sequenceFontTable[cmdArgU16 + lowBits - cmd]; + } + + if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, cmd)) { + channel->fontId = cmd; + } + break; + + case 0xC7: // channel: write into sequence script + cmd = (u8)cmdArgs[0]; + cmdArgU16 = (u16)cmdArgs[1]; + seqData = &seqPlayer->seqData[cmdArgU16]; + seqData[0] = (u8)scriptState->value + cmd; + break; + + case 0xC8: // channel: subtract -> set value + case 0xCC: // channel: set value + case 0xC9: // channel: `bit and` -> set value + cmdArgS8 = (s8)cmdArgs[0]; + + if (cmd == 0xC8) { + scriptState->value -= cmdArgS8; + } else if (cmd == 0xCC) { + scriptState->value = cmdArgS8; + } else { + scriptState->value &= cmdArgS8; + } + break; + + case 0xCD: // channel: disable channel + cmd = (u8)cmdArgs[0]; + AudioSeq_SequenceChannelDisable(seqPlayer->channels[cmd]); + break; + + case 0xCA: // channel: set mute behavior + cmd = (u8)cmdArgs[0]; + channel->muteFlags = cmd; + channel->changes.s.volume = true; + break; + + case 0xCB: // channel: read sequence -> set value + cmdArgU16 = (u16)cmdArgs[0]; + scriptState->value = *(seqPlayer->seqData + (u32)(cmdArgU16 + scriptState->value)); + break; + + case 0xCE: // channel: + cmdArgU16 = (u16)cmdArgs[0]; + channel->unk_22 = cmdArgU16; + break; + + case 0xCF: // channel: write large into sequence script + cmdArgU16 = (u16)cmdArgs[0]; + seqData = &seqPlayer->seqData[cmdArgU16]; + seqData[0] = (channel->unk_22 >> 8) & 0xFF; + seqData[1] = channel->unk_22 & 0xFF; + break; + + case 0xD0: // channel: stereo headset effects + cmd = (u8)cmdArgs[0]; + if (cmd & 0x80) { + channel->stereoHeadsetEffects = true; + } else { + channel->stereoHeadsetEffects = false; + } + channel->stereo.asByte = cmd & 0x7F; + break; + + case 0xD1: // channel: set note allocation policy + cmd = (u8)cmdArgs[0]; + channel->noteAllocPolicy = cmd; + break; + + case 0xD2: // channel: set sustain + cmd = (u8)cmdArgs[0]; + channel->adsr.sustain = cmd; + break; + + case 0xE5: // channel: set reverb index + cmd = (u8)cmdArgs[0]; + channel->reverbIndex = cmd; + break; + + case 0xE4: // channel: dyncall + if (scriptState->value != -1) { + data = (*channel->dynTable)[scriptState->value]; + depth = scriptState->depth; + //! @bug: Missing a stack depth check here + scriptState->stack[depth] = scriptState->pc; + scriptState->depth++; + cmdArgU16 = (u16)((data[0] << 8) + data[1]); + scriptState->pc = seqPlayer->seqData + cmdArgU16; + } + break; + + case 0xE6: // channel: set book offset + cmd = (u8)cmdArgs[0]; + channel->bookOffset = cmd; + break; + + case 0xE7: // channel: + cmdArgU16 = (u16)cmdArgs[0]; + data = &seqPlayer->seqData[cmdArgU16]; + channel->muteFlags = data[0]; + data += 3; + channel->noteAllocPolicy = data[-2]; + AudioSeq_SetChannelPriorities(channel, data[-1]); + channel->transposition = (s8)data[0]; + data += 4; + channel->newPan = data[-3]; + channel->panChannelWeight = data[-2]; + channel->reverb = data[-1]; + channel->reverbIndex = data[0]; + //! @bug: Not marking reverb state as changed + channel->changes.s.pan = true; + break; + + case 0xE8: // channel: + channel->muteFlags = cmdArgs[0]; + channel->noteAllocPolicy = cmdArgs[1]; + cmd = (u8)cmdArgs[2]; + AudioSeq_SetChannelPriorities(channel, cmd); + channel->transposition = (s8)AudioSeq_ScriptReadU8(scriptState); + channel->newPan = AudioSeq_ScriptReadU8(scriptState); + channel->panChannelWeight = AudioSeq_ScriptReadU8(scriptState); + channel->reverb = AudioSeq_ScriptReadU8(scriptState); + channel->reverbIndex = AudioSeq_ScriptReadU8(scriptState); + //! @bug: Not marking reverb state as changed + channel->changes.s.pan = true; + break; + + case 0xEC: // channel: reset vibrato + channel->vibrato.vibratoExtentTarget = 0; + channel->vibrato.vibratoExtentStart = 0; + channel->vibrato.vibratoExtentChangeDelay = 0; + channel->vibrato.vibratoRateTarget = 0; + channel->vibrato.vibratoRateStart = 0; + channel->vibrato.vibratoRateChangeDelay = 0; + channel->filter = NULL; + channel->gain = 0; + channel->adsr.sustain = 0; + channel->velocityRandomVariance = 0; + channel->gateTimeRandomVariance = 0; + channel->unk_0F = 0; + channel->unk_20 = 0; + channel->bookOffset = 0; + channel->unk_DC = 0; + channel->unk_E0 = 0; + channel->freqScale = 1.0f; + break; + + case 0xE9: // channel: set note priority + AudioSeq_SetChannelPriorities(channel, (u8)cmdArgs[0]); + break; + + case 0xED: // channel: set hilo gain + cmd = (u8)cmdArgs[0]; + channel->gain = cmd; + break; + + case 0xB0: // channel: set filter + cmdArgU16 = (u16)cmdArgs[0]; + data = seqPlayer->seqData + cmdArgU16; + channel->filter = (s16*)data; + break; + + case 0xB1: // channel: clear filter + channel->filter = NULL; + break; + + case 0xB3: // channel: load filter + cmd = cmdArgs[0]; + + if (channel->filter != NULL) { + lowBits = (cmd >> 4) & 0xF; // LowPassCutoff + cmd &= 0xF; // HighPassCutoff + AudioHeap_LoadFilter(channel->filter, lowBits, cmd); + } + break; + + case 0xB2: // channel: dynread sequence large + cmdArgU16 = (u16)cmdArgs[0]; + channel->unk_22 = *(u16*)(seqPlayer->seqData + (u32)(cmdArgU16 + scriptState->value * 2)); + break; + + case 0xB4: // channel: set dyntable large + channel->dynTable = (void*)&seqPlayer->seqData[channel->unk_22]; + break; + + case 0xB5: // channel: read dyntable large + channel->unk_22 = ((u16*)(channel->dynTable))[scriptState->value]; + break; + + case 0xB6: // channel: read dyntable + scriptState->value = (*channel->dynTable)[0][scriptState->value]; + break; + + case 0xB7: // channel: random large + channel->unk_22 = (cmdArgs[0] == 0) ? (gAudioContext.audioRandom & 0xFFFF) + : (gAudioContext.audioRandom % cmdArgs[0]); + break; + + case 0xB8: // channel: random value + scriptState->value = (cmdArgs[0] == 0) ? (gAudioContext.audioRandom & 0xFFFF) + : (gAudioContext.audioRandom % cmdArgs[0]); + break; + + case 0xA8: // channel: random range large (only cmd that differs from OoT) + rand = Audio_NextRandom(); + channel->unk_22 = (cmdArgs[0] == 0) ? (rand & 0xFFFF) : (rand % cmdArgs[0]); + channel->unk_22 += cmdArgs[1]; + temp2 = (channel->unk_22 / 0x100) + 0x80; + param = channel->unk_22 % 0x100; + channel->unk_22 = (temp2 << 8) | param; + break; + + case 0xB9: // channel: set velocity random variance + channel->velocityRandomVariance = cmdArgs[0]; + break; + + case 0xBA: // channel: set gatetime random variance + channel->gateTimeRandomVariance = cmdArgs[0]; + break; + + case 0xBB: // channel: + channel->unk_0F = cmdArgs[0]; + channel->unk_20 = cmdArgs[1]; + break; + + case 0xBC: // channel: add large + channel->unk_22 += cmdArgs[0]; + break; + + case 0xBD: // channel: + channel->unk_DC = cmdArgs[0]; + break; + + case 0xBE: // channel: + if (cmdArgs[0] < 5) { + if (1) {} + if (gAudioContext.unk_29A8[cmdArgs[0]] != NULL) { + D_80208E6C = gAudioContext.unk_29A8[cmdArgs[0]]; + scriptState->value = D_80208E6C(scriptState->value, channel); + } + } + break; + + case 0xA0: // channel: + case 0xA1: // channel: + case 0xA2: // channel: + case 0xA3: // channel: + if ((cmd == 0xA0) || (cmd == 0xA2)) { + cmdArgU16 = (u16)cmdArgs[0]; + } else { + cmdArgU16 = channel->unk_22; + } + + if (channel->sfxState != NULL) { + if ((cmd == 0xA0) || (cmd == 0xA1)) { + scriptState->value = channel->sfxState[cmdArgU16]; + } else { + channel->sfxState[cmdArgU16] = scriptState->value; + } + } + break; + + case 0xA4: // channel: + channel->unk_10 = cmdArgs[0]; + break; + + case 0xA5: // channel: + scriptState->value += channel->unk_11; + break; + + case 0xA6: // channel: + cmd = (u8)cmdArgs[0]; + cmdArgU16 = (u16)cmdArgs[1]; + seqData = seqPlayer->seqData + (u32)(cmdArgU16 + channel->unk_11); + seqData[0] = (u8)scriptState->value + cmd; + break; + + case 0xA7: // channel: + new_var2 = (cmdArgs[0] & 0x80); + new_var = (scriptState->value & 0x80); + + if (!new_var2) { + phi_v0_3 = scriptState->value << (cmdArgs[0] & 0xF); + } else { + phi_v0_3 = scriptState->value >> (cmdArgs[0] & 0xF); + } + + if (cmdArgs[0] & 0x40) { + phi_v0_3 &= (u8)~0x80; + phi_v0_3 |= new_var; + } + + scriptState->value = phi_v0_3; + break; + } + continue; + } + + // Commands 0x70 - 0x9F + if (cmd >= 0x70) { + lowBits = cmd & 0x7; + + if (((cmd & 0xF8) != 0x70) && (lowBits >= 4)) { + lowBits = 0; + } + + switch (cmd & 0xF8) { + case 0x80: // channel: test layer is finished + if (channel->layers[lowBits] != NULL) { + scriptState->value = channel->layers[lowBits]->finished; + } else { + scriptState->value = -1; + } + break; + + case 0x88: // channel: set layer + cmdArgU16 = AudioSeq_ScriptReadS16(scriptState); + if (!AudioSeq_SeqChannelSetLayer(channel, lowBits)) { + channel->layers[lowBits]->scriptState.pc = &seqPlayer->seqData[cmdArgU16]; + } + break; + + case 0x90: // channel: free layer + AudioSeq_SeqLayerFree(channel, lowBits); + break; + + case 0x98: // channel: dynset layer + if ((scriptState->value != -1) && (AudioSeq_SeqChannelSetLayer(channel, lowBits) != -1)) { + data = (*channel->dynTable)[scriptState->value]; + cmdArgU16 = (data[0] << 8) + data[1]; + channel->layers[lowBits]->scriptState.pc = &seqPlayer->seqData[cmdArgU16]; + } + break; + + case 0x70: // channel: io write value + channel->soundScriptIO[lowBits] = scriptState->value; + break; + + case 0x78: // channel: set layer relative + temp1 = AudioSeq_ScriptReadS16(scriptState); + if (!AudioSeq_SeqChannelSetLayer(channel, lowBits)) { + channel->layers[lowBits]->scriptState.pc = &scriptState->pc[temp1]; + } + break; + } + continue; + } + + // Commands 0x00 - 0x6F + lowBits = cmd & 0xF; + + switch (cmd & 0xF0) { + case 0x00: // channel: delay short + channel->delay = lowBits; + if (lowBits == 0) { + break; + } + goto exit_loop; + + case 0x10: // channel: load sample + if (lowBits < 8) { + channel->soundScriptIO[lowBits] = -1; + if (AudioLoad_SlowLoadSample(channel->fontId, scriptState->value, + &channel->soundScriptIO[lowBits]) == -1) {} + } else { + lowBits -= 8; + channel->soundScriptIO[lowBits] = -1; + if (AudioLoad_SlowLoadSample(channel->fontId, channel->unk_22 + 0x100, + &channel->soundScriptIO[lowBits]) == -1) {} + } + break; + + case 0x60: // channel: io read value + scriptState->value = channel->soundScriptIO[lowBits]; + if (lowBits < 2) { + channel->soundScriptIO[lowBits] = -1; + } + break; + + case 0x50: // channel: io read value subtract + scriptState->value -= channel->soundScriptIO[lowBits]; + break; + + case 0x20: // channel: start channel + cmdArgU16 = AudioSeq_ScriptReadS16(scriptState); + AudioSeq_SequenceChannelEnable(seqPlayer, lowBits, &seqPlayer->seqData[cmdArgU16]); + break; + + case 0x30: // channel: io write value 2 + cmd = AudioSeq_ScriptReadU8(scriptState); + seqPlayer->channels[lowBits]->soundScriptIO[cmd] = scriptState->value; + break; + + case 0x40: // channel: io read value 2 + cmd = AudioSeq_ScriptReadU8(scriptState); + scriptState->value = seqPlayer->channels[lowBits]->soundScriptIO[cmd]; + break; + } + } +exit_loop: + + for (i = 0; i < ARRAY_COUNT(channel->layers); i++) { + if (channel->layers[i] != NULL) { + AudioSeq_SeqLayerProcessScript(channel->layers[i]); + } + } +} + +void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { + u8 cmd; + u8 cmdLowBits; + SeqScriptState* seqScript = &seqPlayer->scriptState; + s16 tempS; + u16 temp; + s32 i; + s32 value; + u8* data1; + u8* data2; + u8* data3; + u8* data4; + s32 tempoChange; + s32 j; + SequenceChannel* channel; + u16* new_var; + s32 delay; + + if (!seqPlayer->enabled) { + return; + } + + if (!AudioLoad_IsSeqLoadComplete(seqPlayer->seqId) || !AudioLoad_IsFontLoadComplete(seqPlayer->defaultFont)) { + // These function calls serve no purpose + if (AudioLoad_IsSeqLoadComplete(seqPlayer->seqId)) {} + if (AudioLoad_IsSeqLoadComplete(seqPlayer->defaultFont)) {} + + AudioSeq_SequencePlayerDisable(seqPlayer); + return; + } + + AudioLoad_SetSeqLoadStatus(seqPlayer->seqId, LOAD_STATUS_COMPLETE); + AudioLoad_SetFontLoadStatus(seqPlayer->defaultFont, LOAD_STATUS_COMPLETE); + + if (seqPlayer->muted && (seqPlayer->muteFlags & MUTE_FLAGS_STOP_SCRIPT)) { + return; + } + + seqPlayer->scriptCounter++; + + tempoChange = seqPlayer->tempo + seqPlayer->unk_0C; + if (tempoChange > gAudioContext.tempoInternalToExternal) { + tempoChange = gAudioContext.tempoInternalToExternal; + } + + seqPlayer->tempoAcc += tempoChange; + + if (seqPlayer->tempoAcc < gAudioContext.tempoInternalToExternal) { + return; + } + + seqPlayer->tempoAcc -= (u16)gAudioContext.tempoInternalToExternal; + seqPlayer->unk_16++; + + if (seqPlayer->stopScript == true) { + return; + } + + if (seqPlayer->delay > 1) { + seqPlayer->delay--; + } else { + seqPlayer->recalculateVolume = true; + + while (true) { + cmd = AudioSeq_ScriptReadU8(seqScript); + + // 0xF2 and above are "flow control" commands, including termination. + if (cmd >= 0xF2) { + delay = AudioSeq_HandleScriptFlowControl( + seqPlayer, seqScript, cmd, AudioSeq_GetScriptControlFlowArgument(&seqPlayer->scriptState, cmd)); + + if (delay != 0) { + if (delay == -1) { + AudioSeq_SequencePlayerDisable(seqPlayer); + } else { + seqPlayer->delay = delay; + } + break; + } + continue; + } + + // Commands 0xC0 - 0xF1 + if (cmd >= 0xC0) { + switch (cmd) { + case 0xF1: // seqPlayer: reserve notes + AudioPlayback_NotePoolClear(&seqPlayer->notePool); + cmd = AudioSeq_ScriptReadU8(seqScript); + AudioPlayback_NotePoolFill(&seqPlayer->notePool, cmd); + break; + + case 0xF0: // seqPlayer: unreserve notes + AudioPlayback_NotePoolClear(&seqPlayer->notePool); + break; + + case 0xDF: // seqPlayer: transpose + seqPlayer->transposition = 0; + // fallthrough + case 0xDE: // seqPlayer: transpose relative + seqPlayer->transposition += (s8)AudioSeq_ScriptReadU8(seqScript); + break; + + case 0xDD: // seqPlayer: set tempo + seqPlayer->tempo = AudioSeq_ScriptReadU8(seqScript) * TATUMS_PER_BEAT; + if (seqPlayer->tempo > gAudioContext.tempoInternalToExternal) { + seqPlayer->tempo = gAudioContext.tempoInternalToExternal; + } + + if ((s16)seqPlayer->tempo <= 0) { + seqPlayer->tempo = 1; + } + break; + + case 0xDC: // seqPlayer: add tempo + seqPlayer->unk_0C = (s8)AudioSeq_ScriptReadU8(seqScript) * TATUMS_PER_BEAT; + break; + + case 0xDA: // seqPlayer: change volume + cmd = AudioSeq_ScriptReadU8(seqScript); + temp = AudioSeq_ScriptReadS16(seqScript); + switch (cmd) { + case 0: + case 1: + if (seqPlayer->state != 2) { + seqPlayer->fadeTimerUnkEu = temp; + seqPlayer->state = cmd; + } + break; + + case 2: + seqPlayer->fadeTimer = temp; + seqPlayer->state = cmd; + seqPlayer->fadeVelocity = (0.0f - seqPlayer->fadeVolume) / (s32)seqPlayer->fadeTimer; + break; + } + break; + + case 0xDB: // seqPlayer: set volume + value = AudioSeq_ScriptReadU8(seqScript); + switch (seqPlayer->state) { + case 1: + seqPlayer->state = 0; + seqPlayer->fadeVolume = 0.0f; + // fallthrough + case 0: + seqPlayer->fadeTimer = seqPlayer->fadeTimerUnkEu; + if (seqPlayer->fadeTimerUnkEu != 0) { + seqPlayer->fadeVelocity = + ((value / 127.0f) - seqPlayer->fadeVolume) / (s32)seqPlayer->fadeTimer; + } else { + seqPlayer->fadeVolume = value / 127.0f; + } + break; + + case 2: + break; + } + break; + + case 0xD9: // seqPlayer: set volume scale + seqPlayer->fadeVolumeScale = (s8)AudioSeq_ScriptReadU8(seqScript) / 127.0f; + break; + + case 0xD7: // seqPlayer: initialize channels + temp = AudioSeq_ScriptReadS16(seqScript); + AudioSeq_SequencePlayerSetupChannels(seqPlayer, temp); + break; + + case 0xD6: // seqPlayer: disable channels + AudioSeq_ScriptReadS16(seqScript); + break; + + case 0xD5: // seqPlayer: set mute scale + seqPlayer->muteVolumeScale = (s8)AudioSeq_ScriptReadU8(seqScript) / 127.0f; + break; + + case 0xD4: // seqPlayer: mute + seqPlayer->muted = true; + break; + + case 0xD3: // seqPlayer: set mute behavior + seqPlayer->muteFlags = AudioSeq_ScriptReadU8(seqScript); + break; + + case 0xD1: // seqPlayer: set short note gatetime table + case 0xD2: // seqPlayer: set short note velocity table + temp = AudioSeq_ScriptReadS16(seqScript); + data3 = &seqPlayer->seqData[temp]; + if (cmd == 0xD2) { + seqPlayer->shortNoteVelocityTable = data3; + } else { + seqPlayer->shortNoteGateTimeTable = data3; + } + break; + + case 0xD0: // seqPlayer: set note allocation policy + seqPlayer->noteAllocPolicy = AudioSeq_ScriptReadU8(seqScript); + break; + + case 0xCE: // seqPlayer: random value + cmd = AudioSeq_ScriptReadU8(seqScript); + if (cmd == 0) { + seqScript->value = (gAudioContext.audioRandom >> 2) & 0xFF; + } else { + seqScript->value = (gAudioContext.audioRandom >> 2) % cmd; + } + break; + + case 0xCD: // seqPlayer: dyncall + temp = AudioSeq_ScriptReadS16(seqScript); + if ((seqScript->value != -1) && (seqScript->depth != 3)) { + data1 = seqPlayer->seqData + (u32)(temp + (seqScript->value << 1)); + seqScript->stack[seqScript->depth] = seqScript->pc; + seqScript->depth++; + temp = (data1[0] << 8) + data1[1]; + seqScript->pc = &seqPlayer->seqData[temp]; + } + break; + + case 0xCC: // seqPlayer: set value + seqScript->value = AudioSeq_ScriptReadU8(seqScript); + break; + + case 0xC9: // seqPlayer: `bit and` -> set value + seqScript->value &= AudioSeq_ScriptReadU8(seqScript); + break; + + case 0xC8: // seqPlayer: subtract -> set value + seqScript->value -= AudioSeq_ScriptReadU8(seqScript); + break; + + case 0xC7: // seqPlayer: write into sequence script + cmd = AudioSeq_ScriptReadU8(seqScript); + temp = AudioSeq_ScriptReadS16(seqScript); + data2 = &seqPlayer->seqData[temp]; + *data2 = (u8)seqScript->value + cmd; + break; + + case 0xC2: // seqPlayer: + temp = AudioSeq_ScriptReadS16(seqScript); + if (seqScript->value != -1) { + data4 = seqPlayer->seqData + (u32)(temp + (seqScript->value << 1)); + + temp = (data4[0] << 8) + data4[1]; + seqScript->pc = &seqPlayer->seqData[temp]; + } + break; + + case 0xC6: // seqPlayer: stop script + seqPlayer->stopScript = true; + return; + + case 0xC5: // seqPlayer: + seqPlayer->unk_16 = AudioSeq_ScriptReadS16(seqScript); + break; + + case 0xEF: // seqPlayer: + AudioSeq_ScriptReadS16(seqScript); + AudioSeq_ScriptReadU8(seqScript); + break; + + case 0xC4: // seqPlayer: start sequence + cmd = AudioSeq_ScriptReadU8(seqScript); + if (cmd == 0xFF) { + cmd = seqPlayer->playerIndex; + if (seqPlayer->state == 2) { + break; + } + } + + cmdLowBits = AudioSeq_ScriptReadU8(seqScript); + AudioLoad_SyncInitSeqPlayer(cmd, cmdLowBits, 0); + if (cmd == (u8)seqPlayer->playerIndex) { + return; + } + break; + + case 0xC3: // seqPlayer: + temp = AudioSeq_ScriptReadS16(seqScript); + if (seqScript->value != -1) { + new_var = (u16*)(seqPlayer->seqData + (u32)(temp + seqScript->value * 2)); + temp = *new_var; + + for (i = 0; i < ARRAY_COUNT(seqPlayer->channels); i++) { + seqPlayer->channels[i]->stopSomething2 = temp & 1; + temp = temp >> 1; + } + } + break; + } + continue; + } + + // Commands 0x00 - 0xBF + cmdLowBits = cmd & 0x0F; + + switch (cmd & 0xF0) { + case 0x00: // seqPlayer: test channel disabled + seqScript->value = seqPlayer->channels[cmdLowBits]->enabled ^ 1; + break; + + case 0x50: // seqPlayer: io read value subtract + seqScript->value -= seqPlayer->soundScriptIO[cmdLowBits]; + break; + + case 0x70: // seqPlayer: io write value + seqPlayer->soundScriptIO[cmdLowBits] = seqScript->value; + break; + + case 0x80: // seqPlayer: io read value + seqScript->value = seqPlayer->soundScriptIO[cmdLowBits]; + if (cmdLowBits < 2) { + seqPlayer->soundScriptIO[cmdLowBits] = -1; + } + break; + + case 0x40: // seqPlayer: disable channel + AudioSeq_SequenceChannelDisable(seqPlayer->channels[cmdLowBits]); + break; + + case 0x90: // seqPlayer: start channel + temp = AudioSeq_ScriptReadS16(seqScript); + AudioSeq_SequenceChannelEnable(seqPlayer, cmdLowBits, (void*)&seqPlayer->seqData[temp]); + break; + + case 0xA0: // seqPlayer: start channel relative + tempS = AudioSeq_ScriptReadS16(seqScript); + AudioSeq_SequenceChannelEnable(seqPlayer, cmdLowBits, (void*)&seqScript->pc[tempS]); + break; + + case 0xB0: // seqPlayer: load sequence + cmd = AudioSeq_ScriptReadU8(seqScript); + temp = AudioSeq_ScriptReadS16(seqScript); + data2 = &seqPlayer->seqData[temp]; + AudioLoad_SlowLoadSeq(cmd, data2, &seqPlayer->soundScriptIO[cmdLowBits]); + break; + + case 0x60: // seqPlayer: async load + cmd = AudioSeq_ScriptReadU8(seqScript); + value = cmd; + temp = AudioSeq_ScriptReadU8(seqScript); + AudioLoad_ScriptLoad(value, temp, &seqPlayer->soundScriptIO[cmdLowBits]); + break; + } + } + } + + for (j = 0; j < SEQ_NUM_CHANNELS; j++) { + channel = seqPlayer->channels[j]; + if (channel->enabled) { + AudioSeq_SequenceChannelProcessScript(channel); + } + } +} + +void AudioSeq_ProcessSequences(s32 arg0) { + SequencePlayer* seqPlayer; + u32 i; + + gAudioContext.noteSubEuOffset = + (gAudioContext.audioBufferParameters.updatesPerFrame - arg0 - 1) * gAudioContext.numNotes; + + for (i = 0; i < (u32)gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + seqPlayer = &gAudioContext.seqPlayers[i]; + if (seqPlayer->enabled == true) { + AudioSeq_SequencePlayerProcessSequence(seqPlayer); + AudioEffects_SequencePlayerProcessSound(seqPlayer); + } + } + + AudioPlayback_ProcessNotes(); +} + +void AudioSeq_SkipForwardSequence(SequencePlayer* seqPlayer) { + while (seqPlayer->skipTicks > 0) { + AudioSeq_SequencePlayerProcessSequence(seqPlayer); + AudioEffects_SequencePlayerProcessSound(seqPlayer); + seqPlayer->skipTicks--; + } +} + +void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer) { + s32 i; + + AudioSeq_SequencePlayerDisable(seqPlayer); + seqPlayer->stopScript = false; + seqPlayer->delay = 0; + seqPlayer->state = 1; + seqPlayer->fadeTimer = 0; + seqPlayer->fadeTimerUnkEu = 0; + seqPlayer->tempoAcc = 0; + seqPlayer->tempo = 120 * TATUMS_PER_BEAT; // 120 BPM + seqPlayer->unk_0C = 0; + seqPlayer->transposition = 0; + seqPlayer->noteAllocPolicy = 0; + seqPlayer->shortNoteVelocityTable = gDefaultShortNoteVelocityTable; + seqPlayer->shortNoteGateTimeTable = gDefaultShortNoteGateTimeTable; + seqPlayer->scriptCounter = 0; + seqPlayer->unk_16 = 0; + seqPlayer->fadeVolume = 1.0f; + seqPlayer->fadeVelocity = 0.0f; + seqPlayer->volume = 0.0f; + seqPlayer->muteVolumeScale = 0.5f; + + for (i = 0; i < SEQ_NUM_CHANNELS; i++) { + AudioSeq_InitSequenceChannel(seqPlayer->channels[i]); + } +} + +void AudioSeq_InitSequencePlayerChannels(s32 playerIndex) { + SequenceChannel* channel; + SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIndex]; + s32 i; + s32 j; + + for (i = 0; i < SEQ_NUM_CHANNELS; i++) { + seqPlayer->channels[i] = AudioHeap_AllocZeroed(&gAudioContext.miscPool, sizeof(SequenceChannel)); + if (seqPlayer->channels[i] == NULL) { + seqPlayer->channels[i] = &gAudioContext.sequenceChannelNone; + } else { + channel = seqPlayer->channels[i]; + channel->seqPlayer = seqPlayer; + channel->enabled = false; + channel->unk_11 = i; + for (j = 0; j < ARRAY_COUNT(channel->layers); j++) { + channel->layers[j] = NULL; + } + } + + AudioSeq_InitSequenceChannel(seqPlayer->channels[i]); + } +} + +void AudioSeq_InitSequencePlayer(SequencePlayer* seqPlayer) { + s32 i; + s32 j; + + for (i = 0; i < SEQ_NUM_CHANNELS; i++) { + seqPlayer->channels[i] = &gAudioContext.sequenceChannelNone; + } + + seqPlayer->enabled = false; + seqPlayer->muted = false; + seqPlayer->fontDmaInProgress = false; + seqPlayer->seqDmaInProgress = false; + seqPlayer->applyBend = false; + + for (j = 0; j < ARRAY_COUNT(seqPlayer->soundScriptIO); j++) { + seqPlayer->soundScriptIO[j] = -1; + } + + seqPlayer->muteFlags = MUTE_FLAGS_SOFTEN | MUTE_FLAGS_STOP_NOTES; + seqPlayer->fadeVolumeScale = 1.0f; + seqPlayer->bend = 1.0f; + + AudioPlayback_InitNoteLists(&seqPlayer->notePool); + AudioSeq_ResetSequencePlayer(seqPlayer); +} + +void AudioSeq_InitSequencePlayers(void) { + s32 i; + + AudioSeq_InitLayerFreelist(); + + for (i = 0; i < ARRAY_COUNT(gAudioContext.sequenceLayers); i++) { + gAudioContext.sequenceLayers[i].channel = NULL; + gAudioContext.sequenceLayers[i].enabled = false; + } + + for (i = 0; i < ARRAY_COUNT(gAudioContext.seqPlayers); i++) { + AudioSeq_InitSequencePlayer(&gAudioContext.seqPlayers[i]); + } +} diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index ea3c30aa6..07cb436cf 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -481,8 +481,8 @@ s32 Inventory_GetBtnBItem(PlayState* play) { return ITEM_NONE; } else if (CUR_FORM_EQUIP(EQUIP_SLOT_B) == ITEM_NONE) { if (play->interfaceCtx.unk_21C != 0) { - if (play->interfaceCtx.unk_21E != 0) { - return play->interfaceCtx.unk_21E; + if (play->interfaceCtx.bButtonDoAction != 0) { + return play->interfaceCtx.bButtonDoAction; } } return ITEM_NONE; @@ -495,7 +495,7 @@ s32 Inventory_GetBtnBItem(PlayState* play) { * Only changes shield */ void Inventory_ChangeEquipment(s16 value) { - SET_EQUIP_VALUE(EQUIP_SHIELD, value); + SET_EQUIP_VALUE(EQUIP_TYPE_SHIELD, value); } /** @@ -504,8 +504,8 @@ void Inventory_ChangeEquipment(s16 value) { u8 Inventory_DeleteEquipment(PlayState* play, s16 equipment) { Player* player = GET_PLAYER(play); - if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { - SET_EQUIP_VALUE(EQUIP_SHIELD, 0); + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_NONE) { + SET_EQUIP_VALUE(EQUIP_TYPE_SHIELD, EQUIP_VALUE_SHIELD_NONE); Player_SetEquipmentData(play, player); return true; } diff --git a/src/code/code_80172BC0.c b/src/code/code_80172BC0.c index 93aee323f..2ea9e6c67 100644 --- a/src/code/code_80172BC0.c +++ b/src/code/code_80172BC0.c @@ -1,3 +1,15 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80172BC0/func_80172BC0.s") +const u8 sSfxBankIds[] = { + BANK_PLAYER, BANK_ITEM, BANK_ENV, BANK_ENEMY, BANK_SYSTEM, BANK_OCARINA, BANK_VOICE, +}; + +void AudioMgr_StopAllSfxExceptSystem(void) { + volatile const u8* bankIdPtr; + + for (bankIdPtr = sSfxBankIds; bankIdPtr < (sSfxBankIds + ARRAY_COUNT(sSfxBankIds)); bankIdPtr++) { + if (*bankIdPtr != BANK_SYSTEM) { + func_801A7084(*bankIdPtr); + } + } +} diff --git a/src/code/game.c b/src/code/game.c index c8d3e14ba..84743b8c5 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -192,7 +192,7 @@ void GameState_Realloc(GameState* gameState, size_t size) { void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* gfxCtx) { gameState->gfxCtx = gfxCtx; - gameState->frames = 0U; + gameState->frames = 0; gameState->main = NULL; gameState->destroy = NULL; gameState->running = 1; @@ -201,7 +201,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g gfxCtx->xScale = gViConfigXScale; gfxCtx->yScale = gViConfigYScale; gameState->nextGameStateInit = NULL; - gameState->nextGameStateSize = 0U; + gameState->nextGameStateSize = 0; { s32 requiredScopeTemp; @@ -224,7 +224,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g } void GameState_Destroy(GameState* gameState) { - func_80172BC0(); + AudioMgr_StopAllSfxExceptSystem(); func_8019E014(); osRecvMesg(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK); diff --git a/src/code/sched.c b/src/code/sched.c index 927a48f66..5f9cdf236 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/z_actor.c b/src/code/z_actor.c index 273581621..ff3bb411f 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -172,14 +172,14 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, PlayState* play) { f32 alphaRatio; if ((actor->id == ACTOR_PLAYER) && (((Player*)actor)->stateFlags3 & 0x8000)) { - f32 tmpScaleZ = actor->scale.z; + f32 prevScaleZ = actor->scale.z; 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, play, gCircleShadowDL, NULL); - actor->scale.z = tmpScaleZ; + actor->scale.z = prevScaleZ; } else { actor->shape.shadowScale *= 0.3f; alphaRatio = (distToFloor - 20.0f) * 0.02f; @@ -1343,7 +1343,7 @@ void Actor_SetCameraHorseSetting(PlayState* play, Player* player) { EnHorse* rideActor = (EnHorse*)player->rideActor; if ((rideActor != NULL) && !(rideActor->unk_1EC & 0x10)) { - func_800DFAC8(Play_GetCamera(play, CAM_ID_MAIN), 4); + Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_HORSE); } } } @@ -1856,8 +1856,7 @@ s32 Actor_ProcessTalkRequest(Actor* actor, GameState* gameState) { s32 func_800B8500(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 exchangeItemId) { Player* player = GET_PLAYER(play); - if ((player->actor.flags & ACTOR_FLAG_100) || - ((exchangeItemId > EXCH_ITEM_NONE) && Player_InCsMode(&play->state)) || + if ((player->actor.flags & ACTOR_FLAG_100) || ((exchangeItemId > EXCH_ITEM_NONE) && Player_InCsMode(play)) || (!actor->isTargeted && ((fabsf(actor->playerHeightRel) > fabsf(yRange)) || ((actor->xzDistToPlayer > player->targetActorDistance)) || (xzRange < actor->xzDistToPlayer)))) { @@ -1887,7 +1886,7 @@ s32 func_800B863C(Actor* actor, PlayState* play) { } s32 Actor_TextboxIsClosing(Actor* actor, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 2) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { actor->flags &= ~ACTOR_FLAG_100; return true; } @@ -1933,7 +1932,7 @@ s32 func_800B8718(Actor* actor, GameState* gameState) { s32 func_800B874C(Actor* actor, PlayState* play, f32 xzRange, f32 yRange) { Player* player = GET_PLAYER(play); - if ((player->actor.flags & ACTOR_FLAG_20000000) || Player_InCsMode(&play->state) || + if ((player->actor.flags & ACTOR_FLAG_20000000) || Player_InCsMode(play) || (yRange < fabsf(actor->playerHeightRel)) || ((player->unk_A94 < actor->xzDistToPlayer)) || (xzRange < actor->xzDistToPlayer)) { return false; @@ -2205,8 +2204,8 @@ void func_800B9098(Actor* actor) { actor->audioFlags |= 0x40; } -s32 func_800B90AC(PlayState* play, Actor* actor, CollisionPoly* polygon, s32 index, s32 arg4) { - if (func_800C99D4(&play->colCtx, polygon, index) == 8) { +s32 func_800B90AC(PlayState* play, Actor* actor, CollisionPoly* polygon, s32 bgId, s32 arg4) { + if (func_800C99D4(&play->colCtx, polygon, bgId) == 8) { return true; } @@ -2509,10 +2508,10 @@ void Actor_Draw(PlayState* play, Actor* actor) { Lights_Draw(light, play->state.gfxCtx); if (actor->flags & ACTOR_FLAG_1000) { - Matrix_SetTranslateRotateYXZ(actor->world.pos.x + play->mainCamera.skyboxOffset.x, + Matrix_SetTranslateRotateYXZ(actor->world.pos.x + play->mainCamera.quakeOffset.x, actor->world.pos.y + - ((actor->shape.yOffset * actor->scale.y) + play->mainCamera.skyboxOffset.y), - actor->world.pos.z + play->mainCamera.skyboxOffset.z, &actor->shape.rot); + ((actor->shape.yOffset * actor->scale.y) + play->mainCamera.quakeOffset.y), + actor->world.pos.z + play->mainCamera.quakeOffset.z, &actor->shape.rot); } else { Matrix_SetTranslateRotateYXZ(actor->world.pos.x, actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), actor->world.pos.z, &actor->shape.rot); @@ -3545,7 +3544,7 @@ void Actor_SpawnBodyParts(Actor* actor, PlayState* play, s32 arg2, Gfx** dList) part = (EnPart*)spawnedPart; Matrix_MtxFToYXZRot(currentMatrix, &part->actor.shape.rot, false); - part->unk_150 = *dList; + part->dList = *dList; Math_Vec3f_Copy(&part->actor.scale, &actor->scale); } } @@ -4352,7 +4351,7 @@ s32 func_800BE184(PlayState* play, Actor* actor, f32 xzDist, s16 arg3, s16 arg4, s16 phi_v0 = BINANG_SUB(BINANG_ROT180(actor->yawTowardsPlayer), player->actor.shape.rot.y); s16 temp_t0 = actor->yawTowardsPlayer - arg5; - if ((actor->xzDistToPlayer <= xzDist) && (player->swordState != 0)) { + if ((actor->xzDistToPlayer <= xzDist) && (player->meleeWeaponState != 0)) { if ((arg4 >= ABS_ALT(phi_v0)) && (arg3 >= ABS_ALT(temp_t0))) { return true; } diff --git a/src/code/z_camera.c b/src/code/z_camera.c index d3f1f9203..aaf68c759 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -318,7 +318,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DF8EC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFAC8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeSetting.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeDataIdx.s") @@ -328,13 +328,13 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetInputDirYaw.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFC90.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDir.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDirPitch.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDirYaw.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFD04.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_AddQuake.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFD78.s") @@ -350,7 +350,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ClearFlags.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFFAC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeDoorCam.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E007C.s") diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 01234f7fc..edaa159c6 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1516,28 +1516,28 @@ void CollisionCheck_HitSolid(PlayState* play, ColliderInfo* info, Collider* coll s32 flags = info->toucherFlags & TOUCH_SFX_NONE; if (flags == TOUCH_SFX_NORMAL && collider->colType != COLTYPE_METAL) { - EffectSsHitMark_SpawnFixedScale(play, 0, hitPos); + EffectSsHitmark_SpawnFixedScale(play, 0, hitPos); if (collider->actor == NULL) { play_sound(NA_SE_IT_SHIELD_BOUND); } else { Audio_PlaySfxAtPos(&collider->actor->projectedPos, NA_SE_IT_SHIELD_BOUND); } } else if (flags == TOUCH_SFX_NORMAL) { - EffectSsHitMark_SpawnFixedScale(play, 3, hitPos); + EffectSsHitmark_SpawnFixedScale(play, 3, hitPos); if (collider->actor == NULL) { CollisionCheck_SpawnShieldParticlesMetal(play, hitPos); } else { CollisionCheck_SpawnShieldParticlesMetalSound(play, hitPos, &collider->actor->projectedPos); } } else if (flags == TOUCH_SFX_HARD) { - EffectSsHitMark_SpawnFixedScale(play, 0, hitPos); + EffectSsHitmark_SpawnFixedScale(play, 0, hitPos); if (collider->actor == NULL) { play_sound(NA_SE_IT_SHIELD_BOUND); } else { Audio_PlaySfxAtPos(&collider->actor->projectedPos, NA_SE_IT_SHIELD_BOUND); } } else if (flags == TOUCH_SFX_WOOD) { - EffectSsHitMark_SpawnFixedScale(play, 1, hitPos); + EffectSsHitmark_SpawnFixedScale(play, 1, hitPos); if (collider->actor == NULL) { play_sound(NA_SE_IT_REFLECTION_WOOD); } else { @@ -1603,13 +1603,13 @@ void CollisionCheck_HitEffects(PlayState* play, Collider* at, ColliderInfo* atIn CollisionCheck_SpawnShieldParticlesWood(play, hitPos, &at->actor->projectedPos); } } else if (sHitInfo[ac->colType].effect != HIT_NONE) { - EffectSsHitMark_SpawnFixedScale(play, sHitInfo[ac->colType].effect, hitPos); + EffectSsHitmark_SpawnFixedScale(play, sHitInfo[ac->colType].effect, hitPos); if (!(acInfo->bumperFlags & BUMP_NO_SWORD_SFX)) { CollisionCheck_SwordHitAudio(at, acInfo); } } } else { - EffectSsHitMark_SpawnFixedScale(play, 0, hitPos); + EffectSsHitmark_SpawnFixedScale(play, 0, hitPos); if (ac->actor == NULL) { play_sound(NA_SE_IT_SHIELD_BOUND); } else { diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 3860cf153..7c8b7cf99 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -15,7 +15,7 @@ void SaveContext_Init(void) { gSaveContext.nextDayTime = 0xFFFF; gSaveContext.environmentTime = 0; gSaveContext.dogIsLost = true; - gSaveContext.nextTransition = 0xFF; + gSaveContext.nextTransitionType = TRANS_NEXT_TYPE_DEFAULT; gSaveContext.unk_3F26 = 50; gSaveContext.options.language = 1; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 1367198c1..1827acc85 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -82,7 +82,7 @@ CutsceneStateHandler sCsStateHandlers2[] = { }; void Cutscene_Update2(PlayState* play, CutsceneContext* csCtx) { - if ((gSaveContext.cutsceneTrigger != 0) && (play->sceneLoadFlag == 0x14)) { + if ((gSaveContext.cutsceneTrigger != 0) && (play->transitionTrigger == TRANS_TRIGGER_START)) { gSaveContext.cutsceneTrigger = 0; } @@ -293,8 +293,8 @@ void Cutscene_Command_Misc(PlayState* play2, CutsceneContext* csCtx, CsCmdBase* if (isStartFrame) { play->nextEntranceIndex = 0x1C00; gSaveContext.nextCutsceneIndex = 0xFFF8; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; } break; case 0x1C: @@ -562,7 +562,7 @@ void Cutscene_TerminatorImpl(PlayState* play, CutsceneContext* csCtx, CsCmdBase* csCtx->state = CS_STATE_4; func_80165690(); Audio_SetCutsceneFlag(false); - gSaveContext.unk_3F48 = 1; + gSaveContext.cutsceneTransitionControl = 1; if ((gSaveContext.gameMode != 0) && (csCtx->frames != cmd->startFrame)) { gSaveContext.unk_3F1E = 1; @@ -572,7 +572,7 @@ void Cutscene_TerminatorImpl(PlayState* play, CutsceneContext* csCtx, CsCmdBase* if (cmd->base == 1) { play->nextEntranceIndex = play->csCtx.sceneCsList[play->csCtx.currentCsIndex].nextEntranceIndex; gSaveContext.nextCutsceneIndex = 0; - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; if (gSaveContext.gameMode != 1) { Scene_SetExitFade(play); } else { @@ -580,7 +580,7 @@ void Cutscene_TerminatorImpl(PlayState* play, CutsceneContext* csCtx, CsCmdBase* if (D_801BB12C >= 2) { D_801BB12C = 0; } - play->unk_1887F = 4; + play->transitionType = TRANS_TYPE_04; } if ((play->nextEntranceIndex & 0xF) > 0) { @@ -605,26 +605,26 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB case 0x1F: if (gSaveContext.save.weekEventReg[20] & 2) { play->nextEntranceIndex = 0x3010; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; } else { play->nextEntranceIndex = 0x8600; gSaveContext.nextCutsceneIndex = 0xFFF0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; } break; case 0x44: if (gSaveContext.save.weekEventReg[33] & 0x80) { play->nextEntranceIndex = 0xAE70; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; } else { play->nextEntranceIndex = 0xAE00; gSaveContext.nextCutsceneIndex = 0xFFF0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; } break; @@ -632,16 +632,16 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB gSaveContext.save.weekEventReg[55] |= 0x80; play->nextEntranceIndex = 0x6A80; gSaveContext.nextCutsceneIndex = 0xFFF0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; break; case 0x36: gSaveContext.save.weekEventReg[52] |= 0x20; play->nextEntranceIndex = 0x2000; gSaveContext.nextCutsceneIndex = 0xFFF1; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; break; } } @@ -667,7 +667,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->nextEntranceIndex = 0x1C00; gSaveContext.nextCutsceneIndex = 0xFFF9; } - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 3: @@ -680,7 +680,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->nextEntranceIndex = 0x1C10; gSaveContext.nextCutsceneIndex = 0xFFF9; } - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 4: @@ -693,7 +693,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->nextEntranceIndex = 0x1C20; gSaveContext.nextCutsceneIndex = 0xFFF9; } - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 5: @@ -706,7 +706,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->nextEntranceIndex = 0x1C30; gSaveContext.nextCutsceneIndex = 0xFFF9; } - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 6: @@ -719,7 +719,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->nextEntranceIndex = 0x1C50; gSaveContext.nextCutsceneIndex = 0xFFF9; } - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 7: @@ -732,14 +732,14 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->nextEntranceIndex = 0x1C60; gSaveContext.nextCutsceneIndex = 0xFFF9; } - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 8: // Ikana canyon play->nextEntranceIndex = 0x2000; gSaveContext.nextCutsceneIndex = 0xFFF3; - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 9: @@ -752,7 +752,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->nextEntranceIndex = 0x1C70; gSaveContext.nextCutsceneIndex = 0xFFF9; } - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 10: @@ -765,7 +765,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->nextEntranceIndex = 0x1C40; gSaveContext.nextCutsceneIndex = 0xFFF9; } - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; case 11: @@ -778,7 +778,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->nextEntranceIndex = 0x1C80; gSaveContext.nextCutsceneIndex = 0xFFF9; } - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; break; } } @@ -880,7 +880,7 @@ void Cutscene_Command_TransitionFX(PlayState* play, CutsceneContext* csCtx, CsCm break; case 9: - gSaveContext.unk_3F48 = 1; + gSaveContext.cutsceneTransitionControl = 1; break; case 10: @@ -998,7 +998,7 @@ s32 Cutscene_CountNormalMasks(void) { // Command 0xA: Textbox void Cutscene_Command_Textbox(PlayState* play, CutsceneContext* csCtx, CsCmdTextbox* cmd) { static s32 D_801BB160 = CS_TEXTBOX_TYPE_DEFAULT; - u8 dialogState; + u8 talkState; s32 pad; u16 originalCsFrames; s32 pad2; @@ -1048,10 +1048,11 @@ void Cutscene_Command_Textbox(PlayState* play, CutsceneContext* csCtx, CsCmdText // a textbox that is expected to be closed by the user is still open. originalCsFrames = csCtx->frames; - dialogState = Message_GetState(&play->msgCtx); - if ((dialogState != 2) && (dialogState != 0) && (dialogState != 7) && (dialogState != 8)) { + talkState = Message_GetState(&play->msgCtx); + if ((talkState != TEXT_STATE_CLOSING) && (talkState != TEXT_STATE_NONE) && (talkState != TEXT_STATE_7) && + (talkState != TEXT_STATE_8)) { csCtx->frames--; - if ((dialogState == 4) && Message_ShouldAdvance(play)) { + if ((talkState == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { if (play->msgCtx.choiceIndex == 0) { if (cmd->base == 0x33BD) { func_8019F230(); @@ -1089,12 +1090,12 @@ void Cutscene_Command_Textbox(PlayState* play, CutsceneContext* csCtx, CsCmdText } } - if (dialogState == 5 && Message_ShouldAdvance(play)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_80152434(play, cmd->base); } } - if ((dialogState == 2) && (D_801BB160 == CS_TEXTBOX_TYPE_3)) { + if ((talkState == TEXT_STATE_CLOSING) && (D_801BB160 == CS_TEXTBOX_TYPE_3)) { csCtx->frames--; D_801BB124++; } @@ -1176,7 +1177,8 @@ void Cutscene_ProcessCommands(PlayState* play, CutsceneContext* csCtx, u8* cutsc bcopy(cutscenePtr, &cutsceneEndFrame, sizeof(s32)); cutscenePtr += sizeof(s32); - if (((u16)cutsceneEndFrame < csCtx->frames) && (play->sceneLoadFlag != 0x14) && (csCtx->state != CS_STATE_4)) { + if (((u16)cutsceneEndFrame < csCtx->frames) && (play->transitionTrigger != TRANS_TRIGGER_START) && + (csCtx->state != CS_STATE_4)) { csCtx->state = CS_STATE_3; return; } @@ -1454,7 +1456,7 @@ void func_800EDA04(PlayState* play, CutsceneContext* csCtx) { } void func_800EDA84(PlayState* play, CutsceneContext* csCtx) { - if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0) && !Player_InCsMode(&play->state)) { + if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0) && !Player_InCsMode(play)) { gSaveContext.save.cutscene = 0xFFFD; } @@ -1474,8 +1476,8 @@ void func_800EDA84(PlayState* play, CutsceneContext* csCtx) { Audio_SetCutsceneFlag(true); csCtx->frames = 0xFFFF; - csCtx->csCamId = ActorCutscene_GetCurrentCamera(0x7F); - func_8016119C(Play_GetCamera(play, csCtx->csCamId), &sCutsceneCameraInfo); + csCtx->subCamId = ActorCutscene_GetCurrentSubCamId(0x7F); + func_8016119C(Play_GetCamera(play, csCtx->subCamId), &sCutsceneCameraInfo); csCtx->unk_18 = 0xFFFF; if (gSaveContext.cutsceneTrigger == 0) { diff --git a/src/code/z_eff_footmark.c b/src/code/z_eff_footmark.c index 2205d2d95..1dc3d7237 100644 --- a/src/code/z_eff_footmark.c +++ b/src/code/z_eff_footmark.c @@ -77,7 +77,7 @@ void EffFootmark_Update(PlayState* play) { for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) { if (footmark->actor != NULL) { if ((footmark->flags & 1) == 1) { - if (footmark->age < 0xFFFFu) { // TODO replace with MAX_U16 or something + if ((u32)footmark->age < UINT16_MAX) { footmark->age++; } diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index c7b073540..b6a5c46fa 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -32,7 +32,7 @@ #include "overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.h" #include "overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h" -void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture) { +void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, TexturePtr texture) { GraphicsContext* gfxCtx = play->state.gfxCtx; f32 scale; MtxF mfTrans; @@ -41,7 +41,7 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture) { MtxF mfTrans11DA0; s32 pad1; Mtx* mtx; - void* object = play->objectCtx.status[this->rgObjBankIdx].segment; + void* object = play->objectCtx.status[this->rgObjBankIndex].segment; OPEN_DISPS(gfxCtx); @@ -335,7 +335,7 @@ void EffectSsGSpk_SpawnAccel(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* v initParams.actor = actor; initParams.scale = scale; initParams.scaleStep = scaleStep; - initParams.updateMode = 0; + initParams.updateMode = GSPK_UPDATEMODE_NORMAL; EffectSs_Spawn(play, EFFECT_SS_G_SPK, 128, &initParams); } @@ -353,7 +353,7 @@ void EffectSsGSpk_SpawnNoAccel(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* initParams.actor = actor; initParams.scale = scale; initParams.scaleStep = scaleStep; - initParams.updateMode = 1; + initParams.updateMode = GSPK_UPDATEMODE_NO_ACCEL; EffectSs_Spawn(play, EFFECT_SS_G_SPK, 128, &initParams); } @@ -529,7 +529,7 @@ void EffectSsDtBubble_SpawnCustomColor(PlayState* play, Vec3f* pos, Vec3f* veloc * - due to how life is implemented it is capped at 200. Any value over 200 is accepted, but the fragment will * only live for 200 frames */ -void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16 scale, s16 objId, +void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 flags, s16 scale, s16 objId, s16 life, Gfx* dList) { EffectSsHahenInitParams initParams; @@ -537,7 +537,7 @@ void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* ac Math_Vec3f_Copy(&initParams.velocity, velocity); Math_Vec3f_Copy(&initParams.accel, accel); initParams.dList = dList; - initParams.unused = unused; + initParams.flags = flags; initParams.scale = scale; initParams.objId = objId; initParams.life = life; @@ -554,7 +554,7 @@ void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* ac * - due to how life is implemented it is capped at 200. Any value over 200 is accepted, but the fragment will * only live for 200 frames */ -void EffectSsHahen_SpawnBurst(PlayState* play, Vec3f* pos, f32 burstScale, s16 unused, s16 scale, s16 randScaleRange, +void EffectSsHahen_SpawnBurst(PlayState* play, Vec3f* pos, f32 burstScale, s16 flags, s16 scale, s16 randScaleRange, s16 count, s16 objId, s16 life, Gfx* dList) { s32 i; Vec3f velocity; @@ -568,7 +568,7 @@ void EffectSsHahen_SpawnBurst(PlayState* play, Vec3f* pos, f32 burstScale, s16 u velocity.z = (Rand_ZeroOne() - 0.5f) * burstScale; velocity.y = ((Rand_ZeroOne() * 0.5f) + 0.5f) * burstScale; - EffectSsHahen_Spawn(play, pos, &velocity, &accel, unused, Rand_S16Offset(scale, randScaleRange), objId, life, + EffectSsHahen_Spawn(play, pos, &velocity, &accel, flags, Rand_S16Offset(scale, randScaleRange), objId, life, dList); } } @@ -576,7 +576,7 @@ void EffectSsHahen_SpawnBurst(PlayState* play, Vec3f* pos, f32 burstScale, s16 u void func_800B2364(PlayState* play, Vec3f* pos, Gfx* dList) { Vec3f accel = { 0.0f, -2.0f, 0.0f }; - EffectSsHahen_Spawn(play, pos, &gZeroVec3f, &accel, 1, 5, 1, 10, dList); + EffectSsHahen_Spawn(play, pos, &gZeroVec3f, &accel, HAHEN_SMALL, 5, GAMEPLAY_KEEP, 10, dList); } // EffectSsStick Spawn Functions @@ -631,10 +631,10 @@ void EffectSsStone1_Spawn(PlayState* play, Vec3f* pos, s32 reg0) { EffectSs_Spawn(play, EFFECT_SS_STONE1, 128, &initParams); } -// EffectSsHitMark Spawn Functions +// EffectSsHitmark Spawn Functions -void EffectSsHitMark_Spawn(PlayState* play, s32 type, s16 scale, Vec3f* pos) { - EffectSsHitMarkInitParams initParams; +void EffectSsHitmark_Spawn(PlayState* play, s32 type, s16 scale, Vec3f* pos) { + EffectSsHitmarkInitParams initParams; initParams.type = type; initParams.scale = scale; @@ -643,12 +643,12 @@ void EffectSsHitMark_Spawn(PlayState* play, s32 type, s16 scale, Vec3f* pos) { EffectSs_Spawn(play, EFFECT_SS_HITMARK, 128, &initParams); } -void EffectSsHitMark_SpawnFixedScale(PlayState* play, s32 type, Vec3f* pos) { - EffectSsHitMark_Spawn(play, type, 300, pos); +void EffectSsHitmark_SpawnFixedScale(PlayState* play, s32 type, Vec3f* pos) { + EffectSsHitmark_Spawn(play, type, 300, pos); } -void EffectSsHitMark_SpawnCustomScale(PlayState* play, s32 type, s16 scale, Vec3f* pos) { - EffectSsHitMark_Spawn(play, type, scale, pos); +void EffectSsHitmark_SpawnCustomScale(PlayState* play, s32 type, s16 scale, Vec3f* pos) { + EffectSsHitmark_Spawn(play, type, scale, pos); } // EffectSsFhgFlash Spawn Functions diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 0e783e76c..10c33090c 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -224,7 +224,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { break; case ITEM00_FLEXIBLE: case ITEM00_BIG_FAIRY: - func_80115908(play, 0x70); + Health_ChangeBy(play, 0x70); break; case ITEM00_BOMBS_A: case ITEM00_BOMBS_B: @@ -537,7 +537,7 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { break; case ITEM00_FLEXIBLE: case ITEM00_BIG_FAIRY: - func_80115908(play, 0x70); + Health_ChangeBy(play, 0x70); break; case ITEM00_BOMBS_A: case ITEM00_BOMBS_B: diff --git a/src/code/z_eventmgr.c b/src/code/z_eventmgr.c index 1c61431b9..7128368ac 100644 --- a/src/code/z_eventmgr.c +++ b/src/code/z_eventmgr.c @@ -42,7 +42,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/func_800F2178.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCurrentCamera.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCurrentSubCamId.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/func_800F21CC.s") diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index 97d5d8373..e1fb63fa1 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -119,7 +119,7 @@ void FireObj_UpdateStateTransitions(PlayState* play, FireObj* fire) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3); } if ((fire->flags & 2) && (player->itemActionParam == PLAYER_AP_STICK)) { - Math_Vec3f_Diff(&player->swordInfo[0].tip, &fire->position, &dist); + Math_Vec3f_Diff(&player->meleeWeaponInfo[0].tip, &fire->position, &dist); if (Math3D_LengthSquared(&dist) < 400.0f) { sp40 = true; } diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 18df07783..dcbe71a1c 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -36,8 +36,8 @@ void GameOver_Update(PlayState* play) { CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_GILDED && CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_DEITY) { - if (gSaveContext.buttonStatus[0] != BTN_ENABLED) { - CUR_FORM_EQUIP(EQUIP_SLOT_B) = gSaveContext.buttonStatus[0]; + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] != BTN_ENABLED) { + CUR_FORM_EQUIP(EQUIP_SLOT_B) = gSaveContext.buttonStatus[EQUIP_SLOT_B]; } else { CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_NONE; } @@ -52,11 +52,11 @@ void GameOver_Update(PlayState* play) { gSaveContext.eventInf[1] = 0; gSaveContext.eventInf[2] = 0; gSaveContext.eventInf[3] = 0; - gSaveContext.buttonStatus[0] = BTN_ENABLED; - gSaveContext.buttonStatus[1] = BTN_ENABLED; - gSaveContext.buttonStatus[2] = BTN_ENABLED; - gSaveContext.buttonStatus[3] = BTN_ENABLED; - gSaveContext.buttonStatus[4] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; gSaveContext.unk_3F1E = 0; gSaveContext.unk_3F20 = 0; gSaveContext.unk_3F22 = 0; @@ -72,8 +72,8 @@ void GameOver_Update(PlayState* play) { if (gSaveContext.respawnFlag != -7) { gSaveContext.respawnFlag = -6; } - gSaveContext.nextTransition = 2; - gSaveContext.save.playerData.health = 48; + gSaveContext.nextTransitionType = TRANS_TYPE_02; + gSaveContext.save.playerData.health = 0x30; gameOverCtx->state++; if (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU) { gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index b5ec93f5a..342fd1bb0 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -71,7 +71,7 @@ void KaleidoSetup_Update(PlayState* play) { } if ((pauseCtx->state == 0) && (pauseCtx->debugState == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE)) { - if ((play->sceneLoadFlag == 0) && (play->unk_18B4A == 0)) { + if ((play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { if ((gSaveContext.save.cutscene < 0xFFF0) && (gSaveContext.nextCutsceneIndex < 0xFFF0)) { if (!Play_InCsMode(play) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) { if ((play->unk_1887C < 2) && (gSaveContext.unk_3F28 != 8) && (gSaveContext.unk_3F28 != 9)) { @@ -124,10 +124,10 @@ void KaleidoSetup_Init(PlayState* play) { pauseCtx->unk_258 = 11; pauseCtx->unk_25A = 0; - pauseCtx->unk_25E[PAUSE_0] = 999; - pauseCtx->unk_25E[PAUSE_1] = XREG(94) + 3; - pauseCtx->unk_25E[PAUSE_2] = 999; - pauseCtx->unk_25E[PAUSE_3] = 999; + pauseCtx->cursorItem[PAUSE_0] = 999; + pauseCtx->cursorItem[PAUSE_1] = XREG(94) + 3; + pauseCtx->cursorItem[PAUSE_2] = 999; + pauseCtx->cursorItem[PAUSE_3] = 999; pauseCtx->unk_268[PAUSE_0] = 0; pauseCtx->unk_268[PAUSE_1] = XREG(94) + 3; diff --git a/src/code/z_lib.c b/src/code/z_lib.c index aaf4bc7d9..03e6c395c 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -651,15 +651,15 @@ void Lib_PlaySfxAtPos(Vec3f* pos, u16 sfxId) { Audio_PlaySfxAtPos(pos, sfxId); } -void Lib_Vec3f_TranslateAndRotateY(Vec3f* translation, s16 a, Vec3f* src, Vec3f* dst) { - f32 sp1C; - f32 f0; +void Lib_Vec3f_TranslateAndRotateY(Vec3f* translation, s16 rotAngle, Vec3f* src, Vec3f* dst) { + f32 cos; + f32 sin; - sp1C = Math_CosS(a); - f0 = Math_SinS(a); - dst->x = translation->x + (src->x * sp1C + src->z * f0); + cos = Math_CosS(rotAngle); + sin = Math_SinS(rotAngle); + dst->x = translation->x + (src->x * cos + src->z * sin); dst->y = translation->y + src->y; - dst->z = translation->z + (src->z * sp1C - src->x * f0); + dst->z = translation->z + (src->z * cos - src->x * sin); } void Lib_LerpRGB(Color_RGB8* a, Color_RGB8* b, f32 t, Color_RGB8* dst) { @@ -688,7 +688,7 @@ f32 Math_Vec3f_StepTo(Vec3f* start, Vec3f* target, f32 speed) { start->z = start->z + f2 * diff.z; } else { Math_Vec3f_Copy(start, target); - f0 = 0; + f0 = 0.0f; } return f0; diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index c31cf0016..f33a949d8 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -398,7 +398,7 @@ void LifeMeter_UpdateSizeAndBeep(PlayState* play) { if (interfaceCtx->lifeSizeChange <= 0) { interfaceCtx->lifeSizeChange = 0; interfaceCtx->lifeSizeChangeDirection = 0; - if (!Player_InCsMode(&play->state) && (play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && + if (!Player_InCsMode(play) && (play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && LifeMeter_IsCritical() && !Play_InCsMode(play)) { play_sound(NA_SE_SY_HITPOINT_ALARM); } @@ -415,16 +415,16 @@ void LifeMeter_UpdateSizeAndBeep(PlayState* play) { u32 LifeMeter_IsCritical(void) { s16 criticalThreshold; - if (gSaveContext.save.playerData.healthCapacity <= 80) { // healthCapacity <= 5 hearts? - criticalThreshold = 16; + if (gSaveContext.save.playerData.healthCapacity <= 0x50) { + criticalThreshold = 0x10; - } else if (gSaveContext.save.playerData.healthCapacity <= 160) { // healthCapacity <= 10 hearts? - criticalThreshold = 24; + } else if (gSaveContext.save.playerData.healthCapacity <= 0xA0) { + criticalThreshold = 0x18; - } else if (gSaveContext.save.playerData.healthCapacity <= 240) { // healthCapacity <= 15 hearts? - criticalThreshold = 32; + } else if (gSaveContext.save.playerData.healthCapacity <= 0xF0) { + criticalThreshold = 0x20; } else { - criticalThreshold = 44; + criticalThreshold = 0x2C; } if ((criticalThreshold >= gSaveContext.save.playerData.health) && (gSaveContext.save.playerData.health > 0)) { diff --git a/src/code/z_map_disp.c b/src/code/z_map_disp.c index 77de75fa0..a1b303488 100644 --- a/src/code/z_map_disp.c +++ b/src/code/z_map_disp.c @@ -463,7 +463,7 @@ void func_8010549C(PlayState* globalCtx, void* segmentAddress) { MinimapList* temp_v0; s32 i; - if (func_8010A208(globalCtx) == 0) { + if (Map_IsInBossArea(globalCtx) == 0) { D_801BEC1C = globalCtx->numRooms; temp_v0 = Lib_SegmentedToVirtual(segmentAddress); D_801BEC14 = *temp_v0; @@ -520,7 +520,7 @@ s32 func_80106450(PlayState* play) { } s32 func_801064CC(PlayState* play) { - if (((play->csCtx.state != 0) && (func_80106408(play) == 0)) || (D_801BEBB8.unk20 & 2) || (func_8010A208(play) != 0)) { + if (((play->csCtx.state != 0) && (func_80106408(play) == 0)) || (D_801BEBB8.unk20 & 2) || (Map_IsInBossArea(play) != 0)) { return true; } return false; diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index 079117fd4..9baff91f1 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -1,31 +1,257 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A000.s") +s16 sMinimapInitPosX = 0; +s16 sMinimapInitPosZ = 0; +s16 sMinimapInitDir = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A074.s") +s32 sDungeonAndBossScenes[] = { + SCENE_MITURIN, SCENE_HAKUGIN, SCENE_SEA, SCENE_INISIE_N, SCENE_INISIE_R, + SCENE_MITURIN_BS, SCENE_HAKUGIN_BS, SCENE_SEA_BS, SCENE_INISIE_BS, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A0A4.s") +/** + * If the current scene is a dungeon or boss scene, this function returns an index + * indicating which one it is. Otherwise, it returns -1. + */ +s32 Map_GetDungeonOrBossAreaIndex(PlayState* play) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A0F0.s") + for (i = 0; i < ARRAY_COUNT(sDungeonAndBossScenes); i++) { + if (Play_GetOriginalSceneNumber(play->sceneNum) == sDungeonAndBossScenes[i]) { + return i; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A164.s") + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A194.s") +/** + * Returns true if the current scene is a dungeon or boss scene, false otherwise. + */ +s32 Map_IsInDungeonOrBossArea(PlayState* play) { + if (Map_GetDungeonOrBossAreaIndex(play) == -1) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A208.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A238.s") +s32 func_8010A0A4(PlayState* play) { + if ((Map_GetDungeonOrBossAreaIndex(play) == -1) || !func_80102EF0(play)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A2AC.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A2DC.s") +s32 sDungeonScenes[] = { + SCENE_MITURIN, SCENE_HAKUGIN, SCENE_SEA, SCENE_INISIE_N, SCENE_INISIE_R, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A33C.s") +/** + * If the current scene is a dungeon scene, this function returns an index + * indicating which one it is. Otherwise, it returns -1. + */ +s32 Map_GetDungeonAreaIndex(PlayState* play) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A410.s") + for (i = 0; i < ARRAY_COUNT(sDungeonScenes); i++) { + if (Play_GetOriginalSceneNumber(play->sceneNum) == sDungeonScenes[i]) { + return i; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A430.s") + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A54C.s") +/** + * Returns true if the current scene is a dungeon scene, false otherwise. + */ +s32 Map_IsInDungeonArea(PlayState* play) { + if (Map_GetDungeonAreaIndex(play) == -1) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A580.s") + return true; +} + +s32 sBossScenes[] = { + SCENE_MITURIN_BS, // DUNGEON_INDEX_WOODFALL_TEMPLE + SCENE_HAKUGIN_BS, // DUNGEON_INDEX_SNOWHEAD_TEMPLE + SCENE_SEA_BS, // DUNGEON_INDEX_GREAT_BAY_TEMPLE + SCENE_INISIE_BS, // DUNGEON_INDEX_STONE_TOWER_TEMPLE +}; + +/** + * If the current scene is a boss scene, this function returns an index + * indicating which one it is. Otherwise, it returns -1. + */ +s32 Map_GetBossAreaIndex(PlayState* play) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(sBossScenes); i++) { + if (Play_GetOriginalSceneNumber(play->sceneNum) == sBossScenes[i]) { + return i; + } + } + + return -1; +} + +/** + * Returns true if the current scene is a boss scene, false otherwise. + */ +s32 Map_IsInBossArea(PlayState* play) { + if (Map_GetBossAreaIndex(play) == -1) { + return false; + } + + return true; +} + +s32 D_801BF5A4[] = { + SCENE_22DEKUCITY, + SCENE_KOEPONARACE, + SCENE_F01, +}; + +s32 func_8010A238(PlayState* play) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_801BF5A4); i++) { + if (Play_GetOriginalSceneNumber(play->sceneNum) == D_801BF5A4[i]) { + return i; + } + } + + return -1; +} + +s32 func_8010A2AC(PlayState* play) { + if (func_8010A238(play) == -1) { + return false; + } + + return true; +} + +/** + * When a room is loaded, this function is used to save the player's position and rotation + * so that the red arrow on the minimap can be drawn correctly. + */ +void Minimap_SavePlayerRoomInitInfo(PlayState* play) { + Player* player = GET_PLAYER(play); + + sMinimapInitPosX = player->actor.world.pos.x; + sMinimapInitPosZ = player->actor.world.pos.z; + sMinimapInitDir = (0x7FFF - player->actor.shape.rot.y) / 0x400; +} + +void Map_InitRoomData(PlayState* play, s16 room) { + s32 mapIndex = gSaveContext.mapIndex; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + + func_80105C40(room); + + if (room >= 0) { + if (Map_IsInDungeonOrBossArea(play)) { + gSaveContext.save.permanentSceneFlags[Play_GetOriginalSceneNumber(play->sceneNum)].rooms |= gBitFlags[room]; + interfaceCtx->mapRoomNum = room; + interfaceCtx->dungeonOrBossAreaMapIndex = mapIndex; + } + } else { + interfaceCtx->mapRoomNum = 0; + } + + if (gSaveContext.sunsSongState != SUNSSONG_SPEED_TIME) { + gSaveContext.sunsSongState = SUNSSONG_INACTIVE; + } +} + +void Map_Destroy(void) { + func_80105A40(); +} + +void Map_Init(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s32 dungeonIndex; + + func_80105C40(play->roomCtx.currRoom.num); + interfaceCtx->unk_278 = -1; + interfaceCtx->dungeonOrBossAreaMapIndex = -1; + interfaceCtx->mapSegment = THA_AllocEndAlign16(&play->state.heap, 0x1000); + if (func_8010A2AC(play)) { + gSaveContext.mapIndex = func_8010A238(play); + return; + } + + if (Map_IsInDungeonOrBossArea(play)) { + dungeonIndex = Map_GetDungeonOrBossAreaIndex(play); + gSaveContext.mapIndex = dungeonIndex; + switch (play->sceneNum) { + case SCENE_MITURIN_BS: + dungeonIndex = DUNGEON_INDEX_WOODFALL_TEMPLE; + break; + + case SCENE_HAKUGIN_BS: + dungeonIndex = DUNGEON_INDEX_SNOWHEAD_TEMPLE; + break; + + case SCENE_SEA_BS: + dungeonIndex = DUNGEON_INDEX_GREAT_BAY_TEMPLE; + break; + + case SCENE_INISIE_BS: + dungeonIndex = DUNGEON_INDEX_STONE_TOWER_TEMPLE; + break; + } + + gSaveContext.dungeonIndex = dungeonIndex; + Map_InitRoomData(play, play->roomCtx.currRoom.num); + } +} + +void Minimap_Draw(PlayState* play) { + func_80106644(play, sMinimapInitPosX, sMinimapInitPosZ, sMinimapInitDir); +} + +s16 sLastRoomNum = 99; + +void Map_Update(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + Player* player = GET_PLAYER(play); + Input* controller = CONTROLLER1(&play->state); + s32 pad1; + s16 floor; + s32 pad2; + + if ((play->pauseCtx.state < 4) && (CHECK_BTN_ALL(controller->press.button, BTN_L)) && (!Play_InCsMode(play)) && + (!func_80106530(play))) { + if (!R_MINIMAP_DISABLED) { + play_sound(NA_SE_SY_CAMERA_ZOOM_UP); + } else { + play_sound(NA_SE_SY_CAMERA_ZOOM_DOWN); + } + + R_MINIMAP_DISABLED ^= 1; + } + + func_80105B34(play); + + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { + if (Map_IsInDungeonArea(play)) { + floor = func_80109124(player->actor.world.pos.y); + if (floor != -1) { + gSaveContext.save.permanentSceneFlags[Play_GetOriginalSceneNumber(play->sceneNum)].unk_14 |= + gBitFlags[FLOOR_INDEX_MAX - floor]; + XREG(94) = FLOOR_INDEX_MAX - floor; + if (interfaceCtx->mapRoomNum != sLastRoomNum) { + sLastRoomNum = interfaceCtx->mapRoomNum; + } + } + } else if (Map_IsInBossArea(play)) { + func_80105294(); + XREG(94) = FLOOR_INDEX_MAX - func_80105318(); + } + } +} diff --git a/src/code/z_message.c b/src/code/z_message.c index 8081f9c87..1e76578bb 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -99,8 +99,8 @@ s32 Message_ShouldAdvanceSilent(PlayState* play) { void func_801477B4(PlayState* play) { MessageContext* msgCtx = &play->msgCtx; - if (play->msgCtx.unk11F10 != 0) { - msgCtx->unk12023 = 2; + if (play->msgCtx.msgLength != 0) { + msgCtx->stateTimer = 2; msgCtx->msgMode = 0x43; msgCtx->unk12020 = 0; play_sound(NA_SE_PL_WALK_GROUND - SFX_FLAG); @@ -325,7 +325,7 @@ void Message_StartTextbox(PlayState* play, u16 textId, Actor* Actor) { func_80150D08(play, textId); msgCtx->unkActor = Actor; msgCtx->msgMode = 1; - msgCtx->unk12023 = 0; + msgCtx->stateTimer = 0; msgCtx->unk12024 = 0; play->msgCtx.ocarinaMode = 0; } @@ -334,11 +334,11 @@ void func_80151938(PlayState* play, u16 textId) { MessageContext* msgCtx = &play->msgCtx; InterfaceContext* interfaceCtx = &play->interfaceCtx; - msgCtx->unk11F10 = 0; + msgCtx->msgLength = 0; func_80150D08(play, textId); func_80150A84(play); msgCtx->msgMode = 5; - msgCtx->unk12023 = 8; + msgCtx->stateTimer = 8; msgCtx->unk12024 = 0; if (interfaceCtx->unk_222 == 0) { @@ -354,24 +354,24 @@ void func_80151938(PlayState* play, u16 textId) { msgCtx->unk12004 = 0x22; msgCtx->unk12006 = 0x15E; func_80149C18(play); - msgCtx->unk12023 = 1; + msgCtx->stateTimer = 1; } } void func_80151A68(PlayState* play, u16 textId) { MessageContext* msgCtx = &play->msgCtx; - msgCtx->unk11F10 = 0; + msgCtx->msgLength = 0; func_80150D08(play, textId); func_80150A84(play); func_8015B198(play); msgCtx->msgMode = 0x45; msgCtx->unk12024 = 0; msgCtx->unk1203C = msgCtx->unk1203A = msgCtx->unk1201E = 0; - msgCtx->unk12023 = 0x1E; + msgCtx->stateTimer = 30; // Day/Dawn/Night.. Messages - if ((msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId < 0x1BB7)) { + if ((msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId <= 0x1BB6)) { XREG(74) = 0x6A; XREG(75) = 0; XREG(77) = 0x58; @@ -439,7 +439,73 @@ void func_80152464(PlayState* play, u16 arg1) { func_80151DA4(play, arg1); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_GetState.s") +/** + * @return u8 A value of the TextState enum representing the current state of the on-screen message + */ +u8 Message_GetState(MessageContext* msgCtx) { + if (msgCtx->msgLength == 0) { + return TEXT_STATE_NONE; + } + + if (msgCtx->msgMode == 0x42) { + if (msgCtx->unk11F14 != 0xFFFF) { + return TEXT_STATE_1; + } + + if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { + return TEXT_STATE_CHOICE; + } + if ((msgCtx->unk12020 == 0x40) || (msgCtx->unk12020 == 0x42) || (msgCtx->unk12020 == 0x30)) { + return TEXT_STATE_5; + } + if (msgCtx->unk12020 == 0x41) { + return TEXT_STATE_16; + } + if ((msgCtx->unk12020 >= 0x50) && (msgCtx->unk12020 < 0x58)) { + return TEXT_STATE_3; + } + if ((msgCtx->unk12020 == 0x60) || (msgCtx->unk12020 == 0x61)) { + return TEXT_STATE_14; + } + if (msgCtx->unk12020 == 0x62) { + return TEXT_STATE_15; + } + if (msgCtx->unk12020 == 0x63) { + return TEXT_STATE_17; + } + if (msgCtx->unk12020 == 0x12) { + return TEXT_STATE_18; + } + return TEXT_STATE_DONE; + } + + if (msgCtx->msgMode == 0x41) { + return TEXT_STATE_10; + } + if (msgCtx->msgMode == 0x1B) { + return TEXT_STATE_7; + } + if ((msgCtx->ocarinaMode == 3) || (msgCtx->msgMode == 0x37)) { + return TEXT_STATE_8; + } + if (msgCtx->msgMode == 0x20) { + return TEXT_STATE_9; + } + if ((msgCtx->msgMode == 0x21) || (msgCtx->msgMode == 0x3A)) { + return TEXT_STATE_11; + } + if (msgCtx->msgMode == 0x3D) { + return TEXT_STATE_12; + } + if (msgCtx->msgMode == 0x40) { + return TEXT_STATE_13; + } + if ((msgCtx->msgMode == 0x43) && (msgCtx->stateTimer == 1) && (msgCtx->unk120B1 == 0)) { + return TEXT_STATE_CLOSING; + } + + return TEXT_STATE_3; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015268C.s") @@ -523,7 +589,7 @@ void Message_Init(PlayState* play) { func_801586A4(play); play->msgCtx.ocarinaMode = 0; messageCtx->msgMode = 0; - messageCtx->unk11F10 = 0; + messageCtx->msgLength = 0; messageCtx->currentTextId = 0; messageCtx->unk12020 = 0; messageCtx->choiceIndex = 0; diff --git a/src/code/z_olib.c b/src/code/z_olib.c index 6f1cdbc55..2b6b8d139 100644 --- a/src/code/z_olib.c +++ b/src/code/z_olib.c @@ -123,14 +123,14 @@ VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec) { if ((dist == 0.0f) && (vec->y == 0.0f)) { sph.pitch = 0; } else { - sph.pitch = DEGF_TO_BINANG(RADF_TO_DEGF(func_80086B30(dist, vec->y))); + sph.pitch = CAM_DEG_TO_BINANG(RADF_TO_DEGF(func_80086B30(dist, vec->y))); } sph.r = sqrtf(SQ(vec->y) + distSquared); if ((vec->x == 0.0f) && (vec->z == 0.0f)) { sph.yaw = 0; } else { - sph.yaw = DEGF_TO_BINANG(RADF_TO_DEGF(func_80086B30(vec->x, vec->z))); + sph.yaw = CAM_DEG_TO_BINANG(RADF_TO_DEGF(func_80086B30(vec->x, vec->z))); } *dest = sph; @@ -238,8 +238,8 @@ Vec3s* OLib_Vec3fDiffBinAng(Vec3s* dest, Vec3f* a, Vec3f* b) { OLib_Vec3fDiffRad(&anglesRad, a, b); - anglesBinAng.x = DEGF_TO_BINANG(RADF_TO_DEGF(anglesRad.x)); - anglesBinAng.y = DEGF_TO_BINANG(RADF_TO_DEGF(anglesRad.y)); + anglesBinAng.x = CAM_DEG_TO_BINANG(RADF_TO_DEGF(anglesRad.x)); + anglesBinAng.y = CAM_DEG_TO_BINANG(RADF_TO_DEGF(anglesRad.y)); anglesBinAng.z = 0.0f; *dest = anglesBinAng; diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 44b1de152..a76cb36e0 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1,4 +1,225 @@ #include "global.h" +#include "interface/parameter_static/parameter_static.h" +#include "interface/do_action_static/do_action_static.h" +#include "misc/story_static/story_static.h" +#include "overlays/gamestates/ovl_file_choose/z_file_choose.h" + +typedef struct { + /* 0x00 */ u8 scene; + /* 0x01 */ u8 flags1; + /* 0x02 */ u8 flags2; + /* 0x03 */ u8 flags3; +} RestrictionFlags; + +Input D_801F5850[4]; + +RestrictionFlags sRestrictionFlags[] = { + { SCENE_20SICHITAI2, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_1, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_2, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_3, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_4, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_5, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_6, 0x00, 0x00, 0x00 }, + { SCENE_KAKUSIANA, 0x00, 0x00, 0x00 }, + { SCENE_SPOT00, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_9, 0x00, 0x00, 0x00 }, + { SCENE_WITCH_SHOP, 0x10, 0x30, 0xC1 }, + { SCENE_LAST_BS, 0x00, 0x3F, 0x00 }, + { SCENE_HAKASHITA, 0x00, 0x00, 0x00 }, + { SCENE_AYASHIISHOP, 0x10, 0x30, 0xC1 }, + { SCENE_UNSET_E, 0x00, 0x00, 0x00 }, + { SCENE_UNSET_F, 0x00, 0x00, 0x00 }, + { SCENE_OMOYA, 0x00, 0x33, 0x00 }, + { SCENE_BOWLING, 0x10, 0x30, 0xC1 }, + { SCENE_SONCHONOIE, 0x10, 0x30, 0xC1 }, + { SCENE_IKANA, 0x00, 0x00, 0x00 }, + { SCENE_KAIZOKU, 0x00, 0x00, 0x00 }, + { SCENE_MILK_BAR, 0x10, 0x30, 0xC1 }, + { SCENE_INISIE_N, 0x00, 0x00, 0x00 }, + { SCENE_TAKARAYA, 0x10, 0x30, 0xC1 }, + { SCENE_INISIE_R, 0x00, 0x00, 0x00 }, + { SCENE_OKUJOU, 0x00, 0x3F, 0xF0 }, + { SCENE_OPENINGDAN, 0x00, 0x00, 0x00 }, + { SCENE_MITURIN, 0x00, 0x00, 0x00 }, + { SCENE_13HUBUKINOMITI, 0x00, 0x00, 0x00 }, + { SCENE_CASTLE, 0x00, 0x00, 0x00 }, + { SCENE_DEKUTES, 0x10, 0x30, 0x01 }, + { SCENE_MITURIN_BS, 0x00, 0x00, 0x00 }, + { SCENE_SYATEKI_MIZU, 0x10, 0x30, 0xC1 }, + { SCENE_HAKUGIN, 0x00, 0x00, 0x00 }, + { SCENE_ROMANYMAE, 0x00, 0x00, 0x00 }, + { SCENE_PIRATE, 0x00, 0x00, 0x00 }, + { SCENE_SYATEKI_MORI, 0x10, 0x30, 0xC1 }, + { SCENE_SINKAI, 0x00, 0x00, 0x00 }, + { SCENE_YOUSEI_IZUMI, 0x00, 0x00, 0x00 }, + { SCENE_KINSTA1, 0x00, 0x30, 0x00 }, + { SCENE_KINDAN2, 0x00, 0x30, 0x00 }, + { SCENE_TENMON_DAI, 0x00, 0x03, 0xC0 }, + { SCENE_LAST_DEKU, 0x00, 0x3F, 0x00 }, + { SCENE_22DEKUCITY, 0x00, 0x00, 0x00 }, + { SCENE_KAJIYA, 0x00, 0x30, 0xC0 }, + { SCENE_00KEIKOKU, 0x00, 0x00, 0x00 }, + { SCENE_POSTHOUSE, 0x00, 0x30, 0xC1 }, + { SCENE_LABO, 0x00, 0x30, 0xC1 }, + { SCENE_DANPEI2TEST, 0x00, 0x30, 0x00 }, + { SCENE_UNSET_31, 0x00, 0x00, 0x00 }, + { SCENE_16GORON_HOUSE, 0x00, 0x00, 0x00 }, + { SCENE_33ZORACITY, 0x00, 0x00, 0xC0 }, + { SCENE_8ITEMSHOP, 0x00, 0x30, 0xC1 }, + { SCENE_F01, 0x00, 0x00, 0x00 }, + { SCENE_INISIE_BS, 0x00, 0x00, 0x00 }, + { SCENE_30GYOSON, 0x00, 0x00, 0x00 }, + { SCENE_31MISAKI, 0x00, 0x00, 0x00 }, + { SCENE_TAKARAKUJI, 0x00, 0x30, 0xC1 }, + { SCENE_UNSET_3A, 0x00, 0x00, 0x00 }, + { SCENE_TORIDE, 0x00, 0x00, 0x00 }, + { SCENE_FISHERMAN, 0x00, 0x30, 0xC1 }, + { SCENE_GORONSHOP, 0x10, 0x30, 0xC1 }, + { SCENE_DEKU_KING, 0x00, 0x30, 0xC0 }, + { SCENE_LAST_GORON, 0x00, 0x3F, 0x00 }, + { SCENE_24KEMONOMITI, 0x00, 0x00, 0x00 }, + { SCENE_F01_B, 0x00, 0x30, 0x00 }, + { SCENE_F01C, 0x00, 0x30, 0x00 }, + { SCENE_BOTI, 0x00, 0x00, 0x00 }, + { SCENE_HAKUGIN_BS, 0x00, 0x00, 0x00 }, + { SCENE_20SICHITAI, 0x00, 0x00, 0x00 }, + { SCENE_21MITURINMAE, 0x00, 0x00, 0x00 }, + { SCENE_LAST_ZORA, 0x00, 0x3F, 0x00 }, + { SCENE_11GORONNOSATO2, 0x00, 0x00, 0x00 }, + { SCENE_SEA, 0x00, 0x00, 0x00 }, + { SCENE_35TAKI, 0x00, 0x00, 0x00 }, + { SCENE_REDEAD, 0x00, 0x00, 0x00 }, + { SCENE_BANDROOM, 0x00, 0x30, 0xC0 }, + { SCENE_11GORONNOSATO, 0x00, 0x00, 0x00 }, + { SCENE_GORON_HAKA, 0x00, 0x00, 0x00 }, + { SCENE_SECOM, 0x00, 0x3C, 0xC0 }, + { SCENE_10YUKIYAMANOMURA, 0x00, 0x00, 0x00 }, + { SCENE_TOUGITES, 0x00, 0x3F, 0xF0 }, + { SCENE_DANPEI, 0x00, 0x30, 0x00 }, + { SCENE_IKANAMAE, 0x00, 0x00, 0x00 }, + { SCENE_DOUJOU, 0x00, 0x30, 0xC1 }, + { SCENE_MUSICHOUSE, 0x00, 0x30, 0xC0 }, + { SCENE_IKNINSIDE, 0x00, 0x3F, 0xC0 }, + { SCENE_MAP_SHOP, 0x10, 0x30, 0xC1 }, + { SCENE_F40, 0x00, 0x00, 0x00 }, + { SCENE_F41, 0x00, 0x00, 0x00 }, + { SCENE_10YUKIYAMANOMURA2, 0x00, 0x00, 0x00 }, + { SCENE_14YUKIDAMANOMITI, 0x00, 0x00, 0x00 }, + { SCENE_12HAKUGINMAE, 0x00, 0x00, 0x00 }, + { SCENE_17SETUGEN, 0x00, 0x00, 0x00 }, + { SCENE_17SETUGEN2, 0x00, 0x00, 0x00 }, + { SCENE_SEA_BS, 0x00, 0x00, 0x00 }, + { SCENE_RANDOM, 0x00, 0x00, 0x00 }, + { SCENE_YADOYA, 0x10, 0x30, 0xC1 }, + { SCENE_KONPEKI_ENT, 0x00, 0x00, 0x00 }, + { SCENE_INSIDETOWER, 0x00, 0xFF, 0xC0 }, + { SCENE_26SARUNOMORI, 0x00, 0x30, 0x00 }, + { SCENE_LOST_WOODS, 0x00, 0x00, 0x00 }, + { SCENE_LAST_LINK, 0x00, 0x3F, 0x00 }, + { SCENE_SOUGEN, 0x00, 0x3F, 0x00 }, + { SCENE_BOMYA, 0x10, 0x30, 0xC1 }, + { SCENE_KYOJINNOMA, 0x00, 0x00, 0x00 }, + { SCENE_KOEPONARACE, 0x00, 0x30, 0x00 }, + { SCENE_GORONRACE, 0x00, 0x00, 0x00 }, + { SCENE_TOWN, 0x00, 0x00, 0x00 }, + { SCENE_ICHIBA, 0x00, 0x00, 0x00 }, + { SCENE_BACKTOWN, 0x00, 0x00, 0x00 }, + { SCENE_CLOCKTOWER, 0x00, 0x00, 0x00 }, + { SCENE_ALLEY, 0x00, 0x00, 0x00 }, +}; + +s16 D_801BF884 = 0; // pictoBox related +s16 D_801BF888 = false; // pictoBox related + +s16 sHBAScoreTier = 0; // Remnant of OoT, non-functional + +u16 sMinigameScoreDigits[] = { 0, 0, 0, 0 }; + +u16 sCUpInvisible = 0; +u16 sCUpTimer = 0; + +s16 sMagicBarOutlinePrimRed = 255; +s16 sMagicBarOutlinePrimGreen = 255; +s16 sMagicBarOutlinePrimBlue = 255; +s16 D_801BF8AC = 2; // sMagicBorderRatio +s16 D_801BF8B0 = 1; + +s16 sExtraItemBases[] = { + ITEM_STICK, // ITEM_STICKS_5 + ITEM_STICK, // ITEM_STICKS_10 + ITEM_NUT, // ITEM_NUTS_5 + ITEM_NUT, // ITEM_NUTS_10 + ITEM_BOMB, // ITEM_BOMBS_5 + ITEM_BOMB, // ITEM_BOMBS_10 + ITEM_BOMB, // ITEM_BOMBS_20 + ITEM_BOMB, // ITEM_BOMBS_30 + ITEM_BOW, // ITEM_ARROWS_10 + ITEM_BOW, // ITEM_ARROWS_30 + ITEM_BOW, // ITEM_ARROWS_40 + ITEM_BOMBCHU, // ITEM_ARROWS_50 !@bug this data is missing an ITEM_BOW, offsetting the rest by 1 + ITEM_BOMBCHU, // ITEM_BOMBCHUS_20 + ITEM_BOMBCHU, // ITEM_BOMBCHUS_10 + ITEM_BOMBCHU, // ITEM_BOMBCHUS_1 + ITEM_STICK, // ITEM_BOMBCHUS_5 + ITEM_STICK, // ITEM_STICK_UPGRADE_20 + ITEM_NUT, // ITEM_STICK_UPGRADE_30 + ITEM_NUT, // ITEM_NUT_UPGRADE_30 +}; + +s16 D_801BF8DC = 0; +s16 D_801BF8E0 = 0; +s16 D_801BF8E4 = 0; + +OSTime D_801BF8E8 = 0; +OSTime D_801BF8F0 = 0; +OSTime D_801BF8F8[] = { + 0, 0, 0, 0, 0, 0, 0, +}; +OSTime D_801BF930[] = { + 0, 0, 0, 0, 0, 0, 0, +}; + +u8 D_801BF968 = false; +u8 D_801BF96C = false; + +s16 D_801BF970 = 99; +s16 D_801BF974 = 0; +s16 D_801BF978 = 10; +s16 D_801BF97C = 255; +f32 D_801BF980 = 1.0f; +s32 D_801BF984 = 0; + +Gfx D_801BF988[] = { + gsDPPipeSync(), + gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | + G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH), + gsDPSetOtherMode(G_AD_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_1PRIMITIVE, + G_AC_NONE | G_ZS_PIXEL | G_RM_CLD_SURF | G_RM_CLD_SURF2), + gsDPSetCombineMode(G_CC_PRIMITIVE, G_CC_PRIMITIVE), + gsSPEndDisplayList(), +}; + +s16 D_801BF9B0 = 0; +f32 D_801BF9B4[] = { 100.0f, 109.0f }; +s16 D_801BF9BC[] = { 0x226, 0x2A8, 0x2A8, 0x2A8 }; +s16 D_801BF9C4[] = { 0x9E, 0x9B }; +s16 D_801BF9C8[] = { 0x17, 0x16 }; +f32 D_801BF9CC[] = { -380.0f, -350.0f }; +s16 D_801BF9D4[] = { 0xA7, 0xE3 }; +s16 D_801BF9D8[] = { 0xF9, 0x10F }; +s16 D_801BF9DC[] = { 0x11, 0x12 }; +s16 D_801BF9E0[] = { 0x22, 0x12 }; +s16 D_801BF9E4[] = { 0x23F, 0x26C }; +s16 D_801BF9E8[] = { 0x26C, 0x26C }; + +s16 sFinalHoursClockDigitsRed = 0; +s16 sFinalHoursClockFrameEnvRed = 0; +s16 sFinalHoursClockFrameEnvGreen = 0; +s16 sFinalHoursClockFrameEnvBlue = 0; +s16 sFinalHoursClockColorTimer = 15; +s16 sFinalHoursClockColorTargetIndex = 0; #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010CB80.s") @@ -18,8 +239,29 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010DE38.s") +s16 D_801BFA04[] = { + -14, -14, -24, -8, -12, -12, -7, -8, -7, -8, -12, 0, +}; +s16 D_801BFA1C[] = { + 0x1C, 0x1C, 0x30, 0x10, 0x18, 0x18, 0x10, 0x10, 0x10, 0x10, 0x18, 0, +}; +s16 D_801BFA34[] = { + 14, 14, 8, 24, -82, -82, 58, 59, 58, 59, 32, 0, +}; +s16 D_801BFA4C[] = { + 0x1C, 0x1C, 0x10, 0x10, 0x18, 0x18, 0xB, 0xB, 0xB, 0xB, 0x20, 0, +}; +s16 D_801BFA64[] = { + -61, -45, 29, 104, -117, -42, 32, 55, +}; +s16 D_801BFA74[] = { + 1, -70, -99, -70, 71, 101, 72, 1, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010E028.s") +s32 D_801BFA84 = 0; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010E968.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010E9F0.s") @@ -28,6 +270,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EB50.s") +void func_8010EBA0(s16 timer, s16 timerId); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EBA0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EC54.s") @@ -52,38 +295,755 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112AFC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112B40.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_LoadItemIconImpl.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112BE4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_LoadItemIcon.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112C0C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Item_Give.s") +s16 sAmmoRefillCounts[] = { 5, 10, 20, 30 }; // Sticks, nuts, bombs +s16 sArrowRefillCounts[] = { 10, 30, 40, 50 }; +s16 sBombchuRefillCounts[] = { 20, 10, 1, 5 }; +s16 sRupeeRefillCounts[] = { 1, 5, 10, 20, 50, 100, 200 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801143CC.s") +u8 Item_Give(PlayState* play, u8 item) { + Player* player = GET_PLAYER(play); + u8 i; + u8 temp; + u8 slot; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80114978.s") + slot = SLOT(item); + if (item >= ITEM_STICKS_5) { + slot = SLOT(sExtraItemBases[item - ITEM_STICKS_5]); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801149A0.s") + if (item == ITEM_SKULL_TOKEN) { + SET_QUEST_ITEM(item - ITEM_SKULL_TOKEN + QUEST_SKULL_TOKEN); + Inventory_IncrementSkullTokenCount(play->sceneNum); + return ITEM_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80114A9C.s") + } else if (item == ITEM_TINGLE_MAP) { + return ITEM_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80114B84.s") + } else if (item == ITEM_BOMBERS_NOTEBOOK) { + SET_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK); + return ITEM_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80114CA0.s") + } else if ((item == ITEM_HEART_PIECE_2) || (item == ITEM_HEART_PIECE)) { + gSaveContext.save.inventory.questItems += (1 << QUEST_HEART_PIECE_COUNT); + if ((gSaveContext.save.inventory.questItems & 0xF0000000) == (4 << QUEST_HEART_PIECE_COUNT)) { + gSaveContext.save.inventory.questItems ^= (4 << QUEST_HEART_PIECE_COUNT); + gSaveContext.save.playerData.healthCapacity += 0x10; + gSaveContext.save.playerData.health += 0x10; + } + return ITEM_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_HasEmptyBottle.s") + } else if (item == ITEM_HEART_CONTAINER) { + gSaveContext.save.playerData.healthCapacity += 0x10; + gSaveContext.save.playerData.health += 0x10; + return ITEM_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_HasItemInBottle.s") + } else if ((item >= ITEM_SONG_SONATA) && (item <= ITEM_SONG_LULLABY_INTRO)) { + SET_QUEST_ITEM(item - ITEM_SONG_SONATA + QUEST_SONG_SONATA); + return ITEM_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80114FD0.s") + } else if ((item >= ITEM_SWORD_KOKIRI) && (item <= ITEM_SWORD_GILDED)) { + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, item - ITEM_SWORD_KOKIRI + EQUIP_VALUE_SWORD_KOKIRI); + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = item; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + if (item == ITEM_SWORD_RAZOR) { + gSaveContext.save.playerData.swordHealth = 100; + } + return ITEM_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115130.s") + } else if ((item >= ITEM_SHIELD_HERO) && (item <= ITEM_SHIELD_MIRROR)) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != (u16)(item - ITEM_SHIELD_HERO + EQUIP_VALUE_SHIELD_HERO)) { + SET_EQUIP_VALUE(EQUIP_TYPE_SHIELD, item - ITEM_SHIELD_HERO + EQUIP_VALUE_SHIELD_HERO); + Player_SetEquipmentData(play, player); + return ITEM_NONE; + } + return item; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801152B8.s") + } else if ((item == ITEM_KEY_BOSS) || (item == ITEM_COMPASS) || (item == ITEM_DUNGEON_MAP)) { + SET_DUNGEON_ITEM(item - ITEM_KEY_BOSS, gSaveContext.mapIndex); + return ITEM_NONE; + + } else if (item == ITEM_KEY_SMALL) { + if (DUNGEON_KEY_COUNT(gSaveContext.mapIndex) < 0) { + DUNGEON_KEY_COUNT(gSaveContext.mapIndex) = 1; + return ITEM_NONE; + } else { + DUNGEON_KEY_COUNT(gSaveContext.mapIndex)++; + return ITEM_NONE; + } + + } else if ((item == ITEM_QUIVER_30) || (item == ITEM_BOW)) { + if (CUR_UPG_VALUE(UPG_QUIVER) == 0) { + Inventory_ChangeUpgrade(UPG_QUIVER, 1); + INV_CONTENT(ITEM_BOW) = ITEM_BOW; + AMMO(ITEM_BOW) = CAPACITY(UPG_QUIVER, 1); + return ITEM_NONE; + } else { + AMMO(ITEM_BOW)++; + if (AMMO(ITEM_BOW) > (s8)CUR_CAPACITY(UPG_QUIVER)) { + AMMO(ITEM_BOW) = CUR_CAPACITY(UPG_QUIVER); + } + } + + } else if (item == ITEM_QUIVER_40) { + Inventory_ChangeUpgrade(UPG_QUIVER, 2); + INV_CONTENT(ITEM_BOW) = ITEM_BOW; + AMMO(ITEM_BOW) = CAPACITY(UPG_QUIVER, 2); + return ITEM_NONE; + + } else if (item == ITEM_QUIVER_50) { + Inventory_ChangeUpgrade(UPG_QUIVER, 3); + INV_CONTENT(ITEM_BOW) = ITEM_BOW; + AMMO(ITEM_BOW) = CAPACITY(UPG_QUIVER, 3); + return ITEM_NONE; + + } else if (item == ITEM_BOMB_BAG_20) { + if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { + Inventory_ChangeUpgrade(UPG_BOMB_BAG, 1); + INV_CONTENT(ITEM_BOMB) = ITEM_BOMB; + AMMO(ITEM_BOMB) = CAPACITY(UPG_BOMB_BAG, 1); + return ITEM_NONE; + + } else { + AMMO(ITEM_BOMB)++; + if (AMMO(ITEM_BOMB) > CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); + } + } + + } else if (item == ITEM_BOMB_BAG_30) { + Inventory_ChangeUpgrade(UPG_BOMB_BAG, 2); + INV_CONTENT(ITEM_BOMB) = ITEM_BOMB; + AMMO(ITEM_BOMB) = CAPACITY(UPG_BOMB_BAG, 2); + return ITEM_NONE; + + } else if (item == ITEM_BOMB_BAG_40) { + Inventory_ChangeUpgrade(UPG_BOMB_BAG, 3); + INV_CONTENT(ITEM_BOMB) = ITEM_BOMB; + AMMO(ITEM_BOMB) = CAPACITY(UPG_BOMB_BAG, 3); + return ITEM_NONE; + + } else if (item == ITEM_WALLET_ADULT) { + Inventory_ChangeUpgrade(UPG_WALLET, 1); + return ITEM_NONE; + + } else if (item == ITEM_WALLET_GIANT) { + Inventory_ChangeUpgrade(UPG_WALLET, 2); + return ITEM_NONE; + + } else if (item == ITEM_STICK_UPGRADE_20) { + if (INV_CONTENT(ITEM_STICK) != ITEM_STICK) { + INV_CONTENT(ITEM_STICK) = ITEM_STICK; + } + Inventory_ChangeUpgrade(UPG_STICKS, 2); + AMMO(ITEM_STICK) = CAPACITY(UPG_STICKS, 2); + return ITEM_NONE; + + } else if (item == ITEM_STICK_UPGRADE_30) { + if (INV_CONTENT(ITEM_STICK) != ITEM_STICK) { + INV_CONTENT(ITEM_STICK) = ITEM_STICK; + } + Inventory_ChangeUpgrade(UPG_STICKS, 3); + AMMO(ITEM_STICK) = CAPACITY(UPG_STICKS, 3); + return ITEM_NONE; + + } else if (item == ITEM_NUT_UPGRADE_30) { + if (INV_CONTENT(ITEM_NUT) != ITEM_NUT) { + INV_CONTENT(ITEM_NUT) = ITEM_NUT; + } + Inventory_ChangeUpgrade(UPG_NUTS, 2); + AMMO(ITEM_NUT) = CAPACITY(UPG_NUTS, 2); + return ITEM_NONE; + + } else if (item == ITEM_NUT_UPGRADE_40) { + if (INV_CONTENT(ITEM_NUT) != ITEM_NUT) { + INV_CONTENT(ITEM_NUT) = ITEM_NUT; + } + Inventory_ChangeUpgrade(UPG_NUTS, 3); + AMMO(ITEM_NUT) = CAPACITY(UPG_NUTS, 3); + return ITEM_NONE; + + } else if (item == ITEM_STICK) { + if (INV_CONTENT(ITEM_STICK) != ITEM_STICK) { + Inventory_ChangeUpgrade(UPG_STICKS, 1); + AMMO(ITEM_STICK) = 1; + } else { + AMMO(ITEM_STICK)++; + if (AMMO(ITEM_STICK) > CUR_CAPACITY(UPG_STICKS)) { + AMMO(ITEM_STICK) = CUR_CAPACITY(UPG_STICKS); + } + } + + } else if ((item == ITEM_STICKS_5) || (item == ITEM_STICKS_10)) { + if (INV_CONTENT(ITEM_STICK) != ITEM_STICK) { + Inventory_ChangeUpgrade(UPG_STICKS, 1); + AMMO(ITEM_STICK) = sAmmoRefillCounts[item - ITEM_STICKS_5]; + } else { + AMMO(ITEM_STICK) += sAmmoRefillCounts[item - ITEM_STICKS_5]; + if (AMMO(ITEM_STICK) > CUR_CAPACITY(UPG_STICKS)) { + AMMO(ITEM_STICK) = CUR_CAPACITY(UPG_STICKS); + } + } + + item = ITEM_STICK; + + } else if (item == ITEM_NUT) { + if (INV_CONTENT(ITEM_NUT) != ITEM_NUT) { + Inventory_ChangeUpgrade(UPG_NUTS, 1); + AMMO(ITEM_NUT) = 1; + } else { + AMMO(ITEM_NUT)++; + if (AMMO(ITEM_NUT) > CUR_CAPACITY(UPG_NUTS)) { + AMMO(ITEM_NUT) = CUR_CAPACITY(UPG_NUTS); + } + } + + } else if ((item == ITEM_NUTS_5) || (item == ITEM_NUTS_10)) { + if (INV_CONTENT(ITEM_NUT) != ITEM_NUT) { + Inventory_ChangeUpgrade(UPG_NUTS, 1); + AMMO(ITEM_NUT) += sAmmoRefillCounts[item - ITEM_NUTS_5]; + } else { + AMMO(ITEM_NUT) += sAmmoRefillCounts[item - ITEM_NUTS_5]; + if (AMMO(ITEM_NUT) > CUR_CAPACITY(UPG_NUTS)) { + AMMO(ITEM_NUT) = CUR_CAPACITY(UPG_NUTS); + } + } + item = ITEM_NUT; + + } else if (item == ITEM_POWDER_KEG) { + if (INV_CONTENT(ITEM_POWDER_KEG) != ITEM_POWDER_KEG) { + INV_CONTENT(ITEM_POWDER_KEG) = ITEM_POWDER_KEG; + } + + AMMO(ITEM_POWDER_KEG) = 1; + return ITEM_NONE; + + } else if (item == ITEM_BOMB) { + if ((AMMO(ITEM_BOMB) += 1) > CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); + } + return ITEM_NONE; + + } else if ((item >= ITEM_BOMBS_5) && (item <= ITEM_BOMBS_30)) { + if (gSaveContext.save.inventory.items[SLOT_BOMB] != ITEM_BOMB) { + INV_CONTENT(ITEM_BOMB) = ITEM_BOMB; + AMMO(ITEM_BOMB) += sAmmoRefillCounts[item - ITEM_BOMBS_5]; + return ITEM_NONE; + } + + if ((AMMO(ITEM_BOMB) += sAmmoRefillCounts[item - ITEM_BOMBS_5]) > CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); + } + return ITEM_NONE; + + } else if (item == ITEM_BOMBCHU) { + if (INV_CONTENT(ITEM_BOMBCHU) != ITEM_BOMBCHU) { + INV_CONTENT(ITEM_BOMBCHU) = ITEM_BOMBCHU; + AMMO(ITEM_BOMBCHU) = 10; + return ITEM_NONE; + } + if ((AMMO(ITEM_BOMBCHU) += 10) > CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMBCHU) = CUR_CAPACITY(UPG_BOMB_BAG); + } + return ITEM_NONE; + + } else if ((item >= ITEM_BOMBCHUS_20) && (item <= ITEM_BOMBCHUS_5)) { + if (gSaveContext.save.inventory.items[SLOT_BOMBCHU] != ITEM_BOMBCHU) { + INV_CONTENT(ITEM_BOMBCHU) = ITEM_BOMBCHU; + AMMO(ITEM_BOMBCHU) += sBombchuRefillCounts[item - ITEM_BOMBCHUS_20]; + + if (AMMO(ITEM_BOMBCHU) > CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMBCHU) = CUR_CAPACITY(UPG_BOMB_BAG); + } + return ITEM_NONE; + } + + if ((AMMO(ITEM_BOMBCHU) += sBombchuRefillCounts[item - ITEM_BOMBCHUS_20]) > CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMBCHU) = CUR_CAPACITY(UPG_BOMB_BAG); + } + return ITEM_NONE; + + } else if ((item >= ITEM_ARROWS_10) && (item <= ITEM_ARROWS_50)) { + AMMO(ITEM_BOW) += sArrowRefillCounts[item - ITEM_ARROWS_10]; + + if ((AMMO(ITEM_BOW) >= CUR_CAPACITY(UPG_QUIVER)) || (AMMO(ITEM_BOW) < 0)) { + AMMO(ITEM_BOW) = CUR_CAPACITY(UPG_QUIVER); + } + return ITEM_BOW; + + } else if (item == ITEM_OCARINA) { + INV_CONTENT(ITEM_OCARINA) = ITEM_OCARINA; + return ITEM_NONE; + + } else if (item == ITEM_MAGIC_BEANS) { + if (INV_CONTENT(ITEM_MAGIC_BEANS) == ITEM_NONE) { + INV_CONTENT(item) = item; + AMMO(ITEM_MAGIC_BEANS) = 1; + } else if (AMMO(ITEM_MAGIC_BEANS) < 20) { + AMMO(ITEM_MAGIC_BEANS)++; + } else { + AMMO(ITEM_MAGIC_BEANS) = 20; + } + return ITEM_NONE; + + } else if ((item >= ITEM_REMAINS_ODOLWA) && (item <= ITEM_REMAINS_TWINMOLD)) { + SET_QUEST_ITEM(item - ITEM_REMAINS_ODOLWA + QUEST_REMAINS_ODOWLA); + return ITEM_NONE; + + } else if (item == ITEM_HEART) { + Health_ChangeBy(play, 0x10); + return item; + + } else if (item == ITEM_MAGIC_SMALL) { + Parameter_AddMagic(play, 0x18); + if (!(gSaveContext.save.weekEventReg[12] & 0x80)) { + gSaveContext.save.weekEventReg[12] |= 0x80; + return ITEM_NONE; + } + return item; + + } else if (item == ITEM_MAGIC_LARGE) { + Parameter_AddMagic(play, 0x30); + if (!(gSaveContext.save.weekEventReg[12] & 0x80)) { + gSaveContext.save.weekEventReg[12] |= 0x80; + return ITEM_NONE; + } + return item; + + } else if ((item >= ITEM_RUPEE_GREEN) && (item <= ITEM_RUPEE_HUGE)) { + Rupees_ChangeBy(sRupeeRefillCounts[item - ITEM_RUPEE_GREEN]); + return ITEM_NONE; + + } else if (item == ITEM_LONGSHOT) { + slot = SLOT(item); + + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[slot + i] = ITEM_POTION_RED; + return ITEM_NONE; + } + } + return item; + + } else if ((item == ITEM_MILK_BOTTLE) || (item == ITEM_POE) || (item == ITEM_GOLD_DUST) || (item == ITEM_CHATEAU) || + (item == ITEM_HYLIAN_LOACH)) { + slot = SLOT(item); + + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[slot + i] = item; + return ITEM_NONE; + } + } + return item; + + } else if (item == ITEM_BOTTLE) { + slot = SLOT(item); + + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[slot + i] = item; + return ITEM_NONE; + } + } + return item; + + } else if (((item >= ITEM_POTION_RED) && (item <= ITEM_OBABA_DRINK)) || (item == ITEM_CHATEAU_2) || + (item == ITEM_MILK) || (item == ITEM_GOLD_DUST_2) || (item == ITEM_HYLIAN_LOACH_2) || + (item == ITEM_SEA_HORSE_CAUGHT)) { + slot = SLOT(item); + + if ((item != ITEM_MILK_BOTTLE) && (item != ITEM_MILK_HALF)) { + if (item == ITEM_CHATEAU_2) { + item = ITEM_CHATEAU; + + } else if (item == ITEM_MILK) { + item = ITEM_MILK_BOTTLE; + + } else if (item == ITEM_GOLD_DUST_2) { + item = ITEM_GOLD_DUST; + + } else if (item == ITEM_HYLIAN_LOACH_2) { + item = ITEM_HYLIAN_LOACH; + + } else if (item == ITEM_SEA_HORSE_CAUGHT) { + item = ITEM_SEA_HORSE; + } + slot = SLOT(item); + + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[slot + i] == ITEM_BOTTLE) { + if (item == ITEM_HOT_SPRING_WATER) { + func_8010EBA0(60, i); + } + + if ((slot + i) == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = item; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_LEFT); + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_ENABLED; + } else if ((slot + i) == C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = item; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_DOWN); + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_ENABLED; + } else if ((slot + i) == C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = item; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_RIGHT); + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_ENABLED; + } + + gSaveContext.save.inventory.items[slot + i] = item; + return ITEM_NONE; + } + } + } else { + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[slot + i] = item; + return ITEM_NONE; + } + } + } + + } else if ((item >= ITEM_MOON_TEAR) && (item <= ITEM_MASK_GIANT)) { + temp = INV_CONTENT(item); + INV_CONTENT(item) = item; + if ((item >= ITEM_MOON_TEAR) && (item <= ITEM_PENDANT_MEMORIES) && (temp != ITEM_NONE)) { + for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { + if (temp == GET_CUR_FORM_BTN_ITEM(i)) { + SET_CUR_FORM_BTN_ITEM(i, item); + Interface_LoadItemIconImpl(play, i); + return ITEM_NONE; + } + } + } + return ITEM_NONE; + } + + temp = gSaveContext.save.inventory.items[slot]; + INV_CONTENT(item) = item; + return temp; +} + +u8 Item_CheckObtainabilityImpl(u8 item) { + s16 i; + u8 slot; + u8 bottleSlot; + + slot = SLOT(item); + if (item >= ITEM_STICKS_5) { + slot = SLOT(sExtraItemBases[item - ITEM_STICKS_5]); + } + + if (item == ITEM_SKULL_TOKEN) { + return ITEM_NONE; + + } else if (item == ITEM_TINGLE_MAP) { + return ITEM_NONE; + + } else if (item == ITEM_BOMBERS_NOTEBOOK) { + return ITEM_NONE; + + } else if ((item >= ITEM_SWORD_KOKIRI) && (item <= ITEM_SWORD_GILDED)) { + return ITEM_NONE; + + } else if ((item >= ITEM_SHIELD_HERO) && (item <= ITEM_SHIELD_MIRROR)) { + return ITEM_NONE; + + } else if ((item == ITEM_KEY_BOSS) || (item == ITEM_COMPASS) || (item == ITEM_DUNGEON_MAP)) { + if (!CHECK_DUNGEON_ITEM(item - ITEM_KEY_BOSS, gSaveContext.mapIndex)) { + return ITEM_NONE; + } + return item; + + } else if (item == ITEM_KEY_SMALL) { + return ITEM_NONE; + + } else if ((item == ITEM_OCARINA) || (item == ITEM_BOMBCHU) || (item == ITEM_HOOKSHOT) || (item == ITEM_LENS) || + (item == ITEM_SWORD_GREAT_FAIRY) || (item == ITEM_PICTO_BOX)) { + if (INV_CONTENT(item) == ITEM_NONE) { + return ITEM_NONE; + } + return INV_CONTENT(item); + + } else if ((item >= ITEM_BOMBS_5) && (item == ITEM_BOMBS_30)) { + //! @bug: Should be a range check: (item <= ITEM_BOMBS_30) + if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { + return ITEM_NONE; + } + return 0; + + } else if ((item >= ITEM_BOMBCHUS_20) && (item <= ITEM_BOMBCHUS_5)) { + if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { + return ITEM_NONE; + } + return 0; + + } else if ((item == ITEM_QUIVER_30) || (item == ITEM_BOW)) { + if (CUR_UPG_VALUE(UPG_QUIVER) == 0) { + return ITEM_NONE; + } + return 0; + + } else if ((item == ITEM_QUIVER_40) || (item == ITEM_QUIVER_50)) { + return ITEM_NONE; + + } else if ((item == ITEM_BOMB_BAG_20) || (item == ITEM_BOMB)) { + if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { + return ITEM_NONE; + } + return 0; + + } else if ((item >= ITEM_STICK_UPGRADE_20) && (item <= ITEM_NUT_UPGRADE_40)) { + return ITEM_NONE; + + } else if ((item >= ITEM_BOMB_BAG_30) && (item <= ITEM_WALLET_GIANT)) { + return ITEM_NONE; + + } else if (item == ITEM_MAGIC_BEANS) { + return ITEM_NONE; + + } else if (item == ITEM_POWDER_KEG) { + return ITEM_NONE; + + } else if ((item == ITEM_HEART_PIECE_2) || (item == ITEM_HEART_PIECE)) { + return ITEM_NONE; + + } else if (item == ITEM_HEART_CONTAINER) { + return ITEM_NONE; + + } else if (item == ITEM_HEART) { + return ITEM_HEART; + + } else if ((item == ITEM_MAGIC_SMALL) || (item == ITEM_MAGIC_LARGE)) { + if (!(gSaveContext.save.weekEventReg[12] & 0x80)) { + return ITEM_NONE; + } + return item; + + } else if ((item >= ITEM_RUPEE_GREEN) && (item <= ITEM_RUPEE_HUGE)) { + return ITEM_NONE; + + } else if ((item >= ITEM_REMAINS_ODOLWA) && (item <= ITEM_REMAINS_TWINMOLD)) { + return ITEM_NONE; + + } else if (item == ITEM_LONGSHOT) { + return ITEM_NONE; + + } else if (item == ITEM_BOTTLE) { + return ITEM_NONE; + + } else if ((item == ITEM_MILK_BOTTLE) || (item == ITEM_POE) || (item == ITEM_GOLD_DUST) || (item == ITEM_CHATEAU) || + (item == ITEM_HYLIAN_LOACH)) { + return ITEM_NONE; + + } else if (((item >= ITEM_POTION_RED) && (item <= ITEM_OBABA_DRINK)) || (item == ITEM_CHATEAU_2) || + (item == ITEM_MILK) || (item == ITEM_GOLD_DUST_2) || (item == ITEM_HYLIAN_LOACH_2) || + (item == ITEM_SEA_HORSE_CAUGHT)) { + bottleSlot = SLOT(item); + + if ((item != ITEM_MILK_BOTTLE) && (item != ITEM_MILK_HALF)) { + if (item == ITEM_CHATEAU_2) { + item = ITEM_CHATEAU; + + } else if (item == ITEM_MILK) { + item = ITEM_MILK_BOTTLE; + + } else if (item == ITEM_GOLD_DUST_2) { + item = ITEM_GOLD_DUST; + + } else if (item == ITEM_HYLIAN_LOACH_2) { + item = ITEM_HYLIAN_LOACH; + + } else if (item == ITEM_SEA_HORSE_CAUGHT) { + item = ITEM_SEA_HORSE; + } + bottleSlot = SLOT(item); + + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[bottleSlot + i] == ITEM_BOTTLE) { + return ITEM_NONE; + } + } + } else { + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[bottleSlot + i] == ITEM_NONE) { + return ITEM_NONE; + } + } + } + } else if ((item >= ITEM_MOON_TEAR) && (item <= ITEM_MASK_GIANT)) { + return ITEM_NONE; + } + + return gSaveContext.save.inventory.items[slot]; +} + +u8 Item_CheckObtainability(u8 item) { + return Item_CheckObtainabilityImpl(item); +} + +void Inventory_DeleteItem(s16 item, s16 slot) { + s16 btn; + + gSaveContext.save.inventory.items[slot] = ITEM_NONE; + + for (btn = EQUIP_SLOT_C_LEFT; btn <= EQUIP_SLOT_C_RIGHT; btn++) { + if (GET_CUR_FORM_BTN_ITEM(btn) == item) { + SET_CUR_FORM_BTN_ITEM(btn, ITEM_NONE); + SET_CUR_FORM_BTN_SLOT(btn, SLOT_NONE); + } + } +} + +void Inventory_UnequipItem(s16 item) { + s16 btn; + + for (btn = EQUIP_SLOT_C_LEFT; btn <= EQUIP_SLOT_C_RIGHT; btn++) { + if (GET_CUR_FORM_BTN_ITEM(btn) == item) { + SET_CUR_FORM_BTN_ITEM(btn, ITEM_NONE); + SET_CUR_FORM_BTN_SLOT(btn, SLOT_NONE); + } + } +} + +s32 Inventory_ReplaceItem(PlayState* play, u8 oldItem, u8 newItem) { + u8 i; + + for (i = 0; i < 24; i++) { + if (gSaveContext.save.inventory.items[i] == oldItem) { + gSaveContext.save.inventory.items[i] = newItem; + + for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { + if (GET_CUR_FORM_BTN_ITEM(i) == oldItem) { + SET_CUR_FORM_BTN_ITEM(i, newItem); + Interface_LoadItemIconImpl(play, i); + break; + } + } + return true; + } + } + return false; +} + +void Inventory_UpdateDeitySwordEquip(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + u8 btn; + + if (CUR_FORM == PLAYER_FORM_FIERCE_DEITY) { + interfaceCtx->unk_21C = 0; + interfaceCtx->bButtonDoAction = 0; + + // Is simply checking if (gSaveContext.save.playerForm == PLAYER_FORM_FIERCE_DEITY) + if ((((gSaveContext.save.playerForm > 0) && (gSaveContext.save.playerForm < 4)) + ? 1 + : gSaveContext.save.playerForm >> 1) == 0) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_DEITY; + } else if (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_SWORD_DEITY) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_NONE) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_NONE; + } else { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) - EQUIP_VALUE_SWORD_KOKIRI + ITEM_SWORD_KOKIRI; + } + } + } + + for (btn = EQUIP_SLOT_B; btn <= EQUIP_SLOT_B; btn++) { + if ((GET_CUR_FORM_BTN_ITEM(btn) != ITEM_NONE) && (GET_CUR_FORM_BTN_ITEM(btn) != ITEM_FD)) { + Interface_LoadItemIconImpl(play, btn); + } + } +} + +s32 Inventory_HasEmptyBottle(void) { + s32 slot; + + for (slot = SLOT_BOTTLE_1; slot <= SLOT_BOTTLE_6; slot++) { + if (gSaveContext.save.inventory.items[slot] == ITEM_BOTTLE) { + return true; + } + } + return false; +} + +s32 Inventory_HasItemInBottle(u8 item) { + s32 slot; + + for (slot = SLOT_BOTTLE_1; slot <= SLOT_BOTTLE_6; slot++) { + if (gSaveContext.save.inventory.items[slot] == item) { + return true; + } + } + return false; +} + +void Inventory_UpdateBottleItem(PlayState* play, u8 item, u8 btn) { + gSaveContext.save.inventory.items[GET_CUR_FORM_BTN_SLOT(btn)] = item; + SET_CUR_FORM_BTN_ITEM(btn, item); + + Interface_LoadItemIconImpl(play, btn); + + play->pauseCtx.cursorItem[PAUSE_0] = item; + gSaveContext.buttonStatus[btn] = BTN_ENABLED; + + if (item == ITEM_HOT_SPRING_WATER) { + func_8010EBA0(60, GET_CUR_FORM_BTN_SLOT(btn) - SLOT_BOTTLE_1); + } +} + +s32 Inventory_ConsumeFairy(PlayState* play) { + u8 bottleSlot = SLOT(ITEM_FAIRY); + u8 btn; + u8 i; + + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[bottleSlot + i] == ITEM_FAIRY) { + for (btn = EQUIP_SLOT_C_LEFT; btn <= EQUIP_SLOT_C_RIGHT; btn++) { + if (GET_CUR_FORM_BTN_ITEM(btn) == ITEM_FAIRY) { + SET_CUR_FORM_BTN_ITEM(btn, ITEM_BOTTLE); + Interface_LoadItemIconImpl(play, btn); + bottleSlot = GET_CUR_FORM_BTN_SLOT(btn); + i = 0; + break; + } + } + gSaveContext.save.inventory.items[bottleSlot + i] = ITEM_BOTTLE; + return true; + } + } + + return false; +} + +/** + * Only used to equip Spring Water when Hot Spring Water timer runs out. + */ +void Inventory_UpdateItem(PlayState* play, s16 slot, s16 item) { + s16 btn; + + gSaveContext.save.inventory.items[slot] = item; + + for (btn = EQUIP_SLOT_C_LEFT; btn <= EQUIP_SLOT_C_RIGHT; btn++) { + if (GET_CUR_FORM_BTN_SLOT(btn) == slot) { + SET_CUR_FORM_BTN_ITEM(btn, item); + Interface_LoadItemIconImpl(play, btn); + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801153C8.s") +TexturePtr sDoActionTextures[] = { + gDoActionAttackENGTex, + gDoActionCheckENGTex, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115428.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011552C.s") @@ -94,13 +1054,96 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115844.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115908.s") +/** + * @return false if player is out of health + */ +s32 Health_ChangeBy(PlayState* play, s16 healthChange) { + if (healthChange > 0) { + play_sound(NA_SE_SY_HP_RECOVER); + } else if (gSaveContext.save.playerData.doubleDefense && (healthChange < 0)) { + healthChange >>= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801159c0.s") + gSaveContext.save.playerData.health += healthChange; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801159EC.s") + if (((void)0, gSaveContext.save.playerData.health) > ((void)0, gSaveContext.save.playerData.healthCapacity)) { + gSaveContext.save.playerData.health = gSaveContext.save.playerData.healthCapacity; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115A14.s") + if (gSaveContext.save.playerData.health <= 0) { + gSaveContext.save.playerData.health = 0; + return false; + } else { + return true; + } +} + +void Health_GiveHearts(s16 hearts) { + gSaveContext.save.playerData.healthCapacity += hearts * 0x10; +} + +void Rupees_ChangeBy(s16 rupeeChange) { + gSaveContext.rupeeAccumulator += rupeeChange; +} + +void Inventory_ChangeAmmo(s16 item, s16 ammoChange) { + if (item == ITEM_STICK) { + AMMO(ITEM_STICK) += ammoChange; + + if (AMMO(ITEM_STICK) >= CUR_CAPACITY(UPG_STICKS)) { + AMMO(ITEM_STICK) = CUR_CAPACITY(UPG_STICKS); + } else if (AMMO(ITEM_STICK) < 0) { + AMMO(ITEM_STICK) = 0; + } + + } else if (item == ITEM_NUT) { + AMMO(ITEM_NUT) += ammoChange; + + if (AMMO(ITEM_NUT) >= CUR_CAPACITY(UPG_NUTS)) { + AMMO(ITEM_NUT) = CUR_CAPACITY(UPG_NUTS); + } else if (AMMO(ITEM_NUT) < 0) { + AMMO(ITEM_NUT) = 0; + } + + } else if (item == ITEM_BOMBCHU) { + AMMO(ITEM_BOMBCHU) += ammoChange; + + if (AMMO(ITEM_BOMBCHU) >= CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMBCHU) = CUR_CAPACITY(UPG_BOMB_BAG); + } else if (AMMO(ITEM_BOMBCHU) < 0) { + AMMO(ITEM_BOMBCHU) = 0; + } + + } else if (item == ITEM_BOW) { + AMMO(ITEM_BOW) += ammoChange; + + if (AMMO(ITEM_BOW) >= CUR_CAPACITY(UPG_QUIVER)) { + AMMO(ITEM_BOW) = CUR_CAPACITY(UPG_QUIVER); + } else if (AMMO(ITEM_BOW) < 0) { + AMMO(ITEM_BOW) = 0; + } + + } else if (item == ITEM_BOMB) { + AMMO(ITEM_BOMB) += ammoChange; + + if (AMMO(ITEM_BOMB) >= CUR_CAPACITY(UPG_BOMB_BAG)) { + AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); + } else if (AMMO(ITEM_BOMB) < 0) { + AMMO(ITEM_BOMB) = 0; + } + + } else if (item == ITEM_MAGIC_BEANS) { + AMMO(ITEM_MAGIC_BEANS) += ammoChange; + + } else if (item == ITEM_POWDER_KEG) { + AMMO(ITEM_POWDER_KEG) += ammoChange; + if (AMMO(ITEM_POWDER_KEG) >= 1) { + AMMO(ITEM_POWDER_KEG) = 1; + } else if (AMMO(ITEM_POWDER_KEG) < 0) { + AMMO(ITEM_POWDER_KEG) = 0; + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Parameter_AddMagic.s") @@ -110,6 +1153,13 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116088.s") +s16 magicBorderColors[][3] = { + { 255, 255, 255 }, + { 150, 150, 150 }, +}; +s16 magicBorderIndices[] = { 0, 1, 1, 0 }; +s16 magicBorderColorTimerIndex[] = { 2, 1, 2, 1 }; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116114.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116348.s") @@ -120,10 +1170,25 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801170B8.s") +TexturePtr cUpLabelTextures[] = { + gTatlCUpENGTex, gTatlCUpENGTex, gTatlCUpGERTex, gTatlCUpFRATex, gTatlCUpESPTex, +}; +s16 startButtonLeftPos[] = { + // Remnant of OoT + 130, 136, 136, 136, 136, +}; +s16 D_801BFAF4[] = { 0x1D, 0x1B }; +s16 D_801BFAF8[] = { 0x1B, 0x1B }; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80117100.s") +s16 D_801BFAFC[] = { 30, 24, 24, 24 }; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80117A20.s") +s16 D_801BFB04[] = { 0xA2, 0xE4, 0xFA, 0x110 }; +s16 D_801BFB0C[] = { 0x23, 0x23, 0x33, 0x23 }; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80117BD0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80118084.s") @@ -132,36 +1197,179 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80118BA4.s") +extern TexturePtr D_08095AC0; // gMagicArrowEquipEffectTex +s16 D_801BFB14[] = { 255, 100, 255, 0 }; // magicArrowEffectsR +s16 D_801BFB1C[] = { 0, 100, 255, 0 }; // magicArrowEffectsG +s16 D_801BFB24[] = { 0, 255, 100, 0 }; // magicArrowEffectsB + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80119030.s") +s16 D_801BFB2C = 255; +s16 D_801BFB30 = 0; +s16 D_801BFB34 = 0; +u16 D_801BFB38[] = { + CLOCK_TIME(0, 0), CLOCK_TIME(1, 0), CLOCK_TIME(2, 0), CLOCK_TIME(3, 0), CLOCK_TIME(4, 0), + CLOCK_TIME(5, 0), CLOCK_TIME(6, 0), CLOCK_TIME(7, 0), CLOCK_TIME(8, 0), CLOCK_TIME(9, 0), + CLOCK_TIME(10, 0), CLOCK_TIME(11, 0), CLOCK_TIME(12, 0), CLOCK_TIME(13, 0), CLOCK_TIME(14, 0), + CLOCK_TIME(15, 0), CLOCK_TIME(16, 0), CLOCK_TIME(17, 0), CLOCK_TIME(18, 0), CLOCK_TIME(19, 0), + CLOCK_TIME(20, 0), CLOCK_TIME(21, 0), CLOCK_TIME(22, 0), CLOCK_TIME(23, 0), CLOCK_TIME(24, 0) - 1, +}; +TexturePtr D_801BFB6C[] = { + gThreeDayClockHour12Tex, gThreeDayClockHour1Tex, gThreeDayClockHour2Tex, gThreeDayClockHour3Tex, + gThreeDayClockHour4Tex, gThreeDayClockHour5Tex, gThreeDayClockHour6Tex, gThreeDayClockHour7Tex, + gThreeDayClockHour8Tex, gThreeDayClockHour9Tex, gThreeDayClockHour10Tex, gThreeDayClockHour11Tex, + gThreeDayClockHour12Tex, gThreeDayClockHour1Tex, gThreeDayClockHour2Tex, gThreeDayClockHour3Tex, + gThreeDayClockHour4Tex, gThreeDayClockHour5Tex, gThreeDayClockHour6Tex, gThreeDayClockHour7Tex, + gThreeDayClockHour8Tex, gThreeDayClockHour9Tex, gThreeDayClockHour10Tex, gThreeDayClockHour11Tex, +}; +s16 D_801BFBCC = 0; // color R +s16 D_801BFBD0 = 155; // color G +s16 D_801BFBD4 = 255; +s16 D_801BFBD8 = 0; +s16 D_801BFBDC = 0; +s16 D_801BFBE0 = 0; +s16 D_801BFBE4 = 0xF; +u32 D_801BFBE8 = 0; +s16 D_801BFBEC[] = { 100, 0 }; +s16 D_801BFBF0[] = { 205, 155 }; +s16 D_801BFBF4[] = { 255, 255 }; +s16 D_801BFBF8[] = { 30, 0 }; +s16 D_801BFBFC[] = { 30, 0 }; +s16 D_801BFC00[] = { 100, 0 }; +s16 D_801BFC04[] = { 255, 0 }; +s16 D_801BFC08[] = { 100, 0 }; +s16 D_801BFC0C[] = { 30, 0 }; +s16 D_801BFC10[] = { 100, 0 }; +TexturePtr D_801BFC14[] = { + gFinalHoursClockDigit0Tex, gFinalHoursClockDigit1Tex, gFinalHoursClockDigit2Tex, gFinalHoursClockDigit3Tex, + gFinalHoursClockDigit4Tex, gFinalHoursClockDigit5Tex, gFinalHoursClockDigit6Tex, gFinalHoursClockDigit7Tex, + gFinalHoursClockDigit8Tex, gFinalHoursClockDigit9Tex, gFinalHoursClockColonTex, +}; +s16 D_801BFC40[] = { + 127, 136, 144, 151, 160, 168, 175, 184, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80119610.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011B4E0.s") +u16 D_801BFC50[] = { + 0xC000, 0xE000, 0x0000, 0x2000, 0xA000, 0x8000, 0x6000, 0x4000, +}; +s16 D_801BFC60[][3] = { + 255, 255, 255, 255, 165, 55, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011B5C0.s") +s16 D_801BFC6C[] = { + 78, 54, 29, 5, -18, -42, -67, -85, +}; +s16 D_801BFC7C[] = { + 180, 180, 180, 180, -180, -180, -180, -180, +}; +s16 D_801BFC8C[2][3] = { + { 255, 255, 255 }, + { 255, 165, 55 }, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011B9E0.s") +s16 D_801BFC98[] = { + 78, 54, 29, 5, -18, -42, -67, -85, +}; +u16 D_801BFCA8[] = { + 0xC000, 0xE000, 0x0000, 0x2000, 0xA000, 0x8000, 0x6000, 0x4000, +}; +s16 D_801BFCB8[2][3] = { + { 255, 255, 255 }, + { 255, 165, 55 }, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011BF70.s") +TexturePtr D_801BFCC4[] = { + gMinigameLetterPTex, gMinigameLetterETex, gMinigameLetterRTex, gMinigameLetterFTex, + gMinigameLetterETex, gMinigameLetterCTex, gMinigameLetterTTex, gMinigameExclamationTex, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011C4C4.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011C808.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011C898.s") +s16 D_801BFCE4 = 0; +s16 D_801BFCE8[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +s16 D_801BFCF8 = 99; +s16 D_801BFCFC[] = { + // timer digit width + 16, 25, 34, 42, 51, 60, 68, 77, +}; +s16 D_801BFD0C[] = { + // digit width + 9, 9, 8, 9, 9, 8, 9, 9, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011CA64.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011E3B4.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011E730.s") +// rupeeDigitsFirst +s16 D_801BFD1C[] = { 1, 0, 0, 0 }; +// rupeeDigitsCount +s16 D_801BFD24[] = { 2, 3, 3, 0 }; +// rupeeIconPrimColor +Color_RGB16 D_801BFD2C[] = { + { 200, 255, 100 }, + { 170, 170, 255 }, + { 255, 105, 105 }, +}; +// rupeeIconEnvColor +Color_RGB16 D_801BFD40[] = { + { 0, 80, 0 }, + { 10, 10, 80 }, + { 40, 10, 0 }, +}; +// minigameCountdownTexs +TexturePtr D_801BFD54[] = { + gMinigameCountdown3Tex, + gMinigameCountdown2Tex, + gMinigameCountdown1Tex, + gMinigameCountdownGoTex, +}; +// minigameCountdownTexHeights +s16 D_801BFD64[] = { 24, 24, 24, 40 }; +// minigameCountdownPrimColor +Color_RGB16 D_801BFD6C[] = { + { 100, 255, 100 }, + { 255, 255, 60 }, + { 255, 100, 0 }, + { 120, 170, 255 }, +}; +// grandma's story pictures +TexturePtr D_801BFD84[] = { + gStoryMaskFestivalTex, + gStoryGiantsLeavingTex, +}; +// grandma's story TLUT +TexturePtr D_801BFD8C[] = { + gStoryMaskFestivalTLUT, + gStoryGiantsLeavingTLUT, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011F0E0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80120F90.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80121064.s") +u8 D_801BFD94 = 0; +s16 D_801BFD98 = 0; +s16 D_801BFD9C = 0; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801210E0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80121F94.s") diff --git a/src/code/z_play.c b/src/code/z_play.c index e9f5803d2..49ed31bf4 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -59,7 +59,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Update.s") s32 Play_InCsMode(PlayState* this) { - return (this->csCtx.state != 0) || Player_InCsMode(&this->state); + return (this->csCtx.state != 0) || Player_InCsMode(this); } #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169100.s") @@ -209,14 +209,14 @@ void func_80169ECC(PlayState* this) { void func_80169EFC(GameState* thisx) { PlayState* this = (PlayState*)thisx; - gSaveContext.respawn[RESTART_MODE_DOWN].tempSwitchFlags = this->actorCtx.flags.switches[2]; - gSaveContext.respawn[RESTART_MODE_DOWN].unk_18 = this->actorCtx.flags.collectible[1]; - gSaveContext.respawn[RESTART_MODE_DOWN].tempCollectFlags = this->actorCtx.flags.collectible[2]; - this->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex; + gSaveContext.respawn[RESPAWN_MODE_DOWN].tempSwitchFlags = this->actorCtx.flags.switches[2]; + gSaveContext.respawn[RESPAWN_MODE_DOWN].unk_18 = this->actorCtx.flags.collectible[1]; + gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags = this->actorCtx.flags.collectible[2]; + this->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex; gSaveContext.respawnFlag = 1; func_80169ECC(this); - this->sceneLoadFlag = 0x14; - this->unk_1887F = 2; + this->transitionTrigger = TRANS_TRIGGER_START; + this->transitionType = TRANS_TYPE_02; } // Gameplay_LoadToLastEntrance ? @@ -224,11 +224,11 @@ void func_80169EFC(GameState* thisx) { void func_80169F78(GameState* thisx) { PlayState* this = (PlayState*)thisx; - this->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_TOP].entranceIndex; + this->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_TOP].entranceIndex; gSaveContext.respawnFlag = -1; func_80169ECC(this); - this->sceneLoadFlag = 0x14; - this->unk_1887F = 2; + this->transitionTrigger = TRANS_TRIGGER_START; + this->transitionType = TRANS_TYPE_02; } // Gameplay_TriggerRespawn ? diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index cb3d14e8b..98a237b10 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1,130 +1,924 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801226E0.s") +#include "objects/object_link_goron/object_link_goron.h" +#include "objects/object_link_zora/object_link_zora.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122744.s") +#include "objects/object_mask_meoto/object_mask_meoto.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122760.s") +void PlayerCall_Init(Actor* thisx, PlayState* play); +void PlayerCall_Destroy(Actor* thisx, PlayState* play); +void PlayerCall_Update(Actor* thisx, PlayState* play); +void PlayerCall_Draw(Actor* thisx, PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122868.s") +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ s16 unk_18; + /* 0x1A */ s16 unk_1A; +} struct_801F58B0; // size = 0x1C -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801229A0.s") +extern struct_801F58B0 D_801F58B0[3][3]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801229EC.s") +extern s32 D_801F59C8[2]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801229FC.s") +extern s32 D_801F59E0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122BA4.s") +extern Vec3f D_801F59E8; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122C20.s") +void func_80127B64(struct_801F58B0 arg0[], UNK_TYPE arg1, Vec3f* arg2); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122D44.s") +s32 func_801226E0(PlayState* play, s32 arg1) { + if (arg1 == 0) { + Play_SetupRespawnPoint(&play->state, RESPAWN_MODE_DOWN, 0xBFF); + if (play->sceneNum == SCENE_KAKUSIANA) { + return 1; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122ED8.s") + gSaveContext.respawn[RESPAWN_MODE_DOWN].data = 0; + return arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122EEC.s") +s32 func_80122744(PlayState* play, struct_80122744_arg1* arg1, u32 arg2, Vec3s* arg3) { + arg1->unk_00 = arg2; + arg1->unk_01 = 0; + arg1->unk_04 = arg3; + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122F28.s") +s32 func_80122760(PlayState* play, struct_80122744_arg1* arg1, f32 arg2) { + if (arg1->unk_01 < arg1->unk_00) { + Player* player = GET_PLAYER(play); + Vec3f sp30; + s32 pad; + s16 yaw; + f32 distXZ; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122F9C.s") + Math_Vec3s_ToVec3f(&sp30, &arg1->unk_04[arg1->unk_01]); + yaw = Math_Vec3f_Yaw(&player->actor.world.pos, &sp30); + func_800B6F20(play, &play->actorCtx.unk_26C, arg2, yaw); + play->actorCtx.unk268 = 1; + distXZ = Math_Vec3f_DistXZ(&player->actor.world.pos, &sp30); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122FCC.s") + if ((fabsf(player->actor.world.pos.y - sp30.y) < 50.0f) && (distXZ < arg2)) { + arg1->unk_01++; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012300C.s") + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012301C.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123140.s") +void func_80122868(PlayState* play, Player* player) { + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123358.s") + if (player->invincibilityTimer > 0) { + s32 phi_v0 = 50 - player->invincibilityTimer; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_InCsMode.s") + phi_v0 = CLAMP(phi_v0, 8, 40); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123420.s") + player->unk_B5F += phi_v0; + POLY_OPA_DISP = + Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 0, 0, 4000 - (s32)(Math_CosS(player->unk_B5F << 8) * 2000.0f)); + } else if (gSaveContext.jinxTimer != 0) { + player->unk_B5F += 10; + POLY_OPA_DISP = + Gfx_SetFog(POLY_OPA_DISP, 0, 0, 255, 0, 0, 4000 - (s32)(Math_CosS(player->unk_B5F << 8) * 2000.0f)); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123434.s") + CLOSE_DISPS(play->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123448.s") +void func_801229A0(PlayState* play, Player* player) { + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801234B0.s") + if ((gSaveContext.jinxTimer != 0) || (player->invincibilityTimer > 0)) { + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801234D4.s") + CLOSE_DISPS(play->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123590.s") +void func_801229EC(UNK_TYPE arg0, UNK_TYPE arg1) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801235DC.s") +extern s16 sMaskObjectIds[PLAYER_MASK_MAX - 1]; +#if 0 +s16 sMaskObjectIds[PLAYER_MASK_MAX - 1] = { + OBJECT_MASK_TRUTH, OBJECT_MASK_KERFAY, OBJECT_MASK_YOFUKASI, OBJECT_MASK_RABIT, OBJECT_MASK_KI_TAN, + OBJECT_MASK_JSON, OBJECT_MASK_ROMERNY, OBJECT_MASK_ZACHO, OBJECT_MASK_POSTHAT, OBJECT_MASK_MEOTO, + OBJECT_MASK_BIGELF, OBJECT_MASK_GIBUDO, OBJECT_MASK_GERO, OBJECT_MASK_DANCER, OBJECT_MASK_SKJ, + OBJECT_MASK_STONE, OBJECT_MASK_BREE, OBJECT_MASK_BAKURETU, OBJECT_MASK_BU_SAN, OBJECT_MASK_KYOJIN, + OBJECT_MASK_BOY, OBJECT_MASK_GORON, OBJECT_MASK_ZORA, OBJECT_MASK_NUTS, +}; +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012364C.s") +// Load mask object? +/** + * Notes: + * + * player->maskObjectLoadState seems to be able to take 3 possible values + * 0: The mask object is loaded. + * 1: The mask object must be changed (and the DMA request has not been sent yet) + * 2: Waiting for the DMA request to complete. + */ +void func_801229FC(Player* player) { + if (player->maskObjectLoadState == 1) { + s16 objectId = sMaskObjectIds[(u8)player->maskId - 1]; + + osCreateMesgQueue(&player->maskObjectLoadQueue, &player->maskObjectLoadMsg, 1); + DmaMgr_SendRequestImpl(&player->maskDmaRequest, player->maskObjectSegment, gObjectTable[objectId].vromStart, + gObjectTable[objectId].vromEnd - gObjectTable[objectId].vromStart, 0, + &player->maskObjectLoadQueue, NULL); + player->maskObjectLoadState++; + } else if (player->maskObjectLoadState == 2) { + if (osRecvMesg(&player->maskObjectLoadQueue, NULL, OS_MESG_NOBLOCK) == 0) { + player->maskObjectLoadState = 0; + + if (player->currentMask == PLAYER_MASK_GREAT_FAIRY) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_801F58B0); i++) { + func_80127B64(D_801F58B0[i], ARRAY_COUNT(D_801F58B0[i]), &player->bodyPartsPos[7]); + } + } + } + } else if ((player->currentMask != PLAYER_MASK_NONE) && (player->currentMask != (u8)player->maskId)) { + player->maskObjectLoadState = 1; + player->maskId = player->currentMask; + } else if (player->currentMask == PLAYER_MASK_CIRCUS_LEADER) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_801F59C8); i++) { + D_801F59C8[i] += Rand_S16Offset(4, 23) + (s32)(fabsf(player->linearVelocity) * 50.0f); + } + } +} + +void func_80122BA4(PlayState* play, struct_80122D44_arg1* arg1, s32 arg2, s32 alpha) { + if (arg2 == arg1->unk_00) { + s32 index; + + arg1->unk_01--; + if (arg1->unk_01 < 0) { + arg1->unk_01 = 3; + } + + index = arg1->unk_01; + arg1->unk_04[index].unk_00 = arg1->unk_00; + arg1->unk_04[index].alpha = alpha; + Matrix_Get(&arg1->unk_04[index].mf); + + arg1->unk_00 = 0; + } +} + +void func_80122C20(PlayState* play, struct_80122D44_arg1* arg1) { + struct_80122D44_arg1_unk_04* temp_v1 = &arg1->unk_04[0]; + s32 phi_a1; + s32 i; + + for (i = 0; i < ARRAY_COUNT(arg1->unk_04); i++, temp_v1++) { + // Can't be `temp_v1->alpha != 0` + if (temp_v1->alpha) { + phi_a1 = temp_v1->unk_00 == 3 ? (255 / 3) : (255 / 5); + if (phi_a1 >= temp_v1->alpha) { + temp_v1->alpha = 0; + } else { + temp_v1->alpha -= phi_a1; + } + } + } +} + +typedef struct { + /* 0x0 */ Color_RGB8 color; + /* 0x4 */ Gfx* dList; +} struct_801BFDD0; // size = 0x08 + +extern struct_801BFDD0 D_801BFDD0[]; +#if 0 +struct_801BFDD0 D_801BFDD0[] = { + { { 180, 200, 255 }, gLinkGoronCurledDL }, + { { 155, 0, 0 }, gLinkGoronRollingSpikesAndEffectDL }, + { { 255, 0, 0 }, gLinkGoronGoronPunchEffectDL }, +}; +#endif + +void func_80122D44(PlayState* play, struct_80122D44_arg1* arg1) { + struct_801BFDD0* temp_s3; + struct_80122D44_arg1_unk_04* phi_s2 = arg1->unk_04; + s32 phi_s6 = false; + s32 i; + + OPEN_DISPS(play->state.gfxCtx); + + for (i = 0; i != ARRAY_COUNT(arg1->unk_04); i++) { + if ((phi_s2->alpha != 0) && (phi_s2->alpha != 255)) { + temp_s3 = &D_801BFDD0[phi_s2->unk_00 - 1]; + Matrix_Put(&phi_s2->mf); + + gDPPipeSync(POLY_XLU_DISP++); + + if (!phi_s6 && phi_s2->unk_00 == 2) { + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(&object_link_goron_Matanimheader_013138)); + phi_s6 = true; + } + + Scene_SetRenderModeXlu(play, 1, 2); + gDPSetEnvColor(POLY_XLU_DISP++, temp_s3->color.r, temp_s3->color.g, temp_s3->color.b, phi_s2->alpha); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, temp_s3->dList); + } + + phi_s2++; + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +extern u8 sMaskItemIds[PLAYER_MASK_MAX - 1]; +#if 0 +u8 sMaskItemIds[PLAYER_MASK_MAX - 1] = { + ITEM_MASK_TRUTH, // PLAYER_MASK_TRUTH + ITEM_MASK_KAFEIS_MASK, // PLAYER_MASK_KAFEIS_MASK + ITEM_MASK_ALL_NIGHT, // PLAYER_MASK_ALL_NIGHT + ITEM_MASK_BUNNY, // PLAYER_MASK_BUNNY + ITEM_MASK_KEATON, // PLAYER_MASK_KEATON + ITEM_MASK_GARO, // PLAYER_MASK_GARO + ITEM_MASK_ROMANI, // PLAYER_MASK_ROMANI + ITEM_MASK_CIRCUS_LEADER, // PLAYER_MASK_CIRCUS_LEADER + ITEM_MASK_POSTMAN, // PLAYER_MASK_POSTMAN + ITEM_MASK_COUPLE, // PLAYER_MASK_COUPLE + ITEM_MASK_GREAT_FAIRY, // PLAYER_MASK_GREAT_FAIRY + ITEM_MASK_GIBDO, // PLAYER_MASK_GIBDO + ITEM_MASK_DON_GERO, // PLAYER_MASK_DON_GERO + ITEM_MASK_KAMARO, // PLAYER_MASK_KAMARO + ITEM_MASK_CAPTAIN, // PLAYER_MASK_CAPTAIN + ITEM_MASK_STONE, // PLAYER_MASK_STONE + ITEM_MASK_BREMEN, // PLAYER_MASK_BREMEN + ITEM_MASK_BLAST, // PLAYER_MASK_BLAST + ITEM_MASK_SCENTS, // PLAYER_MASK_SCENTS + ITEM_MASK_GIANT, // PLAYER_MASK_GIANT + ITEM_MASK_FIERCE_DEITY, // PLAYER_MASK_FIERCE_DEITY + ITEM_MASK_GORON, // PLAYER_MASK_GORON + ITEM_MASK_ZORA, // PLAYER_MASK_ZORA + ITEM_MASK_DEKU, // PLAYER_MASK_DEKU +}; +#endif + +u8 Player_MaskIdToItemId(s32 maskIdMinusOne) { + return sMaskItemIds[maskIdMinusOne]; +} + +u8 Player_GetCurMaskItemId(PlayState* play) { + Player* player = GET_PLAYER(play); + + if (player->currentMask != PLAYER_MASK_NONE) { + return Player_MaskIdToItemId(player->currentMask - 1); + } + + return ITEM_NONE; +} + +void func_80122F28(Player* player) { + if ((player->actor.category == ACTORCAT_PLAYER) && + (!(player->stateFlags1 & (PLAYER_STATE1_20000000 | PLAYER_STATE1_800000 | PLAYER_STATE1_200000 | + PLAYER_STATE1_800 | PLAYER_STATE1_400))) && + (!(player->stateFlags2 & PLAYER_STATE2_1))) { + if (player->doorType < 0) { + ActorCutscene_SetIntentToPlay(0x7C); + } else { + ActorCutscene_SetIntentToPlay(0x7D); + } + } +} + +s32 func_80122F9C(PlayState* play) { + Player* player = GET_PLAYER(play); + + return (player->stateFlags2 & PLAYER_STATE2_80000) && player->unk_AE7 == 2; +} + +s32 func_80122FCC(PlayState* play) { + Player* player = GET_PLAYER(play); + + return (player->stateFlags2 & PLAYER_STATE2_80000) && (player->unk_AE7 == 1 || player->unk_AE7 == 3); +} + +void func_8012300C(PlayState* play, s32 arg1) { + Player* player = GET_PLAYER(play); + + player->unk_B2B = arg1; +} + +void func_8012301C(Player* player, PlayState* play2) { + PlayState* play = play2; + s32 pad; + + player->unk_AE7++; + + if (player->unk_AE7 == 2) { + s16 objectId = gPlayerFormObjectIndices[((void)0, gSaveContext.save.playerForm)]; + + gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId = objectId; + func_8012F73C(&play->objectCtx, player->actor.objBankIndex, objectId); + player->actor.objBankIndex = Object_GetIndex(&play->objectCtx, GAMEPLAY_KEEP); + } else if (player->unk_AE7 >= 3) { + s32 objBankIndex = Object_GetIndex(&play->objectCtx, gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId); + + if (Object_IsLoaded(&play->objectCtx, objBankIndex)) { + player->actor.objBankIndex = objBankIndex; + player->actor.shape.rot.z = gSaveContext.save.playerForm + 1; + player->actor.init = PlayerCall_Init; + player->actor.update = PlayerCall_Update; + player->actor.draw = PlayerCall_Draw; + gSaveContext.save.equippedMask = PLAYER_MASK_NONE; + } + } +} + +extern s16 D_801BFE14[][18]; + +// OoT's Player_SetBootData +void func_80123140(PlayState* play, Player* player) { + s16* bootRegs; + s32 currentBoots; + f32 scale; + + if ((player->actor.id == ACTOR_PLAYER) && (player->transformation == PLAYER_FORM_FIERCE_DEITY)) { + REG(27) = 1200; + } else { + REG(27) = 2000; + } + + REG(48) = 370; + + currentBoots = player->currentBoots; + if (currentBoots >= PLAYER_BOOTS_ZORA_UNDERWATER) { + if (player->stateFlags1 & PLAYER_STATE1_8000000) { + currentBoots++; + } + if (player->transformation == PLAYER_FORM_GORON) { + REG(48) = 200; + } + } else if (currentBoots == PLAYER_BOOTS_GIANT) { + REG(48) = 170; + } + + bootRegs = D_801BFE14[currentBoots]; + REG(19) = bootRegs[0]; + REG(30) = bootRegs[1]; + REG(32) = bootRegs[2]; + REG(34) = bootRegs[3]; + REG(35) = bootRegs[4]; + REG(36) = bootRegs[5]; + REG(37) = bootRegs[6]; + REG(38) = bootRegs[7]; + REG(39) = bootRegs[8]; + REG(43) = bootRegs[9]; + R_RUN_SPEED_LIMIT = bootRegs[10]; + REG(68) = bootRegs[11]; + REG(69) = bootRegs[12]; + IREG(66) = bootRegs[13]; + IREG(67) = bootRegs[14]; + IREG(68) = bootRegs[15]; + IREG(69) = bootRegs[16]; + MREG(95) = bootRegs[17]; + + if (play->roomCtx.currRoom.unk3 == 2) { + R_RUN_SPEED_LIMIT = 500; + } + + if ((player->actor.id == ACTOR_PLAYER) && (player->transformation == PLAYER_FORM_FIERCE_DEITY)) { + scale = 0.015f; + } else { + scale = 0.01f; + } + + Actor_SetScale(&player->actor, scale); +} + +s32 Player_InBlockingCsMode(PlayState* play, Player* player) { + return (player->stateFlags1 & (PLAYER_STATE1_20000000 | PLAYER_STATE1_200 | PLAYER_STATE1_80)) || + (player->csMode != 0) || (play->transitionTrigger == TRANS_TRIGGER_START) || + (play->transitionMode != TRANS_MODE_OFF) || (player->stateFlags1 & PLAYER_STATE1_1) || + (player->stateFlags3 & PLAYER_STATE3_80) || (play->actorCtx.unk268 != 0); +} + +s32 Player_InCsMode(PlayState* play) { + Player* player = GET_PLAYER(play); + + return Player_InBlockingCsMode(play, player) || player->unk_AA5 == 5; +} + +s32 func_80123420(Player* player) { + return player->stateFlags3 & PLAYER_STATE3_80000000; +} + +s32 func_80123434(Player* player) { + return player->stateFlags1 & (PLAYER_STATE1_40000000 | PLAYER_STATE1_20000 | PLAYER_STATE1_10000); +} + +// Unused +s32 func_80123448(PlayState* play) { + Player* player = GET_PLAYER(play); + + return (player->stateFlags1 & PLAYER_STATE1_400000) && + (player->transformation != PLAYER_FORM_HUMAN || (!func_80123434(player) && player->unk_730 == NULL)); +} + +// TODO: Player_IsGoronOrDeku is a temporary name until we have more info on this function. +// Hypothesis: this function checks if the current form would crouch when he tries to use the shield +s32 Player_IsGoronOrDeku(Player* player) { + return player->transformation == PLAYER_FORM_GORON || player->transformation == PLAYER_FORM_DEKU; +} + +s32 func_801234D4(PlayState* play) { + Player* player = GET_PLAYER(play); + + return (player->stateFlags2 & PLAYER_STATE2_8) || player->actor.speedXZ != 0.0f || + ((player->transformation != PLAYER_FORM_ZORA) && (player->stateFlags1 & PLAYER_STATE1_8000000)) || + ((player->transformation == PLAYER_FORM_ZORA) && (player->stateFlags1 & PLAYER_STATE1_8000000) && + (!(player->actor.bgCheckFlags & 1) || (player->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER))); +} + +s32 func_80123590(PlayState* play, Actor* actor) { + Player* player = GET_PLAYER(play); + + if ((player->stateFlags1 & PLAYER_STATE1_800) && (player->heldActor == actor)) { + player->interactRangeActor = NULL; + player->heldActor = NULL; + player->actor.child = NULL; + player->stateFlags1 &= ~PLAYER_STATE1_800; + return true; + } + + return false; +} + +s32 func_801235DC(PlayState* play, f32 arg1, s16 arg2) { + Player* player = GET_PLAYER(play); + + if (player->stateFlags3 & PLAYER_STATE3_1000) { + player->unk_B08[0] = arg1; + player->unk_B08[1] += arg1 * 0.05f; + player->currentYaw = arg2; + player->actor.home.rot.y = arg2; + player->actor.shape.rot.y = arg2; + player->unk_B8C = 4; + player->invincibilityTimer = 20; + + return true; + } + + return false; +} + +s32 func_8012364C(PlayState* play, Player* player, s32 arg2) { + if (arg2 >= 4) { + return ITEM_NONE; + } + + if (arg2 == 0) { + s32 item = Inventory_GetBtnBItem(play); + + if (item >= ITEM_FD) { + return item; + } + + if ((player->currentMask == PLAYER_MASK_BLAST) && (play->interfaceCtx.bButtonDoAction == 0x18)) { + return ITEM_F0; + } + + if ((player->currentMask == PLAYER_MASK_BREMEN) && (play->interfaceCtx.bButtonDoAction == 0x1A)) { + return ITEM_F1; + } + + if ((player->currentMask == PLAYER_MASK_KAMARO) && (play->interfaceCtx.bButtonDoAction == 0x19)) { + return ITEM_F2; + } + + return item; + } + + if (arg2 == 1) { + return (gSaveContext.buttonStatus[1] != BTN_DISABLED) + ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_LEFT] + : (gSaveContext.unk_3F22 == 0x10) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_LEFT] + : ITEM_NONE; + } + + if (arg2 == 2) { + return (gSaveContext.buttonStatus[2] != BTN_DISABLED) + ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_DOWN] + : (gSaveContext.unk_3F22 == 0x10) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_DOWN] + : ITEM_NONE; + } + + return (gSaveContext.buttonStatus[3] != BTN_DISABLED) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_RIGHT] + : (gSaveContext.unk_3F22 == 0x10) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_RIGHT] + : ITEM_NONE; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123810.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123960.s") +extern u8 sActionModelGroups[]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801239AC.s") +s32 Player_ActionToModelGroup(Player* player, s32 actionParam) { + s32 modelGroup = sActionModelGroups[actionParam]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123AA4.s") + if ((modelGroup == 2) && Player_IsGoronOrDeku(player)) { + return 1; + } + return modelGroup; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123BD4.s") +extern u8 D_801BFF90[PLAYER_FORM_MAX]; +#if 0 +u8 D_801BFF90[PLAYER_FORM_MAX] = { + PLAYER_BOOTS_FIERCE_DEITY, // PLAYER_FORM_FIERCE_DEITY + PLAYER_BOOTS_GORON, // PLAYER_FORM_GORON + PLAYER_BOOTS_ZORA_LAND, // PLAYER_FORM_ZORA + PLAYER_BOOTS_DEKU, // PLAYER_FORM_DEKU + PLAYER_BOOTS_HYLIAN, // PLAYER_FORM_HUMAN +}; +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123C58.s") +extern u8 sPlayerStrengths[PLAYER_FORM_MAX]; +#if 0 +u8 sPlayerStrengths[PLAYER_FORM_MAX] = { + PLAYER_STRENGTH_HUMAN, // PLAYER_FORM_FIERCE_DEITY + PLAYER_STRENGTH_GORON, // PLAYER_FORM_GORON + PLAYER_STRENGTH_ZORA, // PLAYER_FORM_ZORA + PLAYER_STRENGTH_DEKU, // PLAYER_FORM_DEKU + PLAYER_STRENGTH_HUMAN, // PLAYER_FORM_HUMAN +}; +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_SetEquipmentData.s") +typedef struct { + /* 0x00 */ u8 flag; + /* 0x02 */ u16 textId; +} TextTriggerEntry; // size = 0x04 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123D50.s") +extern TextTriggerEntry sEnvironmentTextTriggers[]; +// These textIds are OoT remnants. The corresponding text entries are not present in this game, and so these don't point +// to anything relevant. +#if 0 +TextTriggerEntry sEnvironmentTextTriggers[] = { + { 1, 0x26FC }, + { 2, 0x26FD }, + { 0, 0 }, + { 2, 0x26FD }, +}; +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123DA4.s") +extern Gfx** sPlayerDListGroups[]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123DC0.s") +void func_801239AC(Player* player) { + if (player->stateFlags1 & PLAYER_STATE1_400000) { + if ((player->heldItemActionParam < 0) || (player->heldItemActionParam == player->itemActionParam)) { + if (!Player_IsHoldingTwoHandedWeapon(player)) { + if (!Player_IsGoronOrDeku(player)) { + D_801F59E0 = player->transformation * 2; + player->rightHandType = 8; + player->rightHandDLists = &sPlayerDListGroups[8][D_801F59E0]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123E90.s") + if (player->sheathType == 14) { + player->sheathType = 12; + } else if (player->sheathType == 15) { + player->sheathType = 13; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123F14.s") + player->sheathDLists = &sPlayerDListGroups[player->sheathType][D_801F59E0]; + player->modelAnimType = 2; + player->heldItemActionParam = -1; + } + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123F2C.s") +void Player_SetModels(Player* player, s32 modelGroup) { + u8* playerModelTypes; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123F48.s") + D_801F59E0 = player->transformation * 2; + player->leftHandType = gPlayerModelTypes[modelGroup][1]; + player->rightHandType = gPlayerModelTypes[modelGroup][2]; + player->sheathType = gPlayerModelTypes[modelGroup][3]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124020.s") + if (player->sheathType == 14) { + if (CUR_FORM_EQUIP(EQUIP_SLOT_B) == ITEM_NONE) { + player->sheathType = 15; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_GetMask.s") + playerModelTypes = gPlayerModelTypes[modelGroup]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_RemoveMask.s") + player->leftHandDLists = &sPlayerDListGroups[playerModelTypes[1]][D_801F59E0]; + player->rightHandDLists = &sPlayerDListGroups[playerModelTypes[2]][D_801F59E0]; + player->sheathDLists = &sPlayerDListGroups[playerModelTypes[3]][D_801F59E0]; + player->waistDLists = &sPlayerDListGroups[playerModelTypes[4]][D_801F59E0]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012405C.s") + func_801239AC(player); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124088.s") +void Player_SetModelGroup(Player* player, s32 modelGroup) { + player->modelGroup = modelGroup; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801240C8.s") + if (modelGroup == 1) { + player->modelAnimType = 0; + } else { + player->modelAnimType = gPlayerModelTypes[modelGroup][0]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801240DC.s") + if (player->modelAnimType < 3) { + if (((player->transformation != PLAYER_FORM_FIERCE_DEITY) && (player->transformation != PLAYER_FORM_HUMAN)) || + (player->currentShield == PLAYER_SHIELD_NONE)) { + player->modelAnimType = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124110.s") + Player_SetModels(player, modelGroup); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124148.s") +void func_80123C58(Player* player) { + player->heldItemActionParam = player->itemActionParam; + Player_SetModelGroup(player, Player_ActionToModelGroup(player, player->itemActionParam)); + player->unk_AA5 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124168.s") +void Player_SetEquipmentData(PlayState* play, Player* player) { + if (player->csMode != 0x86) { + player->currentShield = GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD); + if ((player->transformation != PLAYER_FORM_ZORA) || (((player->currentBoots != PLAYER_BOOTS_ZORA_LAND)) && + (player->currentBoots != PLAYER_BOOTS_ZORA_UNDERWATER))) { + player->currentBoots = D_801BFF90[player->transformation]; + } + Player_SetModelGroup(player, Player_ActionToModelGroup(player, player->itemActionParam)); + func_80123140(play, player); + if (player->unk_B62 != 0) { + player->unk_B62 = 1; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124190.s") +void func_80123D50(PlayState* play, Player* player, s32 itemId, s32 actionParam) { + Inventory_UpdateBottleItem(play, itemId, player->heldItemButton); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801241B4.s") + if (itemId != ITEM_BOTTLE) { + player->heldItemId = itemId; + player->itemActionParam = actionParam; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801241E0.s") + player->heldItemActionParam = actionParam; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012420C.s") +void func_80123DA4(Player* player) { + player->unk_730 = NULL; + player->stateFlags2 &= ~PLAYER_STATE2_2000; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012422C.s") +void func_80123DC0(Player* player) { + if ((player->actor.bgCheckFlags & 1) || + (player->stateFlags1 & (PLAYER_STATE1_8000000 | PLAYER_STATE1_800000 | PLAYER_STATE1_200000)) || + (!(player->stateFlags1 & (PLAYER_STATE1_80000 | PLAYER_STATE1_40000)) && + ((player->actor.world.pos.y - player->actor.floorHeight) < 100.0f))) { + player->stateFlags1 &= ~(PLAYER_STATE1_40000000 | PLAYER_STATE1_80000 | PLAYER_STATE1_40000 | + PLAYER_STATE1_20000 | PLAYER_STATE1_10000 | PLAYER_STATE1_8000); + } else if (!(player->stateFlags1 & (PLAYER_STATE1_200000 | PLAYER_STATE1_80000 | PLAYER_STATE1_40000))) { + player->stateFlags1 |= PLAYER_STATE1_80000; + } else if ((player->stateFlags1 & PLAYER_STATE1_40000) && (player->transformation == PLAYER_FORM_DEKU)) { + player->stateFlags1 &= + ~(PLAYER_STATE1_40000000 | PLAYER_STATE1_20000 | PLAYER_STATE1_10000 | PLAYER_STATE1_8000); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_GetExplosiveHeld.s") + func_80123DA4(player); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124278.s") +void func_80123E90(PlayState* play, Actor* actor) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801242B4.s") + func_80123DC0(player); + player->unk_730 = actor; + player->unk_A78 = actor; + player->stateFlags1 |= PLAYER_STATE1_10000; + func_800DFD78(Play_GetCamera(play, CAM_ID_MAIN), 8, actor); + Camera_ChangeMode(Play_GetCamera(play, CAM_ID_MAIN), 9); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801242DC.s") +s32 func_80123F14(PlayState* play) { + Player* player = GET_PLAYER(play); + + return player->stateFlags1 & PLAYER_STATE1_800000; +} + +s32 func_80123F2C(PlayState* play, s32 ammo) { + play->unk_1887C = ammo + 1; + + return 1; +} + +s32 Player_IsBurningStickInRange(PlayState* play, Vec3f* pos, f32 xzRange, f32 yRange) { + Player* this = GET_PLAYER(play); + Vec3f diff; + s32 pad; + + if ((this->itemActionParam == PLAYER_AP_STICK) && (this->unk_B28 != 0)) { + Math_Vec3f_Diff(&this->meleeWeaponInfo[0].tip, pos, &diff); + return (SQXZ(diff) <= SQ(xzRange)) && (0.0f <= diff.y) && (diff.y <= yRange); + } + + return false; +} + +u8 Player_GetStrength(void) { + return sPlayerStrengths[(void)0, gSaveContext.save.playerForm]; +} + +u8 Player_GetMask(PlayState* play) { + Player* player = GET_PLAYER(play); + + return player->currentMask; +} + +// Unused +void Player_RemoveMask(PlayState* play) { + Player* player = GET_PLAYER(play); + + player->currentMask = PLAYER_MASK_NONE; +} + +s32 Player_HasMirrorShieldEquipped(PlayState* play) { + Player* player = GET_PLAYER(play); + + return (player->transformation == PLAYER_FORM_HUMAN) && (player->currentShield == PLAYER_SHIELD_MIRROR_SHIELD); +} + +s32 Player_IsHoldingMirrorShield(PlayState* play) { + Player* player = GET_PLAYER(play); + + return (player->transformation == PLAYER_FORM_HUMAN) && (player->rightHandType == 8) && + (player->currentShield == PLAYER_SHIELD_MIRROR_SHIELD); +} + +s32 Player_IsHoldingHookshot(Player* player) { + return player->itemActionParam == PLAYER_AP_HOOKSHOT; +} + +s32 func_801240DC(Player* player) { + return Player_IsHoldingHookshot(player) && (player->heldActor == NULL); +} + +s32 func_80124110(Player* player, s32 actionParam) { + s32 temp_v0 = actionParam - PLAYER_AP_FISHING_POLE; + + if (player->transformation != PLAYER_FORM_GORON) { + if (((actionParam - PLAYER_AP_FISHING_POLE) > (PLAYER_AP_FISHING_POLE - PLAYER_AP_FISHING_POLE)) && + ((actionParam - PLAYER_AP_FISHING_POLE) < (PLAYER_AP_SWORD_GREAT_FAIRY - PLAYER_AP_FISHING_POLE))) { + return temp_v0; + } + } + + return 0; +} + +s32 func_80124148(Player* player) { + return func_80124110(player, player->itemActionParam); +} + +s32 Player_ActionToMeleeWeapon(s32 actionParam) { + s32 weapon = actionParam - (PLAYER_AP_SWORD_KOKIRI - 1); + + if ((weapon > 0) && (weapon <= (PLAYER_AP_ZORA_FINS - (PLAYER_AP_SWORD_KOKIRI - 1)))) { + return weapon; + } + return 0; +} + +s32 Player_GetMeleeWeaponHeld(Player* player) { + return Player_ActionToMeleeWeapon(player->itemActionParam); +} + +s32 Player_IsHoldingTwoHandedWeapon(Player* player) { + // Relies on the actionParams for two-handed weapons being contiguous. + if ((player->itemActionParam >= PLAYER_AP_SWORD_GREAT_FAIRY) && (player->itemActionParam <= PLAYER_AP_STICK)) { + return true; + } + + return false; +} + +s32 Player_ActionToBottle(Player* player, s32 actionParam) { + s32 bottle = actionParam - PLAYER_AP_BOTTLE; + + // Relies on bottle-related action params to be contiguous + if ((bottle >= (PLAYER_AP_BOTTLE - PLAYER_AP_BOTTLE)) && (bottle <= (PLAYER_AP_BOTTLE_FAIRY - PLAYER_AP_BOTTLE))) { + return bottle; + } + + return -1; +} + +s32 Player_GetBottleHeld(Player* Player) { + return Player_ActionToBottle(Player, Player->itemActionParam); +} + +s32 Player_ActionToExplosive(Player* player, s32 actionParam) { + s32 explosive = actionParam - PLAYER_AP_BOMB; + + // Relies on explosive-related action params to be contiguous + if ((explosive >= (PLAYER_AP_BOMB - PLAYER_AP_BOMB)) && (explosive <= (PLAYER_AP_BOMBCHU - PLAYER_AP_BOMB))) { + return explosive; + } + + return -1; +} + +s32 Player_GetExplosiveHeld(Player* player) { + return Player_ActionToExplosive(player, player->itemActionParam); +} + +// Convert actionParam to sword +s32 func_80124278(Actor* actor, s32 actionParam) { + s32 sword = 0; + + //! FAKE: + if ((actionParam == PLAYER_AP_LAST_USED) || + ((sword = actionParam - PLAYER_AP_SWORD_KOKIRI, (sword >= PLAYER_AP_SWORD_KOKIRI - PLAYER_AP_SWORD_KOKIRI)) && + (sword <= PLAYER_AP_SWORD_GREAT_FAIRY - PLAYER_AP_SWORD_KOKIRI))) { + return sword; + } + + return -1; +} + +s32 func_801242B4(Player* player) { + return (player->stateFlags1 & PLAYER_STATE1_8000000) && player->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER; +} + +s32 func_801242DC(PlayState* play) { + Player* player = GET_PLAYER(play); + TextTriggerEntry* triggerEntry; + s32 envIndex; + + if (play->roomCtx.currRoom.unk2 == 3) { // Room is hot + envIndex = 0; + } else if ((player->transformation != PLAYER_FORM_ZORA) && (player->unk_AD8 > 80)) { + envIndex = 3; + } else if (player->stateFlags1 & PLAYER_STATE1_8000000) { + if ((player->transformation == PLAYER_FORM_ZORA) && (player->currentBoots >= PLAYER_BOOTS_ZORA_UNDERWATER) && + (player->actor.bgCheckFlags & 1)) { + envIndex = 1; + } else { + envIndex = 2; + } + } else { + return 0; + } + + // Trigger general textboxes under certain conditions, like "It's so hot in here!". Unused in MM + triggerEntry = &sEnvironmentTextTriggers[envIndex]; + if (!Player_InCsMode(play)) { + if ((triggerEntry->flag) && !(gSaveContext.textTriggerFlags & triggerEntry->flag) && (envIndex == 0)) { + Message_StartTextbox(play, triggerEntry->textId, NULL); + gSaveContext.textTriggerFlags |= triggerEntry->flag; + } + } + + return envIndex + 1; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124420.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124618.s") +void func_80124618(struct_80124618 arg0[], f32 curFrame, Vec3f* arg2) { + s32 currentFrame = curFrame; + f32 temp_f0; + f32 temp_f14; + f32 progress; + s16 temp_v1; + + do { + temp_v1 = arg0[1].unk_0; + arg0++; + } while (temp_v1 < currentFrame); + + temp_f0 = arg0[-1].unk_0; + + progress = (curFrame - temp_f0) / (temp_v1 - temp_f0); + + temp_f14 = arg0[-1].unk_2.x; + arg2->x = LERPIMP(temp_f14, arg0->unk_2.x, progress) * 0.01f; + + temp_f14 = arg0[-1].unk_2.y; + arg2->y = LERPIMP(temp_f14, arg0->unk_2.y, progress) * 0.01f; + + temp_f14 = arg0[-1].unk_2.z; + arg2->z = LERPIMP(temp_f14, arg0->unk_2.z, progress) * 0.01f; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801246F4.s") @@ -132,22 +926,122 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124CC4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124F18.s") +extern s32 D_801C0958; +#if 0 +s32 D_801C0958 = false; +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124FF0.s") +void func_80124F18(s16* arg0, f32* arg1, s16 arg2, f32 arg3, f32 arg4) { + f32 phi_f12; + + if (*arg0 < arg2) { + *arg1 += arg3; + } else { + *arg1 -= arg3; + } + + *arg1 = CLAMP(*arg1, -arg4, arg4); + *arg0 += (s16)*arg1; + if (((arg2 - *arg0) * (s16)*arg1) < 0) { + *arg0 = arg2; + } +} + +void func_80124FF0(f32 arg0, s16 arg1, Vec3f* arg2, s16 arg3, Vec3f* arg4, Vec3f* arg5, s16* arg6, f32* arg7, f32 arg8, + s16 arg9, s16* arg10, f32* arg11, s32 arg12) { + Vec3f sp44; + f32 sp40; + s16 temp_v0; + s16 sp3C; + f32 temp_f14; + f32 sp34 = Math_CosS(arg1) * arg0; + f32 sp30 = Math_SinS(arg1) * -arg0; + + arg5->x = (Math_SinS(arg3) * sp30) + arg2->x; + arg5->y = arg2->y + sp34; + arg5->z = (Math_CosS(arg3) * sp30) + arg2->z; + + Math_Vec3f_Diff(arg5, arg4, &sp44); + sp40 = sqrtf(SQXZ(sp44)); + + sp3C = (sp40 <= 1.0f) ? arg3 : Math_FAtan2F(sp44.z, sp44.x); + sp40 = (Math_CosS(sp3C - arg3) * sp40) + arg8; + + if (ABS_ALT(BINANG_SUB(sp3C, arg3)) > 0x4000) { + sp3C = BINANG_ROT180(sp3C); + } + sp3C -= arg3; + + temp_v0 = Math_FAtan2F(sp44.y, sp40); + temp_v0 = CLAMP(temp_v0, (s16)-arg9, arg9); + //! FAKE: + if (sp3C) {} + + func_80124F18(arg6, arg7, temp_v0, 20.0f, 2000.0f); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801251C4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80125318.s") +void func_80125318(Vec3f* arg0, Vec3s* arg1) { + arg0->x = 0.0f; + arg0->y = 0.0f; + arg0->z = 0.0f; + arg1->x = 0; + arg1->y = 0; + arg1->z = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80125340.s") +void func_80125340(void) { + Matrix_Push(); + D_801C0958 = true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012536C.s") +void func_8012536C(void) { + if (D_801C0958) { + Matrix_Pop(); + D_801C0958 = false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801253A4.s") +void Player_DrawZoraShield(PlayState* play, Player* player) { + u8* phi_a0; + Vtx* vtx; + Gfx* dList; + f32 scale; + s32 i; + + scale = player->unk_B62 * (10.0f / 51.0f); + + OPEN_DISPS(play->state.gfxCtx); + + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(&object_link_zora_Matanimheader_012A80)); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + + // clang-format off + vtx = Lib_SegmentedToVirtual(&object_link_zora_Vtx_011210); phi_a0 = Lib_SegmentedToVirtual(&object_link_zora_U8_011710); + // clang-format on + + // ARRAY_COUNT(object_link_zora_Vtx_011210) + for (i = 0; i < 80; i++) { + // Editing the Vtxs in object itself + vtx->v.cn[3] = (*phi_a0 * player->unk_B62) >> 8; + vtx++; + phi_a0++; + } + + dList = POLY_XLU_DISP; + + gSPMatrix(&dList[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&dList[1], object_link_zora_DL_011760); + + POLY_XLU_DISP = &dList[2]; + + CLOSE_DISPS(play->state.gfxCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80125500.s") +s32 func_80125580(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80125580.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80125CE0.s") @@ -156,17 +1050,102 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801262C8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801263FC.s") +// unused +s32 func_801263FC(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + Player* player = (Player*)thisx; + + if (!func_80125580(play, limbIndex, dList, pos, rot, thisx)) { + *dList = NULL; + } + + return false; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80126440.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801265C8.s") +extern u8 D_801C096C[PLAYER_SHIELD_MAX]; +#if 0 +u8 D_801C096C[PLAYER_SHIELD_MAX] = { + COLTYPE_METAL, + COLTYPE_METAL, + COLTYPE_METAL, +}; +#endif + +void func_801265C8(PlayState* play, Player* player, ColliderQuad* collider, Vec3f arg3[4]) { + if (player->stateFlags1 & PLAYER_STATE1_400000) { + Vec3f sp4C; + Vec3f sp40; + Vec3f sp34; + Vec3f sp28; + + player->shieldQuad.base.colType = D_801C096C[player->currentShield]; + Matrix_MultVec3f(&arg3[0], &sp28); + Matrix_MultVec3f(&arg3[1], &sp34); + Matrix_MultVec3f(&arg3[2], &sp40); + Matrix_MultVec3f(&arg3[3], &sp4C); + Collider_SetQuadVertices(collider, &sp28, &sp34, &sp40, &sp4C); + CollisionCheck_SetAC(play, &play->colChkCtx, &collider->base); + CollisionCheck_SetAT(play, &play->colChkCtx, &collider->base); + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012669C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80126808.s") +void Player_DrawGetItemImpl(PlayState* play, Player* player, Vec3f* refPos, s32 drawIdPlusOne) { + f32 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012697C.s") + if (player->stateFlags3 & PLAYER_STATE3_4000000) { + sp34 = 6.0f; + } else { + sp34 = 14.0f; + } + + OPEN_DISPS(play->state.gfxCtx); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(player->giObjectSegment); + + gSPSegment(POLY_OPA_DISP++, 0x06, player->giObjectSegment); + gSPSegment(POLY_XLU_DISP++, 0x06, player->giObjectSegment); + + Matrix_Translate((Math_SinS(player->actor.shape.rot.y) * 3.3f) + refPos->x, refPos->y + sp34, + (Math_CosS(player->actor.shape.rot.y) * 3.3f) + refPos->z, MTXMODE_NEW); + Matrix_RotateZYX(0, (play->gameplayFrames * 1000), 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(play, drawIdPlusOne - 1); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Player_DrawGetItem(PlayState* play, Player* player) { + if (!player->giObjectLoading || (osRecvMesg(&player->giObjectLoadQueue, NULL, OS_MESG_NOBLOCK) == 0)) { + Vec3f refPos; + s32 drawIdPlusOne; + + player->giObjectLoading = false; + if ((player->actor.id == ACTOR_EN_TEST3) || + ((player->transformation == PLAYER_FORM_DEKU) && (player->stateFlags1 & PLAYER_STATE1_400))) { + refPos.x = player->actor.world.pos.x; + refPos.z = player->actor.world.pos.z; + if (player->actor.id == ACTOR_EN_TEST3) { + if (player->stateFlags1 & PLAYER_STATE1_400) { + refPos.y = player->actor.world.pos.y + 30.0f; + } else { + refPos.x = player->bodyPartsPos[0xC].x; + refPos.y = player->bodyPartsPos[0xC].y - 6.0f; + refPos.z = player->bodyPartsPos[0xC].z; + } + } else { + refPos.y = player->actor.world.pos.y + 28.0f; + } + } else { + Math_Vec3f_Copy(&refPos, &D_801F59E8); + } + + drawIdPlusOne = ABS_ALT(player->unk_B2A); + Player_DrawGetItemImpl(play, player, &refPos, drawIdPlusOne); + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80126AB4.s") @@ -176,11 +1155,37 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801271B0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127438.s") +// Player_SetMaskSegment? +s32 func_80127438(PlayState* play, Player* player, s32 currentMask) { + if ((player->maskObjectLoadState == 0) && (currentMask == (u8)player->maskId)) { + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127488.s") + gSPSegment(POLY_OPA_DISP++, 0x0A, player->maskObjectSegment); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012754C.s") + CLOSE_DISPS(play->state.gfxCtx); + + return true; + } + + return false; +} + +void func_80127488(PlayState* play, Player* player, u8 alpha) { + OPEN_DISPS(play->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, alpha); + gSPDisplayList(POLY_XLU_DISP++, gLinkGoronGoronPunchEffectDL); + + func_80122BA4(play, &player->unk_3D0, 3, alpha); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Player_DrawCouplesMask(PlayState* play, Player* player) { + gSegments[0xA] = PHYSICAL_TO_VIRTUAL(player->maskObjectSegment); + AnimatedMat_DrawOpa(play, Lib_SegmentedToVirtual(&object_mask_meoto_Matanimheader_001CD8)); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127594.s") diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 2ada2ba78..7caa0f426 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -756,8 +756,8 @@ void Distortion_Update(void) { return; } - depthPhase += DEGF_TO_BINANG(depthPhaseStep); - screenPlanePhase += DEGF_TO_BINANG(screenPlanePhaseStep); + depthPhase += CAM_DEG_TO_BINANG(depthPhaseStep); + screenPlanePhase += CAM_DEG_TO_BINANG(screenPlanePhaseStep); View_SetDistortionDirRot(&sDistortionContext.play->view, Math_CosS(depthPhase) * (DEGF_TO_RADF(rotX) * xyScaleFactor), diff --git a/src/code/z_room.c b/src/code/z_room.c index d3b88bd5d..3507765a5 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -143,9 +143,9 @@ void func_8012EBF8(PlayState* play, RoomContext* roomCtx) { roomCtx->prevRoom.segment = NULL; func_800BA798(play, &play->actorCtx); Actor_SpawnTransitionActors(play, &play->actorCtx); - if (-1 < roomCtx->currRoom.num) { - func_8010A33C(play, roomCtx->currRoom.num); - func_8010A2DC(play); + if (roomCtx->currRoom.num > -1) { + Map_InitRoomData(play, roomCtx->currRoom.num); + Minimap_SavePlayerRoomInitInfo(play); } func_801A3CD8(play->roomCtx.currRoom.echo); } diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 7d2c4301b..b4ba212d5 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -4,12 +4,12 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 id) { size_t size; objectCtx->status[objectCtx->num].id = id; - size = objectFileTable[id].vromEnd - objectFileTable[id].vromStart; + size = gObjectTable[id].vromEnd - gObjectTable[id].vromStart; if (1) {} if (size != 0) { - DmaMgr_SendRequest0(objectCtx->status[objectCtx->num].segment, objectFileTable[id].vromStart, size); + DmaMgr_SendRequest0(objectCtx->status[objectCtx->num].segment, gObjectTable[id].vromStart, size); } if (objectCtx->num < OBJECT_EXCHANGE_BANK_MAX - 1) { @@ -66,7 +66,7 @@ void Object_UpdateBank(ObjectContext* objectCtx) { s32 id = -status->id; if (status->dmaReq.vromAddr == 0) { - objectFile = &objectFileTable[id]; + objectFile = &gObjectTable[id]; size = objectFile->vromEnd - objectFile->vromStart; if (size == 0) { @@ -112,13 +112,13 @@ void Object_LoadAll(ObjectContext* objectCtx) { for (i = 0; i < objectCtx->num; i++) { id = objectCtx->status[i].id; - vromSize = objectFileTable[id].vromEnd - objectFileTable[id].vromStart; + vromSize = gObjectTable[id].vromEnd - gObjectTable[id].vromStart; if (vromSize == 0) { continue; } - DmaMgr_SendRequest0(objectCtx->status[i].segment, objectFileTable[id].vromStart, vromSize); + DmaMgr_SendRequest0(objectCtx->status[i].segment, gObjectTable[id].vromStart, vromSize); } } @@ -130,7 +130,7 @@ void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id) { objectCtx->status[iParm2].id = -id; objectCtx->status[iParm2].dmaReq.vromAddr = 0; - fileTableEntry = &objectFileTable[id]; + fileTableEntry = &gObjectTable[id]; vromSize = fileTableEntry->vromEnd - fileTableEntry->vromStart; // TODO: UB to cast void to u32 @@ -149,7 +149,7 @@ void Scene_HeaderCmdSpawnList(PlayState* play, SceneCmd* cmd) { play->linkActorEntry = (ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) + play->setupEntranceList[play->curSpawn].spawn; if ((play->linkActorEntry->params & 0x0F00) >> 8 == 0x0C || - (gSaveContext.respawnFlag == 0x02 && gSaveContext.respawn[RESTART_MODE_RETURN].playerParams == 0x0CFF)) { + (gSaveContext.respawnFlag == 0x02 && gSaveContext.respawn[RESPAWN_MODE_RETURN].playerParams == 0x0CFF)) { // Skull Kid Object Object_Spawn(&play->objectCtx, OBJECT_STK); return; @@ -159,7 +159,7 @@ void Scene_HeaderCmdSpawnList(PlayState* play, SceneCmd* cmd) { nextObject = play->objectCtx.status[play->objectCtx.num].segment; play->objectCtx.num = loadedCount; play->objectCtx.spawnedObjectCount = loadedCount; - playerObjectId = gLinkFormObjectIndexes[(void)0, gSaveContext.save.playerForm]; + playerObjectId = gPlayerFormObjectIndices[(void)0, gSaveContext.save.playerForm]; gActorOverlayTable[0].initInfo->objectId = playerObjectId; Object_Spawn(&play->objectCtx, playerObjectId); @@ -530,7 +530,7 @@ void Scene_HeaderCmdAnimatedMaterials(PlayState* play, SceneCmd* cmd) { * Sets the exit fade from the next entrance index. */ void Scene_SetExitFade(PlayState* play) { - play->unk_1887F = Entrance_GetTransitionFlags(play->nextEntranceIndex) & 0x7F; + play->transitionType = Entrance_GetTransitionFlags(play->nextEntranceIndex) & 0x7F; } /** diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index 8bb8fa473..8ddde8a82 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -363,10 +363,10 @@ void AnimatedMat_DrawColorNonLinearInterp(PlayState* play, s32 segment, void* pa */ void AnimatedMat_DrawTexCycle(PlayState* play, s32 segment, void* params) { AnimatedMatTexCycleParams* texAnimParams = params; - void** texList = Lib_SegmentedToVirtual(texAnimParams->textureList); + TexturePtr* texList = Lib_SegmentedToVirtual(texAnimParams->textureList); u8* texId = Lib_SegmentedToVirtual(texAnimParams->textureIndexList); s32 curFrame = sMatAnimStep % texAnimParams->keyFrameLength; - void* tex = Lib_SegmentedToVirtual(texList[texId[curFrame]]); + TexturePtr tex = Lib_SegmentedToVirtual(texList[texId[curFrame]]); OPEN_DISPS(play->state.gfxCtx); diff --git a/src/code/z_schedule.c b/src/code/z_schedule.c index 2380cef13..cfc6293ba 100644 --- a/src/code/z_schedule.c +++ b/src/code/z_schedule.c @@ -6,7 +6,7 @@ (dest) = (temp) * (0x10000 / 60 / 24.0f); \ (dest) = SCHEDULE_CONVERT_TIME(dest); -s32 Schedule_CheckFlagS(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_CheckFlagS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckFlagS* cmd = (ScheduleCmdCheckFlagS*)*script; u16 flag = (cmd->flagByte << 8) | cmd->flagMask; @@ -17,7 +17,7 @@ s32 Schedule_CheckFlagS(PlayState* play, u8** script, ScheduleResult* result) { return false; } -s32 Schedule_CheckFlagL(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_CheckFlagL(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckFlagL* cmd = (ScheduleCmdCheckFlagL*)*script; u16 flag = (cmd->flagByte << 8) | cmd->flagMask; @@ -28,7 +28,7 @@ s32 Schedule_CheckFlagL(PlayState* play, u8** script, ScheduleResult* result) { return false; } -s32 Schedule_CheckTimeRangeS(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_CheckTimeRangeS(PlayState* play, u8** script, ScheduleOutput* output) { s32 inRange = false; ScheduleCmdCheckTimeRangeS* cmd = (ScheduleCmdCheckTimeRangeS*)*script; f32 f; @@ -54,7 +54,7 @@ s32 Schedule_CheckTimeRangeS(PlayState* play, u8** script, ScheduleResult* resul return false; } -s32 Schedule_CheckTimeRangeL(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_CheckTimeRangeL(PlayState* play, u8** script, ScheduleOutput* output) { s32 inRange = false; ScheduleCmdCheckTimeRangeL* cmd = (ScheduleCmdCheckTimeRangeL*)*script; f32 f; @@ -80,33 +80,33 @@ s32 Schedule_CheckTimeRangeL(PlayState* play, u8** script, ScheduleResult* resul return false; } -s32 Schedule_ReturnValueL(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_ReturnValueL(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdReturnValueL* cmd = (ScheduleCmdReturnValueL*)*script; //! @bug result is a u8, value is truncated - result->result = (cmd->retH << 8) | cmd->retL; - result->hasResult = true; + output->result = (cmd->retH << 8) | cmd->retL; + output->hasResult = true; return true; } -s32 Schedule_ReturnNone(PlayState* play, u8** script, ScheduleResult* result) { - result->hasResult = false; +s32 Schedule_ReturnNone(PlayState* play, u8** script, ScheduleOutput* output) { + output->hasResult = false; return true; } -s32 Schedule_ReturnEmpty(PlayState* play, u8** script, ScheduleResult* result) { - result->hasResult = true; +s32 Schedule_ReturnEmpty(PlayState* play, u8** script, ScheduleOutput* output) { + output->hasResult = true; return true; } -s32 Schedule_Nop(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_Nop(PlayState* play, u8** script, ScheduleOutput* output) { return false; } -s32 Schedule_CheckMiscS(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_CheckMiscS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckMiscS* cmd = (ScheduleCmdCheckMiscS*)*script; if (((cmd->which == SCHEDULE_CHECK_MISC_ROOM_KEY) && (INV_CONTENT(ITEM_ROOM_KEY) == ITEM_ROOM_KEY)) || @@ -119,16 +119,16 @@ s32 Schedule_CheckMiscS(PlayState* play, u8** script, ScheduleResult* result) { return false; } -s32 Schedule_ReturnValueS(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_ReturnValueS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdReturnValueS* cmd = (ScheduleCmdReturnValueS*)*script; - result->result = cmd->result; - result->hasResult = true; + output->result = cmd->result; + output->hasResult = true; return true; } -s32 Schedule_CheckNotInSceneS(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_CheckNotInSceneS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckNotInSceneS* cmd = (ScheduleCmdCheckNotInSceneS*)*script; s16 scene = (cmd->sceneH << 8) | cmd->sceneL; @@ -139,7 +139,7 @@ s32 Schedule_CheckNotInSceneS(PlayState* play, u8** script, ScheduleResult* resu return false; } -s32 Schedule_CheckNotInSceneL(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_CheckNotInSceneL(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckNotInSceneL* cmd = (ScheduleCmdCheckNotInSceneL*)*script; s16 scene = (cmd->sceneH << 8) | cmd->sceneL; @@ -150,7 +150,7 @@ s32 Schedule_CheckNotInSceneL(PlayState* play, u8** script, ScheduleResult* resu return false; } -s32 Schedule_CheckNotInDayS(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_CheckNotInDayS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckNotInDayS* cmd = (ScheduleCmdCheckNotInDayS*)*script; s16 day = (cmd->dayH << 8) | cmd->dayL; @@ -161,7 +161,7 @@ s32 Schedule_CheckNotInDayS(PlayState* play, u8** script, ScheduleResult* result return false; } -s32 Schedule_CheckNotInDayL(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_CheckNotInDayL(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckNotInDayL* cmd = (ScheduleCmdCheckNotInDayL*)*script; s16 day = (cmd->dayH << 8) | cmd->dayL; @@ -172,7 +172,7 @@ s32 Schedule_CheckNotInDayL(PlayState* play, u8** script, ScheduleResult* result return false; } -s32 Schedule_ReturnTime(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_ReturnTime(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdReturnTime* cmd = (ScheduleCmdReturnTime*)*script; f32 f; u16 time0; @@ -183,15 +183,15 @@ s32 Schedule_ReturnTime(PlayState* play, u8** script, ScheduleResult* result) { SCHEDULE_CALC_TIME(cmd->time1Hr, cmd->time1Min, time1, f); time1--; - result->result = cmd->result; - result->time0 = time0; - result->time1 = time1; - result->hasResult = true; + output->result = cmd->result; + output->time0 = time0; + output->time1 = time1; + output->hasResult = true; return true; } -s32 Schedule_CheckBeforeTimeS(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_CheckBeforeTimeS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckBeforeTimeS* cmd = (ScheduleCmdCheckBeforeTimeS*)*script; f32 f; u16 testTime; @@ -208,7 +208,7 @@ s32 Schedule_CheckBeforeTimeS(PlayState* play, u8** script, ScheduleResult* resu return false; } -s32 Schedule_CheckBeforeTimeL(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_CheckBeforeTimeL(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckBeforeTimeL* cmd = (ScheduleCmdCheckBeforeTimeL*)*script; f32 f; u16 testTime; @@ -225,21 +225,21 @@ s32 Schedule_CheckBeforeTimeL(PlayState* play, u8** script, ScheduleResult* resu return false; } -s32 Schedule_BranchS(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_BranchS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdBranchS* cmd = (ScheduleCmdBranchS*)*script; *script += cmd->offset; return false; } -s32 Schedule_BranchL(PlayState* play, u8** script, ScheduleResult* result) { +s32 Schedule_BranchL(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdBranchL* cmd = (ScheduleCmdBranchL*)*script; *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); return false; } -static s32 (*sScheduleCmdFuncs[])(PlayState*, u8**, ScheduleResult*) = { +static s32 (*sScheduleCmdFuncs[])(PlayState*, u8**, ScheduleOutput*) = { Schedule_CheckFlagS, Schedule_CheckFlagL, Schedule_CheckTimeRangeS, Schedule_CheckTimeRangeL, Schedule_ReturnValueL, Schedule_ReturnNone, Schedule_ReturnEmpty, Schedule_Nop, Schedule_CheckMiscS, Schedule_ReturnValueS, Schedule_CheckNotInSceneS, Schedule_CheckNotInSceneL, @@ -269,15 +269,15 @@ static u8 sScheduleCmdSizes[] = { sizeof(ScheduleCmdBranchL), }; -s32 Schedule_RunScript(PlayState* play, u8* script, ScheduleResult* result) { +s32 Schedule_RunScript(PlayState* play, u8* script, ScheduleOutput* output) { u8 size; s32 stop; do { size = sScheduleCmdSizes[*script]; - stop = (*sScheduleCmdFuncs[*script])(play, &script, result); + stop = (*sScheduleCmdFuncs[*script])(play, &script, output); script += size; } while (!stop); - return result->hasResult; + return output->hasResult; } diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 5129212c2..69a0a4491 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -230,8 +230,8 @@ void Sram_SaveEndOfCycle(PlayState* play) { s16 sceneNum; s32 j; s32 i; - u8 temp; - u8 temp2; + u8 slot; + u8 item; gSaveContext.save.daySpeed = 0; gSaveContext.save.daysElapsed = 0; @@ -260,7 +260,7 @@ void Sram_SaveEndOfCycle(PlayState* play) { ((void)0, gSaveContext.cycleSceneFlags[i].collectible) & D_801C5FC0[i][3]; gSaveContext.cycleSceneFlags[i].clearedRoom = 0; gSaveContext.save.permanentSceneFlags[i].unk_14 = 0; - gSaveContext.save.permanentSceneFlags[i].unk_18 = 0; + gSaveContext.save.permanentSceneFlags[i].rooms = 0; } for (; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { @@ -276,7 +276,7 @@ void Sram_SaveEndOfCycle(PlayState* play) { } if (gSaveContext.save.weekEventReg[84] & 0x20) { - func_801149A0(ITEM_MASK_FIERCE_DEITY, SLOT(ITEM_MASK_FIERCE_DEITY)); + Inventory_DeleteItem(ITEM_MASK_FIERCE_DEITY, SLOT(ITEM_MASK_FIERCE_DEITY)); } for (i = 0; i < ARRAY_COUNT(D_801C66D0); i++) { @@ -306,26 +306,26 @@ void Sram_SaveEndOfCycle(PlayState* play) { } if (INV_CONTENT(ITEM_BOMB) == ITEM_BOMB) { - temp2 = INV_CONTENT(ITEM_BOMB); - if (AMMO(temp2) != 0) { + item = INV_CONTENT(ITEM_BOMB); + if (AMMO(item) != 0) { gSaveContext.eventInf[7] |= 2; } } if (INV_CONTENT(ITEM_NUT) == ITEM_NUT) { - temp2 = INV_CONTENT(ITEM_NUT); - if (AMMO(temp2) != 0) { + item = INV_CONTENT(ITEM_NUT); + if (AMMO(item) != 0) { gSaveContext.eventInf[7] |= 4; } } if (INV_CONTENT(ITEM_STICK) == ITEM_STICK) { - temp2 = INV_CONTENT(ITEM_STICK); - if (AMMO(temp2) != 0) { + item = INV_CONTENT(ITEM_STICK); + if (AMMO(item) != 0) { gSaveContext.eventInf[7] |= 8; } } if (INV_CONTENT(ITEM_BOW) == ITEM_BOW) { - temp2 = INV_CONTENT(ITEM_BOW); - if (AMMO(temp2) != 0) { + item = INV_CONTENT(ITEM_BOW); + if (AMMO(item) != 0) { gSaveContext.eventInf[7] |= 0x10; } } @@ -333,8 +333,8 @@ void Sram_SaveEndOfCycle(PlayState* play) { for (i = 0; i < ARRAY_COUNT(D_801C67B0); i++) { if (D_801C67B0[i] != ITEM_NONE) { if ((gSaveContext.save.inventory.items[i] != ITEM_NONE) && (i != SLOT_PICTO_BOX)) { - temp2 = gSaveContext.save.inventory.items[i]; - AMMO(temp2) = 0; + item = gSaveContext.save.inventory.items[i]; + AMMO(item) = 0; } } } @@ -343,10 +343,10 @@ void Sram_SaveEndOfCycle(PlayState* play) { // Check for all bottled items if (gSaveContext.save.inventory.items[i] >= ITEM_POTION_RED) { if (gSaveContext.save.inventory.items[i] <= ITEM_OBABA_DRINK) { - for (j = 1; j < 4; j++) { + for (j = EQUIP_SLOT_C_LEFT; j <= EQUIP_SLOT_C_RIGHT; j++) { if (GET_CUR_FORM_BTN_ITEM(j) == gSaveContext.save.inventory.items[i]) { SET_CUR_FORM_BTN_ITEM(j, ITEM_BOTTLE); - func_80112B40(play, j); + Interface_LoadItemIconImpl(play, j); } } gSaveContext.save.inventory.items[i] = ITEM_BOTTLE; @@ -354,26 +354,26 @@ void Sram_SaveEndOfCycle(PlayState* play) { } } - REMOVE_QUEST_ITEM(QUEST_UNK_19); + REMOVE_QUEST_ITEM(QUEST_PICTOGRAPH); if (gSaveContext.save.playerData.health < 0x30) { gSaveContext.save.playerData.health = 0x30; } - if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) < 3) { - SET_EQUIP_VALUE(EQUIP_SWORD, 1); + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) <= EQUIP_VALUE_SWORD_RAZOR) { + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_KOKIRI); if (CUR_FORM == 0) { if ((STOLEN_ITEM_1 >= ITEM_SWORD_GILDED) || (STOLEN_ITEM_2 >= ITEM_SWORD_GILDED)) { BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_GILDED; - SET_EQUIP_VALUE(EQUIP_SWORD, 3); + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_GILDED); } else { BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; } } else { if ((STOLEN_ITEM_1 >= ITEM_SWORD_GILDED) || (STOLEN_ITEM_2 >= ITEM_SWORD_GILDED)) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_GILDED; - SET_EQUIP_VALUE(EQUIP_SWORD, 3); + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_GILDED); } else { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; } @@ -385,20 +385,20 @@ void Sram_SaveEndOfCycle(PlayState* play) { } if (STOLEN_ITEM_1 == ITEM_BOTTLE) { - temp = SLOT(ITEM_BOTTLE); - for (i = 0; i < 6; i++) { - if (gSaveContext.save.inventory.items[temp + i] == ITEM_NONE) { - gSaveContext.save.inventory.items[temp + i] = ITEM_BOTTLE; + slot = SLOT(ITEM_BOTTLE); + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[slot + i] = ITEM_BOTTLE; break; } } } if (STOLEN_ITEM_2 == ITEM_BOTTLE) { - temp = SLOT(ITEM_BOTTLE); - for (i = 0; i < 6; i++) { - if (gSaveContext.save.inventory.items[temp + i] == ITEM_NONE) { - gSaveContext.save.inventory.items[temp + i] = ITEM_BOTTLE; + slot = SLOT(ITEM_BOTTLE); + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[slot + i] = ITEM_BOTTLE; break; } } @@ -407,15 +407,14 @@ void Sram_SaveEndOfCycle(PlayState* play) { SET_STOLEN_ITEM_1(STOLEN_ITEM_NONE); SET_STOLEN_ITEM_2(STOLEN_ITEM_NONE); - // ?? - func_801149A0(ITEM_OCARINA_FAIRY, SLOT_TRADE_DEED); - func_801149A0(ITEM_SLINGSHOT, SLOT_TRADE_KEY_MAMA); - func_801149A0(ITEM_LONGSHOT, SLOT_TRADE_COUPLE); + Inventory_DeleteItem(ITEM_OCARINA_FAIRY, SLOT_TRADE_DEED); + Inventory_DeleteItem(ITEM_SLINGSHOT, SLOT_TRADE_KEY_MAMA); + Inventory_DeleteItem(ITEM_LONGSHOT, SLOT_TRADE_COUPLE); - for (j = 1; j < 4; j++) { + for (j = EQUIP_SLOT_C_LEFT; j <= EQUIP_SLOT_C_RIGHT; j++) { if (GET_CUR_FORM_BTN_ITEM(j) >= ITEM_MOON_TEAR && GET_CUR_FORM_BTN_ITEM(j) <= ITEM_PENDANT_MEMORIES) { SET_CUR_FORM_BTN_ITEM(j, ITEM_NONE); - func_80112B40(play, j); + Interface_LoadItemIconImpl(play, j); } } @@ -596,7 +595,7 @@ ItemEquips sSaveDefaultItemEquips = { { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, - { ITEM_UNK_FD, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + { ITEM_FD, ITEM_NONE, ITEM_NONE, ITEM_NONE }, }, { { SLOT_OCARINA, SLOT_NONE, SLOT_NONE, SLOT_NONE }, @@ -809,8 +808,8 @@ void Sram_InitDebugSave(void) { Lib_MemCpy(&gSaveContext.save.checksum, &sSaveDebugChecksum, sizeof(gSaveContext.save.checksum)); if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { - BUTTON_ITEM_EQUIP(0, 2) = D_801C6A48[((void)0, gSaveContext.save.playerForm & 0xFF)]; - C_SLOT_EQUIP(0, 2) = D_801C6A50[((void)0, gSaveContext.save.playerForm & 0xFF)]; + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = D_801C6A48[((void)0, gSaveContext.save.playerForm & 0xFF)]; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = D_801C6A50[((void)0, gSaveContext.save.playerForm & 0xFF)]; } gSaveContext.save.hasTatl = true; diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index f8c6b1a21..afc7f7168 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -480,13 +480,13 @@ void SubS_TimePathing_ComputeInitialY(PlayState* play, Path* path, s32 waypoint, } } -Path* SubS_GetAdditionalPath(PlayState* play, u8 pathIndex, s32 max) { +Path* SubS_GetAdditionalPath(PlayState* play, u8 pathIndex, s32 limit) { Path* path; s32 i = 0; do { path = &play->setupPathList[pathIndex]; - if (i >= max) { + if (i >= limit) { break; } pathIndex = path->unk1; @@ -830,43 +830,52 @@ s32 func_8013C964(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 it xzRange = actor->xzDistToPlayer + 1.0f; ret = Actor_PickUp(actor, play, itemId, xzRange, yRange); break; + case 2: if ((fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) { ret = func_800B8500(actor, play, xzRange, yRange, itemId); } break; + case 3: //! @bug: Both x and y conditionals are always true, || should be an && if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT))) { ret = func_800B8500(actor, play, xzRange, yRange, itemId); } break; + case 4: yRange = fabsf(actor->playerHeightRel) + 1.0f; xzRange = actor->xzDistToPlayer + 1.0f; xzDistToPlayerTemp = actor->xzDistToPlayer; actor->xzDistToPlayer = 0.0f; - actor->flags |= 0x10000; + actor->flags |= ACTOR_FLAG_10000; ret = func_800B8500(actor, play, xzRange, yRange, itemId); actor->xzDistToPlayer = xzDistToPlayerTemp; break; + case 5: //! @bug: Both x and y conditionals are always true, || should be an && if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) && (fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange) && actor->isTargeted) { - actor->flags |= 0x10000; + actor->flags |= ACTOR_FLAG_10000; ret = func_800B8500(actor, play, xzRange, yRange, itemId); } break; + case 6: //! @bug: Both x and y conditionals are always true, || should be an && if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) && (fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) { - actor->flags |= 0x10000; + actor->flags |= ACTOR_FLAG_10000; ret = func_800B8500(actor, play, xzRange, yRange, itemId); } break; + + default: + break; } + return ret; } diff --git a/src/libultra/os/initialize.c b/src/libultra/os/initialize.c index 20564effb..3174d5c99 100644 --- a/src/libultra/os/initialize.c +++ b/src/libultra/os/initialize.c @@ -57,7 +57,7 @@ void osInitialize(void) { osUnmapTLBAll(); osMapTLBRdb(); - osClockRate = (u64)((osClockRate * 3ll) / 4ull); + osClockRate = (u64)((osClockRate * 3LL) / 4ULL); if (osResetType == COLD_RESET) { bzero(osAppNmiBuffer, 64); 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 45d4ff68a..5f32870a7 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -107,7 +107,7 @@ void ArmsHook_DetachHookFromActor(ArmsHook* this) { s32 ArmsHook_CheckForCancel(ArmsHook* this) { Player* player = (Player*)this->actor.parent; - if (func_801240C8(player)) { + if (Player_IsHoldingHookshot(player)) { if ((player->heldItemActionParam != player->itemActionParam) || ((player->actor.flags & ACTOR_FLAG_100)) || ((player->stateFlags1 & 0x4000080))) { this->timer = 0; @@ -128,7 +128,7 @@ void ArmsHook_AttachHookToActor(ArmsHook* this, Actor* actor) { void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((this->actor.parent == NULL) || (!func_801240C8(player))) { + if ((this->actor.parent == NULL) || (!Player_IsHoldingHookshot(player))) { ArmsHook_DetachHookFromActor(this); Actor_MarkForDeath(&this->actor); return; @@ -311,13 +311,13 @@ void ArmsHook_Draw(Actor* thisx, PlayState* play) { Matrix_MultVec3f(&D_808C1C10, &this->unk1E0); Matrix_MultVec3f(&D_808C1C28, &sp5C); Matrix_MultVec3f(&D_808C1C34, &sp50); - this->unk1C4.active = false; + this->unk_1C4.active = false; } else { Matrix_MultVec3f(&D_808C1C1C, &this->unk1E0); Matrix_MultVec3f(&D_808C1C40, &sp5C); Matrix_MultVec3f(&D_808C1C4C, &sp50); } - func_80126440(play, &this->collider, &this->unk1C4, &sp5C, &sp50); + func_80126440(play, &this->collider, &this->unk_1C4, &sp5C, &sp50); func_8012C28C(play->state.gfxCtx); func_80122868(play, player); diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h index 5a79392ff..cee615da1 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h @@ -10,7 +10,7 @@ typedef void (*ArmsHookActionFunc)(struct ArmsHook*, PlayState*); typedef struct ArmsHook { /* 0x000 */ Actor actor; /* 0x144 */ ColliderQuad collider; - /* 0x1C4 */ WeaponInfo unk1C4; + /* 0x1C4 */ WeaponInfo unk_1C4; /* 0x1E0 */ Vec3f unk1E0; /* 0x1EC */ Vec3f unk1EC; /* 0x1F8 */ Actor* grabbed; diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.h b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.h index 338d65a03..a90cfe0ae 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.h +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.h @@ -8,14 +8,14 @@ struct ArrowIce; typedef void (*ArrowIceActionFunc)(struct ArrowIce*, PlayState*); typedef struct ArrowIce { - /* 0x0000 */ Actor actor; - /* 0x0144 */ s16 radius; - /* 0x0146 */ u16 timer; - /* 0x0148 */ u8 alpha; - /* 0x014C */ Vec3f firedPos; - /* 0x0158 */ f32 height; - /* 0x015C */ f32 blueingEffectMagnitude; - /* 0x0160 */ ArrowIceActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 radius; + /* 0x146 */ u16 timer; + /* 0x148 */ u8 alpha; + /* 0x14C */ Vec3f firedPos; + /* 0x158 */ f32 height; + /* 0x15C */ f32 blueingEffectMagnitude; + /* 0x160 */ ArrowIceActionFunc actionFunc; } ArrowIce; // size = 0x164 extern const ActorInit Arrow_Ice_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c index 6965ad4c1..ab7ac8a52 100644 --- a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c @@ -69,7 +69,7 @@ static ColliderTrisInit sTrisInit = { OC2_NONE, COLSHAPE_TRIS, }, - 2, + ARRAY_COUNT(sTrisElementsInit), sTrisElementsInit, }; diff --git a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c index 65080bd3d..dfa31a6a0 100644 --- a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c +++ b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c @@ -5,6 +5,7 @@ */ #include "z_bg_botihasira.h" +#include "objects/object_botihasira/object_botihasira.h" #define FLAGS 0x00000000 @@ -12,10 +13,11 @@ void BgBotihasira_Init(Actor* thisx, PlayState* play); void BgBotihasira_Destroy(Actor* thisx, PlayState* play); -void BgBotihasira_Update(Actor* thisx, PlayState* play); +void BgBotihasira_Update(Actor* thisx, PlayState* play2); void BgBotihasira_Draw(Actor* thisx, PlayState* play); -#if 0 +void BgBotihasira_DoNothing(BgBotihasira* this, PlayState* play); + const ActorInit Bg_Botihasira_InitVars = { ACTOR_BG_BOTIHASIRA, ACTORCAT_ITEMACTION, @@ -28,26 +30,74 @@ const ActorInit Bg_Botihasira_InitVars = { (ActorFunc)BgBotihasira_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B282F0 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 27, 80, 0, { 0, 0, 0 } }, }; -#endif +void BgBotihasira_Init(Actor* thisx, PlayState* play) { + s32 pad; + BgBotihasira* this = THIS; + CollisionHeader* colHeader = NULL; -extern ColliderCylinderInit D_80B282F0; + if (this->dyna.actor.params == 0) { + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_botihasira_Colheader_001BD8, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + } else { + Collider_InitAndSetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); + } + this->actionFunc = BgBotihasira_DoNothing; + this->dyna.actor.scale.z = this->dyna.actor.scale.y = this->dyna.actor.scale.x = 0.1f; +} -extern UNK_TYPE D_06000638; -extern UNK_TYPE D_06001BD8; +void BgBotihasira_Destroy(Actor* thisx, PlayState* play) { + BgBotihasira* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/BgBotihasira_Init.s") + if (this->dyna.actor.params == 0) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/BgBotihasira_Destroy.s") +void BgBotihasira_DoNothing(BgBotihasira* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/func_80B2815C.s") +void BgBotihasira_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + BgBotihasira* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/BgBotihasira_Update.s") + this->actionFunc(this, play); + if (this->dyna.actor.params != 0) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + (Math_SinS(this->dyna.actor.world.rot.y) * -27.0f); + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + (Math_CosS(this->dyna.actor.world.rot.y) * 7.0f); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/BgBotihasira_Draw.s") +void BgBotihasira_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_botihasira_DL_000638); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.h b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.h index c66b00b0a..529b5a904 100644 --- a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.h +++ b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.h @@ -8,10 +8,9 @@ struct BgBotihasira; typedef void (*BgBotihasiraActionFunc)(struct BgBotihasira*, PlayState*); typedef struct BgBotihasira { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgBotihasiraActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x4C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgBotihasiraActionFunc actionFunc; + /* 0x160 */ ColliderCylinder collider; } BgBotihasira; // size = 0x1AC extern const ActorInit Bg_Botihasira_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h index a30f63f1a..77c1b8808 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h @@ -19,11 +19,11 @@ enum { }; typedef struct BgBreakwall { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ s8 unk_15C; - /* 0x015D */ u8 switchFlag; - /* 0x015E */ u8 unk_15E; - /* 0x0160 */ BgBreakwallActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s8 unk_15C; + /* 0x15D */ u8 switchFlag; + /* 0x15E */ u8 unk_15E; + /* 0x160 */ BgBreakwallActionFunc actionFunc; } BgBreakwall; // size = 0x164 extern const ActorInit Bg_Breakwall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h index 8e44e7597..c1e4940d6 100644 --- a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h +++ b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h @@ -8,12 +8,12 @@ struct BgCraceMovebg; typedef void (*BgCraceMovebgActionFunc)(struct BgCraceMovebg*, PlayState*); typedef struct BgCraceMovebg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgCraceMovebgActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x10]; - /* 0x0170 */ s32 unk_170; - /* 0x0174 */ char unk_174[0x20]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x18]; + /* 0x15C */ BgCraceMovebgActionFunc actionFunc; + /* 0x160 */ char unk_160[0x10]; + /* 0x170 */ s32 unk_170; + /* 0x174 */ char unk_174[0x20]; } BgCraceMovebg; // size = 0x194 extern const ActorInit Bg_Crace_Movebg_InitVars; 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 0830d0d81..056af77bb 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 @@ -66,7 +66,7 @@ static Gfx* sDLists[] = { gClockTowerCeilingCogDL, gClockTowerCenterCogDL, gCloc void BgCtowerGear_Splash(BgCtowerGear* this, PlayState* play) { s32 i; - s32 flag40 = this->dyna.actor.flags & 0x40; + s32 flag40 = this->dyna.actor.flags & ACTOR_FLAG_40; Vec3f splashSpawnPos; Vec3f splashOffset; s32 pad; diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.h b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.h index 5da321679..952a13c4a 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.h +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.h @@ -9,10 +9,10 @@ struct BgCtowerGear; #define BGCTOWERGEAR_GET_TYPE(thisx) ((thisx)->params & 3) typedef enum { - /* 0x00 */ BGCTOWERGEAR_CEILING_COG, - /* 0x01 */ BGCTOWERGEAR_CENTER_COG, - /* 0x02 */ BGCTOWERGEAR_WATER_WHEEL, - /* 0x03 */ BGCTOWERGEAR_ORGAN + /* 0x0 */ BGCTOWERGEAR_CEILING_COG, + /* 0x1 */ BGCTOWERGEAR_CENTER_COG, + /* 0x2 */ BGCTOWERGEAR_WATER_WHEEL, + /* 0x3 */ BGCTOWERGEAR_ORGAN } BgCtowerGearType; typedef struct BgCtowerGear { 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 a064823f4..2ca48b346 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 @@ -85,7 +85,7 @@ void BgCtowerRot_CorridorRotate(BgCtowerRot* this, PlayState* play) { Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); rotZ = CLAMP(1100.0f - offset.z, 0.0f, 1000.0f); - func_800DFAC8(play->cameraPtrs[CAM_ID_MAIN], 17); + Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); this->dyna.actor.shape.rot.z = rotZ * 16.384f; if (play->csCtx.frames == 132) { diff --git a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h index 8d8f3d298..1bdf17933 100644 --- a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h +++ b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h @@ -8,11 +8,11 @@ struct BgDanpeiMovebg; typedef void (*BgDanpeiMovebgActionFunc)(struct BgDanpeiMovebg*, PlayState*); typedef struct BgDanpeiMovebg { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ BgDanpeiMovebgActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x6C]; - /* 0x01CC */ u16 unk_1CC; - /* 0x01CE */ char unk_1CE[0xA]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgDanpeiMovebgActionFunc actionFunc; + /* 0x160 */ char unk_160[0x6C]; + /* 0x1CC */ u16 unk_1CC; + /* 0x1CE */ char unk_1CE[0xA]; } BgDanpeiMovebg; // size = 0x1D8 extern const ActorInit Bg_Danpei_Movebg_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h index adef3420e..098f96770 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h @@ -18,30 +18,30 @@ typedef struct { } BgDblueBalanceStruct; // size = 0x14 typedef struct BgDblueBalance { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ struct BgDblueBalance* unk_15C; - /* 0x0160 */ struct BgDblueBalance* unk_160; - /* 0x0164 */ struct BgDblueBalance* unk_164; - /* 0x0168 */ BgDblueBalanceActionFunc actionFunc; - /* 0x016C */ s32 unk_16C; - /* 0x0170 */ s32 unk_170; - /* 0x0174 */ s16 unk_174; - /* 0x0176 */ s16 unk_176; - /* 0x0178 */ s16 unk_178; - /* 0x017A */ s16 unk_17A; - /* 0x017C */ s8 unk_17C; - /* 0x017D */ s8 unk_17D; - /* 0x017E */ s8 unk_17E; - /* 0x017F */ s8 unk_17F; - /* 0x0180 */ s8 unk_180; - /* 0x0181 */ s8 unk_181; - /* 0x0182 */ s8 unk_182; - /* 0x0183 */ u8 unk_183; - /* 0x0184 */ s16 unk_184; - /* 0x0186 */ s8 unk_186; - /* 0x0187 */ s8 unk_187; - /* 0x0188 */ BgDblueBalanceStruct unk_188[8]; - /* 0x0228 */ f32 unk_228; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ struct BgDblueBalance* unk_15C; + /* 0x160 */ struct BgDblueBalance* unk_160; + /* 0x164 */ struct BgDblueBalance* unk_164; + /* 0x168 */ BgDblueBalanceActionFunc actionFunc; + /* 0x16C */ s32 unk_16C; + /* 0x170 */ s32 unk_170; + /* 0x174 */ s16 unk_174; + /* 0x176 */ s16 unk_176; + /* 0x178 */ s16 unk_178; + /* 0x17A */ s16 unk_17A; + /* 0x17C */ s8 unk_17C; + /* 0x17D */ s8 unk_17D; + /* 0x17E */ s8 unk_17E; + /* 0x17F */ s8 unk_17F; + /* 0x180 */ s8 unk_180; + /* 0x181 */ s8 unk_181; + /* 0x182 */ s8 unk_182; + /* 0x183 */ u8 unk_183; + /* 0x184 */ s16 unk_184; + /* 0x186 */ s8 unk_186; + /* 0x187 */ s8 unk_187; + /* 0x188 */ BgDblueBalanceStruct unk_188[8]; + /* 0x228 */ f32 unk_228; } BgDblueBalance; // size = 0x22C extern const ActorInit Bg_Dblue_Balance_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.h b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.h index 4e16a28c7..db6cba5b4 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.h @@ -8,10 +8,10 @@ struct BgDblueElevator; typedef void (*BgDblueElevatorActionFunc)(struct BgDblueElevator*, PlayState*); typedef struct BgDblueElevator { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgDblueElevatorActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x10]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x18]; + /* 0x15C */ BgDblueElevatorActionFunc actionFunc; + /* 0x160 */ char unk_160[0x10]; } BgDblueElevator; // size = 0x170 extern const ActorInit Bg_Dblue_Elevator_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h index 24bd8e91a..c02b82619 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h @@ -11,21 +11,21 @@ typedef void (*BgDblueWaterfallActionFunc)(struct BgDblueWaterfall*, PlayState*) #define BGDBLUEWATERFALL_GET_100(thisx) (((thisx)->params >> 8) & 1) typedef struct BgDblueWaterfall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ AnimatedMaterial* unk_190; - /* 0x0194 */ BgDblueWaterfallActionFunc actionFunc; - /* 0x0198 */ f32 unk_198; - /* 0x019C */ s16 unk_19C; - /* 0x019E */ u8 unk_19E; - /* 0x019F */ u8 unk_19F; - /* 0x01A0 */ u8 unk_1A0; - /* 0x01A1 */ UNK_TYPE1 unk1A1[2]; - /* 0x01A3 */ s8 unk_1A3; - /* 0x01A4 */ s16 unk_1A4; - /* 0x01A6 */ UNK_TYPE1 unk1A6[1]; - /* 0x01A7 */ s8 unk_1A7; - /* 0x01A8 */ f32 unk_1A8; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ AnimatedMaterial* unk_190; + /* 0x194 */ BgDblueWaterfallActionFunc actionFunc; + /* 0x198 */ f32 unk_198; + /* 0x19C */ s16 unk_19C; + /* 0x19E */ u8 unk_19E; + /* 0x19F */ u8 unk_19F; + /* 0x1A0 */ u8 unk_1A0; + /* 0x1A1 */ UNK_TYPE1 unk1A1[2]; + /* 0x1A3 */ s8 unk_1A3; + /* 0x1A4 */ s16 unk_1A4; + /* 0x1A6 */ UNK_TYPE1 unk1A6[1]; + /* 0x1A7 */ s8 unk_1A7; + /* 0x1A8 */ f32 unk_1A8; } BgDblueWaterfall; // size = 0x1AC extern const ActorInit Bg_Dblue_Waterfall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.h b/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.h index e1bf88347..c4d824dc0 100644 --- a/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.h +++ b/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.h @@ -8,10 +8,10 @@ struct BgDkjailIvy; typedef void (*BgDkjailIvyActionFunc)(struct BgDkjailIvy*, PlayState*); typedef struct BgDkjailIvy { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; - /* 0x01A8 */ BgDkjailIvyActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x64]; + /* 0x1A8 */ BgDkjailIvyActionFunc actionFunc; + /* 0x1AC */ char unk_1AC[0x4]; } BgDkjailIvy; // size = 0x1B0 extern const ActorInit Bg_Dkjail_Ivy_InitVars; diff --git a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h index 66c6e00c0..df21bf933 100644 --- a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h +++ b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h @@ -11,12 +11,12 @@ typedef void (*BgF40BlockActionFunc)(struct BgF40Block*, PlayState*); #define BGF40BLOCK_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) typedef struct BgF40Block { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ Path* path; - /* 0x0160 */ s32 unk_160; - /* 0x0164 */ s32 unk_164; - /* 0x0168 */ s32 unk_168; - /* 0x016C */ BgF40BlockActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ Path* path; + /* 0x160 */ s32 unk_160; + /* 0x164 */ s32 unk_164; + /* 0x168 */ s32 unk_168; + /* 0x16C */ BgF40BlockActionFunc actionFunc; } BgF40Block; // size = 0x170 extern const ActorInit Bg_F40_Block_InitVars; diff --git a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c index 4e323cbf9..3974b2fc5 100644 --- a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c +++ b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c @@ -5,6 +5,7 @@ */ #include "z_bg_f40_flift.h" +#include "objects/object_f40_obj/object_f40_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,9 @@ void BgF40Flift_Destroy(Actor* thisx, PlayState* play); void BgF40Flift_Update(Actor* thisx, PlayState* play); void BgF40Flift_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_808D75F0(BgF40Flift* this, PlayState* play); +void func_808D7714(BgF40Flift* this, PlayState* play); + const ActorInit Bg_F40_Flift_InitVars = { ACTOR_BG_F40_FLIFT, ACTORCAT_BG, @@ -28,28 +31,65 @@ const ActorInit Bg_F40_Flift_InitVars = { (ActorFunc)BgF40Flift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808D7830[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 5000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgF40Flift_Init(Actor* thisx, PlayState* play) { + BgF40Flift* this = THIS; -extern InitChainEntry D_808D7830[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_f40_obj_Colheader_004240); + this->dyna.actor.params = 1; + this->actionFunc = func_808D75F0; +} -extern UNK_TYPE D_06004038; -extern UNK_TYPE D_06004240; +void BgF40Flift_Destroy(Actor* thisx, PlayState* play) { + BgF40Flift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/BgF40Flift_Init.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/BgF40Flift_Destroy.s") +void func_808D75F0(BgF40Flift* this, PlayState* play) { + if (((this->dyna.actor.params == 1) && (DynaPolyActor_IsInRidingMovingState(&this->dyna))) || + ((this->dyna.actor.params == -1) && (!DynaPolyActor_IsInRidingMovingState(&this->dyna)))) { + this->timer = 96; + this->actionFunc = func_808D7714; + } else { + if (this->timer == 0) { + this->timer = 48; + } + this->timer--; + if (this->dyna.actor.params == 1) { + this->dyna.actor.world.pos.y = (sin_rad(this->timer * (M_PI / 24.0f)) * 5.0f) + this->dyna.actor.home.pos.y; + } else { + this->dyna.actor.world.pos.y = + (sin_rad(this->timer * (M_PI / 24.0f)) * 5.0f) + (926.8f + this->dyna.actor.home.pos.y); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/func_808D75F0.s") +void func_808D7714(BgF40Flift* this, PlayState* play) { + if (this->timer != 0) { + this->timer--; + this->dyna.actor.world.pos.y = + (((cos_rad(this->timer * (M_PI / 96.0f)) * this->dyna.actor.params) + 1.0f) * 463.4f) + + this->dyna.actor.home.pos.y; + } else { + this->dyna.actor.params = -this->dyna.actor.params; + this->actionFunc = func_808D75F0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/func_808D7714.s") +void BgF40Flift_Update(Actor* thisx, PlayState* play) { + BgF40Flift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/BgF40Flift_Update.s") + this->actionFunc(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Flift/BgF40Flift_Draw.s") +void BgF40Flift_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_f40_obj_DL_004038); +} diff --git a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.h b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.h index 5aa6b4660..95b2e9073 100644 --- a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.h +++ b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.h @@ -8,10 +8,9 @@ struct BgF40Flift; typedef void (*BgF40FliftActionFunc)(struct BgF40Flift*, PlayState*); typedef struct BgF40Flift { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgF40FliftActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgF40FliftActionFunc actionFunc; + /* 0x160 */ s32 timer; } BgF40Flift; // size = 0x164 extern const ActorInit Bg_F40_Flift_InitVars; diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c index eac1f00e3..7838dadb7 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c @@ -50,7 +50,7 @@ void BgF40Switch_CheckAll(BgF40Switch* this, PlayState* play) { s32 isPressed; Actor* actor; BgF40Switch* actorAsSwitch; - u32 inCsMode = Player_InCsMode(&play->state); + u32 inCsMode = Player_InCsMode(play); for (actor = play->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->dyna.actor.room && actor->update != NULL) { diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h index 672a3132e..b0fe89341 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h @@ -10,14 +10,14 @@ struct BgF40Switch; typedef void (*BgF40SwitchActionFunc)(struct BgF40Switch*, PlayState*); typedef struct BgF40Switch { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ s16 switchReleaseDelay; // frames until a pressed switch becomes released if nothing is still pressing it - /* 0x015E */ s8 isPressed; // Logical state of the switch (pressed or unpressed). Animation state may lag behind this slightly. - /* 0x015F */ s8 wasPressed; // used as temporary during update function + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s16 switchReleaseDelay; // frames until a pressed switch becomes released if nothing is still pressing it + /* 0x15E */ s8 isPressed; // Logical state of the switch (pressed or unpressed). Animation state may lag behind this slightly. + /* 0x15F */ s8 wasPressed; // used as temporary during update function // true if this switch is the one that initiated a state change; false if this switch is changing as a result of another switch tied to the same flag. // this is a temporary flag related to something currently happening, not a permanent property of the switch. - /* 0x0160 */ s8 isInitiator; - /* 0x0164 */ BgF40SwitchActionFunc actionFunc; + /* 0x160 */ s8 isInitiator; + /* 0x164 */ BgF40SwitchActionFunc actionFunc; } BgF40Switch; // size = 0x168 extern const ActorInit Bg_F40_Switch_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c index 9e87d66bb..1ad295e68 100644 --- a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c +++ b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c @@ -5,6 +5,8 @@ */ #include "z_bg_fire_wall.h" +#include "objects/object_fwall/object_fwall.h" +#include "overlays/actors/ovl_En_Encount4/z_en_encount4.h" #define FLAGS 0x00000000 @@ -12,14 +14,13 @@ void BgFireWall_Init(Actor* thisx, PlayState* play); void BgFireWall_Destroy(Actor* thisx, PlayState* play); -void BgFireWall_Update(Actor* thisx, PlayState* play); +void BgFireWall_Update(Actor* thisx, PlayState* play2); +void BgFireWall_Draw(Actor* thisx, PlayState* play); void func_809AC638(BgFireWall* this, PlayState* play); void func_809AC68C(BgFireWall* this, PlayState* play); void func_809AC6C0(BgFireWall* this, PlayState* play); -void func_809AC970(BgFireWall* this, PlayState* play); -#if 0 const ActorInit Bg_Fire_Wall_InitVars = { ACTOR_BG_FIRE_WALL, ACTORCAT_BG, @@ -32,41 +33,184 @@ const ActorInit Bg_Fire_Wall_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809ACC60 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x01, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, { 34, 85, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_809ACC8C = { 1, 80, 100, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 80, 100, MASS_IMMOVABLE }; -#endif +static TexturePtr sFlameTextures[] = { + gFwallFireball0Tex, gFwallFireball1Tex, gFwallFireball2Tex, gFwallFireball3Tex, + gFwallFireball4Tex, gFwallFireball5Tex, gFwallFireball6Tex, gFwallFireball7Tex, +}; -extern ColliderCylinderInit D_809ACC60; -extern CollisionCheckInfoInit D_809ACC8C; +void BgFireWall_Init(Actor* thisx, PlayState* play) { + BgFireWall* this = THIS; -extern UNK_TYPE D_06000040; + this->unk_14C = this->actor.params; + this->actor.scale.y = 0.005f; + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + this->actor.scale.z = 0.12f; + this->actor.scale.x = 0.12f; + this->unk_15C = 0.09f; + this->unk_158 = 0.1f; + this->unk_160 = 300.0f; + this->texIndex = Rand_S16Offset(0, ARRAY_COUNT(sFlameTextures) - 1); + this->actor.flags |= ACTOR_FLAG_10; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->actionFunc = func_809AC638; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/BgFireWall_Init.s") +void BgFireWall_Destroy(Actor* thisx, PlayState* play) { + BgFireWall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/BgFireWall_Destroy.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC5C0.s") +s32 func_809AC5C0(BgFireWall* thisx, PlayState* play) { + BgFireWall* this = THIS; + Player* player = GET_PLAYER(play); + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC638.s") + Actor_OffsetOfPointInActorCoords(&this->actor, &sp1C, &player->actor.world.pos); + if ((fabsf(sp1C.x) < this->unk_160) && (fabsf(sp1C.z) < (this->unk_160 + 20.0f))) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC68C.s") +void func_809AC638(BgFireWall* this, PlayState* play) { + if ((this->unk_14C != 0) || (func_809AC5C0(this, play))) { + this->actor.draw = BgFireWall_Draw; + this->timer = 5; + this->actionFunc = func_809AC68C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC6C0.s") +void func_809AC68C(BgFireWall* this, PlayState* play) { + if (this->timer != 0) { + this->timer--; + } + if (this->timer == 0) { + this->actionFunc = func_809AC6C0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC760.s") +void func_809AC6C0(BgFireWall* this, PlayState* play) { + if ((this->unk_14C != 0) || (func_809AC5C0(this, play))) { + this->unk_15C = 0.09f; + Math_StepToF(&this->actor.scale.y, this->unk_15C + this->unk_154, this->unk_158); + } else if (Math_StepToF(&this->actor.scale.y, 0.005f, this->unk_158)) { + this->actionFunc = func_809AC638; + } else { + this->timer = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC7F8.s") +void func_809AC760(BgFireWall* this, PlayState* play) { + s16 phi_a3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC970.s") + if (Actor_IsFacingPlayer(&this->actor, 0x4000)) { + phi_a3 = this->actor.shape.rot.y; + } else { + phi_a3 = (this->actor.shape.rot.y + 0x8000); + } + func_800B8D98(play, &this->actor, BREG(48) + 10.0f, phi_a3, BREG(49) + 5.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/BgFireWall_Update.s") +void func_809AC7F8(BgFireWall* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f sp38; + f32 val = 25.0f; + f32 sin; + f32 cos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809ACB28.s") + Actor_OffsetOfPointInActorCoords(&this->actor, &sp38, &player->actor.world.pos); + sp38.x = CLAMP(sp38.x, -80.0f, 80.0f); + + if (this->step == 0) { + if (sp38.z > 0.0f) { + sp38.z = -val; + this->step = -1.0f; + } else { + sp38.z = val; + this->step = 1.0f; + } + } else { + sp38.z = this->step * 25.0f; + } + + sin = Math_SinS(this->actor.shape.rot.y); + cos = Math_CosS(this->actor.shape.rot.y); + this->collider.dim.pos.x = this->actor.world.pos.x + (sp38.x * cos) + (sp38.z * sin); + this->collider.dim.pos.z = this->actor.world.pos.z - (sp38.x * sin) + (sp38.z * cos); +} + +void func_809AC970(BgFireWall* this, PlayState* play) { + if (Math_StepToF(&this->actor.scale.y, 0.005f, this->unk_158)) { + Actor_MarkForDeath(&this->actor); + } +} + +void BgFireWall_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + BgFireWall* this = THIS; + + this->actionFunc(this, play); + if ((this->unk_14C == 0) || ((this->unk_14C != 0) && (this->actor.xzDistToPlayer < 240.0f))) { + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + func_809AC760(this, play); + } + } + if (this->actionFunc == func_809AC6C0) { + func_800B9010(&this->actor, NA_SE_EV_FIRE_PLATE - SFX_FLAG); + if ((this->unk_14C == 0) || ((this->unk_14C != 0) && (this->actor.xzDistToPlayer < 240.0f))) { + func_809AC7F8(this, play); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } + } + this->texIndex = (this->texIndex + 1) % ARRAY_COUNT(sFlameTextures); + if (this->actionFunc != func_809AC970) { + if (this->actor.parent != NULL) { + EnEncount4* parent = (EnEncount4*)this->actor.parent; + if ((parent->actor.update != NULL) && (parent->unk_150 != 0)) { + this->actionFunc = func_809AC970; + } + } + } +} + +void BgFireWall_Draw(Actor* thisx, PlayState* play) { + BgFireWall* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sFlameTextures[this->texIndex])); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x01, 255, 255, 0, 150); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 255); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_fwall_DL_000040); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h index d1d21f303..018e9f5f1 100644 --- a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h +++ b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h @@ -8,9 +8,17 @@ struct BgFireWall; typedef void (*BgFireWallActionFunc)(struct BgFireWall*, PlayState*); typedef struct BgFireWall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ BgFireWallActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x68]; + /* 0x000 */ Actor actor; + /* 0x144 */ BgFireWallActionFunc actionFunc; + /* 0x148 */ s16 texIndex; + /* 0x14A */ s16 timer; + /* 0x14C */ s16 unk_14C; + /* 0x150 */ f32 step; + /* 0x154 */ f32 unk_154; + /* 0x158 */ f32 unk_158; + /* 0x15C */ f32 unk_15C; + /* 0x160 */ f32 unk_160; + /* 0x164 */ ColliderCylinder collider; } BgFireWall; // size = 0x1B0 extern const ActorInit Bg_Fire_Wall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c index 2681d9292..c485927ce 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c +++ b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c @@ -5,6 +5,7 @@ */ #include "z_bg_fu_mizu.h" +#include "objects/object_fu_kaiten/object_fu_kaiten.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,6 @@ void BgFuMizu_Destroy(Actor* thisx, PlayState* play); void BgFuMizu_Update(Actor* thisx, PlayState* play); void BgFuMizu_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Bg_Fu_Mizu_InitVars = { ACTOR_BG_FU_MIZU, ACTORCAT_BG, @@ -28,17 +28,68 @@ const ActorInit Bg_Fu_Mizu_InitVars = { (ActorFunc)BgFuMizu_Draw, }; -#endif +void BgFuMizu_Init(Actor* thisx, PlayState* play) { + BgFuMizu* this = THIS; + s32 pad; + CollisionHeader* colHeader = NULL; -extern UNK_TYPE D_060037D8; -extern UNK_TYPE D_060037F8; + Actor_SetScale(&this->dyna.actor, 1.0f); + DynaPolyActor_Init(&this->dyna, 1); + CollisionHeader_GetVirtual(&object_fu_kaiten_Colheader_0037F8, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + this->unk_160 = 0; + this->dyna.actor.world.pos.y = -10.0f + this->dyna.actor.home.pos.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fu_Mizu/BgFuMizu_Init.s") +void BgFuMizu_Destroy(Actor* thisx, PlayState* play) { + BgFuMizu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fu_Mizu/BgFuMizu_Destroy.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fu_Mizu/func_80ADABA4.s") +s32 func_80ADABA4(BgFuMizu* this, PlayState* play) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_BG].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fu_Mizu/BgFuMizu_Update.s") + while (actor != NULL) { + if ((actor != NULL) && (actor->id == ACTOR_EN_FU_KAGO) && (actor->colChkInfo.health == 0)) { + return false; + } + actor = actor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fu_Mizu/BgFuMizu_Draw.s") + return true; +} + +void BgFuMizu_Update(Actor* thisx, PlayState* play) { + f32 heightTarget; + BgFuMizu* this = THIS; + + if (this->unk_160 == 0) { + if (func_80ADABA4(this, play)) { + heightTarget = -10.0f + this->dyna.actor.home.pos.y; + } else { + heightTarget = 10.0f + this->dyna.actor.home.pos.y; + } + } else { + heightTarget = 25.0f + this->dyna.actor.home.pos.y; + } + if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, heightTarget, 0.05f, 1.0f, 0.5f) > 1.0f) { + if (this->unk_160 == 1) { + func_800B9010(&this->dyna.actor, NA_SE_EV_WATER_LEVEL_DOWN_FIX - SFX_FLAG); + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_WATER_LEVEL_DOWN_FIX - SFX_FLAG); + } + } +} + +void BgFuMizu_Draw(Actor* thisx, PlayState* play) { + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_fu_kaiten_Matanimheader_0037D8)); + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_fu_kaiten_DL_002FC0); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h index ffb4cc8d8..89b1df323 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h +++ b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h @@ -6,8 +6,8 @@ struct BgFuMizu; typedef struct BgFuMizu { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x1C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ UNK_TYPE1 pad15C[0x4]; /* 0x160 */ s16 unk_160; } BgFuMizu; // size = 0x164 diff --git a/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c b/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c index af246eafe..f494131d9 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c @@ -5,6 +5,7 @@ */ #include "z_bg_haka_bombwall.h" +#include "objects/object_haka_obj/object_haka_obj.h" #define FLAGS 0x00000000 @@ -15,7 +16,14 @@ void BgHakaBombwall_Destroy(Actor* thisx, PlayState* play); void BgHakaBombwall_Update(Actor* thisx, PlayState* play); void BgHakaBombwall_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_80BD5E6C(BgHakaBombwall* this, PlayState* play); +void func_80BD6260(BgHakaBombwall* this); +void func_80BD6274(BgHakaBombwall* this, PlayState* play); +void BgHakaBombwall_SetupPlayCutscene(BgHakaBombwall* this); +void BgHakaBombwall_PlayCutscene(BgHakaBombwall* this, PlayState* play); +void BgHakaBombwall_SetupEndCutscene(BgHakaBombwall* this); +void BgHakaBombwall_EndCutscene(BgHakaBombwall* this, PlayState* play); + const ActorInit Bg_Haka_Bombwall_InitVars = { ACTOR_BG_HAKA_BOMBWALL, ACTORCAT_BG, @@ -28,50 +36,191 @@ const ActorInit Bg_Haka_Bombwall_InitVars = { (ActorFunc)BgHakaBombwall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD64A0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 80, 80, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BD64D4[] = { +static s16 D_80BD64CC[4] = { 24, 15, 10, 5 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; +s32 func_80BD5E00(BgHakaBombwall* this) { + if (this->collider.base.acFlags & AC_HIT) { + if ((this->collider.base.ac != NULL) && + (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < SQ(80.0f))) { + return true; + } + } + return false; +} + +#ifdef NON_MATCHING +void func_80BD5E6C(BgHakaBombwall* this, PlayState* play) { + s32 i; + Vec3f spE0; + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + f32 temp_fs0; + f32 phi_fs1; + s16 phi_s0; + s16 gravity; + s16 phi_t0; + + Matrix_Push(); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + temp_fs0 = 0.0f; + phi_fs1 = 0.0f; + + for (i = 0; i < 30; i++) { + temp_fs0 += 60.0f + (Rand_ZeroOne() * 20.0f); + if (temp_fs0 > 75.0f) { + temp_fs0 -= 150.0f; + } + spC8.x = temp_fs0; + + phi_fs1 += 5; + spC8.y = phi_fs1; + + spC8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; + + spBC.x = ((Rand_ZeroOne() - 0.5f) * 5.0f) + (temp_fs0 * (4.0f / 75.0f)); + spBC.y = (Rand_ZeroOne() * 7.0f) - 2.0f; + spBC.z = (Rand_ZeroOne() * 4.0f) - 2.0f; + + Matrix_MultVec3f(&spC8, &spE0); + Matrix_MultVec3f(&spBC, &spD4); + + spE0.x += this->dyna.actor.world.pos.x; + spE0.y += this->dyna.actor.world.pos.y; + spE0.z += this->dyna.actor.world.pos.z; + + if ((i & 3) == 0) { + phi_s0 = 32; + func_800BBFB0(play, &spE0, 60.0f, 2, 100, 120, 1); + } else { + phi_s0 = 64; + } + + if (i % 2 != 0) { + phi_s0 |= 1; + phi_t0 = 1; + } else { + phi_t0 = 0; + } + + if (D_80BD64CC[i & 3] >= 16) { + gravity = -550; + } else { + gravity = -450; + } + + EffectSsKakera_Spawn(play, &spE0, &spD4, &spE0, gravity, phi_s0, 30, 0, 0, D_80BD64CC[i & 3], phi_t0, 0, 50, -1, + OBJECT_IKANA_OBJ, object_haka_obj_DL_001680); + } + + Matrix_Pop(); +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD5E6C.s") #endif -extern ColliderCylinderInit D_80BD64A0; -extern InitChainEntry D_80BD64D4[]; +void BgHakaBombwall_Init(Actor* thisx, PlayState* play) { + s32 pad; + BgHakaBombwall* this = THIS; -extern UNK_TYPE D_06000040; -extern UNK_TYPE D_06000148; -extern UNK_TYPE D_06001680; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + Collider_InitCylinder(play, &this->collider); + if (Flags_GetSwitch(play, BGHAKABOMBWALL_GET_7F(thisx))) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + DynaPolyActor_LoadMesh(play, &this->dyna, &object_haka_obj_Colheader_000148); + Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + func_80BD6260(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD5E00.s") +void BgHakaBombwall_Destroy(Actor* thisx, PlayState* play) { + BgHakaBombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD5E6C.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/BgHakaBombwall_Init.s") +void func_80BD6260(BgHakaBombwall* this) { + this->actionFunc = func_80BD6274; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/BgHakaBombwall_Destroy.s") +void func_80BD6274(BgHakaBombwall* this, PlayState* play) { + if (func_80BD5E00(this)) { + BgHakaBombwall_SetupPlayCutscene(this); + } else { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD6260.s") +void BgHakaBombwall_SetupPlayCutscene(BgHakaBombwall* this) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = BgHakaBombwall_PlayCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD6274.s") +void BgHakaBombwall_PlayCutscene(BgHakaBombwall* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + func_80BD5E6C(this, play); + this->dyna.actor.draw = NULL; + Flags_SetSwitch(play, BGHAKABOMBWALL_GET_7F(&this->dyna.actor)); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 0x3C, NA_SE_EV_WALL_BROKEN); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + BgHakaBombwall_SetupEndCutscene(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD62D0.s") +void BgHakaBombwall_SetupEndCutscene(BgHakaBombwall* this) { + this->csTimer = 30; + this->actionFunc = BgHakaBombwall_EndCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD6314.s") +void BgHakaBombwall_EndCutscene(BgHakaBombwall* this, PlayState* play) { + this->csTimer--; + if (this->csTimer <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD63B4.s") +void BgHakaBombwall_Update(Actor* thisx, PlayState* play) { + BgHakaBombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD63D0.s") + this->actionFunc(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/BgHakaBombwall_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/BgHakaBombwall_Draw.s") +void BgHakaBombwall_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_haka_obj_DL_000040); +} diff --git a/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.h b/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.h index aef2e5aaf..6a37e3625 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.h @@ -3,15 +3,17 @@ #include "global.h" +#define BGHAKABOMBWALL_GET_7F(thisx) ((thisx)->params & 0x7F) + struct BgHakaBombwall; typedef void (*BgHakaBombwallActionFunc)(struct BgHakaBombwall*, PlayState*); typedef struct BgHakaBombwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; - /* 0x01A8 */ BgHakaBombwallActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ BgHakaBombwallActionFunc actionFunc; + /* 0x1AC */ s8 csTimer; } BgHakaBombwall; // size = 0x1B0 extern const ActorInit Bg_Haka_Bombwall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c index c856edb3a..37a232bc5 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c @@ -20,8 +20,8 @@ void func_80ABBFC0(BgHakuginBombwall* this, PlayState* play); void func_80ABC2E0(BgHakuginBombwall* this, PlayState* play); void func_80ABC58C(BgHakuginBombwall* this, PlayState* play); void func_80ABC7FC(BgHakuginBombwall* this, PlayState* play); -s32 func_80ABCB5C(Actor* thisx, PlayState* play); -s32 func_80ABCC00(Actor* thisx, PlayState* play); +s32 func_80ABCB5C(BgHakuginBombwall* this, PlayState* play); +s32 func_80ABCC00(BgHakuginBombwall* this, PlayState* play); void func_80ABCCE4(BgHakuginBombwall* this, PlayState* play); void func_80ABCD98(BgHakuginBombwall* this, PlayState* play); void func_80ABCE60(BgHakuginBombwall* this, PlayState* play); @@ -342,15 +342,14 @@ void BgHakuginBombwall_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -s32 func_80ABCB5C(Actor* thisx, PlayState* play) { - BgHakuginBombwall* this = THIS; - s32 pad; +s32 func_80ABCB5C(BgHakuginBombwall* this, PlayState* play) { + Actor* thisx = &this->dyna.actor; if (this->collider.base.acFlags & AC_HIT) { if (this->collider.base.ac != NULL) { - if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < - D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)].unk_1C) { - SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); + if (Math3D_Vec3fDistSq(&thisx->world.pos, &this->collider.base.ac->world.pos) < + D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(thisx)].unk_1C) { + SoundSource_PlaySfxAtFixedWorldPos(play, &thisx->world.pos, 60, NA_SE_EV_WALL_BROKEN); return true; } } @@ -358,13 +357,12 @@ s32 func_80ABCB5C(Actor* thisx, PlayState* play) { return false; } -s32 func_80ABCC00(Actor* thisx, PlayState* play) { - BgHakuginBombwall* this = THIS; - s32 pad; - +s32 func_80ABCC00(BgHakuginBombwall* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { if (this->collider.info.acHitInfo->toucher.dmgFlags & 8) { if (this->collider.base.ac != NULL) { + s32 requiredScopeTemp; + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)].unk_1C) { SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 50, NA_SE_EV_WALL_BROKEN); @@ -372,7 +370,6 @@ s32 func_80ABCC00(Actor* thisx, PlayState* play) { } } } else if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { - label:; SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 50, NA_SE_EV_WALL_BROKEN); return true; } @@ -383,7 +380,7 @@ s32 func_80ABCC00(Actor* thisx, PlayState* play) { void func_80ABCCE4(BgHakuginBombwall* this, PlayState* play) { BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; - if (ptr->unk_20(&this->dyna.actor, play)) { + if (ptr->unk_20(this, play)) { this->dyna.actor.flags |= ACTOR_FLAG_10; ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); this->actionFunc = func_80ABCD98; diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h index 9c1da4a06..f849b356f 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h @@ -6,7 +6,7 @@ struct BgHakuginBombwall; typedef void (*BgHakuginBombwallActionFunc)(struct BgHakuginBombwall*, PlayState*); -typedef s32 (*BgHakuginBombwallUnkFunc)(Actor*, PlayState*); +typedef s32 (*BgHakuginBombwallUnkFunc)(struct BgHakuginBombwall*, PlayState*); typedef void (*BgHakuginBombwallUnkFunc2)(struct BgHakuginBombwall*, PlayState*); #define BGHAKUGIN_BOMBWALL_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.h b/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.h index 7662ab638..777c49864 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.h @@ -8,9 +8,9 @@ struct BgHakuginElvpole; typedef void (*BgHakuginElvpoleActionFunc)(struct BgHakuginElvpole*, PlayState*); typedef struct BgHakuginElvpole { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x20]; - /* 0x0164 */ BgHakuginElvpoleActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x20]; + /* 0x164 */ BgHakuginElvpoleActionFunc actionFunc; } BgHakuginElvpole; // size = 0x168 extern const ActorInit Bg_Hakugin_Elvpole_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h index 7ecae1ea8..8e702a006 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h @@ -48,26 +48,26 @@ typedef struct { } BgHakuginPostUnkStruct; // size = 0x1928 typedef struct { - /* 0x0000 */ ColliderCylinder colliders[8]; - /* 0x0260 */ s32 count; + /* 0x000 */ ColliderCylinder colliders[8]; + /* 0x260 */ s32 count; } BgHakuginPostColliders; // size = 0x264 typedef struct BgHakuginPost { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ BgHakuginPostActionFunc actionFunc; - /* 0x0160 */ f32 unk_160; - /* 0x0164 */ f32 unk_164; - /* 0x0168 */ f32 unk_168; - /* 0x016C */ f32 unk_16C; - /* 0x0170 */ s32 unk_170; - /* 0x0174 */ s32 unk_174; - /* 0x0178 */ s8 unk_178; - /* 0x0179 */ s8 unk_179; - /* 0x017C */ BgHakuginPostFunc unkFunc; - /* 0x0180 */ s16 unk_180; - /* 0x0182 */ s16 unk_182; - /* 0x0184 */ s16 unk_184; - /* 0x0186 */ s16 unk_186; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgHakuginPostActionFunc actionFunc; + /* 0x160 */ f32 unk_160; + /* 0x164 */ f32 unk_164; + /* 0x168 */ f32 unk_168; + /* 0x16C */ f32 unk_16C; + /* 0x170 */ s32 unk_170; + /* 0x174 */ s32 unk_174; + /* 0x178 */ s8 unk_178; + /* 0x179 */ s8 unk_179; + /* 0x17C */ BgHakuginPostFunc unkFunc; + /* 0x180 */ s16 unk_180; + /* 0x182 */ s16 unk_182; + /* 0x184 */ s16 unk_184; + /* 0x186 */ s16 unk_186; } BgHakuginPost; // size = 0x188 extern const ActorInit Bg_Hakugin_Post_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h index e4a5928f6..74757f836 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h @@ -15,21 +15,21 @@ typedef void (*BgHakuginSwitchUnkFunc)(struct BgHakuginSwitch*, PlayState*); #define BGHAKUGINSWITCH_GET_7_1 1 typedef struct BgHakuginSwitch { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ Gfx* unk_1A8; - /* 0x01AC */ BgHakuginSwitchActionFunc actionFunc; - /* 0x01B0 */ s16 unk_1B0; - /* 0x01B2 */ s8 unk_1B2; - /* 0x01B4 */ BgHakuginSwitchUnkFunc unk_1B4; - /* 0x01B8 */ s16 unk_1B8; - /* 0x01BA */ s16 unk_1BA; - /* 0x01BC */ s16 unk_1BC; - /* 0x01BE */ s8 unk_1BE; - /* 0x01BF */ s8 unk_1BF; - /* 0x01C0 */ s8 unk_1C0; - /* 0x01C4 */ f32 unk_1C4; - /* 0x01C8 */ f32 unk_1C8; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ Gfx* unk_1A8; + /* 0x1AC */ BgHakuginSwitchActionFunc actionFunc; + /* 0x1B0 */ s16 unk_1B0; + /* 0x1B2 */ s8 unk_1B2; + /* 0x1B4 */ BgHakuginSwitchUnkFunc unk_1B4; + /* 0x1B8 */ s16 unk_1B8; + /* 0x1BA */ s16 unk_1BA; + /* 0x1BC */ s16 unk_1BC; + /* 0x1BE */ s8 unk_1BE; + /* 0x1BF */ s8 unk_1BF; + /* 0x1C0 */ s8 unk_1C0; + /* 0x1C4 */ f32 unk_1C4; + /* 0x1C8 */ f32 unk_1C8; } BgHakuginSwitch; // size = 0x1CC extern const ActorInit Bg_Hakugin_Switch_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c index 68e824f4a..e64cbef70 100644 --- a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c +++ b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c @@ -5,6 +5,7 @@ */ #include "z_bg_icefloe.h" +#include "objects/object_icefloe/object_icefloe.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,13 @@ void BgIcefloe_Destroy(Actor* thisx, PlayState* play); void BgIcefloe_Update(Actor* thisx, PlayState* play); void BgIcefloe_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_80AC4A80(BgIcefloe* this, PlayState* play); +void BgIcefloe_Grow(BgIcefloe* this, PlayState* play); +void func_80AC4C18(BgIcefloe* this); +void func_80AC4D2C(BgIcefloe* this, PlayState* play); +void func_80AC4C34(BgIcefloe* this, PlayState* play); +void func_80AC4CF0(BgIcefloe* this); + const ActorInit Bg_Icefloe_InitVars = { ACTOR_BG_ICEFLOE, ACTORCAT_BG, @@ -27,35 +34,144 @@ const ActorInit Bg_Icefloe_InitVars = { (ActorFunc)BgIcefloe_Update, (ActorFunc)BgIcefloe_Draw, }; +static BgIcefloe* sSpawnedInstances[] = { NULL, NULL, NULL }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AC4F3C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 0, ICHAIN_STOP), }; -#endif +static s32 numberSpawned; -extern InitChainEntry D_80AC4F3C[]; +void BgIcefloe_Init(Actor* thisx, PlayState* play) { + BgIcefloe* this = THIS; -extern UNK_TYPE D_060001E0; -extern UNK_TYPE D_06000C90; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, &gIcefloePlatformCol); + if (numberSpawned >= ARRAY_COUNT(sSpawnedInstances)) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/BgIcefloe_Init.s") + if ((sSpawnedInstances[0] != NULL) && (sSpawnedInstances[0]->dyna.actor.update != NULL) && + (sSpawnedInstances[0]->actionFunc != func_80AC4D2C)) { + func_80AC4CF0(sSpawnedInstances[0]); + } + for (i = 0; i < ARRAY_COUNT(sSpawnedInstances) - 1; i++) { + sSpawnedInstances[i] = sSpawnedInstances[i + 1]; + } + sSpawnedInstances[ARRAY_COUNT(sSpawnedInstances) - 1] = this; + } else { + sSpawnedInstances[numberSpawned] = this; + } + numberSpawned++; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 10.0f; + func_80AC4A80(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/BgIcefloe_Destroy.s") +void BgIcefloe_Destroy(Actor* thisx, PlayState* play) { + BgIcefloe* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/func_80AC4A80.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + numberSpawned--; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/func_80AC4AE8.s") + for (i = 0; i < 3; i++) { + if (sSpawnedInstances[i] == this) { + sSpawnedInstances[i] = NULL; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/func_80AC4C18.s") +void func_80AC4A80(BgIcefloe* this, PlayState* play) { + this->timer = 20; + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &this->dyna.actor.world.pos, &this->dyna.actor.projectedPos, + &this->dyna.actor.projectedW); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_ICE_STAND_APPEAR); + this->actionFunc = BgIcefloe_Grow; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/func_80AC4C34.s") +static Vec3f sIceBlockAccel = { 0.0f, -0.5f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/func_80AC4CF0.s") +void BgIcefloe_Grow(BgIcefloe* this, PlayState* play) { + Vec3f velocity; + Vec3f position; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/func_80AC4D2C.s") + velocity.x = randPlusMinusPoint5Scaled(6.0f); + velocity.z = randPlusMinusPoint5Scaled(6.0f); + velocity.y = Rand_ZeroFloat(4.0f) + 4.0f; + this->dyna.actor.scale.x += (0.65f * 0.01f); + this->dyna.actor.scale.z += (0.65f * 0.01f); + this->dyna.actor.scale.y += (0.65f * 0.01f); + position.x = this->dyna.actor.world.pos.x + (velocity.x * this->dyna.actor.scale.x * 75.0f); + position.z = this->dyna.actor.world.pos.z + (velocity.z * this->dyna.actor.scale.z * 75.0f); + position.y = this->dyna.actor.world.pos.y + (300.0f * this->dyna.actor.scale.y); + EffectSsIceBlock_Spawn(play, &position, &velocity, &sIceBlockAccel, Rand_S16Offset(10, 10)); + this->timer--; + if (this->timer == 0) { + func_80AC4C18(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/BgIcefloe_Update.s") +void func_80AC4C18(BgIcefloe* this) { + this->timer = this->dyna.actor.params; + this->actionFunc = func_80AC4C34; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Icefloe/BgIcefloe_Draw.s") +void func_80AC4C34(BgIcefloe* this, PlayState* play) { + WaterBox* water; + + this->timer--; + if (this->timer == 0 || + !WaterBox_GetSurface1_2(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, + &this->dyna.actor.home.pos.y, &water)) { + func_80AC4CF0(this); + } else { + this->dyna.actor.world.pos.y = + (sin_rad(this->timer * (M_PI / 30.0f)) * 3.0f) + (this->dyna.actor.home.pos.y + 10.0f); + } +} + +void func_80AC4CF0(BgIcefloe* this) { + this->timer = 50; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_ICE_MELT_LEVEL); + this->actionFunc = func_80AC4D2C; +} + +void func_80AC4D2C(BgIcefloe* this, PlayState* play) { + this->timer--; + if ((this->timer >= 38) && !(this->timer % 2)) { + Vec3f velocity; + Vec3f position; + + velocity.y = (this->timer - 38) * (1 / 12.0f); + velocity.x = randPlusMinusPoint5Scaled(1.5f) * velocity.y; + velocity.z = randPlusMinusPoint5Scaled(1.5f) * velocity.y; + velocity.y += 0.8f; + position.x = this->dyna.actor.world.pos.x + (2.0f * velocity.x); + position.z = this->dyna.actor.world.pos.z + (2.0f * velocity.z); + position.y = this->dyna.actor.world.pos.y + 3.0f; + EffectSsIceSmoke_Spawn(play, &position, &velocity, &gZeroVec3f, 200); + } + if (this->timer < 25) { + this->dyna.actor.scale.x -= 0.0052f; + this->dyna.actor.scale.z -= 0.0052f; + } + this->dyna.actor.scale.y -= 0.0026f; + if (this->dyna.actor.scale.y <= 0.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgIcefloe_Update(Actor* thisx, PlayState* play) { + BgIcefloe* this = THIS; + + if (!Play_InCsMode(play)) { + this->actionFunc(this, play); + } +} + +void BgIcefloe_Draw(Actor* thisx, PlayState* play) { + BgIcefloe* this = THIS; + + Gfx_DrawDListOpa(play, gIcefloeIcePlatformDL); +} diff --git a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.h b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.h index 64f61ea2f..91c007d26 100644 --- a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.h +++ b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.h @@ -8,10 +8,9 @@ struct BgIcefloe; typedef void (*BgIcefloeActionFunc)(struct BgIcefloe*, PlayState*); typedef struct BgIcefloe { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgIcefloeActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgIcefloeActionFunc actionFunc; + /* 0x160 */ s32 timer; } BgIcefloe; // size = 0x164 extern const ActorInit Bg_Icefloe_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h index 1eba0e6b6..5c5281911 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h @@ -8,20 +8,20 @@ struct BgIkanaBlock; typedef void (*BgIkanaBlockActionFunc)(struct BgIkanaBlock*, PlayState*); typedef struct BgIkanaBlock { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ AnimatedMaterial* unk_15C; - /* 0x0160 */ BgIkanaBlockActionFunc actionFunc; - /* 0x0164 */ f32* unk_164; - /* 0x0168 */ f32 unk_168; - /* 0x016C */ f32 unk_16C; - /* 0x0170 */ f32 unk_170; - /* 0x0174 */ Vec3s unk_174; - /* 0x017A */ u8 unk_17A; - /* 0x017B */ s8 unk_17B; - /* 0x017C */ u8 unk_17C; - /* 0x017D */ s8 unk_17D; - /* 0x017E */ s8 unk_17E; - /* 0x017F */ s8 unk_17F; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ AnimatedMaterial* unk_15C; + /* 0x160 */ BgIkanaBlockActionFunc actionFunc; + /* 0x164 */ f32* unk_164; + /* 0x168 */ f32 unk_168; + /* 0x16C */ f32 unk_16C; + /* 0x170 */ f32 unk_170; + /* 0x174 */ Vec3s unk_174; + /* 0x17A */ u8 unk_17A; + /* 0x17B */ s8 unk_17B; + /* 0x17C */ u8 unk_17C; + /* 0x17D */ s8 unk_17D; + /* 0x17E */ s8 unk_17E; + /* 0x17F */ s8 unk_17F; } BgIkanaBlock; // size = 0x180 extern const ActorInit Bg_Ikana_Block_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.h b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.h index 1a5850232..da11bcfea 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.h @@ -11,10 +11,10 @@ typedef void (*BgIkanaBombwallActionFunc)(struct BgIkanaBombwall*, PlayState*); #define BGIKANABOMBWALL_GET_100(thisx) (((thisx)->params >> 8) & 1) typedef struct BgIkanaBombwall { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ BgIkanaBombwallActionFunc actionFunc; - /* 0x01AC */ s8 unk_1AC; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ BgIkanaBombwallActionFunc actionFunc; + /* 0x1AC */ s8 unk_1AC; } BgIkanaBombwall; // size = 0x1B0 extern const ActorInit Bg_Ikana_Bombwall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c index 24cb90396..e619aa7e0 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c @@ -75,7 +75,7 @@ void BgIkanaDharma_SpawnEffects(BgIkanaDharma* this, PlayState* play) { for (i = 0; i < 4; i++) { f32 speed = (Rand_ZeroOne() * 5.0f) + 5.0f; - s16 angle = ((u32)Rand_Next() >> 0x12) + this->dyna.actor.world.rot.y + 0x6000; + s16 angle = (Rand_Next() >> 0x12) + this->dyna.actor.world.rot.y + 0x6000; f32 dirX = Math_SinS(angle); f32 dirZ = Math_CosS(angle); @@ -226,7 +226,7 @@ void BgIkanaDharma_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->dyna.actor); Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); if (this->dyna.actor.bgCheckFlags & 2) { - s16 quake = Quake_Add(play->cameraPtrs[play->activeCamera], 3); + s16 quake = Quake_Add(GET_ACTIVE_CAM(play), 3); Quake_SetSpeed(quake, 21536); Quake_SetQuakeValues(quake, 4, 0, 0, 0); diff --git a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h index 11a962b4e..4642a4369 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h @@ -13,10 +13,10 @@ struct BgIkanaDharma; typedef void (*BgIkanaDharmaActionFunc)(struct BgIkanaDharma*, PlayState*); typedef struct BgIkanaDharma { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ BgIkanaDharmaActionFunc actionFunc; - /* 0x01AC */ s8 cutsceneFramesRemaining; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ BgIkanaDharmaActionFunc actionFunc; + /* 0x1AC */ s8 cutsceneFramesRemaining; } BgIkanaDharma; // size = 0x1B0 extern const ActorInit Bg_Ikana_Dharma_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c index 0a3b7b445..cfa67eb1d 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c @@ -2,9 +2,15 @@ * File: z_bg_ikana_mirror.c * Overlay: ovl_Bg_Ikana_Mirror * Description: Stone Tower Temple - Mirror + * + * This mirror absorbs light reflected by the mirror shield or by another mirror of the same kind for a + * maximum of 400 frames (20 seconds) to then release light for the same number of frames it was charged. This number + * of frames is stored in the actor struct's lightRayCharge field and is updated in the BgIkanaMirror_Wait and + * BgIkanaMirror_EmitLight functions both described below. */ #include "z_bg_ikana_mirror.h" +#include "objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +21,11 @@ void BgIkanaMirror_Destroy(Actor* thisx, PlayState* play); void BgIkanaMirror_Update(Actor* thisx, PlayState* play); void BgIkanaMirror_Draw(Actor* thisx, PlayState* play); -#if 0 +void BgIkanaMirror_SetupWait(BgIkanaMirror* this); +void BgIkanaMirror_Wait(BgIkanaMirror* this, PlayState* play); +void BgIkanaMirror_SetupEmitLight(BgIkanaMirror* this); +void BgIkanaMirror_EmitLight(BgIkanaMirror* this, PlayState* play); + const ActorInit Bg_Ikana_Mirror_InitVars = { ACTOR_BG_IKANA_MIRROR, ACTORCAT_PROP, @@ -28,99 +38,371 @@ const ActorInit Bg_Ikana_Mirror_InitVars = { (ActorFunc)BgIkanaMirror_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[9] = { -static ColliderTrisElementInit D_80B7FF50[9] = { +static ColliderTrisElementInit sMirrorColliderElementsInit[] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 21.600000381469727f, 13.699999809265137f }, { -25.299999237060547f, 6.0f, 8.399999618530273f }, { 25.299999237060547f, 6.0f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 21.6f, 13.7f }, { -25.3f, 6.0f, 8.4f }, { 25.3f, 6.0f, 8.4f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { -25.299999237060547f, 6.0f, 8.399999618530273f }, { 0.0f, 21.600000381469727f, 13.699999809265137f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { -25.3f, 6.0f, 8.4f }, { 0.0f, 21.6f, 13.7f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { 0.0f, 21.600000381469727f, 13.699999809265137f }, { 25.299999237060547f, 6.0f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { 0.0f, 21.6f, 13.7f }, { 25.3f, 6.0f, 8.4f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { -25.299999237060547f, 45.0f, 8.399999618530273f }, { -25.299999237060547f, 6.0f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { -25.3f, 45.0f, 8.4f }, { -25.3f, 6.0f, 8.4f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { 25.299999237060547f, 6.0f, 8.399999618530273f }, { 25.299999237060547f, 45.0f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { 25.3f, 6.0f, 8.4f }, { 25.3f, 45.0f, 8.4f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { -17.899999618530273f, 64.0999984741211f, 8.399999618530273f }, { -25.299999237060547f, 45.0f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { -17.9f, 64.1f, 8.4f }, { -25.3f, 45.0f, 8.4f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { 25.299999237060547f, 45.0f, 8.399999618530273f }, { 17.899999618530273f, 64.0999984741211f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { 25.3f, 45.0f, 8.4f }, { 17.9f, 64.1f, 8.4f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { 0.0f, 72.0f, 8.399999618530273f }, { -17.899999618530273f, 64.0999984741211f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { 0.0f, 72.0f, 8.4f }, { -17.9f, 64.1f, 8.4f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 0.0f, 45.0f, 13.699999809265137f }, { 17.899999618530273f, 64.0999984741211f, 8.399999618530273f }, { 0.0f, 72.0f, 8.399999618530273f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 45.0f, 13.7f }, { 17.9f, 64.1f, 8.4f }, { 0.0f, 72.0f, 8.4f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B8016C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 9, D_80B7FF50, // sTrisElementsInit, +static ColliderTrisInit sMirrorColliderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sMirrorColliderElementsInit), + sMirrorColliderElementsInit, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80B8017C = { - { COLTYPE_NONE, AT_ON | AT_TYPE_OTHER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x00200000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_NONE, }, - { { { 0.0f, 72.0f, 20.0f }, { 0.0f, 72.0f, 240.0f }, { 0.0f, 6.0f, 20.0f }, { 0.0f, 6.0f, 240.0f } } }, +static ColliderQuadInit sLightRaysCollidersInit[] = { + { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_OTHER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x00200000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 72.0f, 20.0f }, { 0.0f, 72.0f, 240.0f }, { 0.0f, 6.0f, 20.0f }, { 0.0f, 6.0f, 240.0f } } }, + }, + { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_OTHER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x00200000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 25.3f, 20.0f, 20.0f }, { 25.3f, 20.0f, 240.0f }, { -25.3f, 20.0f, 20.0f }, { -25.3f, 20.0f, 240.0f } } }, + } }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80B801FC = { - { 0x41, AT_NONE | AT_TYPE_OTHER, AC_NONE, OC1_NONE, OC2_FIRST_ONLY | OC2_UNK1 | OC2_HIT_PLAYER, 0x70, }, - { 0xC1, { 0x41A00000, 0x41, 0xA0 }, { 0xC1CA6666, 0x41, 0xA0 }, TOUCH_ON | TOUCH_HIT | TOUCH_SFX_NORMAL | TOUCH_DREW_HITMARK, BUMP_NONE | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, OCELEM_NONE, }, - { { { -1.8339854079840734e-09f, -1.8626939990440405e-09f, -1.9208972190654094e-09f }, { 221185.5625f, 0.0f, 0.003921568859368563f }, { 0.0f, 0.0f, 0.0f }, { 2.8698592549372254e-42f, 1.0761972206014595e-42f, 2.2420775429197073e-44f } } }, -}; - -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B8021C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 220, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgIkanaMirror_SetQuadVertices(BgIkanaMirror* this) { + ColliderQuadDimInit* dim; + ColliderQuad* lightRaysCollider; + Vec3f v0; + Vec3f v1; + Vec3f v2; + Vec3f v3; + s32 i; -extern ColliderTrisElementInit D_80B7FF50[9]; -extern ColliderTrisInit D_80B8016C; -extern ColliderQuadInit D_80B8017C; -extern ColliderQuadInit D_80B801FC; -extern InitChainEntry D_80B8021C[]; + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + for (i = 0; i < ARRAY_COUNT(this->lightRaysColliders); i++) { + dim = &sLightRaysCollidersInit[i].dim; + Matrix_MultVec3f(&dim->quad[0], &v0); + Matrix_MultVec3f(&dim->quad[1], &v1); + Matrix_MultVec3f(&dim->quad[2], &v2); + Matrix_MultVec3f(&dim->quad[3], &v3); + lightRaysCollider = &this->lightRaysColliders[i]; + Collider_SetQuadVertices(lightRaysCollider, &v0, &v1, &v2, &v3); + } -extern UNK_TYPE D_06001E18; -extern UNK_TYPE D_06002358; + Matrix_Pop(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/func_80B7F730.s") +void BgIkanaMirror_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + BgIkanaMirror* this = THIS; + ColliderTrisElementInit* element; + Vec3f vertices[3]; + s32 i; + s32 j; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/BgIkanaMirror_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, &gStoneTowerTempleMirrorCol); + Collider_InitTris(play, &this->mirrorCollider); + Collider_SetTris(play, &this->mirrorCollider, &this->dyna.actor, &sMirrorColliderInit, + this->mirrorColliderElements); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/BgIkanaMirror_Destroy.s") + for (i = 0; i < ARRAY_COUNT(sMirrorColliderElementsInit); i++) { + element = &sMirrorColliderInit.elements[i]; + for (j = 0; j < 3; j++) { + Matrix_MultVec3f(&element->dim.vtx[j], &vertices[j]); + } + Collider_SetTrisVertices(&this->mirrorCollider, i, &vertices[0], &vertices[1], &vertices[2]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/func_80B7FA84.s") + for (i = 0; i < ARRAY_COUNT(this->lightRaysColliders); i++) { + Collider_InitQuad(play, &this->lightRaysColliders[i]); + Collider_SetQuad(play, &this->lightRaysColliders[i], &this->dyna.actor, &sLightRaysCollidersInit[i]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/func_80B7FA9C.s") + BgIkanaMirror_SetQuadVertices(this); + this->lightAbsorptionTexScroll = Lib_SegmentedToVirtual(&gStoneTowerTempleMirrorLightAbsorptionTexAnim); + this->lightEmissionTexScroll = Lib_SegmentedToVirtual(&gStoneTowerTempleMirrorLightEmissionTexAnim); + BgIkanaMirror_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/func_80B7FB84.s") +void BgIkanaMirror_Destroy(Actor* thisx, PlayState* play) { + BgIkanaMirror* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/func_80B7FBA4.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(play, &this->mirrorCollider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/BgIkanaMirror_Update.s") + for (i = 0; i < ARRAY_COUNT(this->lightRaysColliders); i++) { + Collider_DestroyQuad(play, &this->lightRaysColliders[i]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Mirror/BgIkanaMirror_Draw.s") +void BgIkanaMirror_SetupWait(BgIkanaMirror* this) { + this->isEmittingLight = 0; + this->actionFunc = BgIkanaMirror_Wait; +} + +/** + * Charges the mirror with light, increment the alpha value for the light absorption textures and decrement the alpha + * value for the light emission textures. + */ +void BgIkanaMirror_Wait(BgIkanaMirror* this, PlayState* play) { + s8 isEmittingLight; + s32 startEmittingLight = false; + + // The light emission texture gradually fades. + if (this->lightEmissionAlpha > 100) { + this->lightEmissionAlpha -= 100; + } else { + this->lightEmissionAlpha = 0; + } + + // This checks if light is touching the mirror. + if (this->mirrorCollider.base.acFlags & AC_HIT) { + this->mirrorCollider.base.acFlags &= ~AC_HIT; + this->isEmittingLight = 0; + + if (this->lightRayCharge < 400) { + this->lightRayCharge++; + } + + if (this->lightAbsorptionAlpha < 195) { + this->lightAbsorptionAlpha += 60; + } else { + this->lightAbsorptionAlpha = 255; + } + + } else { + isEmittingLight = this->isEmittingLight; + + if (isEmittingLight > 0) { + startEmittingLight = true; + } else if (this->lightRayCharge > 0) { + this->isEmittingLight = isEmittingLight + 1; + } + } + + if (startEmittingLight) { + BgIkanaMirror_SetupEmitLight(this); + } else { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->mirrorCollider.base); + } +} + +void BgIkanaMirror_SetupEmitLight(BgIkanaMirror* this) { + this->dyna.actor.flags |= ACTOR_FLAG_20; + this->actionFunc = BgIkanaMirror_EmitLight; +} + +/** + * Depletes the mirror's light and release it, increase alpha value for the light + * emission textures and decrease the alpha value for the light absorption textures. + */ +void BgIkanaMirror_EmitLight(BgIkanaMirror* this, PlayState* play) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->lightRaysColliders); i++) { + if (this->lightRaysColliders[i].base.atFlags & AT_HIT) { + this->lightRaysColliders[i].base.atFlags &= ~AT_HIT; + } + } + + if (this->lightEmissionAlpha < 155) { + this->lightEmissionAlpha += 100; + } else { + this->lightEmissionAlpha = 255; + } + + if (this->lightAbsorptionAlpha > 60) { + this->lightAbsorptionAlpha -= 60; + } else { + this->lightAbsorptionAlpha = 0; + } + + if (this->lightRayCharge > 0) { + this->lightRayCharge--; + + for (i = 0; i < ARRAY_COUNT(this->lightRaysColliders); i++) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->lightRaysColliders[i].base); + } + + } else { + this->dyna.actor.flags &= ~ACTOR_FLAG_20; + BgIkanaMirror_SetupWait(this); + } +} + +void BgIkanaMirror_Update(Actor* thisx, PlayState* play) { + BgIkanaMirror* this = THIS; + + this->actionFunc(this, play); +} + +void BgIkanaMirror_Draw(Actor* thisx, PlayState* play) { + s32 pad; + BgIkanaMirror* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gStoneTowerTempleMirrorDL); + + if (this->lightAbsorptionAlpha > 0) { + AnimatedMat_Draw(play, this->lightAbsorptionTexScroll); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->lightAbsorptionAlpha); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gStoneTowerTempleMirrorLightAbsorptionDL); + } + + if (this->lightEmissionAlpha > 0) { + f32 alphaFraction = this->lightEmissionAlpha * (1.0f / 255.0f); + s32 primColorAlpha = (s32)(alphaFraction * 123.0f); + s32 envColorAlpha = (s32)(alphaFraction * 185.0f); + + AnimatedMat_Draw(play, this->lightEmissionTexScroll); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, primColorAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 215, 215, 255, envColorAlpha); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gStoneTowerTempleMirrorLightEmissionDL); + } + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.h b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.h index c9f881208..5bd272480 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.h @@ -8,12 +8,17 @@ struct BgIkanaMirror; typedef void (*BgIkanaMirrorActionFunc)(struct BgIkanaMirror*, PlayState*); typedef struct BgIkanaMirror { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x474]; - /* 0x05B8 */ BgIkanaMirrorActionFunc actionFunc; - /* 0x05BC */ char unk_5BC[0x10]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderTris mirrorCollider; + /* 0x17C */ ColliderTrisElement mirrorColliderElements[9]; + /* 0x4B8 */ ColliderQuad lightRaysColliders[2]; + /* 0x5B8 */ BgIkanaMirrorActionFunc actionFunc; + /* 0x5BC */ AnimatedMaterial* lightAbsorptionTexScroll; + /* 0x5C0 */ AnimatedMaterial* lightEmissionTexScroll; + /* 0x5C4 */ s16 lightRayCharge; + /* 0x5C6 */ u8 lightAbsorptionAlpha; + /* 0x5C7 */ u8 lightEmissionAlpha; + /* 0x5C8 */ s8 isEmittingLight; } BgIkanaMirror; // size = 0x5CC -extern const ActorInit Bg_Ikana_Mirror_InitVars; - #endif // Z_BG_IKANA_MIRROR_H diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c index 90de39bf4..94eec2c1d 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c @@ -78,7 +78,7 @@ static ColliderJntSphInit sJntSphInit1 = { OC2_NONE, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit1), sJntSphElementsInit1, }; @@ -105,7 +105,7 @@ static ColliderJntSphInit sJntSphInit2 = { OC2_NONE, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit2), sJntSphElementsInit2, }; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h index e818eb77d..89021fa54 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h @@ -33,20 +33,20 @@ typedef struct { } BgIkanaRotaryroomStruct3; // size = 0x58 typedef struct BgIkanaRotaryroom { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderJntSph collider; - /* 0x017C */ ColliderJntSphElement colliderElements[2]; - /* 0x01FC */ AnimatedMaterial* unk_1FC; - /* 0x0200 */ BgIkanaRotaryroomUnkFunc unk_200; - /* 0x0204 */ BgIkanaRotaryroomStruct1 unk_204; - /* 0x0248 */ BgIkanaRotaryroomStruct1 unk_248[2]; - /* 0x02D0 */ BgIkanaRotaryroomStruct1 unk_2D0[4]; - /* 0x03E0 */ BgIkanaRotaryroomStruct2 unk_3E0[4]; - /* 0x0520 */ BgIkanaRotaryroomStruct3 unk_520; - /* 0x0578 */ BgIkanaRotaryroomUnkFunc2 unk_578; - /* 0x057C */ BgIkanaRotaryroomUnkFunc2 unk_57C; - /* 0x0580 */ BgIkanaRotaryroomActionFunc actionFunc; - /* 0x0584 */ s16 unk_584; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderJntSph collider; + /* 0x17C */ ColliderJntSphElement colliderElements[2]; + /* 0x1FC */ AnimatedMaterial* unk_1FC; + /* 0x200 */ BgIkanaRotaryroomUnkFunc unk_200; + /* 0x204 */ BgIkanaRotaryroomStruct1 unk_204; + /* 0x248 */ BgIkanaRotaryroomStruct1 unk_248[2]; + /* 0x2D0 */ BgIkanaRotaryroomStruct1 unk_2D0[4]; + /* 0x3E0 */ BgIkanaRotaryroomStruct2 unk_3E0[4]; + /* 0x520 */ BgIkanaRotaryroomStruct3 unk_520; + /* 0x578 */ BgIkanaRotaryroomUnkFunc2 unk_578; + /* 0x57C */ BgIkanaRotaryroomUnkFunc2 unk_57C; + /* 0x580 */ BgIkanaRotaryroomActionFunc actionFunc; + /* 0x584 */ s16 unk_584; } BgIkanaRotaryroom; // size = 0x588 extern const ActorInit Bg_Ikana_Rotaryroom_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c index 618cc3ae6..ec17965c6 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 @@ -132,7 +132,7 @@ void func_80BD599C(BgIkanaShutter* this) { } void func_80BD59C4(BgIkanaShutter* this, PlayState* play) { - if (BgIkanaShutter_AllSwitchesPressed(this, play) == 0) { + if (!BgIkanaShutter_AllSwitchesPressed(this, play)) { func_80BD59F8(this); } } diff --git a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c index 50b17b5bb..07de845c0 100644 --- a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c +++ b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c @@ -107,7 +107,7 @@ void func_80C072D0(BgIkninside* this, PlayState* play) { if ((this->collider.info.acHitInfo != NULL) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000)) { for (i = 0; i < 20; i++) { altitude = Rand_S16Offset(0x1800, 0x2800); - azimuth = (u32)Rand_Next() >> 0x10; + azimuth = Rand_Next() >> 0x10; speed = Rand_ZeroFloat(3.0f) + 8.0f; velocity.x = speed * Math_CosS(altitude) * Math_SinS(azimuth); velocity.y = speed * Math_SinS(altitude) + Rand_ZeroFloat(5.0f); diff --git a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c index 20a753fe2..06091b12b 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c @@ -5,6 +5,7 @@ */ #include "z_bg_iknv_doukutu.h" +#include "objects/object_iknv_obj/object_iknv_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -21,8 +22,11 @@ void func_80BD7250(BgIknvDoukutu* this, PlayState* play); void func_80BD72BC(BgIknvDoukutu* this, PlayState* play); void func_80BD7360(BgIknvDoukutu* this, PlayState* play); void func_80BD73D0(BgIknvDoukutu* this, PlayState* play); +void func_80BD7768(Actor* thisx, PlayState* play); +void func_80BD7820(Actor* thisx, PlayState* play); +void func_80BD78C4(Actor* thisx, PlayState* play); +void func_80BD7538(Actor* thisx, PlayState* play); -#if 0 const ActorInit Bg_Iknv_Doukutu_InitVars = { ACTOR_BG_IKNV_DOUKUTU, ACTORCAT_BG, @@ -35,38 +39,233 @@ const ActorInit Bg_Iknv_Doukutu_InitVars = { (ActorFunc)BgIknvDoukutu_Draw, }; -#endif +void BgIknvDoukutu_Init(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; + CollisionHeader* colHeader = NULL; + s32 pad; -extern UNK_TYPE D_0600F1C0; -extern UNK_TYPE D_06010D98; -extern UNK_TYPE D_060117A0; -extern UNK_TYPE D_06012728; -extern UNK_TYPE D_06012788; + Actor_SetScale(&this->dyna.actor, 0.1f); + this->actionFunc = func_80BD73D0; + this->unk_15C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/BgIknvDoukutu_Init.s") + switch (BGIKNVDOUKUTU_GET_F(&this->dyna.actor)) { + case BGIKNVDOUKUTU_F_0: + this->actionFunc = func_80BD71BC; + this->csAction = 0x204; + this->unk_160 = 1.0f; + if ((gSaveContext.save.weekEventReg[14] & 4) || (gSaveContext.save.weekEventReg[52] & 0x20)) { + this->dyna.actor.draw = func_80BD7768; + this->actionFunc = func_80BD73D0; + play->envCtx.lightSettingOverride = 25; + } else { + play->envCtx.lightSettingOverride = 24; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/BgIknvDoukutu_Destroy.s") + case BGIKNVDOUKUTU_F_1: + Actor_SetScale(&this->dyna.actor, 1.0f); + this->dyna.actor.draw = func_80BD7820; + this->csAction = 0x204; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_iknv_obj_Colheader_012788, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + if (!(gSaveContext.save.weekEventReg[14] & 4)) { + Actor_MarkForDeath(&this->dyna.actor); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD716C.s") + case BGIKNVDOUKUTU_F_2: + this->csAction = 0x204; + this->dyna.actor.draw = func_80BD78C4; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_iknv_obj_Colheader_0117C8, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + if (gSaveContext.save.weekEventReg[14] & 4) { + this->unk_160 = 1.0f; + this->dyna.actor.world.pos.y += 68.0f; + } else { + this->actionFunc = func_80BD7360; + this->unk_160 = 0.0f; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD71BC.s") + default: + Actor_MarkForDeath(&this->dyna.actor); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD7250.s") +void BgIknvDoukutu_Destroy(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD72BC.s") + if ((BGIKNVDOUKUTU_GET_F(&this->dyna.actor) == BGIKNVDOUKUTU_F_1) || + (BGIKNVDOUKUTU_GET_F(&this->dyna.actor) == BGIKNVDOUKUTU_F_2)) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD7360.s") +void func_80BD716C(BgIknvDoukutu* this, PlayState* play) { + if (this->unk_160 >= 0.05f) { + this->unk_160 -= 0.05f; + } else { + this->actionFunc = func_80BD73D0; + this->dyna.actor.draw = func_80BD7768; + } + play->envCtx.lightSettingOverride = 25; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD73D0.s") +void func_80BD71BC(BgIknvDoukutu* this, PlayState* play) { + play->envCtx.lightSettingOverride = 24; + if (Cutscene_CheckActorAction(play, this->csAction) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action == 2)) { + this->actionFunc = func_80BD716C; + this->dyna.actor.draw = func_80BD7538; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/BgIknvDoukutu_Update.s") +void func_80BD7250(BgIknvDoukutu* this, PlayState* play) { + f32 temp_fv0 = this->dyna.actor.home.pos.y + 68.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/BgIknvDoukutu_Draw.s") + this->dyna.actor.world.pos.y += 1.7f; + if (temp_fv0 < this->dyna.actor.world.pos.y) { + this->dyna.actor.world.pos.y = temp_fv0; + this->actionFunc = func_80BD73D0; + } + func_8019F128(NA_SE_EV_WATER_LEVEL_DOWN - SFX_FLAG); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD7538.s") +void func_80BD72BC(BgIknvDoukutu* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, this->csAction) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action == 3)) { + this->actionFunc = func_80BD7250; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD7768.s") + if (this->unk_160 < 0.95f) { + this->unk_160 += 0.05f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD7820.s") +void func_80BD7360(BgIknvDoukutu* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, this->csAction) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action == 2)) { + this->actionFunc = func_80BD72BC; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Iknv_Doukutu/func_80BD78C4.s") +void func_80BD73D0(BgIknvDoukutu* this, PlayState* play) { +} + +void BgIknvDoukutu_Update(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; + + this->actionFunc(this, play); +} + +void BgIknvDoukutu_Draw(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_iknv_obj_Matanimheader_00F1C0)); + Scene_SetRenderModeXlu(play, 0, 1); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPDisplayList(POLY_OPA_DISP++, object_iknv_obj_DL_00DDD8); + gDPSetEnvColor(POLY_XLU_DISP++, 215, 42, 55, 120); + gSPDisplayList(POLY_XLU_DISP++, object_iknv_obj_DL_00DB60); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void func_80BD7538(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; + GraphicsContext* gfxCtx; + f32 sp54; + + func_80BD7768(&this->dyna.actor, play); + + gfxCtx = play->state.gfxCtx; + OPEN_DISPS(gfxCtx); + Vec3f sp40; + s16 sp3E = Math_Vec3f_Yaw(&GET_ACTIVE_CAM(play)->eye, &GET_ACTIVE_CAM(play)->at); + s16 sp3C = -Math_Vec3f_Pitch(&GET_ACTIVE_CAM(play)->eye, &GET_ACTIVE_CAM(play)->at); + + sp40.x = -100.0f * Math_SinS(sp3E) * Math_CosS(sp3C); + sp40.y = Math_SinS(sp3C) * -100.0f; + sp40.z = -100.0f * Math_CosS(sp3E) * Math_CosS(sp3C); + Matrix_Translate(sp40.x, sp40.y, sp40.z, MTXMODE_APPLY); + sp54 = this->unk_160; + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_iknv_obj_Matanimheader_00F1C0)); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C304(POLY_XLU_DISP++); + Scene_SetRenderModeXlu(play, 1, 2); + func_8012C2DC(play->state.gfxCtx); + + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, (s32)(255.0f * sp54)); + gSPDisplayList(POLY_XLU_DISP++, object_iknv_obj_DL_00DDD8); + gDPSetEnvColor(POLY_XLU_DISP++, 215, 42, 55, (s32)(120.0f * sp54)); + gSPDisplayList(POLY_XLU_DISP++, object_iknv_obj_DL_00DB60); + + CLOSE_DISPS(gfxCtx); +} + +void func_80BD7768(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + Scene_SetRenderModeXlu(play, 0, 1); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C28C(play->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPDisplayList(POLY_OPA_DISP++, object_iknv_obj_DL_010D98); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void func_80BD7820(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_iknv_obj_Matanimheader_012728)); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C2DC(play->state.gfxCtx); + + gSPDisplayList(POLY_XLU_DISP++, object_iknv_obj_DL_012700); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void func_80BD78C4(Actor* thisx, PlayState* play) { + BgIknvDoukutu* this = THIS; + f32 sp30 = this->unk_160; + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_iknv_obj_Matanimheader_0117A0)); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C2DC(play->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, (s32)(140.0f * sp30)); + + gSPDisplayList(POLY_XLU_DISP++, object_iknv_obj_DL_0115E0); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.h b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.h index e1373e8a6..d9c4f78ad 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.h +++ b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.h @@ -7,11 +7,21 @@ struct BgIknvDoukutu; typedef void (*BgIknvDoukutuActionFunc)(struct BgIknvDoukutu*, PlayState*); +#define BGIKNVDOUKUTU_GET_F(thisx) ((thisx)->params & 0xF) + +enum { + BGIKNVDOUKUTU_F_0, + BGIKNVDOUKUTU_F_1, + BGIKNVDOUKUTU_F_2, +}; + typedef struct BgIknvDoukutu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x20]; - /* 0x0164 */ BgIknvDoukutuActionFunc actionFunc; -} BgIknvDoukutu; // size = 0x168 + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s16 unk_15C; // set and not used + /* 0x15E */ u16 csAction; + /* 0x160 */ f32 unk_160; + /* 0x164 */ BgIknvDoukutuActionFunc actionFunc; +} BgIknvDoukutu;// size = 0x168 extern const ActorInit Bg_Iknv_Doukutu_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 34e0eb484..76c117032 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -123,21 +123,21 @@ s32 func_80953BEC(BgIngate* this) { } s32 func_80953DA8(BgIngate* this, PlayState* play) { - Camera* camera = Play_GetCamera(play, CAM_ID_MAIN); + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); if (gSaveContext.eventInf[3] & 0x20) { func_800B7298(play, &this->dyna.actor, 7); } else { gSaveContext.eventInf[4] |= 2; } - func_800DFAC8(camera, 47); + Camera_ChangeSetting(mainCam, CAM_SET_BOAT_CRUISE); play->unk_1887C = 0x63; return false; } void func_80953E38(PlayState* play) { - func_800DFAC8(Play_GetCamera(play, CAM_ID_MAIN), 1); + Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_NORMAL0); if (!(gSaveContext.eventInf[3] & 0x20)) { gSaveContext.eventInf[4] &= (u8)~2; @@ -178,7 +178,7 @@ void func_80953F8C(BgIngate* this, PlayState* play) { void func_80953F9C(BgIngate* this, PlayState* play) { Player* player = GET_PLAYER(play); - Camera* camera = Play_GetCamera(play, CAM_ID_MAIN); + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); if (!(gSaveContext.eventInf[4] & 1)) { @@ -214,11 +214,11 @@ void func_80953F9C(BgIngate* this, PlayState* play) { } if (ActorCutscene_GetCurrentIndex() != this->unk16E) { if (ActorCutscene_GetCurrentIndex() != -1) { - func_800DFAC8(camera, 1); + Camera_ChangeSetting(mainCam, CAM_SET_NORMAL0); player->stateFlags1 |= 0x20; play->actorCtx.unk5 &= ~0x4; } else { - func_800DFAC8(camera, 47); + Camera_ChangeSetting(mainCam, CAM_SET_BOAT_CRUISE); player->stateFlags1 &= ~0x20; } } @@ -251,9 +251,9 @@ void func_809542A0(BgIngate* this, PlayState* play) { play->nextEntranceIndex = 0xA810; } gSaveContext.nextCutsceneIndex = 0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; this->actionFunc = func_80953F8C; gSaveContext.save.weekEventReg[90] &= (u8)~0x40; func_800FE498(); @@ -273,7 +273,7 @@ void func_80954340(BgIngate* this, PlayState* play) { void func_809543D4(BgIngate* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - if (((talkState == 4) || (talkState == 5)) && Message_ShouldAdvance(play)) { + if (((talkState == TEXT_STATE_CHOICE) || (talkState == TEXT_STATE_5)) && Message_ShouldAdvance(play)) { switch (this->dyna.actor.textId) { case 0x9E4: this->dyna.actor.textId = 0x9E5; 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 bb996b85d..628ade7f1 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 @@ -95,7 +95,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 4, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; 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 59d7649bd..2f50ca820 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 @@ -49,7 +49,7 @@ static ColliderTrisElementInit D_80B6F990[2] = { // static ColliderTrisInit sTrisInit = { static ColliderTrisInit D_80B6FA08 = { { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_80B6F990, // sTrisElementsInit, + ARRAY_COUNT(sTrisElementsInit), D_80B6F990, // sTrisElementsInit, }; // static InitChainEntry sInitChain[] = { diff --git a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h index 1d2569d84..19651ef57 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h +++ b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h @@ -8,10 +8,10 @@ struct BgKin2Picture; typedef void (*BgKin2PictureActionFunc)(struct BgKin2Picture*, PlayState*); typedef struct BgKin2Picture { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xF0]; - /* 0x0234 */ BgKin2PictureActionFunc actionFunc; - /* 0x0238 */ char unk_238[0xC]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0xF0]; + /* 0x234 */ BgKin2PictureActionFunc actionFunc; + /* 0x238 */ char unk_238[0xC]; } BgKin2Picture; // size = 0x244 extern const ActorInit Bg_Kin2_Picture_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h index 0ae259c04..ce88b25e0 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h +++ b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h @@ -10,13 +10,13 @@ typedef void (*BgKin2ShelfActionFunc)(struct BgKin2Shelf*, PlayState*); #define BGKIN2SHELF_GET_1(thisx) ((thisx)->params & 1) typedef struct BgKin2Shelf { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ BgKin2ShelfActionFunc actionFunc; - /* 0x0160 */ f32 unk_160; - /* 0x0164 */ u8 unk_164; - /* 0x0165 */ s8 unk_165; - /* 0x0166 */ s8 unk_166; - /* 0x0167 */ s8 unk_167; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgKin2ShelfActionFunc actionFunc; + /* 0x160 */ f32 unk_160; + /* 0x164 */ u8 unk_164; + /* 0x165 */ s8 unk_165; + /* 0x166 */ s8 unk_166; + /* 0x167 */ s8 unk_167; } BgKin2Shelf; // size = 0x168 extern const ActorInit Bg_Kin2_Shelf_InitVars; 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 7df014520..43e5e94f1 100644 --- a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c +++ b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c @@ -15,10 +15,10 @@ void BgLadder_Init(Actor* thisx, PlayState* play); void BgLadder_Destroy(Actor* thisx, PlayState* play); void BgLadder_Update(Actor* thisx, PlayState* play); void BgLadder_Draw(Actor* thisx, PlayState* play); -void BgLadder_ActionWait(BgLadder* this, PlayState* play); -void BgLadder_ActionStartCutscene(BgLadder* this, PlayState* play); -void BgLadder_ActionFadeIn(BgLadder* this, PlayState* play); -void BgLadder_ActionIdle(BgLadder* this, PlayState* play); +void BgLadder_Wait(BgLadder* this, PlayState* play); +void BgLadder_StartCutscene(BgLadder* this, PlayState* play); +void BgLadder_FadeIn(BgLadder* this, PlayState* play); +void BgLadder_DoNothing(BgLadder* this, PlayState* play); const ActorInit Bg_Ladder_InitVars = { ACTOR_BG_LADDER, @@ -49,7 +49,6 @@ void BgLadder_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - // Has to be `thisx` instead of `&this->actor` to match this->switchFlag = GET_BGLADDER_SWITCHFLAG(thisx); thisx->params = GET_BGLADDER_SIZE(thisx); DynaPolyActor_Init(&this->dyna, 0); @@ -72,13 +71,13 @@ void BgLadder_Init(Actor* thisx, PlayState* play) { // If the flag is set, then the ladder draws immediately this->alpha = 255; this->dyna.actor.flags &= ~ACTOR_FLAG_10; // always update = off - this->action = BgLadder_ActionIdle; + this->action = BgLadder_DoNothing; } else { // Otherwise, the ladder doesn't draw; wait for the flag to be set this->alpha = 5; func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; - this->action = BgLadder_ActionWait; + this->action = BgLadder_Wait; } } @@ -88,27 +87,27 @@ void BgLadder_Destroy(Actor* thisx, PlayState* play) { DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void BgLadder_ActionWait(BgLadder* this, PlayState* play) { +void BgLadder_Wait(BgLadder* this, PlayState* play) { // Wait for the flag to be set, then trigger the cutscene if (Flags_GetSwitch(play, this->switchFlag)) { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); - this->action = BgLadder_ActionStartCutscene; + this->action = BgLadder_StartCutscene; } } -void BgLadder_ActionStartCutscene(BgLadder* this, PlayState* play) { +void BgLadder_StartCutscene(BgLadder* this, PlayState* play) { // Trigger the cutscene, then make the ladder fade in if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); this->dyna.actor.draw = BgLadder_Draw; Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SECRET_LADDER_APPEAR); - this->action = BgLadder_ActionFadeIn; + this->action = BgLadder_FadeIn; } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); } } -void BgLadder_ActionFadeIn(BgLadder* this, PlayState* play) { +void BgLadder_FadeIn(BgLadder* this, PlayState* play) { // Fade in the ladder, then stop the cutscene & go idle this->alpha += 5; if (this->alpha >= 255) { @@ -116,11 +115,11 @@ void BgLadder_ActionFadeIn(BgLadder* this, PlayState* play) { ActorCutscene_Stop(this->dyna.actor.cutscene); func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.flags &= ~ACTOR_FLAG_10; // always update = off - this->action = BgLadder_ActionIdle; + this->action = BgLadder_DoNothing; } } -void BgLadder_ActionIdle(BgLadder* this, PlayState* play) { +void BgLadder_DoNothing(BgLadder* this, PlayState* play) { } void BgLadder_Update(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c index f47536123..a1795d849 100644 --- a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c +++ b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c @@ -43,7 +43,7 @@ static ColliderTrisElementInit D_80C189C0[2] = { // static ColliderTrisInit sTrisInit = { static ColliderTrisInit D_80C18A38 = { { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_80C189C0, // sTrisElementsInit, + ARRAY_COUNT(sTrisElementsInit), D_80C189C0, // sTrisElementsInit, }; // static InitChainEntry sInitChain[] = { diff --git a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.h b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.h index 0ace6c588..c393b55af 100644 --- a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.h +++ b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.h @@ -8,10 +8,10 @@ struct BgLastBwall; typedef void (*BgLastBwallActionFunc)(struct BgLastBwall*, PlayState*); typedef struct BgLastBwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgLastBwallActionFunc actionFunc; - /* 0x0160 */ char unk_160[0xDC]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x18]; + /* 0x15C */ BgLastBwallActionFunc actionFunc; + /* 0x160 */ char unk_160[0xDC]; } BgLastBwall; // size = 0x23C extern const ActorInit Bg_Last_Bwall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c index e830f738b..b54e7a583 100644 --- a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c +++ b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c @@ -5,6 +5,7 @@ */ #include "z_bg_open_shutter.h" +#include "objects/object_open_obj/object_open_obj.h" #include "z64rumble.h" #define FLAGS (ACTOR_FLAG_10) @@ -20,7 +21,11 @@ void func_80ACAD88(BgOpenShutter* this, PlayState* play); void func_80ACAE5C(BgOpenShutter* this, PlayState* play); void func_80ACAEF0(BgOpenShutter* this, PlayState* play); -#if 0 +typedef enum { + /* 0x1 */ BGOPENSHUTTER_DOOR_OPEN = 1, + /* 0x2 */ BGOPENSHUTTER_DOOR_CLOSED, +} BGOpenShutterDoorState; + const ActorInit Bg_Open_Shutter_InitVars = { ACTOR_BG_OPEN_SHUTTER, ACTORCAT_DOOR, @@ -33,35 +38,151 @@ const ActorInit Bg_Open_Shutter_InitVars = { (ActorFunc)BgOpenShutter_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80ACB140[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 350, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 350, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +f32 func_80ACAB10(PlayState* play, Actor* actor, f32 arg2, f32 arg3, f32 arg4) { + Player* player = GET_PLAYER(play); + Vec3f point; + Vec3f offset; -extern InitChainEntry D_80ACB140[]; + point.x = player->actor.world.pos.x; + point.y = player->actor.world.pos.y + arg2; + point.z = player->actor.world.pos.z; -extern UNK_TYPE D_060003E8; -extern UNK_TYPE D_06001640; + Actor_OffsetOfPointInActorCoords(actor, &offset, &point); + if ((arg3 < fabsf(offset.x)) || (arg4 < fabsf(offset.y))) { + return FLT_MAX; + } else { + return offset.z; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACAB10.s") +s8 func_80ACABA8(BgOpenShutter* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 temp_fv0; + s16 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACABA8.s") + if (!Player_InCsMode(play) && (this->dyna.actor.xzDistToPlayer < 100.0f)) { + temp_fv0 = func_80ACAB10(play, &this->dyna.actor, 0.0f, 65.0f, 15.0f); + if (fabsf(temp_fv0) < 50.0f) { + temp_v0 = player->actor.shape.rot.y - this->dyna.actor.shape.rot.y; + if (temp_fv0 > 0.0f) { + temp_v0 = (0x8000 - temp_v0); + } + if (ABS_ALT(temp_v0) < 0x3000) { + if (temp_fv0 > 1.0f) { + return 1; + } + if (temp_fv0 < -1.0f) { + return -1; + } + } + } + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/BgOpenShutter_Init.s") +void BgOpenShutter_Init(Actor* thisx, PlayState* play) { + BgOpenShutter* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/BgOpenShutter_Destroy.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_open_obj_Colheader_001640); + this->actionFunc = func_80ACAD88; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACAD88.s") +void BgOpenShutter_Destroy(Actor* thisx, PlayState* play) { + BgOpenShutter* this = THIS; + s32 params = BGOPENSHUTTER_GET_A(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACAE5C.s") + play->doorCtx.transitionActorList[params].id = -play->doorCtx.transitionActorList[params].id; + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACAEF0.s") +void func_80ACAD88(BgOpenShutter* this, PlayState* play) { + s32 quake; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/BgOpenShutter_Update.s") + if (this->unk_15C != 0) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/BgOpenShutter_Draw.s") + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + Camera_ChangeDoorCam(play->cameraPtrs[CAM_ID_MAIN], &this->dyna.actor, player->unk_3BA, 0.0f, 12, 15, 10); + this->unk_164 = 0; + this->actionFunc = func_80ACAE5C; + this->dyna.actor.velocity.y = 0.0f; + } else { + Player* player = GET_PLAYER(play); + + quake = func_80ACABA8(this, play); + if (quake > 0) { + player->doorType = 2; + player->doorDirection = quake; + player->doorActor = &this->dyna.actor; + func_80122F28(player); + } + } +} + +void func_80ACAE5C(BgOpenShutter* this, PlayState* play) { + Math_StepToF(&this->dyna.actor.velocity.y, 15.0f, 3.0f); + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 120.0f, + this->dyna.actor.velocity.y)) { + this->unk_164++; + } + if (this->unk_164 >= 10) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + this->actionFunc = func_80ACAEF0; + } +} + +void func_80ACAEF0(BgOpenShutter* this, PlayState* play) { + s32 pad; + s16 quake; + + Math_StepToF(&this->dyna.actor.velocity.y, 20.0f, 8.0f); + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, this->dyna.actor.velocity.y)) { + this->dyna.actor.floorHeight = this->dyna.actor.home.pos.y; + Actor_SpawnFloorDustRing(play, &this->dyna.actor, &this->dyna.actor.world.pos, 60.0f, 10, 8.0f, 500, 10, true); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND); + quake = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), 3); + Quake_SetSpeed(quake, -0x7F18); + Quake_SetQuakeValues(quake, 2, 0, 0, 0); + Quake_SetCountdown(quake, 10); + Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 180, 20, 100); + this->unk_15C = 0; + this->actionFunc = func_80ACAD88; + } +} + +void BgOpenShutter_Update(Actor* thisx, PlayState* play2) { + BgOpenShutter* this = THIS; + PlayState* play = play2; + s32 index; + + if (Cutscene_CheckActorAction(play, 0x7C)) { + index = Cutscene_GetActorActionIndex(play, 0x7C); + if (play->csCtx.actorActions[index]->action == BGOPENSHUTTER_DOOR_OPEN) { + if (this->actionFunc == func_80ACAD88) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + this->actionFunc = func_80ACAE5C; + this->dyna.actor.velocity.y = 0.0f; + } + this->unk_164 = 0; + } else if (play->csCtx.actorActions[index]->action == BGOPENSHUTTER_DOOR_CLOSED) { + if (this->actionFunc == func_80ACAE5C) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + this->actionFunc = func_80ACAEF0; + } + } + } + this->actionFunc(this, play); +} + +void BgOpenShutter_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_open_obj_DL_0003E8); +} diff --git a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h index 2c00a5735..fdf2791e1 100644 --- a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h +++ b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h @@ -3,15 +3,17 @@ #include "global.h" +#define BGOPENSHUTTER_GET_A(thisx) ((u16)((thisx)->params) >> 0xA) + struct BgOpenShutter; typedef void (*BgOpenShutterActionFunc)(struct BgOpenShutter*, PlayState*); typedef struct BgOpenShutter { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; - /* 0x0160 */ BgOpenShutterActionFunc actionFunc; - /* 0x0164 */ char unk_164[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s16 unk_15C; + /* 0x160 */ BgOpenShutterActionFunc actionFunc; + /* 0x164 */ s32 unk_164; } BgOpenShutter; // size = 0x168 extern const ActorInit Bg_Open_Shutter_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c index 46eac0c13..4325bc259 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c @@ -70,7 +70,7 @@ static ColliderTrisInit sTrisInit1 = { OC2_TYPE_2, COLSHAPE_TRIS, }, - 2, + ARRAY_COUNT(sTrisElementsInit1), sTrisElementsInit1, }; @@ -130,7 +130,7 @@ static ColliderTrisInit sTrisInit2 = { OC2_TYPE_2, COLSHAPE_TRIS, }, - 4, + ARRAY_COUNT(sTrisElementsInit2), sTrisElementsInit2, }; @@ -280,9 +280,9 @@ void func_809CE4C8(BgSpdweb* this, PlayState* play) { sp40.z = this->dyna.actor.world.pos.z; sp3A = player->unk_B6A; - if (func_80123F48(play, &sp40, 70.0f, 50.0f)) { - this->dyna.actor.home.pos.x = player->swordInfo[0].tip.x; - this->dyna.actor.home.pos.z = player->swordInfo[0].tip.z; + if (Player_IsBurningStickInRange(play, &sp40, 70.0f, 50.0f)) { + this->dyna.actor.home.pos.x = player->meleeWeaponInfo[0].tip.x; + this->dyna.actor.home.pos.z = player->meleeWeaponInfo[0].tip.z; func_809CEE74(this); return; } @@ -461,7 +461,7 @@ void func_809CEBC0(BgSpdweb* this, PlayState* play) { } func_809CEE74(this); } else if ((player->itemActionParam == 7) && (player->unk_B28 != 0)) { - Math_Vec3f_Diff(&player->swordInfo[0].tip, &this->dyna.actor.world.pos, &sp3C); + Math_Vec3f_Diff(&player->meleeWeaponInfo[0].tip, &this->dyna.actor.world.pos, &sp3C); sp38 = Math_SinS(-this->dyna.actor.shape.rot.x); sp34 = Math_CosS(-this->dyna.actor.shape.rot.x); sp30 = Math_SinS(-this->dyna.actor.shape.rot.y); @@ -472,7 +472,7 @@ void func_809CEBC0(BgSpdweb* this, PlayState* play) { temp_f10 = (sp3C.x * sp2C) + (sp3C.z * sp30); if ((fabsf(temp_f10) < 70.0f) && (fabsf(sp58) < 10.0f) && (temp_f18 < 160.0f) && (temp_f18 > 20.0f)) { - Math_Vec3f_Copy(&this->dyna.actor.home.pos, &player->swordInfo[0].tip); + Math_Vec3f_Copy(&this->dyna.actor.home.pos, &player->meleeWeaponInfo[0].tip); func_809CEE74(this); } } diff --git a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h index 2ae0aca41..64a6fd34b 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h @@ -13,15 +13,15 @@ typedef void (*BgSpdwebActionFunc)(struct BgSpdweb*, PlayState*); #define BGSPDWEB_FF_1 1 typedef struct BgSpdweb { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ BgSpdwebActionFunc actionFunc; - /* 0x0160 */ u8 switchFlag; - /* 0x0161 */ u8 unk_161; - /* 0x0162 */ s16 unk_162; - /* 0x0164 */ f32 unk_164; - /* 0x0168 */ ColliderTris collider; - /* 0x0188 */ ColliderTrisElement colliderElements[4]; - /* 0x02F8 */ Vec3s* unk_2F8; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgSpdwebActionFunc actionFunc; + /* 0x160 */ u8 switchFlag; + /* 0x161 */ u8 unk_161; + /* 0x162 */ s16 unk_162; + /* 0x164 */ f32 unk_164; + /* 0x168 */ ColliderTris collider; + /* 0x188 */ ColliderTrisElement colliderElements[4]; + /* 0x2F8 */ Vec3s* unk_2F8; } BgSpdweb; // size = 0x2FC extern const ActorInit Bg_Spdweb_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.c b/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.c index c43a13a25..055598c00 100644 --- a/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.c +++ b/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.c @@ -5,6 +5,7 @@ */ #include "z_bg_spout_fire.h" +#include "objects/object_fwall/object_fwall.h" #define FLAGS 0x00000000 @@ -13,12 +14,14 @@ void BgSpoutFire_Init(Actor* thisx, PlayState* play); void BgSpoutFire_Destroy(Actor* thisx, PlayState* play); void BgSpoutFire_Update(Actor* thisx, PlayState* play); +void BgSpoutFire_Draw(Actor* thisx, PlayState* play); +s32 func_80A60C24(BgSpoutFire* this, PlayState* play); void func_80A60C94(BgSpoutFire* this, PlayState* play); void func_80A60CDC(BgSpoutFire* this, PlayState* play); void func_80A60D10(BgSpoutFire* this, PlayState* play); +void func_80A60E08(BgSpoutFire* this, PlayState* play); -#if 0 const ActorInit Bg_Spout_Fire_InitVars = { ACTOR_BG_SPOUT_FIRE, ACTORCAT_BG, @@ -31,39 +34,170 @@ const ActorInit Bg_Spout_Fire_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A61160 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x01, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, { 30, 83, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80A6118C = { 1, 80, 100, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 80, 100, MASS_IMMOVABLE }; -#endif +static TexturePtr sFlameTextures[] = { + gFwallFireball0Tex, gFwallFireball1Tex, gFwallFireball2Tex, gFwallFireball3Tex, + gFwallFireball4Tex, gFwallFireball5Tex, gFwallFireball6Tex, gFwallFireball7Tex, +}; -extern ColliderCylinderInit D_80A61160; -extern CollisionCheckInfoInit D_80A6118C; +static s32 sTexturesDesegmented = false; -extern UNK_TYPE D_06000040; +void BgSpoutFire_Init(Actor* thisx, PlayState* play) { + s32 i; + BgSpoutFire* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/BgSpoutFire_Init.s") + this->actor.scale.z = 1350.0f * 0.0001f; + this->actor.scale.x = 1350.0f * 0.0001f; + this->actor.scale.y = 0.01f; + this->flameTexIndex = 0; + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->collider.dim.pos.y = this->actor.world.pos.y; + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + if (!sTexturesDesegmented) { + for (i = 0; i < ARRAY_COUNT(sFlameTextures); i++) { + sFlameTextures[i] = Lib_SegmentedToVirtual(sFlameTextures[i]); + } + sTexturesDesegmented = true; + } + this->actionFunc = func_80A60C94; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/BgSpoutFire_Destroy.s") +void BgSpoutFire_Destroy(Actor* thisx, PlayState* play) { + BgSpoutFire* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/func_80A60C24.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/func_80A60C94.s") +s32 func_80A60C24(BgSpoutFire* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f sp18; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/func_80A60CDC.s") + Actor_OffsetOfPointInActorCoords(&this->actor, &sp18, &player->actor.world.pos); + if ((fabsf(sp18.x) < 100.0f) && (fabsf(sp18.z) < 120.0f)) { + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/func_80A60D10.s") +void func_80A60C94(BgSpoutFire* this, PlayState* play) { + if (func_80A60C24(this, play)) { + this->actor.draw = BgSpoutFire_Draw; + this->timer = 5; + this->actionFunc = func_80A60CDC; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/func_80A60DA0.s") +void func_80A60CDC(BgSpoutFire* this, PlayState* play) { + if (this->timer != 0) { + this->timer--; + } + if (this->timer == 0) { + this->actionFunc = func_80A60D10; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/func_80A60E08.s") +void func_80A60D10(BgSpoutFire* this, PlayState* play) { + if (func_80A60C24(this, play)) { + Math_StepToF(&this->actor.scale.y, 0.1f, 2.5f * 0.01f); + } else if (Math_StepToF(&this->actor.scale.y, 0.01f, 0.01f)) { + this->actor.draw = NULL; + this->actionFunc = func_80A60C94; + } else { + this->timer = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/BgSpoutFire_Update.s") +void func_80A60DA0(BgSpoutFire* this, PlayState* play) { + s16 phi_a3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spout_Fire/func_80A61040.s") + if (Actor_IsFacingPlayer(&this->actor, 0x4000)) { + phi_a3 = this->actor.shape.rot.y; + } else { + phi_a3 = (this->actor.shape.rot.y + 0x8000); + } + func_800B8D98(play, &this->actor, 5.0f, phi_a3, 1.0f); +} + +void func_80A60E08(BgSpoutFire* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f sp30; + f32 cos; + f32 sin; + + Actor_OffsetOfPointInActorCoords(&this->actor, &sp30, &player->actor.world.pos); + sp30.x = CLAMP(sp30.x, -74.25f, 74.25f); + if (this->timer == 0) { + if (sp30.z > 0.0f) { + sp30.z = -25.0f; + this->timer = -1; + } else { + sp30.z = 25.0f; + this->timer = 1; + } + } else { + sp30.z = this->timer * 25.0f; + } + sin = Math_SinS(this->actor.shape.rot.y); + cos = Math_CosS(this->actor.shape.rot.y); + this->collider.dim.pos.x = this->actor.world.pos.x + (sp30.x * cos) + (sp30.z * sin); + this->collider.dim.pos.z = this->actor.world.pos.z - (sp30.x * sin) + (sp30.z * cos); +} + +void BgSpoutFire_Update(Actor* thisx, PlayState* play) { + s32 pad; + BgSpoutFire* this = THIS; + + this->flameTexIndex = (this->flameTexIndex + 1) % 8; + if ((this->collider.base.atFlags & AT_HIT)) { + this->collider.base.atFlags &= ~AT_HIT; + func_80A60DA0(this, play); + } + this->actionFunc(this, play); + if (this->actionFunc == func_80A60D10) { + func_80A60E08(this, play); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + func_800B9010(&this->actor, NA_SE_EV_FIRE_PLATE - SFX_FLAG); + } +} + +void BgSpoutFire_Draw(Actor* thisx, PlayState* play) { + BgSpoutFire* this = THIS; + Gfx* gfx; + + OPEN_DISPS(play->state.gfxCtx); + + gfx = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); + POLY_XLU_DISP = gfx; + gSPSegment(&gfx[0], 0x08, sFlameTextures[this->flameTexIndex]); + gDPSetPrimColor(&gfx[1], 0, 1, 255, 255, 0, 150); + gDPSetEnvColor(&gfx[2], 255, 0, 0, 255); + Matrix_Translate(-55.0f, 0.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(&gfx[3], Matrix_NewMtx(play->state.gfxCtx), (G_MTX_NOPUSH | G_MTX_LOAD) | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[4], object_fwall_DL_000040); + POLY_XLU_DISP = &gfx[5]; + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.h b/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.h index 54260cf71..808b72061 100644 --- a/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.h +++ b/src/overlays/actors/ovl_Bg_Spout_Fire/z_bg_spout_fire.h @@ -8,9 +8,11 @@ struct BgSpoutFire; typedef void (*BgSpoutFireActionFunc)(struct BgSpoutFire*, PlayState*); typedef struct BgSpoutFire { - /* 0x0000 */ Actor actor; - /* 0x0144 */ BgSpoutFireActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x50]; + /* 0x000 */ Actor actor; + /* 0x144 */ BgSpoutFireActionFunc actionFunc; + /* 0x148 */ s16 timer; + /* 0x14A */ s16 flameTexIndex; + /* 0x14C */ ColliderCylinder collider; } BgSpoutFire; // size = 0x198 extern const ActorInit Bg_Spout_Fire_InitVars; diff --git a/src/overlays/actors/ovl_Boss_01/z_boss_01.c b/src/overlays/actors/ovl_Boss_01/z_boss_01.c index a07e2f31e..11790f377 100644 --- a/src/overlays/actors/ovl_Boss_01/z_boss_01.c +++ b/src/overlays/actors/ovl_Boss_01/z_boss_01.c @@ -130,7 +130,7 @@ static ColliderJntSphElementInit D_809D79D0[3] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809D7A3C = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 3, D_809D79D0, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809D79D0, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -144,7 +144,7 @@ static ColliderJntSphElementInit D_809D7A4C[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809D7A70 = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809D7A4C, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809D7A4C, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[11] = { @@ -198,7 +198,7 @@ static ColliderJntSphElementInit D_809D7A80[11] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809D7C0C = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 11, D_809D7A80, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809D7A80, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[2] = { @@ -216,7 +216,7 @@ static ColliderJntSphElementInit D_809D7C1C[2] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809D7C64 = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_809D7C1C, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809D7C1C, // sJntSphElementsInit, }; // static ColliderCylinderInit sCylinderInit = { diff --git a/src/overlays/actors/ovl_Boss_01/z_boss_01.h b/src/overlays/actors/ovl_Boss_01/z_boss_01.h index ff9b772dc..3d874a01f 100644 --- a/src/overlays/actors/ovl_Boss_01/z_boss_01.h +++ b/src/overlays/actors/ovl_Boss_01/z_boss_01.h @@ -8,10 +8,10 @@ struct Boss01; typedef void (*Boss01ActionFunc)(struct Boss01*, PlayState*); typedef struct Boss01 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x320]; - /* 0x0464 */ Boss01ActionFunc actionFunc; - /* 0x0468 */ char unk_468[0x674]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x320]; + /* 0x464 */ Boss01ActionFunc actionFunc; + /* 0x468 */ char unk_468[0x674]; } Boss01; // size = 0xADC extern const ActorInit Boss_01_InitVars; 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 d09698981..8a1d3e76b 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -4,7 +4,6 @@ * Description: Twinmold */ -#include "prevent_bss_reordering.h" #include "z_boss_02.h" #include "z64rumble.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" @@ -17,32 +16,32 @@ void Boss02_Init(Actor* thisx, PlayState* play); void Boss02_Destroy(Actor* thisx, PlayState* play); -void Boss02_Update(Actor* thisx, PlayState* play); -void Boss02_Draw(Actor* thisx, PlayState* play); +void Boss02_Twinmold_Update(Actor* thisx, PlayState* play); +void Boss02_Twinmold_Draw(Actor* thisx, PlayState* play); void func_809DAA74(Boss02* this, PlayState* play); void func_809DAA98(Boss02* this, PlayState* play); void func_809DAAA8(Boss02* this, PlayState* play); void func_809DAB78(Boss02* this, PlayState* play); -void func_809DC218(Actor* thisx, PlayState* play); -void func_809DC78C(Actor* thisx, PlayState* play); -void func_809DD0A8(Actor* thisx, PlayState* play); -void func_809DD0CC(PlayState* play); -void func_809DD2F8(PlayState* play); +void Boss02_Tail_Update(Actor* thisx, PlayState* play); +void Boss02_Static_Update(Actor* thisx, PlayState* play); +void Boss02_Static_Draw(Actor* thisx, PlayState* play); +void Boss02_UpdateEffects(PlayState* play); +void Boss02_DrawEffects(PlayState* play); void func_809DD934(Boss02* this, PlayState* play); void func_809DEAC4(Boss02* this, PlayState* play); u8 D_809E0420; u8 D_809E0421; -u8 D_809E0422; -Boss02* D_809E0424; -Boss02* D_809E0428; -Boss02* D_809E042C; -u8 D_809E0430; -DoorWarp1* D_809E0434; -Boss02Effects D_809E0438[150]; +u8 sIsInGiantMode; +Boss02* sRedTwinmold; +Boss02* sBlueTwinmold; +Boss02* sTwinmoldStatic; +u8 sMusicStartTimer; +DoorWarp1* sBlueWarp; +TwinmoldEffect sEffects[150]; -static DamageTable sDamageTable1 = { +static DamageTable sBlueTwinmoldDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -77,7 +76,7 @@ static DamageTable sDamageTable1 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -static DamageTable sDamageTable2 = { +static DamageTable sRedTwinmoldDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -120,8 +119,8 @@ const ActorInit Boss_02_InitVars = { sizeof(Boss02), (ActorFunc)Boss02_Init, (ActorFunc)Boss02_Destroy, - (ActorFunc)Boss02_Update, - (ActorFunc)Boss02_Draw, + (ActorFunc)Boss02_Twinmold_Update, + (ActorFunc)Boss02_Twinmold_Draw, }; f32 D_809DF5B0 = 1.0f; @@ -478,60 +477,60 @@ void func_809DA24C(PlayState* play) { MREG(64) = 0; } -void func_809DA264(Boss02Effects* effects, Vec3f* vec, f32 arg2) { +void Boss02_SpawnEffectSand(TwinmoldEffect* effects, Vec3f* pos, f32 scale) { s16 i; - for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effects++) { - if (effects->unk_24 == 0) { - effects->unk_24 = 1; - effects->unk_00 = *vec; - effects->unk_0C.x = randPlusMinusPoint5Scaled(30.0f); - effects->unk_0C.y = Rand_ZeroFloat(7.0f) + 7.0f; - effects->unk_0C.z = randPlusMinusPoint5Scaled(30.0f); - effects->unk_18.y = -0.3f; - effects->unk_34 = arg2; - effects->unk_2C = 255; - effects->unk_26 = 0; - effects->unk_38 = 2.0f * arg2; - effects->unk_18.x = effects->unk_18.z = 0.0f; + for (i = 0; i < ARRAY_COUNT(sEffects); i++, effects++) { + if (effects->type == TWINMOLD_EFFECT_NONE) { + effects->type = TWINMOLD_EFFECT_SAND; + effects->pos = *pos; + effects->velocity.x = randPlusMinusPoint5Scaled(30.0f); + effects->velocity.y = Rand_ZeroFloat(7.0f) + 7.0f; + effects->velocity.z = randPlusMinusPoint5Scaled(30.0f); + effects->accel.y = -0.3f; + effects->scale = scale; + effects->alpha = 255; + effects->timer = 0; + effects->targetScale = 2.0f * scale; + effects->accel.x = effects->accel.z = 0.0f; break; } } } -void func_809DA344(Boss02Effects* effects, Vec3f* vec) { +void Boss02_SpawnEffectFragment(TwinmoldEffect* effects, Vec3f* pos) { s16 i; - for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effects++) { - if (effects->unk_24 == 0) { - effects->unk_24 = 3; - effects->unk_00 = *vec; - effects->unk_26 = Rand_ZeroFloat(20.0f); - effects->unk_0C.x = randPlusMinusPoint5Scaled(50.0f); - effects->unk_0C.y = randPlusMinusPoint5Scaled(50.0f); - effects->unk_0C.z = randPlusMinusPoint5Scaled(50.0f); - effects->unk_18.z = 0.0f; - effects->unk_18.x = 0.0f; - effects->unk_18.y = -1.5f; - effects->unk_34 = Rand_ZeroFloat(0.04f) + 0.02f; - effects->unk_30 = Rand_ZeroFloat(32767.0f); - effects->unk_2E = Rand_ZeroFloat(32767.0f); + for (i = 0; i < ARRAY_COUNT(sEffects); i++, effects++) { + if (effects->type == TWINMOLD_EFFECT_NONE) { + effects->type = TWINMOLD_EFFECT_FRAGMENT; + effects->pos = *pos; + effects->timer = Rand_ZeroFloat(20.0f); + effects->velocity.x = randPlusMinusPoint5Scaled(50.0f); + effects->velocity.y = randPlusMinusPoint5Scaled(50.0f); + effects->velocity.z = randPlusMinusPoint5Scaled(50.0f); + effects->accel.z = 0.0f; + effects->accel.x = 0.0f; + effects->accel.y = -1.5f; + effects->scale = Rand_ZeroFloat(0.04f) + 0.02f; + effects->rotY = Rand_ZeroFloat(32767.0f); + effects->rotX = Rand_ZeroFloat(32767.0f); break; } } } -void func_809DA460(Boss02Effects* effects, Vec3f* vec) { +void Boss02_SpawnEffectFlash(TwinmoldEffect* effects, Vec3f* pos) { s16 i; - for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effects++) { - if ((effects->unk_24 == 0) || (effects->unk_24 == 3)) { - effects->unk_24 = 4; - effects->unk_00 = *vec; - Math_Vec3f_Copy(&effects->unk_0C, &gZeroVec3f); - Math_Vec3f_Copy(&effects->unk_18, &gZeroVec3f); - effects->unk_2C = 0xFF; - effects->unk_34 = 0.0f; + for (i = 0; i < ARRAY_COUNT(sEffects); i++, effects++) { + if ((effects->type == TWINMOLD_EFFECT_NONE) || (effects->type == TWINMOLD_EFFECT_FRAGMENT)) { + effects->type = TWINMOLD_EFFECT_FLASH; + effects->pos = *pos; + Math_Vec3f_Copy(&effects->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&effects->accel, &gZeroVec3f); + effects->alpha = 255; + effects->scale = 0.0f; break; } } @@ -550,47 +549,48 @@ void Boss02_Init(Actor* thisx, PlayState* play) { s32 i; s32 pad[2]; - if ((gSaveContext.save.weekEventReg[52] & 0x20) && (this->actor.params == 0)) { - D_809E0434 = (DoorWarp1*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, 0.0f, 60.0f, - 0.0f, 0, 0, 0, 1); + if ((gSaveContext.save.weekEventReg[52] & 0x20) && (this->actor.params == TWINMOLD_RED)) { + sBlueWarp = (DoorWarp1*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, 0.0f, 60.0f, + 0.0f, 0, 0, 0, 1); Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, 0.0f, 30.0f, -150.0f, 0, 1, 0, 0); } this->actor.targetMode = 10; - this->unk_1D3C.z = this->unk_1D3C.x = 0.0f; - this->unk_1D3C.y = 1.0f; - if (this->actor.params == 200) { - D_809E042C = this; - play->specialEffects = (void*)D_809E0438; - this->actor.update = func_809DC78C; - this->actor.draw = func_809DD0A8; + this->subCamUp.z = this->subCamUp.x = 0.0f; + this->subCamUp.y = 1.0f; + if (this->actor.params == TWINMOLD_STATIC) { + sTwinmoldStatic = this; + play->specialEffects = (void*)sEffects; + this->actor.update = Boss02_Static_Update; + this->actor.draw = Boss02_Static_Draw; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1D70 = 0.00999999977648f; - if ((KREG(64) != 0) || (gSaveContext.eventInf[5] & 0x20) || (D_809E0434 != NULL)) { + if ((KREG(64) != 0) || (gSaveContext.eventInf[5] & 0x20) || (sBlueWarp != NULL)) { this->unk_1D20 = 0; - D_809E0430 = KREG(15) + 20; + sMusicStartTimer = KREG(15) + 20; } else { this->unk_1D20 = 1; } XREG(41) = KREG(14) + 20; this->unk_01AC = 1.0f; Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_TANRON5, 0.0f, 1000.0f, 0.0f, 0, 0, 0, 0); - } else if (this->actor.params == 100) { - this->actor.update = func_809DC218; + } else if (this->actor.params == TWINMOLD_TAIL) { + this->actor.update = Boss02_Tail_Update; this->actor.draw = NULL; this->actor.hintId = 0x2E; } else { - if (this->actor.params != 35) { - this->actor.params = 0; - Actor_Spawn(&play->actorCtx, play, ACTOR_BOSS_02, 0.0f, 0.0f, 0.0f, 0, 0, 0, 200); - D_809E0424 = this; - D_809E0428 = (Boss02*)Actor_Spawn(&play->actorCtx, play, ACTOR_BOSS_02, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, - this->actor.world.rot.y, this->actor.world.rot.z, 35); - D_809E0424->actor.colChkInfo.damageTable = &sDamageTable2; - D_809E0428->actor.colChkInfo.damageTable = &sDamageTable1; - D_809E0424->unk_1674 = D_809E0428; - D_809E0428->unk_1674 = D_809E0424; + if (this->actor.params != TWINMOLD_BLUE) { + this->actor.params = TWINMOLD_RED; + Actor_Spawn(&play->actorCtx, play, ACTOR_BOSS_02, 0.0f, 0.0f, 0.0f, 0, 0, 0, TWINMOLD_STATIC); + sRedTwinmold = this; + sBlueTwinmold = + (Boss02*)Actor_Spawn(&play->actorCtx, play, ACTOR_BOSS_02, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, + this->actor.world.rot.y, this->actor.world.rot.z, TWINMOLD_BLUE); + sRedTwinmold->actor.colChkInfo.damageTable = &sRedTwinmoldDamageTable; + sBlueTwinmold->actor.colChkInfo.damageTable = &sBlueTwinmoldDamageTable; + sRedTwinmold->otherTwinmold = sBlueTwinmold; + sBlueTwinmold->otherTwinmold = sRedTwinmold; } this->actor.colChkInfo.mass = MASS_HEAVY; @@ -604,7 +604,7 @@ void Boss02_Init(Actor* thisx, PlayState* play) { this->colliderSphere2Elements); Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); - if (D_809E0434 != NULL) { + if (sBlueWarp != NULL) { func_809DAA74(this, play); } else { func_809DAAA8(this, play); @@ -618,7 +618,8 @@ void Boss02_Init(Actor* thisx, PlayState* play) { this->unk_014C = Rand_ZeroFloat(1000.0f); this->unk_1678 = 22; - Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_BOSS_02, 0.0f, 0.0f, 0.0f, 0, 0, 0, 100); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_BOSS_02, 0.0f, 0.0f, 0.0f, 0, 0, 0, + TWINMOLD_TAIL); } } @@ -636,14 +637,14 @@ void func_809DAA98(Boss02* this, PlayState* play) { void func_809DAAA8(Boss02* this, PlayState* play) { this->actionFunc = func_809DAB78; Animation_MorphToLoop(&this->skelAnime, &gTwinmoldHeadFlyAnim, 0.0f); - if (D_809E042C->unk_1D20 != 0) { + if (sTwinmoldStatic->unk_1D20 != 0) { this->unk_0144 = 10; } else { this->unk_0144 = 100; this->unk_01A8 = 25.0f; - D_809E042C->unk_1D7E = 100; + sTwinmoldStatic->unk_1D7E = 100; this->actor.world.pos.x = 0.0f; - if (D_809E0424 == this) { + if (sRedTwinmold == this) { this->actor.world.pos.z = -1000.0f; } else { this->actor.world.pos.z = 1400.0f; @@ -667,7 +668,7 @@ void func_809DAB78(Boss02* this, PlayState* play) { f32 phi_f2; s16 temp_s0; s16 temp_s2; - Boss02* spB0 = this->unk_1674; + Boss02* otherTwinmold = this->otherTwinmold; Vec3f spA4; f32 spA0; f32 sp9C; @@ -694,7 +695,7 @@ void func_809DAB78(Boss02* this, PlayState* play) { this->unk_01A4 = Math_SinS(this->unk_0196) * this->unk_019C; this->actor.world.rot.x = this->actor.shape.rot.x + this->unk_01A4; - if (!(this->unk_014C & 0x1F) && (D_809E042C->unk_1D20 == 0)) { + if (!(this->unk_014C & 0x1F) && (sTwinmoldStatic->unk_1D20 == 0)) { this->unk_01A0 = Rand_ZeroFloat(0x1000) + 0x800; this->unk_019A = Rand_ZeroFloat(0x400) + 0x200; } @@ -717,7 +718,7 @@ void func_809DAB78(Boss02* this, PlayState* play) { Actor_UpdatePos(&this->actor); spD0 = this->actor.world.pos; - if (D_809E0422 != 0) { + if (sIsInGiantMode) { spD0.y = 5000.0f; } else { spD0.y = 2000.0f; @@ -753,9 +754,9 @@ void func_809DAB78(Boss02* this, PlayState* play) { this->unk_0B1C[this->unk_014E].z = BINANG_TO_RAD(this->actor.world.rot.z); } - if ((this->unk_0144 < 10) && (spB0->unk_0144 >= 20)) { + if ((this->unk_0144 < 10) && (otherTwinmold->unk_0144 >= 20)) { this->unk_01B0.y = -1000.0f * D_809DF5B0; - if (D_809E0422 != 0) { + if (sIsInGiantMode) { this->unk_01B0.y += 3150.0f; } this->unk_0144 = 3; @@ -775,7 +776,7 @@ void func_809DAB78(Boss02* this, PlayState* play) { this->actor.world.pos.x = randPlusMinusPoint5Scaled(5000.0f * D_809DF5B0); this->actor.world.pos.z = randPlusMinusPoint5Scaled(5000.0f * D_809DF5B0); this->actor.world.pos.y = -500.0f * D_809DF5B0; - if (D_809E0422 != 0) { + if (sIsInGiantMode) { this->actor.world.pos.y += 3150.0f; } } @@ -808,7 +809,7 @@ void func_809DAB78(Boss02* this, PlayState* play) { this->unk_01B0.z = 500.0f; } this->unk_01B0.y = Rand_ZeroFloat(800.0f * D_809DF5B0) + (200.0f * D_809DF5B0); - if (D_809E0422 != 0) { + if (sIsInGiantMode) { this->unk_01B0.y += 3150.0f; } } @@ -825,7 +826,7 @@ void func_809DAB78(Boss02* this, PlayState* play) { if (sqrtf(SQ(spCC) + SQ(spC8) + SQ(spC4)) < (phi_f2 * D_809DF5B0)) { this->unk_0144 = 3; this->unk_01B0.y = -3000.0f * D_809DF5B0; - if (D_809E0422 != 0) { + if (sIsInGiantMode) { this->unk_01B0.y += 3150.0f; } this->unk_0146[0] = 150; @@ -847,7 +848,7 @@ void func_809DAB78(Boss02* this, PlayState* play) { this->unk_0144 = 3; this->unk_01B0.x = randPlusMinusPoint5Scaled(500.0f * D_809DF5B0) + this->actor.world.pos.x; this->unk_01B0.y = -3000.0f * D_809DF5B0; - if (D_809E0422 != 0) { + if (sIsInGiantMode) { this->unk_01B0.y += 3150.0f; } this->unk_01B0.z = randPlusMinusPoint5Scaled(500.0f * D_809DF5B0) + this->actor.world.pos.z; @@ -871,7 +872,7 @@ void func_809DAB78(Boss02* this, PlayState* play) { return; case 11: - if (this == D_809E0424) { + if (this == sRedTwinmold) { this->unk_01B0.x = D_809DF9C0[this->unk_1D1A].x; this->unk_01B0.y = D_809DF9C0[this->unk_1D1A].y; this->unk_01B0.z = D_809DF9C0[this->unk_1D1A].z; @@ -895,7 +896,7 @@ void func_809DAB78(Boss02* this, PlayState* play) { if (this->unk_1D1A > 8) { this->unk_1D1A = 8; } - if (this == D_809E0424) { + if (this == sRedTwinmold) { this->unk_01B0.x = D_809DF9C0[this->unk_1D1A].x; this->unk_01B0.y = D_809DF9C0[this->unk_1D1A].y; this->unk_01B0.z = D_809DF9C0[this->unk_1D1A].z; @@ -916,7 +917,7 @@ void func_809DAB78(Boss02* this, PlayState* play) { this->unk_0146[0] = 50; this->unk_01B0.x = player->actor.world.pos.x + spA4.x; this->unk_01B0.y = randPlusMinusPoint5Scaled(500.0f * D_809DF5B0) + (600.0f * D_809DF5B0); - if (D_809E0422 != 0) { + if (sIsInGiantMode) { this->unk_01B0.y += 3150.0f; } this->unk_01B0.z = player->actor.world.pos.z + spA4.z; @@ -934,8 +935,8 @@ void func_809DAB78(Boss02* this, PlayState* play) { this->unk_0144 = 21; this->unk_0146[0] = 20; this->unk_0152 = 0; - D_809E042C->unk_1D20 = 102; - D_809E042C->unk_1D5C = 0.0f; + sTwinmoldStatic->unk_1D20 = 102; + sTwinmoldStatic->subCamAtVel = 0.0f; play_sound(NA_SE_EN_INBOSS_DEAD_PRE2_OLD); } else if (!(this->unk_0146[1] & 0xF) && (Rand_ZeroOne() < 0.5f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); @@ -949,10 +950,10 @@ void func_809DAB78(Boss02* this, PlayState* play) { this->unk_0146[0] = 3; for (i = 0; i < 35; i++) { - func_809DA344(play->specialEffects, &this->unk_147C[this->unk_1678]); + Boss02_SpawnEffectFragment(play->specialEffects, &this->unk_147C[this->unk_1678]); } - func_809DA460(play->specialEffects, &this->unk_147C[this->unk_1678]); + Boss02_SpawnEffectFlash(play->specialEffects, &this->unk_147C[this->unk_1678]); play_sound(NA_SE_EV_EXPLOSION); this->unk_1678--; @@ -975,7 +976,7 @@ void func_809DAB78(Boss02* this, PlayState* play) { this->actor.speedXZ = 15.0f * D_809DF5B0; } - if (spB0->unk_0144 >= 10) { + if (otherTwinmold->unk_0144 >= 10) { Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000); } @@ -999,14 +1000,14 @@ void func_809DAB78(Boss02* this, PlayState* play) { this->unk_0170 = this->unk_017C; this->unk_016C = 30; this->unk_0170.y = this->actor.floorHeight; - D_809E042C->unk_1D20 = 103; - D_809E042C->unk_1D1C = 0; - D_809E042C->unk_0146[0] = 15; - D_809E042C->unk_0150 = 0; + sTwinmoldStatic->unk_1D20 = 103; + sTwinmoldStatic->unk_1D1C = 0; + sTwinmoldStatic->unk_0146[0] = 15; + sTwinmoldStatic->unk_0150 = 0; play_sound(NA_SE_EV_LIGHTNING); for (i = 0; i < 30; i++) { - func_809DA344(play->specialEffects, &this->unk_0170); + Boss02_SpawnEffectFragment(play->specialEffects, &this->unk_0170); } this->unk_0146[0] = 10; @@ -1053,13 +1054,13 @@ void func_809DAB78(Boss02* this, PlayState* play) { } void func_809DBFB4(Boss02* this, PlayState* play) { - Boss02* temp_s6 = this->unk_1674; + Boss02* otherTwinmold = this->otherTwinmold; s32 temp; s32 i; u8 damage; if (this->unk_0154 == 0) { - if (D_809E0422 != 0) { + if (sIsInGiantMode) { temp = 0; } else { temp = 1; @@ -1079,7 +1080,7 @@ void func_809DBFB4(Boss02* this, PlayState* play) { this->unk_015C = 10; } - if (D_809E0422 != 0) { + if (sIsInGiantMode) { this->unk_0152 = 15; } else { this->unk_0152 = 12; @@ -1087,7 +1088,7 @@ void func_809DBFB4(Boss02* this, PlayState* play) { damage = this->actor.colChkInfo.damage; - if (temp_s6->unk_0144 < 20) { + if (otherTwinmold->unk_0144 < 20) { do { do { this->actor.colChkInfo.health -= damage; @@ -1101,17 +1102,17 @@ void func_809DBFB4(Boss02* this, PlayState* play) { this->skelAnime.playSpeed = 2.0f; this->unk_0144 = 20; - if (temp_s6->unk_0144 >= 10) { + if (otherTwinmold->unk_0144 >= 10) { Audio_QueueSeqCmd(0x100100FF); } else { - temp_s6->unk_0195 = 1; + otherTwinmold->unk_0195 = 1; } this->unk_0146[1] = BREG(70) + 170; this->unk_0146[0] = 0; this->actor.shape.rot.x = 0x4000; - if (D_809E0422 == 0) { + if (!sIsInGiantMode) { if (this->actor.world.pos.y < -200.0f) { this->actor.world.pos.y = -200.0f; } @@ -1119,12 +1120,12 @@ void func_809DBFB4(Boss02* this, PlayState* play) { this->actor.world.pos.y = 3130.0f; } - D_809E042C->unk_1D20 = 100; + sTwinmoldStatic->unk_1D20 = 100; - if (this == D_809E0424) { - D_809E042C->unk_0194 = 0; + if (this == sRedTwinmold) { + sTwinmoldStatic->unk_0194 = 0; } else { - D_809E042C->unk_0194 = 1; + sTwinmoldStatic->unk_0194 = 1; } } } @@ -1133,23 +1134,23 @@ void func_809DBFB4(Boss02* this, PlayState* play) { } } -void func_809DC218(Actor* thisx, PlayState* play) { +void Boss02_Tail_Update(Actor* thisx, PlayState* play) { Boss02* this = THIS; s32 pad; - Vec3f sp24; - CollisionPoly* sp20; + Vec3f pos; + CollisionPoly* outPoly; this->unk_014C++; if ((this->unk_014C + this->actor.params) & 1) { - sp24 = this->actor.world.pos; + pos = this->actor.world.pos; this->actor.focus.pos = this->actor.world.pos; - if (D_809E0422 != 0) { - sp24.y = 5000.0f; + if (sIsInGiantMode) { + pos.y = 5000.0f; } else { - sp24.y = 2000.0f; + pos.y = 2000.0f; } - if ((this->actor.focus.pos.y < BgCheck_EntityRaycastFloor1(&play->colCtx, &sp20, &sp24)) || (D_809E0422 != 0)) { + if ((this->actor.focus.pos.y < BgCheck_EntityRaycastFloor1(&play->colCtx, &outPoly, &pos)) || sIsInGiantMode) { this->actor.flags &= ~ACTOR_FLAG_1; } else { this->actor.flags |= ACTOR_FLAG_1; @@ -1157,19 +1158,19 @@ void func_809DC218(Actor* thisx, PlayState* play) { } } -void Boss02_Update(Actor* thisx, PlayState* play) { +void Boss02_Twinmold_Update(Actor* thisx, PlayState* play) { Vec3f sp3C; Boss02* this = THIS; s32 pad; s16 i; - if (D_809E0422 == 0) { + if (!sIsInGiantMode) { Actor_SetScale(&this->actor, 0.6f); } else { Actor_SetScale(&this->actor, 0.060000001f); } - if (D_809E042C->unk_1D18 == 0) { + if (sTwinmoldStatic->unk_1D18 == 0) { for (i = 0; i < ARRAY_COUNT(this->unk_0146); i++) { if (this->unk_0146[i] != 0) { this->unk_0146[i]--; @@ -1206,14 +1207,14 @@ void Boss02_Update(Actor* thisx, PlayState* play) { sp3C.x = randPlusMinusPoint5Scaled(100.0f * D_809DF5B0) + this->unk_0170.x; sp3C.y = randPlusMinusPoint5Scaled(50.0f * D_809DF5B0) + this->unk_0170.y; sp3C.z = randPlusMinusPoint5Scaled(100.0f * D_809DF5B0) + this->unk_0170.z; - func_809DA264(play->specialEffects, &sp3C, Rand_ZeroFloat(3.0f) + 6.0f); + Boss02_SpawnEffectSand(play->specialEffects, &sp3C, Rand_ZeroFloat(3.0f) + 6.0f); } if ((this->unk_014C % 2) == 0) { sp3C.x = randPlusMinusPoint5Scaled(100.0f * D_809DF5B0) + this->unk_0170.x; sp3C.y = randPlusMinusPoint5Scaled(50.0f * D_809DF5B0) + this->unk_0170.y; sp3C.z = randPlusMinusPoint5Scaled(100.0f * D_809DF5B0) + this->unk_0170.z; - func_809DA264(play->specialEffects, &sp3C, Rand_ZeroFloat(3.0f) + 6.0f); + Boss02_SpawnEffectSand(play->specialEffects, &sp3C, Rand_ZeroFloat(3.0f) + 6.0f); } } @@ -1275,18 +1276,18 @@ void Boss02_Update(Actor* thisx, PlayState* play) { } } -void func_809DC78C(Actor* thisx, PlayState* play) { +void Boss02_Static_Update(Actor* thisx, PlayState* play) { Boss02* this = THIS; this->unk_01AC = D_809DF5B0; play->envCtx.sandstormState = 0xD; - if (D_809E0434 != NULL) { + if (sBlueWarp != NULL) { this->unk_1D74 = KREG(23) + -15.0f; D_801F4E30 = 0; play->envCtx.lightSettingOverride = 1; play->skyboxId = 1; - } else if (D_809E0422 == 0) { + } else if (!sIsInGiantMode) { this->unk_1D74 = 0.0f; D_801F4E30 = this->unk_1D7C; play->envCtx.lightSettingOverride = 0; @@ -1304,16 +1305,16 @@ void func_809DC78C(Actor* thisx, PlayState* play) { this->unk_0146[0]--; } - if (D_809E0434 == NULL) { - if (D_809E0430 != 0) { - D_809E0430--; - if (D_809E0430 == 0) { + if (sBlueWarp == NULL) { + if (sMusicStartTimer != 0) { + sMusicStartTimer--; + if (sMusicStartTimer == 0) { Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); } } } - func_809DD0CC(play); + Boss02_UpdateEffects(play); func_809DEAC4(this, play); func_809DD934(this, play); } @@ -1329,7 +1330,7 @@ Gfx* D_809DFA9C[] = { Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; -void Boss02_Draw(Actor* thisx, PlayState* play2) { +void Boss02_Twinmold_Draw(Actor* thisx, PlayState* play2) { PlayState* play = play2; Boss02* this = THIS; s32 i; @@ -1359,7 +1360,7 @@ void Boss02_Draw(Actor* thisx, PlayState* play2) { gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - if (D_809E0422 == 0) { + if (!sIsInGiantMode) { sp98 = -500.0f; } else { sp98 = 3100.0f; @@ -1453,7 +1454,7 @@ void Boss02_Draw(Actor* thisx, PlayState* play2) { CLOSE_DISPS(play->state.gfxCtx); - if (D_809E0422 == 0) { + if (!sIsInGiantMode) { func_809DA50C(0, &this->colliderSphere2, &D_809DFAF4); func_809DA50C(21, &this->colliderSphere1, &this->unk_147C[0]); } else { @@ -1462,150 +1463,152 @@ void Boss02_Draw(Actor* thisx, PlayState* play2) { } } -void func_809DD0A8(Actor* thisx, PlayState* play) { - func_809DD2F8(play); +void Boss02_Static_Draw(Actor* thisx, PlayState* play) { + Boss02_DrawEffects(play); } -void func_809DD0CC(PlayState* play) { - Boss02Effects* effect = (Boss02Effects*)play->specialEffects; - f32 phi_f22; +void Boss02_UpdateEffects(PlayState* play) { + TwinmoldEffect* effect = (TwinmoldEffect*)play->specialEffects; + f32 floorY; s16 i; - if (D_809E0422 == 0) { - phi_f22 = 0.0f; + if (!sIsInGiantMode) { + floorY = 0.0f; } else { - phi_f22 = 3150.0f; + floorY = 3150.0f; } - for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effect++) { - if (effect->unk_24) { - effect->unk_26++; - effect->unk_00.x += effect->unk_0C.x * D_809DF5B0; - effect->unk_00.y += effect->unk_0C.y * D_809DF5B0; - effect->unk_00.z += effect->unk_0C.z * D_809DF5B0; - effect->unk_0C.y += effect->unk_18.y; + for (i = 0; i < ARRAY_COUNT(sEffects); i++, effect++) { + if (effect->type) { + effect->timer++; + effect->pos.x += effect->velocity.x * D_809DF5B0; + effect->pos.y += effect->velocity.y * D_809DF5B0; + effect->pos.z += effect->velocity.z * D_809DF5B0; + effect->velocity.y += effect->accel.y; - if (effect->unk_24 < 3) { - Math_ApproachF(&effect->unk_34, effect->unk_38, 0.1f, 0.1f); - if (effect->unk_24 == 2) { - effect->unk_2C -= 18; + if (effect->type < TWINMOLD_EFFECT_FRAGMENT) { + Math_ApproachF(&effect->scale, effect->targetScale, 0.1f, 0.1f); + if (effect->type == TWINMOLD_EFFECT_BLACK_DUST) { + effect->alpha -= 18; } else { - effect->unk_2C -= 15; + effect->alpha -= 15; } - if (effect->unk_2C <= 0) { - effect->unk_24 = 0; + + if (effect->alpha <= 0) { + effect->type = TWINMOLD_EFFECT_NONE; } - } else if (effect->unk_24 == 3) { - effect->unk_2E += 0x1000; - effect->unk_30 += 0x1500; - if ((effect->unk_00.y < phi_f22) || (effect->unk_26 > 50)) { - effect->unk_24 = 0; + } else if (effect->type == TWINMOLD_EFFECT_FRAGMENT) { + effect->rotX += 0x1000; + effect->rotY += 0x1500; + if ((effect->pos.y < floorY) || (effect->timer > 50)) { + effect->type = TWINMOLD_EFFECT_NONE; } - } else if (effect->unk_24 == 4) { - Math_ApproachF(&effect->unk_34, 80.0f, 0.2f, 20.0f); - effect->unk_2C -= 15; - if (effect->unk_2C <= 0) { - effect->unk_24 = 0; + } else if (effect->type == TWINMOLD_EFFECT_FLASH) { + Math_ApproachF(&effect->scale, 80.0f, 0.2f, 20.0f); + effect->alpha -= 15; + if (effect->alpha <= 0) { + effect->type = TWINMOLD_EFFECT_NONE; } } } } } -void func_809DD2F8(PlayState* play) { +void Boss02_DrawEffects(PlayState* play) { u8 flag = false; - Boss02Effects* effect = (Boss02Effects*)play->specialEffects; + TwinmoldEffect* effect = (TwinmoldEffect*)play->specialEffects; s16 i; - u8 phi_a0; + u8 alpha; OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); func_8012C2DC(play->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effect++) { - if (effect->unk_24 == 1) { + for (i = 0; i < ARRAY_COUNT(sEffects); i++, effect++) { + if (effect->type == TWINMOLD_EFFECT_SAND) { if (!flag) { gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 185, 140, 70, 128); flag++; } - phi_a0 = effect->unk_2C; - if (effect->unk_2C > 255) { - phi_a0 = 255; + alpha = effect->alpha; + if (effect->alpha > 255) { + alpha = 255; } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 185, 140, 70, phi_a0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 185, 140, 70, alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, 0, effect->unk_26 + (i * 3), (effect->unk_26 + (i * 3)) * 5, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, effect->timer + (i * 3), (effect->timer + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->scale * D_809DF5B0, effect->scale * D_809DF5B0, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustModelDL); } } - effect = (Boss02Effects*)play->specialEffects; - for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { - if (effect->unk_24 == 3) { + effect = (TwinmoldEffect*)play->specialEffects; + for (i = 0, flag = false; i < ARRAY_COUNT(sEffects); i++, effect++) { + if (effect->type == TWINMOLD_EFFECT_FRAGMENT) { if (!flag) { gDPSetCombineLERP(POLY_OPA_DISP++, SHADE, 0, PRIMITIVE, 0, SHADE, 0, PRIMITIVE, 0, SHADE, 0, PRIMITIVE, 0, SHADE, 0, PRIMITIVE, 0); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x01, 100, 100, 120, 255); flag++; } - Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_RotateYS(effect->unk_30, MTXMODE_APPLY); - Matrix_RotateXS(effect->unk_2E, MTXMODE_APPLY); - Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, + + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateYS(effect->rotY, MTXMODE_APPLY); + Matrix_RotateXS(effect->rotX, MTXMODE_APPLY); + Matrix_Scale(effect->scale * D_809DF5B0, effect->scale * D_809DF5B0, effect->scale * D_809DF5B0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_01A620); + gSPDisplayList(POLY_OPA_DISP++, gEffFragments1DL); } } - effect = (Boss02Effects*)play->specialEffects; - for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { - if (effect->unk_24 == 4) { + effect = (TwinmoldEffect*)play->specialEffects; + for (i = 0, flag = false; i < ARRAY_COUNT(sEffects); i++, effect++) { + if (effect->type == TWINMOLD_EFFECT_FLASH) { if (!flag) { //! @bug - dev forgot to set flag to 1, should only apply to first entry? gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)effect->unk_2C); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)effect->alpha); - Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->scale * D_809DF5B0, effect->scale * D_809DF5B0, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } } - effect = (Boss02Effects*)play->specialEffects; - for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { - if (effect->unk_24 == 2) { + effect = (TwinmoldEffect*)play->specialEffects; + for (i = 0, flag = false; i < ARRAY_COUNT(sEffects); i++, effect++) { + if (effect->type == TWINMOLD_EFFECT_BLACK_DUST) { if (!flag) { gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 30, 30, 30, 128); flag++; } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 30, 30, 30, (u8)effect->unk_2C); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 30, 30, 30, (u8)effect->alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, 0, effect->unk_26 + (i * 3), (effect->unk_26 + (i * 3)) * 5, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, effect->timer + (i * 3), (effect->timer + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->scale * D_809DF5B0, effect->scale * D_809DF5B0, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustModelDL); @@ -1630,14 +1633,14 @@ void func_809DD934(Boss02* this, PlayState* play) { case 0: if (player->stateFlags1 & 0x100) { Cutscene_Start(play, &play->csCtx); - this->unk_1D22 = Play_CreateSubCamera(play); - Play_CameraChangeStatus(play, CAM_ID_MAIN, 1); - Play_CameraChangeStatus(play, this->unk_1D22, 7); + this->subCamId = Play_CreateSubCamera(play); + Play_CameraChangeStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_CameraChangeStatus(play, this->subCamId, CAM_STATUS_ACTIVE); func_8016566C(150); this->unk_1D14 = 0; - this->unk_1D5C = 0.0f; + this->subCamAtVel = 0.0f; this->unk_1D58 = 0.0f; - if (D_809E0422 == 0) { + if (!sIsInGiantMode) { this->unk_1D18 = 1; this->unk_1D68 = 10.0f; this->unk_1D64 = 60.0f; @@ -1659,7 +1662,7 @@ void func_809DD934(Boss02* this, PlayState* play) { break; case 1: - if ((this->unk_1D14 < 80U) && (D_809E0420 != 0) && + if ((this->unk_1D14 < 80) && (D_809E0420 != 0) && CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) { this->unk_1D18++; @@ -1667,30 +1670,30 @@ void func_809DD934(Boss02* this, PlayState* play) { this->unk_1D14 = 0; } else { label1: - if (this->unk_1D14 >= 50U) { + if (this->unk_1D14 >= 50) { if (this->unk_1D14 == (u32)(BREG(43) + 60)) { play_sound(NA_SE_PL_TRANSFORM_GIANT); } - Math_ApproachF(&this->unk_1D64, 200.0f, 0.1f, this->unk_1D5C * 640.0f); - Math_ApproachF(&this->unk_1D6C, 273.0f, 0.1f, this->unk_1D5C * 150.0f); - Math_ApproachF(&this->unk_1D70, 0.1f, 0.2f, this->unk_1D5C * 0.1f); - Math_ApproachF(&this->unk_1D74, -100.0f, 1.0f, this->unk_1D5C * 100.0f); - Math_ApproachF(&this->unk_1D5C, 1.0f, 1.0f, 0.001f); + Math_ApproachF(&this->unk_1D64, 200.0f, 0.1f, this->subCamAtVel * 640.0f); + Math_ApproachF(&this->unk_1D6C, 273.0f, 0.1f, this->subCamAtVel * 150.0f); + Math_ApproachF(&this->unk_1D70, 0.1f, 0.2f, this->subCamAtVel * 0.1f); + Math_ApproachF(&this->unk_1D74, -100.0f, 1.0f, this->subCamAtVel * 100.0f); + Math_ApproachF(&this->subCamAtVel, 1.0f, 1.0f, 0.001f); } else { Math_ApproachF(&this->unk_1D64, 30.0f, 0.1f, 1.0f); } - if (this->unk_1D14 > 50U) { + if (this->unk_1D14 > 50) { Math_ApproachZeroF(&this->unk_1D58, 1.0f, 0.06f); } else { Math_ApproachF(&this->unk_1D58, 0.4f, 1.0f, 0.02f); } - if (this->unk_1D14 == 107U) { + if (this->unk_1D14 == 107) { this->unk_1D78 = 1; } - if (this->unk_1D14 < 121U) { + if (this->unk_1D14 < 121) { break; } @@ -1701,14 +1704,14 @@ void func_809DD934(Boss02* this, PlayState* play) { break; case 2: - if (this->unk_1D14 < 8U) { + if (this->unk_1D14 < 8) { break; } sp57 = 1; goto block_38; case 10: - if ((this->unk_1D14 < 30U) && (D_809E0421 != 0) && + if ((this->unk_1D14 < 30) && (D_809E0421 != 0) && CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) { this->unk_1D18++; @@ -1718,37 +1721,37 @@ void func_809DD934(Boss02* this, PlayState* play) { } label2: - if (this->unk_1D14 != 0U) { + if (this->unk_1D14 != 0) { if (this->unk_1D14 == (u32)(BREG(44) + 10)) { play_sound(NA_SE_PL_TRANSFORM_NORAML); } - Math_ApproachF(&this->unk_1D64, 60.0f, 0.1f, this->unk_1D5C * 640.0f); - Math_ApproachF(&this->unk_1D6C, 23.0f, 0.1f, this->unk_1D5C * 150.0f); + Math_ApproachF(&this->unk_1D64, 60.0f, 0.1f, this->subCamAtVel * 640.0f); + Math_ApproachF(&this->unk_1D6C, 23.0f, 0.1f, this->subCamAtVel * 150.0f); Math_ApproachF(&this->unk_1D70, 0.01f, 0.1f, 0.003f); - Math_ApproachF(&this->unk_1D74, 0.0f, 1.0f, this->unk_1D5C * 100.0f); - Math_ApproachF(&this->unk_1D5C, 2.0f, 1.0f, 0.01f); + Math_ApproachF(&this->unk_1D74, 0.0f, 1.0f, this->subCamAtVel * 100.0f); + Math_ApproachF(&this->subCamAtVel, 2.0f, 1.0f, 0.01f); } - if (this->unk_1D14 == 42U) { + if (this->unk_1D14 == 42) { this->unk_1D78 = 1; } - if (this->unk_1D14 > 50U) { + if (this->unk_1D14 > 50) { D_809E0421 = 1; goto block_38; } break; case 11: - if (this->unk_1D14 < 8U) { + if (this->unk_1D14 < 8) { break; } block_38: case 20: this->unk_1D18 = 0; - func_80169AFC(play, this->unk_1D22, 0); - this->unk_1D22 = 0; + func_80169AFC(play, this->subCamId, 0); + this->subCamId = SUB_CAM_ID_DONE; Cutscene_End(play, &play->csCtx); this->actor.flags |= ACTOR_FLAG_1; player->stateFlags1 &= ~0x100; @@ -1766,19 +1769,19 @@ void func_809DD934(Boss02* this, PlayState* play) { play->envCtx.lightSettings.fogNear = this->unk_1D74; if (sp57) { - D_809E0422 = 1 - D_809E0422; - if (D_809E0422 == 0) { + sIsInGiantMode = 1 - sIsInGiantMode; + if (!sIsInGiantMode) { D_809DF5B0 = 1.0f; } else { D_809DF5B0 = 0.1f; } this->unk_01AC = D_809DF5B0; - if (D_809E0422 == 0) { - if (D_809E0434 != NULL) { - D_809E0434->unk_203 = 0; - D_809E0434->unk_204 = 1.0f; - D_809E0434->dyna.actor.world.pos.y = 60.0f; + if (!sIsInGiantMode) { + if (sBlueWarp != NULL) { + sBlueWarp->unk_203 = 0; + sBlueWarp->unk_204 = 1.0f; + sBlueWarp->dyna.actor.world.pos.y = 60.0f; } player->actor.world.pos.x *= 10.0f; @@ -1787,70 +1790,70 @@ void func_809DD934(Boss02* this, PlayState* play) { player->unk_B68 = player->actor.world.pos.y; player->actor.world.pos.z *= 10.0f; - if ((D_809E0434 != NULL) && ((SQ(player->actor.world.pos.z) + SQ(player->actor.world.pos.x)) < SQ(60.0f))) { + if ((sBlueWarp != NULL) && ((SQ(player->actor.world.pos.z) + SQ(player->actor.world.pos.x)) < SQ(60.0f))) { player->actor.world.pos.z = 60.0f; player->actor.world.pos.x = 60.0f; } - D_809E0424->actor.world.pos.x *= 10.0f; - D_809E0424->actor.world.pos.y -= 3150.0f; - D_809E0424->actor.world.pos.y *= 10.0f; - D_809E0424->actor.world.pos.z *= 10.0f; + sRedTwinmold->actor.world.pos.x *= 10.0f; + sRedTwinmold->actor.world.pos.y -= 3150.0f; + sRedTwinmold->actor.world.pos.y *= 10.0f; + sRedTwinmold->actor.world.pos.z *= 10.0f; - D_809E0424->unk_0170.x *= 10.0f; - D_809E0424->unk_0170.y -= 3150.0f; - D_809E0424->unk_0170.y *= 10.0f; - D_809E0424->unk_0170.z *= 10.0f; + sRedTwinmold->unk_0170.x *= 10.0f; + sRedTwinmold->unk_0170.y -= 3150.0f; + sRedTwinmold->unk_0170.y *= 10.0f; + sRedTwinmold->unk_0170.z *= 10.0f; for (i = 0; i < ARRAY_COUNT(this->unk_01BC); i++) { - D_809E0424->unk_01BC[i].x *= 10.0f; - D_809E0424->unk_01BC[i].y -= 3150.0f; - D_809E0424->unk_01BC[i].y *= 10.0f; - D_809E0424->unk_01BC[i].z *= 10.0f; + sRedTwinmold->unk_01BC[i].x *= 10.0f; + sRedTwinmold->unk_01BC[i].y -= 3150.0f; + sRedTwinmold->unk_01BC[i].y *= 10.0f; + sRedTwinmold->unk_01BC[i].z *= 10.0f; } - D_809E0424->unk_01B0.x *= 10.0f; - D_809E0424->unk_01B0.y -= 3150.0f; - D_809E0424->unk_01B0.y *= 10.0f; - D_809E0424->unk_01B0.z *= 10.0f; + sRedTwinmold->unk_01B0.x *= 10.0f; + sRedTwinmold->unk_01B0.y -= 3150.0f; + sRedTwinmold->unk_01B0.y *= 10.0f; + sRedTwinmold->unk_01B0.z *= 10.0f; - D_809E0424->unk_017C.y -= 3150.0f; - D_809E0424->unk_017C.y *= 10.0f; - D_809E0424->unk_0188.y -= 3150.0f; - D_809E0424->unk_0188.y *= 10.0f; + sRedTwinmold->unk_017C.y -= 3150.0f; + sRedTwinmold->unk_017C.y *= 10.0f; + sRedTwinmold->unk_0188.y -= 3150.0f; + sRedTwinmold->unk_0188.y *= 10.0f; - D_809E0428->actor.world.pos.x *= 10.0f; - D_809E0428->actor.world.pos.y -= 3150.0f; - D_809E0428->actor.world.pos.y *= 10.0f; - D_809E0428->actor.world.pos.z *= 10.0f; + sBlueTwinmold->actor.world.pos.x *= 10.0f; + sBlueTwinmold->actor.world.pos.y -= 3150.0f; + sBlueTwinmold->actor.world.pos.y *= 10.0f; + sBlueTwinmold->actor.world.pos.z *= 10.0f; - D_809E0428->unk_0170.x *= 10.0f; - D_809E0428->unk_0170.y -= 3150.0f; - D_809E0428->unk_0170.y *= 10.0f; - D_809E0428->unk_0170.z *= 10.0f; + sBlueTwinmold->unk_0170.x *= 10.0f; + sBlueTwinmold->unk_0170.y -= 3150.0f; + sBlueTwinmold->unk_0170.y *= 10.0f; + sBlueTwinmold->unk_0170.z *= 10.0f; for (i = 0; i < ARRAY_COUNT(this->unk_01BC); i++) { - D_809E0428->unk_01BC[i].x *= 10.0f; - D_809E0428->unk_01BC[i].y -= 3150.0f; - D_809E0428->unk_01BC[i].y *= 10.0f; - D_809E0428->unk_01BC[i].z *= 10.0f; + sBlueTwinmold->unk_01BC[i].x *= 10.0f; + sBlueTwinmold->unk_01BC[i].y -= 3150.0f; + sBlueTwinmold->unk_01BC[i].y *= 10.0f; + sBlueTwinmold->unk_01BC[i].z *= 10.0f; } - D_809E0428->unk_01B0.x *= 10.0f; - D_809E0428->unk_01B0.y -= 3150.0f; - D_809E0428->unk_01B0.y *= 10.0f; - D_809E0428->unk_01B0.z *= 10.0f; + sBlueTwinmold->unk_01B0.x *= 10.0f; + sBlueTwinmold->unk_01B0.y -= 3150.0f; + sBlueTwinmold->unk_01B0.y *= 10.0f; + sBlueTwinmold->unk_01B0.z *= 10.0f; - D_809E0428->unk_017C.y -= 3150.0f; - D_809E0428->unk_017C.y *= 10.0f; - D_809E0428->unk_0188.y -= 3150.0f; - D_809E0428->unk_0188.y *= 10.0f; + sBlueTwinmold->unk_017C.y -= 3150.0f; + sBlueTwinmold->unk_017C.y *= 10.0f; + sBlueTwinmold->unk_0188.y -= 3150.0f; + sBlueTwinmold->unk_0188.y *= 10.0f; } else { - if (D_809E0434 != 0) { - D_809E0434->unk_203 = 1; - D_809E0434->unk_204 = 0.1f; - D_809E0434->dyna.actor.world.pos.y = 3155.0f; + if (sBlueWarp != 0) { + sBlueWarp->unk_203 = 1; + sBlueWarp->unk_204 = 0.1f; + sBlueWarp->dyna.actor.world.pos.y = 3155.0f; } player->actor.world.pos.x *= 0.1f; @@ -1859,59 +1862,59 @@ void func_809DD934(Boss02* this, PlayState* play) { player->unk_B68 = player->actor.world.pos.y; player->actor.world.pos.z *= 0.1f; - D_809E0424->actor.world.pos.x *= 0.1f; - D_809E0424->actor.world.pos.y *= 0.1f; - D_809E0424->actor.world.pos.y += 3150.0f; - D_809E0424->actor.world.pos.z *= 0.1f; + sRedTwinmold->actor.world.pos.x *= 0.1f; + sRedTwinmold->actor.world.pos.y *= 0.1f; + sRedTwinmold->actor.world.pos.y += 3150.0f; + sRedTwinmold->actor.world.pos.z *= 0.1f; - D_809E0424->unk_0170.x *= 0.1f; - D_809E0424->unk_0170.y *= 0.1f; - D_809E0424->unk_0170.y += 3150.0f; - D_809E0424->unk_0170.z *= 0.1f; + sRedTwinmold->unk_0170.x *= 0.1f; + sRedTwinmold->unk_0170.y *= 0.1f; + sRedTwinmold->unk_0170.y += 3150.0f; + sRedTwinmold->unk_0170.z *= 0.1f; for (i = 0; i < ARRAY_COUNT(this->unk_01BC); i++) { - D_809E0424->unk_01BC[i].x *= 0.1f; - D_809E0424->unk_01BC[i].y *= 0.1f; - D_809E0424->unk_01BC[i].y += 3150.0f; - D_809E0424->unk_01BC[i].z *= 0.1f; + sRedTwinmold->unk_01BC[i].x *= 0.1f; + sRedTwinmold->unk_01BC[i].y *= 0.1f; + sRedTwinmold->unk_01BC[i].y += 3150.0f; + sRedTwinmold->unk_01BC[i].z *= 0.1f; } - D_809E0424->unk_01B0.x *= 0.1f; - D_809E0424->unk_01B0.y *= 0.1f; - D_809E0424->unk_01B0.y += 3150.0f; - D_809E0424->unk_01B0.z *= 0.1f; + sRedTwinmold->unk_01B0.x *= 0.1f; + sRedTwinmold->unk_01B0.y *= 0.1f; + sRedTwinmold->unk_01B0.y += 3150.0f; + sRedTwinmold->unk_01B0.z *= 0.1f; - D_809E0424->unk_017C.y *= 0.1f; - D_809E0424->unk_017C.y += 3150.0f; - D_809E0424->unk_0188.y *= 0.1f; - D_809E0424->unk_0188.y += 3150.0f; + sRedTwinmold->unk_017C.y *= 0.1f; + sRedTwinmold->unk_017C.y += 3150.0f; + sRedTwinmold->unk_0188.y *= 0.1f; + sRedTwinmold->unk_0188.y += 3150.0f; - D_809E0428->actor.world.pos.x *= 0.1f; - D_809E0428->actor.world.pos.y *= 0.1f; - D_809E0428->actor.world.pos.y += 3150.0f; - D_809E0428->actor.world.pos.z *= 0.1f; + sBlueTwinmold->actor.world.pos.x *= 0.1f; + sBlueTwinmold->actor.world.pos.y *= 0.1f; + sBlueTwinmold->actor.world.pos.y += 3150.0f; + sBlueTwinmold->actor.world.pos.z *= 0.1f; - D_809E0428->unk_0170.x *= 0.1f; - D_809E0428->unk_0170.y *= 0.1f; - D_809E0428->unk_0170.y += 3150.0f; - D_809E0428->unk_0170.z *= 0.1f; + sBlueTwinmold->unk_0170.x *= 0.1f; + sBlueTwinmold->unk_0170.y *= 0.1f; + sBlueTwinmold->unk_0170.y += 3150.0f; + sBlueTwinmold->unk_0170.z *= 0.1f; for (i = 0; i < ARRAY_COUNT(this->unk_01BC); i++) { - D_809E0428->unk_01BC[i].x *= 0.1f; - D_809E0428->unk_01BC[i].y *= 0.1f; - D_809E0428->unk_01BC[i].y += 3150.0f; - D_809E0428->unk_01BC[i].z *= 0.1f; + sBlueTwinmold->unk_01BC[i].x *= 0.1f; + sBlueTwinmold->unk_01BC[i].y *= 0.1f; + sBlueTwinmold->unk_01BC[i].y += 3150.0f; + sBlueTwinmold->unk_01BC[i].z *= 0.1f; } - D_809E0428->unk_01B0.x *= 0.1f; - D_809E0428->unk_01B0.y *= 0.1f; - D_809E0428->unk_01B0.y += 3150.0f; - D_809E0428->unk_01B0.z *= 0.1f; + sBlueTwinmold->unk_01B0.x *= 0.1f; + sBlueTwinmold->unk_01B0.y *= 0.1f; + sBlueTwinmold->unk_01B0.y += 3150.0f; + sBlueTwinmold->unk_01B0.z *= 0.1f; - D_809E0428->unk_017C.y *= 0.1f; - D_809E0428->unk_017C.y += 3150.0f; - D_809E0428->unk_0188.y *= 0.1f; - D_809E0428->unk_0188.y += 3150.0f; + sBlueTwinmold->unk_017C.y *= 0.1f; + sBlueTwinmold->unk_017C.y += 3150.0f; + sBlueTwinmold->unk_0188.y *= 0.1f; + sBlueTwinmold->unk_0188.y += 3150.0f; } player->actor.home.pos = player->actor.world.pos; @@ -1926,15 +1929,15 @@ void func_809DD934(Boss02* this, PlayState* play) { temp_a0_5 = temp_a0_5->next; } { - f32 tmp = D_809E0422 ? 3150.0f : 0.0f; + f32 tmp = sIsInGiantMode ? 3150.0f : 0.0f; - Actor_Spawn(&play->actorCtx, play, ACTOR_BG_INIBS_MOVEBG, 0, tmp, 0, 0, 0, 0, D_809E0422); + Actor_Spawn(&play->actorCtx, play, ACTOR_BG_INIBS_MOVEBG, 0, tmp, 0, 0, 0, 0, sIsInGiantMode); } temp_a0_5 = play->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) { + if (!sIsInGiantMode) { temp_a0_5->world.pos.y -= 3150.0f; temp_a0_5->world.pos.y *= 10.0f; @@ -2014,22 +2017,22 @@ void func_809DD934(Boss02* this, PlayState* play) { break; } - if ((this->unk_1D18 != 0) && (this->unk_1D22 != 0)) { + if ((this->unk_1D18 != 0) && (this->subCamId != SUB_CAM_ID_DONE)) { Matrix_RotateYS(player->actor.shape.rot.y, MTXMODE_NEW); Matrix_MultVecZ(this->unk_1D64, &sp58); - this->unk_1D24.x = player->actor.world.pos.x + sp58.x; - this->unk_1D24.y = player->actor.world.pos.y + sp58.y + this->unk_1D68; - this->unk_1D24.z = player->actor.world.pos.z + sp58.z; + this->subCamEye.x = player->actor.world.pos.x + sp58.x; + this->subCamEye.y = player->actor.world.pos.y + sp58.y + this->unk_1D68; + this->subCamEye.z = player->actor.world.pos.z + sp58.z; - this->unk_1D30.x = player->actor.world.pos.x; - this->unk_1D30.y = player->actor.world.pos.y + this->unk_1D6C; - this->unk_1D30.z = player->actor.world.pos.z; + this->subCamAt.x = player->actor.world.pos.x; + this->subCamAt.y = player->actor.world.pos.y + this->unk_1D6C; + this->subCamAt.z = player->actor.world.pos.z; this->unk_1D54 = Math_SinS(this->unk_1D14 * 1512) * this->unk_1D58; Matrix_RotateZF(this->unk_1D54, MTXMODE_APPLY); - Matrix_MultVecY(1.0f, &this->unk_1D3C); - Play_CameraSetAtEyeUp(play, this->unk_1D22, &this->unk_1D30, &this->unk_1D24, &this->unk_1D3C); + Matrix_MultVecY(1.0f, &this->subCamUp); + Play_CameraSetAtEyeUp(play, this->subCamId, &this->subCamAt, &this->subCamEye, &this->subCamUp); ShrinkWindow_SetLetterboxTarget(27); } } @@ -2037,14 +2040,14 @@ void func_809DD934(Boss02* this, PlayState* play) { void func_809DEAC4(Boss02* this, PlayState* play) { Player* player = GET_PLAYER(play); Boss02* sp68; - Vec3f sp5C; + Vec3f subCamEye; f32 sp58 = 0.0f; this->unk_1D1C++; if (this->unk_0194 == 0) { - sp68 = D_809E0424; + sp68 = sRedTwinmold; } else { - sp68 = D_809E0428; + sp68 = sBlueTwinmold; } switch (this->unk_1D20) { @@ -2056,22 +2059,22 @@ void func_809DEAC4(Boss02* this, PlayState* play) { break; } Cutscene_Start(play, &play->csCtx); - this->unk_1D22 = Play_CreateSubCamera(play); - Play_CameraChangeStatus(play, CAM_ID_MAIN, 1); - Play_CameraChangeStatus(play, this->unk_1D22, 7); + this->subCamId = Play_CreateSubCamera(play); + Play_CameraChangeStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_CameraChangeStatus(play, this->subCamId, CAM_STATUS_ACTIVE); this->unk_1D20 = 2; this->unk_1D1C = 0; case 2: 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 = (Player_GetHeight(player) + player->actor.world.pos.y) - 29.0f; - this->unk_1D24.z = player->actor.world.pos.z - 50; + this->subCamEye.x = player->actor.world.pos.x - 20.0f; + this->subCamEye.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 29.0f; + this->subCamEye.z = player->actor.world.pos.z - 50; - this->unk_1D30.x = player->actor.world.pos.x; - this->unk_1D30.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 17.0f; - this->unk_1D30.z = player->actor.world.pos.z; + this->subCamAt.x = player->actor.world.pos.x; + this->subCamAt.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 17.0f; + this->subCamAt.z = player->actor.world.pos.z; if (this->unk_1D1C >= 30) { if (this->unk_1D1C == 30) { Rumble_Override(0.0f, 50, 200, 1); @@ -2079,7 +2082,7 @@ void func_809DEAC4(Boss02* this, PlayState* play) { this->unk_0150 += 0x4000; sp58 = (Math_SinS(this->unk_0150) * (BREG(19) + 5)) * 0.1f; Matrix_RotateZF(Math_SinS(this->unk_1D1C * 0x3000) * ((KREG(28) * 0.001f) + 0.017f), MTXMODE_NEW); - Matrix_MultVecY(1.0f, &this->unk_1D3C); + Matrix_MultVecY(1.0f, &this->subCamUp); func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); } @@ -2089,12 +2092,12 @@ void func_809DEAC4(Boss02* this, PlayState* play) { if (this->unk_1D1C == 45) { func_800B7298(play, &this->actor, 21); - D_809E0430 = KREG(91) + 43; + sMusicStartTimer = KREG(91) + 43; } if (this->unk_1D1C == 85) { - D_809E0424->unk_0144 = 11; - D_809E0424->unk_014C = 0; + sRedTwinmold->unk_0144 = 11; + sRedTwinmold->unk_014C = 0; } if (this->unk_1D1C == 92) { @@ -2113,22 +2116,22 @@ void func_809DEAC4(Boss02* this, PlayState* play) { case 10: if (this->unk_1D1C < 310) { - this->unk_1D48 = sp68->actor.world.pos; - this->unk_1D24.x = (sp68->actor.world.pos.x * 50.0f) * 0.001f; - this->unk_1D24.y = (sp68->actor.world.pos.y * 50.0f) * 0.001f; - if (this->unk_1D24.y < 100.0f) { - this->unk_1D24.y = 100.0f; + this->subCamAtNext = sp68->actor.world.pos; + this->subCamEye.x = (sp68->actor.world.pos.x * 50.0f) * 0.001f; + this->subCamEye.y = (sp68->actor.world.pos.y * 50.0f) * 0.001f; + if (this->subCamEye.y < 100.0f) { + this->subCamEye.y = 100.0f; } - this->unk_1D24.z = (sp68->actor.world.pos.z * 100) * 0.001f; + this->subCamEye.z = (sp68->actor.world.pos.z * 100) * 0.001f; } - Math_ApproachF(&this->unk_1D30.x, this->unk_1D48.x, 0.1f, 3000.0f); - Math_ApproachF(&this->unk_1D30.y, this->unk_1D48.y, 0.1f, 3000.0f); - Math_ApproachF(&this->unk_1D30.z, this->unk_1D48.z, 0.1f, 3000.0f); + Math_ApproachF(&this->subCamAt.x, this->subCamAtNext.x, 0.1f, 3000.0f); + Math_ApproachF(&this->subCamAt.y, this->subCamAtNext.y, 0.1f, 3000.0f); + Math_ApproachF(&this->subCamAt.z, this->subCamAtNext.z, 0.1f, 3000.0f); if (this->unk_1D1C == 100) { - D_809E0428->unk_0144 = 11; - D_809E0428->unk_014C = 0; + sBlueTwinmold->unk_0144 = 11; + sBlueTwinmold->unk_014C = 0; this->unk_0194 = 1; } @@ -2138,14 +2141,14 @@ void func_809DEAC4(Boss02* this, PlayState* play) { } if (this->unk_1D1C == (u32)(BREG(27) + 335)) { - func_80169AFC(play, this->unk_1D22, 0); - this->unk_1D22 = 0; + func_80169AFC(play, this->subCamId, 0); + this->subCamId = SUB_CAM_ID_DONE; Cutscene_End(play, &play->csCtx); func_800B7298(play, &this->actor, 6); this->actor.flags |= ACTOR_FLAG_1; this->unk_1D20 = 0; - D_809E0424->unk_0144 = D_809E0428->unk_0144 = 3; - D_809E0424->unk_0146[0] = D_809E0428->unk_0146[0] = 60; + sRedTwinmold->unk_0144 = sBlueTwinmold->unk_0144 = 3; + sRedTwinmold->unk_0146[0] = sBlueTwinmold->unk_0146[0] = 60; gSaveContext.eventInf[5] |= 0x20; } break; @@ -2153,13 +2156,13 @@ void func_809DEAC4(Boss02* this, PlayState* play) { case 100: if (ActorCutscene_GetCurrentIndex() == -1) { Cutscene_Start(play, &play->csCtx); - this->unk_1D22 = Play_CreateSubCamera(play); - Play_CameraChangeStatus(play, CAM_ID_MAIN, 1); - Play_CameraChangeStatus(play, this->unk_1D22, 7); + this->subCamId = Play_CreateSubCamera(play); + Play_CameraChangeStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_CameraChangeStatus(play, this->subCamId, CAM_STATUS_ACTIVE); this->unk_1D20 = 101; this->unk_1D1C = 0; - this->unk_1D5C = 1.0f; - this->unk_1D30 = sp68->actor.world.pos; + this->subCamAtVel = 1.0f; + this->subCamAt = sp68->actor.world.pos; } else { break; } @@ -2168,30 +2171,30 @@ void func_809DEAC4(Boss02* this, PlayState* play) { case 102: case_10x: if ((this->unk_1D20 == 101) || (this->unk_1D20 == 103)) { - this->unk_1D48 = sp68->actor.world.pos; + this->subCamAtNext = sp68->actor.world.pos; } else { - this->unk_1D48 = sp68->unk_147C[sp68->unk_1678]; + this->subCamAtNext = sp68->unk_147C[sp68->unk_1678]; } - this->unk_1D24.x = player->actor.world.pos.x; - this->unk_1D24.y = player->actor.world.pos.y + 100.0f; - if (D_809E0422 == 0) { - if (this->unk_1D24.y < 100.0f) { - this->unk_1D24.y = 100.0f; + this->subCamEye.x = player->actor.world.pos.x; + this->subCamEye.y = player->actor.world.pos.y + 100.0f; + if (!sIsInGiantMode) { + if (this->subCamEye.y < 100.0f) { + this->subCamEye.y = 100.0f; } - } else if (this->unk_1D24.y < 3160.0f) { - this->unk_1D24.y = 3160.0f; + } else if (this->subCamEye.y < 3160.0f) { + this->subCamEye.y = 3160.0f; } - if (this->unk_1D48.y < (100.0f * D_809DF5B0)) { - this->unk_1D48.y = (100.0f * D_809DF5B0); + if (this->subCamAtNext.y < (100.0f * D_809DF5B0)) { + this->subCamAtNext.y = (100.0f * D_809DF5B0); } - this->unk_1D24.z = player->actor.world.pos.z; - Math_ApproachF(&this->unk_1D30.x, this->unk_1D48.x, 0.3f, this->unk_1D5C * 500.0f); - Math_ApproachF(&this->unk_1D30.y, this->unk_1D48.y, 0.3f, this->unk_1D5C * 500.0f); - Math_ApproachF(&this->unk_1D30.z, this->unk_1D48.z, 0.3f, this->unk_1D5C * 500.0f); - Math_ApproachF(&this->unk_1D5C, 1.0f, 1.0f, 0.02f); + this->subCamEye.z = player->actor.world.pos.z; + Math_ApproachF(&this->subCamAt.x, this->subCamAtNext.x, 0.3f, this->subCamAtVel * 500.0f); + Math_ApproachF(&this->subCamAt.y, this->subCamAtNext.y, 0.3f, this->subCamAtVel * 500.0f); + Math_ApproachF(&this->subCamAt.z, this->subCamAtNext.z, 0.3f, this->subCamAtVel * 500.0f); + Math_ApproachF(&this->subCamAtVel, 1.0f, 1.0f, 0.02f); break; case 103: @@ -2199,45 +2202,45 @@ void func_809DEAC4(Boss02* this, PlayState* play) { sp58 = Math_SinS(this->unk_0150); sp58 = (sp58 * this->unk_0146[0]) * 1.5f; if (this->unk_1D1C == 30) { - func_80169AFC(play, this->unk_1D22, 0); - this->unk_1D22 = 0; + func_80169AFC(play, this->subCamId, 0); + this->subCamId = SUB_CAM_ID_DONE; Cutscene_End(play, &play->csCtx); func_800B7298(play, &this->actor, 6); this->unk_1D20 = 0; this->actor.flags |= ACTOR_FLAG_1; sp68->unk_0144 = 10; - if ((D_809E0424->unk_0144 >= 10) && (D_809E0428->unk_0144 >= 10)) { + if ((sRedTwinmold->unk_0144 >= 10) && (sBlueTwinmold->unk_0144 >= 10)) { f32 phi_f0; this->unk_1D7E = 0; - if (D_809E0422 == 0) { + if (!sIsInGiantMode) { Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, 0.0f, 30.0f, -150.0f, 0, 1, 0, 0); phi_f0 = 60.0f; } else { Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, 0.0f, 3153.0f, -15.0f, 0, 1, 0, 35); phi_f0 = 3155.0f; } - D_809E0434 = (DoorWarp1*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, - 0.0f, phi_f0, 0.0f, 0, 0, 0, 1); + sBlueWarp = (DoorWarp1*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, + 0.0f, phi_f0, 0.0f, 0, 0, 0, 1); - if (D_809E0422 == 0) { - D_809E0434->unk_203 = 0; - D_809E0434->unk_204 = 1.0f; + if (!sIsInGiantMode) { + sBlueWarp->unk_203 = 0; + sBlueWarp->unk_204 = 1.0f; } else { - D_809E0434->unk_203 = 1; - D_809E0434->unk_204 = 0.1f; + sBlueWarp->unk_203 = 1; + sBlueWarp->unk_204 = 0.1f; } } } goto case_10x; } - if ((this->unk_1D20 != 0) && (this->unk_1D22 != 0)) { - sp5C = this->unk_1D24; - sp5C.y += sp58 * D_809DF5B0; - Play_CameraSetAtEyeUp(play, this->unk_1D22, &this->unk_1D30, &sp5C, &this->unk_1D3C); - this->unk_1D3C.z = this->unk_1D3C.x = 0.0f; - this->unk_1D3C.y = 1.0f; + if ((this->unk_1D20 != 0) && (this->subCamId != SUB_CAM_ID_DONE)) { + subCamEye = this->subCamEye; + subCamEye.y += sp58 * D_809DF5B0; + Play_CameraSetAtEyeUp(play, this->subCamId, &this->subCamAt, &subCamEye, &this->subCamUp); + this->subCamUp.z = this->subCamUp.x = 0.0f; + this->subCamUp.y = 1.0f; ShrinkWindow_SetLetterboxTarget(27); } } diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.h b/src/overlays/actors/ovl_Boss_02/z_boss_02.h index 6c4253ace..17028912b 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.h +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.h @@ -9,18 +9,33 @@ struct Boss02; typedef void (*Boss02ActionFunc)(struct Boss02*, PlayState*); typedef struct { - /* 0x00 */ Vec3f unk_00; - /* 0x0C */ Vec3f unk_0C; - /* 0x18 */ Vec3f unk_18; - /* 0x24 */ u8 unk_24; - /* 0x26 */ s16 unk_26; + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3f velocity; + /* 0x18 */ Vec3f accel; + /* 0x24 */ u8 type; + /* 0x26 */ s16 timer; /* 0x28 */ UNK_TYPE1 unk_28[0x4]; - /* 0x2C */ s16 unk_2C; - /* 0x2E */ s16 unk_2E; - /* 0x30 */ s16 unk_30; - /* 0x34 */ f32 unk_34; - /* 0x38 */ f32 unk_38; -} Boss02Effects; // size = 0x3C + /* 0x2C */ s16 alpha; + /* 0x2E */ s16 rotX; + /* 0x30 */ s16 rotY; + /* 0x34 */ f32 scale; + /* 0x38 */ f32 targetScale; +} TwinmoldEffect; // size = 0x3C + +typedef enum { + /* 0 */ TWINMOLD_EFFECT_NONE, + /* 1 */ TWINMOLD_EFFECT_SAND, // The sand kicked up when Twinmold touches the ground + /* 2 */ TWINMOLD_EFFECT_BLACK_DUST, // Unused + /* 3 */ TWINMOLD_EFFECT_FRAGMENT, // The fragments that fly off when the parts of Twinmold explode + /* 4 */ TWINMOLD_EFFECT_FLASH, // The flashes of light that appear when the parts of Twinmold explode +} TwinmoldEffectType; + +typedef enum { + /* 0 */ TWINMOLD_RED, + /* 35 */ TWINMOLD_BLUE = 35, + /* 100 */ TWINMOLD_TAIL = 100, + /* 200 */ TWINMOLD_STATIC = 200, +} TwinmoldParams; typedef struct Boss02 { /* 0x0000 */ Actor actor; @@ -60,7 +75,7 @@ typedef struct Boss02 { /* 0x15D4 */ Vec3s jointTable[TWINMOLD_HEAD_LIMB_MAX]; /* 0x1622 */ Vec3s morphTable[TWINMOLD_HEAD_LIMB_MAX]; /* 0x1670 */ Boss02ActionFunc actionFunc; - /* 0x1674 */ struct Boss02* unk_1674; // points to the other's instance + /* 0x1674 */ struct Boss02* otherTwinmold; // points to the other's instance /* 0x1678 */ s32 unk_1678; /* 0x167C */ Vec3f unk_167C; /* 0x1688 */ ColliderJntSph colliderSphere1; @@ -73,14 +88,14 @@ typedef struct Boss02 { /* 0x1D1A */ s16 unk_1D1A; /* 0x1D1C */ u32 unk_1D1C; /* 0x1D20 */ s16 unk_1D20; - /* 0x1D22 */ s16 unk_1D22; - /* 0x1D24 */ Vec3f unk_1D24; - /* 0x1D30 */ Vec3f unk_1D30; - /* 0x1D3C */ Vec3f unk_1D3C; - /* 0x1D48 */ Vec3f unk_1D48; + /* 0x1D22 */ s16 subCamId; + /* 0x1D24 */ Vec3f subCamEye; + /* 0x1D30 */ Vec3f subCamAt; + /* 0x1D3C */ Vec3f subCamUp; + /* 0x1D48 */ Vec3f subCamAtNext; /* 0x1D54 */ f32 unk_1D54; /* 0x1D58 */ f32 unk_1D58; - /* 0x1D5C */ f32 unk_1D5C; + /* 0x1D5C */ f32 subCamAtVel; /* 0x1D60 */ UNK_TYPE1 unk1D60[0x4]; /* 0x1D64 */ f32 unk_1D64; /* 0x1D68 */ f32 unk_1D68; diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index 91a4c8877..449660f7e 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -724,7 +724,7 @@ void Boss03_ChasePlayer(Boss03* this, PlayState* play) { if (sp43 != 0) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, player->actor.world.pos.x, this->waterHeight, - player->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + player->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_309); Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_SINK_OLD); } @@ -1055,7 +1055,7 @@ void Boss03_Charge(Boss03* this, PlayState* play) { play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); func_800BC848(&this->actor, play, 20, 15); Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, 0.0f, this->waterHeight, 0.0f, 0, 0, 0x96, - ENWATEREFFECT_780); + ENWATEREFFECT_30C); // Player is above water && Player is standing on ground if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { @@ -1150,9 +1150,9 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { if (player->actor.world.pos.y < 1350.0f) { Cutscene_Start(play, &play->csCtx); func_800B7298(play, &this->actor, 7); - this->csCamId = Play_CreateSubCamera(play); - Play_CameraChangeStatus(play, CAM_ID_MAIN, 1); - Play_CameraChangeStatus(play, this->csCamId, 7); + this->subCamId = Play_CreateSubCamera(play); + Play_CameraChangeStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_CameraChangeStatus(play, this->subCamId, CAM_STATUS_ACTIVE); this->actor.world.rot.y = -0x7B30; this->prevPlayerPos.y = 1850.0f; @@ -1165,34 +1165,34 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { player->actor.world.pos.y = 1850.0f; player->actor.world.rot.y = player->actor.shape.rot.y; - this->csCamAt.y = player->actor.world.pos.y + 30.0f; + this->subCamAt.y = player->actor.world.pos.y + 30.0f; this->csState = 1; this->csTimer = 0; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_2D5 = true; - this->cameraFov = KREG(14) + 60.0f; + this->subCamFov = KREG(14) + 60.0f; case 1: player->actor.world.pos.z = 0.0f; player->actor.world.pos.x = 0.0f; player->actor.speedXZ = 0.0f; - this->csCamEye.x = 100.0f; - this->csCamEye.y = 540.0f; + this->subCamEye.x = 100.0f; + this->subCamEye.y = 540.0f; - this->csCamEye.z = player->actor.world.pos.z + 100.0f; - this->csCamAt.x = player->actor.world.pos.x; + this->subCamEye.z = player->actor.world.pos.z + 100.0f; + this->subCamAt.x = player->actor.world.pos.x; - Math_ApproachF(&this->csCamAt.y, player->actor.world.pos.y + 30.0f, 0.5f, 100.0f); - this->csCamAt.z = player->actor.world.pos.z; + Math_ApproachF(&this->subCamAt.y, player->actor.world.pos.y + 30.0f, 0.5f, 100.0f); + this->subCamAt.z = player->actor.world.pos.z; if (this->csTimer > 105) { this->csState = 2; this->csTimer = 0; this->unk_240 = 0; func_8016566C(0x96); - this->cameraFov = 80.0f; + this->subCamFov = 80.0f; case 2: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEMO_MOVE_OLD - SFX_FLAG); @@ -1263,20 +1263,20 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { func_800B7298(play, &this->actor, 8); } - this->csCamEye.x = player->actor.world.pos.x + 30.0f; - this->csCamEye.y = player->actor.world.pos.y + Player_GetHeight(player) - 4.0f + BREG(17); - this->csCamEye.z = player->actor.world.pos.z - 30.0f; + this->subCamEye.x = player->actor.world.pos.x + 30.0f; + this->subCamEye.y = player->actor.world.pos.y + Player_GetHeight(player) - 4.0f + BREG(17); + this->subCamEye.z = player->actor.world.pos.z - 30.0f; - this->csCamAt.x = player->actor.world.pos.x; - this->csCamAt.y = player->actor.world.pos.y + Player_GetHeight(player) - 18.0f + 6.0f + BREG(18); - this->csCamAt.z = player->actor.world.pos.z; + this->subCamAt.x = player->actor.world.pos.x; + this->subCamAt.y = player->actor.world.pos.y + Player_GetHeight(player) - 18.0f + 6.0f + BREG(18); + this->subCamAt.z = player->actor.world.pos.z; if (player->transformation == PLAYER_FORM_FIERCE_DEITY) { - this->csCamEye.y -= 60.0f; - this->csCamAt.y -= 35.0f; + this->subCamEye.y -= 60.0f; + this->subCamAt.y -= 35.0f; } - this->cameraFov = 60.0f; + this->subCamFov = 60.0f; if (this->csTimer == 16) { this->csState = 5; this->csTimer = 0; @@ -1293,13 +1293,13 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { player->actor.shape.rot.y = -0x1470; player->actor.world.rot.y = player->actor.shape.rot.y; - this->csCamEye.x = player->actor.world.pos.x + 30.0f - 90.0f + 300.0f; - this->csCamEye.y = player->actor.world.pos.y + 40.0f + 10.0f; - this->csCamEye.z = player->actor.world.pos.z - 30.0f + 160.0f + 300.0f; + this->subCamEye.x = player->actor.world.pos.x + 30.0f - 90.0f + 300.0f; + this->subCamEye.y = player->actor.world.pos.y + 40.0f + 10.0f; + this->subCamEye.z = player->actor.world.pos.z - 30.0f + 160.0f + 300.0f; - this->csCamAt.x = this->actor.world.pos.x; - this->csCamAt.y = this->actor.world.pos.y - 100.0f; - this->csCamAt.z = this->actor.world.pos.z; + this->subCamAt.x = this->actor.world.pos.x; + this->subCamAt.y = this->actor.world.pos.y - 100.0f; + this->subCamAt.z = this->actor.world.pos.z; if (this->csTimer == 10) { this->actor.velocity.y = 30.0f; @@ -1345,34 +1345,34 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { Boss03_SpawnEffectDroplet(play, &effectPos); } - this->csCamTargetAt.x = this->actor.world.pos.x; - this->csCamTargetAt.y = this->actor.world.pos.y - 100.0f; - this->csCamTargetAt.z = this->actor.world.pos.z; + this->subCamAtNext.x = this->actor.world.pos.x; + this->subCamAtNext.y = this->actor.world.pos.y - 100.0f; + this->subCamAtNext.z = this->actor.world.pos.z; } } else { - Math_ApproachF(&this->csCamEye.x, player->actor.world.pos.x + 30.0f - 90.0f + 300.0f - 90.0f, 0.05f, + Math_ApproachF(&this->subCamEye.x, player->actor.world.pos.x + 30.0f - 90.0f + 300.0f - 90.0f, 0.05f, 3.0f); - Math_ApproachF(&this->csCamEye.y, player->actor.world.pos.y + 40.0f + 10.0f + 90.0f, 0.05f, 3.0f); - Math_ApproachF(&this->csCamEye.z, player->actor.world.pos.z - 30.0f + 160.0f + 300.0f - 90.0f, 0.05f, + Math_ApproachF(&this->subCamEye.y, player->actor.world.pos.y + 40.0f + 10.0f + 90.0f, 0.05f, 3.0f); + Math_ApproachF(&this->subCamEye.z, player->actor.world.pos.z - 30.0f + 160.0f + 300.0f - 90.0f, 0.05f, 3.0f); Math_ApproachF(&this->unk_568, 90.0f, 0.05f, 3.0f); } - Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, 0.5f, 100.0f); - Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y + this->unk_568, 0.5f, 100.0f); - Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, 0.5f, 100.0f); + Math_ApproachF(&this->subCamAt.x, this->subCamAtNext.x, 0.5f, 100.0f); + Math_ApproachF(&this->subCamAt.y, this->subCamAtNext.y + this->unk_568, 0.5f, 100.0f); + Math_ApproachF(&this->subCamAt.z, this->subCamAtNext.z, 0.5f, 100.0f); if (this->csTimer == 145) { - Camera* camera = Play_GetCamera(play, CAM_ID_MAIN); + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); - camera->eye = this->csCamEye; - camera->eyeNext = this->csCamEye; - camera->at = this->csCamAt; + mainCam->eye = this->subCamEye; + mainCam->eyeNext = this->subCamEye; + mainCam->at = this->subCamAt; - func_80169AFC(play, this->csCamId, 0); + func_80169AFC(play, this->subCamId, 0); Cutscene_End(play, &play->csCtx); func_800B7298(play, &this->actor, 6); - this->csCamId = 0; + this->subCamId = SUB_CAM_ID_DONE; func_809E344C(this, play); this->workTimer[WORK_TIMER_UNK1_A] = 50; @@ -1395,22 +1395,22 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); Matrix_RotateYF(sp5C, MTXMODE_APPLY); Matrix_RotateXS(this->actor.world.rot.x, MTXMODE_APPLY); - Matrix_MultVecZ(100.0f, &this->csCamAt); + Matrix_MultVecZ(100.0f, &this->subCamAt); - this->csCamEye = this->actor.world.pos; + this->subCamEye = this->actor.world.pos; for (i = 0; i < bubblesToSpawnNum; i++) { - effectPos.x = randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.x; - effectPos.y = (randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.y) - 150.0f; - effectPos.z = randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.z; + effectPos.x = randPlusMinusPoint5Scaled(100.0f) + this->subCamAt.x; + effectPos.y = (randPlusMinusPoint5Scaled(100.0f) + this->subCamAt.y) - 150.0f; + effectPos.z = randPlusMinusPoint5Scaled(100.0f) + this->subCamAt.z; Boss03_SpawnEffectBubble(play, &effectPos); } } - if (this->csCamId != 0) { - Play_CameraSetAtEye(play, this->csCamId, &this->csCamAt, &this->csCamEye); - Play_CameraSetFov(play, this->csCamId, this->cameraFov); + if (this->subCamId != SUB_CAM_ID_DONE) { + Play_CameraSetAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); + Play_CameraSetFov(play, this->subCamId, this->subCamFov); } } @@ -1435,7 +1435,7 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { s32 pad; f32 pad2; f32 sp64; - Camera* camera = Play_GetCamera(play, CAM_ID_MAIN); + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); Player* player; f32 sp4C; @@ -1450,9 +1450,9 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { if (ActorCutscene_GetCurrentIndex() == -1) { Cutscene_Start(play, &play->csCtx); func_800B7298(play, &this->actor, 1); - this->csCamId = Play_CreateSubCamera(play); - Play_CameraChangeStatus(play, CAM_ID_MAIN, 1); - Play_CameraChangeStatus(play, this->csCamId, 7); + this->subCamId = Play_CreateSubCamera(play); + Play_CameraChangeStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_CameraChangeStatus(play, this->subCamId, CAM_STATUS_ACTIVE); this->unk_2BE = Math_FAtan2F(this->actor.world.pos.z, this->actor.world.pos.x); // Player is above water && Player is standing on ground @@ -1464,15 +1464,15 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { case 1: this->csTimer = 0; this->csState = 2; - this->csCamEye.x = camera->eye.x; - this->csCamEye.y = camera->eye.y; - this->csCamEye.z = camera->eye.z; - this->csCamAt.x = camera->at.x; - this->csCamAt.y = camera->at.y; - this->csCamAt.z = camera->at.z; + this->subCamEye.x = mainCam->eye.x; + this->subCamEye.y = mainCam->eye.y; + this->subCamEye.z = mainCam->eye.z; + this->subCamAt.x = mainCam->at.x; + this->subCamAt.y = mainCam->at.y; + this->subCamAt.z = mainCam->at.z; - aux = this->csCamEye.x - this->actor.world.pos.x; - this->unk_568 = Math_Acot2F(this->csCamEye.z - this->actor.world.pos.z, aux); + aux = this->subCamEye.x - this->actor.world.pos.x; + this->unk_568 = Math_Acot2F(this->subCamEye.z - this->actor.world.pos.z, aux); this->unk_570 = 0.0f; this->unk_56C = 0.0f; @@ -1482,26 +1482,26 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { sp90.y = (50.0f * sp64) + 150.0f; sp90.z = (400.0f * sp64) + 300.0f; - this->csCamTargetAt.x = this->actor.world.pos.x; - this->csCamTargetAt.y = this->actor.world.pos.y; - this->csCamTargetAt.z = this->actor.world.pos.z; + this->subCamAtNext.x = this->actor.world.pos.x; + this->subCamAtNext.y = this->actor.world.pos.y; + this->subCamAtNext.z = this->actor.world.pos.z; this->unk_568 += this->unk_56C; Matrix_RotateYF(this->unk_568, MTXMODE_NEW); - Matrix_MultVec3f(&sp90, &this->csCamTargetEye); + Matrix_MultVec3f(&sp90, &this->subCamEyeNext); - this->csCamTargetEye.x += this->actor.world.pos.x; - this->csCamTargetEye.y += this->waterHeight; - this->csCamTargetEye.z += this->actor.world.pos.z; + this->subCamEyeNext.x += this->actor.world.pos.x; + this->subCamEyeNext.y += this->waterHeight; + this->subCamEyeNext.z += this->actor.world.pos.z; sp4C = 40.0f + aux2; - Math_ApproachF(&this->csCamEye.x, this->csCamTargetEye.x, 0.1f, sp4C); - Math_ApproachF(&this->csCamEye.y, this->csCamTargetEye.y, 0.1f, sp4C); - Math_ApproachF(&this->csCamEye.z, this->csCamTargetEye.z, 0.1f, sp4C); + Math_ApproachF(&this->subCamEye.x, this->subCamEyeNext.x, 0.1f, sp4C); + Math_ApproachF(&this->subCamEye.y, this->subCamEyeNext.y, 0.1f, sp4C); + Math_ApproachF(&this->subCamEye.z, this->subCamEyeNext.z, 0.1f, sp4C); sp4C = 70.0f + aux2; - Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, 0.1f, sp4C); - Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y, 0.1f, sp4C); - Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, 0.1f, sp4C); + Math_ApproachF(&this->subCamAt.x, this->subCamAtNext.x, 0.1f, sp4C); + Math_ApproachF(&this->subCamAt.y, this->subCamAtNext.y, 0.1f, sp4C); + Math_ApproachF(&this->subCamAt.z, this->subCamAtNext.z, 0.1f, sp4C); } break; } @@ -1528,7 +1528,7 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { if ((this->workTimer[WORK_TIMER_UNK0_C] == 0) && ((this->waterHeight - 100.0f) < this->actor.world.pos.y)) { this->workTimer[WORK_TIMER_UNK0_C] = Rand_ZeroFloat(15.0f) + 15.0f; Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, this->waterHeight, - this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_309); if (this->actionFunc == Boss03_DeathCutscene) { if ((D_809E9840 % 2) != 0) { @@ -1622,12 +1622,12 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { case 2: Math_ApproachZeroF(&this->unk_56C, 1.0f, 0.0005f); if (this->csTimer == 60) { - camera = Play_GetCamera(play, CAM_ID_MAIN); - camera->eye = this->csCamEye; - camera->eyeNext = this->csCamEye; - camera->at = this->csCamAt; - func_80169AFC(play, this->csCamId, 0); - this->csCamId = 0; + mainCam = Play_GetCamera(play, CAM_ID_MAIN); + mainCam->eye = this->subCamEye; + mainCam->eyeNext = this->subCamEye; + mainCam->at = this->subCamAt; + func_80169AFC(play, this->subCamId, 0); + this->subCamId = SUB_CAM_ID_DONE; Cutscene_End(play, &play->csCtx); func_800B7298(play, &this->actor, 6); this->csState = 3; @@ -1642,8 +1642,8 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { break; } - if (this->csCamId != 0) { - Play_CameraSetAtEye(play, this->csCamId, &this->csCamAt, &this->csCamEye); + if (this->subCamId != SUB_CAM_ID_DONE) { + Play_CameraSetAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); } } @@ -1664,9 +1664,9 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, PlayState* play) { if (ActorCutscene_GetCurrentIndex() == -1) { Cutscene_Start(play, &play->csCtx); func_800B7298(play, &this->actor, 1); - this->csCamId = Play_CreateSubCamera(play); - Play_CameraChangeStatus(play, CAM_ID_MAIN, 1); - Play_CameraChangeStatus(play, this->csCamId, 7); + this->subCamId = Play_CreateSubCamera(play); + Play_CameraChangeStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_CameraChangeStatus(play, this->subCamId, CAM_STATUS_ACTIVE); this->csState = 1; this->unk_2BE = 0xBB8; @@ -1691,11 +1691,11 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, PlayState* play) { Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); Matrix_RotateYS(this->actor.shape.rot.y + this->unk_2BE, MTXMODE_APPLY); - Matrix_MultVecZ(340.0f, &this->csCamEye); + Matrix_MultVecZ(340.0f, &this->subCamEye); - this->csCamAt.x = this->actor.world.pos.x; - this->csCamAt.y = this->actor.world.pos.y; - this->csCamAt.z = this->actor.world.pos.z; + this->subCamAt.x = this->actor.world.pos.x; + this->subCamAt.y = this->actor.world.pos.y; + this->subCamAt.z = this->actor.world.pos.z; Math_ApproachS(&this->unk_2BE, -4000, 10, 70); @@ -1715,15 +1715,14 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, PlayState* play) { } if (this->csTimer >= 150) { - Camera* camera; + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); - camera = Play_GetCamera(play, CAM_ID_MAIN); - camera->eye = this->csCamEye; - camera->eyeNext = this->csCamEye; - camera->at = this->csCamAt; + mainCam->eye = this->subCamEye; + mainCam->eyeNext = this->subCamEye; + mainCam->at = this->subCamAt; - func_80169AFC(play, this->csCamId, 0); - this->csCamId = 0; + func_80169AFC(play, this->subCamId, 0); + this->subCamId = SUB_CAM_ID_DONE; Cutscene_End(play, &play->csCtx); func_800B7298(play, &this->actor, 6); @@ -1734,8 +1733,8 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, PlayState* play) { break; } - if (this->csCamId != 0) { - Play_CameraSetAtEye(play, this->csCamId, &this->csCamAt, &this->csCamEye); + if (this->subCamId != SUB_CAM_ID_DONE) { + Play_CameraSetAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); } } @@ -2013,7 +2012,7 @@ void Boss03_Update(Actor* thisx, PlayState* play2) { } Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, this->waterHeight, - this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_309); this->unk_280 = 27; this->unk_284 = this->actor.world.pos.x; @@ -2441,8 +2440,7 @@ void Boss03_DrawEffects(PlayState* play) { Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); if (eff->type == GYORG_EFFECT_DROPLET) { - Matrix_RotateYF(Camera_GetInputDirYaw(play->cameraPtrs[play->activeCamera]) * (M_PI / 0x8000), - MTXMODE_APPLY); + Matrix_RotateYF(Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)) * (M_PI / 0x8000), MTXMODE_APPLY); } else { // GYORG_EFFECT_SPLASH Matrix_ReplaceRotation(&play->billboardMtxF); } diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.h b/src/overlays/actors/ovl_Boss_03/z_boss_03.h index 96dd4fc3f..a00dbacff 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.h +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.h @@ -35,73 +35,73 @@ typedef enum { } GyorgEffectType; typedef struct Boss03 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ UNK_TYPE1 unk_144[0x04]; - /* 0x0148 */ SkelAnime skelAnime; - /* 0x018C */ Vec3s jointTable[GYORG_LIMB_MAX]; - /* 0x01E6 */ Vec3s morphTable[GYORG_LIMB_MAX]; - /* 0x0240 */ s16 unk_240; // generic timer? used by Gyorg and seaweed - /* 0x0242 */ u8 unk_242; - /* 0x0243 */ UNK_TYPE1 unk_243[0x09]; - /* 0x024C */ s16 workTimer[GYORG_WORK_TIMER_MAX]; - /* 0x0252 */ s8 numSpawnedSmallFish; // number of Tanron3 fish that are currently alive, -1 indexed - /* 0x0253 */ u8 hasSpwanedSmallFishes; // Tanron - /* 0x0254 */ s16 bubbleEffectSpawnCount; // Amount of bubble effect which will be spawned by Update - /* 0x0258 */ f32 waterHeight; // always 430.0f - /* 0x025C */ s16 unk_25C; // Timer related to collision? - /* 0x025E */ s16 unk_25E; - /* 0x0260 */ f32 unk_260; // rotY - /* 0x0264 */ UNK_TYPE1 unk_264[0x04]; - /* 0x0268 */ Vec3f unk_268; // set to player.world.pos or random values - /* 0x0274 */ s16 unk_274; - /* 0x0276 */ s16 unk_276; - /* 0x0278 */ f32 unk_278; - /* 0x027C */ f32 unk_27C; - /* 0x0280 */ s16 unk_280; - /* 0x0284 */ f32 unk_284; // Maybe a Vec3f - /* 0x0288 */ f32 unk_288; // Set but not used - /* 0x028C */ f32 unk_28C; - /* 0x0290 */ u8 unk_290; - /* 0x0294 */ f32 unk_294; - /* 0x0298 */ f32 unk_298; - /* 0x029C */ s16 leftFinYRot; - /* 0x029E */ s16 rightFinYRot; - /* 0x02A0 */ s16 bodyYRot; - /* 0x02A2 */ Vec3s unk_2A2; - /* 0x02A8 */ s16 jawZRot; - /* 0x02AC */ Vec3f insideJawPos; // used to grab player - /* 0x02B8 */ f32 unk_2B8; - /* 0x02BC */ u8 unk_2BC; // set but not used - /* 0x02BD */ u8 unk_2BD; // playerUnderwater? - /* 0x02BE */ s16 unk_2BE; - /* 0x02C0 */ UNK_TYPE1 unk_2C0[0x04]; - /* 0x02C0 */ f32 unk_2C4; - /* 0x02C8 */ Vec3f prevPlayerPos; - /* 0x02D4 */ u8 wetSpotEffectSpawnCount; - /* 0x02D5 */ u8 unk_2D5; // flag - /* 0x02D6 */ s16 shapeRotTargetX; - /* 0x02D8 */ s16 shapeRotTargetY; - /* 0x02DA */ s16 shapeRotTargetZ; - /* 0x02DC */ Vec3f seaweedSegmentPositions[6]; - /* 0x0324 */ s16 unk_324; // timer? set by Tanron3 - /* 0x0328 */ Boss03ActionFunc actionFunc; - /* 0x032C */ ColliderJntSph headCollider; - /* 0x034C */ ColliderJntSphElement headColliderElements[2]; - /* 0x03CC */ ColliderJntSph bodyCollider; - /* 0x03EC */ ColliderJntSphElement bodyColliderElements[5]; - /* 0x052C */ f32 floppingAnimLastFrame; - /* 0x0530 */ u32 csTimer; - /* 0x0534 */ s16 csState; - /* 0x0536 */ s16 csCamId; - /* 0x0538 */ Vec3f csCamEye; - /* 0x0544 */ Vec3f csCamAt; - /* 0x0550 */ Vec3f csCamTargetEye; - /* 0x055C */ Vec3f csCamTargetAt; - /* 0x0568 */ f32 unk_568; - /* 0x056C */ f32 unk_56C; - /* 0x0570 */ f32 unk_570; // set but not used - /* 0x0574 */ UNK_TYPE1 unk_574[0x04]; - /* 0x0578 */ f32 cameraFov; + /* 0x000 */ Actor actor; + /* 0x144 */ UNK_TYPE1 unk_144[0x04]; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ Vec3s jointTable[GYORG_LIMB_MAX]; + /* 0x1E6 */ Vec3s morphTable[GYORG_LIMB_MAX]; + /* 0x240 */ s16 unk_240; // generic timer? used by Gyorg and seaweed + /* 0x242 */ u8 unk_242; + /* 0x243 */ UNK_TYPE1 unk_243[0x09]; + /* 0x24C */ s16 workTimer[GYORG_WORK_TIMER_MAX]; + /* 0x252 */ s8 numSpawnedSmallFish; // number of Tanron3 fish that are currently alive, -1 indexed + /* 0x253 */ u8 hasSpwanedSmallFishes; // Tanron + /* 0x254 */ s16 bubbleEffectSpawnCount; // Amount of bubble effect which will be spawned by Update + /* 0x258 */ f32 waterHeight; // always 430.0f + /* 0x25C */ s16 unk_25C; // Timer related to collision? + /* 0x25E */ s16 unk_25E; + /* 0x260 */ f32 unk_260; // rotY + /* 0x264 */ UNK_TYPE1 unk_264[0x04]; + /* 0x268 */ Vec3f unk_268; // set to player.world.pos or random values + /* 0x274 */ s16 unk_274; + /* 0x276 */ s16 unk_276; + /* 0x278 */ f32 unk_278; + /* 0x27C */ f32 unk_27C; + /* 0x280 */ s16 unk_280; + /* 0x284 */ f32 unk_284; // Maybe a Vec3f + /* 0x288 */ f32 unk_288; // Set but not used + /* 0x28C */ f32 unk_28C; + /* 0x290 */ u8 unk_290; + /* 0x294 */ f32 unk_294; + /* 0x298 */ f32 unk_298; + /* 0x29C */ s16 leftFinYRot; + /* 0x29E */ s16 rightFinYRot; + /* 0x2A0 */ s16 bodyYRot; + /* 0x2A2 */ Vec3s unk_2A2; + /* 0x2A8 */ s16 jawZRot; + /* 0x2AC */ Vec3f insideJawPos; // used to grab player + /* 0x2B8 */ f32 unk_2B8; + /* 0x2BC */ u8 unk_2BC; // set but not used + /* 0x2BD */ u8 unk_2BD; // playerUnderwater? + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ UNK_TYPE1 unk_2C0[0x04]; + /* 0x2C0 */ f32 unk_2C4; + /* 0x2C8 */ Vec3f prevPlayerPos; + /* 0x2D4 */ u8 wetSpotEffectSpawnCount; + /* 0x2D5 */ u8 unk_2D5; // flag + /* 0x2D6 */ s16 shapeRotTargetX; + /* 0x2D8 */ s16 shapeRotTargetY; + /* 0x2DA */ s16 shapeRotTargetZ; + /* 0x2DC */ Vec3f seaweedSegmentPositions[6]; + /* 0x324 */ s16 unk_324; // timer? set by Tanron3 + /* 0x328 */ Boss03ActionFunc actionFunc; + /* 0x32C */ ColliderJntSph headCollider; + /* 0x34C */ ColliderJntSphElement headColliderElements[2]; + /* 0x3CC */ ColliderJntSph bodyCollider; + /* 0x3EC */ ColliderJntSphElement bodyColliderElements[5]; + /* 0x52C */ f32 floppingAnimLastFrame; + /* 0x530 */ u32 csTimer; + /* 0x534 */ s16 csState; + /* 0x536 */ s16 subCamId; + /* 0x538 */ Vec3f subCamEye; + /* 0x544 */ Vec3f subCamAt; + /* 0x550 */ Vec3f subCamEyeNext; + /* 0x55C */ Vec3f subCamAtNext; + /* 0x568 */ f32 unk_568; + /* 0x56C */ f32 unk_56C; + /* 0x570 */ f32 unk_570; // set but not used + /* 0x574 */ UNK_TYPE1 unk_574[0x04]; + /* 0x578 */ f32 subCamFov; } Boss03; // size = 0x57C #define GYORG_PARAM_DEFAULT (0) 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 d731cac90..2fb1e79b7 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -5,7 +5,6 @@ */ #include "z_boss_04.h" -#include "objects/object_boss04/object_boss04.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -97,7 +96,7 @@ static ColliderJntSphInit sJntSphInit1 = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit1), sJntSphElementsInit1, }; @@ -124,7 +123,7 @@ static ColliderJntSphInit sJntSphInit2 = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit2), sJntSphElementsInit2, }; @@ -172,8 +171,8 @@ void Boss04_Init(Actor* thisx, PlayState* play2) { this->unk_6F8 = 1.0f; Collider_InitAndSetJntSph(play, &this->collider1, &this->actor, &sJntSphInit1, this->collider1Elements); Collider_InitAndSetJntSph(play, &this->collider2, &this->actor, &sJntSphInit2, this->collider2Elements); - SkelAnime_InitFlex(play, &this->skelAnime, &object_boss04_Skel_0045E8, &object_boss04_Anim_00004C, this->jointTable, - this->morphtable, 9); + SkelAnime_InitFlex(play, &this->skelAnime, &gWartSkel, &gWartIdleAnim, this->jointTable, this->morphtable, + WART_LIMB_MAX); spA8.y = this->actor.world.pos.y + 200.0f; for (i = 0; i < ARRAY_COUNT(D_809EE1F8); i++) { @@ -260,19 +259,19 @@ void func_809EC568(Boss04* this, PlayState* play) { this->unk_708 = 10; this->unk_704 = 0; Cutscene_Start(play, &play->csCtx); - this->unk_70A = Play_CreateSubCamera(play); - Play_CameraChangeStatus(play, CAM_ID_MAIN, 1); - Play_CameraChangeStatus(play, this->unk_70A, 7); + this->subCamId = Play_CreateSubCamera(play); + Play_CameraChangeStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_CameraChangeStatus(play, this->subCamId, CAM_STATUS_ACTIVE); func_800B7298(play, &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); + Math_Vec3f_Copy(&this->subCamEye, &player->actor.world.pos); + this->subCamEye.y += 100.0f; + Math_Vec3f_Copy(&this->subCamAt, &this->actor.world.pos); func_8016566C(150); - this->unk_744 = 60.0f; + this->subCamFov = 60.0f; boss = play->actorCtx.actorLists[ACTORCAT_BOSS].first; while (boss != NULL) { @@ -294,7 +293,7 @@ void func_809EC568(Boss04* this, PlayState* play) { } this->unk_2D0 = 10000.0f; this->unk_2C8 = 300; - Math_ApproachF(&this->unk_744, 20.0f, 0.3f, 11.0f); + Math_ApproachF(&this->subCamFov, 20.0f, 0.3f, 11.0f); if (this->unk_704 == 40) { this->unk_708 = 11; this->unk_704 = 0; @@ -320,9 +319,9 @@ void func_809EC568(Boss04* this, PlayState* play) { 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); + Math_ApproachF(&this->subCamAt.x, this->actor.world.pos.x, 0.5f, 1000.0f); + Math_ApproachF(&this->subCamAt.y, this->actor.world.pos.y, 0.5f, 1000.0f); + Math_ApproachF(&this->subCamAt.z, this->actor.world.pos.z, 0.5f, 1000.0f); if (this->actor.bgCheckFlags & 2) { play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); this->unk_6F4 = 15; @@ -332,22 +331,22 @@ void func_809EC568(Boss04* this, PlayState* play) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_SPLASH); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); - this->unk_748 = 20; + this->subCamAtOscillator = 20; } break; case 1: player->actor.shape.rot.y = 0x7FFF; player->actor.world.rot.y = player->actor.shape.rot.y; - Matrix_MultVecZ(-100.0f, &this->unk_70C); + Matrix_MultVecZ(-100.0f, &this->subCamEye); - 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->subCamEye.x += player->actor.world.pos.x; + this->subCamEye.y = Player_GetHeight(player) + player->actor.world.pos.y + 36.0f; + this->subCamEye.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; + this->subCamAt.x = player->actor.world.pos.x; + this->subCamAt.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 4.0f; + this->subCamAt.z = player->actor.world.pos.z; if (this->unk_704 >= 35) { this->unk_704 = 0; @@ -358,13 +357,13 @@ void func_809EC568(Boss04* this, PlayState* play) { case 2: case 3: - Matrix_MultVecZ(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; + Matrix_MultVecZ(500.0f, &this->subCamEye); + this->subCamEye.x += this->actor.world.pos.x; + this->subCamEye.y += this->actor.world.pos.y - 50.0f; + this->subCamEye.z += this->actor.world.pos.z; + this->subCamAt.x = this->actor.world.pos.x; + this->subCamAt.z = this->actor.world.pos.z; + this->subCamAt.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) { @@ -380,15 +379,15 @@ void func_809EC568(Boss04* this, PlayState* play) { } if (this->unk_704 > 140) { - Camera* sp5C = Play_GetCamera(play, CAM_ID_MAIN); + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); this->unk_708 = 0; func_809ECD00(this, play); - sp5C->eye = this->unk_70C; - sp5C->eyeNext = this->unk_70C; - sp5C->at = this->unk_718; - func_80169AFC(play, this->unk_70A, 0); - this->unk_70A = 0; + mainCam->eye = this->subCamEye; + mainCam->eyeNext = this->subCamEye; + mainCam->at = this->subCamAt; + func_80169AFC(play, this->subCamId, 0); + this->subCamId = SUB_CAM_ID_DONE; Cutscene_End(play, &play->csCtx); func_800B7298(play, &this->actor, 6); func_80165690(); @@ -397,18 +396,18 @@ void func_809EC568(Boss04* this, PlayState* play) { break; } - if (this->unk_70A != 0) { - Vec3f sp50; + if (this->subCamId != SUB_CAM_ID_DONE) { + Vec3f subCamAt; ShrinkWindow_SetLetterboxTarget(27); - if (this->unk_748 != 0) { - this->unk_748--; + if (this->subCamAtOscillator != 0) { + this->subCamAtOscillator--; } - Math_Vec3f_Copy(&sp50, &this->unk_718); - sp50.y += Math_SinS(this->unk_748 * 0x4000) * this->unk_748 * 1.5f; - Play_CameraSetAtEye(play, this->unk_70A, &sp50, &this->unk_70C); - Play_CameraSetFov(play, this->unk_70A, this->unk_744); - Math_ApproachF(&this->unk_744, 60.0f, 0.1f, 1.0f); + Math_Vec3f_Copy(&subCamAt, &this->subCamAt); + subCamAt.y += Math_SinS(this->subCamAtOscillator * 0x4000) * this->subCamAtOscillator * 1.5f; + Play_CameraSetAtEye(play, this->subCamId, &subCamAt, &this->subCamEye); + Play_CameraSetFov(play, this->subCamId, this->subCamFov); + Math_ApproachF(&this->subCamFov, 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; @@ -781,11 +780,11 @@ s32 Boss04_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* rot->z += KREG(35) * 256; } - if ((limbIndex == 5) || (limbIndex == 7)) { + if ((limbIndex == WART_LIMB_TOP_EYELID_ROOT) || (limbIndex == WART_LIMB_BOTTOM_EYELID_ROOT)) { rot->y = (rot->y + (s16)this->unk_2CC) - 0x500; } - if (limbIndex == 4) { + if (limbIndex == WART_LIMB_EYE) { rot->y += this->unk_2D8; rot->z += this->unk_2D4; if (this->unk_2DA != 0) { @@ -803,7 +802,7 @@ void Boss04_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot Boss04* this = THIS; Vec3f sp18; - if (limbIndex == 1) { + if (limbIndex == WART_LIMB_ROOT) { Matrix_MultVecY(-500.0f, &this->actor.focus.pos); Matrix_MultVec3f(&D_809EE228, &sp18); func_809EC040(0, &this->collider1, &sp18); @@ -834,7 +833,7 @@ void Boss04_Draw(Actor* thisx, PlayState* play) { func_8012C448(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 150); - gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004510); + gSPDisplayList(POLY_XLU_DISP++, gWartShadowMaterialDL); Matrix_Translate(this->unk_6BC.x, this->actor.floorHeight, this->unk_6BC.z, MTXMODE_NEW); Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); @@ -842,7 +841,7 @@ void Boss04_Draw(Actor* thisx, PlayState* play) { Matrix_Scale(this->unk_6F8 * 1.8f, 0.0f, this->unk_700 * 2.8f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004550); + gSPDisplayList(POLY_XLU_DISP++, gWartShadowModelDL); } CLOSE_DISPS(play->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 579032aa2..c0944ce82 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.h +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.h @@ -2,77 +2,78 @@ #define Z_BOSS_04_H #include "global.h" +#include "objects/object_boss04/object_boss04.h" struct Boss04; typedef void (*Boss04ActionFunc)(struct Boss04*, PlayState*); typedef struct Boss04 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[9]; - /* 0x01BE */ Vec3s morphtable[9]; - /* 0x01F4 */ s16 unk_1F4; - /* 0x01F6 */ u8 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 */ 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; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[WART_LIMB_MAX]; + /* 0x1BE */ Vec3s morphtable[WART_LIMB_MAX]; + /* 0x1F4 */ s16 unk_1F4; + /* 0x1F6 */ u8 unk_1F6; + /* 0x1F7 */ u8 unk_1F7; + /* 0x1F8 */ s16 unk_1F8; + /* 0x1FA */ s16 unk_1FA; + /* 0x1FC */ UNK_TYPE1 unk_1FC[2]; + /* 0x1FE */ s16 unk_1FE; + /* 0x200 */ s16 unk_200; + /* 0x204 */ Boss04ActionFunc actionFunc; + /* 0x208 */ ColliderJntSph collider1; + /* 0x228 */ ColliderJntSphElement collider1Elements[1]; + /* 0x268 */ ColliderJntSph collider2; + /* 0x288 */ ColliderJntSphElement collider2Elements[1]; + /* 0x2C8 */ s16 unk_2C8; + /* 0x2CC */ f32 unk_2CC; + /* 0x2D0 */ f32 unk_2D0; + /* 0x2D4 */ s16 unk_2D4; + /* 0x2D6 */ s16 unk_2D6; + /* 0x2D8 */ s16 unk_2D8; + /* 0x2DA */ s16 unk_2DA; + /* 0x2DC */ s16 unk_2DC; + /* 0x2DE */ s16 unk_2DE; + /* 0x2E0 */ s16 unk_2E0; + /* 0x2E2 */ s16 unk_2E2; + /* 0x2E4 */ Vec3f unk_2E4[16]; + /* 0x3A4 */ Vec3f unk_3A4[15]; + /* 0x458 */ Vec3f unk_458[15]; + /* 0x50C */ Vec3f unk_50C[11]; + /* 0x590 */ Vec3f unk_590[11]; + /* 0x614 */ Vec3f unk_614[6]; + /* 0x65C */ Vec3f unk_65C[6]; + /* 0x6A4 */ Vec3f unk_6A4; + /* 0x6B0 */ Vec3f unk_6B0; + /* 0x6BC */ Vec3f unk_6BC; + /* 0x6C8 */ Vec3f unk_6C8; + /* 0x6D4 */ f32 unk_6D4; + /* 0x6D8 */ f32 unk_6D8; + /* 0x6DC */ f32 unk_6DC; + /* 0x6E0 */ f32 unk_6E0; + /* 0x6E4 */ f32 unk_6E4; + /* 0x6E8 */ f32 unk_6E8; + /* 0x6EC */ UNK_TYPE1 unk_6EC[4]; + /* 0x6F0 */ f32 unk_6F0; + /* 0x6F4 */ s16 unk_6F4; + /* 0x6F6 */ s16 unk_6F6; + /* 0x6F8 */ f32 unk_6F8; + /* 0x6FC */ f32 unk_6FC; + /* 0x700 */ f32 unk_700; + /* 0x704 */ u32 unk_704; + /* 0x708 */ s16 unk_708; + /* 0x70A */ s16 subCamId; + /* 0x70C */ Vec3f subCamEye; + /* 0x718 */ Vec3f subCamAt; + /* 0x724 */ UNK_TYPE1 unk_724[4]; + /* 0x728 */ f32 unk_728; + /* 0x72C */ UNK_TYPE1 unk_72C[0x10]; + /* 0x73C */ f32 unk_73C; + /* 0x740 */ UNK_TYPE1 unk_740[4]; + /* 0x744 */ f32 subCamFov; + /* 0x748 */ s16 subCamAtOscillator; + /* 0x74A */ u8 unk_74A; } Boss04; // size = 0x74C extern const ActorInit Boss_04_InitVars; diff --git a/src/overlays/actors/ovl_Boss_05/z_boss_05.c b/src/overlays/actors/ovl_Boss_05/z_boss_05.c index b214a511d..7b40069d7 100644 --- a/src/overlays/actors/ovl_Boss_05/z_boss_05.c +++ b/src/overlays/actors/ovl_Boss_05/z_boss_05.c @@ -44,7 +44,7 @@ static ColliderJntSphElementInit D_809F1B2C[2] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809F1B74 = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_809F1B2C, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809F1B2C, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -58,7 +58,7 @@ static ColliderJntSphElementInit D_809F1B84[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809F1BA8 = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809F1B84, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809F1B84, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -72,7 +72,7 @@ static ColliderJntSphElementInit D_809F1BB8[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809F1BDC = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809F1BB8, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809F1BB8, // sJntSphElementsInit, }; // static DamageTable sDamageTable = { diff --git a/src/overlays/actors/ovl_Boss_05/z_boss_05.h b/src/overlays/actors/ovl_Boss_05/z_boss_05.h index 039eeb750..7a3f29507 100644 --- a/src/overlays/actors/ovl_Boss_05/z_boss_05.h +++ b/src/overlays/actors/ovl_Boss_05/z_boss_05.h @@ -8,10 +8,10 @@ struct Boss05; typedef void (*Boss05ActionFunc)(struct Boss05*, PlayState*); typedef struct Boss05 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x2C]; - /* 0x0170 */ Boss05ActionFunc actionFunc; - /* 0x0174 */ char unk_174[0x394]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x2C]; + /* 0x170 */ Boss05ActionFunc actionFunc; + /* 0x174 */ char unk_174[0x394]; } Boss05; // size = 0x508 extern const ActorInit Boss_05_InitVars; diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 4467a5658..29506a372 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -200,9 +200,9 @@ void func_809F24C8(Boss06* this, PlayState* play) { Cutscene_Start(play, &play->csCtx); func_800B7298(play, &this->actor, 7); - this->unk_A00 = Play_CreateSubCamera(play); - Play_CameraChangeStatus(play, CAM_ID_MAIN, 1); - Play_CameraChangeStatus(play, this->unk_A00, 7); + this->subCamId = Play_CreateSubCamera(play); + Play_CameraChangeStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_CameraChangeStatus(play, this->subCamId, CAM_STATUS_ACTIVE); D_809F4970->unk_151 = 1; this->unk_1C9 = 1; this->unk_1C8 = 1; @@ -244,26 +244,26 @@ void func_809F24C8(Boss06* this, PlayState* play) { player->actor.world.rot.y = player->actor.shape.rot.y; } - this->unk_A04.x = player->actor.world.pos.x + 20.0f; - this->unk_A04.y = player->actor.world.pos.y + 20.0f; - this->unk_A04.z = player->actor.world.pos.z + 30.0f; + this->subCamEye.x = player->actor.world.pos.x + 20.0f; + this->subCamEye.y = player->actor.world.pos.y + 20.0f; + this->subCamEye.z = player->actor.world.pos.z + 30.0f; - this->unk_A10.x = player->actor.world.pos.x; - this->unk_A10.y = player->actor.world.pos.y + 26.0f; - this->unk_A10.z = player->actor.world.pos.z; + this->subCamAt.x = player->actor.world.pos.x; + this->subCamAt.y = player->actor.world.pos.y + 26.0f; + this->subCamAt.z = player->actor.world.pos.z; if (this->unk_1CA >= 75) { temp_v0_2 = play->actorCtx.actorLists[ACTORCAT_BOSS].first; while (temp_v0_2 != NULL) { if ((temp_v0_2->id == ACTOR_EN_KNIGHT) && (&D_809F4970->actor == temp_v0_2) && (D_809F4970->unk_680 != 0)) { - this->unk_A04.x = 1307.0f; - this->unk_A04.y = 142.0f; - this->unk_A04.z = 2897.0f; + this->subCamEye.x = 1307.0f; + this->subCamEye.y = 142.0f; + this->subCamEye.z = 2897.0f; - this->unk_A10.x = 1376.0f; - this->unk_A10.y = 132.0f; - this->unk_A10.z = 2860.0f; + this->subCamAt.x = 1376.0f; + this->subCamAt.y = 132.0f; + this->subCamAt.z = 2860.0f; if (this->unk_1CA == 75) { D_809F4970->unk_148 = 1; @@ -291,25 +291,25 @@ void func_809F24C8(Boss06* this, PlayState* play) { this->actor.world.pos.y - 200.0f, this->actor.world.pos.z - 170.0f, 15, 0, 0, 1); if (ENBOSS06_GET_PARAMS(&this->actor) == 0) { - this->unk_A04.x = this->actor.world.pos.x - 200.0f; + this->subCamEye.x = this->actor.world.pos.x - 200.0f; } else { - this->unk_A04.x = this->actor.world.pos.x + 200.0f; + this->subCamEye.x = this->actor.world.pos.x + 200.0f; } - this->unk_A04.y = (this->actor.world.pos.y - 200.0f) + 100.0f; - this->unk_A04.z = this->actor.world.pos.z - 200.0f; + this->subCamEye.y = (this->actor.world.pos.y - 200.0f) + 100.0f; + this->subCamEye.z = this->actor.world.pos.z - 200.0f; - this->unk_A10.x = this->actor.world.pos.x; - this->unk_A10.y = this->actor.world.pos.y + 80.0f; - this->unk_A10.z = this->actor.world.pos.z; + this->subCamAt.x = this->actor.world.pos.x; + this->subCamAt.y = this->actor.world.pos.y + 80.0f; + this->subCamAt.z = this->actor.world.pos.z; } } else { - this->unk_A10.z = this->actor.world.pos.z; - this->unk_A04.y = this->actor.world.pos.y + 60.0f; - this->unk_A04.x = this->actor.world.pos.x; + this->subCamEye.x = this->actor.world.pos.x; + this->subCamEye.y = this->actor.world.pos.y + 60.0f; + this->subCamEye.z = this->actor.world.pos.z - 210.0f; - this->unk_A04.z = this->actor.world.pos.z - 210.0f; - this->unk_A10.y = this->actor.world.pos.y + 80.0f; - this->unk_A10.x = this->actor.world.pos.x; + this->subCamAt.x = this->actor.world.pos.x; + this->subCamAt.y = this->actor.world.pos.y + 80.0f; + this->subCamAt.z = this->actor.world.pos.z; } break; @@ -317,20 +317,20 @@ void func_809F24C8(Boss06* this, PlayState* play) { child = this->actor.child; if (this->unk_1CA == 1) { - this->unk_A1C.x = fabsf(this->unk_A10.x - child->world.pos.x); - this->unk_A1C.y = fabsf(this->unk_A10.y - child->world.pos.y); - this->unk_A1C.z = fabsf(this->unk_A10.z - child->world.pos.z); + this->unk_A1C.x = fabsf(this->subCamAt.x - child->world.pos.x); + this->unk_A1C.y = fabsf(this->subCamAt.y - child->world.pos.y); + this->unk_A1C.z = fabsf(this->subCamAt.z - child->world.pos.z); } - Math_ApproachF(&this->unk_A10.x, child->world.pos.x, 0.15f, this->unk_A1C.x * this->unk_A28); - Math_ApproachF(&this->unk_A10.y, child->world.pos.y, 0.15f, this->unk_A1C.y * this->unk_A28); - Math_ApproachF(&this->unk_A10.z, child->world.pos.z, 0.15f, this->unk_A1C.z * this->unk_A28); + Math_ApproachF(&this->subCamAt.x, child->world.pos.x, 0.15f, this->unk_A1C.x * this->unk_A28); + Math_ApproachF(&this->subCamAt.y, child->world.pos.y, 0.15f, this->unk_A1C.y * this->unk_A28); + Math_ApproachF(&this->subCamAt.z, child->world.pos.z, 0.15f, this->unk_A1C.z * this->unk_A28); Math_ApproachF(&this->unk_A28, 1.0f, 1.0f, 0.001f); if (this->unk_1CA > 80) { func_809F2ED0(this, play); - func_80169AFC(play, this->unk_A00, 0); - this->unk_A00 = 0; + func_80169AFC(play, this->subCamId, 0); + this->subCamId = SUB_CAM_ID_DONE; Cutscene_End(play, &play->csCtx); func_800B7298(play, &this->actor, 6); D_809F4970->unk_151 = 0; @@ -338,9 +338,9 @@ void func_809F24C8(Boss06* this, PlayState* play) { break; } - if (this->unk_A00 != 0) { + if (this->subCamId != SUB_CAM_ID_DONE) { ShrinkWindow_SetLetterboxTarget(27); - Play_CameraSetAtEye(play, this->unk_A00, &this->unk_A10, &this->unk_A04); + Play_CameraSetAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); } } #else diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.h b/src/overlays/actors/ovl_Boss_06/z_boss_06.h index a720d2b24..39d2f900a 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.h +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.h @@ -10,44 +10,44 @@ typedef void (*Boss06ActionFunc)(struct Boss06*, PlayState*); #define ENBOSS06_GET_PARAMS(thisx) ((thisx)->params) typedef struct Boss06 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ u8 unk_144; - /* 0x0146 */ s16 unk_146; - /* 0x0148 */ s16 unk_148; - /* 0x014C */ ColliderCylinder collider; - /* 0x0198 */ Boss06ActionFunc actionFunc; - /* 0x019C */ f32 unk_19C; - /* 0x01A0 */ f32 unk_1A0; - /* 0x01A4 */ f32 unk_1A4; - /* 0x01A8 */ f32 unk_1A8; - /* 0x01AC */ f32 unk_1AC; - /* 0x01B0 */ f32 unk_1B0; - /* 0x01B4 */ f32 unk_1B4; - /* 0x01B8 */ UNK_TYPE1 unk1B8[4]; - /* 0x01BC */ f32 unk_1BC; - /* 0x01C0 */ f32 unk_1C0; - /* 0x01C4 */ UNK_TYPE1 unk1C4[4]; - /* 0x01C8 */ u8 unk_1C8; - /* 0x01C9 */ u8 unk_1C9; - /* 0x01CA */ s16 unk_1CA; - /* 0x01CC */ f32 unk_1CC; - /* 0x01D0 */ f32 unk_1D0; - /* 0x01D4 */ f32 unk_1D4; - /* 0x01D8 */ f32 unk_1D8; - /* 0x01DC */ f32 unk_1DC; - /* 0x01E0 */ f32 unk_1E0; - /* 0x01E4 */ f32 unk_1E4; - /* 0x01E8 */ UNK_TYPE1 unk1E8[0x15]; - /* 0x01FD */ u8 unk_1FD; - /* 0x01FE */ u8 unk_1FE; - /* 0x01FF */ u8 unk_1FF; - /* 0x0200 */ u8 unk_200[0x800]; - /* 0x0A00 */ s16 unk_A00; - /* 0x0A04 */ Vec3f unk_A04; - /* 0x0A10 */ Vec3f unk_A10; - /* 0x0A1C */ Vec3f unk_A1C; - /* 0x0A28 */ f32 unk_A28; - /* 0x0A2C */ f32 unk_A2C; + /* 0x000 */ Actor actor; + /* 0x144 */ u8 unk_144; + /* 0x146 */ s16 unk_146; + /* 0x148 */ s16 unk_148; + /* 0x14C */ ColliderCylinder collider; + /* 0x198 */ Boss06ActionFunc actionFunc; + /* 0x19C */ f32 unk_19C; + /* 0x1A0 */ f32 unk_1A0; + /* 0x1A4 */ f32 unk_1A4; + /* 0x1A8 */ f32 unk_1A8; + /* 0x1AC */ f32 unk_1AC; + /* 0x1B0 */ f32 unk_1B0; + /* 0x1B4 */ f32 unk_1B4; + /* 0x1B8 */ UNK_TYPE1 unk1B8[4]; + /* 0x1BC */ f32 unk_1BC; + /* 0x1C0 */ f32 unk_1C0; + /* 0x1C4 */ UNK_TYPE1 unk1C4[4]; + /* 0x1C8 */ u8 unk_1C8; + /* 0x1C9 */ u8 unk_1C9; + /* 0x1CA */ s16 unk_1CA; + /* 0x1CC */ f32 unk_1CC; + /* 0x1D0 */ f32 unk_1D0; + /* 0x1D4 */ f32 unk_1D4; + /* 0x1D8 */ f32 unk_1D8; + /* 0x1DC */ f32 unk_1DC; + /* 0x1E0 */ f32 unk_1E0; + /* 0x1E4 */ f32 unk_1E4; + /* 0x1E8 */ UNK_TYPE1 unk1E8[0x15]; + /* 0x1FD */ u8 unk_1FD; + /* 0x1FE */ u8 unk_1FE; + /* 0x1FF */ u8 unk_1FF; + /* 0x200 */ u8 unk_200[0x800]; + /* 0xA00 */ s16 subCamId; + /* 0xA04 */ Vec3f subCamEye; + /* 0xA10 */ Vec3f subCamAt; + /* 0xA1C */ Vec3f unk_A1C; + /* 0xA28 */ f32 unk_A28; + /* 0xA2C */ f32 unk_A2C; } Boss06; // size = 0xA30 extern const ActorInit Boss_06_InitVars; diff --git a/src/overlays/actors/ovl_Boss_07/z_boss_07.c b/src/overlays/actors/ovl_Boss_07/z_boss_07.c index ba2a30072..9b988da18 100644 --- a/src/overlays/actors/ovl_Boss_07/z_boss_07.c +++ b/src/overlays/actors/ovl_Boss_07/z_boss_07.c @@ -296,7 +296,7 @@ static ColliderJntSphElementInit D_80A07A40[11] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A07BCC = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 11, D_80A07A40, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A07A40, // sJntSphElementsInit, }; // static ColliderCylinderInit sCylinderInit = { @@ -317,7 +317,7 @@ static ColliderJntSphElementInit D_80A07C08[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A07C2C = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A07C08, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A07C08, // sJntSphElementsInit, }; // static ColliderQuadInit sQuadInit = { @@ -385,7 +385,7 @@ static ColliderJntSphElementInit D_80A07CDC[11] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A07E68 = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 11, D_80A07CDC, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A07CDC, // sJntSphElementsInit, }; // static ColliderCylinderInit sCylinderInit = { diff --git a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c index 539387aaa..75f530c48 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c @@ -128,7 +128,7 @@ static ColliderJntSphElementInit D_80B0E700[19] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80B0E9AC = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 19, D_80B0E700, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80B0E700, // sJntSphElementsInit, }; // static ColliderTrisElementInit sTrisElementsInit[1] = { @@ -142,7 +142,7 @@ static ColliderTrisElementInit D_80B0E9BC[1] = { // static ColliderTrisInit sTrisInit = { static ColliderTrisInit D_80B0E9F8 = { { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_TYPE_1, COLSHAPE_TRIS, }, - 1, D_80B0E9BC, // sTrisElementsInit, + ARRAY_COUNT(sTrisElementsInit), D_80B0E9BC, // sTrisElementsInit, }; // static ColliderSphereInit sSphereInit = { diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h index 749ead946..985e2c30c 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h @@ -23,15 +23,15 @@ typedef enum { } DemoEffectType; typedef struct DemoEffect { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelCurve skelCurve; - /* 0x0164 */ u8 initObjectIndex; - /* 0x0165 */ u8 primXluColor[3]; - /* 0x0168 */ u8 envXluColor[3]; - /* 0x016C */ s16 timer; - /* 0x0170 */ DemoEffectActionFunc initActionFunc; - /* 0x0174 */ ActorFunc initDrawFunc; - /* 0x0178 */ DemoEffectActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelCurve skelCurve; + /* 0x164 */ u8 initObjectIndex; + /* 0x165 */ u8 primXluColor[3]; + /* 0x168 */ u8 envXluColor[3]; + /* 0x16C */ s16 timer; + /* 0x170 */ DemoEffectActionFunc initActionFunc; + /* 0x174 */ ActorFunc initDrawFunc; + /* 0x178 */ DemoEffectActionFunc actionFunc; } DemoEffect; // size = 0x17C extern const ActorInit Demo_Effect_InitVars; diff --git a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c index 7a767d8de..d39c8aa17 100644 --- a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c +++ b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c @@ -1,7 +1,7 @@ /* * File: z_demo_getitem.c * Overlay: ovl_Demo_Getitem - * Description: Cutscene object for Great Fairy's Mask and Great Fairy's Sword + * Description: Cutscene objectIndex for Great Fairy's Mask and Great Fairy's Sword */ #include "z_demo_getitem.h" @@ -14,7 +14,10 @@ void DemoGetitem_Init(Actor* thisx, PlayState* play); void DemoGetitem_Destroy(Actor* thisx, PlayState* play); void DemoGetitem_Update(Actor* thisx, PlayState* play); -#if 0 +void func_80A4FB10(DemoGetitem* this, PlayState* play); +void func_80A4FB68(DemoGetitem* this, PlayState* play2); +void DemoGetitem_Draw(Actor* thisx, PlayState* play); + const ActorInit Demo_Getitem_InitVars = { ACTOR_DEMO_GETITEM, ACTORCAT_BG, @@ -27,16 +30,84 @@ const ActorInit Demo_Getitem_InitVars = { (ActorFunc)NULL, }; -#endif +static s16 sObjectBankIndices[] = { OBJECT_GI_MASK14, OBJECT_GI_SWORD_4 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/DemoGetitem_Init.s") +static s16 sGetItemDraws[] = { GID_MASK_GREAT_FAIRY, GID_SWORD_GREAT_FAIRY }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/DemoGetitem_Destroy.s") +static u16 sCsActionIndices[] = { 0x6E, 0x236 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/func_80A4FB10.s") +void DemoGetitem_Init(Actor* thisx, PlayState* play) { + s32 pad; + s32 objectIndex; + s32 itemIndex; + DemoGetitem* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/func_80A4FB68.s") + itemIndex = 0; + if (DEMOGETITEM_GET_F(thisx) == 1) { + itemIndex = 1; + } + Actor_SetScale(&this->actor, 0.25f); + this->actionFunc = func_80A4FB10; + this->item = sGetItemDraws[itemIndex]; + this->csAction = sCsActionIndices[itemIndex]; + objectIndex = Object_GetIndex(&play->objectCtx, sObjectBankIndices[itemIndex]); + if (objectIndex < 0) { + Actor_MarkForDeath(&this->actor); + } else { + this->objectIndex = objectIndex; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/DemoGetitem_Update.s") +void DemoGetitem_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/func_80A4FCF0.s") +void func_80A4FB10(DemoGetitem* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->objectIndex)) { + this->actor.draw = NULL; + this->actor.objBankIndex = this->objectIndex; + this->actionFunc = func_80A4FB68; + } +} + +void func_80A4FB68(DemoGetitem* this, PlayState* play2) { + PlayState* play = play2; + u16 sp22 = (play->gameplayFrames * 1000) & 0xFFFF; + + if (Cutscene_CheckActorAction(play, this->csAction)) { + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action != 4) { + this->actor.shape.yOffset = 0.0f; + } + switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action) { + case 2: + this->actor.draw = DemoGetitem_Draw; + Cutscene_ActorTranslate(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csAction)); + this->actor.shape.rot.y += 0x3E8; + return; + case 3: + Actor_MarkForDeath(&this->actor); + return; + case 4: + this->actor.draw = DemoGetitem_Draw; + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csAction)); + this->actor.shape.yOffset = Math_SinS(sp22) * 15.0f; + return; + } + this->actor.draw = NULL; + } else { + this->actor.draw = NULL; + } +} + +void DemoGetitem_Update(Actor* thisx, PlayState* play) { + DemoGetitem* this = THIS; + + this->actionFunc(this, play); +} + +void DemoGetitem_Draw(Actor* thisx, PlayState* play) { + DemoGetitem* this = THIS; + + func_800B8050(&this->actor, play, 0); + func_800B8118(&this->actor, play, 0); + GetItem_Draw(play, this->item); +} diff --git a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.h b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.h index c7b933811..acc2c0312 100644 --- a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.h +++ b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.h @@ -3,14 +3,18 @@ #include "global.h" +#define DEMOGETITEM_GET_F(thisx) ((thisx)->params & 0xF) + struct DemoGetitem; typedef void (*DemoGetitemActionFunc)(struct DemoGetitem*, PlayState*); typedef struct DemoGetitem { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8]; - /* 0x014C */ DemoGetitemActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 item; + /* 0x146 */ u16 csAction; + /* 0x148 */ s8 objectIndex; + /* 0x14C */ DemoGetitemActionFunc actionFunc; } DemoGetitem; // size = 0x150 extern const ActorInit Demo_Getitem_InitVars; diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index 57347e4e2..8aba01fc0 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -502,7 +502,7 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, PlayState* play2) { Vec3f screenPos; // if not underwater - if (!(play->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100)) { + if (!(play->cameraPtrs[CAM_ID_MAIN]->stateFlags & CAM_STATE_UNDERWATER)) { OPEN_DISPS(play->state.gfxCtx); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h index 7c7885b14..f6f05d0a6 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h @@ -8,21 +8,21 @@ struct DemoKankyo; typedef void (*DemoKankyoActionFunc)(struct DemoKankyo*, PlayState*); typedef struct { - /* 0x000 */ u8 state; - /* 0x004 */ Vec3f posOffset; - /* 0x010 */ Vec3f posOffsetPrev; - /* 0x01C */ Vec3f posBase; - /* 0x028 */ Vec3f speedClock; // cycles in radians - /* 0x034 */ f32 speed; - /* 0x038 */ f32 speedTarget; - /* 0x03C */ u16 alphaClock; - /* 0x03E */ u16 LostWoodsSkyFishSpeedXZClock; - /* 0x040 */ u8 alpha; - /* 0x044 */ f32 scale; // size of the effect - /* 0x048 */ u16 LostWoodsSkyFishSpeedXZ; // the x-z speed (angular velocity) the lost woods skyfish oscillates around player. pos or neg 200-400 - /* 0x04A */ u16 LostWoodsSkyFishPosOffsetMax; // The x-z range the lost woods skyfish oscillates around player. random value between 15-65 - /* 0x04C */ f32 LostWoodsSkyFishSpeedY; // the y speed (angular velocity) the lost woods skyfish oscillates around player. - /* 0x050 */ u16 pad50; // unused, always assigned to 0, nothing else in this actor uses it + /* 0x00 */ u8 state; + /* 0x04 */ Vec3f posOffset; + /* 0x10 */ Vec3f posOffsetPrev; + /* 0x1C */ Vec3f posBase; + /* 0x28 */ Vec3f speedClock; // cycles in radians + /* 0x34 */ f32 speed; + /* 0x38 */ f32 speedTarget; + /* 0x3C */ u16 alphaClock; + /* 0x3E */ u16 LostWoodsSkyFishSpeedXZClock; + /* 0x40 */ u8 alpha; + /* 0x44 */ f32 scale; // size of the effect + /* 0x48 */ u16 LostWoodsSkyFishSpeedXZ; // the x-z speed (angular velocity) the lost woods skyfish oscillates around player. pos or neg 200-400 + /* 0x4A */ u16 LostWoodsSkyFishPosOffsetMax; // The x-z range the lost woods skyfish oscillates around player. random value between 15-65 + /* 0x4C */ f32 LostWoodsSkyFishSpeedY; // the y speed (angular velocity) the lost woods skyfish oscillates around player. + /* 0x50 */ u16 pad50; // unused, always assigned to 0, nothing else in this actor uses it } DemoKankyoEffect; // size = 0x54 #define DEMOKANKYO_EFFECT_COUNT 64 diff --git a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.h b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.h index c7cd1fb10..212e93d84 100644 --- a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.h +++ b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.h @@ -8,9 +8,9 @@ struct DemoMoonend; typedef void (*DemoMoonendActionFunc)(struct DemoMoonend*, PlayState*); typedef struct DemoMoonend { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x19C]; - /* 0x02E0 */ DemoMoonendActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x19C]; + /* 0x2E0 */ DemoMoonendActionFunc actionFunc; } DemoMoonend; // size = 0x2E4 extern const ActorInit Demo_Moonend_InitVars; diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h index b9625d75e..b0a00f2a6 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h @@ -21,20 +21,20 @@ enum { }; typedef struct DemoSyoten { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkeletonInfo unk_144; - /* 0x0174 */ Vec3s unk_174[51]; - /* 0x02A6 */ s16 unk_2A6[153]; - /* 0x03D8 */ f32 unk_3D8; - /* 0x03DC */ Gfx* unk_3DC; - /* 0x03E0 */ AnimatedMaterial* unk_3E0; - /* 0x03E4 */ u16 unk_3E4; - /* 0x03E6 */ s16 unk_3E6; - /* 0x03E8 */ Path* unk_3E8; - /* 0x03EC */ s32 unk_3EC; - /* 0x03F0 */ u16 unk_3F0; - /* 0x03F2 */ u16 unk_3F2; - /* 0x03F4 */ DemoSyotenActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkeletonInfo unk_144; + /* 0x174 */ Vec3s unk_174[51]; + /* 0x2A6 */ Vec3s unk_2A6[51]; + /* 0x3D8 */ f32 unk_3D8; + /* 0x3DC */ Gfx* unk_3DC; + /* 0x3E0 */ AnimatedMaterial* unk_3E0; + /* 0x3E4 */ u16 unk_3E4; + /* 0x3E6 */ s16 unk_3E6; + /* 0x3E8 */ Path* unk_3E8; + /* 0x3EC */ s32 unk_3EC; + /* 0x3F0 */ u16 unk_3F0; + /* 0x3F2 */ u16 unk_3F2; + /* 0x3F4 */ DemoSyotenActionFunc actionFunc; } DemoSyoten; // size = 0x3F8 extern const ActorInit Demo_Syoten_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.h b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.h index c49f049d1..f52f92d69 100644 --- a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.h +++ b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.h @@ -8,10 +8,10 @@ struct DmAh; typedef void (*DmAhActionFunc)(struct DmAh*, PlayState*); typedef struct DmAh { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ DmAhActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x114]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ DmAhActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x114]; } DmAh; // size = 0x2A0 extern const ActorInit Dm_Ah_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Al/z_dm_al.c b/src/overlays/actors/ovl_Dm_Al/z_dm_al.c index a19de97b0..ce3e18ab2 100644 --- a/src/overlays/actors/ovl_Dm_Al/z_dm_al.c +++ b/src/overlays/actors/ovl_Dm_Al/z_dm_al.c @@ -15,9 +15,6 @@ void DmAl_Destroy(Actor* thisx, PlayState* play); void DmAl_Update(Actor* thisx, PlayState* play); void DmAl_Draw(Actor* thisx, PlayState* play); -void func_80C1BDD8(DmAl* this, PlayState* play); - -#if 0 const ActorInit Dm_Al_InitVars = { ACTOR_EN_AL, ACTORCAT_NPC, @@ -30,24 +27,135 @@ const ActorInit Dm_Al_InitVars = { (ActorFunc)DmAl_Draw, }; -#endif +static AnimationInfoS sAnimationInfos[] = { + { &object_al_Anim_00DBE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern UNK_TYPE D_0600A0D8; +s32 DmAl_ChangeAnimation(DmAl* this, s32 animationIndex) { + s32 didAnimationChange = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/func_80C1BD90.s") + if (animationIndex != this->animationIndex) { + this->animationIndex = animationIndex; + didAnimationChange = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfos, animationIndex); + } + return didAnimationChange; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/func_80C1BDD8.s") +void func_80C1BDD8(DmAl* this, PlayState* play) { + s32 D_80C1C280[] = { 0, 0, 0, 0, 0 }; + u16 csAction; + s32 actionIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/DmAl_Init.s") + if (play->csCtx.state != 0) { + if (!this->unk_45C) { + this->action = 0xFF; + this->unk_45C = true; + this->animationIndex2 = this->animationIndex; + } + if (Cutscene_CheckActorAction(play, 0x232)) { + actionIndex = Cutscene_GetActorActionIndex(play, 0x232); + csAction = play->csCtx.actorActions[actionIndex]->action; + if (this->action != (u8)csAction) { + this->action = csAction; + DmAl_ChangeAnimation(this, D_80C1C280[csAction]); + } + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + } + } else if (this->unk_45C) { + this->unk_45C = false; + DmAl_ChangeAnimation(this, this->animationIndex2); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/DmAl_Destroy.s") +void DmAl_Init(Actor* thisx, PlayState* play) { + DmAl* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/DmAl_Update.s") + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gMadameAromaSkel, NULL, this->jointTable, this->morphTable, + MADAME_AROMA_LIMB_MAX); + this->animationIndex = -1; + DmAl_ChangeAnimation(this, MADAME_AROMA_ANIMATION_0); + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80C1BDD8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/func_80C1C028.s") +void DmAl_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/func_80C1C064.s") +void DmAl_Update(Actor* thisx, PlayState* play) { + DmAl* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/func_80C1C11C.s") + this->actionFunc(this, play); + SkelAnime_Update(&this->skelAnime); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Al/DmAl_Draw.s") +s32 DmAl_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* rot, Vec3s* pos, Actor* thisx) { + switch (limbIndex) { + case MADAME_AROMA_LIMB_SHAWL_MIDDLE: + case MADAME_AROMA_LIMB_SHAWL_UPPER: + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER_MIDDLE: + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER: + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER_MIDDLE: + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER: + *dList = NULL; + break; + } + return false; +} + +void DmAl_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + DmAl* this = THIS; + + switch (limbIndex) { + case MADAME_AROMA_LIMB_SHAWL_MIDDLE: + Matrix_Get(&this->shawlMatrices[0]); + break; + case MADAME_AROMA_LIMB_SHAWL_UPPER: + Matrix_Get(&this->shawlMatrices[1]); + break; + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER_MIDDLE: + Matrix_Get(&this->shawlMatrices[2]); + break; + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER: + Matrix_Get(&this->shawlMatrices[3]); + break; + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER_MIDDLE: + Matrix_Get(&this->shawlMatrices[4]); + break; + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER: + Matrix_Get(&this->shawlMatrices[5]); + break; + default: + break; + } +} + +void DmAl_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { +} + +static Gfx* sDlists[] = { + gMadameAromaShawlMiddleDL, gMadameAromaShawlUpperDL, + gMadameAromaShawlLeftLowerMiddleDL, gMadameAromaShawlLeftLowerDL, + gMadameAromaShawlRightLowerMiddleDL, gMadameAromaShawlRightLowerDL, +}; + +void DmAl_Draw(Actor* thisx, PlayState* play) { + u32 i; + DmAl* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, DmAl_OverrideLimbDraw, DmAl_PostLimbDraw, + DmAl_TransformLimbDraw, &this->actor); + for (i = 0; i < ARRAY_COUNT(this->shawlMatrices); i++) { + Matrix_Put(&this->shawlMatrices[i]); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sDlists[i]); + } + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Al/z_dm_al.h b/src/overlays/actors/ovl_Dm_Al/z_dm_al.h index 5e9a3d91d..f15513177 100644 --- a/src/overlays/actors/ovl_Dm_Al/z_dm_al.h +++ b/src/overlays/actors/ovl_Dm_Al/z_dm_al.h @@ -2,18 +2,30 @@ #define Z_DM_AL_H #include "global.h" +#include "objects/object_al/object_al.h" struct DmAl; typedef void (*DmAlActionFunc)(struct DmAl*, PlayState*); typedef struct DmAl { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ DmAlActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x2D4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ DmAlActionFunc actionFunc; + /* 0x18C */ MtxF shawlMatrices[6]; + /* 0x30C */ Vec3s jointTable[MADAME_AROMA_LIMB_MAX]; + /* 0x3AE */ Vec3s morphTable[MADAME_AROMA_LIMB_MAX]; + /* 0x450 */ u8 action; + /* 0x454 */ s32 animationIndex; + /* 0x458 */ s32 animationIndex2; + /* 0x45C */ s32 unk_45C; } DmAl; // size = 0x460 +typedef enum { + /* 0x0 */ MADAME_AROMA_ANIMATION_0, + /* 0x1 */ MADAME_AROMA_ANIMATION_1 +} DmAlAnimations; + extern const ActorInit Dm_Al_InitVars; #endif // Z_DM_AL_H diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.c b/src/overlays/actors/ovl_Dm_An/z_dm_an.c index 01f71f179..aec59f032 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -62,9 +62,9 @@ s32 func_80C1C410(DmAn* this, PlayState* play) { } if (objectIndex2 >= 0) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[objectIndex2].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex2].segment); ret = SkelAnime_Update(&this->skelAnime); - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[objectIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex].segment); } return ret; } @@ -81,10 +81,10 @@ s32 func_80C1C4D8(DmAn* this, PlayState* play, s32 arg2) { } if ((objectIndex2 >= 0) && (arg2 != this->unk_2C8)) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[objectIndex2].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex2].segment); this->unk_2C8 = arg2; ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[objectIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex].segment); } return ret; } diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.h b/src/overlays/actors/ovl_Dm_An/z_dm_an.h index 676d215a4..2282fee9c 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.h +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.h @@ -9,31 +9,31 @@ struct DmAn; typedef void (*DmAnActionFunc)(struct DmAn*, PlayState*); typedef struct DmAn { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ DmAnActionFunc actionFunc; - /* 0x018C */ Vec3f unk_18C; - /* 0x018C */ Vec3f unk_194; - /* 0x01A4 */ Vec3s unk_1A4; - /* 0x01A4 */ Vec3s unk_1AA; - /* 0x01B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; - /* 0x022E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; - /* 0x02AC */ s8 unk_2AC; - /* 0x02AD */ s8 unk_2AD; - /* 0x02AE */ u16 unk_2AE; - /* 0x02B0 */ u8 unk_2B0; - /* 0x02B4 */ Actor* unk_2B4; - /* 0x02B8 */ s16 unk_2B8; - /* 0x02BA */ s16 unk_2BA; - /* 0x02BC */ s16 unk_2BC; - /* 0x02BE */ s16 unk_2BE; - /* 0x02C0 */ s16 unk_2C0; - /* 0x02C2 */ s16 unk_2C2; - /* 0x02C4 */ s16 unk_2C4; - /* 0x02C8 */ s32 unk_2C8; - /* 0x02CC */ s32 unk_2CC; - /* 0x02D0 */ s32 unk_2D0; - /* 0x02D4 */ s32 unk_2D4; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ DmAnActionFunc actionFunc; + /* 0x18C */ Vec3f unk_18C; + /* 0x18C */ Vec3f unk_194; + /* 0x1A4 */ Vec3s unk_1A4; + /* 0x1A4 */ Vec3s unk_1AA; + /* 0x1B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; + /* 0x22E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; + /* 0x2AC */ s8 unk_2AC; + /* 0x2AD */ s8 unk_2AD; + /* 0x2AE */ u16 unk_2AE; + /* 0x2B0 */ u8 unk_2B0; + /* 0x2B4 */ Actor* unk_2B4; + /* 0x2B8 */ s16 unk_2B8; + /* 0x2BA */ s16 unk_2BA; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C2 */ s16 unk_2C2; + /* 0x2C4 */ s16 unk_2C4; + /* 0x2C8 */ s32 unk_2C8; + /* 0x2CC */ s32 unk_2CC; + /* 0x2D0 */ s32 unk_2D0; + /* 0x2D4 */ s32 unk_2D4; } DmAn; // size = 0x2D8 extern const ActorInit Dm_An_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c index 2a3144be3..44905d800 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -899,7 +899,7 @@ s32 DmChar00_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f Vec3f sp1C; if (limbIndex == 6) { - sp28 = ((Math_SinS(this->unk_262 * 0x1000) * 0.1f) + 1.0f) * 0.012f * (this->actor.scale.x * 124.99999f); + sp28 = ((Math_SinS(this->unk_262 * 0x1000) * 0.1f) + 1.0f) * 0.012f * (this->actor.scale.x * (1.0f / 0.008f)); Matrix_MultVec3f(&D_80AA7808, &sp1C); Matrix_Translate(sp1C.x, sp1C.y, sp1C.z, MTXMODE_NEW); Matrix_Scale(sp28, sp28, sp28, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h index d28232eb3..0a7f2410c 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h @@ -21,18 +21,18 @@ typedef struct { } DmChar00Struct; // size = 0x10 typedef struct DmChar00 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[7]; - /* 0x01B2 */ UNK_TYPE1 unk_1B2[0x30]; - /* 0x01E2 */ Vec3s morphTable[7]; - /* 0x020C */ UNK_TYPE1 unk_20C[0x30]; - /* 0x023C */ DmChar00ActionFunc actionFunc; - /* 0x0240 */ DmChar00Struct unk_240; - /* 0x0250 */ DmChar00Struct unk_250; - /* 0x0260 */ u8 unk_260; - /* 0x0261 */ u8 unk_261; - /* 0x0262 */ u16 unk_262; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[7]; + /* 0x1B2 */ UNK_TYPE1 unk_1B2[0x30]; + /* 0x1E2 */ Vec3s morphTable[7]; + /* 0x20C */ UNK_TYPE1 unk_20C[0x30]; + /* 0x23C */ DmChar00ActionFunc actionFunc; + /* 0x240 */ DmChar00Struct unk_240; + /* 0x250 */ DmChar00Struct unk_250; + /* 0x260 */ u8 unk_260; + /* 0x261 */ u8 unk_261; + /* 0x262 */ u16 unk_262; } DmChar00; // size = 0x264 extern const ActorInit Dm_Char00_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c index 3f3e83382..35fc84ccf 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -6,6 +6,7 @@ #include "z_dm_char01.h" #include "objects/object_mtoride/object_mtoride.h" +#include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) @@ -127,7 +128,8 @@ void DmChar01_Init(Actor* thisx, PlayState* play) { return; } - Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_ETCETERA, 5.0f, 202.0f, 294.0f, 0, 0, 0, 0x80); + Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_ETCETERA, 5.0f, 202.0f, 294.0f, 0, 0, 0, + DEKU_FLOWER_PARAMS(DEKU_FLOWER_TYPE_PINK_WITH_INITIAL_BOUNCE)); DynaPolyActor_Init(&this->dyna, 0); DynaPolyActor_LoadMesh(play, &this->dyna, &object_mtoride_Colheader_00FE5C); @@ -331,7 +333,8 @@ void func_80AA8F2C(DmChar01* this, PlayState* play) { Math_SmoothStepToF(&this->unk_348, 0.0f, 0.01f, 0.5f, 0.4f); if ((s32)this->dyna.actor.world.pos.y >= 0) { D_80AAAE26 = 2; - Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_ETCETERA, 5.0f, 202.0f, 294.0f, 0, 0, 0, 0x80); + Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_ETCETERA, 5.0f, 202.0f, 294.0f, 0, 0, 0, + DEKU_FLOWER_PARAMS(DEKU_FLOWER_TYPE_PINK_WITH_INITIAL_BOUNCE)); this->actionFunc = func_80AA90F4; } } diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h index e972f89ab..677a2b59b 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h @@ -17,15 +17,15 @@ enum { }; typedef struct DmChar01 { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ UNK_TYPE1 unk15C[0x44]; - /* 0x01A0 */ DmChar01ActionFunc actionFunc; - /* 0x01A4 */ UNK_TYPE1 unk1A4[0x8]; - /* 0x01AC */ s16 unk_1AC[205]; - /* 0x0346 */ s16 unk_346; - /* 0x0348 */ f32 unk_348; - /* 0x034C */ u8 unk_34C; - /* 0x034D */ u8 unk_34D; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ UNK_TYPE1 unk15C[0x44]; + /* 0x1A0 */ DmChar01ActionFunc actionFunc; + /* 0x1A4 */ UNK_TYPE1 unk1A4[0x8]; + /* 0x1AC */ s16 unk_1AC[205]; + /* 0x346 */ s16 unk_346; + /* 0x348 */ f32 unk_348; + /* 0x34C */ u8 unk_34C; + /* 0x34D */ u8 unk_34D; } DmChar01; // size = 0x350 extern const ActorInit Dm_Char01_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c index 590045fa0..08e6dfbcf 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c @@ -5,6 +5,7 @@ */ #include "z_dm_char02.h" +#include "objects/object_stk2/object_stk2.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -17,7 +18,6 @@ void DmChar02_Draw(Actor* thisx, PlayState* play); void func_80AAB04C(DmChar02* this, PlayState* play); -#if 0 const ActorInit Dm_Char02_InitVars = { ACTOR_DM_CHAR02, ACTORCAT_ITEMACTION, @@ -28,30 +28,148 @@ const ActorInit Dm_Char02_InitVars = { (ActorFunc)DmChar02_Destroy, (ActorFunc)DmChar02_Update, (ActorFunc)DmChar02_Draw, + }; -#endif +static AnimationInfo sAnimations[] = { + { &object_stk2_Anim_00A2BC, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_00A4C4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_00A6D4, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_00A104, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, +}; -extern UNK_TYPE D_0600AD68; +void DmChar02_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animInfo, u16 index) { + f32 frameCount; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAAE30.s") + animInfo += index; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAAECC.s") + if (animInfo->frameCount < 0.0f) { + frameCount = Animation_GetLastFrame(animInfo->animation); + } else { + frameCount = animInfo->frameCount; + } + Animation_Change(skelAnime, animInfo->animation, animInfo->playSpeed, animInfo->startFrame, frameCount, + animInfo->mode, animInfo->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAAF2C.s") +void func_80AAAECC(Actor* actor, PlayState* play) { + switch (play->csCtx.frames) { + case 95: + Actor_PlaySfxAtPos(actor, NA_SE_EV_OCARINA_BOUND_0); + return; + case 101: + case 105: + case 112: + Actor_PlaySfxAtPos(actor, NA_SE_EV_OCARINA_BOUND_1); + return; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/DmChar02_Init.s") +void func_80AAAF2C(DmChar02* this, PlayState* play) { + if ((play->csCtx.state != 0) && (play->sceneNum == SCENE_OKUJOU) && (play->csCtx.currentCsIndex == 1)) { + func_80AAAECC(&this->actor, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/DmChar02_Destroy.s") +void DmChar02_Init(Actor* thisx, PlayState* play) { + DmChar02* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAB04C.s") + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + this->animIndex = 0; + this->actor.targetArrowOffset = 3000.0f; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gClockTowerOcarinaOfTimeSkel, NULL, NULL, NULL, 0); + DmChar02_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80AAB04C; + } else { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/DmChar02_Update.s") +void DmChar02_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAB23C.s") +void func_80AAB04C(DmChar02* this, PlayState* play) { + u8 sp2F = true; + s32 actionIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAB258.s") + if (Cutscene_CheckActorAction(play, 0x83)) { + actionIndex = Cutscene_GetActorActionIndex(play, 0x83); + if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + switch (play->csCtx.actorActions[actionIndex]->action) { + default: + this->animIndex = 0; + sp2F = false; + break; + case 1: + this->animIndex = 0; + break; + case 2: + this->animIndex = 1; + break; + case 4: + this->animIndex = 3; + break; + } + if (sp2F) { + DmChar02_ChangeAnimationByInfo(&this->skelAnime, &sAnimations[this->animIndex], 0); + } + } + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + } + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->animIndex == 1) { + this->animIndex++; + DmChar02_ChangeAnimationByInfo(&this->skelAnime, &sAnimations[this->animIndex], 0); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAB270.s") +void DmChar02_Update(Actor* thisx, PlayState* play) { + DmChar02* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/DmChar02_Draw.s") + SkelAnime_Update(&this->skelAnime); + this->unk2F0 = this->unk2F0; + this->actionFunc(this, play); + if (!Actor_HasParent(&this->actor, play)) { + Actor_PickUp(&this->actor, play, GI_OCARINA, 30.0f, 80.0f); + } else { + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + Actor_MarkForDeath(&this->actor); + } + func_80AAAF2C(this, play); +} + +s32 DmChar02_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void DmChar02_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +void DmChar02_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { +} + +void DmChar02_Draw(Actor* thisx, PlayState* play) { + s32 pad[2]; + DmChar02* this = THIS; + s32 sp30 = false; + + if ((play->csCtx.state == 0) && (this->actor.world.pos.y < 100.0f)) { + sp30 = true; + } else if (Cutscene_CheckActorAction(play, 0x6B)) { + switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x6B)]->action) { + case 0x17: + case 0x1C: + case 0x26: + sp30 = true; + } + } + if (sp30) { + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, DmChar02_OverrideLimbDraw, DmChar02_PostLimbDraw, + DmChar02_TransformLimbDraw, &this->actor); + } +} diff --git a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h index 276a7b026..246fd5531 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h @@ -8,10 +8,14 @@ struct DmChar02; typedef void (*DmChar02ActionFunc)(struct DmChar02*, PlayState*); typedef struct DmChar02 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x14C]; - /* 0x0290 */ DmChar02ActionFunc actionFunc; - /* 0x0294 */ char unk_294[0x60]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ UNK_TYPE1 pad188[0x108]; + /* 0x290 */ DmChar02ActionFunc actionFunc; + /* 0x294 */ UNK_TYPE1 pad294[0x4C]; + /* 0x2E0 */ s16 animIndex; + /* 0x2E2 */ UNK_TYPE1 pad2E2[0xE]; + /* 0x2F0 */ u32 unk2F0; } DmChar02; // size = 0x2F4 extern const ActorInit Dm_Char02_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c index 4245f7371..0684dbdec 100644 --- a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c +++ b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c @@ -1,7 +1,7 @@ /* * File: z_dm_char03.c * Overlay: ovl_Dm_Char03 - * Description: + * Description: Deku Mask (cutscene) */ #include "z_dm_char03.h" diff --git a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.h b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.h index f06e8085e..8d2905ad8 100644 --- a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.h +++ b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.h @@ -8,10 +8,10 @@ struct DmChar03; typedef void (*DmChar03ActionFunc)(struct DmChar03*, PlayState*); typedef struct DmChar03 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ DmChar03ActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x10]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ DmChar03ActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x10]; } DmChar03; // size = 0x19C extern const ActorInit Dm_Char03_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c index 9bec4b6cc..6c97624a8 100644 --- a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c +++ b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c @@ -5,6 +5,7 @@ */ #include "z_dm_char04.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,8 @@ void DmChar04_Destroy(Actor* thisx, PlayState* play); void DmChar04_Update(Actor* thisx, PlayState* play); void DmChar04_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_80AABE34(DmChar04* this, PlayState* play); + const ActorInit Dm_Char04_InitVars = { ACTOR_DM_CHAR04, ACTORCAT_ITEMACTION, @@ -28,18 +30,127 @@ const ActorInit Dm_Char04_InitVars = { (ActorFunc)DmChar04_Draw, }; -#endif +void DmChar04_ChangeAnim(SkelAnime* skelAnime, AnimationInfo* animation, u16 index) { + f32 endFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char04/func_80AABC40.s") + animation += index; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char04/DmChar04_Init.s") + if (animation->frameCount < 0.0f) { + endFrame = Animation_GetLastFrame(animation->animation); + } else { + endFrame = animation->frameCount; + } + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, endFrame, + animation->mode, animation->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char04/DmChar04_Destroy.s") +static AnimationInfo sAnimations[] = { + { &gameplay_keep_Anim_02B2E8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gameplay_keep_Anim_029140, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char04/func_80AABE34.s") +Color_RGBAf sPrimColors[] = { + { 250.0f, 255.0f, 230.0f, 255.0f }, + { 10.0f, 10.0f, 40.0f, 255.0f }, + { 255.0f, 235.0f, 220.0f, 255.0f }, +}; +Color_RGBAf sEnvColors[] = { + { 220.0f, 160.0f, 80.0f, 255.0f }, + { 120.0f, 255.0f, 255.0f, 255.0f }, + { 255.0f, 235.0f, 220.0f, 255.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char04/DmChar04_Update.s") +void DmChar04_Init(Actor* thisx, PlayState* play) { + DmChar04* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char04/func_80AABF74.s") + this->primColors = sPrimColors[this->actor.params]; + this->envColors = sEnvColors[this->actor.params]; + this->actor.targetArrowOffset = 3000.0f; + this->csAction = 0x63; + this->timer = this->actor.params << 0xB; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(play, &this->skelAnime, &gameplay_keep_Skel_02AF58.sh, &gameplay_keep_Anim_029140, this->jointTable, + this->morphTable, 7); + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 15.0f); + DmChar04_ChangeAnim(&this->skelAnime, sAnimations, 0); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80AABE34; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char04/DmChar04_Draw.s") +void DmChar04_Destroy(Actor* thisx, PlayState* play) { +} + +void func_80AABE34(DmChar04* this, PlayState* play) { + u16 params = this->actor.params + 0x71; + + if (Cutscene_CheckActorAction(play, params)) { + s32 actionIndex = Cutscene_GetActorActionIndex(play, params); + + if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + if (this->csAction != play->csCtx.actorActions[actionIndex]->action) { + this->csAction = play->csCtx.actorActions[actionIndex]->action; + if (play->csCtx.actorActions[actionIndex]->action == 1) { + this->animationIndex = 0; + } else { + this->animationIndex = 0; + } + DmChar04_ChangeAnim(&this->skelAnime, &sAnimations[this->animationIndex], 0); + } + } + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + } else { + this->csAction = 0x63; + } +} + +void DmChar04_Update(Actor* thisx, PlayState* play) { + DmChar04* this = THIS; + + SkelAnime_Update(&this->skelAnime); + this->actionFunc(this, play); + this->timer++; +} +static Vec3f D_80AAC4F0 = { 0.0f, 0.0f, 0.0f }; + +s32 DmChar04_OverrideLimbDraw(PlayState* play2, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + PlayState* play = play2; + f32 sp28; + Vec3f sp1C; + DmChar04* this = THIS; + + if (limbIndex == 6) { + sp28 = ((Math_SinS(this->timer << 0xC) * 0.1f) + 1.0f) * 0.012f * (this->actor.scale.x * (1.0f / 0.008f)); + Matrix_MultVec3f(&D_80AAC4F0, &sp1C); + Matrix_Translate(sp1C.x, sp1C.y, sp1C.z, MTXMODE_NEW); + Matrix_Scale(sp28, sp28, sp28, MTXMODE_APPLY); + } + return false; +} + +void DmChar04_Draw(Actor* thisx, PlayState* play) { + Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 4); + s32 alpha; + s32 pad; + DmChar04* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C94C(play->state.gfxCtx); + alpha = (this->timer * 50) & 0x1FF; + if (alpha > 255) { + alpha = 511 - alpha; + } + gSPSegment(POLY_XLU_DISP++, 0x08, &gfx[0]); + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0x01, (u8)this->primColors.r, (u8)this->primColors.g, (u8)this->primColors.b, + (u8)(this->primColors.a * 1)); + gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPEndDisplayList(gfx); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(s8)this->envColors.r, (u8)(s8)this->envColors.g, (u8)(s8)this->envColors.b, + (u8)(s8)((f32)alpha * 1)); + gDPSetDither(POLY_XLU_DISP++, G_CD_BAYER); + POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + DmChar04_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.h b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.h index 7bb8efc04..91de6d567 100644 --- a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.h +++ b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.h @@ -9,9 +9,15 @@ typedef void (*DmChar04ActionFunc)(struct DmChar04*, PlayState*); typedef struct DmChar04 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xF8]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[15]; + /* 0x1E2 */ Vec3s morphTable[15]; /* 0x023C */ DmChar04ActionFunc actionFunc; - /* 0x0240 */ char unk_240[0x24]; + /* 0x240 */ Color_RGBAf primColors; + /* 0x250 */ Color_RGBAf envColors; + /* 0x260 */ u8 csAction; + /* 0x261 */ u8 animationIndex; + /* 0x262 */ u16 timer; } DmChar04; // size = 0x264 extern const ActorInit Dm_Char04_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c index face0bef5..7f27b584d 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -770,7 +770,7 @@ void func_80AAE030(PlayState* play, DmChar05* this) { void func_80AAE114(PlayState* play, DmChar05* this) { s32 sp34; s16 sp24[] = { - GID_02, GID_6A, GID_70, GID_3A, GID_0E, GID_0F, GID_3E, GID_71, + GID_02, GID_MASK_GREAT_FAIRY, GID_70, GID_3A, GID_0E, GID_0F, GID_3E, GID_71, }; sp34 = DMCHAR05_GET(&this->actor) - DMCHAR05_5; diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h index 85a422e96..212cdb03e 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h @@ -26,20 +26,20 @@ enum { }; typedef struct DmChar05 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ DmChar05ActionFunc actionFunc; - /* 0x018C */ s16 unk_18C; - /* 0x018E */ u8 unk_18E; - /* 0x018F */ u8 unk_18F; - /* 0x0190 */ Vec3f unk_190; - /* 0x019C */ u32 unk_19C; - /* 0x01A0 */ u32 unk_1A0; - /* 0x01A4 */ u32 unk_1A4; - /* 0x01A8 */ s32 unk_1A8; - /* 0x01AC */ s32 unk_1AC; - /* 0x01B0 */ s32 unk_1B0; - /* 0x01B4 */ u8 unk_1B4; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ DmChar05ActionFunc actionFunc; + /* 0x18C */ s16 unk_18C; + /* 0x18E */ u8 unk_18E; + /* 0x18F */ u8 unk_18F; + /* 0x190 */ Vec3f unk_190; + /* 0x19C */ u32 unk_19C; + /* 0x1A0 */ u32 unk_1A0; + /* 0x1A4 */ u32 unk_1A4; + /* 0x1A8 */ s32 unk_1A8; + /* 0x1AC */ s32 unk_1AC; + /* 0x1B0 */ s32 unk_1B0; + /* 0x1B4 */ u8 unk_1B4; } DmChar05; // size = 0x1B8 extern const ActorInit Dm_Char05_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.h b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.h index 5e51fc516..49a026063 100644 --- a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.h +++ b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.h @@ -8,10 +8,10 @@ struct DmChar06; typedef void (*DmChar06ActionFunc)(struct DmChar06*, PlayState*); typedef struct DmChar06 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x14C]; - /* 0x0290 */ DmChar06ActionFunc actionFunc; - /* 0x0294 */ char unk_294[0x10]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x14C]; + /* 0x290 */ DmChar06ActionFunc actionFunc; + /* 0x294 */ char unk_294[0x10]; } DmChar06; // size = 0x2A4 extern const ActorInit Dm_Char06_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.h b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.h index 7633e8918..1718a9fb0 100644 --- a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.h +++ b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.h @@ -8,10 +8,10 @@ struct DmChar08; typedef void (*DmChar08ActionFunc)(struct DmChar08*, PlayState*); typedef struct DmChar08 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; - /* 0x01A0 */ DmChar08ActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0x68]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x5C]; + /* 0x1A0 */ DmChar08ActionFunc actionFunc; + /* 0x1A4 */ char unk_1A4[0x68]; } DmChar08; // size = 0x20C extern const ActorInit Dm_Char08_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.h b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.h index 22e57726e..770c9358c 100644 --- a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.h +++ b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.h @@ -8,10 +8,10 @@ struct DmChar09; typedef void (*DmChar09ActionFunc)(struct DmChar09*, PlayState*); typedef struct DmChar09 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xBC]; - /* 0x0200 */ DmChar09ActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x2C]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0xBC]; + /* 0x200 */ DmChar09ActionFunc actionFunc; + /* 0x204 */ char unk_204[0x2C]; } DmChar09; // size = 0x230 extern const ActorInit Dm_Char09_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c index 2e0aef68b..823aa7fa2 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -62,9 +62,9 @@ s32 func_80C24360(DmGm* this, PlayState* play) { } if (objectIndex2 >= 0) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[objectIndex2].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex2].segment); ret = SkelAnime_Update(&this->skelAnime); - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[objectIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex].segment); } return ret; } @@ -81,10 +81,10 @@ s32 func_80C24428(DmGm* this, PlayState* play, s32 arg2) { } if ((objectIndex2 >= 0) && (arg2 != this->unk_2C8)) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[objectIndex2].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex2].segment); this->unk_2C8 = arg2; ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[objectIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objectIndex].segment); } return ret; } diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h index 74efd4c1e..b7e45a3a1 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h @@ -9,31 +9,31 @@ struct DmGm; typedef void (*DmGmActionFunc)(struct DmGm*, PlayState*); typedef struct DmGm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ DmGmActionFunc actionFunc; - /* 0x018C */ Vec3f unk_18C; - /* 0x018C */ Vec3f unk_194; - /* 0x01A4 */ Vec3s unk_1A4; - /* 0x01A4 */ Vec3s unk_1AA; - /* 0x01B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; - /* 0x022E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; - /* 0x02AC */ s8 unk_2AC; - /* 0x02AD */ s8 unk_2AD; - /* 0x02AE */ u16 unk_2AE; - /* 0x02B0 */ u8 unk_2B0; - /* 0x02B4 */ Actor* unk_2B4; - /* 0x02B8 */ s16 unk_2B8; - /* 0x02BA */ s16 unk_2BA; - /* 0x02BC */ s16 unk_2BC; - /* 0x02BE */ s16 unk_2BE; - /* 0x02C0 */ s16 unk_2C0; - /* 0x02C2 */ s16 unk_2C2; - /* 0x02C4 */ s16 unk_2C4; - /* 0x02C8 */ s32 unk_2C8; - /* 0x02CC */ s32 unk_2CC; - /* 0x02D0 */ s32 unk_2D0; - /* 0x02D4 */ s32 unk_2D4; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ DmGmActionFunc actionFunc; + /* 0x18C */ Vec3f unk_18C; + /* 0x18C */ Vec3f unk_194; + /* 0x1A4 */ Vec3s unk_1A4; + /* 0x1A4 */ Vec3s unk_1AA; + /* 0x1B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; + /* 0x22E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; + /* 0x2AC */ s8 unk_2AC; + /* 0x2AD */ s8 unk_2AD; + /* 0x2AE */ u16 unk_2AE; + /* 0x2B0 */ u8 unk_2B0; + /* 0x2B4 */ Actor* unk_2B4; + /* 0x2B8 */ s16 unk_2B8; + /* 0x2BA */ s16 unk_2BA; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C2 */ s16 unk_2C2; + /* 0x2C4 */ s16 unk_2C4; + /* 0x2C8 */ s32 unk_2C8; + /* 0x2CC */ s32 unk_2CC; + /* 0x2D0 */ s32 unk_2D0; + /* 0x2D4 */ s32 unk_2D4; } DmGm; // size = 0x2D8 extern const ActorInit Dm_Gm_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 32bd6aa39..02d12ee7d 100644 --- a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.h +++ b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.h @@ -8,12 +8,12 @@ struct DmHina; typedef void (*DmHinaActionFunc)(struct DmHina*, PlayState*); typedef struct DmHina { - /* 0x0000 */ Actor actor; - /* 0x0144 */ DmHinaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x10]; - /* 0x0158 */ f32 unk_158; - /* 0x015C */ f32 unk_15C; - /* 0x0160 */ char unk_160[0x24]; + /* 0x000 */ Actor actor; + /* 0x144 */ DmHinaActionFunc actionFunc; + /* 0x148 */ char unk_148[0x10]; + /* 0x158 */ f32 unk_158; + /* 0x15C */ f32 unk_15C; + /* 0x160 */ char unk_160[0x24]; } DmHina; // size = 0x184 extern const ActorInit Dm_Hina_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c index 0ee7b3ed4..4e3915af0 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c @@ -1,7 +1,7 @@ /* * File: z_dm_opstage.c * Overlay: ovl_Dm_Opstage - * Description: Lost Woods cutscene objects + * Description: Lost Woods Cutscene Trees and Floor */ #include "z_dm_opstage.h" @@ -44,14 +44,17 @@ void DmOpstage_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DmOpstage_SetupAction(this, DmOpstage_FollowCutsceneScript); Actor_SetScale(&this->dyna.actor, 0.1f); - if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DM_OPSTAGE_TYPE_FLOOR) { + + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DMOPSTAGE_TYPE_GROUND) { DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(play, &this->dyna, &object_keikoku_demo_Colheader_001C98); + DynaPolyActor_LoadMesh(play, &this->dyna, &gKeikokuDemoFloorColliderHeader); } - if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) > DM_OPSTAGE_TYPE_FLOOR) { - this->pos.x = this->dyna.actor.world.pos.x; - this->pos.y = this->dyna.actor.world.pos.y; - this->pos.z = this->dyna.actor.world.pos.z; + + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) > DMOPSTAGE_TYPE_GROUND) { + // trees move their world pos to map origin/center, then draw at their starting position + this->drawOffset.x = this->dyna.actor.world.pos.x; + this->drawOffset.y = this->dyna.actor.world.pos.y; + this->drawOffset.z = this->dyna.actor.world.pos.z; this->dyna.actor.world.pos.x = 0.0f; this->dyna.actor.world.pos.y = 0.0f; this->dyna.actor.world.pos.z = 0.0f; @@ -61,7 +64,7 @@ void DmOpstage_Init(Actor* thisx, PlayState* play) { void DmOpstage_Destroy(Actor* thisx, PlayState* play) { DmOpstage* this = THIS; - if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DM_OPSTAGE_TYPE_FLOOR) { + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DMOPSTAGE_TYPE_GROUND) { DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } } @@ -69,7 +72,7 @@ void DmOpstage_Destroy(Actor* thisx, PlayState* play) { void DmOpstage_FollowCutsceneScript(DmOpstage* this, PlayState* play) { s32 actionIndex; - if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DM_OPSTAGE_TYPE_FLOOR) { + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DMOPSTAGE_TYPE_GROUND) { if (Cutscene_CheckActorAction(play, 0x73)) { actionIndex = Cutscene_GetActorActionIndex(play, 0x73); if (play->csCtx.actorActions[actionIndex]->action == 2) { @@ -81,9 +84,10 @@ void DmOpstage_FollowCutsceneScript(DmOpstage* this, PlayState* play) { } Cutscene_ActorTranslateAndYaw(&this->dyna.actor, play, actionIndex); } - } else if (Cutscene_CheckActorAction(play, DMOPSTAGE_GET_08(&this->dyna.actor) + 0x74)) { - Cutscene_ActorTranslateAndYaw(&this->dyna.actor, play, - Cutscene_GetActorActionIndex(play, DMOPSTAGE_GET_08(&this->dyna.actor) + 0x74)); + } else if (Cutscene_CheckActorAction(play, DMOPSTAGE_GET_ACTORACTION(&this->dyna.actor) + 0x74)) { + Cutscene_ActorTranslateAndYaw( + &this->dyna.actor, play, + Cutscene_GetActorActionIndex(play, DMOPSTAGE_GET_ACTORACTION(&this->dyna.actor) + 0x74)); } } @@ -92,6 +96,8 @@ void DmOpstage_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); if ((play->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0) && (play->csCtx.frames == 480)) { + // This actor is responsible for playing the fairy sound during the exposition in the intro, + // during the transition to Lost Woods, before Ocarina gets stolen. func_8019F128(NA_SE_EV_NAVY_FLY_REBIRTH); } } @@ -99,31 +105,34 @@ void DmOpstage_Update(Actor* thisx, PlayState* play) { void DmOpstage_Draw(Actor* thisx, PlayState* play) { DmOpstage* this = THIS; - if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) > DM_OPSTAGE_TYPE_FLOOR) { - Matrix_Translate(this->dyna.actor.world.pos.x + this->pos.x, this->dyna.actor.world.pos.y + this->pos.y, - this->dyna.actor.world.pos.z + this->pos.z, MTXMODE_NEW); + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) > DMOPSTAGE_TYPE_GROUND) { + // Assumption: worldPos is being manipulated by cutscene + Matrix_Translate(this->dyna.actor.world.pos.x + this->drawOffset.x, + this->dyna.actor.world.pos.y + this->drawOffset.y, + this->dyna.actor.world.pos.z + this->drawOffset.z, MTXMODE_NEW); Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); } + switch (DMOPSTAGE_GET_TYPE(&this->dyna.actor)) { - case DM_OPSTAGE_TYPE_FLOOR: - Gfx_DrawDListOpa(play, object_keikoku_demo_DL_000978); - Gfx_DrawDListXlu(play, object_keikoku_demo_DL_000970); + case DMOPSTAGE_TYPE_GROUND: + Gfx_DrawDListOpa(play, gKeikokuDemoFloorDL); + Gfx_DrawDListXlu(play, gKeikokuDemoFloorEmptyDL); break; - case DM_OPSTAGE_TYPE_TREE1: - Gfx_DrawDListOpa(play, object_keikoku_demo_DL_002878); - Gfx_DrawDListXlu(play, object_keikoku_demo_DL_002870); + case DMOPSTAGE_TYPE_ROOT_TREE: + Gfx_DrawDListOpa(play, gKeikokuDemoTallTreeWithRootBaseDL); + Gfx_DrawDListXlu(play, gKeikokuDemoTallTreeWithRootBaseEmptyDL); break; - case DM_OPSTAGE_TYPE_TREE2: - Gfx_DrawDListOpa(play, object_keikoku_demo_DL_003068); - Gfx_DrawDListXlu(play, object_keikoku_demo_DL_003060); + case DMOPSTAGE_TYPE_CUT_TREE: + Gfx_DrawDListOpa(play, gKeikokuDemoTallTreeCutDL); + Gfx_DrawDListXlu(play, gKeikokuDemoTallTreeCutEmptyDL); break; - case DM_OPSTAGE_TYPE_TREE3: - Gfx_DrawDListOpa(play, object_keikoku_demo_DL_003728); - Gfx_DrawDListXlu(play, object_keikoku_demo_DL_003720); + case DMOPSTAGE_TYPE_STRAIGHT_TREE: + Gfx_DrawDListOpa(play, gKeikokuDemoTallTreeStraightDL); + Gfx_DrawDListXlu(play, gKeikokuDemoTallTreeStraightEmptyDL); break; } } diff --git a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h index a8f4b0c60..073efa1bf 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h @@ -3,26 +3,27 @@ #include "global.h" -#define DMOPSTAGE_GET_TYPE(thisx) (((thisx)->params & 0xFF)) -#define DMOPSTAGE_GET_08(thisx) (((thisx)->params >> 8) & 0xFF) +#define DMOPSTAGE_GET_TYPE(thisx) ((thisx)->params & 0xFF) +#define DMOPSTAGE_GET_ACTORACTION(thisx) (((thisx)->params >> 8) & 0xFF) struct DmOpstage; typedef void (*DmOpstageActionFunc)(struct DmOpstage*, PlayState*); + +typedef enum { + /* 0 */ DMOPSTAGE_TYPE_GROUND, + /* 1 */ DMOPSTAGE_TYPE_ROOT_TREE, + /* 2 */ DMOPSTAGE_TYPE_CUT_TREE, + /* 3 */ DMOPSTAGE_TYPE_STRAIGHT_TREE, +} DmOpStageTypes; + typedef struct DmOpstage { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ UNK_TYPE1 pad_15C[0x44]; /* 0x1A0 */ DmOpstageActionFunc actionFunc; - /* 0x1A4 */ Vec3f pos; + /* 0x1A4 */ Vec3f drawOffset; } DmOpstage; // size = 0x1B0 -typedef enum { - /* 0 */ DM_OPSTAGE_TYPE_FLOOR, - /* 1 */ DM_OPSTAGE_TYPE_TREE1, - /* 2 */ DM_OPSTAGE_TYPE_TREE2, - /* 3 */ DM_OPSTAGE_TYPE_TREE3, -} DmOpStageTypes; - extern const ActorInit Dm_Opstage_InitVars; #endif // Z_DM_OPSTAGE_H 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 8ec435a61..caa2d02b1 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1815,7 +1815,7 @@ void DmStk_Update(Actor* thisx, PlayState* play) { // This code is responsible for making in-game time pass while using the telescope in the Astral Observatory. // Skull Kid is always loaded in the scene, even if he isn't visible, hence why time always passes. if ((play->actorCtx.unk5 & 2) && (play->msgCtx.msgMode != 0) && (play->msgCtx.currentTextId == 0x5E6) && - !FrameAdvance_IsEnabled(&play->state) && (play->sceneLoadFlag == 0) && + !FrameAdvance_IsEnabled(&play->state) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (ActorCutscene_GetCurrentIndex() == -1) && (play->csCtx.state == 0)) { gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); if (REG(15) != 0) { diff --git a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h index 6d568cd50..fda9397c7 100644 --- a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h +++ b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h @@ -8,10 +8,10 @@ struct DmTag; typedef void (*DmTagActionFunc)(struct DmTag*, PlayState*); typedef struct DmTag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ DmTagActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x20]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ DmTagActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x20]; } DmTag; // size = 0x1AC extern const ActorInit Dm_Tag_InitVars; 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 4ec0706ec..7edb7af4d 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -129,8 +129,8 @@ void DoorAna_WaitOpen(DoorAna* this, PlayState* play) { s32 grottoType = DOORANA_GET_TYPE(&this->actor); if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.001f)) { - if (this->actor.targetMode != 0 && play->sceneLoadFlag == 0 && play->unk_18B4A == 0 && - (player->stateFlags1 & 0x80000000) && player->unk_AE7 == 0) { + if ((this->actor.targetMode != 0) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && + (play->transitionMode == TRANS_MODE_OFF) && (player->stateFlags1 & 0x80000000) && (player->unk_AE7 == 0)) { if (grottoType == DOORANA_TYPE_VISIBLE_SCENE_EXIT) { s32 exitIndex = DOORANA_GET_EXIT_INDEX(&this->actor); diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 61eb057a9..0c99056b4 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -288,7 +288,7 @@ f32 func_808A0D90(PlayState* play, DoorShutter* this, f32 arg2, f32 arg3, f32 ar s32 func_808A0E28(DoorShutter* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (!Player_InCsMode(&play->state)) { + if (!Player_InCsMode(play)) { ShutterInfo* shutterInfo = &D_808A21B0[this->unk_164]; f32 temp_f0 = func_808A0D90(play, this, 0.0f, shutterInfo->unk_0A, shutterInfo->unk_0B); @@ -405,7 +405,7 @@ void func_808A1288(DoorShutter* this, PlayState* play) { this->unk_164 = sp38; this->unk_168 = 0.0f; - func_800DFFAC(play->cameraPtrs[CAM_ID_MAIN], &this->actor, player->unk_3BA, this->unk_168, 12, sp34, 10); + Camera_ChangeDoorCam(play->cameraPtrs[CAM_ID_MAIN], &this->actor, player->unk_3BA, this->unk_168, 12, sp34, 10); } } @@ -569,7 +569,7 @@ void func_808A1884(DoorShutter* this, PlayState* play) { if (DoorShutter_SetupDoor(this, play) && !(player->stateFlags1 & 0x800)) { DoorShutter_SetupAction(this, func_808A1C50); if (ActorCutscene_GetCurrentIndex() == 0x7D) { - func_801226E0(play, ((void)0, gSaveContext.respawn[RESTART_MODE_DOWN].data)); + func_801226E0(play, ((void)0, gSaveContext.respawn[RESPAWN_MODE_DOWN].data)); player->unk_A86 = -1; func_800B7298(play, NULL, 0x73); } @@ -608,7 +608,7 @@ void func_808A1B48(DoorShutter* this, PlayState* play) { Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 45.0f, 10, 8.0f, 500, 10, 0); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BIGWALL_BOUND); - quake = Quake_Add(Play_GetCamera(play, 0), 3); + quake = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), 3); Quake_SetSpeed(quake, -32536); Quake_SetQuakeValues(quake, 2, 0, 0, 0); Quake_SetCountdown(quake, 10); @@ -643,7 +643,7 @@ s32 func_808A1D68(DoorShutter* this, PlayState* play) { s32 temp_a0; s32 temp_a1; - if (Player_InCsMode(&play->state)) { + if (Player_InCsMode(play)) { return true; } 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 1d9c72ccb..43c7143c3 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c @@ -246,7 +246,7 @@ f32 DoorSpiral_GetDistFromPlayer(PlayState* play, DoorSpiral* this, f32 yOffset, s32 DoorSpiral_PlayerShouldClimb(DoorSpiral* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (!Player_InCsMode(&play->state)) { + if (!Player_InCsMode(play)) { SpiralInfo* spiralInfo = &sSpiralInfo[this->spiralType]; f32 dist = DoorSpiral_GetDistFromPlayer(play, 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 a848f878e..8c28cd1b5 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -356,7 +356,7 @@ void func_808B93A0(DoorWarp1* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); - if (Message_GetState(&play->msgCtx) == 4 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { func_801477B4(play); if (play->msgCtx.choiceIndex == 0) { func_8019F208(); @@ -410,8 +410,8 @@ void func_808B958C(DoorWarp1* this, PlayState* play) { this->unk_1D0++; if ((this->unk_1D0 > 120) && (gSaveContext.nextCutsceneIndex == 0xFFEF)) { func_808BA10C(this, play); - play->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } Math_SmoothStepToF(&this->unk_1A8, 6.0f, 0.2f, 0.02f, 0.01f); @@ -486,7 +486,7 @@ void func_808B98A8(DoorWarp1* this, PlayState* play) { if (DOORWARP1_GET_FF00_1(&this->dyna.actor) != 0xFF) { play->nextEntranceIndex = play->setupExitList[DOORWARP1_GET_FF00_3(&this->dyna.actor)]; Scene_SetExitFade(play); - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; } else { func_80169FDC(&play->state); } @@ -579,7 +579,7 @@ void func_808B9CE8(DoorWarp1* this, PlayState* play) { } void func_808B9E94(DoorWarp1* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 2) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { this->unk_1CE = 110; DoorWarp1_SetupAction(this, func_808B9ED8); } @@ -703,49 +703,49 @@ void func_808BA10C(DoorWarp1* this, PlayState* play) { gSaveContext.nextCutsceneIndex = phi_v0_3 + 0xFFF0; } - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } else { switch (phi_v0_2) { case 0: if (gSaveContext.save.weekEventReg[20] & 2) { gSaveContext.save.weekEventReg[7] |= 0x80; play->nextEntranceIndex = 0x3010; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } else { play->nextEntranceIndex = 0x8600; gSaveContext.nextCutsceneIndex = 0xFFF0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } break; case 1: gSaveContext.save.weekEventReg[33] |= 0x80; play->nextEntranceIndex = 0xAE70; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; break; case 3: if (gSaveContext.save.weekEventReg[55] & 0x80) { play->nextEntranceIndex = 0x6A90; gSaveContext.nextCutsceneIndex = 0xFFF0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } else { gSaveContext.save.weekEventReg[55] |= 0x80; play->nextEntranceIndex = 0x6A80; gSaveContext.nextCutsceneIndex = 0xFFF0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } break; @@ -753,9 +753,9 @@ void func_808BA10C(DoorWarp1* this, PlayState* play) { gSaveContext.save.weekEventReg[52] |= 0x20; play->nextEntranceIndex = 0x20F0; gSaveContext.nextCutsceneIndex = 0xFFF2; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; break; } } @@ -765,7 +765,7 @@ void func_808BA10C(DoorWarp1* this, PlayState* play) { } play->nextEntranceIndex = play->setupExitList[DOORWARP1_GET_FF00_3(&this->dyna.actor)]; Scene_SetExitFade(play); - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; } else { func_80169FDC(&play->state); } 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 bc66c2480..c57f610a0 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h @@ -24,36 +24,36 @@ enum { }; typedef struct DoorWarp1 { - /* 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 */ 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 */ u8 unk_208; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ DmHina* unk_1A0; + /* 0x1A4 */ f32 unk_1A4; + /* 0x1A8 */ f32 unk_1A8; + /* 0x1AC */ f32 unk_1AC; + /* 0x1B0 */ f32 unk_1B0; + /* 0x1B4 */ f32 unk_1B4; + /* 0x1B8 */ f32 unk_1B8; + /* 0x1BC */ f32 unk_1BC; + /* 0x1C0 */ f32 unk_1C0; + /* 0x1C4 */ s16 unk_1C4; + /* 0x1C6 */ s16 unk_1C6; + /* 0x1C8 */ s16 unk_1C8; + /* 0x1CA */ s16 unk_1CA; + /* 0x1CC */ s16 unk_1CC; + /* 0x1CE */ s16 unk_1CE; + /* 0x1D0 */ u16 unk_1D0; + /* 0x1D2 */ s8 unk_1D2; + /* 0x1D3 */ u8 unk_1D3; + /* 0x1D4 */ u8 unk_1D4; + /* 0x1D8 */ DoorWarp1ActionFunc actionFunc; + /* 0x1DC */ LightNode* unk_1DC; + /* 0x1E0 */ LightInfo unk_1E0; + /* 0x1F0 */ LightNode* unk_1F0; + /* 0x1F4 */ LightInfo unk_1F4; + /* 0x202 */ u8 unk_202; + /* 0x203 */ u8 unk_203; + /* 0x204 */ f32 unk_204; + /* 0x208 */ u8 unk_208; } DoorWarp1; // size = 0x20C extern const ActorInit Door_Warp1_InitVars; diff --git a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c index 127a24ddf..0f5245617 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c @@ -13,8 +13,11 @@ void EffChange_Init(Actor* thisx, PlayState* play); void EffChange_Destroy(Actor* thisx, PlayState* play); void EffChange_Update(Actor* thisx, PlayState* play); +void EffChange_Draw(Actor* thisx, PlayState* play); + +void EffChange_SetColors(EffChange* this, s32 arg1); +void func_80A4C5CC(EffChange* this, PlayState* play); -#if 0 const ActorInit Eff_Change_InitVars = { ACTOR_EFF_CHANGE, ACTORCAT_ITEMACTION, @@ -27,16 +30,118 @@ const ActorInit Eff_Change_InitVars = { (ActorFunc)NULL, }; -#endif +static u8 D_80A4C920[] = { + // prim r g b env r g b + 255, 255, 170, 0, 100, 0, // COLOR_0 + 255, 255, 170, 200, 0, 0, // COLOR_1 + 170, 255, 255, 0, 100, 255, // COLOR_2 + 255, 255, 170, 200, 150, 0, // COLOR_3 + 255, 255, 170, 0, 100, 0, // COLOR_4 + 255, 255, 170, 0, 100, 0, // COLOR_5 + 255, 255, 170, 0, 100, 0, // COLOR_6 + 255, 255, 170, 0, 100, 0 // COLOR_7 +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/EffChange_Init.s") +void EffChange_Init(Actor* thisx, PlayState* play) { + EffChange* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/EffChange_Destroy.s") + this->actionFunc = func_80A4C5CC; + this->actor.draw = EffChange_Draw; + EffChange_SetColors(this, EFFCHANGE_GET_COLORS(thisx)); + Actor_SetScale(&this->actor, 0.075f); + this->primColors[3] = 0; + func_80183430(&this->skeletonInfo, gameplay_keep_Blob_02900C, gameplay_keep_Blob_0281DC, this->jointTable, + this->morphTable, NULL); + func_801834A8(&this->skeletonInfo, gameplay_keep_Blob_0281DC); + this->step = 0; + this->actor.shape.rot.y = 0; + this->skeletonInfo.frameCtrl.unk_C = (2.0f / 3.0f); + ActorCutscene_SetIntentToPlay(0x7B); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/func_80A4C578.s") +void EffChange_Destroy(Actor* thisx, PlayState* play) { + EffChange* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/func_80A4C5CC.s") + func_8018349C(&this->skeletonInfo); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/EffChange_Update.s") +void EffChange_SetColors(EffChange* this, s32 arg1) { + arg1 *= 6; + this->primColors[0] = D_80A4C920[arg1]; + this->primColors[1] = D_80A4C920[arg1 + 1]; + this->primColors[2] = D_80A4C920[arg1 + 2]; + this->envColors[0] = D_80A4C920[arg1 + 3]; + this->envColors[1] = D_80A4C920[arg1 + 4]; + this->envColors[2] = D_80A4C920[arg1 + 5]; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Change/func_80A4C7B0.s") +void func_80A4C5CC(EffChange* this, PlayState* play) { + f32 phi_fv0; + + if (func_80183DE0(&this->skeletonInfo)) { + Actor_MarkForDeath(&this->actor); + ActorCutscene_Stop(0x7B); + func_800FD2B4(play, 0.0f, 850.0f, 0.2f, 0.0f); + } else { + this->step++; + if (this->skeletonInfo.frameCtrl.unk_10 < 20.0f) { + if ((this->primColors[3]) < 242) { + this->primColors[3] += 13; + } else { + this->primColors[3] = 255; + } + } else if (this->skeletonInfo.frameCtrl.unk_10 > 70.0f) { + if ((this->primColors[3]) >= 14) { + this->primColors[3] -= 13; + } else { + this->primColors[3] = 0; + } + } else { + this->primColors[3] = 255; + } + + phi_fv0 = this->primColors[3] * (1.0f / 255.0f); + if (phi_fv0 > 1.0f) { + phi_fv0 = 1.0f; + } else if (phi_fv0 < 0.0f) { + phi_fv0 = 0.0f; + } + func_800FD2B4(play, phi_fv0, 850.0f, 0.2f, 0.0f); + if (ActorCutscene_GetCurrentIndex() != 0x7B) { + if (ActorCutscene_GetCanPlayNext(0x7B)) { + ActorCutscene_Start(0x7B, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(0x7B); + } + } + } +} + +void EffChange_Update(Actor* thisx, PlayState* play) { + EffChange* this = THIS; + + this->actionFunc(this, play); +} + +void EffChange_Draw(Actor* thisx, PlayState* play) { + s32 pad; + Mtx* mtx; + EffChange* this = THIS; + + AnimatedMat_DrawStepXlu(play, Lib_SegmentedToVirtual(&gameplay_keep_Matanimheader_028FEC), this->step); + mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx))); + + if (mtx != NULL) { + func_8012C2DC(play->state.gfxCtx); + Matrix_RotateYS((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000), MTXMODE_APPLY); + + OPEN_DISPS(play->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, this->primColors[0], this->primColors[1], this->primColors[2], + this->primColors[3]); + gDPSetEnvColor(POLY_XLU_DISP++, this->envColors[0], this->envColors[1], this->envColors[2], 255); + func_8018450C(play, &this->skeletonInfo, mtx, NULL, NULL, &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Eff_Change/z_eff_change.h b/src/overlays/actors/ovl_Eff_Change/z_eff_change.h index 9f45088a2..aed7e534a 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.h +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.h @@ -2,15 +2,23 @@ #define Z_EFF_CHANGE_H #include "global.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define EFFCHANGE_GET_COLORS(thisx) ((thisx)->params & 7) struct EffChange; typedef void (*EffChangeActionFunc)(struct EffChange*, PlayState*); typedef struct EffChange { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x84]; - /* 0x01C8 */ EffChangeActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkeletonInfo skeletonInfo; + /* 0x174 */ Vec3s jointTable[PINK_DEKU_FLOWER_LIMB_BACK_RIGHT_PETAL]; + /* 0x198 */ Vec3s morphTable[PINK_DEKU_FLOWER_LIMB_BACK_RIGHT_PETAL]; + /* 0x1BC */ s16 step; + /* 0x1BE */ u8 primColors[4]; + /* 0x1C2 */ u8 envColors[4]; + /* 0x1C8 */ EffChangeActionFunc actionFunc; } EffChange; // size = 0x1CC extern const ActorInit Eff_Change_InitVars; diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h index d214453b2..ec864ea4d 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h @@ -8,26 +8,26 @@ struct EffDust; typedef void (*EffDustActionFunc)(struct EffDust*, PlayState*); typedef struct EffDust { - /* 0x0000 */ Actor actor; - /* 0x0144 */ f32 distanceTraveled[64]; // For each particle. Normalized. From 0.0f to 1.0f - /* 0x0244 */ Vec3f initialPositions[64]; // Array of position for each dust particle. - /* 0x0544 */ u8 index; - /* 0x0545 */ u8 life; // Only considered if actor.params is 2, 3 or 4. - /* 0x0548 */ f32 dx; // Normalized. 0.0f to 1.0f - /* 0x054C */ f32 dy; // Normalized. 0.0f to 1.0f - /* 0x0550 */ f32 dz; // Normalized. 0.0f to 1.0f - /* 0x0554 */ f32 scalingFactor; - /* 0x0558 */ EffDustActionFunc actionFunc; - /* 0x055C */ ActorFunc drawFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ f32 distanceTraveled[64]; // For each particle. Normalized. From 0.0f to 1.0f + /* 0x244 */ Vec3f initialPositions[64]; // Array of position for each dust particle. + /* 0x544 */ u8 index; + /* 0x545 */ u8 life; // Only considered if actor.params is 2, 3 or 4. + /* 0x548 */ f32 dx; // Normalized. 0.0f to 1.0f + /* 0x54C */ f32 dy; // Normalized. 0.0f to 1.0f + /* 0x550 */ f32 dz; // Normalized. 0.0f to 1.0f + /* 0x554 */ f32 scalingFactor; + /* 0x558 */ EffDustActionFunc actionFunc; + /* 0x55C */ ActorFunc drawFunc; } EffDust; // size = 0x560 typedef enum { - /* 0x00 */ EFF_DUST_TYPE_0, - /* 0x01 */ EFF_DUST_TYPE_1, - /* 0x02 */ EFF_DUST_TYPE_2, - /* 0x03 */ EFF_DUST_TYPE_3, - /* 0x04 */ EFF_DUST_TYPE_4, - /* 0x05 */ EFF_DUST_TYPE_5 + /* 0x0 */ EFF_DUST_TYPE_0, + /* 0x1 */ EFF_DUST_TYPE_1, + /* 0x2 */ EFF_DUST_TYPE_2, + /* 0x3 */ EFF_DUST_TYPE_3, + /* 0x4 */ EFF_DUST_TYPE_4, + /* 0x5 */ EFF_DUST_TYPE_5 } EffDustType; extern const ActorInit Eff_Dust_InitVars; diff --git a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c index f644ad9dc..83842569f 100644 --- a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c +++ b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c @@ -5,6 +5,7 @@ */ #include "z_eff_kamejima_wave.h" +#include "objects/object_kamejima/object_kamejima.h" #define FLAGS (ACTOR_FLAG_10) @@ -13,8 +14,14 @@ void EffKamejimaWave_Init(Actor* thisx, PlayState* play); void EffKamejimaWave_Destroy(Actor* thisx, PlayState* play); void EffKamejimaWave_Update(Actor* thisx, PlayState* play); +void EffKamejimaWave_Draw(Actor* thisx, PlayState* play); + +void func_80BCEC6C(EffKamejimaWave* this, PlayState* play); +void func_80BCEDE0(EffKamejimaWave* this, PlayState* play); +void func_80BCEBC0(EffKamejimaWave* this, PlayState* play); +void func_80BCED34(EffKamejimaWave* this, PlayState* play); +void EffKamejimaWave_SetVtxAlpha(u8 alpha); -#if 0 const ActorInit Eff_Kamejima_Wave_InitVars = { ACTOR_EFF_KAMEJIMA_WAVE, ACTORCAT_ITEMACTION, @@ -27,26 +34,138 @@ const ActorInit Eff_Kamejima_Wave_InitVars = { (ActorFunc)NULL, }; -#endif +static Color_RGBA8 sPrimColors[] = { + { 255, 240, 255, 255 }, { 255, 255, 255, 255 }, { 255, 240, 230, 255 }, { 140, 170, 220, 255 } +}; +static Color_RGBA8 sEnvColors[] = { + { 130, 80, 90, 255 }, { 90, 120, 130, 255 }, { 130, 80, 70, 255 }, { 40, 60, 110, 255 } +}; -extern UNK_TYPE D_06000000; -extern UNK_TYPE D_06000140; -extern UNK_TYPE D_06001AF0; +s16 sVtxAlpha; +AnimatedMaterial* D_80BCF1C4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/EffKamejimaWave_Init.s") +void EffKamejimaWave_Init(Actor* thisx, PlayState* play) { + EffKamejimaWave* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/EffKamejimaWave_Destroy.s") + Actor_SetScale(&this->actor, 0.2f); + this->actor.scale.y = 0.0f; + if (EFFKAMEJIMAWAVE_GET_F(thisx) == EFFKAMEJIMAWAVE_PARAMS_1) { + this->actionFunc = func_80BCEDE0; + sVtxAlpha = 255; + } else { + this->actionFunc = func_80BCEC6C; + sVtxAlpha = 255; + } + D_80BCF1C4 = Lib_SegmentedToVirtual(object_kamejima_Matanimheader_001AF0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/func_80BCEBC0.s") +void EffKamejimaWave_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/func_80BCEC6C.s") +void func_80BCEBC0(EffKamejimaWave* this, PlayState* play) { + this->actor.scale.y += this->scaleOffset; + this->scaleOffset -= 0.003f; + this->actor.shape.rot.x += 0x64; + if (this->scaleOffset < 0.0f) { + this->actor.scale.x += 0.003f; + } + if (this->scaleOffset < -0.01f) { + this->scaleOffset = -0.01f; + } + if (this->actor.scale.y < 0.0f) { + this->actor.scale.y = 0.0f; + this->actor.scale.x = 0.2f; + this->actionFunc = func_80BCEC6C; + this->actor.draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/func_80BCED34.s") +void func_80BCEC6C(EffKamejimaWave* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 0x1E0)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 0x1E0)); + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x1E0)]->action == 2) { + this->scaleOffset = 0.05f; + this->actionFunc = func_80BCEBC0; + this->actor.draw = EffKamejimaWave_Draw; + sVtxAlpha = 255; + this->actor.shape.rot.x = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TORTOISE_WAKE_UP); + } + } else { + this->actor.draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/func_80BCEDE0.s") +void func_80BCED34(EffKamejimaWave* this, PlayState* play) { + this->actor.scale.y += this->scaleOffset; + this->scaleOffset -= 0.002f; + this->actor.shape.rot.x += 0x8C; + if (this->scaleOffset < 0.0f) { + this->actor.scale.x += 0.002f; + } + if (this->scaleOffset < 0.0f) { + this->scaleOffset = 0; + } + if (sVtxAlpha >= 4) { + sVtxAlpha -= 4; + } else { + this->actor.scale.y = 0.0f; + this->actionFunc = func_80BCEDE0; + this->actor.draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/EffKamejimaWave_Update.s") +void func_80BCEDE0(EffKamejimaWave* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 0x1F6)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 0x1F6)); + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x1F6)]->action == 2) { + this->scaleOffset = 0.03f; + this->actor.scale.x = 0.35f; + this->actionFunc = func_80BCED34; + this->actor.draw = EffKamejimaWave_Draw; + this->actor.shape.rot.x = 0; + } + } else { + this->actor.draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/func_80BCEEBC.s") +void EffKamejimaWave_Update(Actor* thisx, PlayState* play) { + EffKamejimaWave* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Kamejima_Wave/func_80BCEF0C.s") + this->actionFunc(this, play); +} + +void EffKamejimaWave_SetVtxAlpha(u8 alpha) { + Vtx* vtx = Lib_SegmentedToVirtual(&object_kamejima_Vtx_000000); + + vtx[2].v.cn[3] = alpha; + vtx[6].v.cn[3] = alpha; + vtx[8].v.cn[3] = alpha; + vtx[9].v.cn[3] = alpha; + vtx[12].v.cn[3] = alpha; + vtx[16].v.cn[3] = alpha; + vtx[18].v.cn[3] = alpha; + vtx[19].v.cn[3] = alpha; +} + +void EffKamejimaWave_Draw(Actor* thisx, PlayState* play) { + Color_RGBA8 primColor; + Color_RGBA8 envColor; + + func_800FE7A8(sPrimColors, &primColor); + func_800FE7A8(sEnvColors, &envColor); + EffKamejimaWave_SetVtxAlpha(sVtxAlpha); + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + Matrix_Scale(6.0f, 5.0f, 5.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + AnimatedMat_Draw(play, D_80BCF1C4); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, primColor.r, primColor.g, primColor.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, envColor.r, envColor.g, envColor.b, 255); + gSPDisplayList(POLY_XLU_DISP++, object_kamejima_DL_000140); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.h b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.h index 93fb666b3..9b4713034 100644 --- a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.h +++ b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.h @@ -3,16 +3,24 @@ #include "global.h" +#define EFFKAMEJIMAWAVE_GET_F(thisx) ((thisx)->params & 0xF) + struct EffKamejimaWave; typedef void (*EffKamejimaWaveActionFunc)(struct EffKamejimaWave*, PlayState*); typedef struct EffKamejimaWave { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8]; - /* 0x014C */ EffKamejimaWaveActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ f32 scaleOffset; + /* 0x148 */ UNK_TYPE1 pad148[4]; + /* 0x14C */ EffKamejimaWaveActionFunc actionFunc; } EffKamejimaWave; // size = 0x150 +typedef enum params { + /* 0x0 */ EFFKAMEJIMAWAVE_PARAMS_0, + /* 0x1 */ EFFKAMEJIMAWAVE_PARAMS_1 +} EffKamejimaWaveParams; + extern const ActorInit Eff_Kamejima_Wave_InitVars; #endif // Z_EFF_KAMEJIMA_WAVE_H diff --git a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c index c700aa220..773e881ed 100644 --- a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c +++ b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c @@ -5,12 +5,13 @@ */ #include "z_eff_lastday.h" +#include "objects/object_lastday/object_lastday.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffLastday*)thisx) -void EffLastday_Init(Actor* thisx, PlayState* play); +void EffLastday_Init(Actor* thisx, PlayState* play2); void EffLastday_Destroy(Actor* thisx, PlayState* play); void EffLastday_Update(Actor* thisx, PlayState* play); void EffLastday_Draw(Actor* thisx, PlayState* play); @@ -20,7 +21,13 @@ void func_80BEBDF8(EffLastday* this, PlayState* play); void func_80BEBEB8(EffLastday* this, PlayState* play); void func_80BEBF78(EffLastday* this, PlayState* play); -#if 0 +typedef enum EffLastDayAction { + /* 0x0 */ EFFLASTDAY_ACTION_NONE, + /* 0x1 */ EFFLASTDAY_ACTION_1, + /* 0x2 */ EFFLASTDAY_ACTION_2, + /* 0x3 */ EFFLASTDAY_ACTION_3 +} EffLastDayAction; + const ActorInit Eff_Lastday_InitVars = { ACTOR_EFF_LASTDAY, ACTORCAT_ITEMACTION, @@ -33,25 +40,216 @@ const ActorInit Eff_Lastday_InitVars = { (ActorFunc)EffLastday_Draw, }; -#endif +void EffLastday_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EffLastday* this = THIS; -extern UNK_TYPE D_06000000; -extern UNK_TYPE D_06000510; + Actor_SetScale(&this->actor, 0.1f); + switch (EFFLASTDAY_GET_F(&this->actor)) { + case EFFLASTDAY_PARAMS_1: + this->dList = object_lastday_DL_000510; + this->matAnim = Lib_SegmentedToVirtual(object_lastday_Matanimheader_000608); + this->csActionCmd = 0x1FC; + this->actionFunc = func_80BEBDF8; + Actor_SetScale(&this->actor, 1.0f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/EffLastday_Init.s") + case EFFLASTDAY_PARAMS_2: + this->dList = object_lastday_DL_000210; + this->matAnim = Lib_SegmentedToVirtual(object_lastday_Matanimheader_000308); + this->csActionCmd = 0x1FD; + this->actionFunc = func_80BEBEB8; + Actor_SetScale(&this->actor, 0.5f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/EffLastday_Destroy.s") + case EFFLASTDAY_PARAMS_3: + this->dList = object_lastday_DL_000060; + this->matAnim = Lib_SegmentedToVirtual(object_lastday_Matanimheader_000148); + this->csActionCmd = 0x1FE; + this->actionFunc = func_80BEBF78; + Actor_SetScale(&this->actor, 0.2f); + this->actor.home.rot.z = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/func_80BEBD0C.s") + default: + this->dList = object_lastday_DL_000370; + this->matAnim = Lib_SegmentedToVirtual(object_lastday_Matanimheader_000448); + this->csActionCmd = 0x1FB; + this->actionFunc = func_80BEBD0C; + Actor_SetScale(&this->actor, 1.0f); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EFF_LASTDAY, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, + EFFLASTDAY_PARAMS_1); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EFF_LASTDAY, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, + EFFLASTDAY_PARAMS_2); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EFF_LASTDAY, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, + EFFLASTDAY_PARAMS_3); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/func_80BEBDF8.s") +void EffLastday_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/func_80BEBEB8.s") +void func_80BEBD0C(EffLastday* this, PlayState* play) { + u16 csAction; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/func_80BEBF78.s") + if ((Cutscene_CheckActorAction(play, this->csActionCmd))) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionCmd)); + csAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionCmd)]->action; + switch (csAction) { + default: + this->actor.draw = NULL; + this->alpha = 0; + this->step = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/EffLastday_Update.s") + case EFFLASTDAY_ACTION_2: + this->actor.draw = NULL; + this->actor.draw = EffLastday_Draw; + if (this->alpha < 255) { + this->alpha += 10; + } + if (this->alpha > 255) { + this->alpha = 255; + } + this->step++; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/func_80BEC0A4.s") + case EFFLASTDAY_ACTION_3: + this->actor.draw = EffLastday_Draw; + break; + } + } else { + this->actor.draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Lastday/EffLastday_Draw.s") +void func_80BEBDF8(EffLastday* this, PlayState* play) { + u16 csAction; + + if (Cutscene_CheckActorAction(play, this->csActionCmd)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionCmd)); + csAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionCmd)]->action; + switch (csAction) { + default: + this->actor.draw = NULL; + this->step = 0; + break; + + case EFFLASTDAY_ACTION_2: + this->actor.draw = EffLastday_Draw; + this->step++; + break; + + case EFFLASTDAY_ACTION_3: + this->actor.draw = EffLastday_Draw; + break; + } + } else { + this->actor.draw = NULL; + } +} + +void func_80BEBEB8(EffLastday* this, PlayState* play) { + u16 csAction; + + if (Cutscene_CheckActorAction(play, this->csActionCmd)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionCmd)); + csAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionCmd)]->action; + switch (csAction) { + default: + this->actor.draw = NULL; + this->step = 0; + break; + + case EFFLASTDAY_ACTION_2: + this->actor.draw = EffLastday_Draw; + this->step++; + break; + + case EFFLASTDAY_ACTION_3: + this->actor.draw = EffLastday_Draw; + break; + } + } else { + this->actor.draw = NULL; + } +} + +void func_80BEBF78(EffLastday* this, PlayState* play) { + u16 csAction; + + if (Cutscene_CheckActorAction(play, this->csActionCmd)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionCmd)); + csAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionCmd)]->action; + switch (csAction) { + default: + this->actor.draw = NULL; + this->alpha = 0; + this->step = 0; + break; + + case EFFLASTDAY_ACTION_2: + if (!this->actor.home.rot.z) { + this->actor.home.rot.z = true; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_COMING_FIRE); + } + this->actor.draw = EffLastday_Draw; + if (this->alpha < 255) { + this->alpha += 5; + } + if (this->alpha > 255) { + this->alpha = 255; + } + this->step++; + break; + + case EFFLASTDAY_ACTION_3: + + this->actor.draw = EffLastday_Draw; + break; + } + } else { + this->actor.draw = NULL; + } +} + +void EffLastday_Update(Actor* thisx, PlayState* play) { + EffLastday* this = THIS; + + this->actionFunc(this, play); +} + +void EffLastday_SetVtxAlpha(s16 alpha) { + Vtx* vtx = Lib_SegmentedToVirtual(object_lastday_Vtx_000000); + + vtx[0].v.cn[3] = alpha; + vtx[3].v.cn[3] = alpha; + vtx[4].v.cn[3] = alpha; + vtx[5].v.cn[3] = alpha; +} + +void EffLastday_Draw(Actor* thisx, PlayState* play) { + EffLastday* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + switch (EFFLASTDAY_GET_F(thisx)) { + case EFFLASTDAY_PARAMS_1: + case EFFLASTDAY_PARAMS_2: + break; + case EFFLASTDAY_PARAMS_3: + EffLastday_SetVtxAlpha(this->alpha); + break; + default: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, this->alpha); + break; + } + AnimatedMat_DrawAlphaStep(play, this->matAnim, 1.0f, this->step); + Gfx_DrawDListXlu(play, this->dList); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.h b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.h index 175ac5a20..d1f81a184 100644 --- a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.h +++ b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.h @@ -3,16 +3,29 @@ #include "global.h" +#define EFFLASTDAY_GET_F(thisx) ((thisx)->params & 0xF) + struct EffLastday; typedef void (*EffLastdayActionFunc)(struct EffLastday*, PlayState*); typedef struct EffLastday { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x10]; - /* 0x0154 */ EffLastdayActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ Gfx* dList; + /* 0x148 */ AnimatedMaterial* matAnim; + /* 0x14C */ s16 step; + /* 0x14E */ s16 alpha; + /* 0x150 */ s16 csActionCmd; + /* 0x154 */ EffLastdayActionFunc actionFunc; } EffLastday; // size = 0x158 +typedef enum EffLastDayParams { + /* 0x0 */ EFFLASTDAY_PARAMS_0, + /* 0x1 */ EFFLASTDAY_PARAMS_1, + /* 0x2 */ EFFLASTDAY_PARAMS_2, + /* 0x3 */ EFFLASTDAY_PARAMS_3 +} EffLastDayParams; + extern const ActorInit Eff_Lastday_InitVars; #endif // Z_EFF_LASTDAY_H diff --git a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.h b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.h index 3df7fe224..9c8d5946e 100644 --- a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.h +++ b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.h @@ -8,9 +8,9 @@ struct EffStk; typedef void (*EffStkActionFunc)(struct EffStk*, PlayState*); typedef struct EffStk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8]; - /* 0x014C */ EffStkActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x8]; + /* 0x14C */ EffStkActionFunc actionFunc; } EffStk; // size = 0x150 extern const ActorInit Eff_Stk_InitVars; diff --git a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c index 8c365167d..b566e5c62 100644 --- a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c +++ b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c @@ -5,6 +5,7 @@ */ #include "z_eff_zoraband.h" +#include "objects/object_zoraband/object_zoraband.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -13,11 +14,10 @@ void EffZoraband_Init(Actor* thisx, PlayState* play); void EffZoraband_Destroy(Actor* thisx, PlayState* play); void EffZoraband_Update(Actor* thisx, PlayState* play); -void EffZoraband_Draw(Actor* thisx, PlayState* play); +void EffZoraband_Draw(Actor* thisx, PlayState* play2); -void func_80C07790(EffZoraband* this, PlayState* play); +void EffZoraband_MikauFadeOut(EffZoraband* this, PlayState* play); -#if 0 const ActorInit Eff_Zoraband_InitVars = { ACTOR_EFF_ZORABAND, ACTORCAT_ITEMACTION, @@ -30,16 +30,71 @@ const ActorInit Eff_Zoraband_InitVars = { (ActorFunc)EffZoraband_Draw, }; -#endif +void EffZoraband_Init(Actor* thisx, PlayState* play) { + EffZoraband* this = THIS; -extern UNK_TYPE D_06000F38; + Actor_SetScale(&this->actor, 1.0f); + this->actionFunc = EffZoraband_MikauFadeOut; + this->alpha = 0; + this->actor.shape.rot.z = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Zoraband/EffZoraband_Init.s") +void EffZoraband_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Zoraband/EffZoraband_Destroy.s") +void EffZoraband_MikauFadeOut(EffZoraband* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 0x20F)) { + if ((EFFZORABAND_GET_F(&this->actor) + 2) == + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x20F)]->action) { + this->stateFlags |= 2; + } + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x20F)]->action == 7) { + this->actor.draw = NULL; + } else { + this->actor.draw = EffZoraband_Draw; + } + } + if ((this->actor.home.rot.z != 0) && (this->actor.draw != NULL)) { + func_800B9010(&this->actor, NA_SE_EV_UFO_LIGHT_BEAM - SFX_FLAG); + } + if (this->stateFlags & 2) { + if (this->alpha < 240) { + this->alpha += 25; + } else { + this->alpha = 255; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Zoraband/func_80C07790.s") +void EffZoraband_Update(Actor* thisx, PlayState* play) { + EffZoraband* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Zoraband/EffZoraband_Update.s") + this->actionFunc(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Eff_Zoraband/EffZoraband_Draw.s") +void EffZoraband_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EffZoraband* this = THIS; + + if (this->alpha != 0) { + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + Matrix_RotateYS((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000), MTXMODE_APPLY); + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(object_zoraband_Matanimheader_000F38)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (this->actor.home.rot.z != 0) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 100, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 200, 0, 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 0, 100, 255, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 100, 255); + } + gSPDisplayList(POLY_XLU_DISP++, object_zoraband_DL_000180); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 200, 255, 255, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, 255); + gSPDisplayList(POLY_XLU_DISP++, object_zoraband_DL_0002A8); + + CLOSE_DISPS(play->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.h b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.h index c1213c666..2ecaf7187 100644 --- a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.h +++ b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.h @@ -3,14 +3,17 @@ #include "global.h" +#define EFFZORABAND_GET_F(thisx) ((thisx)->params & 0xF) + struct EffZoraband; typedef void (*EffZorabandActionFunc)(struct EffZoraband*, PlayState*); typedef struct EffZoraband { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4]; - /* 0x0148 */ EffZorabandActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 alpha; + /* 0x146 */ u16 stateFlags; + /* 0x148 */ EffZorabandActionFunc actionFunc; } EffZoraband; // size = 0x14C extern const ActorInit Eff_Zoraband_InitVars; diff --git a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c index 5cd49cbb8..5d3905914 100644 --- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c +++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c @@ -5,6 +5,7 @@ */ #include "z_elf_msg.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,8 +16,8 @@ void ElfMsg_Destroy(Actor* thisx, PlayState* play); void ElfMsg_Update(Actor* thisx, PlayState* play); void ElfMsg_SetupAction(ElfMsg* this, ElfMsgActionFunc actionFunc); +void func_8092E284(ElfMsg* this, PlayState* play); -#if 0 const ActorInit Elf_Msg_InitVars = { ACTOR_ELF_MSG, ACTORCAT_ITEMACTION, @@ -29,30 +30,119 @@ const ActorInit Elf_Msg_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8092E470[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -#endif +void ElfMsg_SetupAction(ElfMsg* this, ElfMsgActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern InitChainEntry D_8092E470[]; +s32 func_8092DF9C(ElfMsg* this, PlayState* play) { + if ((this->actor.home.rot.y > 0) && (this->actor.home.rot.y < 0x81) && + (Flags_GetSwitch(play, this->actor.home.rot.y - 1))) { + (void)"共倒れ"; // "Collapse together" + if (ELFMSG_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + if (this->actor.home.rot.y == 0x81) { + if (Flags_GetClear(play, this->actor.room)) { + if (ELFMSG_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + } + if (ELFMSG_GET_SWITCHFLAG(&this->actor) == 0x7F) { + return false; + } + if (Flags_GetSwitch(play, ELFMSG_GET_SWITCHFLAG(&this->actor))) { + (void)"共倒れ"; // "Collapse together" + Actor_MarkForDeath(&this->actor); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/D_8092E480.s") +void ElfMsg_Init(Actor* thisx, PlayState* play) { + ElfMsg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_SetupAction.s") + if (!func_8092DF9C(this, play)) { + Actor_ProcessInitChain(&this->actor, sInitChain); + if (ABS_ALT(this->actor.home.rot.x) == 0) { + this->actor.scale.x = this->actor.scale.z = 0.4f; + } else { + this->actor.scale.x = this->actor.scale.z = ABS_ALT(this->actor.home.rot.x) * 0.04f; + } + if (this->actor.home.rot.z == 0) { + this->actor.scale.y = 0.4f; + } else { + this->actor.scale.y = this->actor.home.rot.z * 0.04f; + } + ElfMsg_SetupAction(this, func_8092E284); + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092DF9C.s") +void ElfMsg_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_Init.s") +s32 func_8092E1D0(ElfMsg* this) { + if (ELFMSG_GET_8000(&this->actor) != 0) { + return ELFMSG_GET_FF(&this->actor) + 0x200; + } else { + return -0x200 - ELFMSG_GET_FF(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_Destroy.s") +s32 func_8092E1FC(ElfMsg* this) { + return (this->actor.xzDistToPlayer < (100.0f * this->actor.scale.x)) && (this->actor.playerHeightRel >= 0.0f) && + (this->actor.playerHeightRel < (100.0f * this->actor.scale.y)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092E1D0.s") +void func_8092E284(ElfMsg* this, PlayState* play) { + Player* player = GET_PLAYER(play); + EnElf* tatl = (EnElf*)player->tatlActor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092E1FC.s") + if ((player->tatlActor != NULL) && ((func_8092E1FC(this)))) { + player->tatlTextId = func_8092E1D0(this); + ActorCutscene_SetIntentToPlay(0x7C); + tatl->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + if ((player->tatlTextId < 0) && (this->actor.home.rot.x < 0)) { + if (ActorCutscene_GetCurrentIndex() == 0x7D) { + ActorCutscene_Stop(0x7D); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + this->actor.home.rot.x = 0; + ActorCutscene_Start(this->actor.cutscene, &this->actor); + func_800E0348(play->cameraPtrs[CAM_ID_MAIN]); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/func_8092E284.s") +void ElfMsg_Update(Actor* thisx, PlayState* play) { + ElfMsg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg/ElfMsg_Update.s") + if (func_8092DF9C(this, play) == 0) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (ELFMSG_GET_SWITCHFLAG(thisx) != 0x7F) { + Flags_SetSwitch(play, ELFMSG_GET_SWITCHFLAG(thisx)); + } + Actor_MarkForDeath(&this->actor); + } else if ((this->actor.home.rot.y >= 0) || (this->actor.home.rot.y < -0x80) || + (Flags_GetSwitch(play, -1 - this->actor.home.rot.y))) { + this->actionFunc(this, play); + } + } +} diff --git a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h index dd9accf93..f335f0158 100644 --- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h +++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h @@ -3,13 +3,17 @@ #include "global.h" +#define ELFMSG_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ELFMSG_GET_SWITCHFLAG(thisx) (((thisx)->params & 0x7F00) >> 8) +#define ELFMSG_GET_8000(thisx) ((thisx)->params & 0x8000) + struct ElfMsg; typedef void (*ElfMsgActionFunc)(struct ElfMsg*, PlayState*); typedef struct ElfMsg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ElfMsgActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ElfMsgActionFunc actionFunc; } ElfMsg; // size = 0x148 extern const ActorInit Elf_Msg_InitVars; diff --git a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c index 7c244d255..6e78ef085 100644 --- a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c +++ b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c @@ -14,11 +14,10 @@ void ElfMsg2_Init(Actor* thisx, PlayState* play); void ElfMsg2_Destroy(Actor* thisx, PlayState* play); void ElfMsg2_Update(Actor* thisx, PlayState* play); +s32 func_8096EE50(ElfMsg2* this); +void func_8096EF98(ElfMsg2* this, PlayState* play); void func_8096EFD0(ElfMsg2* this, PlayState* play); -void ElfMsg2_SetupAction(ElfMsg2* this, ElfMsg2ActionFunc actionFunc); - -#if 0 const ActorInit Elf_Msg2_InitVars = { ACTOR_ELF_MSG2, ACTORCAT_BG, @@ -31,32 +30,120 @@ const ActorInit Elf_Msg2_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8096F0B0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -#endif +void ElfMsg2_SetupAction(ElfMsg2* this, ElfMsg2ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern InitChainEntry D_8096F0B0[]; +s32 func_8096EC4C(ElfMsg2* this, PlayState* play) { + if ((this->actor.home.rot.y > 0) && (this->actor.home.rot.y < 0x81) && + (Flags_GetSwitch(play, this->actor.home.rot.y - 1))) { + (void)"共倒れ"; // "Collapse together" + if (ELFMSG2_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG2_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + if (this->actor.home.rot.y == 129) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/D_8096F0C0.s") + if (Flags_GetClear(play, this->actor.room)) { + (void)"共倒れ2"; // "Collapse 2" + if (ELFMSG2_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG2_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + } + if (ELFMSG2_GET_SWITCHFLAG(&this->actor) == 0x7F) { + return false; + } + if (Flags_GetSwitch(play, ELFMSG2_GET_SWITCHFLAG(&this->actor))) { + (void)"共倒れ"; // "Collapse together" + Actor_MarkForDeath(&this->actor); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/ElfMsg2_SetupAction.s") +void ElfMsg2_Init(Actor* thisx, PlayState* play) { + ElfMsg2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EC4C.s") + if (!func_8096EC4C(this, play)) { + if ((this->actor.home.rot.x > 0) && (this->actor.home.rot.x < 8)) { + this->actor.targetMode = this->actor.home.rot.x - 1; + } + Actor_ProcessInitChain(&this->actor, sInitChain); + if (this->actor.home.rot.y < 0) { + ElfMsg2_SetupAction(this, func_8096EFD0); + } else { + ElfMsg2_SetupAction(this, func_8096EF98); + this->actor.flags |= (ACTOR_FLAG_40000 | ACTOR_FLAG_1); + this->actor.textId = func_8096EE50(this); + } + this->actor.shape.rot.z = 0; + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/ElfMsg2_Init.s") +void ElfMsg2_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/ElfMsg2_Destroy.s") +s32 func_8096EE50(ElfMsg2* this) { + return ELFMSG2_GET_FF(&this->actor) + 0x200; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EE50.s") +void func_8096EE64(ElfMsg2* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->actor, play)) { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + } + if (this->actor.home.rot.z != 1) { + Actor_MarkForDeath(&this->actor); + if (ELFMSG2_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG2_GET_SWITCHFLAG(&this->actor)); + } + } else { + ElfMsg2_SetupAction(this, func_8096EF98); + } + } else if ((this->actor.cutscene != -1) && (ActorCutscene_GetCurrentIndex() != this->actor.cutscene)) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EE64.s") +void func_8096EF98(ElfMsg2* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + ElfMsg2_SetupAction(this, func_8096EE64); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EF98.s") +void func_8096EFD0(ElfMsg2* this, PlayState* play) { + if ((this->actor.home.rot.y < 0) && (this->actor.home.rot.y >= -0x80) && + (Flags_GetSwitch(play, -this->actor.home.rot.y - 1))) { + ElfMsg2_SetupAction(this, func_8096EF98); + this->actor.flags |= (ACTOR_FLAG_40000 | ACTOR_FLAG_1); + this->actor.textId = func_8096EE50(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EFD0.s") +void ElfMsg2_Update(Actor* thisx, PlayState* play) { + ElfMsg2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/ElfMsg2_Update.s") + if (!func_8096EC4C(this, play)) { + this->actionFunc(this, play); + } +} diff --git a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.h b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.h index 82194009a..e8b48dfd7 100644 --- a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.h +++ b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.h @@ -3,13 +3,16 @@ #include "global.h" +#define ELFMSG2_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) +#define ELFMSG2_GET_FF(thisx) ((thisx)->params & 0xFF) + struct ElfMsg2; typedef void (*ElfMsg2ActionFunc)(struct ElfMsg2*, PlayState*); typedef struct ElfMsg2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ElfMsg2ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ElfMsg2ActionFunc actionFunc; } ElfMsg2; // size = 0x148 extern const ActorInit Elf_Msg2_InitVars; diff --git a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c index b81bb2963..a62a22ad0 100644 --- a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c +++ b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c @@ -5,6 +5,7 @@ */ #include "z_elf_msg3.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" #define FLAGS (ACTOR_FLAG_10) @@ -14,9 +15,8 @@ void ElfMsg3_Init(Actor* thisx, PlayState* play); void ElfMsg3_Destroy(Actor* thisx, PlayState* play); void ElfMsg3_Update(Actor* thisx, PlayState* play); -void ElfMsg3_SetupAction(ElfMsg3* this, ElfMsg3ActionFunc actionFunc); +void func_80A2CF7C(ElfMsg3* this, PlayState* play); -#if 0 const ActorInit Elf_Msg3_InitVars = { ACTOR_ELF_MSG3, ACTORCAT_ITEMACTION, @@ -29,28 +29,118 @@ const ActorInit Elf_Msg3_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A2D1E0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -#endif +void ElfMsg3_SetupAction(ElfMsg3* this, ElfMsg3ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern InitChainEntry D_80A2D1E0[]; +s32 func_80A2CD1C(ElfMsg3* this, PlayState* play) { + if ((this->actor.home.rot.y > 0) && (this->actor.home.rot.y < 0x81) && + (Flags_GetSwitch(play, this->actor.home.rot.y - 1))) { + (void)"共倒れ"; // "Collapse together" + if (ELFMSG3_GET_SWITCH(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG3_GET_SWITCH(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + if (this->actor.home.rot.y == 0x81) { + if (Flags_GetClear(play, this->actor.room)) { + if (ELFMSG3_GET_SWITCH(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG3_GET_SWITCH(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + } + if (ELFMSG3_GET_SWITCH(&this->actor) == 0x7F) { + return false; + } + if (Flags_GetSwitch(play, ELFMSG3_GET_SWITCH(&this->actor))) { + (void)"共倒れ"; // "Collapse together" + Actor_MarkForDeath(&this->actor); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/D_80A2D1F0.s") +void ElfMsg3_Init(Actor* thisx, PlayState* play) { + ElfMsg3* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/ElfMsg3_SetupAction.s") + if (!func_80A2CD1C(this, play)) { + Actor_ProcessInitChain(&this->actor, sInitChain); + if (ABS_ALT(this->actor.home.rot.x) == 0) { + this->actor.scale.z = 0.4f; + this->actor.scale.x = 0.4f; + } else { + this->actor.scale.x = this->actor.scale.z = ABS_ALT(this->actor.home.rot.x) * 0.04f; + } + if (this->actor.home.rot.z == 0) { + this->actor.scale.y = 0.4f; + } else { + this->actor.scale.y = this->actor.home.rot.z * 0.04f; + } + ElfMsg3_SetupAction(this, func_80A2CF7C); + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/func_80A2CD1C.s") +void ElfMsg3_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/ElfMsg3_Init.s") +s32 func_80A2CF50(ElfMsg3* this) { + if (ELFMSG3_GET_8000(&this->actor) != 0) { + return ELFMSG3_GET_FF(&this->actor) + 0x200; + } else { + return -0x200 - ELFMSG3_GET_FF(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/ElfMsg3_Destroy.s") +void func_80A2CF7C(ElfMsg3* this, PlayState* play) { + Player* player = GET_PLAYER(play); + EnElf* tatl = (EnElf*)player->tatlActor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/func_80A2CF50.s") + if (((((player->tatlActor != NULL) && + (fabsf(player->actor.world.pos.x - this->actor.world.pos.x) < (100.0f * this->actor.scale.x))) && + (this->actor.world.pos.y <= player->actor.world.pos.y)) && + ((player->actor.world.pos.y - this->actor.world.pos.y) < (100.0f * this->actor.scale.y))) && + (fabsf(player->actor.world.pos.z - this->actor.world.pos.z) < (100.0f * this->actor.scale.z))) { + player->tatlTextId = func_80A2CF50(this); + ActorCutscene_SetIntentToPlay(0x7C); + tatl->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + if ((player->tatlTextId < 0) && (this->actor.home.rot.x < 0)) { + if (ActorCutscene_GetCurrentIndex() == 0x7D) { + ActorCutscene_Stop(0x7D); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + func_800E0348(play->cameraPtrs[CAM_ID_MAIN]); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/func_80A2CF7C.s") +void ElfMsg3_Update(Actor* thisx, PlayState* play) { + ElfMsg3* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg3/ElfMsg3_Update.s") + if (!func_80A2CD1C(this, play)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (ELFMSG3_GET_SWITCH(thisx) != 0x7F) { + Flags_SetSwitch(play, ELFMSG3_GET_SWITCH(thisx)); + } + Actor_MarkForDeath(&this->actor); + } else if ((this->actor.home.rot.y >= 0) || (this->actor.home.rot.y < -0x80) || + (Flags_GetSwitch(play, -1 - this->actor.home.rot.y))) { + this->actionFunc(this, play); + } + } +} diff --git a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h index 73b285dba..cb71166e8 100644 --- a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h +++ b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h @@ -3,13 +3,17 @@ #include "global.h" +#define ELFMSG3_GET_SWITCH(thisx) (((thisx)->params & 0x7F00) >> 8) +#define ELFMSG3_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ELFMSG3_GET_8000(thisx) ((thisx)->params & 0x8000) + struct ElfMsg3; typedef void (*ElfMsg3ActionFunc)(struct ElfMsg3*, PlayState*); typedef struct ElfMsg3 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ElfMsg3ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ElfMsg3ActionFunc actionFunc; } ElfMsg3; // size = 0x148 extern const ActorInit Elf_Msg3_InitVars; diff --git a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c index 4606d6c08..4c6f143ff 100644 --- a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c +++ b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c @@ -5,6 +5,8 @@ */ #include "z_elf_msg4.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" +#include "overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h" #define FLAGS (ACTOR_FLAG_10) @@ -16,8 +18,10 @@ void ElfMsg4_Update(Actor* thisx, PlayState* play); void func_80AFD668(ElfMsg4* this, PlayState* play); void func_80AFD770(ElfMsg4* this, PlayState* play); +s32 func_80AFD380(ElfMsg4* this, PlayState* play); +s32 ElfMsg4_GetTextId(ElfMsg4* this); +s32 func_80AFD5E0(ElfMsg4* this); -#if 0 const ActorInit Elf_Msg4_InitVars = { ACTOR_ELF_MSG4, ACTORCAT_ITEMACTION, @@ -30,30 +34,137 @@ const ActorInit Elf_Msg4_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AFD8F0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -#endif +s32 func_80AFD380(ElfMsg4* this, PlayState* play) { + if ((this->actor.home.rot.y > 0) && (this->actor.home.rot.y < 0x81) && + (Flags_GetSwitch(play, this->actor.home.rot.y - 1))) { + (void)"共倒れ"; // "Collapse together" + if (ELFMSG4_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG4_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + if (this->actor.home.rot.y == 0x81) { + if (Flags_GetClear(play, this->actor.room)) { + if (ELFMSG4_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG4_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + } + if (ELFMSG4_GET_SWITCHFLAG(&this->actor) == 0x7F) { + return false; + } + if (Flags_GetSwitch(play, ELFMSG4_GET_SWITCHFLAG(&this->actor))) { + (void)"共倒れ"; // "Collapse together" + Actor_MarkForDeath(&this->actor); + return true; + } + return false; +} -extern InitChainEntry D_80AFD8F0[]; +void ElfMsg4_Init(Actor* thisx, PlayState* play) { + ElfMsg4* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/D_80AFD900.s") + if (!func_80AFD380(this, play)) { + Actor_ProcessInitChain(&this->actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/func_80AFD380.s") + if (ABS_ALT(this->actor.home.rot.x) == 0) { + this->actor.scale.z = 0.4f; + this->actor.scale.x = 0.4f; + } else { + this->actor.scale.x = this->actor.scale.z = ABS_ALT(this->actor.home.rot.x) * 0.04f; + } + if (this->actor.home.rot.z == 0) { + this->actor.scale.y = 0.4f; + } else { + this->actor.scale.y = this->actor.home.rot.z * 0.04f; + } + this->actor.shape.rot.z = 0; + this->actionFunc = func_80AFD770; + this->elfMsg5 = NULL; + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/ElfMsg4_Init.s") +void ElfMsg4_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/ElfMsg4_Destroy.s") +s32 ElfMsg4_GetTextId(ElfMsg4* this) { + if (ELFMSG4_GET_8000(&this->actor) != 0) { + return ELFMSG4_GET_TEXT(&this->actor) + 0x200; + } else { + return -ELFMSG4_GET_TEXT(&this->actor) - 0x200; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/func_80AFD5B4.s") +s32 func_80AFD5E0(ElfMsg4* this) { + return (this->actor.xzDistToPlayer < (100.0f * this->actor.scale.x)) && (this->actor.playerHeightRel >= 0.0f) && + (this->actor.playerHeightRel < (100.0f * this->actor.scale.y)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/func_80AFD5E0.s") +void func_80AFD668(ElfMsg4* this, PlayState* play) { + Player* player = GET_PLAYER(play); + EnElf* tatl = (EnElf*)player->tatlActor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/func_80AFD668.s") + if ((player->tatlActor != NULL) && func_80AFD5E0(this)) { + player->tatlTextId = ElfMsg4_GetTextId(this); + ActorCutscene_SetIntentToPlay(0x7C); + tatl->elfMsg = this->elfMsg5; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + if ((player->tatlTextId < 0) && (this->actor.home.rot.x < 0)) { + if (ActorCutscene_GetCurrentIndex() == 0x7D) { + ActorCutscene_Stop(0x7D); + ActorCutscene_SetIntentToPlay((s16)this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext((s16)this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + func_800E0348(play->cameraPtrs[CAM_ID_MAIN]); + } else { + ActorCutscene_SetIntentToPlay((s16)this->actor.cutscene); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/func_80AFD770.s") +void func_80AFD770(ElfMsg4* this, PlayState* play) { + Actor* bgActor = play->actorCtx.actorLists[ACTORCAT_BG].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg4/ElfMsg4_Update.s") + while (bgActor != NULL) { + if ((bgActor->id != ACTOR_ELF_MSG5) || (ELFMSG4_GET_TEXT(&this->actor) != ELFMSG5_GET_FF(bgActor)) || + (this->actor.cutscene != bgActor->cutscene)) { + bgActor = bgActor->next; + } else { + this->elfMsg5 = bgActor; + this->actionFunc = func_80AFD668; + bgActor = bgActor->next; + } + } +} + +void ElfMsg4_Update(Actor* thisx, PlayState* play) { + Actor* bgActor; + ElfMsg4* this = THIS; + + if (!func_80AFD380(this, play)) { + bgActor = this->elfMsg5; + if ((bgActor != NULL) && (bgActor->update == NULL)) { + Actor_MarkForDeath(&this->actor); + } else if ((bgActor != NULL) && (Actor_ProcessTalkRequest(bgActor, &play->state))) { + if (ELFMSG4_GET_SWITCHFLAG(thisx) != 0x7F) { + Flags_SetSwitch(play, ELFMSG4_GET_SWITCHFLAG(thisx)); + } + Actor_MarkForDeath(&this->actor); + } else if ((this->actor.home.rot.y >= 0) || (this->actor.home.rot.y < -0x80) || + (Flags_GetSwitch(play, -1 - this->actor.home.rot.y))) { + this->actionFunc(this, play); + } + } +} diff --git a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.h b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.h index 85cc0bc1b..f3d523ba4 100644 --- a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.h +++ b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.h @@ -3,14 +3,18 @@ #include "global.h" +#define ELFMSG4_GET_SWITCHFLAG(thisx) (((thisx)->params & 0x7F00) >> 8) +#define ELFMSG4_GET_8000(thisx) ((thisx)->params & 0x8000) +#define ELFMSG4_GET_TEXT(thisx) ((thisx)->params & 0xFF) + struct ElfMsg4; typedef void (*ElfMsg4ActionFunc)(struct ElfMsg4*, PlayState*); typedef struct ElfMsg4 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4]; - /* 0x0148 */ ElfMsg4ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ Actor* elfMsg5; + /* 0x148 */ ElfMsg4ActionFunc actionFunc; } ElfMsg4; // size = 0x14C extern const ActorInit Elf_Msg4_InitVars; diff --git a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c index 140029163..bcc88ad5d 100644 --- a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c +++ b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c @@ -15,8 +15,8 @@ void ElfMsg5_Destroy(Actor* thisx, PlayState* play); void ElfMsg5_Update(Actor* thisx, PlayState* play); void func_80AFDB38(ElfMsg5* this, PlayState* play); +s32 func_80AFD990(ElfMsg5* this, PlayState* play); -#if 0 const ActorInit Elf_Msg5_InitVars = { ACTOR_ELF_MSG5, ACTORCAT_BG, @@ -29,24 +29,65 @@ const ActorInit Elf_Msg5_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AFDBD0[] = { +static InitChainEntry sInitChainsInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -#endif +s32 func_80AFD990(ElfMsg5* this, PlayState* play) { + if ((this->actor.home.rot.y > 0) && (this->actor.home.rot.y < 0x81) && + (Flags_GetSwitch(play, this->actor.home.rot.y - 1))) { + (void)"共倒れ"; // Collapse together + if (ELFMSG5_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG5_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + if (this->actor.home.rot.y == 0x81) { + if (Flags_GetClear(play, this->actor.room)) { + (void)"共倒れ2"; // Collapse 2 + if (ELFMSG5_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG5_GET_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return true; + } + } + if (ELFMSG5_GET_SWITCHFLAG(&this->actor) == 0x7F) { + return false; + } + if (Flags_GetSwitch(play, ELFMSG5_GET_SWITCHFLAG(&this->actor))) { + (void)"共倒れ"; // Collapse together + Actor_MarkForDeath(&this->actor); + return true; + } + return false; +} -extern InitChainEntry D_80AFDBD0[]; +void ElfMsg5_Init(Actor* thisx, PlayState* play) { + ElfMsg5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/D_80AFDBE0.s") + if (!func_80AFD990(this, play)) { + Actor_ProcessInitChain(&this->actor, sInitChainsInitChain); + this->actor.shape.rot.z = 0; + this->actionFunc = func_80AFDB38; + this->actor.home.rot.x = -0x961; + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/func_80AFD990.s") +void ElfMsg5_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/ElfMsg5_Init.s") +void func_80AFDB38(ElfMsg5* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/ElfMsg5_Destroy.s") +void ElfMsg5_Update(Actor* thisx, PlayState* play) { + ElfMsg5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/func_80AFDB38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg5/ElfMsg5_Update.s") + if ((this->actor.home.rot.y >= 0) || (this->actor.home.rot.y < -0x80) || + (Flags_GetSwitch(play, -this->actor.home.rot.y - 1))) { + this->actionFunc(this, play); + } +} diff --git a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h index be4ff4116..af2589434 100644 --- a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h +++ b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h @@ -3,13 +3,16 @@ #include "global.h" +#define ELFMSG5_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) +#define ELFMSG5_GET_FF(thisx) ((thisx)->params & 0xFF) + struct ElfMsg5; typedef void (*ElfMsg5ActionFunc)(struct ElfMsg5*, PlayState*); typedef struct ElfMsg5 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ElfMsg5ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ElfMsg5ActionFunc actionFunc; } ElfMsg5; // size = 0x148 extern const ActorInit Elf_Msg5_InitVars; diff --git a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h index c8875a7d5..cd33b350b 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h @@ -12,8 +12,8 @@ typedef void (*ElfMsg6ActionFunc)(struct ElfMsg6*, PlayState*); #define ELFMSG6_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) typedef struct ElfMsg6 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ElfMsg6ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ElfMsg6ActionFunc actionFunc; } ElfMsg6; // size = 0x148 extern const ActorInit Elf_Msg6_InitVars; diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index fae0025d2..bfc6d197b 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -376,7 +376,7 @@ s32 func_80BD3320(EnAh* this, PlayState* play, u8 actorCat, s16 actorId) { return ret; } -s32 func_80BD3374(EnAh* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BD3374(EnAh* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3EC4.pos); @@ -388,7 +388,7 @@ s32 func_80BD3374(EnAh* this, PlayState* play, ScheduleResult* arg2) { return true; } -s32 func_80BD33FC(EnAh* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BD33FC(EnAh* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3ED8.pos); @@ -400,7 +400,7 @@ s32 func_80BD33FC(EnAh* this, PlayState* play, ScheduleResult* arg2) { return true; } -s32 func_80BD3484(EnAh* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BD3484(EnAh* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; if (func_80BD3320(this, play, ACTORCAT_NPC, ACTOR_EN_AN)) { @@ -419,26 +419,26 @@ s32 func_80BD3484(EnAh* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80BD3548(EnAh* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BD3548(EnAh* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret; this->unk_2D8 = 0; - switch (arg2->result) { + switch (scheduleOutput->result) { default: ret = false; break; case 1: - ret = func_80BD3374(this, play, arg2); + ret = func_80BD3374(this, play, scheduleOutput); break; case 2: - ret = func_80BD33FC(this, play, arg2); + ret = func_80BD33FC(this, play, scheduleOutput); break; case 3: - ret = func_80BD3484(this, play, arg2); + ret = func_80BD3484(this, play, scheduleOutput); break; } return ret; @@ -472,7 +472,7 @@ void func_80BD3658(EnAh* this, PlayState* play) { } void func_80BD36B8(EnAh* this, PlayState* play) { - ScheduleResult sp18; + ScheduleOutput sp18; if (!Schedule_RunScript(play, D_80BD3DB0, &sp18) || ((this->unk_1DC != sp18.result) && !func_80BD3548(this, play, &sp18))) { diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.h b/src/overlays/actors/ovl_En_Ah/z_en_ah.h index b1c18287f..78872a270 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.h +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.h @@ -9,33 +9,33 @@ typedef void (*EnAhActionFunc)(struct EnAh*, PlayState*); typedef void (*EnAhUnkFunc)(struct EnAh*, PlayState*); typedef struct EnAh { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnAhActionFunc actionFunc; - /* 0x018C */ EnAhUnkFunc unk_18C; - /* 0x0190 */ ColliderCylinder collider; - /* 0x01DC */ u8 unk_1DC; - /* 0x01E0 */ s32 unk_1E0; - /* 0x01E4 */ Actor* unk_1E4; - /* 0x01E8 */ Vec3f unk_1E8[2]; - /* 0x0200 */ Vec3s unk_200[2]; - /* 0x020C */ Vec3s jointTable[17]; - /* 0x0272 */ Vec3s morphTable[17]; - /* 0x02D8 */ u16 unk_2D8; - /* 0x02DA */ u16 unk_2DA; - /* 0x02DC */ f32 unk_2DC; - /* 0x02E0 */ UNK_TYPE1 unk2E0[0xC]; - /* 0x02EC */ s16 unk_2EC; - /* 0x02EE */ s16 unk_2EE; - /* 0x02F0 */ s16 unk_2F0; - /* 0x02F2 */ s16 unk_2F2; - /* 0x02F4 */ s16 unk_2F4; - /* 0x02F6 */ s16 unk_2F6; - /* 0x02F8 */ s16 unk_2F8; - /* 0x02FA */ s16 unk_2FA; - /* 0x02FC */ s16 unk_2FC; - /* 0x02FE */ s16 unk_2FE; - /* 0x0300 */ s32 unk_300; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnAhActionFunc actionFunc; + /* 0x18C */ EnAhUnkFunc unk_18C; + /* 0x190 */ ColliderCylinder collider; + /* 0x1DC */ u8 unk_1DC; + /* 0x1E0 */ s32 unk_1E0; + /* 0x1E4 */ Actor* unk_1E4; + /* 0x1E8 */ Vec3f unk_1E8[2]; + /* 0x200 */ Vec3s unk_200[2]; + /* 0x20C */ Vec3s jointTable[17]; + /* 0x272 */ Vec3s morphTable[17]; + /* 0x2D8 */ u16 unk_2D8; + /* 0x2DA */ u16 unk_2DA; + /* 0x2DC */ f32 unk_2DC; + /* 0x2E0 */ UNK_TYPE1 unk2E0[0xC]; + /* 0x2EC */ s16 unk_2EC; + /* 0x2EE */ s16 unk_2EE; + /* 0x2F0 */ s16 unk_2F0; + /* 0x2F2 */ s16 unk_2F2; + /* 0x2F4 */ s16 unk_2F4; + /* 0x2F6 */ s16 unk_2F6; + /* 0x2F8 */ s16 unk_2F8; + /* 0x2FA */ s16 unk_2FA; + /* 0x2FC */ s16 unk_2FC; + /* 0x2FE */ s16 unk_2FE; + /* 0x300 */ s32 unk_300; } EnAh; // size = 0x304 extern const ActorInit En_Ah_InitVars; diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index 244642225..faf39aece 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -221,36 +221,36 @@ s16 func_80BECF6C(Path* path) { s32 func_80BECFBC(EnAkindonuts* this) { switch (ENAKINDONUTS_GET_3(&this->actor)) { case 0: - return 0x98; + return GI_DEED_SWAMP; case 1: - return 0x99; + return GI_DEED_MOUNTAIN; case 2: - return 0x9A; + return GI_DEED_OCEAN; case 3: - func_801149A0(ITEM_DEED_OCEAN, SLOT(ITEM_DEED_OCEAN)); - return 0x7; + Inventory_DeleteItem(ITEM_DEED_OCEAN, SLOT(ITEM_DEED_OCEAN)); + return GI_RUPEE_HUGE; } - return 0; + return GI_NONE; } s32 func_80BED034(EnAkindonuts* this) { switch (ENAKINDONUTS_GET_3(&this->actor)) { case 0: - return 0x35; + return GI_MAGIC_BEANS; case 1: - return 0x1D; + return GI_BOMB_BAG_40; case 2: - return 0x5C; + return GI_POTION_GREEN; case 3: - return 0x5D; + return GI_POTION_BLUE; } - return 0; + return GI_NONE; } void func_80BED090(PlayState* play) { @@ -296,7 +296,7 @@ s32 func_80BED140(PlayState* play) { } s32 func_80BED208(EnAkindonuts* this) { - if (INV_CONTENT(ITEM_MAGIC_BEANS) != 10U) { + if ((u32)INV_CONTENT(ITEM_MAGIC_BEANS) != ITEM_MAGIC_BEANS) { return 0; } @@ -332,7 +332,7 @@ s32 func_80BED27C(EnAkindonuts* this) { } s32 func_80BED2FC(EnAkindonuts* this) { - if (!Interface_HasEmptyBottle()) { + if (!Inventory_HasEmptyBottle()) { return 2; } @@ -346,7 +346,7 @@ s32 func_80BED2FC(EnAkindonuts* this) { } s32 func_80BED35C(EnAkindonuts* this) { - if (!Interface_HasEmptyBottle()) { + if (!Inventory_HasEmptyBottle()) { return 2; } @@ -426,7 +426,7 @@ void func_80BED3BC(EnAkindonuts* this, PlayState* play) { this->unk_32C &= ~0x1; this->unk_32C |= 0x40; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x15EF; this->actionFunc = func_80BEF360; return; @@ -509,7 +509,7 @@ void func_80BED680(EnAkindonuts* this, PlayState* play) { this->unk_32C |= 0x40; this->unk_32C &= ~0x1; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x15EF; this->actionFunc = func_80BEF360; return; @@ -604,7 +604,7 @@ void func_80BED8A4(EnAkindonuts* this, PlayState* play) { this->unk_32C |= 0x40; this->unk_32C &= ~0x1; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x15EF; this->actionFunc = func_80BEF360; return; @@ -687,7 +687,7 @@ void func_80BEDB88(EnAkindonuts* this, PlayState* play) { this->unk_32C |= 0x40; this->unk_32C &= ~0x1; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x15EF; this->actionFunc = func_80BEF360; return; @@ -777,7 +777,7 @@ void func_80BEDDAC(EnAkindonuts* this, PlayState* play) { this->unk_32C |= 0x40; this->unk_32C &= ~0x1; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x15EF; this->actionFunc = func_80BEF360; return; @@ -855,7 +855,7 @@ void func_80BEE070(EnAkindonuts* this, PlayState* play) { this->unk_32C |= 0x40; this->unk_32C &= ~0x1; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x161A; this->actionFunc = func_80BEF360; return; @@ -938,7 +938,7 @@ void func_80BEE274(EnAkindonuts* this, PlayState* play) { this->unk_32C |= 0x40; this->unk_32C &= ~0x1; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x1629; this->actionFunc = func_80BEF360; return; @@ -1016,7 +1016,7 @@ void func_80BEE530(EnAkindonuts* this, PlayState* play) { this->unk_32C |= 0x40; this->unk_32C &= ~0x1; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_33C = 0x15EF; this->actionFunc = func_80BEF360; return; @@ -1240,14 +1240,14 @@ void func_80BEEE10(EnAkindonuts* this, PlayState* play) { } void func_80BEEFA8(EnAkindonuts* this, PlayState* play) { - u8 temp_v0 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 5) { + if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { if (this->unk_32C & 1) { this->unk_32C &= ~0x1; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_33C = 0; this->actionFunc = func_80BEEE10; } else if (this->unk_32C & 0x20) { @@ -1255,7 +1255,7 @@ void func_80BEEFA8(EnAkindonuts* this, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_1; this->unk_32C &= ~0x4; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_338 = 8; this->unk_33C = 0; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); @@ -1264,7 +1264,7 @@ void func_80BEEFA8(EnAkindonuts* this, PlayState* play) { this->unk_2DC(this, play); } } - } else if (temp_v0 == 4) { + } else if (talkState == TEXT_STATE_CHOICE) { if (Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: @@ -1279,22 +1279,22 @@ void func_80BEEFA8(EnAkindonuts* this, PlayState* play) { break; } } - } else if (temp_v0 == 16) { + } else if (talkState == TEXT_STATE_16) { func_80BEE73C(this, play); } } void func_80BEF18C(EnAkindonuts* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_33C = 0; this->actionFunc = func_80BEEE10; } } void func_80BEF20C(EnAkindonuts* this, PlayState* play) { - u8 sp27 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); s16 sp24 = this->skelAnime.curFrame; s16 sp22 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); @@ -1310,11 +1310,11 @@ void func_80BEF20C(EnAkindonuts* this, PlayState* play) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 6); } - if ((sp27 == 5) && Message_ShouldAdvance(play)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_32C & 1) { this->unk_32C &= ~0x1; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80BEF360; } else { this->unk_2DC(this, play); @@ -1326,7 +1326,7 @@ void func_80BEF360(EnAkindonuts* this, PlayState* play) { if (this->unk_32C & 0x40) { if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; - func_801159EC(this->unk_364); + Rupees_ChangeBy(this->unk_364); this->unk_32C &= ~0x40; this->actionFunc = func_80BEF450; } else { @@ -1341,7 +1341,7 @@ void func_80BEF360(EnAkindonuts* this, PlayState* play) { } void func_80BEF450(EnAkindonuts* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 6) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { func_800B85E0(&this->actor, play, 400.0f, -1); this->actionFunc = func_80BEF4B8; } 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 a14898736..ec0446f95 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.h +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.h @@ -18,36 +18,36 @@ enum { }; typedef struct EnAkindonuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[28]; - /* 0x0230 */ Vec3s morphTable[28]; - /* 0x02D8 */ EnAkindonutsActionFunc actionFunc; - /* 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; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[28]; + /* 0x230 */ Vec3s morphTable[28]; + /* 0x2D8 */ EnAkindonutsActionFunc actionFunc; + /* 0x2DC */ EnAkindonutsUnkFunc unk_2DC; + /* 0x2E0 */ ColliderCylinder collider; + /* 0x32C */ u16 unk_32C; + /* 0x330 */ Path* path; + /* 0x334 */ s32 unk_334; + /* 0x338 */ s16 unk_338; + /* 0x33A */ s16 unk_33A; + /* 0x33C */ u16 unk_33C; + /* 0x33E */ s16 unk_33E; + /* 0x340 */ f32 unk_340; + /* 0x344 */ f32 unk_344; + /* 0x348 */ f32 unk_348; + /* 0x34C */ f32 unk_34C; + /* 0x350 */ s16 unk_350; + /* 0x352 */ s16 unk_352; + /* 0x354 */ UNK_TYPE1 unk354[0x2]; + /* 0x356 */ s16 unk_356; + /* 0x358 */ f32 unk_358; + /* 0x35C */ s16 unk_35C; + /* 0x35E */ s16 unk_35E; + /* 0x360 */ s16 cutscene; + /* 0x362 */ s16 unk_362; + /* 0x364 */ s16 unk_364; + /* 0x366 */ s8 unk_366; + /* 0x368 */ s16 unk_368; } EnAkindonuts; // size = 0x36C extern const ActorInit En_Akindonuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index ca5138971..c3b893a5d 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -129,8 +129,9 @@ static AnimationInfoS sAnimations[] = { Vec3f D_80BE0070 = { 1000.0f, 0.0f, 0.0f }; Gfx* D_80BE007C[] = { - object_al_DL_006598, object_al_DL_005920, object_al_DL_005878, - object_al_DL_0057D0, object_al_DL_005728, object_al_DL_005680, + gMadameAromaShawlMiddleDL, gMadameAromaShawlUpperDL, + gMadameAromaShawlLeftLowerMiddleDL, gMadameAromaShawlLeftLowerDL, + gMadameAromaShawlRightLowerMiddleDL, gMadameAromaShawlRightLowerDL, }; Actor* func_80BDE1A0(EnAl* this, PlayState* play, u8 arg0, s16 arg1) { @@ -331,7 +332,7 @@ s32 func_80BDE7FC(EnAl* this, PlayState* play) { case 6: case 8: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), this->actor.child); } this->unk_4E6++; sp20 = true; @@ -341,7 +342,7 @@ s32 func_80BDE7FC(EnAl* this, PlayState* play) { case 3: case 5: case 7: - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); this->unk_4E6++; sp20 = true; break; @@ -634,7 +635,7 @@ s32 func_80BDF064(EnAl* this, PlayState* play) { return false; } -s32 func_80BDF244(EnAl* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BDF244(EnAl* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; Actor* sp20 = func_80BDE1A0(this, play, ACTORCAT_NPC, ACTOR_EN_GM); Actor* temp_v0 = func_80BDE1A0(this, play, ACTORCAT_NPC, ACTOR_EN_TOTO); @@ -649,10 +650,10 @@ s32 func_80BDF244(EnAl* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80BDF308(EnAl* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BDF308(EnAl* this, PlayState* play, ScheduleOutput* scheduleOutput) { SubS_UpdateFlags(&this->unk_4C2, 3, 7); - switch (arg2->result) { + switch (scheduleOutput->result) { case 1: func_80BDE27C(this, 0); break; @@ -666,7 +667,7 @@ s32 func_80BDF308(EnAl* this, PlayState* play, ScheduleResult* arg2) { return true; } -s32 func_80BDF390(EnAl* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BDF390(EnAl* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret; this->actor.flags |= ACTOR_FLAG_1; @@ -675,14 +676,14 @@ s32 func_80BDF390(EnAl* this, PlayState* play, ScheduleResult* arg2) { this->unk_4C2 = 0; this->unk_4D4 = 40.0f; - switch (arg2->result) { + switch (scheduleOutput->result) { case 3: - ret = func_80BDF244(this, play, arg2); + ret = func_80BDF244(this, play, scheduleOutput); break; case 1: case 2: - ret = func_80BDF308(this, play, arg2); + ret = func_80BDF308(this, play, scheduleOutput); break; default: @@ -745,7 +746,7 @@ void func_80BDF578(EnAl* this, PlayState* play) { } void func_80BDF5E8(EnAl* this, PlayState* play) { - ScheduleResult sp20; + ScheduleOutput sp20; this->unk_4E0 = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (!Schedule_RunScript(play, D_80BDFC70, &sp20) || @@ -780,7 +781,8 @@ void EnAl_Init(Actor* thisx, PlayState* play) { EnAl* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_al_Skel_00A0D8, NULL, this->jointTable, this->morphTable, 27); + SkelAnime_InitFlex(play, &this->skelAnime, &gMadameAromaSkel, NULL, this->jointTable, this->morphTable, + MADAME_AROMA_LIMB_MAX); this->unk_4F8 = -1; func_80BDE27C(this, 1); Collider_InitAndSetCylinder(play, &this->unk_310, &this->actor, &sCylinderInit); @@ -817,16 +819,16 @@ void EnAl_Update(Actor* thisx, PlayState* play) { s32 EnAl_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { switch (limbIndex) { - case 3: - case 11: - case 12: - case 13: - case 14: - case 15: + case MADAME_AROMA_LIMB_SHAWL_MIDDLE: + case MADAME_AROMA_LIMB_SHAWL_UPPER: + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER_MIDDLE: + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER: + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER_MIDDLE: + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER: *dList = NULL; break; - case 16: + case MADAME_AROMA_LIMB_HEAD: break; } return false; @@ -836,31 +838,31 @@ void EnAl_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, EnAl* this = THIS; switch (limbIndex) { - case 3: + case MADAME_AROMA_LIMB_SHAWL_MIDDLE: Matrix_Get(&this->unk_190[0]); break; - case 11: + case MADAME_AROMA_LIMB_SHAWL_UPPER: Matrix_Get(&this->unk_190[1]); break; - case 12: + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER_MIDDLE: Matrix_Get(&this->unk_190[2]); break; - case 13: + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER: Matrix_Get(&this->unk_190[3]); break; - case 14: + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER_MIDDLE: Matrix_Get(&this->unk_190[4]); break; - case 15: + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER: Matrix_Get(&this->unk_190[5]); break; - case 16: + case MADAME_AROMA_LIMB_HEAD: Matrix_MultVec3f(&D_80BE0070, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); break; diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.h b/src/overlays/actors/ovl_En_Al/z_en_al.h index 42fe81ef2..4a92743df 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.h +++ b/src/overlays/actors/ovl_En_Al/z_en_al.h @@ -10,39 +10,39 @@ typedef s32 (*EnAlUnkFunc)(struct EnAl*, PlayState*); typedef void (*EnAlUnkFunc2)(struct EnAl*, PlayState*); typedef struct EnAl { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnAlActionFunc actionFunc; - /* 0x018C */ EnAlUnkFunc2 unk_18C; - /* 0x0190 */ MtxF unk_190[6]; - /* 0x0310 */ ColliderCylinder unk_310; - /* 0x035C */ u8 unk_35C; - /* 0x0360 */ s32* unk_360; - /* 0x0364 */ s32 unk_364; - /* 0x0368 */ Actor* unk_368; - /* 0x036C */ Vec3f unk_36C; - /* 0x0378 */ Vec3s unk_378; - /* 0x037E */ Vec3s jointTable[27]; - /* 0x0420 */ Vec3s morphTable[27]; - /* 0x04C2 */ u16 unk_4C2; - /* 0x04C4 */ u16 unk_4C4; - /* 0x04C8 */ f32 unk_4C8; - /* 0x04CC */ UNK_TYPE1 unk4CC[8]; - /* 0x04D4 */ f32 unk_4D4; - /* 0x04D8 */ UNK_TYPE1 unk4D8[4]; - /* 0x04DC */ s16 unk_4DC; - /* 0x04DE */ s16 unk_4DE; - /* 0x04E0 */ s16 unk_4E0; - /* 0x04E2 */ s16 unk_4E2; - /* 0x04E4 */ s16 unk_4E4; - /* 0x04E6 */ s16 unk_4E6; - /* 0x04E8 */ s16 unk_4E8; - /* 0x04EA */ s16 unk_4EA; - /* 0x04EC */ EnAlUnkFunc unk_4EC; - /* 0x04F0 */ s32 unk_4F0; - /* 0x04F4 */ s32 unk_4F4; - /* 0x04F8 */ s32 unk_4F8; - /* 0x04FC */ UNK_TYPE1 unk4FC[4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnAlActionFunc actionFunc; + /* 0x18C */ EnAlUnkFunc2 unk_18C; + /* 0x190 */ MtxF unk_190[6]; + /* 0x310 */ ColliderCylinder unk_310; + /* 0x35C */ u8 unk_35C; + /* 0x360 */ s32* unk_360; + /* 0x364 */ s32 unk_364; + /* 0x368 */ Actor* unk_368; + /* 0x36C */ Vec3f unk_36C; + /* 0x378 */ Vec3s unk_378; + /* 0x37E */ Vec3s jointTable[27]; + /* 0x420 */ Vec3s morphTable[27]; + /* 0x4C2 */ u16 unk_4C2; + /* 0x4C4 */ u16 unk_4C4; + /* 0x4C8 */ f32 unk_4C8; + /* 0x4CC */ UNK_TYPE1 unk4CC[8]; + /* 0x4D4 */ f32 unk_4D4; + /* 0x4D8 */ UNK_TYPE1 unk4D8[4]; + /* 0x4DC */ s16 unk_4DC; + /* 0x4DE */ s16 unk_4DE; + /* 0x4E0 */ s16 unk_4E0; + /* 0x4E2 */ s16 unk_4E2; + /* 0x4E4 */ s16 unk_4E4; + /* 0x4E6 */ s16 unk_4E6; + /* 0x4E8 */ s16 unk_4E8; + /* 0x4EA */ s16 unk_4EA; + /* 0x4EC */ EnAlUnkFunc unk_4EC; + /* 0x4F0 */ s32 unk_4F0; + /* 0x4F4 */ s32 unk_4F4; + /* 0x4F8 */ s32 unk_4F8; + /* 0x4FC */ UNK_TYPE1 unk4FC[4]; } EnAl; // size = 0x500 extern const ActorInit En_Al_InitVars; diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index 7bc18e5c5..5b1b488cb 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -205,7 +205,7 @@ void EnAm_SpawnEffects(EnAm* this, PlayState* play) { void func_808AFF9C(EnAm* this) { f32 lastFrame = Animation_GetLastFrame(&gArmosPushedBackAnim); - Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 0.0f, lastFrame, lastFrame, 0, 0.0f); + Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 0.0f, lastFrame, lastFrame, ANIMMODE_LOOP, 0.0f); this->enemyCollider.info.bumper.dmgFlags = 0x80000088; this->interactCollider.info.bumper.dmgFlags = 0x77CFFF77; if (this->actor.colChkInfo.health != 0) { @@ -380,7 +380,7 @@ void func_808B066C(EnAm* this, PlayState* play) { void EnAm_TakeDamage(EnAm* this, PlayState* play) { Animation_Change(&this->skelAnime, &gArmosTakeDamageAnim, 1.0f, 4.0f, - Animation_GetLastFrame(&gArmosTakeDamageAnim) - 6, 2, 0.0f); + Animation_GetLastFrame(&gArmosTakeDamageAnim) - 6, ANIMMODE_ONCE, 0.0f); func_800BE504(&this->actor, &this->enemyCollider); this->actor.speedXZ = 6.0f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, Animation_GetLastFrame(&gArmosTakeDamageAnim) - 10); @@ -449,7 +449,7 @@ void func_808B0894(EnAm* this, PlayState* play) { } void func_808B0AD0(EnAm* this, PlayState* play) { - Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 1.0f, 0.0f, 8.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 1.0f, 0.0f, 8.0f, ANIMMODE_ONCE, 0.0f); this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.speedXZ = -6.0f; this->actionFunc = func_808B0B4C; diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.h b/src/overlays/actors/ovl_En_Am/z_en_am.h index 50770ccfc..79d3a81bd 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.h +++ b/src/overlays/actors/ovl_En_Am/z_en_am.h @@ -9,22 +9,22 @@ struct EnAm; typedef void (*EnAmActionFunc)(struct EnAm*, PlayState*); typedef struct EnAm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; - /* 0x01DC */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; - /* 0x0230 */ EnAmActionFunc actionFunc; - /* 0x0234 */ u8 textureBlend; // 0 = statue textures; 255 = enemy textures - /* 0x0236 */ s16 explodeTimer; // timer counting down till armos explodes - /* 0x0238 */ s16 returnHomeTimer; // Timer that counts down till an armos will return to its spawn position - /* 0x023A */ s16 unkFlag; - /* 0x023C */ s16 armosYaw; // Yaw of Armos - /* 0x0240 */ f32 speed; // Hopping speed of Armos - /* 0x0244 */ f32 drawDmgEffAlpha; - /* 0x0248 */ f32 drawDmgEffScale; - /* 0x024C */ Vec3f limbPos[13]; - /* 0x02E8 */ ColliderCylinder enemyCollider; // Collider for when Armos is Hostile - /* 0x0334 */ ColliderCylinder interactCollider; // Collider for when an interactable Armos is docile + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; + /* 0x1DC */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; + /* 0x230 */ EnAmActionFunc actionFunc; + /* 0x234 */ u8 textureBlend; // 0 = statue textures; 255 = enemy textures + /* 0x236 */ s16 explodeTimer; // timer counting down till armos explodes + /* 0x238 */ s16 returnHomeTimer; // Timer that counts down till an armos will return to its spawn position + /* 0x23A */ s16 unkFlag; + /* 0x23C */ s16 armosYaw; // Yaw of Armos + /* 0x240 */ f32 speed; // Hopping speed of Armos + /* 0x244 */ f32 drawDmgEffAlpha; + /* 0x248 */ f32 drawDmgEffScale; + /* 0x24C */ Vec3f limbPos[13]; + /* 0x2E8 */ ColliderCylinder enemyCollider; // Collider for when Armos is Hostile + /* 0x334 */ ColliderCylinder interactCollider; // Collider for when an interactable Armos is docile } EnAm; // size = 0x380 extern const ActorInit En_Am_InitVars; diff --git a/src/overlays/actors/ovl_En_An/z_en_an.h b/src/overlays/actors/ovl_En_An/z_en_an.h index 71eff9d4e..c4d2dd5ae 100644 --- a/src/overlays/actors/ovl_En_An/z_en_an.h +++ b/src/overlays/actors/ovl_En_An/z_en_an.h @@ -8,10 +8,10 @@ struct EnAn; typedef void (*EnAnActionFunc)(struct EnAn*, PlayState*); typedef struct EnAn { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnAnActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x23C]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ EnAnActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x23C]; } EnAn; // size = 0x3C8 extern const ActorInit En_An_InitVars; diff --git a/src/overlays/actors/ovl_En_And/z_en_and.h b/src/overlays/actors/ovl_En_And/z_en_and.h index 680a179da..0ebd1a743 100644 --- a/src/overlays/actors/ovl_En_And/z_en_and.h +++ b/src/overlays/actors/ovl_En_And/z_en_and.h @@ -8,10 +8,10 @@ struct EnAnd; typedef void (*EnAndActionFunc)(struct EnAnd*, PlayState*); typedef struct EnAnd { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnAndActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x188]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ EnAndActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x188]; } EnAnd; // size = 0x314 extern const ActorInit En_And_InitVars; diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c index 3264bd95a..c1cb31614 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -175,7 +175,7 @@ void EnAni_IdleStanding(EnAni* this, PlayState* play) { void EnAni_Talk(EnAni* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Message_GetState(&play->msgCtx) == 2 && play->msgCtx.currentTextId == 0x6DE) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) && play->msgCtx.currentTextId == 0x6DE) { this->actionFunc = EnAni_IdleInPain; } } @@ -219,7 +219,7 @@ void EnAni_FallToGround(EnAni* this, PlayState* play) { // the animation gets cut short, (first 16 frames only) only the landing part is seen Animation_Change(&this->skelAnime, &gAniLandingThenStandingUpAnim, 1.0f, 0.0f, 16.0f, ANIMMODE_ONCE, 0.0f); this->stateFlags |= ANI_STATE_WRITHING; - quakeValue = Quake_Add(play->cameraPtrs[0], 3); + quakeValue = Quake_Add(play->cameraPtrs[CAM_ID_MAIN], 3); Quake_SetSpeed(quakeValue, 0x6978); Quake_SetQuakeValues(quakeValue, 7, 0, 0, 0); Quake_SetCountdown(quakeValue, 0x14); @@ -308,7 +308,7 @@ void EnAni_Update(Actor* thisx, PlayState* play) { } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); - Camera_SetToTrackActor(Play_GetCamera(play, ActorCutscene_GetCurrentCamera(this->actor.cutscene)), + Camera_SetToTrackActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->actor.cutscene)), &this->actor); } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); 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 91c543f7e..3b825641c 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 @@ -118,17 +118,17 @@ void func_809C1158(EnAob01* this, PlayState* play) { } void func_809C11EC(EnAob01* this, PlayState* play) { - s32 unk; + s32 enDgParams; s16 i; func_809C1158(this, play); for (i = 0; i < ARRAY_COUNT(D_809C384C); i++) { - unk = (this->unk_1D8[D_809C384C[i].unk_06]->unk1 << 0xA) | (i << 5); + enDgParams = ENDG_PARAMS(this->unk_1D8[D_809C384C[i].unk_06]->unk1, i); this->unk_3F8[i] = Actor_SpawnAsChildAndCutscene( &play->actorCtx, play, ACTOR_EN_DG, D_809C384C[i].unk_00.x, D_809C384C[i].unk_00.y, D_809C384C[i].unk_00.z, - 0, D_809C384C[i].unk_04 * 182.04445f, 0, unk, 0xFFFF, this->actor.unk20, NULL); + 0, D_809C384C[i].unk_04 * 182.04445f, 0, enDgParams, 0xFFFF, this->actor.unk20, NULL); } } @@ -391,10 +391,10 @@ void func_809C16DC(EnAob01* this, PlayState* play) { case 0x3529: if (this->unk_2D2 & 2) { this->unk_2D2 &= ~2; - func_801159EC(-this->unk_434); + Rupees_ChangeBy(-this->unk_434); func_800B7298(play, NULL, 7); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = func_809C1C9C; return; } @@ -417,18 +417,18 @@ void func_809C1C9C(EnAob01* this, PlayState* play) { this->unk_2D2 |= 0x20; func_800FD750(0x40); play->nextEntranceIndex = 0x7C10; - play->unk_1887F = 0x40; - gSaveContext.nextTransition = 0x40; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_64; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 2; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (this->unk_432 * 8); - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; } } void func_809C1D64(EnAob01* this, PlayState* play) { - u8 temp_v0 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 4) { + if (talkState == TEXT_STATE_CHOICE) { if (Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: @@ -453,9 +453,9 @@ void func_809C1D64(EnAob01* this, PlayState* play) { break; } } - } else if ((temp_v0 == 5) && Message_ShouldAdvance(play)) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_210 = 0; this->actionFunc = func_809C2060; } @@ -521,7 +521,7 @@ void func_809C2060(EnAob01* this, PlayState* play) { } void func_809C21E0(EnAob01* this, PlayState* play) { - u8 sp2F = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 4000, 1); @@ -561,7 +561,7 @@ void func_809C21E0(EnAob01* this, PlayState* play) { } this->unk_2D2 &= ~8; } - } else if (sp2F == 4) { + } else if (talkState == TEXT_STATE_CHOICE) { if (Message_ShouldAdvance(play)) { this->unk_2D2 &= ~0x40; switch (play->msgCtx.choiceIndex) { @@ -577,19 +577,19 @@ void func_809C21E0(EnAob01* this, PlayState* play) { break; } } - } else if (sp2F == 5) { + } else if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { this->unk_2D2 &= ~0x40; if (this->unk_2D2 & 0x10) { this->unk_2D2 &= ~0x10; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = func_809C2060; } else { func_809C16DC(this, play); } } - } else if ((sp2F == 14) && Message_ShouldAdvance(play)) { + } else if ((talkState == TEXT_STATE_14) && Message_ShouldAdvance(play)) { this->unk_2D2 &= ~0x40; this->unk_434 = play->msgCtx.bankRupeesSelected; func_809C16DC(this, play); @@ -674,9 +674,9 @@ void func_809C2788(EnAob01* this, PlayState* play) { if (func_801A8A50(0) != 0x41) { play->nextEntranceIndex = 0x7C10; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 3; - play->unk_1887F = 0x40; - gSaveContext.nextTransition = 3; - play->sceneLoadFlag = 0x14; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionTrigger = TRANS_TRIGGER_START; } } } @@ -711,7 +711,7 @@ void func_809C28B8(EnAob01* this, PlayState* play) { this->unk_210 = 0x352A; this->unk_2D2 |= 0x80; this->unk_434 *= 3; - func_801159EC(this->unk_434); + Rupees_ChangeBy(this->unk_434); play->msgCtx.bankRupees = this->unk_434; break; @@ -719,7 +719,7 @@ void func_809C28B8(EnAob01* this, PlayState* play) { this->unk_210 = 0x352B; this->unk_2D2 |= 0x80; this->unk_434 *= 2; - func_801159EC(this->unk_434); + Rupees_ChangeBy(this->unk_434); play->msgCtx.bankRupees = this->unk_434; break; @@ -727,7 +727,7 @@ void func_809C28B8(EnAob01* this, PlayState* play) { case 4: case 5: this->unk_210 = 0x352C; - func_801159EC(this->unk_434); + Rupees_ChangeBy(this->unk_434); break; default: @@ -746,13 +746,13 @@ void func_809C28B8(EnAob01* this, PlayState* play) { } void func_809C2A64(EnAob01* this, PlayState* play) { - u8 sp2F = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); if (func_809C15BC(this)) { - if ((sp2F == 5) && Message_ShouldAdvance(play)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->unk_434 = 0; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; } if (Actor_HasParent(&this->actor, play)) { @@ -776,9 +776,9 @@ void func_809C2A64(EnAob01* this, PlayState* play) { } void func_809C2BE4(EnAob01* this, PlayState* play) { - u8 temp_v0 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); - if (((temp_v0 == 5) || (temp_v0 == 6)) && Message_ShouldAdvance(play)) { + if (((talkState == TEXT_STATE_5) || (talkState == TEXT_STATE_DONE)) && Message_ShouldAdvance(play)) { if (gSaveContext.save.weekEventReg[63] & 2) { gSaveContext.save.weekEventReg[63] &= (u8)~2; } @@ -805,7 +805,7 @@ void func_809C2C9C(EnAob01* this, PlayState* play) { } void func_809C2D0C(EnAob01* this, PlayState* play) { - u8 sp2F = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 4000, 1); @@ -819,7 +819,7 @@ void func_809C2D0C(EnAob01* this, PlayState* play) { } } - if ((sp2F == 5) && Message_ShouldAdvance(play)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->unk_2D2 &= ~0x40; this->unk_2D2 &= ~0x80; if (this->unk_434 >= 150) { 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 39fdd6167..ab68d8769 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -135,7 +135,7 @@ void EnArrow_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyQuad(play, &this->collider); if ((this->unk_264 != NULL) && (this->unk_264->update != NULL)) { - this->unk_264->flags &= ~0x8000; + this->unk_264->flags &= ~ACTOR_FLAG_8000; } if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6) && (this->actor.child == NULL)) { @@ -389,7 +389,7 @@ void func_8088ACE0(EnArrow* this, PlayState* play) { SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, sp82); Actor_MarkForDeath(&this->actor); } else { - EffectSsHitMark_SpawnCustomScale(play, 0, 150, &this->actor.world.pos); + EffectSsHitmark_SpawnCustomScale(play, 0, 150, &this->actor.world.pos); if (sp50 && (this->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4)) { sp7C = this->collider.base.at; @@ -496,14 +496,14 @@ void func_8088ACE0(EnArrow* this, PlayState* play) { this->unk_264->world.pos.z = ((sp54.z <= sp9C.z) ? 1.0f : -1.0f) + sp9C.z; Math_Vec3f_Diff(&this->unk_264->world.pos, &this->actor.world.pos, &this->unk_268); - this->unk_264->flags &= ~0x8000; + this->unk_264->flags &= ~ACTOR_FLAG_8000; this->unk_264 = NULL; } else { Math_Vec3f_Sum(&this->actor.world.pos, &this->unk_268, &this->unk_264->world.pos); } if ((this->unk_262 != 0) && (this->unk_264 != NULL)) { - this->unk_264->flags &= ~0x8000; + this->unk_264->flags &= ~ACTOR_FLAG_8000; this->unk_264 = NULL; } } else { @@ -548,7 +548,7 @@ void EnArrow_Update(Actor* thisx, PlayState* play) { if ((this->unk_263 != 0) || ((this->actor.params >= ENARROW_0) && ((this->actor.params == ENARROW_7) || (player->unk_D57 != 0))) || - !func_80123358(play, player)) { + !Player_InBlockingCsMode(play, player)) { this->actionFunc(this, play); } @@ -588,7 +588,7 @@ void func_8088B88C(PlayState* play, EnArrow* this, EnArrowUnkStruct* arg2) { Matrix_MultVec3f(&sp4C[1], &sp34); if (this->actor.params < ENARROW_8) { sp30 = this->actor.params < ENARROW_6; - if (this->unk_264 == 0) { + if (this->unk_264 == NULL) { sp30 &= func_80126440(play, &this->collider, &this->unk_244, &sp40, &sp34); } else if (sp30 && (sp40.x == this->unk_244.tip.x) && (sp40.y == this->unk_244.tip.y) && (sp40.z == this->unk_244.tip.z) && (sp34.x == this->unk_244.base.x) && diff --git a/src/overlays/actors/ovl_En_Az/z_en_az.h b/src/overlays/actors/ovl_En_Az/z_en_az.h index ee141bfb3..5c302c6f3 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.h +++ b/src/overlays/actors/ovl_En_Az/z_en_az.h @@ -8,9 +8,9 @@ struct EnAz; typedef void (*EnAzActionFunc)(struct EnAz*, PlayState*); typedef struct EnAz { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnAzActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x290]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnAzActionFunc actionFunc; + /* 0x148 */ char unk_148[0x290]; } EnAz; // size = 0x3D8 extern const ActorInit En_Az_InitVars; diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index c7386e403..b96fb35c0 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -5,29 +5,50 @@ */ #include "z_en_baba.h" -#include "overlays/actors/ovl_En_Ossan/z_en_ossan.h" -#include "objects/object_bba/object_bba.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBaba*)thisx) +#define BOMB_SHOP_LADY_STATE_END_CONVERSATION (1 << 0) +#define BOMB_SHOP_LADY_STATE_VISIBLE (1 << 1) +#define BOMB_SHOP_LADY_STATE_KNOCKED_OVER (1 << 2) // Don't track player +#define BOMB_SHOP_LADY_STATE_AUTOTALK (1 << 3) +#define BOMB_SHOP_LADY_STATE_GIVE_BLAST_MASK (1 << 5) +#define BOMB_SHOP_LADY_STATE_GAVE_BLAST_MASK (1 << 6) +#define BOMB_SHOP_LADY_STATE_DRAW_SHADOW (1 << 7) + void EnBaba_Init(Actor* thisx, PlayState* play); void EnBaba_Destroy(Actor* thisx, PlayState* play); void EnBaba_Update(Actor* thisx, PlayState* play); void EnBaba_Draw(Actor* thisx, PlayState* play); -void func_80BA9480(EnBaba* this, PlayState* play); -void func_80BA9758(EnBaba* this, PlayState* play); -void func_80BA9848(EnBaba* this, PlayState* play); -void func_80BA98EC(EnBaba* this, PlayState* play); -void func_80BA9AB8(EnBaba* this, PlayState* play); -void func_80BA9B24(EnBaba* this, PlayState* play); -void func_80BA9B80(EnBaba* this, PlayState* play); -void func_80BA9CD4(EnBaba* this, PlayState* play); -void func_80BA9E00(EnBaba* this, PlayState* play); -void func_80BA9E10(EnBaba* this, PlayState* play); -void func_80BA9E48(EnBaba* this, PlayState* play); +void EnBaba_FinishInit(EnBaba* this, PlayState* play); +void EnBaba_Idle(EnBaba* this, PlayState* play); +void EnBaba_FollowSchedule_Talk(EnBaba* this, PlayState* play); +void EnBaba_Talk(EnBaba* this, PlayState* play); +void EnBaba_GiveBlastMask(EnBaba* this, PlayState* play); +void EnBaba_GaveBlastMask(EnBaba* this, PlayState* play); +void EnBaba_FollowSchedule(EnBaba* this, PlayState* play); +void EnBaba_KnockedOver(EnBaba* this, PlayState* play); +void EnBaba_DoNothing(EnBaba* this, PlayState* play); +void EnBaba_Walk(EnBaba* this, PlayState* play); +void EnBaba_FaceForward(EnBaba* this, PlayState* play); + +typedef enum { + /* 0 */ BOMB_SHOP_LADY_ANIM_IDLE_HOLDING_BAG, + /* 1 */ BOMB_SHOP_LADY_ANIM_IDLE, + /* 2 */ BOMB_SHOP_LADY_ANIM_WALKING_HOLDING_BAG, + /* 3 */ BOMB_SHOP_LADY_ANIM_KNOCKED_OVER, + /* 4 */ BOMB_SHOP_LADY_ANIM_LYING_DOWN, + /* 5 */ BOMB_SHOP_LADY_ANIM_SWAY +} BombShopLadyAnimation; + +typedef enum { + /* 0 */ BOMB_SHOP_LADY_SCH_NONE, + /* 1 */ BOMB_SHOP_LADY_SCH_KNOCKED_OVER, + /* 2 */ BOMB_SHOP_LADY_SCH_FOLLOW_TIME_PATH +} BombShopLadyScheduleResult; const ActorInit En_Baba_InitVars = { ACTOR_EN_BABA, @@ -47,7 +68,7 @@ static AnimationInfo sAnimations[] = { { &gBbaWalkingHoldingBagAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, { &gBbaKnockedOverAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, { &gBbaLyingDownAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &gBbaWalkingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gBbaSwayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -107,19 +128,19 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static u8 D_80BAA488[] = { +static u8 sSchedule[] = { /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x1D - 0x04), /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0x1C - 0x08), /* 0x08 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 30, 0x16 - 0x0E), /* 0x0E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 30, 0x15 - 0x12), - /* 0x12 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x12 */ SCHEDULE_CMD_RET_VAL_L(BOMB_SHOP_LADY_SCH_KNOCKED_OVER), /* 0x15 */ SCHEDULE_CMD_RET_NONE(), - /* 0x16 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 30, 2), + /* 0x16 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 30, BOMB_SHOP_LADY_SCH_FOLLOW_TIME_PATH), /* 0x1C */ SCHEDULE_CMD_RET_NONE(), /* 0x1D */ SCHEDULE_CMD_RET_NONE(), }; -s32 D_80BAA4A8[] = { -1, -1, 0 }; +static s32 sSearchTimePathLimit[] = { -1, -1, 0 }; static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, @@ -128,142 +149,164 @@ static TrackOptionsSet sTrackOptions = { { 0x1770, 4, 1, 6 }, }; -s32 func_80BA8820(EnBaba* this, PlayState* play) { - this->unk_144 = (EnOssan*)SubS_FindActor(play, &this->unk_144->actor, ACTORCAT_NPC, ACTOR_EN_OSSAN); +s32 EnBaba_FindBombShopkeeper(EnBaba* this, PlayState* play) { + //! The bomb shopkeeper is an EnSob1, but initalizes itself with id `ACTOR_EN_OSSAN` + //! Note if there are other `EnOssan` actors, it may find that instance instead + //! in which case `EnSob1` struct acceses would be incorrect + this->bombShopkeeper = (EnSob1*)SubS_FindActor(play, &this->bombShopkeeper->actor, ACTORCAT_NPC, ACTOR_EN_OSSAN); - if (this->unk_144 != NULL) { + if (this->bombShopkeeper != NULL) { return true; } return false; } -void func_80BA886C(EnBaba* this, PlayState* play) { +void EnBaba_HandleConversation(EnBaba* this, PlayState* play) { Player* player = GET_PLAYER(play); - switch (this->unk_1E0) { + switch (this->textId) { case 0: - if (this->unk_40A & 8) { + if (this->stateFlags & BOMB_SHOP_LADY_STATE_AUTOTALK) { if (gSaveContext.save.weekEventReg[33] & 8) { - this->unk_1E0 = 0x2A34; + // Thanks. Can stock Bomb Bags tomorrow + this->textId = 0x2A34; break; } if (gSaveContext.save.weekEventReg[79] & 0x40) { - this->unk_40A |= 1; - this->unk_1E0 = 0x2A33; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; + // Oh my, learned my lesson. Can't stock Bomb Bags tomorrow + this->textId = 0x2A33; break; } - this->unk_40A |= 1; - this->unk_1E0 = 0x2A32; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; + // Can't stock Bomb Bags tomorrow + this->textId = 0x2A32; break; } else if (player->transformation == PLAYER_FORM_DEKU) { if (!(gSaveContext.save.weekEventReg[79] & 0x20)) { gSaveContext.save.weekEventReg[79] |= 0x20; - this->unk_40A |= 1; - this->unk_1E0 = 0x2A37; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; + // Small customer, use bombs as adult + this->textId = 0x2A37; break; } else { - this->unk_40A |= 1; - this->unk_1E0 = 0x2A38; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; + // use bombs as adult + this->textId = 0x2A38; } break; } else if (!(gSaveContext.save.weekEventReg[33] & 8)) { if (!(gSaveContext.save.weekEventReg[73] & 1)) { - this->unk_1E0 = 0x660; + // Thought could sell Big Bomb Bags + this->textId = 0x660; break; } - this->unk_1E0 = 0x662; + // Can't judge people + this->textId = 0x662; break; } else { if (!(gSaveContext.save.weekEventReg[73] & 2)) { - this->unk_1E0 = 0x65A; + // Someone helped me out + this->textId = 0x65A; break; } - this->unk_1E0 = 0x65E; + // Buy Big Bomb Bag + this->textId = 0x65E; break; } break; case 0x660: - Actor_ChangeFocus(&this->actor, play, &this->unk_144->actor); - this->unk_1E0 = 0x661; + Actor_ChangeFocus(&this->actor, play, &this->bombShopkeeper->actor); + // Don't go by yourself + this->textId = 0x661; break; case 0x661: - Actor_ChangeFocus(&this->unk_144->actor, play, &this->actor); - this->unk_1E0 = 0x662; + Actor_ChangeFocus(&this->bombShopkeeper->actor, play, &this->actor); + // Can't judge people + this->textId = 0x662; break; case 0x662: - Actor_ChangeFocus(&this->actor, play, &this->unk_144->actor); - this->unk_1E0 = 0x663; + Actor_ChangeFocus(&this->actor, play, &this->bombShopkeeper->actor); + // I'll go next time + this->textId = 0x663; gSaveContext.save.weekEventReg[73] |= 1; - this->unk_40A |= 1; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; break; case 0x65A: - Actor_ChangeFocus(&this->actor, play, &this->unk_144->actor); - this->unk_1E0 = 0x65B; + Actor_ChangeFocus(&this->actor, play, &this->bombShopkeeper->actor); + // Don't pick up Bomb bags at night + this->textId = 0x65B; break; case 0x65B: - Actor_ChangeFocus(&this->unk_144->actor, play, &this->actor); - this->unk_1E0 = 0x65C; + Actor_ChangeFocus(&this->bombShopkeeper->actor, play, &this->actor); + // Lifelong dream to sell Big Bomb Bags + this->textId = 0x65C; break; case 0x65C: - Actor_ChangeFocus(&this->actor, play, &this->unk_144->actor); - this->unk_1E0 = 0x65D; + Actor_ChangeFocus(&this->actor, play, &this->bombShopkeeper->actor); + // I worry about you + this->textId = 0x65D; gSaveContext.save.weekEventReg[73] |= 2; - this->unk_40A |= 1; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; break; case 0x65E: - Actor_ChangeFocus(&this->actor, play, &this->unk_144->actor); - this->unk_1E0 = 0x65F; - this->unk_40A |= 1; + Actor_ChangeFocus(&this->actor, play, &this->bombShopkeeper->actor); + // I worry about you + this->textId = 0x65F; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; break; case 0x2A34: if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) { - this->unk_40A |= 1; - this->unk_1E0 = 0x2A36; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; + // Thank you + this->textId = 0x2A36; break; } - this->unk_40A |= 0x20; - this->unk_1E0 = 0x2A35; + this->stateFlags |= BOMB_SHOP_LADY_STATE_GIVE_BLAST_MASK; + // It's a dangerous mask + this->textId = 0x2A35; break; case 0x2A35: - this->unk_40A |= 1; - this->unk_1E0 = 0x2A36; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; + // Thank you + this->textId = 0x2A36; break; case 0x2A30: case 0x2A31: - this->unk_40A |= 1; + this->stateFlags |= BOMB_SHOP_LADY_STATE_END_CONVERSATION; break; } - Message_StartTextbox(play, this->unk_1E0, &this->actor); - if (this->unk_40A & 1) { - if (this->unk_40A & 0x40) { - this->unk_40A &= ~0x40; + Message_StartTextbox(play, this->textId, &this->actor); + if (this->stateFlags & BOMB_SHOP_LADY_STATE_END_CONVERSATION) { + if (this->stateFlags & BOMB_SHOP_LADY_STATE_GAVE_BLAST_MASK) { + this->stateFlags &= ~BOMB_SHOP_LADY_STATE_GAVE_BLAST_MASK; func_80151BB4(play, 0x33); } func_80151BB4(play, 4); } } -void func_80BA8C4C(PlayState* play, u16 nextEntrance) { +void EnBaba_TriggerTransition(PlayState* play, u16 nextEntrance) { play->nextEntranceIndex = nextEntrance; - play->unk_1887F = 0x40; - gSaveContext.nextTransition = 0x40; - play->sceneLoadFlag = 0x14; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_64; + play->transitionTrigger = TRANS_TRIGGER_START; } -void func_80BA8C90(EnBaba* this, PlayState* play) { +void EnBaba_UpdateCollider(EnBaba* this, PlayState* play) { this->collider.dim.pos.x = this->actor.world.pos.x + 5.0f; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z + 22.0f; @@ -272,30 +315,31 @@ void func_80BA8C90(EnBaba* this, PlayState* play) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 func_80BA8D2C(EnBaba* this, f32 arg1) { - s16 sp3E; - s32 ret = false; - Vec3f sp2C; +s32 EnBaba_MoveForward(EnBaba* this, f32 speedTarget) { + s16 rotStep; + s32 reachedEnd = false; + Vec3f point; - Math_SmoothStepToF(&this->actor.speedXZ, arg1, 0.4f, 1000.0f, 0.0f); - sp3E = this->actor.speedXZ * 400.0f; - if (SubS_CopyPointFromPath(this->path, this->unk_1E8, &sp2C) && SubS_MoveActorToPoint(&this->actor, &sp2C, sp3E)) { - this->unk_1E8++; - if (this->unk_1E8 >= this->path->count) { - ret = true; + Math_SmoothStepToF(&this->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); + rotStep = this->actor.speedXZ * 400.0f; + if (SubS_CopyPointFromPath(this->path, this->waypoint, &point) && + SubS_MoveActorToPoint(&this->actor, &point, rotStep)) { + this->waypoint++; + if (this->waypoint >= this->path->count) { + reachedEnd = true; } } - return ret; + return reachedEnd; } -void func_80BA8DF4(EnBaba* this, PlayState* play) { +void EnBaba_UpdateModel(EnBaba* this, PlayState* play) { Player* player = GET_PLAYER(play); Vec3f point; SkelAnime_Update(&this->skelAnime); if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer) && - !(this->unk_40A & 4)) { + !(this->stateFlags & BOMB_SHOP_LADY_STATE_KNOCKED_OVER)) { point.x = player->actor.world.pos.x; point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; @@ -311,214 +355,223 @@ void func_80BA8DF4(EnBaba* this, PlayState* play) { Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } - SubS_FillLimbRotTables(play, this->unk_302, this->unk_326, ARRAY_COUNT(this->unk_302)); + SubS_FillLimbRotTables(play, this->limbRotTableY, this->limbRotTableZ, ARRAY_COUNT(this->limbRotTableY)); - if (this->unk_40A & 2) { - func_80BA8C90(this, play); + if (this->stateFlags & BOMB_SHOP_LADY_STATE_VISIBLE) { + EnBaba_UpdateCollider(this, play); } } -s32 func_80BA8F88(EnBaba* this, PlayState* play, ScheduleResult* arg2) { - u16 sp26 = SCHEDULE_TIME_NOW; - u16 temp; - u8 sp23 = ENBABA_GET_3F00(&this->actor); +s32 EnBaba_InitTimePath(EnBaba* this, PlayState* play, ScheduleOutput* scheduleOutput) { + u16 now = SCHEDULE_TIME_NOW; + u16 startTime; + u8 pathIndex = BOMB_SHOP_LADY_GET_PATH_INDEX(&this->actor); + u16 numWaypoints; - if (D_80BAA4A8[arg2->result] >= 0) { - this->timePath = SubS_GetAdditionalPath(play, sp23, D_80BAA4A8[arg2->result]); + if (sSearchTimePathLimit[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, pathIndex, sSearchTimePathLimit[scheduleOutput->result]); } if (this->timePath == NULL) { return false; } - if ((this->unk_434 != 0) && (this->timePathTimeSpeed >= 0)) { - temp = sp26; + if ((this->scheduleResult != BOMB_SHOP_LADY_SCH_NONE) && (this->timePathTimeSpeed >= 0)) { + startTime = now; } else { - temp = arg2->time0; + startTime = scheduleOutput->time0; } - if (arg2->time1 < temp) { - this->timePathTotalTime = (temp - arg2->time1) + 0xFFFF; + if (scheduleOutput->time1 < startTime) { + this->timePathTotalTime = (startTime - scheduleOutput->time1) + (DAY_LENGTH - 1); } else { - this->timePathTotalTime = arg2->time1 - temp; + this->timePathTotalTime = scheduleOutput->time1 - startTime; } - this->timePathElapsedTime = sp26 - temp; - temp = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); - this->timePathWaypointTime = this->timePathTotalTime / temp; - this->unk_438 = 0; + this->timePathElapsedTime = now - startTime; + + numWaypoints = startTime = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / numWaypoints; + + this->timePathIsSetup = false; this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); - this->unk_43C = 0; + this->timePathHasReachedEnd = false; + return true; } -s32 func_80BA9110(EnBaba* this, PlayState* play, ScheduleResult* arg2) { - s32 ret; +s32 EnBaba_ProcessScheduleOutput(EnBaba* this, PlayState* play, ScheduleOutput* scheduleOutput) { + s32 success; - switch (arg2->result) { + switch (scheduleOutput->result) { default: - ret = false; + success = false; break; - case 2: - ret = func_80BA8F88(this, play, arg2); + case BOMB_SHOP_LADY_SCH_FOLLOW_TIME_PATH: + success = EnBaba_InitTimePath(this, play, scheduleOutput); break; - case 1: - ret = true; + case BOMB_SHOP_LADY_SCH_KNOCKED_OVER: + success = true; break; } - return ret; + return success; } -s32 func_80BA9160(EnBaba* this, PlayState* play) { - f32 knots[265]; - Vec3f sp70; - Vec3f sp64; - Vec3f timePathTargetPos; - s32 sp54 = 0; - s32 sp50 = 0; +s32 EnBaba_FollowTimePath(EnBaba* this, PlayState* play) { + f32 weightArray[265]; + Vec3f worldPos; + Vec3f timePathPointNew; // used to compute yaw after update + Vec3f timePathPoint; // used in setup and to store a backup before update + s32 prevTimePathElapsedTime = 0; + s32 prevTimePathWaypoint = 0; s32 pad; - SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); + SubS_TimePathing_FillKnots(weightArray, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); - if (this->unk_438 == 0) { - timePathTargetPos = gZeroVec3f; + if (!this->timePathIsSetup) { + timePathPoint = gZeroVec3f; SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, - this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, - &timePathTargetPos, this->timePathTimeSpeed); - SubS_TimePathing_ComputeInitialY(play, this->timePath, this->timePathWaypoint, &timePathTargetPos); - this->actor.world.pos.y = timePathTargetPos.y; - this->unk_438 = 1; + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, + weightArray, &timePathPoint, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(play, this->timePath, this->timePathWaypoint, &timePathPoint); + this->actor.world.pos.y = timePathPoint.y; + this->timePathIsSetup = true; } else { - timePathTargetPos = this->timePathTargetPos; + timePathPoint = this->timePathPoint; } - this->actor.world.pos.x = timePathTargetPos.x; - this->actor.world.pos.z = timePathTargetPos.z; + this->actor.world.pos.x = timePathPoint.x; + this->actor.world.pos.z = timePathPoint.z; if (SubS_InCsMode(play)) { - sp54 = this->timePathElapsedTime; - sp50 = this->timePathWaypoint; - timePathTargetPos = this->actor.world.pos; + prevTimePathElapsedTime = this->timePathElapsedTime; + prevTimePathWaypoint = this->timePathWaypoint; + timePathPoint = this->actor.world.pos; } - this->timePathTargetPos = gZeroVec3f; + this->timePathPoint = gZeroVec3f; if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, - this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, - &this->timePathTargetPos, this->timePathTimeSpeed)) { - this->unk_43C = 1; + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, + weightArray, &this->timePathPoint, this->timePathTimeSpeed)) { + this->timePathHasReachedEnd = true; } else { - sp70 = this->actor.world.pos; - sp64 = this->timePathTargetPos; - this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); + worldPos = this->actor.world.pos; + timePathPointNew = this->timePathPoint; + this->actor.world.rot.y = Math_Vec3f_Yaw(&worldPos, &timePathPointNew); } if (SubS_InCsMode(play)) { - this->timePathElapsedTime = sp54; - this->timePathWaypoint = sp50; - this->timePathTargetPos = timePathTargetPos; + this->timePathElapsedTime = prevTimePathElapsedTime; + this->timePathWaypoint = prevTimePathWaypoint; + this->timePathPoint = timePathPoint; } return false; } -void func_80BA93AC(EnBaba* this, PlayState* play) { - if (this->unk_434 != 1) { - if (this->unk_434 == 2) { +void EnBaba_HandleSchedule(EnBaba* this, PlayState* play) { + switch (this->scheduleResult) { + case BOMB_SHOP_LADY_SCH_FOLLOW_TIME_PATH: gSaveContext.save.weekEventReg[58] |= 0x40; - this->unk_40A |= 2; - func_80BA9160(this, play); - } - } else { - this->unk_40C = 3; - this->unk_1E0 = 10800; - this->actor.speedXZ = 0.0f; - Enemy_StartFinishingBlow(play, &this->actor); - this->unk_40A |= 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_40C); - this->actionFunc = func_80BA9CD4; + this->stateFlags |= BOMB_SHOP_LADY_STATE_VISIBLE; + EnBaba_FollowTimePath(this, play); + break; + + case BOMB_SHOP_LADY_SCH_KNOCKED_OVER: + this->animIndex = BOMB_SHOP_LADY_ANIM_KNOCKED_OVER; + // Ouch + this->textId = 0x2A30; + this->actor.speedXZ = 0.0f; + Enemy_StartFinishingBlow(play, &this->actor); + this->stateFlags |= BOMB_SHOP_LADY_STATE_KNOCKED_OVER; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animIndex); + this->actionFunc = EnBaba_KnockedOver; + break; } Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 4, 0x1554); } -void func_80BA9480(EnBaba* this, PlayState* play) { +void EnBaba_FinishInit(EnBaba* this, PlayState* play) { SkelAnime_InitFlex(play, &this->skelAnime, &gBbaSkel, &gBbaWalkingHoldingBagAnim, this->jointTable, - this->morphTable, 0x12); + this->morphTable, BBA_LIMB_MAX); this->actor.draw = EnBaba_Draw; - this->unk_40A |= 0x80; + this->stateFlags |= BOMB_SHOP_LADY_STATE_DRAW_SHADOW; this->actor.flags |= ACTOR_FLAG_1; if (play->sceneNum == SCENE_BOMYA) { - this->unk_40A |= 2; - this->unk_40C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); - this->actionFunc = func_80BA9758; + this->stateFlags |= BOMB_SHOP_LADY_STATE_VISIBLE; + this->animIndex = BOMB_SHOP_LADY_ANIM_IDLE; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animIndex); + this->actionFunc = EnBaba_Idle; } else if (play->sceneNum == SCENE_BACKTOWN) { - if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_0) && (gSaveContext.save.entranceIndex != 0xD670) && - ((ENBABA_GET_3F00(&this->actor)) != ENBABA_3F00_3F)) { + if ((BOMB_SHOP_LADY_GET_TYPE(&this->actor) == BOMB_SHOP_LADY_TYPE_FOLLOW_SCHEDULE) && + (gSaveContext.save.entranceIndex != 0xD670) && (BOMB_SHOP_LADY_GET_PATH_INDEX(&this->actor) != 0x3F)) { if ((gSaveContext.save.weekEventReg[58] & 0x40) || - (!(gSaveContext.save.time < CLOCK_TIME(0, 20)) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { + (gSaveContext.save.time >= CLOCK_TIME(0, 20) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { Actor_MarkForDeath(&this->actor); return; } - this->unk_404 = 50; - this->unk_40C = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_80BA9B80; - } else if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_1) && (gSaveContext.save.entranceIndex == 0xD670)) { + this->sakonDeadTimer = 50; + this->animIndex = BOMB_SHOP_LADY_ANIM_WALKING_HOLDING_BAG; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animIndex); + this->actionFunc = EnBaba_FollowSchedule; + } else if ((BOMB_SHOP_LADY_GET_TYPE(&this->actor) == BOMB_SHOP_LADY_TYPE_IDLE) && + (gSaveContext.save.entranceIndex == 0xD670)) { if (gSaveContext.save.weekEventReg[81] & 2) { Actor_MarkForDeath(&this->actor); return; } - this->unk_40A |= 2; + this->stateFlags |= BOMB_SHOP_LADY_STATE_VISIBLE; if (gSaveContext.save.weekEventReg[33] & 8) { - this->unk_40C = 0; + this->animIndex = BOMB_SHOP_LADY_ANIM_IDLE_HOLDING_BAG; } else { - this->unk_40C = 1; + this->animIndex = BOMB_SHOP_LADY_ANIM_IDLE; } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_40C); - this->unk_40A |= 8; - this->actionFunc = func_80BA9758; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animIndex); + this->stateFlags |= BOMB_SHOP_LADY_STATE_AUTOTALK; + this->actionFunc = EnBaba_Idle; } else { Actor_MarkForDeath(&this->actor); return; } } else { - this->unk_40A |= 2; - if (ENBABA_GET_C000(&this->actor) == ENBABA_C000_2) { + this->stateFlags |= BOMB_SHOP_LADY_STATE_VISIBLE; + if (BOMB_SHOP_LADY_GET_TYPE(&this->actor) == BOMB_SHOP_LADY_TYPE_SWAY) { this->actor.flags &= ~ACTOR_FLAG_1; - this->unk_40C = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); - this->actionFunc = func_80BA9E00; - } else if ((ENBABA_GET_3F00(&this->actor)) != ENBABA_3F00_3F) { - this->unk_40C = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_80BA9E10; + this->animIndex = BOMB_SHOP_LADY_ANIM_SWAY; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animIndex); + this->actionFunc = EnBaba_DoNothing; + } else if (BOMB_SHOP_LADY_GET_PATH_INDEX(&this->actor) != 0x3F) { + this->animIndex = BOMB_SHOP_LADY_ANIM_WALKING_HOLDING_BAG; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animIndex); + this->actionFunc = EnBaba_Walk; } else { - this->unk_40C = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); - this->actionFunc = func_80BA9E48; + this->animIndex = BOMB_SHOP_LADY_ANIM_IDLE_HOLDING_BAG; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animIndex); + this->actionFunc = EnBaba_FaceForward; } } } -void func_80BA9758(EnBaba* this, PlayState* play) { - if ((this->unk_40A & 8) || (this->unk_144 != NULL) || func_80BA8820(this, play)) { +void EnBaba_Idle(EnBaba* this, PlayState* play) { + if ((this->stateFlags & BOMB_SHOP_LADY_STATE_AUTOTALK) || (this->bombShopkeeper != NULL) || + EnBaba_FindBombShopkeeper(this, play)) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - func_80BA886C(this, play); - if (this->unk_40A & 8) { + EnBaba_HandleConversation(this, play); + if (this->stateFlags & BOMB_SHOP_LADY_STATE_AUTOTALK) { this->actor.flags &= ~ACTOR_FLAG_10000; } - this->actionFunc = func_80BA98EC; + this->actionFunc = EnBaba_Talk; } else if (this->actor.xzDistToPlayer < 100.0f) { - if (this->unk_40A & 8) { + if (this->stateFlags & BOMB_SHOP_LADY_STATE_AUTOTALK) { this->actor.flags |= ACTOR_FLAG_10000; } func_800B8614(&this->actor, play, 100.0f); @@ -526,99 +579,100 @@ void func_80BA9758(EnBaba* this, PlayState* play) { } } -void func_80BA9848(EnBaba* this, PlayState* play) { - u8 temp_v0 = Message_GetState(&play->msgCtx); +void EnBaba_FollowSchedule_Talk(EnBaba* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (((temp_v0 == 5) || (temp_v0 == 6)) && Message_ShouldAdvance(play)) { + if (((talkState == TEXT_STATE_5) || (talkState == TEXT_STATE_DONE)) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; - this->actionFunc = func_80BA9B80; + play->msgCtx.stateTimer = 4; + this->actionFunc = EnBaba_FollowSchedule; } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); } -void func_80BA98EC(EnBaba* this, PlayState* play) { - u8 temp_v0 = Message_GetState(&play->msgCtx); +void EnBaba_Talk(EnBaba* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 5) { + if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { - if (this->unk_40A & 1) { - this->unk_40A &= ~1; + if (this->stateFlags & BOMB_SHOP_LADY_STATE_END_CONVERSATION) { + this->stateFlags &= ~BOMB_SHOP_LADY_STATE_END_CONVERSATION; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; - if (this->unk_40A & 8) { + play->msgCtx.stateTimer = 4; + if (this->stateFlags & BOMB_SHOP_LADY_STATE_AUTOTALK) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (play->msgCtx.unk120B1 == 0) { gSaveContext.save.weekEventReg[81] |= 2; - func_80BA8C4C(play, 0xD670); + EnBaba_TriggerTransition(play, 0xD670); return; } } else { gSaveContext.save.weekEventReg[81] |= 2; - func_80BA8C4C(play, 0xD670); + EnBaba_TriggerTransition(play, 0xD670); } } else { - this->unk_1E0 = 0; - this->actionFunc = func_80BA9758; + this->textId = 0; + this->actionFunc = EnBaba_Idle; } - } else if (this->unk_40A & 0x20) { - this->unk_40A &= ~0x20; + } else if (this->stateFlags & BOMB_SHOP_LADY_STATE_GIVE_BLAST_MASK) { + this->stateFlags &= ~BOMB_SHOP_LADY_STATE_GIVE_BLAST_MASK; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; - this->actionFunc = func_80BA9AB8; + play->msgCtx.stateTimer = 4; + this->actionFunc = EnBaba_GiveBlastMask; } else { - func_80BA886C(this, play); + EnBaba_HandleConversation(this, play); } } - } else if (temp_v0 == 6) { + } else if (talkState == TEXT_STATE_DONE) { if (Message_ShouldAdvance(play) && (play->msgCtx.unk120B1 == 0)) { gSaveContext.save.weekEventReg[81] |= 2; - func_80BA8C4C(play, 0xD670); + EnBaba_TriggerTransition(play, 0xD670); } } } -void func_80BA9AB8(EnBaba* this, PlayState* play) { +void EnBaba_GiveBlastMask(EnBaba* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; - this->unk_40A |= 0x40; - this->actionFunc = func_80BA9B24; + this->stateFlags |= BOMB_SHOP_LADY_STATE_GAVE_BLAST_MASK; + this->actionFunc = EnBaba_GaveBlastMask; } else { Actor_PickUp(&this->actor, play, GI_MASK_BLAST, 300.0f, 300.0f); } } -void func_80BA9B24(EnBaba* this, PlayState* play) { +void EnBaba_GaveBlastMask(EnBaba* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - func_80BA886C(this, play); - this->actionFunc = func_80BA98EC; + EnBaba_HandleConversation(this, play); + this->actionFunc = EnBaba_Talk; } else { - func_800B85E0(&this->actor, play, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, EXCH_ITEM_MINUS1); } } -void func_80BA9B80(EnBaba* this, PlayState* play) { - ScheduleResult sp20; +void EnBaba_FollowSchedule(EnBaba* this, PlayState* play) { + ScheduleOutput scheduleOutput; this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(play, D_80BAA488, &sp20) || - ((this->unk_434 != sp20.result) && !func_80BA9110(this, play, &sp20))) { - this->unk_40A &= ~0x80; + if (!Schedule_RunScript(play, sSchedule, &scheduleOutput) || + ((this->scheduleResult != scheduleOutput.result) && + !EnBaba_ProcessScheduleOutput(this, play, &scheduleOutput))) { + this->stateFlags &= ~BOMB_SHOP_LADY_STATE_DRAW_SHADOW; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.result = false; + scheduleOutput.result = BOMB_SHOP_LADY_SCH_NONE; } else { - this->unk_40A |= 0x80; + this->stateFlags |= BOMB_SHOP_LADY_STATE_DRAW_SHADOW; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_434 = sp20.result; + this->scheduleResult = scheduleOutput.result; - func_80BA93AC(this, play); + EnBaba_HandleSchedule(this, play); - if (this->unk_40A & 2) { + if (this->stateFlags & BOMB_SHOP_LADY_STATE_VISIBLE) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { Message_StartTextbox(play, 0x2A39, &this->actor); // "I'm sorry" - this->actionFunc = func_80BA9848; + this->actionFunc = EnBaba_FollowSchedule_Talk; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, play); } @@ -626,42 +680,42 @@ void func_80BA9B80(EnBaba* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); } -void func_80BA9CD4(EnBaba* this, PlayState* play) { - s16 sp2E = this->skelAnime.curFrame; - s16 sp2C = Animation_GetLastFrame(sAnimations[this->unk_40C].animation); +void EnBaba_KnockedOver(EnBaba* this, PlayState* play) { + s16 curFrame = this->skelAnime.curFrame; + s16 endFrame = Animation_GetLastFrame(sAnimations[this->animIndex].animation); this->collider.dim.height = 37; this->collider.dim.radius = 23; - if (this->unk_40C == 3) { + if (this->animIndex == BOMB_SHOP_LADY_ANIM_KNOCKED_OVER) { if (Animation_OnFrame(&this->skelAnime, 0.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_BBVO00); } - if (sp2E == sp2C) { - this->unk_40C = 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + if (curFrame == endFrame) { + this->animIndex = BOMB_SHOP_LADY_ANIM_LYING_DOWN; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animIndex); } } else { - if ((gSaveContext.save.weekEventReg[79] & 0x40) && (DECR(this->unk_404) == 0)) { + if ((gSaveContext.save.weekEventReg[79] & 0x40) && (DECR(this->sakonDeadTimer) == 0)) { Audio_QueueSeqCmd(0x101400FF); - func_80BA8C4C(play, 0xD670); + EnBaba_TriggerTransition(play, 0xD670); } else { Actor_MoveWithGravity(&this->actor); } } } -void func_80BA9E00(EnBaba* this, PlayState* play) { +void EnBaba_DoNothing(EnBaba* this, PlayState* play) { } -void func_80BA9E10(EnBaba* this, PlayState* play) { - if (func_80BA8D2C(this, 1.0f)) { - this->unk_1E8 = 0; +void EnBaba_Walk(EnBaba* this, PlayState* play) { + if (EnBaba_MoveForward(this, 1.0f)) { + this->waypoint = 0; } } -void func_80BA9E48(EnBaba* this, PlayState* play) { +void EnBaba_FaceForward(EnBaba* this, PlayState* play) { this->actor.shape.rot = this->actor.world.rot; } @@ -673,13 +727,13 @@ void EnBaba_Init(Actor* thisx, PlayState* play) { Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->path = SubS_GetPathByIndex(play, ENBABA_GET_3F00(&this->actor), ENBABA_3F00_3F); + this->path = SubS_GetPathByIndex(play, BOMB_SHOP_LADY_GET_PATH_INDEX(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 0; this->actor.gravity = -4.0f; - this->actionFunc = func_80BA9480; + this->actionFunc = EnBaba_FinishInit; } void EnBaba_Destroy(Actor* thisx, PlayState* play) { @@ -694,46 +748,48 @@ void EnBaba_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); - func_80BA8DF4(this, play); + EnBaba_UpdateModel(this, play); } s32 EnBaba_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnBaba* this = THIS; - if (limbIndex == 6) { + if (limbIndex == BBA_LIMB_NECK) { Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); Matrix_RotateZS(-this->headRot.x, MTXMODE_APPLY); Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } - if (limbIndex == 5) { + if (limbIndex == BBA_LIMB_UPPER_ROOT) { Matrix_RotateXS(-this->torsoRot.y, MTXMODE_APPLY); Matrix_RotateZS(-this->torsoRot.x, MTXMODE_APPLY); } - if ((limbIndex == 6) && (this->unk_1E2 != 0) && ((play->state.frames % 2) == 0)) { + if ((limbIndex == BBA_LIMB_NECK) && (this->inMsgState3 != 0) && ((play->state.frames % 2) == 0)) { Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); } - if ((limbIndex == 5) || (limbIndex == 10) || (limbIndex == 14)) { - rot->y += (s16)(Math_SinS(this->unk_302[limbIndex]) * 200.0f); - rot->z += (s16)(Math_CosS(this->unk_326[limbIndex]) * 200.0f); + if ((limbIndex == BBA_LIMB_UPPER_ROOT) || (limbIndex == BBA_LIMB_LEFT_UPPER_ARM) || + (limbIndex == BBA_LIMB_RIGHT_UPPER_ARM)) { + rot->y += (s16)(Math_SinS(this->limbRotTableY[limbIndex]) * 200.0f); + rot->z += (s16)(Math_CosS(this->limbRotTableZ[limbIndex]) * 200.0f); } - if (((this->unk_40C == 1) || (this->unk_40C == 3) || (this->unk_40C == 4) || - (ENBABA_GET_C000(&this->actor) == ENBABA_C000_2)) && - (limbIndex == 8)) { + if (((this->animIndex == BOMB_SHOP_LADY_ANIM_IDLE) || (this->animIndex == BOMB_SHOP_LADY_ANIM_KNOCKED_OVER) || + (this->animIndex == BOMB_SHOP_LADY_ANIM_LYING_DOWN) || + (BOMB_SHOP_LADY_GET_TYPE(&this->actor) == BOMB_SHOP_LADY_TYPE_SWAY)) && + (limbIndex == BBA_LIMB_BAG)) { *dList = NULL; } - return 0; + return false; } void EnBaba_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnBaba* this = THIS; Vec3f sp18 = { 0.0f, 0.0f, 0.0f }; - if (limbIndex == 7) { + if (limbIndex == BBA_LIMB_HEAD) { this->actor.focus.pos.x = this->actor.world.pos.x; this->actor.focus.pos.y = this->actor.world.pos.y; this->actor.focus.pos.z = this->actor.world.pos.z; @@ -747,10 +803,10 @@ void EnBaba_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { void EnBaba_Draw(Actor* thisx, PlayState* play) { s32 pad; EnBaba* this = THIS; - Vec3f sp4C; - Vec3f sp40; + Vec3f pos; + Vec3f scale; - if (this->unk_40A & 2) { + if (this->stateFlags & BOMB_SHOP_LADY_STATE_VISIBLE) { OPEN_DISPS(play->state.gfxCtx); func_8012C5B0(play->state.gfxCtx); @@ -761,18 +817,19 @@ void EnBaba_Draw(Actor* thisx, PlayState* play) { this->skelAnime.dListCount, EnBaba_OverrideLimbDraw, EnBaba_PostLimbDraw, EnBaba_TransformLimbDraw, &this->actor); - if (this->unk_40A & 0x80) { - if ((this->unk_40C == 3) || (this->unk_40C == 4)) { + if (this->stateFlags & BOMB_SHOP_LADY_STATE_DRAW_SHADOW) { + if ((this->animIndex == BOMB_SHOP_LADY_ANIM_KNOCKED_OVER) || + (this->animIndex == BOMB_SHOP_LADY_ANIM_LYING_DOWN)) { func_8012C2DC(play->state.gfxCtx); - sp4C.x = this->actor.world.pos.x + 20.0f; - sp4C.y = this->actor.world.pos.y; - sp4C.z = this->actor.world.pos.z + 20.0f; + pos.x = this->actor.world.pos.x + 20.0f; + pos.y = this->actor.world.pos.y; + pos.z = this->actor.world.pos.z + 20.0f; } else { - sp4C = this->actor.world.pos; + pos = this->actor.world.pos; } - sp40.x = sp40.y = sp40.z = 0.3f; - func_800BC620(&sp4C, &sp40, 255, play); + scale.x = scale.y = scale.z = 0.3f; + func_800BC620(&pos, &scale, 255, play); } CLOSE_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.h b/src/overlays/actors/ovl_En_Baba/z_en_baba.h index 8c00f10e5..2335dcb70 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.h +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.h @@ -2,58 +2,60 @@ #define Z_EN_BABA_H #include "global.h" +#include "overlays/actors/ovl_En_Sob1/z_en_sob1.h" +#include "objects/object_bba/object_bba.h" struct EnBaba; typedef void (*EnBabaActionFunc)(struct EnBaba*, PlayState*); -#define ENBABA_GET_3F00(thisx) (((thisx)->params & 0x3F00) >> 8) -#define ENBABA_GET_C000(thisx) (((thisx)->params & 0xC000) >> 0xE) +#define BOMB_SHOP_LADY_GET_PATH_INDEX(thisx) (((thisx)->params & 0x3F00) >> 8) +#define BOMB_SHOP_LADY_GET_TYPE(thisx) (((thisx)->params & 0xC000) >> 0xE) -#define ENBABA_3F00_3F 0x3F - -enum { - /* 0 */ ENBABA_C000_0, - /* 1 */ ENBABA_C000_1, - /* 2 */ ENBABA_C000_2, -}; +// Types BOMB_SHOP_LADY_TYPE_FOLLOW_SCHEDULE and BOMB_SHOP_LADY_TYPE_IDLE can only be used in SCENE_BACKTOWN +// Type BOMB_SHOP_LADY_TYPE_SWAY can be used anywhere except SCENE_BACKTOWN and SCENE_BOMYA +typedef enum { + /* 0 */ BOMB_SHOP_LADY_TYPE_FOLLOW_SCHEDULE, + /* 1 */ BOMB_SHOP_LADY_TYPE_IDLE, + /* 2 */ BOMB_SHOP_LADY_TYPE_SWAY +} BombShopLadyType; typedef struct EnBaba { - /* 0x0000 */ Actor actor; - /* 0x0144 */ struct EnOssan* unk_144; - /* 0x0148 */ EnBabaActionFunc actionFunc; - /* 0x014C */ UNK_TYPE1 unk14C[4]; - /* 0x0150 */ SkelAnime skelAnime; - /* 0x0194 */ ColliderCylinder collider; - /* 0x01E0 */ u16 unk_1E0; - /* 0x01E2 */ u8 unk_1E2; - /* 0x01E4 */ Path* path; - /* 0x01E8 */ s16 unk_1E8; - /* 0x01EA */ UNK_TYPE1 unk1EA[0x1C]; - /* 0x0206 */ Vec3s jointTable[18]; - /* 0x0272 */ Vec3s morphTable[18]; - /* 0x02DE */ Vec3s trackTarget; - /* 0x02E4 */ Vec3s headRot; - /* 0x02EA */ Vec3s torsoRot; - /* 0x02F0 */ UNK_TYPE1 unk2F0[0x12]; - /* 0x0302 */ s16 unk_302[18]; - /* 0x0326 */ s16 unk_326[18]; - /* 0x034A */ UNK_TYPE1 unk34A[0xBA]; - /* 0x0404 */ s16 unk_404; - /* 0x0406 */ UNK_TYPE1 unk406[4]; - /* 0x040A */ u16 unk_40A; - /* 0x040C */ s32 unk_40C; - /* 0x0410 */ Path* timePath; - /* 0x0414 */ Vec3f timePathTargetPos; - /* 0x0420 */ f32 timePathProgress; - /* 0x0424 */ s32 timePathTotalTime; - /* 0x0428 */ s32 timePathWaypointTime; - /* 0x042C */ s32 timePathWaypoint; - /* 0x0430 */ s32 timePathElapsedTime; - /* 0x0434 */ u8 unk_434; - /* 0x0436 */ s16 timePathTimeSpeed; - /* 0x0438 */ s32 unk_438; - /* 0x043C */ s32 unk_43C; + /* 0x000 */ Actor actor; + /* 0x144 */ EnSob1* bombShopkeeper; + /* 0x148 */ EnBabaActionFunc actionFunc; + /* 0x14C */ UNK_TYPE1 unk14C[4]; + /* 0x150 */ SkelAnime skelAnime; + /* 0x194 */ ColliderCylinder collider; + /* 0x1E0 */ u16 textId; + /* 0x1E2 */ u8 inMsgState3; + /* 0x1E4 */ Path* path; + /* 0x1E8 */ s16 waypoint; + /* 0x1EA */ UNK_TYPE1 unk1EA[0x1C]; + /* 0x206 */ Vec3s jointTable[BBA_LIMB_MAX]; + /* 0x272 */ Vec3s morphTable[BBA_LIMB_MAX]; + /* 0x2DE */ Vec3s trackTarget; + /* 0x2E4 */ Vec3s headRot; + /* 0x2EA */ Vec3s torsoRot; + /* 0x2F0 */ UNK_TYPE1 unk2F0[0x12]; + /* 0x302 */ s16 limbRotTableY[18]; + /* 0x326 */ s16 limbRotTableZ[18]; + /* 0x34A */ UNK_TYPE1 unk34A[0xBA]; + /* 0x404 */ s16 sakonDeadTimer; + /* 0x406 */ UNK_TYPE1 unk406[4]; + /* 0x40A */ u16 stateFlags; + /* 0x40C */ s32 animIndex; + /* 0x410 */ Path* timePath; + /* 0x414 */ Vec3f timePathPoint; + /* 0x420 */ f32 timePathProgress; + /* 0x424 */ s32 timePathTotalTime; + /* 0x428 */ s32 timePathWaypointTime; + /* 0x42C */ s32 timePathWaypoint; + /* 0x430 */ s32 timePathElapsedTime; + /* 0x434 */ u8 scheduleResult; + /* 0x436 */ s16 timePathTimeSpeed; + /* 0x438 */ s32 timePathIsSetup; + /* 0x43C */ s32 timePathHasReachedEnd; } EnBaba; // size = 0x440 extern const ActorInit En_Baba_InitVars; diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c index 46b40b9a9..a0954943b 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -76,7 +76,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; 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 d00a92aa2..e14bc8ce5 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c @@ -59,7 +59,7 @@ static u16 sTextIds[] = { 0x2ABD, 0x2ABB, 0x2AD5, 0x2AD6, 0x2AD7, 0x2AD8, 0x2AC6 static AnimationHeader* D_80BE8E4C[] = { &object_bai_Anim_0011C0, &object_bai_Anim_0008B4, &object_bai_Anim_008198 }; -static u8 animModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP }; +static u8 sAnimModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP }; void EnBaisen_Init(Actor* thisx, PlayState* play) { EnBaisen* this = THIS; @@ -104,7 +104,7 @@ void EnBaisen_ChangeAnimation(EnBaisen* this, s32 animIndex) { this->animIndex = animIndex; this->frameCount = Animation_GetLastFrame(D_80BE8E4C[animIndex]); Animation_Change(&this->skelAnime, D_80BE8E4C[this->animIndex], 1.0f, 0.0f, this->frameCount, - animModes[this->animIndex], -10.0f); + sAnimModes[this->animIndex], -10.0f); } void func_80BE871C(EnBaisen* this) { @@ -222,7 +222,7 @@ void func_80BE8AAC(EnBaisen* this, PlayState* play) { EnBaisen_ChangeAnimation(this, 0); } } - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); this->textIdIndex++; if (this->textIdIndex < 6) { diff --git a/src/overlays/actors/ovl_En_Bal/z_en_bal.c b/src/overlays/actors/ovl_En_Bal/z_en_bal.c index 98f3e6c4a..9617e0559 100644 --- a/src/overlays/actors/ovl_En_Bal/z_en_bal.c +++ b/src/overlays/actors/ovl_En_Bal/z_en_bal.c @@ -78,7 +78,7 @@ static ColliderJntSphElementInit D_80A63D0C[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A63D30 = { { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A63D0C, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A63D0C, // sJntSphElementsInit, }; #endif diff --git a/src/overlays/actors/ovl_En_Bal/z_en_bal.h b/src/overlays/actors/ovl_En_Bal/z_en_bal.h index 3bb22cb34..9184cfa68 100644 --- a/src/overlays/actors/ovl_En_Bal/z_en_bal.h +++ b/src/overlays/actors/ovl_En_Bal/z_en_bal.h @@ -8,10 +8,10 @@ struct EnBal; typedef void (*EnBalActionFunc)(struct EnBal*, PlayState*); typedef struct EnBal { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x48]; - /* 0x018C */ EnBalActionFunc actionFunc; - /* 0x0190 */ char unk_190[0x224]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x48]; + /* 0x18C */ EnBalActionFunc actionFunc; + /* 0x190 */ char unk_190[0x224]; } EnBal; // size = 0x3B4 extern const ActorInit En_Bal_InitVars; diff --git a/src/overlays/actors/ovl_En_Bat/z_en_bat.c b/src/overlays/actors/ovl_En_Bat/z_en_bat.c index c85cd3410..e81608721 100644 --- a/src/overlays/actors/ovl_En_Bat/z_en_bat.c +++ b/src/overlays/actors/ovl_En_Bat/z_en_bat.c @@ -5,22 +5,29 @@ */ #include "z_en_bat.h" +#include "objects/object_bat/object_bat.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnBat*)thisx) +#define BAD_BAT_FLAP_FRAME 5 + void EnBat_Init(Actor* thisx, PlayState* play); void EnBat_Destroy(Actor* thisx, PlayState* play); void EnBat_Update(Actor* thisx, PlayState* play); void EnBat_Draw(Actor* thisx, PlayState* play); -void func_80A438D4(EnBat* this, PlayState* play); -void func_80A4392C(EnBat* this, PlayState* play); -void func_80A43CE8(EnBat* this, PlayState* play); -void func_80A44114(EnBat* this, PlayState* play); +s32 EnBat_IsGraveyardOnSecondDay(PlayState* play); +void EnBat_SetupPerch(EnBat* this); +void EnBat_Perch(EnBat* this, PlayState* play); +void EnBat_SetupFlyIdle(EnBat* this); +void EnBat_FlyIdle(EnBat* this, PlayState* play); +void EnBat_SetupDiveAttack(EnBat* this); +void EnBat_DiveAttack(EnBat* this, PlayState* play); +void EnBat_Die(EnBat* this, PlayState* play); +void EnBat_Stunned(EnBat* this, PlayState* play); -#if 0 const ActorInit En_Bat_InitVars = { ACTOR_EN_BAT, ACTORCAT_ENEMY, @@ -33,99 +40,522 @@ const ActorInit En_Bat_InitVars = { (ActorFunc)EnBat_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80A44A00 = { - { COLTYPE_HIT3, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT3, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 15 }, 100 }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A44A2C = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0x0), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0 */ BAD_BAT_DMGEFF_NONE, + /* 1 */ BAD_BAT_DMGEFF_STUN, + /* 2 */ BAD_BAT_DMGEFF_FIRE, + /* 3 */ BAD_BAT_DMGEFF_ICE, + /* 4 */ BAD_BAT_DMGEFF_LIGHT, + /* 5 */ BAD_BAT_DMGEFF_ELECTRIC +} BatDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, BAD_BAT_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, BAD_BAT_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, BAD_BAT_DMGEFF_ICE), + /* Light arrow */ DMG_ENTRY(2, BAD_BAT_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, BAD_BAT_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, BAD_BAT_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, BAD_BAT_DMGEFF_ELECTRIC), + /* Normal shield */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, BAD_BAT_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, BAD_BAT_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80A44A4C = { 1, 15, 30, 10 }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 30, 10 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A44A54[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 96, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -#endif +static Gfx* sWingsDLs[] = { + gBadBatWingsFrame0DL, gBadBatWingsFrame1DL, gBadBatWingsFrame2DL, gBadBatWingsFrame3DL, gBadBatWingsFrame4DL, + gBadBatWingsFrame5DL, gBadBatWingsFrame6DL, gBadBatWingsFrame7DL, gBadBatWingsFrame8DL, +}; -extern ColliderSphereInit D_80A44A00; -extern DamageTable D_80A44A2C; -extern CollisionCheckInfoInit D_80A44A4C; -extern InitChainEntry D_80A44A54[]; +#define BAD_BAT_MAX_NUMBER_ATTACKING 3 -extern UNK_TYPE D_060000A0; +s32 sNumberAttacking; //!< Limit number attacking player to at most `BAD_BAT_MAX_NUMBER_ATTACKING` +s32 sAlreadySpawned; //!< used for those spawned with room -1 in Graveyard to avoid respawn on room change -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/EnBat_Init.s") +void EnBat_Init(Actor* thisx, PlayState* play) { + EnBat* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/EnBat_Destroy.s") + Actor_ProcessInitChain(thisx, sInitChain); + Collider_InitAndSetSphere(play, &this->collider, thisx, &sSphereInit); + this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; + CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); + ActorShape_Init(&thisx->shape, 2000.0f, ActorShadow_DrawCircle, 25.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A437CC.s") + this->animationFrame = Rand_ZeroOne() * 9.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A43810.s") + this->paramFlags = BAD_BAT_GET_PARAMFLAGS(thisx); + this->switchFlag = BAD_BAT_GET_SWITCHFLAG(thisx); + thisx->params = BAD_BAT_GET_TYPE(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A43870.s") + thisx->depthInWater = BGCHECK_Y_MIN; + Actor_SetFocus(thisx, 20.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A438D4.s") + if (sAlreadySpawned) { + Actor_MarkForDeath(thisx); + } else if (EnBat_IsGraveyardOnSecondDay(play)) { + if (Flags_GetSwitch(play, this->switchFlag)) { + Actor_MarkForDeath(thisx); + } else { + this->actor.room = -1; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A438F8.s") + if (this->paramFlags & BAD_BAT_PARAMFLAG_PERCH) { + thisx->params = 0; + EnBat_SetupPerch(this); + } else { + if (thisx->params == 0x1F) { + thisx->params = 0; + } + EnBat_SetupFlyIdle(this); + while (BAD_BAT_GET_NUMBER_TO_SPAWN(thisx) > 1) { + Actor_SpawnAsChildAndCutscene( + &play->actorCtx, play, ACTOR_EN_BAT, thisx->world.pos.x + randPlusMinusPoint5Scaled(200.0f), + thisx->world.pos.y + randPlusMinusPoint5Scaled(100.0f), + thisx->world.pos.z + randPlusMinusPoint5Scaled(200.0f), randPlusMinusPoint5Scaled(0x2000), + 0xFFFF * Rand_ZeroOne(), 0, BAD_BAT_PARAMS(this->switchFlag, this->paramFlags, 0), -1, thisx->unk20, + NULL); + BAD_BAT_GET_NUMBER_TO_SPAWN(thisx)--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A4392C.s") +void EnBat_Destroy(Actor* thisx, PlayState* play) { + EnBat* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A43CA0.s") + Collider_DestroySphere(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A43CE8.s") +s32 EnBat_IsGraveyardOnSecondDay(PlayState* play) { + if ((CURRENT_DAY == 2) && (play->sceneNum == SCENE_BOTI)) { + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A43F60.s") +void EnBat_StepAnimation(EnBat* this, s32 frameStep) { + s32 prevFrame = this->animationFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A44114.s") + this->animationFrame += frameStep; + if (this->animationFrame >= ARRAY_COUNT(sWingsDLs)) { + this->animationFrame -= ARRAY_COUNT(sWingsDLs); + } + if ((prevFrame < BAD_BAT_FLAP_FRAME) && (this->animationFrame >= BAD_BAT_FLAP_FRAME)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_FLY); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A44294.s") +void EnBat_SetupPerch(EnBat* this) { + this->collider.base.acFlags |= AC_ON; + this->collider.base.atFlags |= AT_ON; + this->collider.dim.worldSphere.center.x = this->actor.focus.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.focus.pos.y; + this->collider.dim.worldSphere.center.z = this->actor.focus.pos.z; + this->actor.speedXZ = 0.0f; + this->actionFunc = EnBat_Perch; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A4431C.s") +void EnBat_Perch(EnBat* this, PlayState* play) { + EnBat_StepAnimation(this, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/func_80A443D8.s") +void EnBat_SetupFlyIdle(EnBat* this) { + this->timer = 100; + this->collider.base.acFlags |= AC_ON; + this->actor.speedXZ = 3.5f; + this->actionFunc = EnBat_FlyIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/EnBat_Update.s") +void EnBat_FlyIdle(EnBat* this, PlayState* play) { + s32 finishedRotStep; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bat/EnBat_Draw.s") + EnBat_StepAnimation(this, 1); + + finishedRotStep = Math_ScaledStepToS(&this->actor.shape.rot.y, this->yawTarget, 0x300); + + if (this->actor.bgCheckFlags & 8) { + this->actor.bgCheckFlags &= ~8; + this->yawTarget = this->actor.wallYaw; + } else if (Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x, + this->actor.home.pos.z) > SQ(300.0f)) { + this->yawTarget = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + } else if (finishedRotStep && (Rand_ZeroOne() < 0.015f)) { + this->yawTarget = + this->actor.shape.rot.y + (((s32)(0x1000 * Rand_ZeroOne()) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + } + + finishedRotStep = Math_ScaledStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0x100); + + if ((this->actor.bgCheckFlags & 1) || (this->actor.depthInWater > -40.0f)) { + this->pitchTarget = -0x1000; + } else if (this->actor.world.pos.y < (this->actor.home.pos.y - 100.0f)) { + this->pitchTarget = -((s32)(0x800 * Rand_ZeroOne()) + 0x800); + } else if ((this->actor.home.pos.y + 100.0f) < this->actor.world.pos.y) { + this->pitchTarget = (s32)(0x800 * Rand_ZeroOne()) + 0x800; + } else if ((finishedRotStep) && (Rand_ZeroOne() < 0.015f)) { + this->pitchTarget += (s16)(((s32)(0x400 * Rand_ZeroOne()) + 0x400) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + this->pitchTarget = CLAMP(this->pitchTarget, -0x1000, 0x1000); + } + + if (this->timer != 0) { + this->timer--; + } + if ((this->actor.xzDistToPlayer < 300.0f) && (this->timer == 0) && (Player_GetMask(play) != PLAYER_MASK_STONE) && + (sNumberAttacking < BAD_BAT_MAX_NUMBER_ATTACKING) && + (!(this->paramFlags & BAD_BAT_PARAMFLAG_CHECK_HEIGHTREL) || (fabsf(this->actor.playerHeightRel) < 150.0f))) { + EnBat_SetupDiveAttack(this); + } +} + +void EnBat_SetupDiveAttack(EnBat* this) { + this->collider.base.atFlags |= AT_ON; + this->timer = 300; + this->actor.speedXZ = 4.0f; + sNumberAttacking++; + this->actionFunc = EnBat_DiveAttack; +} + +void EnBat_DiveAttack(EnBat* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 isFacingPlayer; + Vec3f preyPos; + + EnBat_StepAnimation(this, 2); + isFacingPlayer = Actor_IsFacingPlayer(&this->actor, 0x2800); + + if (isFacingPlayer) { + s16 pitchTarget; + + preyPos.x = player->actor.world.pos.x; + preyPos.y = player->actor.world.pos.y + 20.0f; + preyPos.z = player->actor.world.pos.z; + + pitchTarget = Actor_PitchToPoint(&this->actor, &preyPos); + pitchTarget = CLAMP(pitchTarget, -0x3000, 0x3000); + Math_SmoothStepToS(&this->actor.shape.rot.x, pitchTarget, 2, 0x400, 0x40); + } else { + Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 2, 0x100, 0x10); + } + if (isFacingPlayer || (this->actor.xzDistToPlayer > 80.0f)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00, 0xC0); + } + + this->timer--; + + if ((this->timer == 0) || (this->collider.base.atFlags & AT_HIT) || (Player_GetMask(play) == PLAYER_MASK_STONE) || + (this->actor.bgCheckFlags & 1) || (player->stateFlags1 & PLAYER_STATE1_800000) || + (this->actor.depthInWater > -40.0f)) { + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_ATTACK); + } + this->collider.base.atFlags &= ~AT_ON; + sNumberAttacking--; + EnBat_SetupFlyIdle(this); + } else if ((this->actor.bgCheckFlags & 8) && + (ABS_ALT(BINANG_SUB(this->actor.wallYaw, this->actor.yawTowardsPlayer)) > 0x6800)) { + sNumberAttacking--; + this->collider.base.atFlags &= ~AT_ON; + this->actor.bgCheckFlags &= ~8; + this->yawTarget = this->actor.wallYaw; + EnBat_SetupFlyIdle(this); + } +} + +void EnBat_SetupDie(EnBat* this, PlayState* play) { + this->actor.flags &= ~ACTOR_FLAG_1; + Enemy_StartFinishingBlow(play, &this->actor); + this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); + this->actor.bgCheckFlags &= ~1; + this->actor.velocity.y = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_DEAD); + + if (this->actor.colChkInfo.damageEffect == BAD_BAT_DMGEFF_ICE) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffFrozenSteamScale = 60.0f * (0.45f / 40.0f); + this->drawDmgEffScale = 0.45f; + } else if (this->actor.colChkInfo.damageEffect == BAD_BAT_DMGEFF_LIGHT) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.45f; + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_SMALL_LIGHT_RAYS); + } else if (this->actor.colChkInfo.damageEffect == BAD_BAT_DMGEFF_FIRE) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.45f; + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + + if (this->actor.flags & ACTOR_FLAG_8000) { + this->actor.speedXZ = 0.0f; + } + + this->collider.base.acFlags &= ~AC_ON; + this->actor.flags |= ACTOR_FLAG_10; + this->actionFunc = EnBat_Die; +} + +void EnBat_Die(EnBat* this, PlayState* play) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + this->actor.colorFilterTimer = 40; + + if (!(this->actor.flags & ACTOR_FLAG_8000)) { // Carried by arrow + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); + this->actor.shape.rot.z += 0x1780; + } + + if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartPoss, ARRAY_COUNT(this->bodyPartPoss), 2, 0.2f, + 0.2f); + } + + func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 100, 0, 0); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + Actor_MarkForDeath(&this->actor); + + if (this->actor.room == -1) { + Actor* enemy = NULL; + + // Search for other EnBats. If find none, set switch flag. + do { + enemy = SubS_FindActor(play, enemy, ACTORCAT_ENEMY, ACTOR_EN_BAT); + if (enemy != NULL) { + if (enemy != &this->actor) { + break; + } + enemy = enemy->next; + } + } while (enemy != NULL); + + if (enemy == NULL) { + Flags_SetSwitch(play, this->switchFlag); + } + } + } + } +} + +void EnBat_SetupStunned(EnBat* this) { + if (this->actionFunc != EnBat_Stunned) { + this->actor.shape.yOffset = 700.0f; + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->actor.world.pos.y += 13.0f; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, this->timer); + this->actionFunc = EnBat_Stunned; +} + +void EnBat_Stunned(EnBat* this, PlayState* play) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x100); + if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { + if (this->timer != 0) { + this->timer--; + } + if (this->timer == 0) { + EnBat_SetupFlyIdle(this); + } + } else { + this->actor.colorFilterTimer = 40; + if (this->drawDmgEffAlpha > 0.0f) { + this->drawDmgEffAlpha = 2.0f; + } + } +} + +void EnBat_UpdateDamage(EnBat* this, PlayState* play) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + + Actor_SetDropFlag(&this->actor, &this->collider.info); + this->collider.base.atFlags &= ~AT_ON; + + if (this->actionFunc == EnBat_DiveAttack) { + sNumberAttacking--; + } + + if (this->actor.colChkInfo.damageEffect == BAD_BAT_DMGEFF_ELECTRIC) { + this->timer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffScale = 0.45f; + EnBat_SetupStunned(this); + } else if (this->actor.colChkInfo.damageEffect == BAD_BAT_DMGEFF_STUN) { + this->timer = 40; + EnBat_SetupStunned(this); + } else { + Actor_ApplyDamage(&this->actor); + EnBat_SetupDie(this, play); + } + } +} + +void EnBat_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnBat* this = THIS; + + if (this->actor.room == -1) { + sAlreadySpawned = true; + } + + EnBat_UpdateDamage(this, play); + this->actionFunc(this, play); + + if (this->actionFunc != EnBat_Stunned) { + Math_StepToF(&this->actor.shape.yOffset, 2000.0f, 200.0f); + } + + if (this->actionFunc != EnBat_Perch) { + Vec3f prevPos; + + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.x = -this->actor.shape.rot.x; + Math_Vec3f_Copy(&prevPos, &this->actor.prevPos); + + if ((this->actor.colChkInfo.health != 0) && (this->actionFunc != EnBat_Stunned)) { + Actor_MoveWithoutGravity(&this->actor); + } else { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actionFunc == EnBat_DiveAttack) { + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 15.0f, 50.0f, 5); + } else if ((this->actionFunc != EnBat_FlyIdle) || + ((this->actor.xzDistToPlayer < 400.0f) && (this->actor.projectedPos.z > 0.0f))) { + if (this->paramFlags & BAD_BAT_PARAMFLAG_0) { + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 15.0f, 50.0f, 5); + } else { + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 15.0f, 50.0f, 4); + } + } else { + Math_Vec3f_Copy(&this->actor.prevPos, &prevPos); + } + + Actor_SetFocus(&this->actor, this->actor.shape.yOffset * 0.01f); + this->collider.dim.worldSphere.center.x = this->actor.focus.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.focus.pos.y; + this->collider.dim.worldSphere.center.z = this->actor.focus.pos.z; + } + + if (this->collider.base.atFlags & AT_ON) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } + if (this->actionFunc == EnBat_DiveAttack) { + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.225f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.45f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.45f, 0.45f / 40.0f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +void EnBat_Draw(Actor* thisx, PlayState* play) { + EnBat* this = THIS; + Gfx* gfx; + + // Draw body and wings + if (this->actor.projectedPos.z > 0.0f) { + OPEN_DISPS(play->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + gSPMatrix(&gfx[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], gBadBatSetupDL); + gSPDisplayList(&gfx[3], gBadBatBodyDL); + gSPDisplayList(&gfx[4], sWingsDLs[this->animationFrame]); + + POLY_OPA_DISP = &gfx[5]; + + CLOSE_DISPS(play->state.gfxCtx); + } + + // Draw damage effects + if (this->drawDmgEffAlpha > 0.0f) { + s16 rollAngle; + + if (this->animationFrame < BAD_BAT_FLAP_FRAME - 1) { + rollAngle = this->animationFrame * (15 * (0x10000 / 360)); + } else { + rollAngle = (this->animationFrame >= BAD_BAT_FLAP_FRAME) + ? (this->animationFrame * (15 * (0x10000 / 360))) - (120 * (0x10000 / 360)) + : 0; + } + Matrix_MultZero(&this->bodyPartPoss[0]); + Matrix_RotateZS(rollAngle, MTXMODE_APPLY); + Matrix_MultVecX(1700.0f, &this->bodyPartPoss[1]); + Matrix_RotateZS(-2 * rollAngle, MTXMODE_APPLY); + Matrix_MultVecX(-1700.0f, &this->bodyPartPoss[2]); + Actor_DrawDamageEffects(play, &this->actor, this->bodyPartPoss, ARRAY_COUNT(this->bodyPartPoss), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + } +} diff --git a/src/overlays/actors/ovl_En_Bat/z_en_bat.h b/src/overlays/actors/ovl_En_Bat/z_en_bat.h index 3a8a2e0a1..4f4ada810 100644 --- a/src/overlays/actors/ovl_En_Bat/z_en_bat.h +++ b/src/overlays/actors/ovl_En_Bat/z_en_bat.h @@ -3,14 +3,41 @@ #include "global.h" +#define BAD_BAT_GET_TYPE(thisx) (((thisx)->params >> 0) & 0x1F) +#define BAD_BAT_GET_PARAMFLAGS(thisx) (((thisx)->params >> 5) & 7) +#define BAD_BAT_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0xFF) +#define BAD_BAT_PARAMS(switchFlag, paramflags, type) ((type) | ((paramflags) << 5) | ((switchFlag) << 8)) + +//! PARAMFLAGS +//! Affects which flags are used in Actor_UpdateBgCheckInfo in certain circumstances +#define BAD_BAT_PARAMFLAG_0 (1 << 0) +//! Whether to apply a height range check to attack +#define BAD_BAT_PARAMFLAG_CHECK_HEIGHTREL (1 << 1) +//! Spawn as perching instead of flying +#define BAD_BAT_PARAMFLAG_PERCH (1 << 2) + +#define BAD_BAT_GET_NUMBER_TO_SPAWN(thisx) ((thisx)->params) +#define BAD_BAT_SPAWN_COUNT(n) (n) + struct EnBat; typedef void (*EnBatActionFunc)(struct EnBat*, PlayState*); typedef struct EnBat { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBatActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x94]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnBatActionFunc actionFunc; + /* 0x148 */ u8 drawDmgEffType; + /* 0x149 */ u8 paramFlags; + /* 0x14A */ s16 switchFlag; + /* 0x14C */ s16 timer; + /* 0x14E */ s16 pitchTarget; + /* 0x150 */ s16 yawTarget; + /* 0x152 */ s16 animationFrame; //!< Manual animation using displaylists + /* 0x154 */ f32 drawDmgEffScale; + /* 0x158 */ f32 drawDmgEffFrozenSteamScale; + /* 0x15C */ f32 drawDmgEffAlpha; + /* 0x160 */ Vec3f bodyPartPoss[3]; + /* 0x184 */ ColliderSphere collider; } EnBat; // size = 0x1DC extern const ActorInit En_Bat_InitVars; diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index 0be4ae957..a9314b9fa 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -689,9 +689,8 @@ void EnBb_Draw(Actor* thisx, PlayState* play) { if (this->flameScaleX > 0.0f) { currentMatrixState = Matrix_GetCurrent(); func_8012C2DC(play->state.gfxCtx); - Matrix_RotateYS( - ((Camera_GetCamDirYaw(play->cameraPtrs[play->activeCamera]) - this->actor.shape.rot.y) + 0x8000), - MTXMODE_APPLY); + Matrix_RotateYS(((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) - this->actor.shape.rot.y) + 0x8000), + MTXMODE_APPLY); Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 0); diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index ae6e8921c..7bfbf596c 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -134,10 +134,10 @@ s32 EnBba01_TestIsTalking(EnBba01* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->enHy.actor, &play->state)) { isTalking = true; this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox - this->enHy.tmptrackTarget = this->enHy.trackTarget; - this->enHy.tmpHeadRot = this->enHy.headRot; - this->enHy.tmpTorsoRot = this->enHy.torsoRot; - this->enHy.tmpActionFunc = this->enHy.actionFunc; + this->enHy.prevTrackTarget = this->enHy.trackTarget; + this->enHy.prevHeadRot = this->enHy.headRot; + this->enHy.prevTorsoRot = this->enHy.torsoRot; + this->enHy.prevActionFunc = this->enHy.actionFunc; this->enHy.actionFunc = EnBba01_Talk; } return isTalking; @@ -162,7 +162,7 @@ void EnBba01_FinishInit(EnHy* this, PlayState* play) { this->actor.flags |= ACTOR_FLAG_1; this->actor.draw = EnBba01_Draw; this->waitingOnInit = false; - if (ENBBA01_GET_PATH(&this->actor) == ENBBA01_NO_PATH) { + if (ENBBA01_GET_PATH(&this->actor) == 0x3F) { this->actionFunc = EnBba01_FaceFoward; } else { this->actionFunc = EnBba01_Walk; @@ -185,24 +185,26 @@ void EnBba01_Talk(EnHy* this, PlayState* play) { u8 talkState; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xFA0, 1); + talkState = Message_GetState(&play->msgCtx); - this->inMsgState3 = (talkState == 3) ? true : false; + this->inMsgState3 = (talkState == TEXT_STATE_3) ? true : false; switch (talkState) { - case 0: + case TEXT_STATE_NONE: yaw = ABS_ALT(this->actor.shape.rot.y - this->actor.yawTowardsPlayer); if (yaw < 0x64) { Message_StartTextbox(play, this->textId, NULL); } break; - case 2: + + case TEXT_STATE_CLOSING: this->actor.textId = 0; - this->trackTarget = this->tmptrackTarget; - this->headRot = this->tmpHeadRot; - this->torsoRot = this->tmpTorsoRot; + this->trackTarget = this->prevTrackTarget; + this->headRot = this->prevHeadRot; + this->torsoRot = this->prevTorsoRot; this->actor.shape.rot.y = this->actor.world.rot.y; - this->actionFunc = this->tmpActionFunc; - this->tmpActionFunc = NULL; + this->actionFunc = this->prevActionFunc; + this->prevActionFunc = NULL; break; } } @@ -225,7 +227,7 @@ void EnBba01_Init(Actor* thisx, PlayState* play) { Collider_SetCylinder(play, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->enHy.actor.flags &= ~ACTOR_FLAG_1; - this->enHy.path = SubS_GetPathByIndex(play, ENBBA01_GET_PATH(&this->enHy.actor), ENBBA01_NO_PATH); + this->enHy.path = SubS_GetPathByIndex(play, ENBBA01_GET_PATH(&this->enHy.actor), 0x3F); this->enHy.waitingOnInit = true; Actor_SetScale(&this->enHy.actor, 0.01f); this->enHy.actionFunc = EnBba01_FinishInit; diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h index 04bab2ff1..c9030f112 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h @@ -8,7 +8,6 @@ struct EnBba01; typedef void (*EnBba01ActionFunc)(struct EnBba01*, PlayState*); #define ENBBA01_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) -#define ENBBA01_NO_PATH 0x3F typedef struct EnBba01 { /* 0x000 */ EnHy enHy; diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c index e2deeb38a..c489ba806 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -723,9 +723,8 @@ void EnBbfall_Draw(Actor* thisx, PlayState* play2) { if (this->flameOpacity > 0) { func_8012C2DC(play->state.gfxCtx); - Matrix_RotateYS( - ((Camera_GetCamDirYaw(play->cameraPtrs[play->activeCamera]) - this->actor.shape.rot.y) + 0x8000), - MTXMODE_APPLY); + Matrix_RotateYS(((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) - this->actor.shape.rot.y) + 0x8000), + MTXMODE_APPLY); Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); currentMatrixState = Matrix_GetCurrent(); diff --git a/src/overlays/actors/ovl_En_Bee/z_en_bee.h b/src/overlays/actors/ovl_En_Bee/z_en_bee.h index 3cf0dbd51..1676a5507 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.h +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.h @@ -8,10 +8,10 @@ struct EnBee; typedef void (*EnBeeActionFunc)(struct EnBee*, PlayState*); typedef struct EnBee { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xBC]; - /* 0x0200 */ EnBeeActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x84]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0xBC]; + /* 0x200 */ EnBeeActionFunc actionFunc; + /* 0x204 */ char unk_204[0x84]; } EnBee; // size = 0x288 extern const ActorInit En_Bee_InitVars; diff --git a/src/overlays/actors/ovl_En_Bh/z_en_bh.c b/src/overlays/actors/ovl_En_Bh/z_en_bh.c index 01284d2bf..b18bedfc9 100644 --- a/src/overlays/actors/ovl_En_Bh/z_en_bh.c +++ b/src/overlays/actors/ovl_En_Bh/z_en_bh.c @@ -15,7 +15,8 @@ void EnBh_Destroy(Actor* thisx, PlayState* play); void EnBh_Update(Actor* thisx, PlayState* play); void EnBh_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_80C22DEC(EnBh* this, PlayState* play); + const ActorInit En_Bh_InitVars = { ACTOR_EN_BH, ACTORCAT_ITEMACTION, @@ -28,16 +29,93 @@ const ActorInit En_Bh_InitVars = { (ActorFunc)EnBh_Draw, }; -#endif +void EnBh_Init(Actor* thisx, PlayState* play) { + EnBh* this = THIS; -extern UNK_TYPE D_06000074; + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + SkelAnime_InitFlex(play, &this->skelanime, &gBhSkel, &gBhFlyingAnim, this->jointTable, this->morphTable, + OBJECT_BH_LIMB_MAX); + Animation_PlayLoop(&this->skelanime, &gBhFlyingAnim); + this->actionFunc = func_80C22DEC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Init.s") +void EnBh_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Destroy.s") +void func_80C22DEC(EnBh* this, PlayState* play) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 xzDist; + s16 xRot; + s16 yRot; + s16 zRot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/func_80C22DEC.s") + this->actor.speedXZ = 3.0f; + xDiff = this->pos.x - this->actor.world.pos.x; + yDiff = this->pos.y - this->actor.world.pos.y; + zDiff = this->pos.z - this->actor.world.pos.z; + xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Update.s") + if ((this->timer2 == 0) || (xzDist < 100.0f)) { + this->pos.x = randPlusMinusPoint5Scaled(300.0f) + this->actor.home.pos.x; + this->pos.y = randPlusMinusPoint5Scaled(100.0f) + this->actor.home.pos.y; + this->pos.z = randPlusMinusPoint5Scaled(300.0f) + this->actor.home.pos.z; + this->timer2 = Rand_ZeroFloat(50.0f) + 30.0f; + this->step = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Draw.s") + yRot = Math_Atan2S(xDiff, zDiff); + xRot = Math_Atan2S(yDiff, xzDist); + zRot = Math_SmoothStepToS(&this->actor.world.rot.y, yRot, 0xA, this->step, 0); + + if (zRot > 0x1000) { + zRot = 0x1000; + } else if (zRot < -0x1000) { + zRot = -0x1000; + } + + Math_ApproachS(&this->actor.world.rot.x, xRot, 0xA, this->step); + Math_ApproachS(&this->actor.world.rot.z, -zRot, 0xA, this->step); + Math_ApproachS(&this->step, 0x200, 1, 0x10); + + if ((s32)this->skelanime.playSpeed == 0) { + if (this->timer == 0) { + this->skelanime.playSpeed = 1.0f; + this->timer = Rand_ZeroFloat(70.0f) + 50.0f; + } else if (((this->timer & 7) == 7) && (Rand_ZeroOne() < 0.5f)) { + this->unk1E4 = randPlusMinusPoint5Scaled(3000.0f); + } + } else { + SkelAnime_Update(&this->skelanime); + if ((this->timer == 0) && (Animation_OnFrame(&this->skelanime, 6.0f))) { + this->skelanime.playSpeed = 0.0f; + this->timer = Rand_ZeroFloat(50.0f) + 50.0f; + } + } + + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + Math_ApproachS(&this->unk1E2, this->unk1E4, 3, 0x3E8); +} + +void EnBh_Update(Actor* thisx, PlayState* play) { + EnBh* this = THIS; + + Actor_MoveWithoutGravity(&this->actor); + DECR(this->timer2); + DECR(this->timer); + this->actionFunc(this, play); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); +} + +void EnBh_Draw(Actor* thisx, PlayState* play) { + EnBh* this = THIS; + + func_8012C28C(play->state.gfxCtx); + Matrix_RotateZS(this->unk1E2, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(play, this->skelanime.skeleton, this->skelanime.jointTable, this->skelanime.dListCount, NULL, + NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Bh/z_en_bh.h b/src/overlays/actors/ovl_En_Bh/z_en_bh.h index 11c475e3f..b5e8a7c0c 100644 --- a/src/overlays/actors/ovl_En_Bh/z_en_bh.h +++ b/src/overlays/actors/ovl_En_Bh/z_en_bh.h @@ -2,15 +2,24 @@ #define Z_EN_BH_H #include "global.h" +#include "objects/object_bh/object_bh.h" struct EnBh; typedef void (*EnBhActionFunc)(struct EnBh*, PlayState*); typedef struct EnBh { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xA4]; - /* 0x01E8 */ EnBhActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelanime; + /* 0x188 */ Vec3s jointTable[OBJECT_BH_LIMB_MAX]; + /* 0x1AC */ Vec3s morphTable[OBJECT_BH_LIMB_MAX]; + /* 0x1D0 */ Vec3f pos; + /* 0x1DC */ s16 timer; + /* 0x1DE */ s16 timer2; + /* 0x1E0 */ s16 step; + /* 0x1E2 */ s16 unk1E2; + /* 0x1E4 */ s16 unk1E4; + /* 0x1E8 */ EnBhActionFunc actionFunc; } EnBh; // size = 0x1EC extern const ActorInit En_Bh_InitVars; diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index e14da9e04..60dbab041 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -113,9 +113,9 @@ void EnBigokuta_Init(Actor* thisx, PlayState* play) { EnBigokuta_SetupIdle(this); } - this->camAt.x = (Math_SinS(this->actor.home.rot.y) * 66.0f) + this->actor.world.pos.x; - this->camAt.y = (this->actor.home.pos.y - 49.5f) + 42.899998f; - this->camAt.z = (Math_CosS(this->actor.home.rot.y) * 66.0f) + this->actor.world.pos.z; + this->subCamAt.x = (Math_SinS(this->actor.home.rot.y) * 66.0f) + this->actor.world.pos.x; + this->subCamAt.y = (this->actor.home.pos.y - 49.5f) + 42.899998f; + this->subCamAt.z = (Math_CosS(this->actor.home.rot.y) * 66.0f) + this->actor.world.pos.z; this->unkFunc = func_80AC2B4C; // set but never called } @@ -127,40 +127,40 @@ void EnBigokuta_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->bodyCollider); } -void EnBigokuta_SetupCutsceneCamera(EnBigokuta* this, PlayState* play, Vec3f* at, Vec3f* eye) { +void EnBigokuta_SetupCutsceneCamera(EnBigokuta* this, PlayState* play, Vec3f* subCamAt, Vec3f* subCamEye) { s16 angle; ActorCutscene_Start(this->actor.cutscene, &this->actor); - this->camId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); - Play_CameraSetAtEye(play, this->camId, at, eye); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + Play_CameraSetAtEye(play, this->subCamId, subCamAt, subCamEye); - angle = BINANG_SUB(Actor_YawToPoint(&this->actor, eye), this->actor.home.rot.y); + angle = BINANG_SUB(Actor_YawToPoint(&this->actor, subCamEye), this->actor.home.rot.y); if (angle > 0) { angle = BINANG_ADD(this->actor.home.rot.y, 0x1800); } else { angle = BINANG_SUB(this->actor.home.rot.y, 0x1800); } - this->camEye.x = (Math_SinS(angle) * 250.0f) + this->camAt.x; - this->camEye.y = this->camAt.y + 100.0f; - this->camEye.z = (Math_CosS(angle) * 250.0f) + this->camAt.z; + this->subCamEye.x = (Math_SinS(angle) * 250.0f) + this->subCamAt.x; + this->subCamEye.y = this->subCamAt.y + 100.0f; + this->subCamEye.z = (Math_CosS(angle) * 250.0f) + this->subCamAt.z; } void EnBigokuta_MoveCamera(EnBigokuta* this, PlayState* play) { - Camera* camera = Play_GetCamera(play, this->camId); + Camera* subCam = Play_GetCamera(play, this->subCamId); - Math_Vec3f_StepTo(&camera->eye, &this->camEye, 20.0f); - Math_Vec3f_StepTo(&camera->at, &this->camAt, 20.0f); - Play_CameraSetAtEye(play, this->camId, &camera->at, &camera->eye); + Math_Vec3f_StepTo(&subCam->eye, &this->subCamEye, 20.0f); + Math_Vec3f_StepTo(&subCam->at, &this->subCamAt, 20.0f); + Play_CameraSetAtEye(play, this->subCamId, &subCam->at, &subCam->eye); } void EnBigokuta_ResetCamera(EnBigokuta* this, PlayState* play) { - Camera* camera; + Camera* subCam; - if (this->camId != 0) { - camera = Play_GetCamera(play, this->camId); - Play_CameraSetAtEye(play, 0, &camera->at, &camera->eye); - this->camId = 0; + if (this->subCamId != SUB_CAM_ID_DONE) { + subCam = Play_GetCamera(play, this->subCamId); + Play_CameraSetAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = SUB_CAM_ID_DONE; ActorCutscene_Stop(this->actor.cutscene); } } @@ -208,7 +208,7 @@ void EnBigokuta_SpawnRipple(EnBigokuta* this, PlayState* play) { } void EnBigokuta_SetupIdle(EnBigokuta* this) { - Animation_Change(&this->skelAnime, &gBigOctoIdleAnim, 0.5f, 0.0f, 0.0f, 1, -3.0f); + Animation_Change(&this->skelAnime, &gBigOctoIdleAnim, 0.5f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); this->actionFunc = EnBigokuta_Idle; } @@ -267,12 +267,12 @@ void EnBigokuta_IdleAboveWater(EnBigokuta* this, PlayState* play) { void EnBigokuta_UpdateOrSetupCam(EnBigokuta* this, PlayState* play) { if (this->actor.cutscene != -1) { - if (this->camId != 0) { + if (this->subCamId != SUB_CAM_ID_DONE) { EnBigokuta_MoveCamera(this, play); } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - Camera* camera = Play_GetCamera(play, 0); + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); - EnBigokuta_SetupCutsceneCamera(this, play, &camera->at, &camera->eye); + EnBigokuta_SetupCutsceneCamera(this, play, &mainCam->at, &mainCam->eye); } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } @@ -287,7 +287,7 @@ void EnBigokuta_SetupSuckInPlayer(EnBigokuta* this, PlayState* play) { Math_Vec3f_Copy(&this->playerPos, &player->actor.world.pos); this->timer = 0; - Animation_Change(&this->skelAnime, &gBigOctoIdleAnim, 1.0f, 12.0f, 12.0f, 2, -3.0f); + Animation_Change(&this->skelAnime, &gBigOctoIdleAnim, 1.0f, 12.0f, 12.0f, ANIMMODE_ONCE, -3.0f); ActorCutscene_SetIntentToPlay(this->actor.cutscene); this->playerHoldPos.x = (Math_SinS(this->actor.shape.rot.y) * 66.0f) + this->actor.world.pos.x; diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h index 283872763..c5cb799a5 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h @@ -33,26 +33,26 @@ typedef enum { } ObjectBigokutaLimbs; typedef struct EnBigokuta { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBigokutaUnkFunc unkFunc; // possibly something to do with photographing - /* 0x0148 */ SkelAnime skelAnime; - /* 0x018C */ EnBigokutaActionFunc actionFunc; - /* 0x0190 */ u8 drawDmgEffType; - /* 0x0192 */ s16 timer; - /* 0x0194 */ s16 camId; - /* 0x0196 */ s16 cutscene; - /* 0x0198 */ Vec3s jointTable[BIGOKUTA_LIMB_MAX]; - /* 0x0210 */ Vec3s morphTable[BIGOKUTA_LIMB_MAX]; - /* 0x0288 */ f32 drawDmgEffAlpha; - /* 0x028C */ f32 drawDmgEffScale; - /* 0x0290 */ f32 drawDmgEffFrozenSteamScale; // only affects DRAWEFFECT_ICE - /* 0x0294 */ Vec3f playerPos; - /* 0x02A0 */ Vec3f playerHoldPos; - /* 0x02AC */ Vec3f camAt; - /* 0x02B8 */ Vec3f camEye; - /* 0x02C4 */ Vec3f limbPos[13]; - /* 0x0360 */ ColliderCylinder shellCollider; - /* 0x03AC */ ColliderCylinder bodyCollider; + /* 0x000 */ Actor actor; + /* 0x144 */ EnBigokutaUnkFunc unkFunc; // possibly something to do with photographing + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ EnBigokutaActionFunc actionFunc; + /* 0x190 */ u8 drawDmgEffType; + /* 0x192 */ s16 timer; + /* 0x194 */ s16 subCamId; + /* 0x196 */ s16 cutscene; + /* 0x198 */ Vec3s jointTable[BIGOKUTA_LIMB_MAX]; + /* 0x210 */ Vec3s morphTable[BIGOKUTA_LIMB_MAX]; + /* 0x288 */ f32 drawDmgEffAlpha; + /* 0x28C */ f32 drawDmgEffScale; + /* 0x290 */ f32 drawDmgEffFrozenSteamScale; // only affects DRAWEFFECT_ICE + /* 0x294 */ Vec3f playerPos; + /* 0x2A0 */ Vec3f playerHoldPos; + /* 0x2AC */ Vec3f subCamAt; + /* 0x2B8 */ Vec3f subCamEye; + /* 0x2C4 */ Vec3f limbPos[13]; + /* 0x360 */ ColliderCylinder shellCollider; + /* 0x3AC */ ColliderCylinder bodyCollider; } EnBigokuta; // size = 0x3F8 extern const ActorInit En_Bigokuta_InitVars; diff --git a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h index e845aad90..b2d01d468 100644 --- a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h +++ b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h @@ -8,12 +8,12 @@ struct EnBigpamet; typedef void (*EnBigpametActionFunc)(struct EnBigpamet*, PlayState*); typedef struct EnBigpamet { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x154]; - /* 0x0298 */ EnBigpametActionFunc actionFunc; - /* 0x029C */ char unk_29C[0x10]; - /* 0x02AC */ f32 unk_2AC; - /* 0x02B0 */ char unk_2B0[0x31C]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x154]; + /* 0x298 */ EnBigpametActionFunc actionFunc; + /* 0x29C */ char unk_29C[0x10]; + /* 0x2AC */ f32 unk_2AC; + /* 0x2B0 */ char unk_2B0[0x31C]; } EnBigpamet; // size = 0x5CC extern const ActorInit En_Bigpamet_InitVars; 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 087328c4d..6ba8eac96 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -271,14 +271,14 @@ void EnBigpo_UpdateSpin(EnBigpo* this) { void EnBigpo_LowerCutsceneSubCamera(EnBigpo* this, PlayState* play) { Camera* subCam; - if (this->cutsceneSubCamId != CAM_ID_MAIN) { - subCam = Play_GetCamera(play, this->cutsceneSubCamId); + if (this->subCamId != SUB_CAM_ID_DONE) { + subCam = Play_GetCamera(play, this->subCamId); subCam->eye.y -= this->actor.velocity.y; if (this->actor.velocity.y > 0.0f) { subCam->eye.x -= 1.5f * Math_SinS(this->actor.yawTowardsPlayer); subCam->eye.z -= 1.5f * Math_CosS(this->actor.yawTowardsPlayer); } - Play_CameraSetAtEye(play, this->cutsceneSubCamId, &this->actor.focus.pos, &subCam->eye); + Play_CameraSetAtEye(play, this->subCamId, &this->actor.focus.pos, &subCam->eye); } } @@ -303,7 +303,7 @@ void EnBigpo_WaitCutsceneQueue(EnBigpo* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_Start(this->actor.cutscene, &this->actor); func_800B724C(play, &this->actor, 7); - this->cutsceneSubCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); if (this->actor.params == ENBIGPO_REGULAR) { // and SUMMONED, got switched earlier EnBigpo_SpawnCutsceneStage1(this, play); } else { // ENBIGPO_REVEALEDFIRE @@ -332,13 +332,13 @@ void EnBigpo_SpawnCutsceneStage1(EnBigpo* this, PlayState* play) { this->actor.scale.y = 0.015f; this->actor.scale.z = 0.0f; - if (this->cutsceneSubCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { Vec3f subCamEye; subCamEye.x = ((this->actor.world.pos.x - this->fires[0].pos.x) * 1.8f) + this->actor.world.pos.x; subCamEye.y = this->actor.world.pos.y + 150.0f; subCamEye.z = ((this->actor.world.pos.z - this->fires[0].pos.z) * 1.8f) + this->actor.world.pos.z; - Play_CameraSetAtEye(play, this->cutsceneSubCamId, &this->actor.focus.pos, &subCamEye); + Play_CameraSetAtEye(play, this->subCamId, &this->actor.focus.pos, &subCamEye); } this->actionFunc = EnBigpo_SpawnCutsceneStage2; } @@ -459,9 +459,9 @@ void EnBigpo_SpawnCutsceneStage8(EnBigpo* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->idleTimer--; if (this->idleTimer == 0) { - subCam = Play_GetCamera(play, this->cutsceneSubCamId); + subCam = Play_GetCamera(play, this->subCamId); Play_CameraSetAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye); - this->cutsceneSubCamId = CAM_ID_MAIN; + this->subCamId = SUB_CAM_ID_DONE; if (this->actor.params == ENBIGPO_SUMMONED) { dampe = SubS_FindActor(play, NULL, ACTORCAT_NPC, ACTOR_EN_TK); if (dampe != NULL) { @@ -953,12 +953,11 @@ void EnBigpo_SetupFlameCirclePositions(EnBigpo* this, PlayState* play) { EnBigpo_SetupFlameCircleCutscene(firePo); } - // Setup sub camera - if (this->cutsceneSubCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { subCamEye.x = (Math_SinS(this->actor.yawTowardsPlayer) * 360.0f) + this->actor.world.pos.x; subCamEye.y = this->actor.world.pos.y + 150.0f; subCamEye.z = (Math_CosS(this->actor.yawTowardsPlayer) * 360.0f) + this->actor.world.pos.z; - Play_CameraSetAtEye(play, this->cutsceneSubCamId, &this->actor.focus.pos, &subCamEye); + Play_CameraSetAtEye(play, this->subCamId, &this->actor.focus.pos, &subCamEye); } this->actionFunc = EnBigpo_DoNothing; diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h index 36762f45d..248c9356c 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h @@ -35,7 +35,7 @@ typedef struct EnBigpo { /* 0x208 */ s16 unk208; // facing rotY? /* 0x20A */ s16 rotVelocity; /* 0x20C */ s16 unk20C; // is this counting the number of frames the player is ztargeting them? - /* 0x20E */ s16 cutsceneSubCamId; + /* 0x20E */ s16 subCamId; /* 0x210 */ s16 switchFlags; /* 0x212 */ s16 hoverHeightCycleTimer; // sin wave up and down bobbing /* 0x214 */ f32 fireRadius; // distance from center during conjunction cutscene 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 fd7ba4907..e22457a12 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -842,10 +842,10 @@ void EnBigslime_UpdateCameraFormingBigslime(EnBigslime* this, PlayState* play) { void EnBigslime_EndCutscene(EnBigslime* this, PlayState* play) { Camera* subCam; - if (this->subCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { subCam = Play_GetCamera(play, this->subCamId); Play_CameraSetAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye); - this->subCamId = CAM_ID_MAIN; + this->subCamId = SUB_CAM_ID_DONE; ActorCutscene_Stop(this->cutscene); this->cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); func_800B724C(play, &this->actor, 6); @@ -1018,7 +1018,7 @@ void EnBigslime_SetupMoveOnCeiling(EnBigslime* this) { this->actor.gravity = 0.0f; this->actor.velocity.y = 20.0f; - if (this->subCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { this->actor.speedXZ = 0.0f; this->ceilingMoveTimer = 20; } else { @@ -1042,7 +1042,7 @@ void EnBigslime_MoveOnCeiling(EnBigslime* this, PlayState* play) { EnBigslime_Scale(this, pitch, 0.04f, 0.04f); EnBigslime_UpdateWavySurface(this); - if (this->subCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { if (this->ceilingMoveTimer == 0) { EnBigslime_EndCutscene(this, play); this->ceilingMoveTimer = 320; @@ -2320,7 +2320,7 @@ void EnBigslime_SetupCutsceneDefeat(EnBigslime* this, PlayState* play) { s16 yawOffset; Animation_Change(&this->skelAnime, &gGekkoDamagedAnim, 0.5f, 0.0f, - Animation_GetLastFrame(&gGekkoDamagedAnim.common), 3, 0.0f); + Animation_GetLastFrame(&gGekkoDamagedAnim.common), ANIMMODE_ONCE_INTERP, 0.0f); this->gekkoCollider.base.acFlags &= ~AC_ON; this->defeatTimer = 60; this->actor.speedXZ = 10.0f; @@ -2545,7 +2545,7 @@ void EnBigslime_PlayCutscene(EnBigslime* this, PlayState* play) { func_800B724C(play, &this->actor, 7); } - this->subCamId = ActorCutscene_GetCurrentCamera(this->cutscene); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->cutscene); if (this->actor.colChkInfo.health == 0) { EnBigslime_SetupCutsceneDefeat(this, play); } else if ((this->actionFuncStored == EnBigslime_DamageGekko) || 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 985089dbc..63cc7ed57 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 @@ -99,7 +99,7 @@ void func_809CCEE8(EnBji01* this, PlayState* play) { } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { play->msgCtx.msgMode = 0; - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_809CD028(this, play); } else { if (this->moonsTear != NULL) { @@ -198,14 +198,14 @@ void func_809CD028(EnBji01* this, PlayState* play) { void EnBji01_DialogueHandler(EnBji01* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 0: + case TEXT_STATE_NONE: Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x444); func_809CCDE0(this, play); if (this->actor.shape.rot.y == this->actor.yawTowardsPlayer) { Message_StartTextbox(play, this->textId, &this->actor); } break; - case 4: + case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(play)) { this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; @@ -233,7 +233,7 @@ void EnBji01_DialogueHandler(EnBji01* this, PlayState* play) { } } break; - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { this->actor.flags &= ~ACTOR_FLAG_10000; switch (play->msgCtx.currentTextId) { @@ -282,7 +282,7 @@ void EnBji01_DialogueHandler(EnBji01* this, PlayState* play) { } } break; - case 6: + case TEXT_STATE_DONE: this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; this->actor.flags &= ~ACTOR_FLAG_10000; func_809CCE98(this, play); @@ -297,7 +297,7 @@ void func_809CD634(EnBji01* this, PlayState* play) { func_801A5BD0(0x6F); Audio_QueueSeqCmd(0xE0000101); play->nextEntranceIndex = 0x54A0; /* Termina Field from telescope */ - gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = play->nextEntranceIndex; + gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex = play->nextEntranceIndex; func_80169EFC(&play->state); /* Load new entrance? */ gSaveContext.respawnFlag = -2; this->actionFunc = EnBji01_DoNothing; @@ -374,7 +374,7 @@ void EnBji01_Update(Actor* thisx, PlayState* play) { s32 pad; this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, (Actor*)this, 0.0f, 0.0f, 0.0f, 4U); + Actor_UpdateBgCheckInfo(play, (Actor*)this, 0.0f, 0.0f, 0.0f, 4); SkelAnime_Update(&this->skelAnime); if (this->blinkTimer-- <= 0) { diff --git a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c index 3400e5f52..91c6d6a4f 100644 --- a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c +++ b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c @@ -15,10 +15,37 @@ void EnBjt_Destroy(Actor* thisx, PlayState* play); void EnBjt_Update(Actor* thisx, PlayState* play); void EnBjt_Draw(Actor* thisx, PlayState* play); -void func_80BFDA48(EnBjt* this, PlayState* play); -void func_80BFDAE8(EnBjt* this, PlayState* play); +void EnBjt_Talk(EnBjt* this, PlayState* play); +void EnBjt_FollowSchedule(EnBjt* this, PlayState* play); + +#define TOILET_HAND_STATE_TALKING (1 << 3) // Actually talking to Player +#define TOILET_HAND_STATE_TEXTBOX (1 << 4) // Whenever a textbox is on screen +#define TOILET_HAND_STATE_APPEARING (1 << 7) // Appearing +#define TOILET_HAND_STATE_VANISHING (1 << 8) // Vanishing +#define TOILET_HAND_STATE_VISIBLE (1 << 9) // Out + +typedef enum { + /* 0 */ TOILET_HAND_SCH_NONE, + /* 1 */ TOILET_HAND_SCH_AVAILABLE +} ToiletHandScheduleResult; + +static u8 sScheduleScript[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x11 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 6, 0, 0x0B - 0x0A), + /* 0x0A */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B */ SCHEDULE_CMD_RET_TIME(0, 0, 6, 0, TOILET_HAND_SCH_AVAILABLE), + /* 0x11 */ SCHEDULE_CMD_RET_NONE(), +}; + +static u8 sMsgEventScript[] = { + 0x0E, 0x29, 0x48, 0x0C, 0x0E, 0x00, 0xFF, 0x2B, 0x00, 0x00, 0x00, 0x52, 0x00, 0x5F, 0x2C, 0x29, 0x4A, 0x0C, 0x2F, + 0x00, 0x00, 0x0C, 0x15, 0x09, 0x00, 0x00, 0x0E, 0x29, 0x4B, 0x0C, 0x15, 0x09, 0x00, 0x00, 0x0E, 0x29, 0x4C, 0x0C, + 0x12, 0x00, 0x49, 0x08, 0x00, 0x1D, 0x09, 0x00, 0x00, 0x06, 0x00, 0x0C, 0x00, 0x00, 0x13, 0x00, 0x0C, 0x2F, 0x00, + 0x00, 0x2E, 0x2D, 0x00, 0x28, 0x2D, 0x00, 0x0D, 0x0C, 0x11, 0x49, 0x08, 0x11, 0x5A, 0x80, 0x10, 0x09, 0x00, 0x00, + 0x06, 0x00, 0x02, 0x00, 0x00, 0x13, 0x00, 0x02, 0x2F, 0x00, 0x00, 0x2E, 0x2D, 0x00, 0x0D, 0x0C, 0x11, 0x5A, 0x80, + 0x10, 0x2C, 0x29, 0x49, 0x0C, 0x2F, 0x00, 0x00, 0x0C, 0x2D, 0x00, 0x0D, 0x12, 0x10, 0x2D, 0x00, 0x0D, 0x12, 0x10, +}; -#if 0 const ActorInit En_Bjt_InitVars = { ACTOR_EN_BJT, ACTORCAT_NPC, @@ -31,49 +58,407 @@ const ActorInit En_Bjt_InitVars = { (ActorFunc)EnBjt_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BFDF48 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 68, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BFDF74 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +typedef enum { + /* -1 */ TOILET_HAND_ANIM_NONE = -1, + /* 0 */ TOILET_HAND_ANIM_WAITING, + /* 1 */ TOILET_HAND_ANIM_WAITING_MORPH, // Same as TOILET_HAND_ANIM_WAITING, but with morph frames + /* 2 */ TOILET_HAND_ANIM_WAGGING_FINGER, // Wrong + /* 3 */ TOILET_HAND_ANIM_THUMBS_UP, // Right + /* 4 */ TOILET_HAND_ANIM_OPEN_HAND, + /* 5 */ TOILET_HAND_ANIM_FIST // i.e. holding the reward +} ToiletHandAnimations; -extern ColliderCylinderInit D_80BFDF48; -extern CollisionCheckInfoInit2 D_80BFDF74; +static AnimationInfoS sAnimationInfos[] = { + /* 0 */ { &gToiletHandWaitingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + /* 1 */ { &gToiletHandWaitingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + /* 2 */ { &gToiletHandWaggingFingerAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + /* 3 */ { &gToiletHandThumbsUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + /* 4 */ { &gToiletHandOpenHandAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + /* 5 */ { &gToiletHandFistAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, +}; -extern UNK_TYPE D_06002390; +void EnBjt_UpdateSkelAnime(EnBjt* this) { + this->skelAnime.playSpeed = this->animPlaySpeed; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD2E0.s") +s32 EnBjt_ChangeAnimation(EnBjt* this, s32 animIndex) { + s32 changeAnim = false; + s32 changed = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD30C.s") + if ((animIndex == TOILET_HAND_ANIM_WAITING) || (animIndex == TOILET_HAND_ANIM_WAITING_MORPH)) { + if (!((this->curAnimIndex == TOILET_HAND_ANIM_WAITING) || + (this->curAnimIndex == TOILET_HAND_ANIM_WAITING_MORPH))) { + changeAnim = true; + } + } else if (this->curAnimIndex != animIndex) { + changeAnim = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD3A4.s") + if (changeAnim) { + this->curAnimIndex = animIndex; + changed = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfos, animIndex); + this->animPlaySpeed = this->skelAnime.playSpeed; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD434.s") + return changed; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD4FC.s") +void EnBjt_UpdateCollision(EnBjt* this, PlayState* play) { + static Vec3f sColliderBasePos = { 0.0f, 8.0f, 10.0f }; + s32 pad; + Vec3f pos; + f32 height; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD5E4.s") + if (this->stateFlags & (TOILET_HAND_STATE_APPEARING | TOILET_HAND_STATE_VISIBLE)) { + Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &sColliderBasePos, &pos); + Math_Vec3f_ToVec3s(&this->collider.dim.pos, &pos); + height = this->actor.focus.pos.y - this->actor.world.pos.y; + this->collider.dim.height = height; + this->collider.dim.radius = 32; + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD6BC.s") +s32 EnBjt_TakeItem(s32 exchangeItem) { + switch (exchangeItem) { + case EXCH_ITEM_LETTER_TO_KAFEI: + Inventory_DeleteItem(ITEM_LETTER_TO_KAFEI, SLOT(ITEM_LETTER_TO_KAFEI)); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD8F0.s") + case EXCH_ITEM_DEED_SWAMP: + Inventory_DeleteItem(ITEM_DEED_SWAMP, SLOT(ITEM_DEED_SWAMP)); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFD984.s") + case EXCH_ITEM_DEED_MOUNTAIN: + Inventory_DeleteItem(ITEM_DEED_MOUNTAIN, SLOT(ITEM_DEED_MOUNTAIN)); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFDA48.s") + case EXCH_ITEM_DEED_OCEAN: + Inventory_DeleteItem(ITEM_DEED_OCEAN, SLOT(ITEM_DEED_OCEAN)); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/func_80BFDAE8.s") + case EXCH_ITEM_DEED_LAND: + Inventory_DeleteItem(ITEM_DEED_LAND, SLOT(ITEM_DEED_LAND)); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/EnBjt_Init.s") + case EXCH_ITEM_LETTER_MAMA: + Inventory_DeleteItem(ITEM_LETTER_MAMA, SLOT(ITEM_LETTER_MAMA)); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/EnBjt_Destroy.s") + default: + break; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/EnBjt_Update.s") +#define FULLY_GROWN_SCALE 0.017f -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bjt/EnBjt_Draw.s") +/** + * @return boolean true if scale is set to final value + */ +s32 EnBjt_Appear(EnBjt* this) { + s32 finished = false; + + if (!this->playedSfx) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TOILET_HAND_APPEAR); + this->playedSfx = true; + } + + Math_ApproachF(&this->actor.scale.x, FULLY_GROWN_SCALE, 0.21f, 0.3f); + if ((FULLY_GROWN_SCALE - this->actor.scale.x) < FULLY_GROWN_SCALE / 100.0f) { + this->actor.scale.x = FULLY_GROWN_SCALE; + this->stateFlags |= TOILET_HAND_STATE_VISIBLE; + this->stateFlags &= ~TOILET_HAND_STATE_APPEARING; + finished = true; + } + this->heightOffset = (this->actor.scale.x / FULLY_GROWN_SCALE) * 4.0f; + this->actor.world.pos.y = this->actor.home.pos.y + this->heightOffset; + Actor_SetScale(&this->actor, this->actor.scale.x); + + return finished; +} + +/** + * @return boolean true if scale is set to final value + */ +s32 EnBjt_Vanish(EnBjt* this) { + s32 finished = false; + + if (!this->playedSfx) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TOILET_HAND_VANISH); + this->playedSfx = true; + } + + Math_ApproachF(&this->actor.scale.x, 0.0f, 0.21f, 0.3f); + if (this->actor.scale.x < FULLY_GROWN_SCALE / 100.0f) { + this->actor.scale.x = 0.0f; + this->stateFlags &= ~TOILET_HAND_STATE_VANISHING; + finished = true; + } + this->heightOffset = (this->actor.scale.x / FULLY_GROWN_SCALE) * 4.0f; + this->actor.world.pos.y = this->actor.home.pos.y + this->heightOffset; + Actor_SetScale(&this->actor, this->actor.scale.x); + + return finished; +} + +typedef enum { + /* 0 */ TOILET_HAND_BEHAVIOUR_WAIT_FOR_ITEM, // and check if item is suitable + /* 1 */ TOILET_HAND_BEHAVIOUR_TAKE_ITEM, // take paper and disappear to use it + /* 2 */ TOILET_HAND_BEHAVIOUR_USE_ITEM, // using paper, flushing + /* 3 */ TOILET_HAND_BEHAVIOUR_REAPPEAR, // reappear with reward + /* 4 */ TOILET_HAND_BEHAVIOUR_REWARD_GIVEN, +} ToiletHandBehaviour; + +// msgevent callback/communication. Follow and choose parts of script to run +s32 EnBjt_ChooseBehaviour(Actor* thisx, PlayState* play) { + Player* player = GET_PLAYER(play); + EnBjt* this = THIS; + s32 itemAP; + s32 scriptBranch = 0; + + switch (this->behaviour) { + case TOILET_HAND_BEHAVIOUR_WAIT_FOR_ITEM: + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + if (!Message_ShouldAdvance(play)) { + break; + } + // Fallthrough + case TEXT_STATE_16: + itemAP = func_80123810(play); + if ((itemAP == EXCH_ITEM_DEED_LAND) || (itemAP == EXCH_ITEM_LETTER_TO_KAFEI) || + (itemAP == EXCH_ITEM_DEED_SWAMP) || (itemAP == EXCH_ITEM_DEED_MOUNTAIN) || + (itemAP == EXCH_ITEM_DEED_OCEAN) || (itemAP == EXCH_ITEM_LETTER_MAMA)) { + EnBjt_ChangeAnimation(this, TOILET_HAND_ANIM_WAITING_MORPH); + this->playedSfx = false; + this->behaviour++; + scriptBranch = 1; // Right item + } else if (itemAP < 0) { + this->playedSfx = false; + this->behaviour++; + scriptBranch = 3; // Not showing item + } else if (itemAP != 0) { + this->playedSfx = false; + this->behaviour++; + scriptBranch = 2; // Wrong item + } + break; + + default: + break; + } + break; + + case TOILET_HAND_BEHAVIOUR_TAKE_ITEM: + if (player->exchangeItemId != EXCH_ITEM_NONE) { + EnBjt_TakeItem(player->exchangeItemId); + player->exchangeItemId = EXCH_ITEM_NONE; + } + if (EnBjt_Vanish(this)) { + this->timer = 60; + this->behaviour++; + scriptBranch = 1; // Right item + } + break; + + case TOILET_HAND_BEHAVIOUR_USE_ITEM: + if (DECR(this->timer) == 0) { + EnBjt_ChangeAnimation(this, TOILET_HAND_ANIM_FIST); // change while not visible + this->playedSfx = false; + this->behaviour++; + } else if (this->timer == 10) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TOILET_WATER); + } + break; + + case TOILET_HAND_BEHAVIOUR_REAPPEAR: + if (EnBjt_Appear(this)) { + this->behaviour++; + scriptBranch = 1; // Right item + } + break; + + case TOILET_HAND_BEHAVIOUR_REWARD_GIVEN: + EnBjt_ChangeAnimation(this, TOILET_HAND_ANIM_OPEN_HAND); + this->behaviour++; + scriptBranch = 1; // Right item + break; + + default: + break; + } + + return scriptBranch; +} + +s32 EnBjt_CheckTalk(EnBjt* this, PlayState* play) { + s32 ret = false; + + if ((this->stateFlags & 7) && Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->stateFlags |= TOILET_HAND_STATE_TALKING; + SubS_UpdateFlags(&this->stateFlags, 0, 7); + this->msgEventCallback = EnBjt_ChooseBehaviour; + this->behaviour = 0; + this->actionFunc = EnBjt_Talk; + ret = true; + } + return ret; +} + +s32 EnBjt_ChooseAnimation(EnBjt* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u16 curTextId = play->msgCtx.currentTextId; + + if (player->stateFlags1 & (PLAYER_STATE1_40 | PLAYER_STATE1_400)) { // Talking, show item? + this->stateFlags |= TOILET_HAND_STATE_TEXTBOX; + if (this->textId != curTextId) { + switch (curTextId) { + case 0x2949: // Wrong item + EnBjt_ChangeAnimation(this, TOILET_HAND_ANIM_WAGGING_FINGER); + break; + + case 0x294A: // Right item + EnBjt_ChangeAnimation(this, TOILET_HAND_ANIM_THUMBS_UP); + break; + + default: + break; + } + } + this->textId = curTextId; + } else if (this->stateFlags & TOILET_HAND_STATE_TEXTBOX) { + this->stateFlags &= ~TOILET_HAND_STATE_TEXTBOX; + EnBjt_ChangeAnimation(this, TOILET_HAND_ANIM_WAITING); + } + return 0; +} + +// Action function, based on msgEvent +void EnBjt_Talk(EnBjt* this, PlayState* play) { + s16 yaw = this->actor.yawTowardsPlayer; + + // TODO: Casting to remove warning for now + if (func_8010BF58(&this->actor, play, (s32)sMsgEventScript, this->msgEventCallback, &this->msgEventArg4)) { + this->actor.flags &= ~ACTOR_FLAG_100; + SubS_UpdateFlags(&this->stateFlags, 3, 7); + this->stateFlags &= ~TOILET_HAND_STATE_TALKING; + this->msgEventArg4 = 0; + this->actionFunc = EnBjt_FollowSchedule; + } else { + Math_ApproachS(&this->actor.shape.rot.y, yaw, 4, 0x2AA8); + } +} + +// Change state based on schedule and stateFlags +void EnBjt_FollowSchedule(EnBjt* this, PlayState* play) { + ScheduleOutput scheduleOutput; + + if (!Schedule_RunScript(play, sScheduleScript, &scheduleOutput)) { + scheduleOutput.result = TOILET_HAND_SCH_NONE; + } + if (scheduleOutput.result == TOILET_HAND_SCH_AVAILABLE) { + if (this->stateFlags & TOILET_HAND_STATE_APPEARING) { + if (EnBjt_Appear(this)) { + SubS_UpdateFlags(&this->stateFlags, 3, 7); + } + } else if (this->stateFlags & TOILET_HAND_STATE_VANISHING) { + EnBjt_Vanish(this); + } else if (this->stateFlags & TOILET_HAND_STATE_VISIBLE) { + // Vanish if player goes too far away or heart piece given + if ((fabsf(this->actor.playerHeightRel) > 70.0f) || (this->actor.xzDistToPlayer > 140.0f) || + (gSaveContext.save.weekEventReg[90] & 0x80)) { + SubS_UpdateFlags(&this->stateFlags, 0, 7); + this->playedSfx = false; + this->stateFlags &= ~TOILET_HAND_STATE_VISIBLE; + this->stateFlags |= TOILET_HAND_STATE_VANISHING; + } + } else { + // Appear if player approaches and heart piece not given + if ((fabsf(this->actor.playerHeightRel) < 20.0f) && (this->actor.xzDistToPlayer < 70.0f) && + !(gSaveContext.save.weekEventReg[90] & 0x80)) { + this->stateFlags |= TOILET_HAND_STATE_APPEARING; + this->playedSfx = false; + } + } + this->scheduleResult = scheduleOutput.result; + } else { + this->actor.flags |= ACTOR_FLAG_8000000; + Actor_SetScale(&this->actor, 0.0f); + this->stateFlags = 0; + this->msgEventCallback = NULL; + this->scheduleResult = TOILET_HAND_SCH_NONE; + } +} + +void EnBjt_Init(Actor* thisx, PlayState* play) { + EnBjt* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gToiletHandSkel, NULL, this->jointTable, this->morphTable, + TOILET_HAND_LIMB_MAX); + + this->curAnimIndex = TOILET_HAND_ANIM_NONE; + EnBjt_ChangeAnimation(this, TOILET_HAND_ANIM_WAITING); + + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + this->actor.flags |= ACTOR_FLAG_8000000; + Actor_SetScale(&this->actor, 0.0f); + + this->scheduleResult = TOILET_HAND_SCH_NONE; + this->stateFlags = 0; + this->actionFunc = EnBjt_FollowSchedule; +} + +void EnBjt_Destroy(Actor* thisx, PlayState* play) { +} + +void EnBjt_Update(Actor* thisx, PlayState* play) { + EnBjt* this = THIS; + + EnBjt_CheckTalk(this, play); + this->actionFunc(this, play); + EnBjt_ChooseAnimation(this, play); + + if (this->scheduleResult != TOILET_HAND_SCH_NONE) { + EnBjt_UpdateSkelAnime(this); + func_8013C964(&this->actor, play, 60.0f, 10.0f, EXCH_ITEM_NONE, this->stateFlags & 7); + Actor_SetFocus(&this->actor, 26.0f); + EnBjt_UpdateCollision(this, play); + } +} + +void EnBjt_Draw(Actor* thisx, PlayState* play) { + EnBjt* this = THIS; + + if (this->scheduleResult != TOILET_HAND_SCH_NONE) { + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, &this->actor); + } +} diff --git a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.h b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.h index 54ed04c40..d1aabb999 100644 --- a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.h +++ b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.h @@ -2,18 +2,36 @@ #define Z_EN_BJT_H #include "global.h" +#include "objects/object_bjt/object_bjt.h" struct EnBjt; typedef void (*EnBjtActionFunc)(struct EnBjt*, PlayState*); +typedef s32 (*MsgEventFunc)(Actor*, PlayState*); typedef struct EnBjt { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnBjtActionFunc actionFunc; - /* 0x018C */ char unk_18C[0xD0]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnBjtActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ u8 scheduleResult; + /* 0x1DC */ s32 msgEventArg4; + /* 0x1E0 */ Vec3s jointTable[TOILET_HAND_LIMB_MAX]; + /* 0x20A */ Vec3s morphTable[TOILET_HAND_LIMB_MAX]; + /* 0x234 */ u16 stateFlags; + /* 0x236 */ u16 textId; + /* 0x238 */ f32 animPlaySpeed; + /* 0x23C */ f32 heightOffset; + /* 0x240 */ s16 behaviour; + /* 0x242 */ s16 timer; + /* 0x244 */ UNK_TYPE1 unk_244[4]; + /* 0x248 */ s32 playedSfx; // to only play once + /* 0x24C */ MsgEventFunc msgEventCallback; + /* 0x250 */ s32 curAnimIndex; + /* 0x254 */ UNK_TYPE1 pad_254[8]; } EnBjt; // size = 0x25C + extern const ActorInit En_Bjt_InitVars; #endif // Z_EN_BJT_H diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index c00a9adf5..3271d8bcb 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -89,7 +89,7 @@ static ColliderJntSphInit sJntSphInit1 = { OC2_NONE, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit1), sJntSphElementsInit1, }; @@ -116,7 +116,7 @@ static ColliderJntSphInit sJntSphInit2 = { OC2_NONE, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit2), sJntSphElementsInit2, }; @@ -502,7 +502,7 @@ void EnBom_Update(Actor* thisx, PlayState* play) { (this->collider1.base.oc->category == ACTORCAT_BOSS)))) { this->timer = 0; thisx->shape.rot.z = 0; - } else if ((this->timer > 100) && (func_80123F48(play, &thisx->world.pos, 30.0f, 50.0f))) { + } else if ((this->timer > 100) && (Player_IsBurningStickInRange(play, &thisx->world.pos, 30.0f, 50.0f))) { this->timer = 100; } @@ -538,7 +538,7 @@ void EnBom_Update(Actor* thisx, PlayState* play) { play->envCtx.lightSettings.diffuseColor1[2] = 250; play->envCtx.lightSettings.ambientColor[0] = play->envCtx.lightSettings.ambientColor[1] = play->envCtx.lightSettings.ambientColor[2] = 250; - func_800DFD04(&play->mainCamera, 2, 11, 8); + Camera_AddQuake(&play->mainCamera, 2, 11, 8); thisx->params = ENBOM_1; this->timer = 10; thisx->flags |= (0x100000 | 0x20); diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index 51d077cd9..4aaa21bce 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -98,7 +98,7 @@ void EnBomBowlMan_Init(Actor* thisx, PlayState* play) { this->unk_2C8 = 80.0f; if ((gSaveContext.save.entranceIndex == 0xD220) && (gSaveContext.save.weekEventReg[73] & 0x80) && - !CHECK_QUEST_ITEM(ITEM_BOTTLE)) { + !CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { this->unk_2D6 = this->actor.cutscene; if (this->unk_2D6 == 0) { Actor_MarkForDeath(&this->actor); @@ -237,7 +237,7 @@ void func_809C4DA4(EnBomBowlMan* this, PlayState* play) { } } - if ((this->unk_2BC == 0) && (Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((this->unk_2BC == 0) && (Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { Player* player = GET_PLAYER(play); s32 pad; s32 sp28 = false; @@ -248,7 +248,7 @@ void func_809C4DA4(EnBomBowlMan* this, PlayState* play) { case 0: this->unk_2C0 = 1; D_809C6104 = 1; - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentCamera(this->unk_2D0)), + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->unk_2D0)), &this->unk_2D8[0]->actor); this->unk_2D4 = 0; this->unk_2BC = 10; @@ -260,7 +260,7 @@ void func_809C4DA4(EnBomBowlMan* this, PlayState* play) { func_809C493C(this, 3, 1.0f); this->unk_2D4 = this->actor.yawTowardsPlayer; this->unk_2C0 = 2; - if ((player->transformation == PLAYER_FORM_HUMAN) && CHECK_QUEST_ITEM(ITEM_BOTTLE)) { + if ((player->transformation == PLAYER_FORM_HUMAN) && CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { this->unk_2C0 = 4; } break; @@ -273,7 +273,7 @@ void func_809C4DA4(EnBomBowlMan* this, PlayState* play) { sp28 = true; } else { this->unk_2C0 = 3; - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_809C493C(this, 1, 1.0f); D_809C6100 = 1; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -301,7 +301,7 @@ void func_809C4DA4(EnBomBowlMan* this, PlayState* play) { if (this->unk_2B8 != 2) { ActorCutscene_Stop(this->unk_2D0); } - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_809C493C(this, 1, 1.0f); D_809C6100 = 1; this->actionFunc = func_809C5B1C; @@ -330,12 +330,13 @@ void func_809C4DA4(EnBomBowlMan* this, PlayState* play) { void func_809C51B4(EnBomBowlMan* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((play->msgCtx.unk120B1 == 0) && ((play->msgCtx.msgMode == 0) || (Message_GetState(&play->msgCtx) == 6))) { + if ((play->msgCtx.unk120B1 == 0) && + ((play->msgCtx.msgMode == 0) || (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE))) { play->nextEntranceIndex = Entrance_CreateIndexFromSpawn(6); gSaveContext.nextCutsceneIndex = 0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 0x56; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_86; + gSaveContext.nextTransitionType = TRANS_TYPE_03; gSaveContext.save.weekEventReg[75] &= (u8)~0x40; if (player->transformation == PLAYER_FORM_HUMAN) { gSaveContext.save.weekEventReg[84] |= 0x80; @@ -409,7 +410,7 @@ void func_809C5524(EnBomBowlMan* this, PlayState* play) { } void func_809C5598(EnBomBowlMan* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); if ((this->actor.textId == 0x72F) || (this->actor.textId == 0x730)) { this->actor.textId = 0x731; @@ -447,7 +448,8 @@ void func_809C5738(EnBomBowlMan* this, PlayState* play) { s16 yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2A0); if (this->unk_2C2 == 0) { - if ((play->msgCtx.unk120B1 == 0) && ((play->msgCtx.msgMode == 0) || (Message_GetState(&play->msgCtx) == 6))) { + if ((play->msgCtx.unk120B1 == 0) && + ((play->msgCtx.msgMode == 0) || (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE))) { this->unk_2C2 = 1; func_809C4B6C(this); if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -550,7 +552,7 @@ void func_809C5BA0(EnBomBowlMan* this) { void func_809C5BF4(EnBomBowlMan* this, PlayState* play) { f32 sp2C = this->skelAnime.curFrame; - s32 sp28; + s32 subCam; if ((D_809C6104 != 0) && (this->unk_2F8 != 15)) { func_809C493C(this, 15, 1.0f); @@ -571,13 +573,13 @@ void func_809C5BF4(EnBomBowlMan* this, PlayState* play) { } if (this->unk_2F4 == 0) { - sp28 = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(this->unk_2D2)); + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->unk_2D2)); if (D_809C6100 > 5) { Player* player = GET_PLAYER(play); func_801477B4(play); - Camera_SetTargetActor(sp28, &this->unk_2D8[0]->actor); + Camera_SetTargetActor(subCam, &this->unk_2D8[0]->actor); func_809C493C(this, 13, 1.0f); D_809C6100 = 0; if (player->transformation == PLAYER_FORM_HUMAN) { @@ -592,7 +594,7 @@ void func_809C5BF4(EnBomBowlMan* this, PlayState* play) { } else { s32 idx = D_809C6100 - 1; - Camera_SetTargetActor(sp28, &this->unk_2D8[1 + idx]->actor); + Camera_SetTargetActor(subCam, &this->unk_2D8[1 + idx]->actor); } } } diff --git a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c index 10b952244..7d4fbbafb 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -175,7 +175,7 @@ void func_80C038B4(EnBombers* this) { void func_80C039A8(EnBombers* this, PlayState* play) { Player* player = GET_PLAYER(play); - this->unk_2A6 = 5; + this->unk_2A6 = TEXT_STATE_5; switch (player->transformation) { case PLAYER_FORM_HUMAN: @@ -296,7 +296,7 @@ void func_80C03AF4(EnBombers* this, PlayState* play) { if (!Text_GetFaceReaction(play, 0x12)) { func_80C039A8(this, play); } else { - this->unk_2A6 = 5; + this->unk_2A6 = TEXT_STATE_5; this->actor.textId = Text_GetFaceReaction(play, 0x12); } @@ -337,11 +337,11 @@ void func_80C03FAC(EnBombers* this, PlayState* play) { if ((this->unk_2A6 == Message_GetState(&play->msgCtx)) && Message_ShouldAdvance(play)) { sp2A = 0; func_801477B4(play); - this->unk_2A6 = 5; + this->unk_2A6 = TEXT_STATE_5; if ((this->actor.textId == 0x73D) || (this->actor.textId == 0x73E) || (this->actor.textId == 0x73F)) { this->actor.textId = 0x740; - this->unk_2A6 = 4; + this->unk_2A6 = TEXT_STATE_CHOICE; sp2A = 1; } else if (this->actor.textId == 0x740) { if (play->msgCtx.choiceIndex == 0) { @@ -361,7 +361,7 @@ void func_80C03FAC(EnBombers* this, PlayState* play) { sp2A = 1; } else if (this->actor.textId == 0x74B) { this->actor.textId = 0x74C; - this->unk_2A6 = 4; + this->unk_2A6 = TEXT_STATE_CHOICE; sp2A = 1; } else if (this->actor.textId == 0x74C) { if (play->msgCtx.choiceIndex == 1) { @@ -446,7 +446,7 @@ void func_80C04354(EnBombers* this, PlayState* play) { void func_80C043C8(EnBombers* this, PlayState* play) { Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); func_80C042F8(this); } diff --git a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h index 4365c1f66..538b0d8b5 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h @@ -21,33 +21,33 @@ enum { #define ENBOMBERS_F0_0 0 typedef struct EnBombers { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[21]; - /* 0x0206 */ Vec3s morphtable[21]; - /* 0x0284 */ EnBombersActionFunc actionFunc; - /* 0x0288 */ s16 unk_288; - /* 0x028A */ s16 unk_28A; - /* 0x028C */ UNK_TYPE1 unk28C[2]; - /* 0x028E */ s16 unk_28E; - /* 0x0290 */ s16 unk_290; - /* 0x0294 */ Vec3f unk_294; - /* 0x02A0 */ s16 unk_2A0; - /* 0x02A2 */ UNK_TYPE1 unk2A2[2]; - /* 0x02A4 */ s16 unk_2A4; - /* 0x02A6 */ s16 unk_2A6; - /* 0x02A8 */ s16 unk_2A8; - /* 0x02AA */ s16 unk_2AA; - /* 0x02AC */ s16 unk_2AC; - /* 0x02B0 */ f32 unk_2B0; - /* 0x02B4 */ f32 unk_2B4; - /* 0x02B8 */ s16 unk_2B8; - /* 0x02BA */ s16 unk_2BA; - /* 0x02BC */ s16 unk_2BC; - /* 0x02BE */ s16 unk_2BE; - /* 0x02C0 */ s16 unk_2C0; - /* 0x02C4 */ s32 unk_2C4; - /* 0x02C8 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[21]; + /* 0x206 */ Vec3s morphtable[21]; + /* 0x284 */ EnBombersActionFunc actionFunc; + /* 0x288 */ s16 unk_288; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ UNK_TYPE1 unk28C[2]; + /* 0x28E */ s16 unk_28E; + /* 0x290 */ s16 unk_290; + /* 0x294 */ Vec3f unk_294; + /* 0x2A0 */ s16 unk_2A0; + /* 0x2A2 */ UNK_TYPE1 unk2A2[2]; + /* 0x2A4 */ s16 unk_2A4; + /* 0x2A6 */ s16 unk_2A6; + /* 0x2A8 */ s16 unk_2A8; + /* 0x2AA */ s16 unk_2AA; + /* 0x2AC */ s16 unk_2AC; + /* 0x2B0 */ f32 unk_2B0; + /* 0x2B4 */ f32 unk_2B4; + /* 0x2B8 */ s16 unk_2B8; + /* 0x2BA */ s16 unk_2BA; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C4 */ s32 unk_2C4; + /* 0x2C8 */ ColliderCylinder collider; } EnBombers; // size = 0x314 extern const ActorInit En_Bombers_InitVars; diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c index 95c413baf..265388ff7 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c @@ -146,12 +146,12 @@ void func_80C04BA0(EnBombers2* this, PlayState* play) { case PLAYER_FORM_GORON: case PLAYER_FORM_ZORA: this->textIdIndex = 1; - this->unk_2CE = 5; + this->talkState = TEXT_STATE_5; break; case PLAYER_FORM_DEKU: case PLAYER_FORM_HUMAN: this->textIdIndex = 2; - this->unk_2CE = 5; + this->talkState = TEXT_STATE_5; break; } if (this->unk_2AC != 0) { @@ -213,8 +213,8 @@ void func_80C04D8C(EnBombers2* this, PlayState* play) { default: break; } - if ((this->unk_2CE == Message_GetState(&play->msgCtx)) && Message_ShouldAdvance(play)) { - if (this->unk_2CE == 0xF) { + if ((this->talkState == Message_GetState(&play->msgCtx)) && Message_ShouldAdvance(play)) { + if (this->talkState == TEXT_STATE_15) { s32 i; s32 correctDigits; @@ -234,7 +234,7 @@ void func_80C04D8C(EnBombers2* this, PlayState* play) { this->actor.textId = sTextIds[this->textIdIndex]; func_80151938(play, this->actor.textId); Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); - this->unk_2CE = 5; + this->talkState = TEXT_STATE_5; return; } } @@ -258,7 +258,7 @@ void func_80C04D8C(EnBombers2* this, PlayState* play) { this->textIdIndex = 3; this->actor.textId = sTextIds[this->textIdIndex]; func_80151938(play, this->actor.textId); - this->unk_2CE = 0xF; + this->talkState = TEXT_STATE_15; break; case 3: for (j = 0; j < ARRAY_COUNT(this->correctDigitSlots); j++) { @@ -268,16 +268,16 @@ void func_80C04D8C(EnBombers2* this, PlayState* play) { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); this->actor.textId = sTextIds[this->textIdIndex]; func_80151938(play, this->actor.textId); - this->unk_2CE = 5; + this->talkState = TEXT_STATE_5; break; case 4: this->textIdIndex = 5; this->actor.textId = sTextIds[this->textIdIndex]; func_80151938(play, this->actor.textId); - this->unk_2CE = 5; + this->talkState = TEXT_STATE_5; break; case 6: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80C050B8(this, play); break; } @@ -324,7 +324,7 @@ void func_80C0520C(EnBombers2* this, PlayState* play) { this->actor.speedXZ = 0.0f; if (fabsf(this->actor.world.rot.y - this->actor.yawTowardsPlayer) < 100.0f) { func_801477B4(play); - this->unk_2CE = 5; + this->talkState = TEXT_STATE_5; this->textIdIndex = 7; EnBombers2_ChangeAnim(this, 6, 1.0f); this->unk_2A8 = 0; diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h index a5120ffcf..0a62fd704 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h @@ -10,35 +10,35 @@ struct EnBombers2; typedef void (*EnBombers2ActionFunc)(struct EnBombers2*, PlayState*); typedef struct EnBombers2 { - /* 0x0000 */ Actor actor; - /* 0x014C */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s morphTable[OBJECT_CS_LIMB_MAX]; - /* 0x0206 */ Vec3s jointTable[OBJECT_CS_LIMB_MAX]; - /* 0x0284 */ EnBombers2ActionFunc actionFunc; - /* 0x0288 */ s16 unk_288; - /* 0x028A */ s16 unk_28A; - /* 0x028C */ UNK_TYPE1 pad_28C[2]; - /* 0x028E */ s16 unk_28E; - /* 0x0290 */ s16 unk_290; - /* 0x0292 */ UNK_TYPE1 pad_292[4]; - /* 0x0296 */ s16 unk_296; - /* 0x0298 */ UNK_TYPE1 pad_298[4]; - /* 0x029C */ Vec3f unk_29C; - /* 0x02A8 */ s32 unk_2A8; - /* 0x02AC */ u8 unk_2AC; - /* 0x02AE */ s16 animIndex; - /* 0x02B0 */ s16 cutscene; - /* 0x02B2 */ s16 unk_2B2; - /* 0x02B4 */ s16 unk_2B4; - /* 0x02B6 */ s16 unk_2B6; - /* 0x02B8 */ f32 lastAnimFrame; - /* 0x02BC */ s16 eyeIndex; - /* 0x02BE */ s16 unk_2BE; - /* 0x02C0 */ s16 unk_2C0; - /* 0x02C2 */ s16 textIdIndex; - /* 0x02C4 */ s16 correctDigitSlots[5]; - /* 0x02CE */ s16 unk_2CE; - /* 0x02D0 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x14C */ SkelAnime skelAnime; + /* 0x188 */ Vec3s morphTable[OBJECT_CS_LIMB_MAX]; + /* 0x206 */ Vec3s jointTable[OBJECT_CS_LIMB_MAX]; + /* 0x284 */ EnBombers2ActionFunc actionFunc; + /* 0x288 */ s16 unk_288; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ UNK_TYPE1 pad_28C[2]; + /* 0x28E */ s16 unk_28E; + /* 0x290 */ s16 unk_290; + /* 0x292 */ UNK_TYPE1 pad_292[4]; + /* 0x296 */ s16 unk_296; + /* 0x298 */ UNK_TYPE1 pad_298[4]; + /* 0x29C */ Vec3f unk_29C; + /* 0x2A8 */ s32 unk_2A8; + /* 0x2AC */ u8 unk_2AC; + /* 0x2AE */ s16 animIndex; + /* 0x2B0 */ s16 cutscene; + /* 0x2B2 */ s16 unk_2B2; + /* 0x2B4 */ s16 unk_2B4; + /* 0x2B6 */ s16 unk_2B6; + /* 0x2B8 */ f32 lastAnimFrame; + /* 0x2BC */ s16 eyeIndex; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C2 */ s16 textIdIndex; + /* 0x2C4 */ s16 correctDigitSlots[5]; + /* 0x2CE */ s16 talkState; + /* 0x2D0 */ ColliderCylinder collider; } EnBombers2; // size = 0x31C extern const ActorInit En_Bombers2_InitVars; diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index 5fb2758c5..4a7ac1baf 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -79,7 +79,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_NONE, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -182,7 +182,7 @@ void func_808AEAE0(EnBombf* this, PlayState* play) { } } } else { - if (func_80123F48(play, &this->actor.world.pos, 30.0f, 50.0f)) { + if (Player_IsBurningStickInRange(play, &this->actor.world.pos, 30.0f, 50.0f)) { bombf = (EnBombf*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOMBF, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); if (bombf != NULL) { @@ -365,7 +365,7 @@ void EnBombf_Update(Actor* thisx, PlayState* play) { ((this->colliderCylinder.base.ocFlags1 & OC1_HIT) && (this->colliderCylinder.base.oc->category == 5))) { this->unk_1F8 = 1; this->timer = 0; - } else if ((this->timer > 100) && func_80123F48(play, &this->actor.world.pos, 30.0f, 50.0f)) { + } else if ((this->timer > 100) && Player_IsBurningStickInRange(play, &this->actor.world.pos, 30.0f, 50.0f)) { this->timer = 100; } @@ -414,7 +414,7 @@ void EnBombf_Update(Actor* thisx, PlayState* play) { play->envCtx.lightSettings.ambientColor[0] = play->envCtx.lightSettings.ambientColor[1] = play->envCtx.lightSettings.ambientColor[2] = 250; - func_800DFD04(&play->mainCamera, 2, 11, 8); + Camera_AddQuake(&play->mainCamera, 2, 11, 8); this->actor.params = ENBOMBF_1; this->timer = 10; diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h index 209f5c91a..18a2a32ed 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h @@ -13,17 +13,17 @@ typedef void (*EnBombfActionFunc)(struct EnBombf*, PlayState*); #define ENBOMBF_1 1 typedef struct EnBombf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder colliderCylinder; - /* 0x0190 */ ColliderJntSph colliderJntSph; - /* 0x01B0 */ ColliderJntSphElement colliderJntSphElements[1]; - /* 0x01F0 */ s16 timer; - /* 0x01F4 */ EnBombfActionFunc actionFunc; - /* 0x01F8 */ s32 unk_1F8; - /* 0x01FC */ u8 unk_1FC; - /* 0x01FE */ s16 unk_1FE; - /* 0x0200 */ f32 unk_200; - /* 0x0204 */ f32 unk_204; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder colliderCylinder; + /* 0x190 */ ColliderJntSph colliderJntSph; + /* 0x1B0 */ ColliderJntSphElement colliderJntSphElements[1]; + /* 0x1F0 */ s16 timer; + /* 0x1F4 */ EnBombfActionFunc actionFunc; + /* 0x1F8 */ s32 unk_1F8; + /* 0x1FC */ u8 unk_1FC; + /* 0x1FE */ s16 unk_1FE; + /* 0x200 */ f32 unk_200; + /* 0x204 */ f32 unk_204; } EnBombf; // size = 0x208 extern const ActorInit En_Bombf_InitVars; diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 7b6909b21..75ad8576d 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -414,7 +414,7 @@ void func_80BFEB64(EnBomjima* this, PlayState* play) { sp40.z = (Math_CosS(sp3E) * (Rand_ZeroFloat(20.0f) + 40.0f)) + this->unk_2F0->actor.world.pos.z; SoundSource_PlaySfxAtFixedWorldPos(play, &sp40, 50, NA_SE_EV_BOMBERS_SHOT_EXPLOSUIN); - EffectSsHitMark_SpawnFixedScale(play, 0, &sp40); + EffectSsHitmark_SpawnFixedScale(play, 0, &sp40); this->unk_2BC++; if (((s16)Rand_ZeroFloat(2.0f) + 3) < this->unk_2BC) { @@ -581,7 +581,7 @@ void func_80BFF4F4(EnBomjima* this) { } void func_80BFF52C(EnBomjima* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 4) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { func_801477B4(play); if (play->msgCtx.choiceIndex == 0) { Player* player = GET_PLAYER(play); @@ -624,7 +624,7 @@ void func_80BFF6CC(EnBomjima* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; if (this->unk_2CC <= curFrame) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); func_80BFE494(this, 1, 1.0f); this->actionFunc = func_80BFF754; @@ -729,7 +729,7 @@ void func_80BFF9B0(EnBomjima* this, PlayState* play) { } void func_80BFFB40(EnBomjima* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); func_80BFE494(this, 15, 1.0f); D_80C009F0 = 100; @@ -759,9 +759,9 @@ void func_80BFFBC4(EnBomjima* this, PlayState* play) { func_801477B4(play); play->nextEntranceIndex = Entrance_CreateIndexFromSpawn(6); gSaveContext.nextCutsceneIndex = 0; - play->sceneLoadFlag = 20; - play->unk_1887F = 0x56; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_86; + gSaveContext.nextTransitionType = TRANS_TYPE_03; ActorCutscene_Stop(this->unk_2D4[1]); } } @@ -916,7 +916,7 @@ void func_80C00284(EnBomjima* this, PlayState* play) { break; } - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->collider.dim.radius = 10; this->collider.dim.height = 30; if ((this->unk_2A0 == 4) || (this->unk_2CA == 1) || ((this->unk_2CA == 3) && (this->unk_2C8 >= 2))) { diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h index 6e4682eb3..b247e03ea 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h @@ -11,7 +11,7 @@ typedef void (*EnBomjimaActionFunc)(struct EnBomjima*, PlayState*); #define ENBOMJIMA_GET_F(thisx) ((thisx)->params & 0xF) typedef struct EnBomjima { - /* 0x0000 */ Actor actor; + /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ Vec3s jointTable[21]; /* 0x206 */ Vec3s morphTable[21]; 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 da81a580c..ba777bbc6 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -72,6 +72,22 @@ static ColliderCylinderInit sCylinderInit = { { 20, 30, 0, { 0, 0, 0 } }, }; +static AnimationHeader* sAnimations[] = { + &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, + &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_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 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, +}; + void EnBomjimb_Init(Actor* thisx, PlayState* play) { EnBomjimb* this = THIS; @@ -159,21 +175,9 @@ void EnBomjimb_Destroy(Actor* thisx, PlayState* play) { } void func_80C0113C(EnBomjimb* this, s32 arg1, f32 arg2) { - static AnimationHeader* sAnimations[] = { - &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, - &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, - &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_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, - }; - 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], + Animation_Change(&this->skelAnime, sAnimations[this->unk_2DC], arg2, 0.0f, this->unk_2B8, sAnimModes[this->unk_2DC], -4.0f); } @@ -210,7 +214,7 @@ s32 func_80C012FC(EnBomjimb* this, PlayState* play) { Player* player = GET_PLAYER(play); if (!Play_InCsMode(play) && (this->actor.xzDistToPlayer < 40.0f) && - (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 50.0f) && (play->msgCtx.unk11F10 == 0)) { + (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 50.0f) && (play->msgCtx.msgLength == 0)) { this->actor.speedXZ = 0.0f; func_80C02740(this, play); return true; @@ -755,7 +759,7 @@ void func_80C02A14(EnBomjimb* this, PlayState* play) { player->actor.freezeTimer = 3; } - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); if ((this->unk_2CA == 8) && (gSaveContext.save.bombersCaughtNum >= 5)) { func_80C02CA4(this, play); @@ -774,7 +778,7 @@ void func_80C02BCC(EnBomjimb* this, PlayState* play) { 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(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); this->unk_2C0 = 1; player->stateFlags1 &= ~0x10000000; @@ -789,13 +793,13 @@ void func_80C02CA4(EnBomjimb* this, PlayState* play) { play->nextEntranceIndex = play->setupExitList[this->unk_2B2]; gSaveContext.nextCutsceneIndex = 0; Scene_SetExitFade(play); - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; } else { play->nextEntranceIndex = Entrance_CreateIndexFromSpawn(5); gSaveContext.nextCutsceneIndex = 0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 0x56; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_86; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } gSaveContext.save.weekEventReg[75] |= 0x40; gSaveContext.save.weekEventReg[83] |= 4; diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.h b/src/overlays/actors/ovl_En_Boom/z_en_boom.h index bbc8e68e1..45e3618ed 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.h +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.h @@ -8,17 +8,17 @@ struct EnBoom; typedef void (*EnBoomActionFunc)(struct EnBoom*, PlayState*); typedef struct EnBoom { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderQuad collider; - /* 0x01C4 */ Actor* player; - /* 0x01C8 */ Actor* unk_1C8; - /* 0x01CC */ u8 unk_1CC; - /* 0x01CD */ u8 unk_1CD; - /* 0x01CE */ u8 unk_1CE; - /* 0x01CF */ s8 unk_1CF; - /* 0x01D0 */ s32 effectIndex; - /* 0x01D4 */ WeaponInfo weaponInfo; - /* 0x01F0 */ EnBoomActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderQuad collider; + /* 0x1C4 */ Actor* player; + /* 0x1C8 */ Actor* unk_1C8; + /* 0x1CC */ u8 unk_1CC; + /* 0x1CD */ u8 unk_1CD; + /* 0x1CE */ u8 unk_1CE; + /* 0x1CF */ s8 unk_1CF; + /* 0x1D0 */ s32 effectIndex; + /* 0x1D4 */ WeaponInfo weaponInfo; + /* 0x1F0 */ EnBoomActionFunc actionFunc; } EnBoom; // size = 0x1F4 extern const ActorInit En_Boom_InitVars; diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.h b/src/overlays/actors/ovl_En_Box/z_en_box.h index a7017a716..0ea7fe8de 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.h +++ b/src/overlays/actors/ovl_En_Box/z_en_box.h @@ -44,26 +44,26 @@ typedef enum { #define ENBOX_PARAMS(type, item, chestFlag) ((((type) & 0xF) << 12) | ((item) << 5) | ((chestFlag) & 0x1F)) typedef struct EnBox { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ SkelAnime skelAnime; - /* 0x01A0 */ s32 unk_1A0; - /* 0x01A4 */ UNK_TYPE1 unk_1A4[0x04]; - /* 0x01A8 */ f32 unk_1A8; - /* 0x01AC */ EnBoxActionFunc actionFunc; - /* 0x01B0 */ Vec3s jointTable[OBJECT_BOX_CHEST_LIMB_MAX]; - /* 0x01CE */ Vec3s morphTable[OBJECT_BOX_CHEST_LIMB_MAX]; - /* 0x01EC */ s16 unk_1EC; - /* 0x01EE */ u8 movementFlags; - /* 0x01EF */ u8 alpha; - /* 0x01F0 */ u8 switchFlag; - /* 0x01F1 */ u8 type; - /* 0x01F2 */ u8 iceSmokeTimer; - /* 0x01F3 */ s8 unk_1F3; - /* 0x01F4 */ func_80867BDC_a0 unk_1F4; - /* 0x0218 */ s16 cutsceneIdxA; - /* 0x021A */ s16 cutsceneIdxB; - /* 0x021C */ s32 getItem; - /* 0x0220 */ s32 collectableFlag; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ s32 unk_1A0; + /* 0x1A4 */ UNK_TYPE1 unk_1A4[0x04]; + /* 0x1A8 */ f32 unk_1A8; + /* 0x1AC */ EnBoxActionFunc actionFunc; + /* 0x1B0 */ Vec3s jointTable[OBJECT_BOX_CHEST_LIMB_MAX]; + /* 0x1CE */ Vec3s morphTable[OBJECT_BOX_CHEST_LIMB_MAX]; + /* 0x1EC */ s16 unk_1EC; + /* 0x1EE */ u8 movementFlags; + /* 0x1EF */ u8 alpha; + /* 0x1F0 */ u8 switchFlag; + /* 0x1F1 */ u8 type; + /* 0x1F2 */ u8 iceSmokeTimer; + /* 0x1F3 */ s8 unk_1F3; + /* 0x1F4 */ func_80867BDC_a0 unk_1F4; + /* 0x218 */ s16 cutsceneIdxA; + /* 0x21A */ s16 cutsceneIdxB; + /* 0x21C */ s32 getItem; + /* 0x220 */ s32 collectableFlag; } EnBox; // size = 0x224 extern const ActorInit En_Box_InitVars; diff --git a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c index dfb92082d..5a3ce9cf8 100644 --- a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c +++ b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c @@ -72,7 +72,7 @@ static ColliderJntSphElementInit D_80C0F8D4[7] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80C0F9D0 = { { COLTYPE_HIT6, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 7, D_80C0F8D4, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80C0F8D4, // sJntSphElementsInit, }; // static DamageTable sDamageTable = { diff --git a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c index 82fb047f3..3030041ca 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c @@ -47,7 +47,7 @@ static ColliderJntSphElementInit D_808A0700[2] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_808A0748 = { { COLTYPE_HIT6, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_808A0700, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_808A0700, // sJntSphElementsInit, }; // sColChkInfoInit diff --git a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.h b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.h index 4a67a94c6..2217b86b1 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.h +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.h @@ -8,9 +8,9 @@ struct EnBubble; typedef void (*EnBubbleActionFunc)(struct EnBubble*, PlayState*); typedef struct EnBubble { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBubbleActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x110]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnBubbleActionFunc actionFunc; + /* 0x148 */ char unk_148[0x110]; } EnBubble; // size = 0x258 extern const ActorInit En_Bubble_InitVars; diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c index d1ec4df11..93bc67792 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -13,7 +13,7 @@ #define THIS ((EnButte*)thisx) void EnButte_Init(Actor* thisx, PlayState* play); -void EnButte_Destroy(Actor* thisx, PlayState* play); +void EnButte_Destroy(Actor* thisx, PlayState* play2); void EnButte_Update(Actor* thisx, PlayState* play); void EnButte_Draw(Actor* thisx, PlayState* play); @@ -49,7 +49,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -143,7 +143,7 @@ void func_8091C178(EnButte* this, PlayState* play) { sp48 = Math_SinS(D_8091D3A0) * 250.0f; sp48 = CLAMP(sp48, 0, 255); - func_800DFC90(&sp40, GET_ACTIVE_CAM(play)); + Camera_GetCamDir(&sp40, GET_ACTIVE_CAM(play)); Matrix_RotateYS(sp40.y, MTXMODE_NEW); Matrix_RotateXS(sp40.x, MTXMODE_APPLY); Matrix_RotateZS(sp40.z, MTXMODE_APPLY); @@ -190,14 +190,17 @@ void EnButte_Init(Actor* thisx, PlayState* play) { this->unk_256 = Rand_ZeroOne() * 0xFFFF; this->unk_258 = Rand_ZeroOne() * 0xFFFF; - Animation_Change(&this->skelAnime, &gameplay_field_keep_Anim_001D20, 1.0f, 0.0f, 0.0f, 1, 0.0f); + Animation_Change(&this->skelAnime, &gameplay_field_keep_Anim_001D20, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, 0.0f); func_8091C748(this); this->actor.shape.rot.x -= 0x2320; this->unk_250 = 1; } -void EnButte_Destroy(Actor* thisx, PlayState* play) { - Collider_DestroyJntSph(play, &THIS->collider); +void EnButte_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnButte* this = THIS; + + Collider_DestroyJntSph(play, &this->collider); } void func_8091C524(EnButte* this) { @@ -318,9 +321,9 @@ void func_8091CBB4(EnButte* this, PlayState* play) { sp40 = 0.0f; if ((this->unk_24E != 0) && (this->unk_24C < 12)) { - sp48.x = player->swordInfo[0].tip.x + (Math_SinS(player->actor.shape.rot.y) * 10.0f); - sp48.y = player->swordInfo[0].tip.y; - sp48.z = player->swordInfo[0].tip.z + (Math_CosS(player->actor.shape.rot.y) * 10.0f); + sp48.x = player->meleeWeaponInfo[0].tip.x + (Math_SinS(player->actor.shape.rot.y) * 10.0f); + sp48.y = player->meleeWeaponInfo[0].tip.y; + sp48.z = player->meleeWeaponInfo[0].tip.z + (Math_CosS(player->actor.shape.rot.y) * 10.0f); yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &sp48); if (Math_ScaledStepToS(&this->actor.world.rot.y, yaw + (s32)(Rand_ZeroOne() * D_8091D3F0), 0x7D0)) { @@ -332,10 +335,10 @@ void func_8091CBB4(EnButte* this, PlayState* play) { } } - if (player->swordInfo[0].tip.y < player->actor.world.pos.y + 30.0f) { + if (player->meleeWeaponInfo[0].tip.y < player->actor.world.pos.y + 30.0f) { this->unk_25C = player->actor.world.pos.y + 30.0f; } else { - this->unk_25C = player->swordInfo[0].tip.y; + this->unk_25C = player->meleeWeaponInfo[0].tip.y; } func_8091C6B4(this); @@ -356,7 +359,7 @@ void func_8091CBB4(EnButte* this, PlayState* play) { !(distSq < SQ(320.0f))) { func_8091C748(this); } else if ((distSq > SQ(240.0f)) && - (Math3D_XZDistanceSquared(player->swordInfo[0].tip.x, player->swordInfo[0].tip.z, + (Math3D_XZDistanceSquared(player->meleeWeaponInfo[0].tip.x, player->meleeWeaponInfo[0].tip.z, this->actor.world.pos.x, this->actor.world.pos.z) < SQ(60.0f))) { func_8091CF64(this); } @@ -413,7 +416,7 @@ void EnButte_Update(Actor* thisx, PlayState* play) { this->unk_258 += 0x600; if (ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) { - if (GET_PLAYER(play)->swordState == 0) { + if (GET_PLAYER(play)->meleeWeaponState == 0) { if (this->unk_252 > 0) { this->unk_252--; } diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.h b/src/overlays/actors/ovl_En_Butte/z_en_butte.h index a93c0eea8..2d7a6a0bc 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.h +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.h @@ -15,22 +15,22 @@ typedef void (*EnButteActionFunc)(struct EnButte*, PlayState*); #define ENBUTTE_1 1 typedef struct EnButte { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderJntSph collider; - /* 0x0164 */ ColliderJntSphElement colldierElements[1]; - /* 0x01A4 */ SkelAnime skelAnime; - /* 0x01E8 */ Vec3s jointTable[8]; - /* 0x0218 */ Vec3s morphTable[8]; - /* 0x0248 */ EnButteActionFunc actionFunc; - /* 0x024C */ s16 unk_24C; - /* 0x024E */ u8 unk_24E; - /* 0x024F */ u8 unk_24F; - /* 0x0250 */ u8 unk_250; - /* 0x0252 */ s16 unk_252; - /* 0x0254 */ s16 unk_254; - /* 0x0256 */ s16 unk_256; - /* 0x0258 */ s16 unk_258; - /* 0x025C */ f32 unk_25C; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colldierElements[1]; + /* 0x1A4 */ SkelAnime skelAnime; + /* 0x1E8 */ Vec3s jointTable[8]; + /* 0x218 */ Vec3s morphTable[8]; + /* 0x248 */ EnButteActionFunc actionFunc; + /* 0x24C */ s16 unk_24C; + /* 0x24E */ u8 unk_24E; + /* 0x24F */ u8 unk_24F; + /* 0x250 */ u8 unk_250; + /* 0x252 */ s16 unk_252; + /* 0x254 */ s16 unk_254; + /* 0x256 */ s16 unk_256; + /* 0x258 */ s16 unk_258; + /* 0x25C */ f32 unk_25C; } EnButte; // size = 0x260 extern const ActorInit En_Butte_InitVars; 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 65a1da5f0..3ad9f3bd1 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 @@ -558,8 +558,8 @@ void EnClearTag_UpdateCamera(EnClearTag* this, PlayState* play) { case 1: Cutscene_Start(play, &play->csCtx); this->subCamId = Play_CreateSubCamera(play); - Play_CameraChangeStatus(play, CAM_ID_MAIN, 1); - Play_CameraChangeStatus(play, this->subCamId, 7); + Play_CameraChangeStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_CameraChangeStatus(play, this->subCamId, CAM_STATUS_ACTIVE); func_800B7298(play, &this->actor, 4); mainCam = Play_GetCamera(play, CAM_ID_MAIN); this->subCamEye.x = mainCam->eye.x; @@ -579,7 +579,7 @@ void EnClearTag_UpdateCamera(EnClearTag* this, PlayState* play) { } player->actor.speedXZ = 0.0f; - if (Message_GetState(&play->msgCtx) == 0) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { mainCam = Play_GetCamera(play, CAM_ID_MAIN); mainCam->eye = this->subCamEye; mainCam->eyeNext = this->subCamEye; @@ -588,13 +588,13 @@ void EnClearTag_UpdateCamera(EnClearTag* this, PlayState* play) { Cutscene_End(play, &play->csCtx); func_800B7298(play, &this->actor, 6); this->cameraState = 0; - this->subCamId = CAM_ID_MAIN; + this->subCamId = SUB_CAM_ID_DONE; this->activeTimer = 20; } break; } - if (this->subCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { Play_CameraSetAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); } } diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index df5bab168..a9aa59c7b 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -126,10 +126,10 @@ s32 EnCne01_TestIsTalking(EnCne01* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->enHy.actor, &play->state)) { isTalking = true; this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox - this->enHy.tmptrackTarget = this->enHy.trackTarget; - this->enHy.tmpHeadRot = this->enHy.headRot; - this->enHy.tmpTorsoRot = this->enHy.torsoRot; - this->enHy.tmpActionFunc = this->enHy.actionFunc; + this->enHy.prevTrackTarget = this->enHy.trackTarget; + this->enHy.prevHeadRot = this->enHy.headRot; + this->enHy.prevTorsoRot = this->enHy.torsoRot; + this->enHy.prevActionFunc = this->enHy.actionFunc; this->enHy.actionFunc = EnCne01_Talk; } return isTalking; @@ -152,7 +152,7 @@ void EnCne01_FinishInit(EnHy* this, PlayState* play) { this->actor.flags |= ACTOR_FLAG_1; this->actor.draw = EnCne01_Draw; this->waitingOnInit = false; - if (ENCNE01_GET_PATH(&this->actor) == ENCNE01_NO_PATH) { + if (ENCNE01_GET_PATH(&this->actor) == 0x3F) { this->actionFunc = EnCne01_FaceForward; } else { this->actionFunc = EnCne01_Walk; @@ -175,24 +175,26 @@ void EnCne01_Talk(EnHy* this, PlayState* play) { u8 talkState; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xFA0, 1); + talkState = Message_GetState(&play->msgCtx); - this->inMsgState3 = (talkState == 3) ? true : false; + this->inMsgState3 = (talkState == TEXT_STATE_3) ? true : false; switch (talkState) { - case 0: + case TEXT_STATE_NONE: yaw = ABS_ALT(this->actor.shape.rot.y - this->actor.yawTowardsPlayer); if (yaw < 0x64) { Message_StartTextbox(play, this->textId, NULL); } break; - case 2: + + case TEXT_STATE_CLOSING: this->actor.textId = 0; - this->trackTarget = this->tmptrackTarget; - this->headRot = this->tmpHeadRot; - this->torsoRot = this->tmpTorsoRot; + this->trackTarget = this->prevTrackTarget; + this->headRot = this->prevHeadRot; + this->torsoRot = this->prevTorsoRot; this->actor.shape.rot.y = this->actor.world.rot.y; - this->actionFunc = this->tmpActionFunc; - this->tmpActionFunc = NULL; + this->actionFunc = this->prevActionFunc; + this->prevActionFunc = NULL; break; } } @@ -215,7 +217,7 @@ void EnCne01_Init(Actor* thisx, PlayState* play) { Collider_SetCylinder(play, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->enHy.actor.flags &= ~ACTOR_FLAG_1; - this->enHy.path = SubS_GetPathByIndex(play, ENCNE01_GET_PATH(&this->enHy.actor), ENCNE01_NO_PATH); + this->enHy.path = SubS_GetPathByIndex(play, ENCNE01_GET_PATH(&this->enHy.actor), 0x3F); this->enHy.waitingOnInit = true; Actor_SetScale(&this->enHy.actor, 0.01f); this->enHy.actionFunc = EnCne01_FinishInit; diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h index c2ce1c861..0b9e1e08b 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h @@ -8,7 +8,6 @@ struct EnCne01; typedef void (*EnCne01ActionFunc)(struct EnCne01*, PlayState*); #define ENCNE01_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) -#define ENCNE01_NO_PATH 0x3F typedef struct EnCne01 { /* 0x000 */ EnHy enHy; 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 9857d9403..54a78442c 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 @@ -138,7 +138,7 @@ void func_80AFDE00(EnColMan* this, PlayState* play) { } void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 6 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { gSaveContext.save.weekEventReg[56] |= 2; Actor_MarkForDeath(&this->actor); } 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 342e61385..902f01931 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -200,7 +200,7 @@ void EnCow_UpdateAnimation(EnCow* this, PlayState* play) { } void EnCow_TalkEnd(EnCow* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(play); this->actionFunc = EnCow_Idle; @@ -224,7 +224,7 @@ void EnCow_GiveMilkWait(EnCow* this, PlayState* play) { } void EnCow_GiveMilk(EnCow* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(play); this->actionFunc = EnCow_GiveMilkWait; @@ -233,8 +233,8 @@ void EnCow_GiveMilk(EnCow* this, PlayState* play) { } void EnCow_CheckForEmptyBottle(EnCow* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { - if (Interface_HasEmptyBottle()) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + if (Inventory_HasEmptyBottle()) { func_80151938(play, 0x32C9); // Text to give milk. this->actionFunc = EnCow_GiveMilk; } else { @@ -291,7 +291,7 @@ void EnCow_Idle(EnCow* this, PlayState* play) { if (func_801A5100() == 4) { if (!(gSaveContext.save.weekEventReg[87] & 1)) { gSaveContext.save.weekEventReg[87] |= 1; - if (Interface_HasEmptyBottle()) { + if (Inventory_HasEmptyBottle()) { this->actor.textId = 0x32C9; // Text to give milk. } else { this->actor.textId = 0x32CA; // Text if you don't have an empty bottle. diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.c b/src/overlays/actors/ovl_En_Crow/z_en_crow.c index 46becf085..e6980ba4f 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -62,48 +62,59 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 30, 30 }; +typedef enum { + /* 0 */ GUAY_DMGEFF_NONE, + /* 1 */ GUAY_DMGEFF_STUN, + /* 2 */ GUAY_DMGEFF_FIRE, + /* 3 */ GUAY_DMGEFF_ICE, + /* 4 */ GUAY_DMGEFF_LIGHT, + /* 5 */ GUAY_DMGEFF_ELECTRIC, +} GuayDamageEffect; + static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0x0), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), + /* Deku Nut */ DMG_ENTRY(0, GUAY_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, GUAY_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, GUAY_DMGEFF_ICE), + /* Light arrow */ DMG_ENTRY(2, GUAY_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, GUAY_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, GUAY_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, GUAY_DMGEFF_ELECTRIC), + /* Normal shield */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, GUAY_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, GUAY_DMGEFF_NONE), }; -static s32 D_8099C0CC = 0; +#define GUAY_NUMBER_OF_DEAD_TO_SPAWN_MEGAGUAY 10 + +static s32 sDeadCount = 0; static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), @@ -122,7 +133,9 @@ void EnCrow_Init(Actor* thisx, PlayState* play) { this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); - D_8099C0CC = 0; + + sDeadCount = 0; + if (this->actor.parent != NULL) { this->actor.flags &= ~ACTOR_FLAG_1; } @@ -162,40 +175,40 @@ void EnCrow_FlyIdle(EnCrow* this, PlayState* play) { } if (this->actor.bgCheckFlags & 8) { - this->aimRotY = this->actor.wallYaw; + this->yawTarget = this->actor.wallYaw; } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { - this->aimRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->yawTarget = Actor_YawToPoint(&this->actor, &this->actor.home.pos); } - if ((Math_SmoothStepToS(&this->actor.shape.rot.y, this->aimRotY, 5, 0x300, 0x10) == 0) && onInitialAnimFrame && + if ((Math_SmoothStepToS(&this->actor.shape.rot.y, this->yawTarget, 5, 0x300, 0x10) == 0) && onInitialAnimFrame && (Rand_ZeroOne() < 0.1f)) { yaw = (Actor_YawToPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y); if (yaw > 0) { - this->aimRotY += Rand_S16Offset(0x1000, 0x1000); + this->yawTarget += Rand_S16Offset(0x1000, 0x1000); } else { - this->aimRotY -= Rand_S16Offset(0x1000, 0x1000); + this->yawTarget -= Rand_S16Offset(0x1000, 0x1000); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); } if ((this->actor.depthInWater > -40.0f) || (this->actor.bgCheckFlags & 1)) { - this->aimRotX = -0x1000; + this->pitchTarget = -0x1000; } else if (this->actor.world.pos.y < (this->actor.home.pos.y - 50.0f)) { - this->aimRotX = -Rand_S16Offset(0x800, 0x800); + this->pitchTarget = -Rand_S16Offset(0x800, 0x800); } else if (this->actor.world.pos.y > (this->actor.home.pos.y + 50.0f)) { - this->aimRotX = Rand_S16Offset(0x800, 0x800); + this->pitchTarget = Rand_S16Offset(0x800, 0x800); } - if ((Math_SmoothStepToS(&this->actor.shape.rot.x, this->aimRotX, 0xA, 0x100, 8) == 0) && onInitialAnimFrame && + if ((Math_SmoothStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0xA, 0x100, 8) == 0) && onInitialAnimFrame && (Rand_ZeroOne() < 0.1f)) { if (this->actor.home.pos.y < this->actor.world.pos.y) { - this->aimRotX -= Rand_S16Offset(0x400, 0x400); + this->pitchTarget -= Rand_S16Offset(0x400, 0x400); } else { - this->aimRotX += Rand_S16Offset(0x400, 0x400); + this->pitchTarget += Rand_S16Offset(0x400, 0x400); } - this->aimRotX = CLAMP(this->aimRotX, -0x1000, 0x1000); + this->pitchTarget = CLAMP(this->pitchTarget, -0x1000, 0x1000); } if (this->actor.bgCheckFlags & 1) { @@ -206,7 +219,7 @@ void EnCrow_FlyIdle(EnCrow* this, PlayState* play) { this->timer--; } if ((this->timer == 0) && - (((this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & 0x800000)) || (dist < 300.0f)) && + (((this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & PLAYER_STATE1_800000)) || (dist < 300.0f)) && (this->actor.depthInWater < -40.0f) && (Player_GetMask(play) != PLAYER_MASK_STONE)) { if (dist < this->actor.xzDistToPlayer) { this->actor.child = this->actor.parent; @@ -227,9 +240,7 @@ void EnCrow_SetupDiveAttack(EnCrow* this) { void EnCrow_DiveAttack(EnCrow* this, PlayState* play) { Player* player = GET_PLAYER(play); s32 isFacingActor; - Vec3f pos; - s16 pitch; - s16 pitchTarget; + Vec3f targetPos; SkelAnime_Update(&this->skelAnime); if (this->timer != 0) { @@ -238,27 +249,30 @@ void EnCrow_DiveAttack(EnCrow* this, PlayState* play) { isFacingActor = Actor_ActorAIsFacingActorB(&this->actor, this->actor.child, 0x2800); if (isFacingActor) { + s16 pitchTarget; + if (&player->actor == this->actor.child) { - pos.y = this->actor.child->world.pos.y + 20.0f; + targetPos.y = this->actor.child->world.pos.y + 20.0f; } else { - pos.y = this->actor.child->world.pos.y + 40.0f; + targetPos.y = this->actor.child->world.pos.y + 40.0f; } - pos.x = this->actor.child->world.pos.x; - pos.z = this->actor.child->world.pos.z; - pitch = Actor_PitchToPoint(&this->actor, &pos); - pitchTarget = CLAMP(pitch, -0x3000, 0x3000); - Math_SmoothStepToS(&this->actor.shape.rot.x, pitchTarget, 2, 0x400, 64); + targetPos.x = this->actor.child->world.pos.x; + targetPos.z = this->actor.child->world.pos.z; + pitchTarget = Actor_PitchToPoint(&this->actor, &targetPos); + pitchTarget = CLAMP(pitchTarget, -0x3000, 0x3000); + Math_SmoothStepToS(&this->actor.shape.rot.x, pitchTarget, 2, 0x400, 0x40); } else { - Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 2, 0x100, 16); + Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 2, 0x100, 0x10); } if (isFacingActor || (Actor_XZDistanceBetweenActors(&this->actor, this->actor.child) > 80.0f)) { Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->actor.child), 4, 0xC00, 0xC0); } + if (((this->timer == 0) || ((&player->actor != this->actor.child) && (this->actor.child->home.rot.z != 0)) || ((&player->actor == this->actor.child) && - ((Player_GetMask(play) == PLAYER_MASK_STONE) || (player->stateFlags1 & 0x800000))) || + ((Player_GetMask(play) == PLAYER_MASK_STONE) || (player->stateFlags1 & PLAYER_STATE1_800000))) || ((this->collider.base.atFlags & AT_HIT) || (this->actor.bgCheckFlags & 9))) || (this->actor.depthInWater > -40.0f)) { @@ -271,9 +285,9 @@ void EnCrow_DiveAttack(EnCrow* this, PlayState* play) { } void EnCrow_CheckIfFrozen(EnCrow* this, PlayState* play) { - if (this->deathMode == 10) { - this->deathMode = 0; - this->effectAlpha = 0.0f; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, 4, 2, 0.2f, 0.2f); } } @@ -291,22 +305,22 @@ void EnCrow_SetupDamaged(EnCrow* this, PlayState* play) { this->actor.world.pos.y += 20.0f * scale; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); - if (this->actor.colChkInfo.damageEffect == 3) { - this->deathMode = 10; // Ice arrows - this->effectAlpha = 1.0f; - this->effectScale = 0.75f; - this->steamScale = 0.5f; - } else if (this->actor.colChkInfo.damageEffect == 4) { - this->deathMode = 20; // Light Arrows - this->effectAlpha = 4.0f; - this->steamScale = 0.5f; + if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_ICE) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 0.5f; + } else if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_LIGHT) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffFrozenSteamScale = 0.5f; Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.elements->info.bumper.hitPos.x, this->collider.elements->info.bumper.hitPos.y, this->collider.elements->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); - } else if (this->actor.colChkInfo.damageEffect == 2) { - this->deathMode = 0; // Fire arrows - this->effectAlpha = 4.0f; - this->steamScale = 0.5f; + } else if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_FIRE) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffFrozenSteamScale = 0.5f; } Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); @@ -325,7 +339,7 @@ void EnCrow_Damaged(EnCrow* this, PlayState* play) { this->actor.colorFilterTimer = 40; if (!(this->actor.flags & ACTOR_FLAG_8000)) { - if (this->deathMode != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); this->actor.shape.rot.z += 0x1780; } @@ -351,14 +365,14 @@ void EnCrow_SetupDie(EnCrow* this) { void EnCrow_Die(EnCrow* this, PlayState* play) { f32 stepScale; - if (this->actor.params != 0) { + if (this->actor.params != GUAY_TYPE_NORMAL) { stepScale = 0.006f; } else { stepScale = 0.002f; } - if (Math_StepToF(&this->actor.scale.x, 0.0f, stepScale) != 0) { - if (this->actor.params == 0) { - D_8099C0CC++; + if (Math_StepToF(&this->actor.scale.x, 0.0f, stepScale)) { + if (this->actor.params == GUAY_TYPE_NORMAL) { + sDeadCount++; Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x80); } else { Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x90); @@ -370,11 +384,11 @@ void EnCrow_Die(EnCrow* this, PlayState* play) { void EnCrow_SetupTurnAway(EnCrow* this) { this->timer = 100; - this->aimRotX = -0x1000; + this->pitchTarget = -0x1000; this->actor.speedXZ = 3.5f; - this->aimRotY = this->actor.yawTowardsPlayer + 0x8000; + this->yawTarget = this->actor.yawTowardsPlayer + 0x8000; this->skelAnime.playSpeed = 2.0f; - if (this->actor.colChkInfo.damageEffect == 1) { + if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_STUN) { Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); } else { Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); @@ -387,13 +401,13 @@ void EnCrow_TurnAway(EnCrow* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (this->actor.bgCheckFlags & 8) { - this->aimRotY = this->actor.wallYaw; + this->yawTarget = this->actor.wallYaw; } else { - this->aimRotY = this->actor.yawTowardsPlayer + 0x8000; + this->yawTarget = this->actor.yawTowardsPlayer + 0x8000; } - Math_SmoothStepToS(&this->actor.shape.rot.y, this->aimRotY, 3, 0xC00, 0xC0); - Math_SmoothStepToS(&this->actor.shape.rot.x, this->aimRotX, 5, 0x100, 0x10); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->yawTarget, 3, 0xC00, 0xC0); + Math_SmoothStepToS(&this->actor.shape.rot.x, this->pitchTarget, 5, 0x100, 0x10); if (this->timer != 0) { this->timer--; @@ -405,12 +419,12 @@ void EnCrow_TurnAway(EnCrow* this, PlayState* play) { } void EnCrow_SetupRespawn(EnCrow* this) { - if (D_8099C0CC == 10) { - this->actor.params = 1; - D_8099C0CC = 0; + if (sDeadCount == GUAY_NUMBER_OF_DEAD_TO_SPAWN_MEGAGUAY) { + this->actor.params = GUAY_TYPE_MEGA; + sDeadCount = 0; this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius * 0.03f * 100.0f; } else { - this->actor.params = 0; + this->actor.params = GUAY_TYPE_NORMAL; this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius; } Animation_PlayLoop(&this->skelAnime, &gGuayFlyAnim); @@ -421,12 +435,12 @@ void EnCrow_SetupRespawn(EnCrow* this) { this->actor.draw = NULL; this->actor.shape.yOffset = 2000.0f; this->actor.targetArrowOffset = 2000.0; - this->effectAlpha = 0.0f; + this->drawDmgEffAlpha = 0.0f; this->actionFunc = EnCrow_Respawn; } void EnCrow_Respawn(EnCrow* this, PlayState* play) { - f32 target; + f32 scaleTarget; if (this->timer != 0) { this->timer--; @@ -434,12 +448,12 @@ void EnCrow_Respawn(EnCrow* this, PlayState* play) { if (this->timer == 0) { SkelAnime_Update(&this->skelAnime); this->actor.draw = EnCrow_Draw; - if (this->actor.params != 0) { - target = 0.03f; + if (this->actor.params != GUAY_TYPE_NORMAL) { + scaleTarget = 0.03f; } else { - target = 0.01f; + scaleTarget = 0.01f; } - if (Math_StepToF(&this->actor.scale.x, target, target * 0.1f)) { + if (Math_StepToF(&this->actor.scale.x, scaleTarget, scaleTarget * 0.1f)) { this->actor.flags |= ACTOR_FLAG_1; this->actor.flags &= ~ACTOR_FLAG_10; this->actor.colChkInfo.health = 1; @@ -450,18 +464,17 @@ void EnCrow_Respawn(EnCrow* this, PlayState* play) { } void EnCrow_UpdateDamage(EnCrow* this, PlayState* play) { - if (this->collider.base.acFlags & AT_HIT) { this->collider.base.acFlags &= ~AT_HIT; Actor_SetDropFlag(&this->actor, &this->collider.elements->info); - if (this->actor.colChkInfo.damageEffect == 1) { + if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_STUN) { EnCrow_SetupTurnAway(this); - } else if (this->actor.colChkInfo.damageEffect == 5) { - this->deathMode = 31; // Stunned via deku nuts or zora barrier - this->effectAlpha = 2.0f; - this->steamScale = 0.5f; + } else if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_ELECTRIC) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffFrozenSteamScale = 0.5f; EnCrow_SetupTurnAway(this); } else { @@ -475,7 +488,7 @@ void EnCrow_UpdateDamage(EnCrow* this, PlayState* play) { void EnCrow_Update(Actor* thisx, PlayState* play) { f32 pad; - EnCrow* this = (EnCrow*)thisx; + EnCrow* this = THIS; f32 height; f32 scale; @@ -517,23 +530,23 @@ void EnCrow_Update(Actor* thisx, PlayState* play) { if ((this->actor.colChkInfo.health != 0) && (Animation_OnFrame(&this->skelAnime, 3.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_FLUTTER); } - if (this->effectAlpha > 0.0f) { - if (this->deathMode != 10) { - Math_StepToF(&this->effectAlpha, 0.0f, 0.05f); - this->steamScale = (this->effectAlpha + 1.0f) * 0.25f; - if (this->steamScale > 0.5f) { - this->steamScale = 0.5f; + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffFrozenSteamScale = (this->drawDmgEffAlpha + 1.0f) * 0.25f; + if (this->drawDmgEffFrozenSteamScale > 0.5f) { + this->drawDmgEffFrozenSteamScale = 0.5f; } else { - this->steamScale = this->steamScale; + this->drawDmgEffFrozenSteamScale = this->drawDmgEffFrozenSteamScale; } - } else if (Math_StepToF(&this->effectScale, 0.5f, 0.0125f) == 0) { + } else if (!Math_StepToF(&this->drawDmgEffScale, 0.5f, 0.5f * 0.025f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } } s32 EnCrow_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { - EnCrow* this = (EnCrow*)thisx; + EnCrow* this = THIS; if (this->actor.colChkInfo.health != 0) { if (limbIndex == OBJECT_CROW_LIMB_UPPER_TAIL) { @@ -546,25 +559,23 @@ s32 EnCrow_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* } void EnCrow_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - EnCrow* this = (EnCrow*)thisx; + EnCrow* this = THIS; if (limbIndex == OBJECT_CROW_LIMB_BODY) { Matrix_MultVecX(2500.0f, this->bodyPartsPos); - return; - } - if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || - (limbIndex == OBJECT_CROW_LIMB_TAIL)) { + } else if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || + (limbIndex == OBJECT_CROW_LIMB_TAIL)) { Matrix_MultZero(&this->bodyPartsPos[(limbIndex >> 1) - 1]); } } void EnCrow_Draw(Actor* thisx, PlayState* play) { - EnCrow* this = (EnCrow*)thisx; + EnCrow* this = THIS; func_8012C28C(play->state.gfxCtx); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnCrow_OverrideLimbDraw, EnCrow_PostLimbDraw, &this->actor); Actor_DrawDamageEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), - this->actor.scale.x * 100.0f * this->steamScale, this->effectScale, this->effectAlpha, - this->deathMode); + this->actor.scale.x * 100.0f * this->drawDmgEffFrozenSteamScale, this->drawDmgEffScale, + this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.h b/src/overlays/actors/ovl_En_Crow/z_en_crow.h index 79bfdeb6c..86ffba903 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.h +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.h @@ -4,26 +4,31 @@ #include "global.h" #include "objects/object_crow/object_crow.h" +typedef enum { + /* 0 */ GUAY_TYPE_NORMAL, + /* 1 */ GUAY_TYPE_MEGA +} GuayType; + struct EnCrow; typedef void (*EnCrowActionFunc)(struct EnCrow*, PlayState*); typedef struct EnCrow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnCrowActionFunc actionFunc; - /* 0x18C */ u8 deathMode; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnCrowActionFunc actionFunc; + /* 0x18C */ u8 drawDmgEffType; /* 0x18E */ s16 timer; - /* 0x190 */ s16 aimRotX; - /* 0x192 */ s16 aimRotY; + /* 0x190 */ s16 pitchTarget; + /* 0x192 */ s16 yawTarget; /* 0x194 */ Vec3s jointTable[OBJECT_CROW_LIMB_MAX]; /* 0x1CA */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; /* 0x200 */ ColliderJntSph collider; /* 0x220 */ ColliderJntSphElement colliderItems[1]; /* 0x260 */ Vec3f bodyPartsPos[4]; - /* 0x290 */ f32 effectAlpha; - /* 0x294 */ f32 steamScale; - /* 0x298 */ f32 effectScale; + /* 0x290 */ f32 drawDmgEffAlpha; + /* 0x294 */ f32 drawDmgEffFrozenSteamScale; + /* 0x298 */ f32 drawDmgEffScale; } EnCrow; // size = 0x29C extern const ActorInit En_Crow_InitVars; 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 216b2d2f1..2e7442fa4 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -57,6 +57,17 @@ static ColliderCylinderInit sCylinderInit = { { 20, 60, 0, { 0, 0, 0 } }, }; +static AnimationHeader* sAnimations[] = { + &object_daiku_Anim_002FA0, &object_daiku_Anim_00ACD0, &object_daiku_Anim_00C92C, + &object_daiku_Anim_000C44, &object_daiku_Anim_00C234, &object_daiku_Anim_000600, + &object_daiku_Anim_001114, &object_daiku_Anim_00B690, &object_daiku_Anim_00BEAC, +}; + +static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, +}; + void EnDaiku_Init(Actor* thisx, PlayState* play) { EnDaiku* this = THIS; @@ -119,17 +130,8 @@ void EnDaiku_Destroy(Actor* thisx, PlayState* play) { } void func_8094373C(EnDaiku* this, s32 arg1) { - static AnimationHeader* D_809440A4[] = { - &object_daiku_Anim_002FA0, &object_daiku_Anim_00ACD0, &object_daiku_Anim_00C92C, - &object_daiku_Anim_000C44, &object_daiku_Anim_00C234, &object_daiku_Anim_000600, - &object_daiku_Anim_001114, &object_daiku_Anim_00B690, &object_daiku_Anim_00BEAC, - }; - static u8 D_809440C8[] = { - 0, 0, 0, 0, 2, 0, 0, 2, 2, - }; - - this->unk_284 = Animation_GetLastFrame(D_809440A4[arg1]); - Animation_Change(&this->skelAnime, D_809440A4[arg1], 1.0f, 0.0f, this->unk_284, D_809440C8[arg1], -4.0f); + this->unk_284 = Animation_GetLastFrame(sAnimations[arg1]); + Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, this->unk_284, sAnimModes[arg1], -4.0f); } void func_809437C8(EnDaiku* this) { @@ -242,7 +244,7 @@ void func_80943BDC(EnDaiku* this, PlayState* play) { } } - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); func_80943820(this); } diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c index a573a4dcb..b7b46b5af 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -127,7 +127,8 @@ void func_80BE6408(EnDaiku2* this, s32 arg1) { &object_daiku_Anim_001A24, &object_daiku_Anim_002134, &object_daiku_Anim_00D328, }; static u8 D_80BE7958[] = { - 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, }; f32 sp34 = 1.0f; @@ -263,7 +264,8 @@ void func_80BE66E4(EnDaiku2* this, PlayState* play) { func_80BE6408(this, 10); } else if ((this->unk_276 == 10) && (this->unk_284 <= sp9C)) { this->unk_284 = Animation_GetLastFrame(&object_daiku_Anim_002134); - Animation_Change(&this->skelAnime, &object_daiku_Anim_002134, -1.0f, this->unk_284, 0.0f, 2, -4.0f); + Animation_Change(&this->skelAnime, &object_daiku_Anim_002134, -1.0f, this->unk_284, 0.0f, ANIMMODE_ONCE, + -4.0f); this->unk_276 = 11; } else if ((this->unk_276 == 11) && (sp9C <= 0.0f)) { func_80BE6408(this, 8); @@ -292,7 +294,7 @@ void func_80BE6B40(EnDaiku2* this, PlayState* play) { void func_80BE6BC0(EnDaiku2* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0x0); - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { s32 day = gSaveContext.save.day - 1; func_801477B4(play); diff --git a/src/overlays/actors/ovl_En_Death/z_en_death.c b/src/overlays/actors/ovl_En_Death/z_en_death.c index 5ed61f146..edc240cd5 100644 --- a/src/overlays/actors/ovl_En_Death/z_en_death.c +++ b/src/overlays/actors/ovl_En_Death/z_en_death.c @@ -79,7 +79,7 @@ static ColliderTrisElementInit D_808C9938[2] = { // static ColliderTrisInit sTrisInit = { static ColliderTrisInit D_808C99B0 = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_TRIS, }, - 2, D_808C9938, // sTrisElementsInit, + ARRAY_COUNT(sTrisElementsInit), D_808C9938, // sTrisElementsInit, }; // static ColliderQuadInit sQuadInit = { diff --git a/src/overlays/actors/ovl_En_Death/z_en_death.h b/src/overlays/actors/ovl_En_Death/z_en_death.h index 2441e00b5..bc4e326bb 100644 --- a/src/overlays/actors/ovl_En_Death/z_en_death.h +++ b/src/overlays/actors/ovl_En_Death/z_en_death.h @@ -8,10 +8,10 @@ struct EnDeath; typedef void (*EnDeathActionFunc)(struct EnDeath*, PlayState*); typedef struct EnDeath { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnDeathActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x7AC]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ EnDeathActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x7AC]; } EnDeath; // size = 0x938 extern const ActorInit En_Death_InitVars; diff --git a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c index 250f4c7ee..d05ac1003 100644 --- a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c +++ b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c @@ -79,7 +79,7 @@ static ColliderJntSphElementInit D_808B4D60[7] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_808B4E5C = { { COLTYPE_HIT6, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 7, D_808B4D60, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_808B4D60, // sJntSphElementsInit, }; // sColChkInfoInit diff --git a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.h b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.h index 19b977e09..923f336aa 100644 --- a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.h +++ b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.h @@ -8,10 +8,10 @@ struct EnDekubaba; typedef void (*EnDekubabaActionFunc)(struct EnDekubaba*, PlayState*); typedef struct EnDekubaba { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnDekubabaActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x290]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ EnDekubabaActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x290]; } EnDekubaba; // size = 0x41C extern const ActorInit En_Dekubaba_InitVars; 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 868c3c0d5..15ae675a1 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -5,6 +5,7 @@ */ #include "z_en_dekunuts.h" +#include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) @@ -539,8 +540,10 @@ void func_808BE4D4(EnDekunuts* this, PlayState* play) { EffectSsHahen_SpawnBurst(play, &sp40, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xE0); Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_ETCETERA, this->actor.home.pos.x, this->actor.home.pos.y, - this->actor.home.pos.z, 0, this->actor.home.rot.y, 0, 0x80); - EffectSsHahen_SpawnBurst(play, &this->actor.home.pos, 6.0f, 0, 6, 2, 15, 64, 10, gDekuScrubFlowerFragmentDL); + this->actor.home.pos.z, 0, this->actor.home.rot.y, 0, + DEKU_FLOWER_PARAMS(DEKU_FLOWER_TYPE_PINK_WITH_INITIAL_BOUNCE)); + EffectSsHahen_SpawnBurst(play, &this->actor.home.pos, 6.0f, 0, 6, 2, 15, OBJECT_DEKUNUTS, 10, + gDekuScrubFlowerFragmentDL); Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c index 5507dff34..17ee92ede 100644 --- a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c +++ b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c @@ -143,7 +143,7 @@ void EnDemoheishi_SetupTalk(EnDemoheishi* this) { } void EnDemoheishi_Talk(EnDemoheishi* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); EnDemoheishi_SetupIdle(this); } diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 716d822fb..8b9d67e64 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -15,26 +15,26 @@ void EnDg_Destroy(Actor* thisx, PlayState* play); void EnDg_Update(Actor* thisx, PlayState* play); void EnDg_Draw(Actor* thisx, PlayState* play); -void func_8098A468(EnDg* this, PlayState* play); -void func_8098A55C(EnDg* this, PlayState* play); -void func_8098A618(EnDg* this, PlayState* play); -void func_8098A70C(EnDg* this, PlayState* play); -void func_8098A89C(EnDg* this, PlayState* play); -void func_8098A938(EnDg* this, PlayState* play); -void func_8098AB48(EnDg* this, PlayState* play); -void func_8098AC34(EnDg* this, PlayState* play); -void func_8098AF44(EnDg* this, PlayState* play); -void func_8098AF98(EnDg* this, PlayState* play); -void func_8098B004(EnDg* this, PlayState* play); -void func_8098B198(EnDg* this, PlayState* play); -void func_8098B28C(EnDg* this, PlayState* play); -void func_8098B390(EnDg* this, PlayState* play); -void func_8098B560(EnDg* this, PlayState* play); -void func_8098B88C(EnDg* this, PlayState* play); -void func_8098BA64(EnDg* this, PlayState* play); -void func_8098BB10(EnDg* this, PlayState* play); -void func_8098BBEC(EnDg* this, PlayState* play); -void func_8098BC54(EnDg* this, PlayState* play); +void EnDg_IdleMove(EnDg* this, PlayState* play); +void EnDg_IdleBark(EnDg* this, PlayState* play); +void EnDg_BackAwayFromGoron(EnDg* this, PlayState* play); +void EnDg_RunAwayFromGoron(EnDg* this, PlayState* play); +void EnDg_BarkAtGoron(EnDg* this, PlayState* play); +void EnDg_ApproachPlayerToAttack(EnDg* this, PlayState* play); +void EnDg_SitNextToPlayer(EnDg* this, PlayState* play); +void EnDg_JumpAttack(EnDg* this, PlayState* play); +void EnDg_SetupBremenMaskApproachPlayer(EnDg* this, PlayState* play); +void EnDg_Fall(EnDg* this, PlayState* play); +void EnDg_ApproachPlayer(EnDg* this, PlayState* play); +void EnDg_SlowlyBackUpBeforeAttacking(EnDg* this, PlayState* play); +void EnDg_BackAwayFromPlayer(EnDg* this, PlayState* play); +void EnDg_BarkAtPlayer(EnDg* this, PlayState* play); +void EnDg_Swim(EnDg* this, PlayState* play); +void EnDg_JumpOutOfWater(EnDg* this, PlayState* play); +void EnDg_Held(EnDg* this, PlayState* play); +void EnDg_Thrown(EnDg* this, PlayState* play); +void EnDg_SetupTalk(EnDg* this, PlayState* play); +void EnDg_Talk(EnDg* this, PlayState* play); const ActorInit En_Dg_InitVars = { ACTOR_EN_DG, @@ -48,14 +48,37 @@ const ActorInit En_Dg_InitVars = { (ActorFunc)EnDg_Draw, }; -static u8 D_8098C2A0 = 0; +#define DOG_FLAG_NONE 0 +#define DOG_FLAG_HELD (1 << 0) +#define DOG_FLAG_JUMP_ATTACKING (1 << 1) +#define DOG_FLAG_SWIMMING (1 << 2) +#define DOG_FLAG_BOUNCED (1 << 3) +#define DOG_FLAG_THROWN (1 << 4) +#define DOG_FLAG_FOLLOWING_BREMEN_MASK (1 << 5) -typedef struct { - s16 unk_00; - s16 unk_02; -} D_8098C2A4_s; +#define ENDG_INDEX_NO_BREMEN_MASK_FOLLOWER 99 -static D_8098C2A4_s D_8098C2A4 = { 0x0063, 0x0000 }; +typedef enum { + /* 0 */ DOG_GRAB_STATE_NONE, + /* 1 */ DOG_GRAB_STATE_HELD, + /* 2 */ DOG_GRAB_STATE_THROWN_OR_SITTING_AFTER_THROW, +} DogGrabState; + +typedef enum { + /* 0 */ DOG_BEHAVIOR_INITIAL, // Gets immediately replaced by DOG_BEHAVIOR_DEFAULT in EnDg_Update + /* 1 */ DOG_BEHAVIOR_HUMAN, // Gets immediately replaced by DOG_BEHAVIOR_DEFAULT in EnDg_Update + /* 2 */ DOG_BEHAVIOR_GORON, + /* 3 */ DOG_BEHAVIOR_GORON_WAIT, + /* 4 */ DOG_BEHAVIOR_ZORA, + /* 5 */ DOG_BEHAVIOR_ZORA_WAIT, + /* 6 */ DOG_BEHAVIOR_DEKU, + /* 7 */ DOG_BEHAVIOR_DEKU_WAIT, + /* 8 */ DOG_BEHAVIOR_DEFAULT, +} DogBehavior; + +static u8 sIsAnyDogHeld = false; + +static s16 sBremenMaskFollowerIndex = ENDG_INDEX_NO_BREMEN_MASK_FOLLOWER; /** * Stores the state for the dogs milling about at the Doggy Racetrack. @@ -80,7 +103,7 @@ static RacetrackDogInfo sRacetrackDogInfo[] = { /** * Stores the RacetrackDogInfo for the dog that is selected by the player. These values are just - * placeholders, and the actual value gets grabbed from sRacetrackDogInfo in func_80989E18. + * placeholders, and the actual value gets grabbed from sRacetrackDogInfo in EnDg_TryPickUp. */ static RacetrackDogInfo sSelectedRacetrackDogInfo = { DOG_COLOR_DEFAULT, -1, 0x353E }; @@ -141,6 +164,26 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; +typedef enum { + /* 0 */ DOG_ANIMATION_WALK_AFTER_TALKING, + /* 1 */ DOG_ANIMATION_WALK, + /* 2 */ DOG_ANIMATION_RUN, + /* 3 */ DOG_ANIMATION_BARK, + /* 4 */ DOG_ANIMATION_SIT_DOWN_ONCE, // unused + /* 5 */ DOG_ANIMATION_SIT_DOWN, + /* 6 */ DOG_ANIMATION_LYING_DOWN_START_1, // unused + /* 7 */ DOG_ANIMATION_LYING_DOWN_LOOP, // unused + /* 8 */ DOG_ANIMATION_LYING_DOWN_START_2, // unused + /* 9 */ DOG_ANIMATION_LYING_DOWN_START_3, // unused + /* 10 */ DOG_ANIMATION_LYING_DOWN_START_4, // unused + /* 11 */ DOG_ANIMATION_WALK_BACKWARDS, + /* 12 */ DOG_ANIMATION_JUMP, + /* 13 */ DOG_ANIMATION_LONG_JUMP, // unused + /* 14 */ DOG_ANIMATION_JUMP_ATTACK, + /* 15 */ DOG_ANIMATION_SWIM, + /* 16 */ DOG_ANIMATION_MAX +} DogAnimationIndex; + static AnimationInfoS sAnimations[] = { { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, { &gDogRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogBarkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, @@ -149,41 +192,44 @@ static AnimationInfoS sAnimations[] = { { &gDogLyingDownAnim, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, { &gDogWalkAnim, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, { &gDogJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogLongJumpAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, - { &gDogJump2Anim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDogJumpAttackAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, }; static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -void func_80989140(SkelAnime* skelAnime, AnimationInfoS arg1[], s32 arg2) { +void EnDg_ChangeAnimation(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 index) { f32 frameCount; - arg1 += arg2; - if (arg1->frameCount < 0) { - frameCount = Animation_GetLastFrame(arg1->animation); + animationInfo += index; + if (animationInfo->frameCount < 0) { + frameCount = Animation_GetLastFrame(animationInfo->animation); } else { - frameCount = arg1->frameCount; + frameCount = animationInfo->frameCount; } - Animation_Change(skelAnime, arg1->animation, arg1->playSpeed + (BREG(88) * 0.1f), arg1->startFrame, frameCount, - arg1->mode, arg1->morphFrames); + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed + (BREG(88) * 0.1f), + animationInfo->startFrame, frameCount, animationInfo->mode, animationInfo->morphFrames); } -void func_80989204(EnDg* this, PlayState* play) { +void EnDg_UpdateCollision(EnDg* this, PlayState* play) { Player* player = GET_PLAYER(play); this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; Collider_UpdateCylinder(&this->actor, &this->collider); - if ((player->transformation == PLAYER_FORM_DEKU) && (this->actionFunc == func_8098AC34)) { + + if ((player->transformation == PLAYER_FORM_DEKU) && (this->actionFunc == EnDg_JumpAttack)) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } else { Collider_ResetCylinderAT(play, &this->collider.base); } - if ((this->unk_290 != 1) && !(this->unk_280 & 2)) { + // The check for DOG_FLAG_JUMP_ATTACKING here makes it so the dog passes through the + // player if it hits them with their jump attack. + if ((this->grabState != DOG_GRAB_STATE_HELD) && !(this->dogFlags & DOG_FLAG_JUMP_ATTACKING)) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } else { Collider_ResetCylinderOC(play, &this->collider.base); @@ -192,63 +238,67 @@ void func_80989204(EnDg* this, PlayState* play) { Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 10.0f, 0.0f, 5); } -void func_8098933C(EnDg* this, Vec3f* arg1) { - f32 sp24; - f32 sp20; - f32 sp1C; +void EnDg_GetFloorRot(EnDg* this, Vec3f* floorRot) { + f32 nx; + f32 ny; + f32 nz; if (this->actor.floorPoly != NULL) { - sp24 = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x); - sp20 = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); - sp1C = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); + 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); sinf(0.0f); cosf(0.0f); - arg1->x = -Math_Acot2F(1.0f, -sp1C * sp20); - arg1->z = Math_Acot2F(1.0f, -sp24 * sp20); + floorRot->x = -Math_Acot2F(1.0f, -nz * ny); + floorRot->z = Math_Acot2F(1.0f, -nx * ny); } } -s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { - Vec3s* sp5C = Lib_SegmentedToVirtual(arg1->points); - s32 count = arg1->count; - s32 idx = arg2; - s32 sp50 = false; - f32 phi_f12; - f32 phi_f14; - f32 sp44; - f32 sp40; - f32 sp3C; - Vec3f sp30; +s32 EnDg_HasReachedPoint(EnDg* 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; - Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); - if (idx == 0) { - phi_f12 = sp5C[1].x - sp5C[0].x; - phi_f14 = sp5C[1].z - sp5C[0].z; - } else if (idx == count - 1) { - phi_f12 = sp5C[count - 1].x - sp5C[count - 2].x; - phi_f14 = sp5C[count - 1].z - sp5C[count - 2].z; + Math_Vec3s_ToVec3f(&point, &points[currentPoint]); + 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 { - phi_f12 = sp5C[idx + 1].x - sp5C[idx - 1].x; - phi_f14 = sp5C[idx + 1].z - sp5C[idx - 1].z; + diffX = points[currentPoint + 1].x - points[currentPoint - 1].x; + diffZ = points[currentPoint + 1].z - points[currentPoint - 1].z; } - func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); - if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { - sp50 = true; + 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; } - return sp50; + return reached; } -s16 func_809895B4(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { +/** + * Returns the Y-rotation the dog should have to move to the next point along its path. + */ +s16 EnDg_GetYRotation(Path* path, s32 index, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; if (path != NULL) { points = Lib_SegmentedToVirtual(path->points); - points = &points[idx]; + points = &points[index]; diffX = points->x - pos->x; diffZ = points->z - pos->z; } else { @@ -256,34 +306,38 @@ s16 func_809895B4(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { diffZ = 0.0f; } - *distSQ = SQ(diffX) + SQ(diffZ); + *distSq = SQ(diffX) + SQ(diffZ); return RADF_TO_BINANG(Math_Acot2F(diffZ, diffX)); } -void func_80989674(EnDg* this, PlayState* play) { - s16 phi_a1; - f32 sp30; +/** + * Updates the dog's Y-rotation and speed so that it moves along its path. + */ +void EnDg_MoveAlongPath(EnDg* this, PlayState* play) { + s16 yRotation; + f32 distSq; if (this->path != NULL) { - phi_a1 = func_809895B4(this->path, this->unk_1E0, &this->actor.world.pos, &sp30); + yRotation = EnDg_GetYRotation(this->path, this->currentPoint, &this->actor.world.pos, &distSq); if (this->actor.bgCheckFlags & 8) { - phi_a1 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } - Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - if (func_80989418(this, this->path, this->unk_1E0)) { - if (this->unk_1E0 >= (this->path->count - 1)) { - this->unk_1E0 = 0; + if (EnDg_HasReachedPoint(this, this->path, this->currentPoint)) { + if (this->currentPoint >= (this->path->count - 1)) { + this->currentPoint = 0; } else { - this->unk_1E0++; + this->currentPoint++; } } - if ((this->index == 21) || ((this->index == 20) && (play->sceneNum == SCENE_OMOYA))) { + if ((this->index == ENDG_INDEX_SWAMP_SPIDER_HOUSE) || + ((this->index == ENDG_INDEX_ROMANI_RANCH) && (play->sceneNum == SCENE_OMOYA))) { Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); - } else if (this->index == 20) { + } else if (this->index == ENDG_INDEX_ROMANI_RANCH) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); } else if (play->sceneNum == SCENE_CLOCKTOWER) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); @@ -297,197 +351,232 @@ void func_80989674(EnDg* this, PlayState* play) { } } -void func_80989864(EnDg* this, PlayState* play) { - s16 frame = this->skelAnime.curFrame; +void EnDg_SpawnFloorDustRing(EnDg* this, PlayState* play) { + s16 curFrame = this->skelAnime.curFrame; s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; - Vec3f sp38; + Vec3f pos; - if (((this->index + frame) % mod) == 0) { - 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; - Actor_SpawnFloorDustRing(play, &this->actor, &sp38, 10.0f, 0, 2.0f, 300, 0, 1); + if (((this->index + curFrame) % mod) == 0) { + pos.x = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.x; + pos.y = this->actor.world.pos.y; + pos.z = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.z; + Actor_SpawnFloorDustRing(play, &this->actor, &pos, 10.0f, 0, 2.0f, 300, 0, true); } } -void func_80989974(EnDg* this) { +void EnDg_PlaySfxWalk(EnDg* this) { if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 7.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); } } -void func_809899C8(EnDg* this, f32 arg1) { - if (Animation_OnFrame(&this->skelAnime, arg1)) { +void EnDg_PlaySfxBark(EnDg* this, f32 frame) { + if (Animation_OnFrame(&this->skelAnime, frame)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); } } -void func_80989A08(EnDg* this, f32 arg1) { - if (Animation_OnFrame(&this->skelAnime, arg1)) { +void EnDg_PlaySfxAngryBark(EnDg* this, f32 frame) { + if (Animation_OnFrame(&this->skelAnime, frame)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); } } -void func_80989A48(EnDg* this) { +void EnDg_PlaySfxWhine(EnDg* this) { if (Animation_OnFrame(&this->skelAnime, 23.0f) || Animation_OnFrame(&this->skelAnime, 28.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_WHINE); } } -void func_80989A9C(EnDg* this, f32 arg1) { - if (Animation_OnFrame(&this->skelAnime, arg1)) { +void EnDg_PlaySfxGrowl(EnDg* this, f32 frame) { + if (Animation_OnFrame(&this->skelAnime, frame)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); } } -void func_80989ADC(EnDg* this, PlayState* play) { +void EnDg_SetupIdleMove(EnDg* this, PlayState* play) { if (!(this->actor.bgCheckFlags & 0x20)) { - if ((this->index == 21) || ((this->index == 20) && (play->sceneNum == SCENE_OMOYA))) { - func_80989140(&this->skelAnime, sAnimations, 1); - } else if (this->index == 20) { - func_80989140(&this->skelAnime, sAnimations, 2); + if ((this->index == ENDG_INDEX_SWAMP_SPIDER_HOUSE) || + ((this->index == ENDG_INDEX_ROMANI_RANCH) && (play->sceneNum == SCENE_OMOYA))) { + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_WALK); + } else if (this->index == ENDG_INDEX_ROMANI_RANCH) { + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_RUN); } else if (play->sceneNum == SCENE_CLOCKTOWER) { - func_80989140(&this->skelAnime, sAnimations, 2); + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_RUN); } else if (sRacetrackDogInfo[this->index].textId & 0x11) { - func_80989140(&this->skelAnime, sAnimations, 1); + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_WALK); } else { - func_80989140(&this->skelAnime, sAnimations, 2); + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_RUN); } - this->actionFunc = func_8098A468; + + this->actionFunc = EnDg_IdleMove; } } -void func_80989BF8(EnDg* this) { +/** + * Updates the text ID in sRacetrackDogInfo based on what was set in the weekEventRegs by + * En_Aob_01. This makes it sp the proper message can be displayed when the player picks up + * the dog with the Mask of Truth equipped. + */ +void EnDg_UpdateTextId(EnDg* this) { if (this->index < 14) { + // Assuming that the weekEventRegs haven't been tampered with, then this will produce a text ID in + // the range of 0x3538 to 0x3545. if (this->index % 2) { sRacetrackDogInfo[this->index].textId = - 0x3538 + ((gSaveContext.save.weekEventReg[42 + (this->index / 2)] & (0x10 | 0x20 | 0x40 | 0x80)) >> 4); + 0x3538 + ((gSaveContext.save.weekEventReg[42 + (this->index / 2)] & 0xF0) >> 4); } else { sRacetrackDogInfo[this->index].textId = - 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->index / 2)] & (1 | 2 | 4 | 8)); + 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->index / 2)] & 0x0F); } } else { Actor_MarkForDeath(&this->actor); } - if ((sRacetrackDogInfo[this->index].textId >= 0x3547) || (sRacetrackDogInfo[this->index].textId < 0x3538)) { + // As a sanity check, this makes sure the text ID is something in the expected range of 0x3538 to 0x3546. + if ((sRacetrackDogInfo[this->index].textId > 0x3546) || (sRacetrackDogInfo[this->index].textId < 0x3538)) { sRacetrackDogInfo[this->index].textId = 0x353E; } + // Text ID 0x353D is the text for the Romani Ranch dog, which is in the middle of the race dog block. If + // the dog ends up with this text ID, adjust it so the dog says a different message indcating it's in + // good condition. if (sRacetrackDogInfo[this->index].textId == 0x353D) { sRacetrackDogInfo[this->index].textId = 0x3538; } } -void func_80989D38(EnDg* this, PlayState* play) { - if (this->index == 21) { +void EnDg_StartTextBox(EnDg* this, PlayState* play) { + if (this->index == ENDG_INDEX_SWAMP_SPIDER_HOUSE) { if (CURRENT_DAY == 1) { + // Stupid master... Message_StartTextbox(play, 0x91C, NULL); } else { + // I miss the ranch... Message_StartTextbox(play, 0x91E, NULL); } - } else if ((this->index >= 0) && (this->index < 14)) { + } else if ((this->index >= ENDG_INDEX_RACETRACK_0) && (this->index <= ENDG_INDEX_RACETRACK_13)) { Message_StartTextbox(play, sRacetrackDogInfo[this->index].textId, NULL); - } else if (this->index == 20) { + } else if (this->index == ENDG_INDEX_ROMANI_RANCH) { + // I wonder if I can stop practicing... Message_StartTextbox(play, 0x353D, NULL); } else { + // Where did that Deku Scrub go? Message_StartTextbox(play, 0x627, NULL); } } -void func_80989E18(EnDg* this, PlayState* play) { - RacetrackDogInfo* temp; - - if ((D_8098C2A0 != 0) && !(this->unk_280 & 1)) { +/** + * Checks to see if the player picked up the dog and sets the appropriate state if they did. + */ +void EnDg_TryPickUp(EnDg* this, PlayState* play) { + if (sIsAnyDogHeld && !(this->dogFlags & DOG_FLAG_HELD)) { this->actor.flags |= ACTOR_FLAG_8000000; - this->unk_280 |= 1; - } else if ((D_8098C2A0 == 0) && (this->unk_280 & 1)) { + this->dogFlags |= DOG_FLAG_HELD; + } else if (!sIsAnyDogHeld && (this->dogFlags & DOG_FLAG_HELD)) { this->actor.flags &= ~ACTOR_FLAG_8000000; - this->unk_280 &= ~1; + this->dogFlags &= ~DOG_FLAG_HELD; } if (Actor_HasParent(&this->actor, play)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); - this->unk_290 = 1; + this->grabState = DOG_GRAB_STATE_HELD; sSelectedRacetrackDogInfo = sRacetrackDogInfo[this->index]; - if (D_8098C2A0 == 0) { + if (!sIsAnyDogHeld) { this->actor.flags |= ACTOR_FLAG_8000000; - D_8098C2A0 = 1; - this->unk_280 |= 1; + sIsAnyDogHeld = true; + this->dogFlags |= DOG_FLAG_HELD; } - func_80989140(&this->skelAnime, sAnimations, 5); + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_SIT_DOWN); this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; if (Player_GetMask(play) == PLAYER_MASK_TRUTH) { this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, play, 100.0f); - this->actionFunc = func_8098BBEC; + this->actionFunc = EnDg_SetupTalk; } else { - this->actionFunc = func_8098BA64; + this->actionFunc = EnDg_Held; } } else { Actor_LiftActor(&this->actor, play); } } -s32 func_80989FC8(PlayState* play) { - EnDg* enemy = (EnDg*)play->actorCtx.actorLists[ACTORCAT_ENEMY].first; +/** + * Returns true if it finds a dog to follow the player around while they're marching with + * the Bremen Mask. The index of the dog it finds is stored in sBremenMaskFollowerIndex. + */ +s32 EnDg_FindFollowerForBremenMask(PlayState* play) { + Actor* enemy = play->actorCtx.actorLists[ACTORCAT_ENEMY].first; f32 minDist = 9999.0f; f32 dist; while (enemy != NULL) { - if (enemy->actor.id == ACTOR_EN_DG) { - if (enemy->actor.isTargeted) { - D_8098C2A4.unk_00 = enemy->index; + if (enemy->id == ACTOR_EN_DG) { + if (enemy->isTargeted) { + sBremenMaskFollowerIndex = ((EnDg*)enemy)->index; return true; } - dist = enemy->actor.xzDistToPlayer; + dist = enemy->xzDistToPlayer; if (dist < minDist) { - D_8098C2A4.unk_00 = enemy->index; + sBremenMaskFollowerIndex = ((EnDg*)enemy)->index; minDist = dist; } } - enemy = (EnDg*)enemy->actor.next; + + enemy = enemy->next; } - if (D_8098C2A4.unk_00 != 99) { + if (sBremenMaskFollowerIndex != ENDG_INDEX_NO_BREMEN_MASK_FOLLOWER) { return true; } return false; } -void func_8098A064(EnDg* this, PlayState* play) { +/** + * This checks for two conditions: + * - If the player has started marching with the Bremen Mask, then it makes the dog + * start following the player around (assuming it's the best candidate found in + * EnDg_FindFollowerForBremenMask above). + * - If the player has stopped marching with the Bremen Mask, and this dog was + * following them around, then it returns the dog to its idle state. + */ +void EnDg_CheckForBremenMaskMarch(EnDg* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (player->stateFlags3 & 0x20000000) { - if (D_8098C2A4.unk_00 == 99) { - func_80989FC8(play); + if (player->stateFlags3 & 0x20000000) { // bremen mask march + if (sBremenMaskFollowerIndex == ENDG_INDEX_NO_BREMEN_MASK_FOLLOWER) { + EnDg_FindFollowerForBremenMask(play); } - if (this->index == D_8098C2A4.unk_00) { - if (!(this->unk_280 & 0x20)) { - this->unk_280 |= 0x20; - func_80989140(&this->skelAnime, sAnimations, 1); - this->actionFunc = func_8098AF44; - } else if ((this->actionFunc == func_8098B004) || (this->actionFunc == func_8098AB48)) { - if (DECR(this->unk_292) == 0) { - this->unk_292 = 10; + if (this->index == sBremenMaskFollowerIndex) { + if (!(this->dogFlags & DOG_FLAG_FOLLOWING_BREMEN_MASK)) { + this->dogFlags |= DOG_FLAG_FOLLOWING_BREMEN_MASK; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_WALK); + this->actionFunc = EnDg_SetupBremenMaskApproachPlayer; + } else if ((this->actionFunc == EnDg_ApproachPlayer) || (this->actionFunc == EnDg_SitNextToPlayer)) { + if (DECR(this->bremenBarkTimer) == 0) { + this->bremenBarkTimer = 10; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); } } } - } else if (this->index == D_8098C2A4.unk_00) { - this->unk_280 &= ~0x20; - D_8098C2A4.unk_00 = 99; - func_80989ADC(this, play); - this->actionFunc = func_8098A468; + } else if (this->index == sBremenMaskFollowerIndex) { + this->dogFlags &= ~DOG_FLAG_FOLLOWING_BREMEN_MASK; + sBremenMaskFollowerIndex = ENDG_INDEX_NO_BREMEN_MASK_FOLLOWER; + EnDg_SetupIdleMove(this, play); + this->actionFunc = EnDg_IdleMove; } } -s32 func_8098A1B4(EnDg* this, PlayState* play) { +/** + * Returns true if the player is not human and the dog is close enough to start + * reacting to their current form. + */ +s32 EnDg_ShouldReactToNonHumanPlayer(EnDg* this, PlayState* play) { Player* player = GET_PLAYER(play); switch (player->transformation) { @@ -496,7 +585,7 @@ s32 func_8098A1B4(EnDg* this, PlayState* play) { if (this->actor.xzDistToPlayer < 300.0f) { return true; } - + // fallthrough case PLAYER_FORM_DEKU: if (this->actor.xzDistToPlayer < 250.0f) { return true; @@ -507,144 +596,167 @@ s32 func_8098A1B4(EnDg* this, PlayState* play) { return false; } -void func_8098A234(EnDg* this, PlayState* play) { +/** + * Sets the appropriate actionFunc given the player's current form and the dog's current behavior. + * Specifically, it makes sure that the dog doesn't start reacting to the player's form until the + * player starts moving a bit. This was presumably done so the player could more easily react to + * the dog changing its behavior; it would be strange if the dog attacked the player the instant + * they put on the Deku Mask, for example. + */ +void EnDg_ChooseActionForForm(EnDg* this, PlayState* play) { Player* player = GET_PLAYER(play); if (!(this->actor.bgCheckFlags & 0x20)) { switch (player->transformation) { case PLAYER_FORM_HUMAN: - if (this->unk_28C != 1) { - this->unk_28C = 1; - this->unk_280 &= ~2; - func_80989ADC(this, play); + if (this->behavior != DOG_BEHAVIOR_HUMAN) { + this->behavior = DOG_BEHAVIOR_HUMAN; + this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; + EnDg_SetupIdleMove(this, play); } break; case PLAYER_FORM_ZORA: - this->unk_280 &= ~2; - if ((this->unk_28C != 4) && (player->actor.speedXZ > 1.0f)) { - this->unk_28C = 4; - func_80989140(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_8098B004; + this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; + if ((this->behavior != DOG_BEHAVIOR_ZORA) && (player->actor.speedXZ > 1.0f)) { + this->behavior = DOG_BEHAVIOR_ZORA; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_RUN); + this->actionFunc = EnDg_ApproachPlayer; } - if ((this->unk_28C != 5) && (this->unk_28C != 4)) { - this->unk_28C = 5; - func_80989ADC(this, play); + if ((this->behavior != DOG_BEHAVIOR_ZORA_WAIT) && (this->behavior != DOG_BEHAVIOR_ZORA)) { + this->behavior = DOG_BEHAVIOR_ZORA_WAIT; + EnDg_SetupIdleMove(this, play); } break; case PLAYER_FORM_GORON: - this->unk_280 &= ~2; - if ((this->unk_28C != 2) && (player->actor.speedXZ > 1.0f)) { - this->unk_28C = 2; - func_80989140(&this->skelAnime, sAnimations, 11); - this->unk_282 = 50; - this->actionFunc = func_8098A618; + this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; + if ((this->behavior != DOG_BEHAVIOR_GORON) && (player->actor.speedXZ > 1.0f)) { + this->behavior = DOG_BEHAVIOR_GORON; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_WALK_BACKWARDS); + this->timer = 50; + this->actionFunc = EnDg_BackAwayFromGoron; } - if ((this->unk_28C != 3) && (this->unk_28C != 2)) { - this->unk_28C = 3; - func_80989ADC(this, play); + if ((this->behavior != DOG_BEHAVIOR_GORON_WAIT) && (this->behavior != DOG_BEHAVIOR_GORON)) { + this->behavior = DOG_BEHAVIOR_GORON_WAIT; + EnDg_SetupIdleMove(this, play); } break; case PLAYER_FORM_DEKU: - this->unk_280 &= ~2; - if ((this->unk_28C != 6) && (player->actor.speedXZ > 1.0f)) { - this->unk_28C = 6; - func_80989140(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_8098A938; + this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; + if ((this->behavior != DOG_BEHAVIOR_DEKU) && (player->actor.speedXZ > 1.0f)) { + this->behavior = DOG_BEHAVIOR_DEKU; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_RUN); + this->actionFunc = EnDg_ApproachPlayerToAttack; } - if ((this->unk_28C != 7) && (this->unk_28C != 6)) { - this->unk_28C = 7; - func_80989ADC(this, play); + if ((this->behavior != DOG_BEHAVIOR_DEKU_WAIT) && (this->behavior != DOG_BEHAVIOR_DEKU)) { + this->behavior = DOG_BEHAVIOR_DEKU_WAIT; + EnDg_SetupIdleMove(this, play); } break; } } } -void func_8098A468(EnDg* this, PlayState* play) { +/** + * Moves the dog along its path, stopping to bark at random intervals. + */ +void EnDg_IdleMove(EnDg* this, PlayState* play) { Player* player = GET_PLAYER(play); this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; - func_80989674(this, play); + EnDg_MoveAlongPath(this, play); Actor_MoveWithGravity(&this->actor); if (player->transformation == PLAYER_FORM_HUMAN) { - func_80989E18(this, play); + EnDg_TryPickUp(this, play); } - func_8098A064(this, play); - func_80989974(this); + EnDg_CheckForBremenMaskMarch(this, play); + EnDg_PlaySfxWalk(this); if (!(this->actor.bgCheckFlags & 1)) { - this->actionFunc = func_8098AF98; + this->actionFunc = EnDg_Fall; } - if (DECR(this->unk_282) == 0) { - this->unk_282 = Rand_S16Offset(20, 20); - func_80989140(&this->skelAnime, sAnimations, 3); - this->actionFunc = func_8098A55C; + if (DECR(this->timer) == 0) { + this->timer = Rand_S16Offset(20, 20); + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_BARK); + this->actionFunc = EnDg_IdleBark; } } -void func_8098A55C(EnDg* this, PlayState* play) { +/** + * Stops and barks, before returning to moving along its path. + */ +void EnDg_IdleBark(EnDg* this, PlayState* play) { Player* player = GET_PLAYER(play); if (player->transformation == PLAYER_FORM_HUMAN) { - func_80989E18(this, play); + EnDg_TryPickUp(this, play); } - func_809899C8(this, 13.0f); - func_809899C8(this, 19.0f); + EnDg_PlaySfxBark(this, 13.0f); + EnDg_PlaySfxBark(this, 19.0f); + if (!(this->actor.bgCheckFlags & 1)) { - this->actionFunc = func_8098AF98; + this->actionFunc = EnDg_Fall; } - if (DECR(this->unk_282) == 0) { - this->unk_282 = Rand_S16Offset(60, 60); - func_80989ADC(this, play); + if (DECR(this->timer) == 0) { + this->timer = Rand_S16Offset(60, 60); + EnDg_SetupIdleMove(this, play); } } -void func_8098A618(EnDg* this, PlayState* play) { +/** + * Slowly back away from the player while growling. After a short time backing away, + * this function will make the dog away from the player. + */ +void EnDg_BackAwayFromGoron(EnDg* this, PlayState* play) { this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; - if (DECR(this->unk_282) == 0) { - this->unk_282 = 50; - func_80989140(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_8098A70C; + if (DECR(this->timer) == 0) { + this->timer = 50; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_RUN); + this->actionFunc = EnDg_RunAwayFromGoron; } else { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0x3E8, 1); if (this->actor.bgCheckFlags & 8) { this->actor.shape.rot.y = this->actor.wallYaw; } + this->actor.world.rot.y = this->actor.shape.rot.y; Math_ApproachF(&this->actor.speedXZ, -1.5f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); } - func_80989974(this); - func_80989A9C(this, 0); + EnDg_PlaySfxWalk(this); + EnDg_PlaySfxGrowl(this, 0); } -void func_8098A70C(EnDg* this, PlayState* play) { +/** + * Quickly run away from the player. Once the dog is far enough from the player, + * this function will make them start barking at them. + */ +void EnDg_RunAwayFromGoron(EnDg* this, PlayState* play) { Player* player = GET_PLAYER(play); - s16 phi_a1; + s16 yRotation; if (this->actor.xzDistToPlayer < 250.0f) { Math_ApproachS(&this->actor.shape.rot.y, -this->actor.yawTowardsPlayer, 4, 0xC00); if (this->actor.bgCheckFlags & 8) { - phi_a1 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } else { - phi_a1 = 0; + yRotation = 0; } - Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); this->actor.world.rot.y = this->actor.shape.rot.y; if (player->actor.speedXZ != 0.0f) { Math_ApproachF(&this->actor.speedXZ, player->actor.speedXZ, 0.2f, 1.0f); @@ -652,8 +764,8 @@ void func_8098A70C(EnDg* this, PlayState* play) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); } } else { - func_80989140(&this->skelAnime, sAnimations, 3); - this->actionFunc = func_8098A89C; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_BARK); + this->actionFunc = EnDg_BarkAtGoron; } if (this->actor.speedXZ > 7.0f) { @@ -661,7 +773,8 @@ void func_8098A70C(EnDg* this, PlayState* play) { } Actor_MoveWithGravity(&this->actor); - func_80989974(this); + EnDg_PlaySfxWalk(this); + if (Animation_OnFrame(&this->skelAnime, 3.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_CRY); } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { @@ -669,20 +782,23 @@ void func_8098A70C(EnDg* this, PlayState* play) { } } -void func_8098A89C(EnDg* this, PlayState* play) { +/** + * Bark at the player until they get close enough, at which point the dog starts backing away. + */ +void EnDg_BarkAtGoron(EnDg* this, PlayState* play) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00); this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.xzDistToPlayer < 250.0f) { - func_80989140(&this->skelAnime, sAnimations, 11); - this->unk_282 = 50; - this->actionFunc = func_8098A618; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_WALK_BACKWARDS); + this->timer = 50; + this->actionFunc = EnDg_BackAwayFromGoron; } - func_80989A08(this, 13.0f); - func_80989A08(this, 19.0f); + EnDg_PlaySfxAngryBark(this, 13.0f); + EnDg_PlaySfxAngryBark(this, 19.0f); } -void func_8098A938(EnDg* this, PlayState* play) { +void EnDg_ApproachPlayerToAttack(EnDg* this, PlayState* play) { Player* player = GET_PLAYER(play); this->actor.velocity.y = 0.0f; @@ -695,16 +811,16 @@ void func_8098A938(EnDg* this, PlayState* play) { if (this->actor.xzDistToPlayer < 70.0f) { Math_ApproachZeroF(&this->actor.speedXZ, 0.2f, 1.0f); if (Animation_OnFrame(&this->skelAnime, 7.0f)) { - s16 y = ABS_ALT(player->actor.shape.rot.y - this->actor.shape.rot.y); + s16 yawDiff = ABS_ALT(player->actor.shape.rot.y - this->actor.shape.rot.y); - this->unk_28E = 20; - if (y < 0x4000) { - func_80989140(&this->skelAnime, sAnimations, 14); - this->actionFunc = func_8098AC34; + this->attackTimer = 20; + if (yawDiff < 0x4000) { + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_JUMP_ATTACK); + this->actionFunc = EnDg_JumpAttack; } else { - func_80989140(&this->skelAnime, sAnimations, 11); - sAnimations[11].playSpeed = -1.0f; - this->actionFunc = func_8098B198; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_WALK_BACKWARDS); + sAnimations[DOG_ANIMATION_WALK_BACKWARDS].playSpeed = -1.0f; + this->actionFunc = EnDg_SlowlyBackUpBeforeAttacking; } } } else { @@ -713,102 +829,121 @@ void func_8098A938(EnDg* this, PlayState* play) { } Actor_MoveWithGravity(&this->actor); - func_80989974(this); - func_80989A08(this, 5.0f); + EnDg_PlaySfxWalk(this); + EnDg_PlaySfxAngryBark(this, 5.0f); } -void func_8098AAAC(EnDg* this, PlayState* play) { - this->unk_280 &= ~8; +/** + * Makes the dog run around for a bit after attacking before it + * starts to approach the player for another attack. + */ +void EnDg_RunAfterAttacking(EnDg* this, PlayState* play) { + this->dogFlags &= ~DOG_FLAG_BOUNCED; Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.1f, 0.5f); Actor_MoveWithGravity(&this->actor); - if (DECR(this->unk_28E) == 0) { - this->unk_28E = 20; - this->actionFunc = func_8098A938; + if (DECR(this->attackTimer) == 0) { + this->attackTimer = 20; + this->actionFunc = EnDg_ApproachPlayerToAttack; } - func_80989974(this); - func_80989A08(this, 3.0f); + EnDg_PlaySfxWalk(this); + EnDg_PlaySfxAngryBark(this, 3.0f); } -void func_8098AB48(EnDg* this, PlayState* play) { +/** + * Makes the dog sit next to the player until they get too far away, at which point + * it will attempt to approach them again. + */ +void EnDg_SitNextToPlayer(EnDg* this, PlayState* play) { Player* player = GET_PLAYER(play); if (!(this->actor.bgCheckFlags & 1)) { - this->actionFunc = func_8098AF98; + this->actionFunc = EnDg_Fall; } if (this->actor.xzDistToPlayer < 50.0f) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00); this->actor.world.rot.y = this->actor.shape.rot.y; } else { - if (player->stateFlags3 & 0x20000000) { - func_80989140(&this->skelAnime, sAnimations, 1); + if (player->stateFlags3 & 0x20000000) { // bremen mask march + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_WALK); } else { - func_80989140(&this->skelAnime, sAnimations, 2); + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_RUN); } - this->actionFunc = func_8098B004; + + this->actionFunc = EnDg_ApproachPlayer; } - func_8098A064(this, play); - if (!(this->unk_280 & 0x20)) { - func_80989A48(this); + EnDg_CheckForBremenMaskMarch(this, play); + + // If we're in this function, the player is either marching with the Bremen Mask, or + // they're a Zora. The below code will make the dog repeatedly whine in the latter case. + if (!(this->dogFlags & DOG_FLAG_FOLLOWING_BREMEN_MASK)) { + EnDg_PlaySfxWhine(this); } } -void func_8098AC34(EnDg* this, PlayState* play) { - s16 sp26 = this->skelAnime.curFrame; +void EnDg_JumpAttack(EnDg* this, PlayState* play) { + s16 curFrame = this->skelAnime.curFrame; if ((this->actor.xyzDistToPlayerSq < 800.0f) && (this->collider.base.atFlags & AT_BOUNCED)) { - this->unk_28E = 60; - this->unk_280 &= ~2; - this->unk_280 |= 8; + this->attackTimer = 60; + this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; + this->dogFlags |= DOG_FLAG_BOUNCED; this->collider.base.atFlags &= ~AT_BOUNCED; this->actor.speedXZ *= -1.0f; - func_80989140(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_8098AAAC; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_RUN); + this->actionFunc = EnDg_RunAfterAttacking; return; } - if (DECR(this->unk_28E) == 0) { - this->unk_28E = 60; - this->unk_280 &= ~2; - func_80989140(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_8098AAAC; + if (DECR(this->attackTimer) == 0) { + this->attackTimer = 60; + this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_RUN); + this->actionFunc = EnDg_RunAfterAttacking; } - if (sp26 < 9) { + if (curFrame < 9) { if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - sAnimations[14].playSpeed = randPlusMinusPoint5Scaled(1.0f) + 3.0f; + sAnimations[DOG_ANIMATION_JUMP_ATTACK].playSpeed = randPlusMinusPoint5Scaled(1.0f) + 3.0f; } - func_80989864(this, play); + + EnDg_SpawnFloorDustRing(this, play); } else { - this->unk_280 |= 2; + this->dogFlags |= DOG_FLAG_JUMP_ATTACKING; if (Animation_OnFrame(&this->skelAnime, 9.0f)) { f32 rand = randPlusMinusPoint5Scaled(1.5f); - sAnimations[14].playSpeed = 1.2f; + sAnimations[DOG_ANIMATION_JUMP_ATTACK].playSpeed = 1.2f; this->actor.velocity.y = 2.0f * rand + 3.0f; this->actor.speedXZ = 8.0f + rand; - } else if (sp26 >= 0x15) { + } else if (curFrame > 20) { Math_ApproachF(&this->actor.speedXZ, 2.5f, 0.2f, 1.0f); } - if (sp26 >= 0x18) { - func_80989864(this, play); + + if (curFrame > 23) { + EnDg_SpawnFloorDustRing(this, play); } + Actor_MoveWithGravity(&this->actor); } - func_80989A9C(this, 10.0f); + EnDg_PlaySfxGrowl(this, 10.0f); } -// Unused? -void func_8098AE58(EnDg* this, PlayState* play) { +/** + * An unused function that will make the dog walk slowly towards the player until they're + * in a specific range, at which point they will bark at them. This might be part of an + * unused or early variation of how dogs react to Goron Link. + */ +void EnDg_WalkToPlayer(EnDg* this, PlayState* play) { if (this->actor.xzDistToPlayer < 150.0f) { - func_80989140(&this->skelAnime, sAnimations, 11); - this->actionFunc = func_8098B28C; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_WALK_BACKWARDS); + this->actionFunc = EnDg_BackAwayFromPlayer; } else if (this->actor.xzDistToPlayer < 200.0f) { - func_80989140(&this->skelAnime, sAnimations, 3); - this->actionFunc = func_8098B390; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_BARK); + this->actionFunc = EnDg_BarkAtPlayer; } else { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00); this->actor.world.rot.y = this->actor.shape.rot.y; @@ -816,29 +951,33 @@ void func_8098AE58(EnDg* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); } - func_80989974(this); - func_809899C8(this, 5.0f); + EnDg_PlaySfxWalk(this); + EnDg_PlaySfxBark(this, 5.0f); } -void func_8098AF44(EnDg* this, PlayState* play) { +void EnDg_SetupBremenMaskApproachPlayer(EnDg* this, PlayState* play) { if (func_801A46F8() == 1) { - this->unk_292 = 10; + this->bremenBarkTimer = 10; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); - this->actionFunc = func_8098B004; + this->actionFunc = EnDg_ApproachPlayer; } } -void func_8098AF98(EnDg* this, PlayState* play) { +void EnDg_Fall(EnDg* this, PlayState* play) { if (this->actor.bgCheckFlags & 1) { - func_80989140(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_8098A468; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_RUN); + this->actionFunc = EnDg_IdleMove; } Actor_MoveWithGravity(&this->actor); - func_809899C8(this, 3.0f); + EnDg_PlaySfxBark(this, 3.0f); } -void func_8098B004(EnDg* this, PlayState* play) { +/** + * Approach the player non-aggressively. If the player stops moving, then + * eventually the dog will sit down next to them. + */ +void EnDg_ApproachPlayer(EnDg* this, PlayState* play) { Player* player = GET_PLAYER(play); this->actor.velocity.y = 0.0f; @@ -851,9 +990,9 @@ void func_8098B004(EnDg* this, PlayState* play) { this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.xzDistToPlayer < 40.0f) { - func_80989140(&this->skelAnime, sAnimations, 5); - this->actionFunc = func_8098AB48; - } else if (player->stateFlags3 & 0x20000000) { + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_SIT_DOWN); + this->actionFunc = EnDg_SitNextToPlayer; + } else if (player->stateFlags3 & 0x20000000) { // bremen mask march if ((this->actor.xzDistToPlayer > 40.0f) && (player->linearVelocity == 0.0f)) { Math_ApproachF(&this->actor.speedXZ, 1.5f, 0.2f, 1.0f); } else { @@ -863,41 +1002,54 @@ void func_8098B004(EnDg* this, PlayState* play) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); } - func_8098A064(this, play); + EnDg_CheckForBremenMaskMarch(this, play); Actor_MoveWithGravity(&this->actor); - func_80989974(this); - if (!(this->unk_280 & 0x20)) { - func_809899C8(this, 3.0f); + EnDg_PlaySfxWalk(this); + + // If we're in this function, the player is either marching with the Bremen Mask, or + // they're a Zora. The below code will make the dog repeatedly bark in the latter case. + if (!(this->dogFlags & DOG_FLAG_FOLLOWING_BREMEN_MASK)) { + EnDg_PlaySfxBark(this, 3.0f); } } -void func_8098B198(EnDg* this, PlayState* play) { +/** + * Makes the dog slowly back up and face the player before performing a jump attack. Used to + * give the dog a bit of time to correct its angle if they were unlikely to hit the player. + */ +void EnDg_SlowlyBackUpBeforeAttacking(EnDg* this, PlayState* play) { if (this->actor.xzDistToPlayer > 72.0f) { - func_80989140(&this->skelAnime, sAnimations, 14); - this->actionFunc = func_8098AC34; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_JUMP_ATTACK); + this->actionFunc = EnDg_JumpAttack; } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0x3E8, 1); if (this->actor.bgCheckFlags & 8) { this->actor.shape.rot.y = this->actor.wallYaw; - func_80989140(&this->skelAnime, sAnimations, 14); - this->actionFunc = func_8098AC34; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_JUMP_ATTACK); + this->actionFunc = EnDg_JumpAttack; } this->actor.world.rot.y = this->actor.shape.rot.y; Math_ApproachF(&this->actor.speedXZ, -1.0f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); - func_80989974(this); - func_80989A9C(this, 4.0f); + EnDg_PlaySfxWalk(this); + EnDg_PlaySfxGrowl(this, 4.0f); } -void func_8098B28C(EnDg* this, PlayState* play) { +/** + * An unused function that will make the dog back away from the player while growling. + * It is quite similar to EnDg_BackAwayFromGoron; perhaps this is an earlier version of it? + * Unlike that function, this will make the dog approach the player if they move too far away. + * It also lacks the behavior where the dog runs away in a panic after a short time. + */ +void EnDg_BackAwayFromPlayer(EnDg* this, PlayState* play) { if (this->actor.xzDistToPlayer > 200.0f) { - func_80989140(&this->skelAnime, sAnimations, 1); - this->actionFunc = func_8098AE58; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_WALK); + this->actionFunc = EnDg_WalkToPlayer; } else if (this->actor.xzDistToPlayer > 150.0f) { - func_80989140(&this->skelAnime, sAnimations, 3); - this->actionFunc = func_8098B390; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_BARK); + this->actionFunc = EnDg_BarkAtPlayer; } else { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0x3E8, 1); if (this->actor.bgCheckFlags & 8) { @@ -909,69 +1061,86 @@ void func_8098B28C(EnDg* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); } - func_80989974(this); + EnDg_PlaySfxWalk(this); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); } -void func_8098B390(EnDg* this, PlayState* play) { +/** + * An unused function that will make the dog bark at the player endlessly. + * It is quite similar to EnDg_BarkAtGoron; perhaps this is an earlier version of it? + * Unlike that function, this will make the dog approach the player if they move too far away. + * It also mixes in multiple growls into the bark. + */ +void EnDg_BarkAtPlayer(EnDg* this, PlayState* play) { if (this->actor.xzDistToPlayer < 150.0f) { - func_80989140(&this->skelAnime, sAnimations, 11); - this->actionFunc = func_8098B28C; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_WALK_BACKWARDS); + this->actionFunc = EnDg_BackAwayFromPlayer; } else if (this->actor.xzDistToPlayer > 200.0f) { - func_80989140(&this->skelAnime, sAnimations, 1); - this->actionFunc = func_8098AE58; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_WALK); + this->actionFunc = EnDg_WalkToPlayer; } - func_80989A9C(this, 0.0f); - func_80989A9C(this, 1.0f); - func_80989A9C(this, 2.0f); - func_80989A9C(this, 3.0f); - func_809899C8(this, 5.0f); + EnDg_PlaySfxGrowl(this, 0.0f); + EnDg_PlaySfxGrowl(this, 1.0f); + EnDg_PlaySfxGrowl(this, 2.0f); + EnDg_PlaySfxGrowl(this, 3.0f); + EnDg_PlaySfxBark(this, 5.0f); } -void func_8098B464(EnDg* this, PlayState* play) { - Vec3f sp2C; +/** + * Makes a splash effect and plays the splash sfx when the dog enters the water, then + * makes them start swimming. + */ +void EnDg_SetupSwim(EnDg* this, PlayState* play) { + Vec3f pos; + + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + this->actor.depthInWater; + pos.z = this->actor.world.pos.z + 20.0f; + EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 0, 800); + EffectSsGRipple_Spawn(play, &pos, 100, 500, 30); - sp2C.x = this->actor.world.pos.x; - sp2C.y = this->actor.world.pos.y + this->actor.depthInWater; - sp2C.z = this->actor.world.pos.z + 20.0f; - EffectSsGSplash_Spawn(play, &sp2C, NULL, NULL, 0, 800); - EffectSsGRipple_Spawn(play, &sp2C, 100, 500, 30); if (this->actor.depthInWater > 0.0f) { this->actor.gravity = 0.0f; this->actor.velocity.y = -3.0f; - this->unk_284 = 10; + this->swimTimer = 10; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); - this->actionFunc = func_8098B560; + this->actionFunc = EnDg_Swim; } Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); } -void func_8098B560(EnDg* this, PlayState* play) { - Vec3f sp54; +/** + * Makes the dog swim until it either: + * - Touches land, at which point it will just resume its idle movement. + * - Touches a wall, at which point it will attempt to jump out of the water. + */ +void EnDg_Swim(EnDg* this, PlayState* play) { + Vec3f ripplePos; Vec3f pos; - s16 sp46 = 0; + s16 yRotation = 0; WaterBox* waterBox; f32 waterSurface; CollisionPoly* poly; - f32 sp34; + f32 floorHeight; - sp54.x = this->actor.world.pos.x; - sp54.y = this->actor.world.pos.y + this->actor.depthInWater; - sp54.z = this->actor.world.pos.z + 20.0f; + ripplePos.x = this->actor.world.pos.x; + ripplePos.y = this->actor.world.pos.y + this->actor.depthInWater; + ripplePos.z = this->actor.world.pos.z + 20.0f; pos.x = (Math_SinS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.x; pos.y = this->actor.home.pos.y + 100.0f; pos.z = (Math_CosS(this->actor.world.rot.y) * 50.0f) + this->actor.world.pos.z; - if (DECR(this->unk_284) == 0) { - if (!(this->unk_280 & 4)) { - this->unk_280 |= 4; + if (DECR(this->swimTimer) == 0) { + if (!(this->dogFlags & DOG_FLAG_SWIMMING)) { + this->dogFlags |= DOG_FLAG_SWIMMING; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); } - this->unk_284 = 5; - EffectSsGRipple_Spawn(play, &sp54, 100, 500, 30); + + this->swimTimer = 5; + EffectSsGRipple_Spawn(play, &ripplePos, 100, 500, 30); } if (this->actor.depthInWater > 15.0f) { @@ -980,52 +1149,63 @@ void func_8098B560(EnDg* this, PlayState* play) { this->actor.velocity.y = -0.5f; } - sp34 = BgCheck_EntityRaycastFloor2(play, &play->colCtx, &poly, &pos); + floorHeight = BgCheck_EntityRaycastFloor2(play, &play->colCtx, &poly, &pos); + + // The below code checks *only* that the dog is touching a wall, which can result in + // some strange behavior if the dog is touching a wall that is too tall for it to jump + // over. For example, if the player throws the dog at a tall wall next to some water, + // this code will make the dog "skip" along the water's surface, assuming the floor + // height is low enough to make it try to jump out. if (this->actor.bgCheckFlags & 8) { if (!WaterBox_GetSurface1(play, &play->colCtx, pos.x, pos.z, &waterSurface, &waterBox)) { - if (sp34 > -100.0f) { - this->unk_280 &= ~4; - this->actionFunc = func_8098B88C; + if (floorHeight > -100.0f) { + this->dogFlags &= ~DOG_FLAG_SWIMMING; + this->actionFunc = EnDg_JumpOutOfWater; } else { - sp46 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } - } else if (sp34 > -100.0f) { - if (waterSurface < sp34) { - this->unk_280 &= ~4; - this->actionFunc = func_8098B88C; + } else if (floorHeight > -100.0f) { + if (waterSurface < floorHeight) { + this->dogFlags &= ~DOG_FLAG_SWIMMING; + this->actionFunc = EnDg_JumpOutOfWater; } else { - sp46 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } } else { - sp46 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } } else if ((this->actor.bgCheckFlags & 1) && !(this->actor.bgCheckFlags & 0x20)) { this->actor.gravity = -3.0f; - this->unk_280 &= ~4; - this->unk_28C = 8; - this->unk_282 = Rand_S16Offset(60, 60); + this->dogFlags &= ~DOG_FLAG_SWIMMING; + this->behavior = DOG_BEHAVIOR_DEFAULT; + this->timer = Rand_S16Offset(60, 60); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); - func_80989140(&this->skelAnime, sAnimations, 2); + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_RUN); Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); - this->actionFunc = func_8098A468; + this->actionFunc = EnDg_IdleMove; } - Math_SmoothStepToS(&this->actor.world.rot.y, sp46, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); } -void func_8098B88C(EnDg* this, PlayState* play) { - Vec3f sp34; +/** + * This function attempts to get the dog out of water by making it jump near walls. + * The point of this is seemingly to let the dog escape the shallow water pools in + * South Clock Town. + */ +void EnDg_JumpOutOfWater(EnDg* this, PlayState* play) { + Vec3f pos; - sp34.x = this->actor.world.pos.x; - sp34.y = this->actor.world.pos.y + this->actor.depthInWater; - sp34.z = this->actor.world.pos.z + 20.0f; + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + this->actor.depthInWater; + pos.z = this->actor.world.pos.z + 20.0f; - if (DECR(this->unk_284) == 0) { - this->unk_284 = 5; - EffectSsGRipple_Spawn(play, &sp34, 100, 500, 30); + if (DECR(this->swimTimer) == 0) { + this->swimTimer = 5; + EffectSsGRipple_Spawn(play, &pos, 100, 500, 30); } if (this->actor.depthInWater > 15.0f) { @@ -1035,19 +1215,19 @@ void func_8098B88C(EnDg* this, PlayState* play) { } if (this->actor.bgCheckFlags & 8) { - this->actor.world.pos.y = sp34.y; + this->actor.world.pos.y = pos.y; this->actor.velocity.y = 10.0f; - EffectSsGSplash_Spawn(play, &sp34, NULL, NULL, 0, 800); + EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 0, 800); } if (!(this->actor.bgCheckFlags & 0x20)) { - this->unk_28C = 8; + this->behavior = DOG_BEHAVIOR_DEFAULT; this->actor.velocity.y = 10.0f; this->actor.gravity = -3.0f; - this->unk_282 = Rand_S16Offset(60, 60); + this->timer = Rand_S16Offset(60, 60); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); - func_80989140(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_8098A468; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_RUN); + this->actionFunc = EnDg_IdleMove; Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); } else { Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); @@ -1056,63 +1236,64 @@ void func_8098B88C(EnDg* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); } -void func_8098BA64(EnDg* this, PlayState* play) { +void EnDg_Held(EnDg* this, PlayState* play) { if (Actor_HasNoParent(&this->actor, play)) { - this->unk_290 = 2; + this->grabState = DOG_GRAB_STATE_THROWN_OR_SITTING_AFTER_THROW; this->actor.flags |= ACTOR_FLAG_1; - if (D_8098C2A0 != 0) { + if (sIsAnyDogHeld) { this->actor.flags &= ~ACTOR_FLAG_8000000; - D_8098C2A0 = 0; - this->unk_280 &= ~1; + sIsAnyDogHeld = false; + this->dogFlags &= ~DOG_FLAG_HELD; } + this->selectedDogIndex = -1; sSelectedRacetrackDogInfo.index = this->selectedDogIndex; - this->unk_28A = 100; + this->sitAfterThrowTimer = 100; Actor_MoveWithGravity(&this->actor); - this->unk_280 |= 0x10; - this->actionFunc = func_8098BB10; + this->dogFlags |= DOG_FLAG_THROWN; + this->actionFunc = EnDg_Thrown; } } -void func_8098BB10(EnDg* this, PlayState* play) { +void EnDg_Thrown(EnDg* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->actor.bgCheckFlags & 1) { - if (this->unk_280 & 0x10) { - this->unk_280 &= ~0x10; + if (this->dogFlags & DOG_FLAG_THROWN) { + this->dogFlags &= ~DOG_FLAG_THROWN; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); } this->actor.speedXZ = 0.0f; this->actor.gravity = -3.0f; if (player->transformation == PLAYER_FORM_HUMAN) { - func_80989E18(this, play); + EnDg_TryPickUp(this, play); } } - if (DECR(this->unk_28A) == 0) { - this->unk_290 = 0; - func_80989ADC(this, play); - this->actionFunc = func_8098A468; + if (DECR(this->sitAfterThrowTimer) == 0) { + this->grabState = DOG_GRAB_STATE_NONE; + EnDg_SetupIdleMove(this, play); + this->actionFunc = EnDg_IdleMove; } Actor_MoveWithGravity(&this->actor); } -void func_8098BBEC(EnDg* this, PlayState* play) { +void EnDg_SetupTalk(EnDg* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_80989D38(this, play); - this->actionFunc = func_8098BC54; + EnDg_StartTextBox(this, play); + this->actionFunc = EnDg_Talk; } else { func_800B8614(&this->actor, play, 100.0f); } } -void func_8098BC54(EnDg* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 2) { - func_80989140(&this->skelAnime, sAnimations, 0); - this->actionFunc = func_8098BA64; +void EnDg_Talk(EnDg* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_WALK_AFTER_TALKING); + this->actionFunc = EnDg_Held; } } @@ -1126,22 +1307,24 @@ void EnDg_Init(Actor* thisx, PlayState* play) { Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); + this->path = SubS_GetPathByIndex(play, ENDG_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.targetMode = 1; this->actor.gravity = -3.0f; - this->unk_282 = Rand_S16Offset(60, 60); - this->unk_280 = 0; - this->unk_28E = 20; - this->unk_284 = 10; + this->timer = Rand_S16Offset(60, 60); + this->dogFlags = DOG_FLAG_NONE; + this->attackTimer = 20; + this->swimTimer = 10; this->index = ENDG_GET_INDEX(&this->actor); - this->unk_28C = 0; - this->unk_290 = 0; + this->behavior = DOG_BEHAVIOR_INITIAL; + this->grabState = DOG_GRAB_STATE_NONE; if (play->sceneNum == SCENE_F01_B) { - this->unk_28A = 100; - func_80989BF8(this); + this->sitAfterThrowTimer = 100; + EnDg_UpdateTextId(this); } - func_80989ADC(this, play); + + EnDg_SetupIdleMove(this, play); } void EnDg_Destroy(Actor* thisx, PlayState* play) { @@ -1154,27 +1337,27 @@ void EnDg_Update(Actor* thisx, PlayState* play) { EnDg* this = THIS; Player* player = GET_PLAYER(play); s32 pad; - Vec3f sp28 = { 0.0f, 0.0f, 0.0f }; + Vec3f floorRot = { 0.0f, 0.0f, 0.0f }; this->selectedDogIndex = sSelectedRacetrackDogInfo.index; if (!(player->stateFlags1 & 0x20) || (play->sceneNum != SCENE_CLOCKTOWER)) { - if (func_8098A1B4(this, play)) { - func_8098A234(this, play); - } else if (this->unk_28C != 8) { - this->unk_28C = 8; - func_80989ADC(this, play); + if (EnDg_ShouldReactToNonHumanPlayer(this, play)) { + EnDg_ChooseActionForForm(this, play); + } else if (this->behavior != DOG_BEHAVIOR_DEFAULT) { + this->behavior = DOG_BEHAVIOR_DEFAULT; + EnDg_SetupIdleMove(this, play); } if ((this->actor.bgCheckFlags & 0x40) && Actor_HasNoParent(&this->actor, play)) { - func_80989140(&this->skelAnime, sAnimations, 15); - this->actionFunc = func_8098B464; + EnDg_ChangeAnimation(&this->skelAnime, sAnimations, DOG_ANIMATION_SWIM); + this->actionFunc = EnDg_SetupSwim; } this->actionFunc(this, play); - func_80989204(this, play); - func_8098933C(this, &sp28); - Math_ApproachF(&this->unk_294.x, sp28.x, 0.2f, 0.1f); - Math_ApproachF(&this->unk_294.z, sp28.z, 0.2f, 0.1f); + EnDg_UpdateCollision(this, play); + EnDg_GetFloorRot(this, &floorRot); + Math_ApproachF(&this->curRot.x, floorRot.x, 0.2f, 0.1f); + Math_ApproachF(&this->curRot.z, floorRot.z, 0.2f, 0.1f); SkelAnime_Update(&this->skelAnime); } } @@ -1185,14 +1368,14 @@ s32 EnDg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po void EnDg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnDg* this = THIS; - Vec3f sp20 = { 0.0f, 20.0f, 0.0f }; + Vec3f sFocusOffset = { 0.0f, 20.0f, 0.0f }; if (limbIndex == DOG_LIMB_HEAD) { - if (this->actionFunc == func_8098BBEC) { - sp20.x = 5000.0f; - Matrix_MultVec3f(&sp20, &this->actor.focus.pos); - } else if (this->actionFunc != func_8098BC54) { - Matrix_MultVec3f(&sp20, &this->actor.focus.pos); + if (this->actionFunc == EnDg_SetupTalk) { + sFocusOffset.x = 5000.0f; + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); + } else if (this->actionFunc != EnDg_Talk) { + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); } } } @@ -1237,8 +1420,8 @@ void EnDg_Draw(Actor* thisx, PlayState* play) { } Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateXFApply(this->unk_294.x); - Matrix_RotateZF(this->unk_294.z, MTXMODE_APPLY); + Matrix_RotateXFApply(this->curRot.x); + Matrix_RotateZF(this->curRot.z, MTXMODE_APPLY); Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.h b/src/overlays/actors/ovl_En_Dg/z_en_dg.h index 43e65b5f8..2b2bdd7cb 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.h +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.h @@ -19,7 +19,28 @@ struct EnDg; typedef void (*EnDgActionFunc)(struct EnDg*, PlayState*); #define ENDG_GET_INDEX(thisx) (((thisx)->params & 0x3E0) >> 5) -#define ENDG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) +#define ENDG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 10) +#define ENDG_PARAMS(path, index) ((path << 10) | (index << 5)) + +typedef enum { + /* 0 */ ENDG_INDEX_RACETRACK_0, + /* 1 */ ENDG_INDEX_RACETRACK_1, + /* 2 */ ENDG_INDEX_RACETRACK_2, + /* 3 */ ENDG_INDEX_RACETRACK_3, + /* 4 */ ENDG_INDEX_RACETRACK_4, + /* 5 */ ENDG_INDEX_RACETRACK_5, + /* 6 */ ENDG_INDEX_RACETRACK_6, + /* 7 */ ENDG_INDEX_RACETRACK_7, + /* 8 */ ENDG_INDEX_RACETRACK_8, + /* 9 */ ENDG_INDEX_RACETRACK_9, + /* 10 */ ENDG_INDEX_RACETRACK_10, + /* 11 */ ENDG_INDEX_RACETRACK_11, + /* 12 */ ENDG_INDEX_RACETRACK_12, + /* 13 */ ENDG_INDEX_RACETRACK_13, + /* 20 */ ENDG_INDEX_ROMANI_RANCH = 20, + /* 21 */ ENDG_INDEX_SWAMP_SPIDER_HOUSE, + /* 31 */ ENDG_INDEX_SOUTH_CLOCK_TOWN = 31 +} EnDgIndex; typedef struct EnDg { /* 0x000 */ Actor actor; @@ -28,20 +49,20 @@ typedef struct EnDg { /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ ColliderCylinder collider; /* 0x1DC */ Path* path; - /* 0x1E0 */ s32 unk_1E0; + /* 0x1E0 */ s32 currentPoint; /* 0x1E4 */ Vec3s jointTable[DOG_LIMB_MAX]; /* 0x232 */ Vec3s morphTable[DOG_LIMB_MAX]; - /* 0x280 */ u16 unk_280; - /* 0x282 */ s16 unk_282; - /* 0x284 */ s16 unk_284; + /* 0x280 */ u16 dogFlags; + /* 0x282 */ s16 timer; + /* 0x284 */ s16 swimTimer; /* 0x286 */ s16 index; /* 0x288 */ s16 selectedDogIndex; - /* 0x28A */ s16 unk_28A; - /* 0x28C */ s16 unk_28C; - /* 0x28E */ s16 unk_28E; - /* 0x290 */ s16 unk_290; - /* 0x292 */ s16 unk_292; - /* 0x294 */ Vec3f unk_294; + /* 0x28A */ s16 sitAfterThrowTimer; + /* 0x28C */ s16 behavior; + /* 0x28E */ s16 attackTimer; + /* 0x290 */ s16 grabState; + /* 0x292 */ s16 bremenBarkTimer; + /* 0x294 */ Vec3f curRot; } EnDg; // size = 0x2A0 extern const ActorInit En_Dg_InitVars; 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 a3c995d18..c9719f613 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -180,7 +180,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 9, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -362,11 +362,11 @@ void func_8089A9B0(EnDinofos* this, PlayState* play) { } void func_8089ABF4(EnDinofos* this, PlayState* play) { - if (this->subCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { Camera* subCam = Play_GetCamera(play, this->subCamId); Play_CameraSetAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye); - this->subCamId = CAM_ID_MAIN; + this->subCamId = SUB_CAM_ID_DONE; ActorCutscene_Stop(this->actor.cutscene); if (this->actor.colChkInfo.health == 0) { func_800B724C(play, &this->actor, 6); @@ -438,7 +438,7 @@ s32 func_8089AE00(EnDinofos* this, PlayState* play) { return true; } - if ((this->actor.xzDistToPlayer < 100.0f) && (player->swordState != 0) && this->actor.isTargeted && + if ((this->actor.xzDistToPlayer < 100.0f) && (player->meleeWeaponState != 0) && this->actor.isTargeted && (Rand_ZeroOne() < 0.5f) && func_8089A968(this) && Player_IsFacingActor(&this->actor, 0x2000, play)) { if (Rand_ZeroOne() < 0.5f) { func_8089C024(this, 2); @@ -467,7 +467,7 @@ void func_8089B100(EnDinofos* this, PlayState* play) { Animation_Change(&this->skelAnime, &object_dinofos_Anim_001CCC, 1.0f, Animation_GetLastFrame(&object_dinofos_Anim_001CCC), - Animation_GetLastFrame(&object_dinofos_Anim_001CCC), 2, 0.0f); + Animation_GetLastFrame(&object_dinofos_Anim_001CCC), ANIMMODE_ONCE, 0.0f); func_800BE33C(&subCam->eye, &subCam->at, &this->unk_29A, true); Math_Vec3f_Diff(&this->actor.world.pos, &player->actor.world.pos, &sp3C); this->unk_2BC.x = player->actor.world.pos.x + (0.4f * sp3C.x); @@ -715,7 +715,7 @@ void func_8089BBB4(EnDinofos* this, PlayState* play) { this->skelAnime.playSpeed = this->actor.speedXZ * 0.166666671634f; } else { Animation_Change(&this->skelAnime, &object_dinofos_Anim_00D62C, this->actor.speedXZ * 0.166666671634f, 0.0f, - 0.0f, 0, -4.0f); + 0.0f, ANIMMODE_LOOP, -4.0f); } this->actor.world.rot.y = BINANG_ADD(this->actor.shape.rot.y, 0x4000); @@ -864,7 +864,7 @@ void func_8089C2A8(EnDinofos* this, PlayState* play) { if ((this->actor.velocity.y < 0.0f) && (this->skelAnime.animation == &object_dinofos_Anim_001CCC)) { this->colliderQuad.base.atFlags |= AT_ON; this->colliderJntSph.base.acFlags |= AC_ON; - Animation_Change(&this->skelAnime, &object_dinofos_Anim_0025B4, 1.0f, 7.0f, 13.0f, 2, -2.0f); + Animation_Change(&this->skelAnime, &object_dinofos_Anim_0025B4, 1.0f, 7.0f, 13.0f, ANIMMODE_ONCE, -2.0f); } if (this->actor.bgCheckFlags & 1) { @@ -935,7 +935,8 @@ void func_8089C56C(EnDinofos* this, PlayState* play) { } void func_8089C690(EnDinofos* this) { - Animation_Change(&this->skelAnime, &object_dinofos_Anim_0025B4, -1.0f, this->skelAnime.curFrame, 0.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &object_dinofos_Anim_0025B4, -1.0f, this->skelAnime.curFrame, 0.0f, + ANIMMODE_ONCE, 0.0f); this->colliderQuad.base.atFlags &= ~(AT_ON | AT_BOUNCED); if (this->actionFunc != func_8089C2A8) { this->actor.world.rot.y = this->actor.shape.rot.y; @@ -1166,8 +1167,8 @@ void func_8089D11C(EnDinofos* this, s16 arg1) { } else { this->actor.speedXZ = 15.0f; } - Animation_Change(&this->skelAnime, &object_dinofos_Anim_00D62C, this->actor.speedXZ * (1.0f / 7.5f), 0.0f, 0.0f, 0, - -4.0f); + Animation_Change(&this->skelAnime, &object_dinofos_Anim_00D62C, this->actor.speedXZ * (1.0f / 7.5f), 0.0f, 0.0f, + ANIMMODE_LOOP, -4.0f); this->actor.world.rot.y = BINANG_ADD(this->actor.shape.rot.y, 0x4000); this->unk_292 = 10; this->unk_2A4 = 0.0f; @@ -1209,7 +1210,7 @@ void func_8089D318(EnDinofos* this, PlayState* play) { } else { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); } - this->subCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); if (this->actor.colChkInfo.health == 0) { subCamEye.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.x; subCamEye.y = this->actor.focus.pos.y; diff --git a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.h b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.h index f0fb5ed76..e26b9a7c0 100644 --- a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.h +++ b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.h @@ -8,9 +8,9 @@ struct EnDnh; typedef void (*EnDnhActionFunc)(struct EnDnh*, PlayState*); typedef struct EnDnh { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnDnhActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x74]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnDnhActionFunc actionFunc; + /* 0x148 */ char unk_148[0x74]; } EnDnh; // size = 0x1BC extern const ActorInit En_Dnh_InitVars; 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 e2e8e4145..646667c05 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -322,7 +322,7 @@ void func_80A71C3C(EnDno* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { play->msgCtx.msgMode = 0; - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80A71E54(this, play); } else if (this->actor.xzDistToPlayer < 60.0f) { func_800B8614(&this->actor, play, 60.0f); @@ -356,7 +356,7 @@ void func_80A71E54(EnDno* this, PlayState* play) { void func_80A71F18(EnDno* this, PlayState* play) { Math_ScaledStepToS(&this->unk_466, 0, 0x16C); switch (Message_GetState(&play->msgCtx)) { - case 0: + case TEXT_STATE_NONE: if (!(this->unk_3B0 & 0x10) || Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xE38)) { switch (this->textId) { @@ -380,7 +380,7 @@ void func_80A71F18(EnDno* this, PlayState* play) { } break; - case 3: + case TEXT_STATE_3: if (play->msgCtx.currentTextId == 0x80B) { switch (this->unk_32C) { case 16: @@ -402,9 +402,9 @@ void func_80A71F18(EnDno* this, PlayState* play) { } break; - case 4: - case 5: - case 6: + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: switch (play->msgCtx.currentTextId) { case 0x80B: switch (this->unk_32C) { @@ -537,7 +537,7 @@ void func_80A725F8(EnDno* this, PlayState* play) { func_80A71424(&this->unk_466, 0, 0, 0, 0x2000, 0x16C); switch (Message_GetState(&play->msgCtx)) { - case 0: + case TEXT_STATE_NONE: switch (this->unk_328) { case 0: if (this->unk_32C == 14) { @@ -569,9 +569,9 @@ void func_80A725F8(EnDno* this, PlayState* play) { } break; - case 1: - case 2: - case 3: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: if (((play->msgCtx.currentTextId == 0x800) || (play->msgCtx.currentTextId == 0x801)) && (this->unk_32C == 8)) { Math_SmoothStepToF(&this->unk_454, 1.0f, 1.0f, 0.1f, 0.01f); @@ -593,9 +593,9 @@ void func_80A725F8(EnDno* this, PlayState* play) { } break; - case 4: - case 5: - case 6: + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: switch (play->msgCtx.currentTextId) { case 0x800: case 0x801: 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 37736acbe..3d084d849 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -296,7 +296,7 @@ void func_80B3D2D4(EnDnp* this, PlayState* play) { void func_80B3D338(EnDnp* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((this->unk_32E != 0) && (Message_GetState(&play->msgCtx) == 2)) { + if ((this->unk_32E != 0) && (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING)) { Actor_MarkForDeath(&this->actor); } else if (this->unk_32E == 0) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { @@ -364,7 +364,7 @@ void EnDnp_Init(Actor* thisx, PlayState* play) { this->actor.world.rot.x = this->actor.shape.rot.x; this->actor.cutscene = 0x10; this->actionFunc = func_80B3D47C; - } else if (((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_0) && !Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && + } else if (((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_0) && !Inventory_HasItemInBottle(ITEM_DEKU_PRINCESS) && !(gSaveContext.save.weekEventReg[23] & 0x20)) || ((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_2) && (gSaveContext.save.weekEventReg[23] & 0x20))) { Actor_SetScale(&this->actor, 0.0085f); 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 f2a6a46dc..36a8b6911 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -342,8 +342,8 @@ void func_80A52DC8(EnDnq* this, PlayState* play) { if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { this->unk_390 = 70.0f; - if (Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && !Play_InCsMode(play) && - (Message_GetState(&play->msgCtx) == 0) && (ActorCutscene_GetCurrentIndex() == -1)) { + if (Inventory_HasItemInBottle(ITEM_DEKU_PRINCESS) && !Play_InCsMode(play) && + (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) && (ActorCutscene_GetCurrentIndex() == -1)) { if ((DECR(this->unk_384) == 0) && (gSaveContext.save.weekEventReg[29] & 0x40)) { Message_StartTextbox(play, 0x969, NULL); this->unk_384 = 200; 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 1284a9523..92dbc1126 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -441,9 +441,9 @@ void func_8092D330(EnDns* this, PlayState* play) { this->unk_2C6 &= ~0x100; play->nextEntranceIndex = 0x5010; gSaveContext.nextCutsceneIndex = 0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } } 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 b0d11ee9c..45311b83f 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -169,7 +169,7 @@ static ColliderJntSphInit sJntSphInit1 = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 10, + ARRAY_COUNT(sJntSphElementsInit1), sJntSphElementsInit1, }; @@ -231,7 +231,7 @@ static ColliderJntSphInit sJntSphInit3 = { OC2_NONE, COLSHAPE_JNTSPH, }, - 3, + ARRAY_COUNT(sJntSphElementsInit2), sJntSphElementsInit2, }; @@ -691,7 +691,7 @@ void func_80877D90(EnDodongo* this, PlayState* play) { } void func_80877DE0(EnDodongo* this) { - Animation_Change(&this->skelAnime, &object_dodongo_Anim_0028F0, -1.0f, 35.0f, 0.0f, 2, -4.0f); + Animation_Change(&this->skelAnime, &object_dodongo_Anim_0028F0, -1.0f, 35.0f, 0.0f, ANIMMODE_ONCE, -4.0f); this->actor.flags |= ACTOR_FLAG_10; this->timer = 25; this->actionFunc = func_80877E60; @@ -957,9 +957,9 @@ void EnDodongo_UpdateDamage(EnDodongo* this, PlayState* play) { Math_Vec3s_ToVec3f(&sp3C, &this->collider2.elements[i].info.bumper.hitPos); if (this->actor.colChkInfo.damageEffect == 0xF) { CollisionCheck_BlueBlood(play, NULL, &sp3C); - EffectSsHitMark_SpawnFixedScale(play, 0, &sp3C); + EffectSsHitmark_SpawnFixedScale(play, 0, &sp3C); } else if (this->actor.colChkInfo.damageEffect != 14) { - EffectSsHitMark_SpawnFixedScale(play, 3, &sp3C); + EffectSsHitmark_SpawnFixedScale(play, 3, &sp3C); CollisionCheck_SpawnShieldParticlesMetalSound(play, &sp3C, &this->actor.projectedPos); } } diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index e938706f0..d9bc5cee1 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -489,7 +489,7 @@ void func_80866B20(EnDoor* this, PlayState* play) { } else if (this->unk_1A7 != 0) { this->actionFunc = func_80866F94; Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_OPEN); - } else if (!Player_InCsMode(&play->state)) { + } else if (!Player_InCsMode(play)) { Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &playerPosRelToDoor, &player->actor.world.pos); if ((D_80867BC0[0] != 0) || ((fabsf(playerPosRelToDoor.y) < 20.0f) && (fabsf(playerPosRelToDoor.x) < 20.0f) && (fabsf(playerPosRelToDoor.z) < 50.0f))) { @@ -532,7 +532,7 @@ void func_80866B20(EnDoor* this, PlayState* play) { this->dyna.actor.textId = baseTextId + textIdOffset; } } else if ((this->unk_1A4 == 5) && (playerPosRelToDoor.z > 0.0f)) { - ScheduleResult sp30; + ScheduleOutput sp30; if (Schedule_RunScript(play, D_8086778C[this->switchFlag], &sp30) != 0) { this->dyna.actor.textId = sp30.result + 0x1800; diff --git a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h index cfbbbbd58..18d525f44 100644 --- a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h +++ b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h @@ -8,9 +8,9 @@ struct EnDoorEtc; typedef void (*EnDoorEtcActionFunc)(struct EnDoorEtc*, PlayState*); typedef struct EnDoorEtc { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xB4]; - /* 0x01F8 */ EnDoorEtcActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0xB4]; + /* 0x1F8 */ EnDoorEtcActionFunc actionFunc; } EnDoorEtc; // size = 0x1FC extern const ActorInit En_Door_Etc_InitVars; diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c index 7b703c0f5..ece3c0903 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -445,11 +445,11 @@ void EnDragon_Extend(EnDragon* this, PlayState* play) { } } -void EnDragon_CameraSetAtEye(EnDragon* this, PlayState* play, Vec3f eye, Vec3f at) { - this->cameraId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); - Math_Vec3f_Copy(&this->cameraEye, &eye); - Math_Vec3f_Copy(&this->cameraAt, &at); - Play_CameraSetAtEye(play, this->cameraId, &this->cameraAt, &this->cameraEye); +void EnDragon_SetSubCamEyeAt(EnDragon* this, PlayState* play, Vec3f subCamEye, Vec3f subCamAt) { + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + Math_Vec3f_Copy(&this->subCamEye, &subCamEye); + Math_Vec3f_Copy(&this->subCamAt, &subCamAt); + Play_CameraSetAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); } void EnDragon_SetupGrab(EnDragon* this, PlayState* play) { @@ -476,12 +476,12 @@ void EnDragon_SetupGrab(EnDragon* this, PlayState* play) { } } -static Vec3f sCameraEyePerPython[] = { +static Vec3f sSubCamEyePerPython[] = { { 1600.0f, 0.0f, 1400.0f }, { 1400.0f, 0.0f, 400.0f }, { 1800.0f, 0.0f, 1400.f }, { 1100.0f, -200.0f, 1500.0f }, { 2000.0f, 0.0f, 1500.0f }, { 1900.0f, 0.0f, 1800.0f }, { 1700.0f, 0.0f, 1100.0f }, { 1700.0f, 0.0f, 1100.0f }, }; -static Vec3f sCameraAtPerPython[] = { +static Vec3f sSubCamAtPerPython[] = { { 300.0f, -100.0f, 1300.0f }, { 1500.0f, 0.0f, 2400.0f }, { 300.0f, -100.0f, 1300.0f }, { 1900.0f, 500.0f, 600.0f }, { -1000.0f, 0.0f, 1000.0f }, { 1200.0f, 0.0f, 1500.0f }, { 1100.0f, 0.0f, 2000.0f }, { 1100.0f, 0.0f, 2000.0f }, }; @@ -492,10 +492,10 @@ static s32 sMaxGrabTimerPerPython[] = { 5, 5, 5, 4, 5, 8, 5, 5 }; void EnDragon_Grab(EnDragon* this, PlayState* play) { Player* player = GET_PLAYER(play); - Vec3f sp50; // used as both the extended position and the camera eye - Vec3f at; + Vec3f pos; // used as both the extended position and the camera eye + Vec3f subCamAt; - this->cameraId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); SkelAnime_Update(&this->skelAnime); if (this->grabTimer == 0) { @@ -507,10 +507,10 @@ void EnDragon_Grab(EnDragon* this, PlayState* play) { Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPositionTemp); } - Math_Vec3f_Copy(&sp50, &this->burrowEntrancePos); - sp50.x += Math_SinS(this->actor.world.rot.y) * -930.0f; - sp50.z += Math_CosS(this->actor.world.rot.y) * -930.0f; - Math_Vec3f_Copy(&this->actor.world.pos, &sp50); + Math_Vec3f_Copy(&pos, &this->burrowEntrancePos); + pos.x += Math_SinS(this->actor.world.rot.y) * -930.0f; + pos.z += Math_CosS(this->actor.world.rot.y) * -930.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &pos); this->jawZRotation = 0x1450; this->actor.speedXZ = 60.0f; } @@ -519,17 +519,18 @@ void EnDragon_Grab(EnDragon* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.z, sZRotPerPython[this->pythonIndex], 0xA, 0x1F4, 0x14); EnDragon_SpawnBubbles(this, play, this->jawPos); - Math_Vec3f_Copy(&sp50, &this->burrowEntrancePos); - sp50.x += Math_SinS(this->actor.world.rot.y) * sCameraEyePerPython[this->pythonIndex].x; - sp50.y += sCameraEyePerPython[this->pythonIndex].y; - sp50.z += Math_CosS(this->actor.world.rot.y) * sCameraEyePerPython[this->pythonIndex].z; + Math_Vec3f_Copy(&pos, &this->burrowEntrancePos); - Math_Vec3f_Copy(&at, &this->actor.world.pos); - at.x += Math_SinS(this->actor.world.rot.y) * sCameraAtPerPython[this->pythonIndex].x; - at.y += sCameraAtPerPython[this->pythonIndex].y; - at.z += Math_CosS(this->actor.world.rot.y) * sCameraAtPerPython[this->pythonIndex].z; + pos.x += Math_SinS(this->actor.world.rot.y) * sSubCamEyePerPython[this->pythonIndex].x; + pos.y += sSubCamEyePerPython[this->pythonIndex].y; + pos.z += Math_CosS(this->actor.world.rot.y) * sSubCamEyePerPython[this->pythonIndex].z; - EnDragon_CameraSetAtEye(this, play, sp50, at); + Math_Vec3f_Copy(&subCamAt, &this->actor.world.pos); + subCamAt.x += Math_SinS(this->actor.world.rot.y) * sSubCamAtPerPython[this->pythonIndex].x; + subCamAt.y += sSubCamAtPerPython[this->pythonIndex].y; + subCamAt.z += Math_CosS(this->actor.world.rot.y) * sSubCamAtPerPython[this->pythonIndex].z; + + EnDragon_SetSubCamEyeAt(this, play, pos, subCamAt); if (this->grabTimer > sMaxGrabTimerPerPython[this->pythonIndex]) { if (this->state == DEEP_PYTHON_GRAB_STATE_START) { @@ -560,8 +561,8 @@ void EnDragon_SetupAttack(EnDragon* this) { void EnDragon_Attack(EnDragon* this, PlayState* play) { Player* player = GET_PLAYER(play); f32 currentFrame = this->skelAnime.curFrame; - Vec3f sp4C; // used as both the extended position and the camera eye - Vec3f at; + Vec3f pos; // used as both the extended position and the camera eye + Vec3f subCamAt; SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->actor.shape.rot.z, 0, 0xA, 0x1388, 0); @@ -575,17 +576,17 @@ void EnDragon_Attack(EnDragon* this, PlayState* play) { CollisionCheck_GreenBlood(play, NULL, &player->actor.world.pos); } - Math_Vec3f_Copy(&sp4C, &this->actor.world.pos); - sp4C.x += Math_SinS(this->actor.world.rot.y) * 3000.0f; - sp4C.y += 600.0f; - sp4C.z += Math_CosS(this->actor.world.rot.y) * 3000.0f; + Math_Vec3f_Copy(&pos, &this->actor.world.pos); + pos.x += Math_SinS(this->actor.world.rot.y) * 3000.0f; + pos.y += 600.0f; + pos.z += Math_CosS(this->actor.world.rot.y) * 3000.0f; - Math_Vec3f_Copy(&at, &this->actor.world.pos); - at.x += Math_SinS(this->actor.world.rot.y) * 1200.0f; - at.y += -100.0f; - at.z += Math_CosS(this->actor.world.rot.y) * 1200.0f; + Math_Vec3f_Copy(&subCamAt, &this->actor.world.pos); + subCamAt.x += Math_SinS(this->actor.world.rot.y) * 1200.0f; + subCamAt.y += -100.0f; + subCamAt.z += Math_CosS(this->actor.world.rot.y) * 1200.0f; - EnDragon_CameraSetAtEye(this, play, sp4C, at); + EnDragon_SetSubCamEyeAt(this, play, pos, subCamAt); player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y; player->actor.world.rot.x = player->actor.shape.rot.x = this->actor.world.rot.x; @@ -593,12 +594,12 @@ void EnDragon_Attack(EnDragon* this, PlayState* play) { Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPosition); this->jawZRotation = 0xC8; - Math_Vec3f_Copy(&sp4C, &this->burrowEntrancePos); - sp4C.x += Math_SinS(this->actor.world.rot.y) * -530.0f; - sp4C.z += Math_CosS(this->actor.world.rot.y) * -530.0f; - Math_ApproachF(&this->actor.world.pos.x, sp4C.x, 0.3f, 200.0f); - Math_ApproachF(&this->actor.world.pos.y, sp4C.y, 0.3f, 200.0f); - Math_ApproachF(&this->actor.world.pos.z, sp4C.z, 0.3f, 200.0f); + Math_Vec3f_Copy(&pos, &this->burrowEntrancePos); + pos.x += Math_SinS(this->actor.world.rot.y) * -530.0f; + pos.z += Math_CosS(this->actor.world.rot.y) * -530.0f; + Math_ApproachF(&this->actor.world.pos.x, pos.x, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.y, pos.y, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.z, pos.z, 0.3f, 200.0f); if ((this->state <= DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BITE); diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h index 1e6a0aa3c..b12c63dd0 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h @@ -31,8 +31,8 @@ typedef struct EnDragon { /* 0x254 */ Vec3f jawPos; /* 0x260 */ Vec3f burrowEntrancePos; // Vertically and horizontally centered on the burrow opening. Set by Bg_Sinkai_Kabe /* 0x26C */ Vec3f playerGrabPosition; - /* 0x278 */ Vec3f cameraEye; - /* 0x278 */ Vec3f cameraAt; + /* 0x278 */ Vec3f subCamEye; + /* 0x278 */ Vec3f subCamAt; /* 0x290 */ Vec3f playerGrabPositionTemp; /* 0x29C */ Vec3f focusPos; /* 0x2A8 */ s16 jawZRotation; @@ -50,7 +50,7 @@ typedef struct EnDragon { /* 0x2C0 */ s16 grabCutsceneIndex; /* 0x2C2 */ s16 deathCutsceneIndex; /* 0x2C4 */ UNK_TYPE1 unk_2C4[0x4]; - /* 0x2C8 */ s16 cameraId; + /* 0x2C8 */ s16 subCamId; /* 0x2CA */ s16 grabTimer; // Counts up from the time a grab starts until the time the actor begins attacking /* 0x2CC */ s16 unk_2CC; // Initialized, but never used /* 0x2CE */ UNK_TYPE1 unk_2CE[0x2]; diff --git a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c index 7f05e9e50..0d274c0e4 100644 --- a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c +++ b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c @@ -2,6 +2,9 @@ * File: z_en_ds2n.c * Overlay: ovl_En_Ds2n * Description: Potion Shop Owner from OoT (unused) + * + * This actor was placed in the Staff Office of Stockpot inn + * but does not spawn because their object is missing. */ #include "z_en_ds2n.h" @@ -15,7 +18,8 @@ void EnDs2n_Destroy(Actor* thisx, PlayState* play); void EnDs2n_Update(Actor* thisx, PlayState* play); void EnDs2n_Draw(Actor* thisx, PlayState* play); -#if 0 +void EnDs2n_Idle(EnDs2n* this, PlayState* play); + const ActorInit En_Ds2n_InitVars = { ACTOR_EN_DS2N, ACTORCAT_NPC, @@ -28,24 +32,102 @@ const ActorInit En_Ds2n_InitVars = { (ActorFunc)EnDs2n_Draw, }; -#endif +static AnimationInfo sAnimations[] = { + { &gDs2nIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, +}; -extern UNK_TYPE D_06008038; +static Vec3f sZeroVec = { 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE1650.s") +static TexturePtr sEyeTextures[] = { gDs2nEyeOpenTex, gDs2nEyeHalfTex, gDs2nEyeClosedTex }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE16A0.s") +void EnDs2n_SetupIdle(EnDs2n* this) { + this->blinkTimer = 20; + this->blinkState = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = EnDs2n_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE16D8.s") +void EnDs2n_Idle(EnDs2n* this, PlayState* play) { + SubS_FillLimbRotTables(play, this->limbRotTableY, this->limbRotTableZ, DS2N_LIMB_MAX); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/EnDs2n_Init.s") +void EnDs2n_UpdateEyes(EnDs2n* this) { + s16 nextBlinkTime = this->blinkTimer - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/EnDs2n_Destroy.s") + if (nextBlinkTime >= 3) { + this->blinkState = 0; + this->blinkTimer = nextBlinkTime; + } else if (nextBlinkTime == 0) { + this->blinkState = 2; + this->blinkTimer = (s32)(Rand_ZeroOne() * 60.0f) + 20; + } else { + this->blinkState = 1; + this->blinkTimer = nextBlinkTime; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/EnDs2n_Update.s") +void EnDs2n_Init(Actor* thisx, PlayState* play) { + EnDs2n* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE1874.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gDs2nSkeleton, &gDs2nIdleAnim, NULL, NULL, 0); + EnDs2n_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE18B4.s") +void EnDs2n_Destroy(Actor* thisx, PlayState* play) { + EnDs2n* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/EnDs2n_Draw.s") + SkelAnime_Free(&this->skelAnime, play); +} + +void EnDs2n_Update(Actor* thisx, PlayState* play) { + EnDs2n* this = THIS; + + this->actionFunc(this, play); + Actor_MoveWithGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->chestRot, this->actor.focus.pos); + EnDs2n_UpdateEyes(this); +} + +s32 EnDs2n_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnDs2n* this = THIS; + + if (limbIndex == DS2N_LIMB_HEAD) { + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); + } + + return false; +} + +void EnDs2n_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnDs2n* this = THIS; + Vec3f focusOffset = sZeroVec; + + if ((limbIndex == DS2N_LIMB_HIPS) || (limbIndex == DS2N_LIMB_LEFT_UPPER_ARM) || + (limbIndex == DS2N_LIMB_RIGHT_UPPER_ARM)) { + rot->y += (s16)Math_SinS(this->limbRotTableY[limbIndex]) * 0xC8; + rot->z += (s16)Math_CosS(this->limbRotTableZ[limbIndex]) * 0xC8; + } + + if (limbIndex == DS2N_LIMB_HEAD) { + Matrix_MultVec3f(&focusOffset, &thisx->focus.pos); + } +} + +void EnDs2n_Draw(Actor* thisx, PlayState* play) { + EnDs2n* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C5B0(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->blinkState])); + + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->blinkState])); + + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnDs2n_OverrideLimbDraw, EnDs2n_PostLimbDraw, &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h index e182edfd1..c7155ed74 100644 --- a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h +++ b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h @@ -2,16 +2,24 @@ #define Z_EN_DS2N_H #include "global.h" +#include "objects/object_ds2n/object_ds2n.h" struct EnDs2n; typedef void (*EnDs2nActionFunc)(struct EnDs2n*, PlayState*); typedef struct EnDs2n { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; - /* 0x01D4 */ EnDs2nActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x5C]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; // unused + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnDs2nActionFunc actionFunc; + /* 0x1D8 */ s16 limbRotTableY[DS2N_LIMB_MAX]; + /* 0x1FE */ s16 limbRotTableZ[DS2N_LIMB_MAX]; + /* 0x224 */ Vec3s headRot; + /* 0x22A */ Vec3s chestRot; // set by function, but not applied in limbdraw + /* 0x230 */ s16 blinkState; + /* 0x232 */ s16 blinkTimer; + } EnDs2n; // size = 0x234 extern const ActorInit En_Ds2n_InitVars; diff --git a/src/overlays/actors/ovl_En_Dt/z_en_dt.h b/src/overlays/actors/ovl_En_Dt/z_en_dt.h index 2fbd228e6..78b098789 100644 --- a/src/overlays/actors/ovl_En_Dt/z_en_dt.h +++ b/src/overlays/actors/ovl_En_Dt/z_en_dt.h @@ -8,10 +8,10 @@ struct EnDt; typedef void (*EnDtActionFunc)(struct EnDt*, PlayState*); typedef struct EnDt { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xF8]; - /* 0x023C */ EnDtActionFunc actionFunc; - /* 0x0240 */ char unk_240[0xA0]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0xF8]; + /* 0x23C */ EnDtActionFunc actionFunc; + /* 0x240 */ char unk_240[0xA0]; } EnDt; // size = 0x2E0 extern const ActorInit En_Dt_InitVars; diff --git a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.h b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.h index 812774938..d1222a5eb 100644 --- a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.h +++ b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.h @@ -8,10 +8,10 @@ struct EnEgblock; typedef void (*EnEgblockActionFunc)(struct EnEgblock*, PlayState*); typedef struct EnEgblock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; - /* 0x01A0 */ EnEgblockActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0xC10]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x5C]; + /* 0x1A0 */ EnEgblockActionFunc actionFunc; + /* 0x1A4 */ char unk_1A4[0xC10]; } EnEgblock; // size = 0xDB4 extern const ActorInit En_Egblock_InitVars; diff --git a/src/overlays/actors/ovl_En_Egol/z_en_egol.c b/src/overlays/actors/ovl_En_Egol/z_en_egol.c index 8952e118b..373d06583 100644 --- a/src/overlays/actors/ovl_En_Egol/z_en_egol.c +++ b/src/overlays/actors/ovl_En_Egol/z_en_egol.c @@ -47,7 +47,7 @@ static ColliderJntSphElementInit D_80A80C64[6] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A80D3C = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 6, D_80A80C64, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A80C64, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -61,7 +61,7 @@ static ColliderJntSphElementInit D_80A80C40[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A80D4C = { { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A80C40, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A80C40, // sJntSphElementsInit, }; // static ColliderQuadInit sQuadInit = { 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 7d53c4fc2..795b2cb9e 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -662,7 +662,7 @@ void func_8088DD34(EnElf* this, PlayState* play) { return; } - if (Player_InCsMode(&play->state)) { + if (Player_InCsMode(play)) { if ((this->fairyFlags & 0x4000) && (this->fairyFlags & 0x100) && func_8088DCA4(this)) { return; } @@ -673,7 +673,7 @@ void func_8088DD34(EnElf* this, PlayState* play) { if ((this->fairyFlags & 0x1000) && (heightDiff > 0.0f) && (heightDiff < 60.0f) && !func_8088C804(&this->actor.world.pos, &refActor->actor.world.pos, 10.0f)) { - func_80115908(play, 0x80); + Health_ChangeBy(play, 0x80); if (this->fairyFlags & 0x200) { Parameter_AddMagic(play, ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); @@ -1359,7 +1359,7 @@ void func_8088FE64(Actor* thisx, PlayState* play2) { func_8088FA38(this, play); switch (Message_GetState(&play->msgCtx)) { - case 4: + case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(play)) { if (play->msgCtx.currentTextId == 0x202) { switch (play->msgCtx.choiceIndex) { @@ -1385,10 +1385,10 @@ void func_8088FE64(Actor* thisx, PlayState* play2) { } break; - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { - case 576: + case 0x240: func_80151938(play, 0x245); break; @@ -1434,7 +1434,7 @@ void func_8088FE64(Actor* thisx, PlayState* play2) { } break; - case 2: + case TEXT_STATE_CLOSING: func_8088FDCC(this); break; } @@ -1555,7 +1555,7 @@ s32 EnElf_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p if (this->fairyFlags & 0x200) { scale *= 2.0f; } - scale *= this->actor.scale.x * 124.99999f; + scale *= this->actor.scale.x * (1.0f / 0.008f); Matrix_MultVec3f(&zeroVec, &sp34); Matrix_Translate(sp34.x, sp34.y, sp34.z, MTXMODE_NEW); 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 0f8646dc6..2ee080fa3 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.h +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.h @@ -12,41 +12,41 @@ typedef void (*EnElfUnkFunc)(struct EnElf*, PlayState*); #define ENELF_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) typedef struct EnElf { - /* 0x0000 */ Actor actor; - /* 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; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[7]; + /* 0x1B2 */ Vec3s morphTable[7]; + /* 0x1DC */ Color_RGBAf innerColor; + /* 0x1EC */ Color_RGBAf outerColor; + /* 0x1FC */ LightInfo lightInfoGlow; + /* 0x20C */ LightNode* lightNodeGlow; + /* 0x210 */ LightInfo lightInfoNoGlow; + /* 0x220 */ LightNode* lightNodeNoGlow; + /* 0x224 */ Vec3f unk_224; + /* 0x230 */ Actor* elfMsg; + /* 0x234 */ Actor* unk_234; + /* 0x238 */ f32 unk_238; + /* 0x23C */ f32 unk_23C; + /* 0x240 */ f32 unk_240; + /* 0x244 */ s16 unk_244; + /* 0x246 */ s16 unk_246; + /* 0x248 */ s16 unk_248; + /* 0x24A */ s16 unk_24A; + /* 0x24C */ s16 unk_24C; + /* 0x250 */ f32 unk_250; + /* 0x254 */ f32 unk_254; + /* 0x258 */ s16 unk_258; + /* 0x25A */ u16 timer; + /* 0x25C */ s16 unk_25C; + /* 0x25E */ s16 disappearTimer; + /* 0x260 */ s16 unk_260; + /* 0x262 */ u16 fairyFlags; + /* 0x264 */ u16 unk_264; + /* 0x266 */ u16 unk_266; + /* 0x268 */ u8 unk_268; + /* 0x269 */ u8 unk_269; + /* 0x26C */ EnElfUnkFunc unk_26C; + /* 0x270 */ EnElfActionFunc actionFunc; } EnElf; // size = 0x274 extern const ActorInit En_Elf_InitVars; diff --git a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.h b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.h index 46862f2c6..cab77c8a4 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.h +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.h @@ -10,15 +10,15 @@ struct EnElfbub; typedef void (*EnElfbubActionFunc)(struct EnElfbub*, PlayState*); typedef struct EnElfbub { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ s16 zRot; - /* 0x0192 */ s16 zRotDelta; - /* 0x0194 */ s16 oscillationAngle; - /* 0x0196 */ s16 popTimer; - /* 0x0198 */ f32 xScale; - /* 0x019C */ f32 xyScale; - /* 0x01A0 */ EnElfbubActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ s16 zRot; + /* 0x192 */ s16 zRotDelta; + /* 0x194 */ s16 oscillationAngle; + /* 0x196 */ s16 popTimer; + /* 0x198 */ f32 xScale; + /* 0x19C */ f32 xyScale; + /* 0x1A0 */ EnElfbubActionFunc actionFunc; } EnElfbub; // size = 0x1A4 extern const ActorInit En_Elfbub_InitVars; diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h index bb3a86a40..8536b806e 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h @@ -19,13 +19,13 @@ enum { }; typedef struct EnElfgrp { - /* 0x0000 */ Actor actor; - /* 0x0144 */ s16 unk_144; - /* 0x0146 */ u8 unk_146; - /* 0x0147 */ u8 unk_147; - /* 0x0148 */ s8 unk_148; - /* 0x014A */ u16 unk_14A; - /* 0x014C */ EnElfgrpActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 unk_144; + /* 0x146 */ u8 unk_146; + /* 0x147 */ u8 unk_147; + /* 0x148 */ s8 unk_148; + /* 0x14A */ u16 unk_14A; + /* 0x14C */ EnElfgrpActionFunc actionFunc; } EnElfgrp; // size = 0x150 extern const ActorInit En_Elfgrp_InitVars; 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 005a53975..915eb1d6c 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -105,11 +105,11 @@ void EnElforg_Init(Actor* thisx, PlayState* play) { break; } - if (func_8010A074(play)) { - this->area = gSaveContext.unk_48C8 + 1; + if (Map_IsInDungeonOrBossArea(play)) { + this->area = gSaveContext.dungeonIndex + STRAY_FAIRY_AREA_WOODFALL; } else { // Needs to be thisx in order to match - this->area = STRAY_FAIRY_GET_PARAM_1C0(thisx) >> 6; + this->area = STRAY_FAIRY_GET_NON_DUNGEON_AREA(thisx); } switch (STRAY_FAIRY_TYPE(&this->actor)) { @@ -437,10 +437,10 @@ void EnElforg_FreeFloating(EnElforg* this, PlayState* play) { } scaledYDistance = this->actor.playerHeightRel - (this->actor.shape.yOffset * this->actor.scale.y); - if (!Player_InCsMode(&play->state)) { + if (!Player_InCsMode(play)) { if ((this->actor.xzDistToPlayer < 30.0f) && (scaledYDistance < 12.0f) && (scaledYDistance > -68.0f)) { EnElforg_SetupFairyCollected(this, play); - func_80115908(play, 48); + Health_ChangeBy(play, 0x30); switch (STRAY_FAIRY_TYPE(&this->actor)) { case STRAY_FAIRY_TYPE_COLLECTIBLE: Flags_SetCollectible(play, STRAY_FAIRY_FLAG(&this->actor)); @@ -462,10 +462,10 @@ void EnElforg_FreeFloating(EnElforg* this, PlayState* play) { return; } - if (func_8010A074(play)) { - gSaveContext.save.inventory.strayFairies[gSaveContext.unk_48C8]++; + if (Map_IsInDungeonOrBossArea(play)) { + gSaveContext.save.inventory.strayFairies[gSaveContext.dungeonIndex]++; Message_StartTextbox(play, 0x11, NULL); - if (gSaveContext.save.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { + if (gSaveContext.save.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex] >= 15) { func_801A3098(NA_BGM_GET_ITEM | 0x900); } } 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 5e46e7581..55695240f 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h @@ -4,7 +4,7 @@ #include "global.h" #define STRAY_FAIRY_TYPE(thisx) ((thisx)->params & 0xF) -#define STRAY_FAIRY_GET_PARAM_1C0(thisx) ((thisx)->params & 0x1C0) +#define STRAY_FAIRY_GET_NON_DUNGEON_AREA(thisx) (((thisx)->params & 0x1C0) >> 6) #define STRAY_FAIRY_FLAG(thisx) (((thisx)->params & 0xFE00) >> 9) #define STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME (1 << 0) diff --git a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h index f9e1e9647..d625f2151 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h @@ -8,13 +8,13 @@ struct EnEncount1; typedef void (*EnEncount1ActionFunc)(struct EnEncount1*, PlayState*); typedef struct EnEncount1 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnEncount1ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x6]; - /* 0x014E */ s16 unk_14E; - /* 0x0150 */ char unk_150[0xA]; - /* 0x015A */ s16 unk_15A; - /* 0x015C */ char unk_15C[0x8]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnEncount1ActionFunc actionFunc; + /* 0x148 */ char unk_148[0x6]; + /* 0x14E */ s16 unk_14E; + /* 0x150 */ char unk_150[0xA]; + /* 0x15A */ s16 unk_15A; + /* 0x15C */ char unk_15C[0x8]; } EnEncount1; // size = 0x164 extern const ActorInit En_Encount1_InitVars; diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index 7887c4378..d7c0cc561 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -60,7 +60,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -283,7 +283,7 @@ void EnEncount2_DrawEffects(EnEncount2* this, PlayState* play) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, sPtr->alpha); Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZF(DEGTORAD(play->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(play->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); } diff --git a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.h b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.h index 81391df30..2b0bb59d8 100644 --- a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.h +++ b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.h @@ -8,9 +8,9 @@ struct EnEncount3; typedef void (*EnEncount3ActionFunc)(struct EnEncount3*, PlayState*); typedef struct EnEncount3 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnEncount3ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x84]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnEncount3ActionFunc actionFunc; + /* 0x148 */ char unk_148[0x84]; } EnEncount3; // size = 0x1CC extern const ActorInit En_Encount3_InitVars; diff --git a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h index a2b50e085..499da9663 100644 --- a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h +++ b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h @@ -13,7 +13,8 @@ typedef struct EnEncount4 { /* 0x0148 */ char unk_148[0x4]; /* 0x014C */ s16 unk_14C; /* 0x014E */ s16 unk_14E; - /* 0x0150 */ char unk_150[0x8]; + /* 0x0150 */ s16 unk_150; + /* 0x0152 */ char unk_152[0x6]; } EnEncount4; // size = 0x158 extern const ActorInit En_Encount4_InitVars; 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 95e9c362b..e22603b4e 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 @@ -69,7 +69,7 @@ void EnEndingHero6_Destroy(Actor* thisx, PlayState* play) { void EnEndingHero6_InitSkelAnime(EnEndingHero6* this, s32 npcIndex) { this->animIndex = npcIndex; this->frameCount = Animation_GetLastFrame(sAnimations[npcIndex]); - Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.f, this->frameCount, 0, 0.0f); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.f, this->frameCount, ANIMMODE_LOOP, 0.0f); } void EnEndingHero6_SetupIdle(EnEndingHero6* this) { diff --git a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.h b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.h index 6f00783d5..f30d09a7a 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.h +++ b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.h @@ -8,19 +8,19 @@ struct EnEndingHero6; typedef void (*EnEndingHero6ActionFunc)(struct EnEndingHero6*, PlayState*); typedef struct EnEndingHero6 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[20]; - /* 0x0200 */ Vec3s morphTable[20]; - /* 0x0278 */ EnEndingHero6ActionFunc actionFunc; - /* 0x027C */ s32 animIndex; - /* 0x0280 */ s32 npcIndex; - /* 0x0284 */ s8 objectIndex; - /* 0x0286 */ s16 timer; - /* 0x0288 */ s16 blinkTimer; - /* 0x028A */ s16 eyeState; - /* 0x028C */ f32 frameCount; - /* 0x0290 */ s16 isIdle; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[20]; + /* 0x200 */ Vec3s morphTable[20]; + /* 0x278 */ EnEndingHero6ActionFunc actionFunc; + /* 0x27C */ s32 animIndex; + /* 0x280 */ s32 npcIndex; + /* 0x284 */ s8 objectIndex; + /* 0x286 */ s16 timer; + /* 0x288 */ s16 blinkTimer; + /* 0x28A */ s16 eyeState; + /* 0x28C */ f32 frameCount; + /* 0x290 */ s16 isIdle; } EnEndingHero6; // size = 0x294 extern const ActorInit En_Ending_Hero6_InitVars; 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 9f07dc339..646d8b08c 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -343,9 +343,9 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, PlayState* play) { } else if (play->csCtx.frames > 1600) { play->nextEntranceIndex = 0x2C00; gSaveContext.nextCutsceneIndex = 0xFFF2; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 2; - gSaveContext.nextTransition = 2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_02; sGiantsCutsceneState = 9; } break; diff --git a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c index dac233f96..58ab4e591 100644 --- a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c +++ b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c @@ -15,7 +15,12 @@ void EnFall2_Destroy(Actor* thisx, PlayState* play); void EnFall2_Update(Actor* thisx, PlayState* play); void EnFall2_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_80C1B724(f32 arg0); +void EnFall2_DoNothing(EnFall2* this, PlayState* play); +void func_80C1B9D4(EnFall2* this, PlayState* play); +void func_80C1B8F0(EnFall2* this); +void func_80C1B9D4(EnFall2* this, PlayState* play); + const ActorInit En_Fall2_InitVars = { ACTOR_EN_FALL2, ACTORCAT_ITEMACTION, @@ -28,26 +33,137 @@ const ActorInit En_Fall2_InitVars = { (ActorFunc)EnFall2_Draw, }; -#endif +void EnFall2_Init(Actor* thisx, PlayState* play) { + EnFall2* this = THIS; -extern UNK_TYPE D_06005EF4; -extern UNK_TYPE D_06005F10; -extern UNK_TYPE D_06008840; + Actor_SetScale(&this->actor, 1.0f); + this->actionFunc = EnFall2_DoNothing; + func_80183430(&this->skeletonInfo, object_fall2_Blob_008898, object_fall2_Blob_005EF4, this->unk174, this->unk228, + NULL); + func_801835EC(&this->skeletonInfo, object_fall2_Blob_005EF4); + this->unk2DC = Lib_SegmentedToVirtual(object_fall2_Matanimheader_008840); + Actor_SetScale(&this->actor, 0.02f); + this->actionFunc = func_80C1B9D4; + this->csActionIndex = 0x231; + this->alphaLevel = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/EnFall2_Init.s") +void EnFall2_Destroy(Actor* thisx, PlayState* play) { + EnFall2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/EnFall2_Destroy.s") + func_8018349C(&this->skeletonInfo); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/func_80C1B724.s") +u8 sAlphaTableIndices[] = { + 0, 2, 0, 0, 4, 0, 4, 4, 2, 0, 0, 0, 0, 0, 0, 2, 4, 4, 4, 2, 0, 4, 2, 2, 0, 4, 4, 4, 4, 0, 2, 2, 4, 0, 2, + 0, 4, 4, 2, 0, 2, 4, 4, 4, 2, 0, 4, 4, 4, 2, 2, 0, 4, 4, 2, 4, 0, 2, 0, 0, 2, 4, 4, 2, 0, 2, 4, 4, 4, 2, + 0, 4, 4, 4, 4, 4, 2, 2, 0, 2, 4, 0, 2, 0, 0, 2, 4, 4, 2, 0, 2, 4, 4, 4, 2, 0, 0, 2, 2, 4, 4, 4, 4, 4, 4, + 2, 0, 2, 0, 0, 2, 4, 4, 2, 0, 2, 4, 4, 4, 2, 0, 2, 0, 5, 2, 5, 5, 5, 5, 0, 2, 5, 0, 2, 0, 2, 5, 5, 2, 0, + 2, 5, 5, 5, 2, 0, 3, 3, 3, 2, 2, 0, 0, 3, 3, 0, 2, 2, 3, 0, 2, 3, 3, 2, 0, 2, 3, 3, 3, 2, 0, 2, 2, 2, 2, + 0, 2, 2, 2, 2, 2, 0, 0, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/func_80C1B8A4.s") +void func_80C1B724(f32 arg0) { + Vtx* vertex = Lib_SegmentedToVirtual(object_fall2_Vtx_005F10); + u8 perVertexAlphaTable[6]; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/func_80C1B8B4.s") + if (arg0 > 1.0f) { + arg0 = 1.0f; + } + if (arg0 < 0.0f) { + arg0 = 0.0f; + } + perVertexAlphaTable[0] = 0; + perVertexAlphaTable[1] = (s8)(54.0f * arg0); + perVertexAlphaTable[2] = (s8)(104.0f * arg0); + perVertexAlphaTable[3] = (s8)(155.0f * arg0); + perVertexAlphaTable[4] = (s8)(255.0f * arg0); + perVertexAlphaTable[5] = (s8)(205.0f * arg0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/func_80C1B8F0.s") + for (i = 0; i < ARRAY_COUNT(sAlphaTableIndices); i++, vertex++) { + vertex->v.cn[3] = perVertexAlphaTable[sAlphaTableIndices[i]]; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/func_80C1B9D4.s") +void EnFall2_DoNothing(EnFall2* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/EnFall2_Update.s") +void func_80C1B8B4(EnFall2* this) { + this->actor.draw = EnFall2_Draw; + if (this->csActorAction == 1) { + Actor_SetScale(&this->actor, 0.02f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fall2/EnFall2_Draw.s") +void func_80C1B8F0(EnFall2* this) { + switch (this->csActorAction) { + case 1: + if (this->alphaLevel < 1.0f) { + this->alphaLevel += 1.0f / 30.0f; + } else { + this->alphaLevel = 1.0f; + } + break; + case 2: + if (this->alphaLevel > 0.0f) { + this->alphaLevel -= 0.1f; + if (this->alphaLevel < 0.0f) { + this->alphaLevel = 0.0f; + } + } + if (this->actor.scale.x > 0.0f) { + this->actor.scale.x -= 20.0f * 0.0001f; + if (this->actor.scale.x < 0.0f) { + this->actor.scale.x = 0.0f; + } + this->actor.scale.z = this->actor.scale.x; + } + } +} + +void func_80C1B9D4(EnFall2* this, PlayState* play) { + func_80183DE0(&this->skeletonInfo); + if (Cutscene_CheckActorAction(play, this->csActionIndex)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionIndex)); + if (this->csActorAction != + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionIndex)]->action) { + this->csActorAction = + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionIndex)]->action; + func_80C1B8B4(this); + } + func_80C1B8F0(this); + if (this->alphaLevel > 0.0f) { + func_800B9010(&this->actor, NA_SE_EV_MOON_LIGHT_PILLAR - SFX_FLAG); + } + } else { + this->actor.draw = NULL; + } + func_80C1B724(this->alphaLevel); +} + +void EnFall2_Update(Actor* thisx, PlayState* play) { + EnFall2* this = THIS; + + this->actionFunc(this, play); +} + +void EnFall2_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnFall2* this = THIS; + Mtx* mtx; + + if (!(this->alphaLevel <= 0.0f)) { + func_8012C2DC(play->state.gfxCtx); + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(object_fall2_Matanimheader_008840)); + + mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx))); + + if (mtx != NULL) { + func_8012C2DC(play->state.gfxCtx); + Matrix_RotateYS((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000), MTXMODE_APPLY); + func_8018450C(play, &this->skeletonInfo, mtx, NULL, NULL, &this->actor); + } + } +} diff --git a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.h b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.h index 5c489bd7c..5ac33b27d 100644 --- a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.h +++ b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.h @@ -2,15 +2,22 @@ #define Z_EN_FALL2_H #include "global.h" +#include "assets/objects/object_fall2/object_fall2.h" struct EnFall2; typedef void (*EnFall2ActionFunc)(struct EnFall2*, PlayState*); typedef struct EnFall2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1A4]; - /* 0x02E8 */ EnFall2ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkeletonInfo skeletonInfo; + /* 0x174 */ Vec3s unk174[30]; + /* 0x228 */ Vec3s unk228[30]; + /* 0x2DC */ AnimatedMaterial* unk2DC; + /* 0x2E0 */ f32 alphaLevel; + /* 0x2E4 */ s16 csActorAction; + /* 0x2E6 */ u16 csActionIndex; + /* 0x2E8 */ EnFall2ActionFunc actionFunc; } EnFall2; // size = 0x2EC extern const ActorInit En_Fall2_InitVars; diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index f8dd32a84..8cebddded 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -139,7 +139,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -549,7 +549,7 @@ void EnFamos_Attack(EnFamos* this, PlayState* play) { this->collider1.base.atFlags &= ~AT_ON; this->collider2.base.atFlags |= AT_ON; if (hitFloor) { - func_800DFD04(play->cameraPtrs[play->activeCamera], 2, 15, 10); // camera shake? + Camera_AddQuake(GET_ACTIVE_CAM(play), 2, 15, 10); Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); EnFamos_SetupAttackDebris(this); diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.h b/src/overlays/actors/ovl_En_Famos/z_en_famos.h index 0478f70df..c446c2113 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.h +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.h @@ -9,10 +9,10 @@ struct EnFamos; typedef void (*EnFamosActionFunc)(struct EnFamos*, PlayState*); typedef struct EnFamosRock { - /* 00 */ Vec3f pos; - /* 0C */ Vec3f velocity; - /* 18 */ Vec3s rotation; - /* 20 */ f32 scale; + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3f velocity; + /* 0x18 */ Vec3s rotation; + /* 0x20 */ f32 scale; } EnFamosRock; // size = 0x24 #define GET_FAMOS_PATH(thisx) (thisx->params) diff --git a/src/overlays/actors/ovl_En_Fg/z_en_fg.h b/src/overlays/actors/ovl_En_Fg/z_en_fg.h index 1dfb30f04..6440812ca 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.h +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.h @@ -9,32 +9,32 @@ typedef void (*EnFgActionFunc)(struct EnFg*, PlayState*); // Based on the envColor data. Related to params but mostly unused. typedef enum { - /* 0x00 */ FG_YELLOW, - /* 0x01 */ FG_CYAN, - /* 0x02 */ FG_PINK, - /* 0x03 */ FG_BLUE, - /* 0x04 */ FG_WHITE, - /* 0x05 */ FG_BLACK, // All frogs are blackened when hit by an explosion + /* 0x0 */ FG_YELLOW, + /* 0x1 */ FG_CYAN, + /* 0x2 */ FG_PINK, + /* 0x3 */ FG_BLUE, + /* 0x4 */ FG_WHITE, + /* 0x5 */ FG_BLACK, // All frogs are blackened when hit by an explosion } FrogType; typedef enum { - /* 0x00 */ FG_DMGEFFECT_NONE, - /* 0x01 */ FG_DMGEFFECT_EXPLOSION, // Bomb or bombchu, not powderkeg - /* 0x02 */ FG_DMGEFFECT_DEKUSTICK, - /* 0x03 */ FG_DMGEFFECT_HOOKSHOT, - /* 0x04 */ FG_DMGEFFECT_ARROW, - /* 0x05 */ FG_DMGEFFECT_ICEARROW, + /* 0x0 */ FG_DMGEFFECT_NONE, + /* 0x1 */ FG_DMGEFFECT_EXPLOSION, // Bomb or bombchu, not powderkeg + /* 0x2 */ FG_DMGEFFECT_DEKUSTICK, + /* 0x3 */ FG_DMGEFFECT_HOOKSHOT, + /* 0x4 */ FG_DMGEFFECT_ARROW, + /* 0x5 */ FG_DMGEFFECT_ICEARROW, } FrogDamageEffect; typedef struct { - /* 0x0000 */ u8 type; - /* 0x0001 */ u8 timer; - /* 0x0004 */ f32 xyScale; - /* 0x0008 */ UNK_TYPE1 unk_08[0xC]; - /* 0x0014 */ Vec3f pos; - /* 0x0020 */ Vec3f unk_20; // Likely acceleration, set to 0 but unused - /* 0x002C */ Vec3f velocity; - /* 0x0038 */ UNK_TYPE1 unk_38[0x4]; + /* 0x00 */ u8 type; + /* 0x01 */ u8 timer; + /* 0x04 */ f32 xyScale; + /* 0x08 */ UNK_TYPE1 unk_08[0xC]; + /* 0x14 */ Vec3f pos; + /* 0x20 */ Vec3f unk_20; // Likely acceleration, set to 0 but unused + /* 0x2C */ Vec3f velocity; + /* 0x38 */ UNK_TYPE1 unk_38[0x4]; } EnFgEffectDust; // size = 0x3C typedef struct EnFg { 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 3e6e4f53c..d8cbe91f5 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -78,39 +78,48 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit sColChkInfoInit = { 1, 10, 10, 10 }; +typedef enum { + /* 0 */ KEESE_DMGEFF_NONE, + /* 1 */ KEESE_DMGEFF_STUN, + /* 2 */ KEESE_DMGEFF_FIRE, + /* 3 */ KEESE_DMGEFF_ICE, + /* 4 */ KEESE_DMGEFF_LIGHT, + /* 5 */ KEESE_DMGEFF_ELECTRIC +} BatDamageEffect; + static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0x0), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), + /* Deku Nut */ DMG_ENTRY(0, KEESE_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, KEESE_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, KEESE_DMGEFF_ICE), + /* Light arrow */ DMG_ENTRY(2, KEESE_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, KEESE_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, KEESE_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, KEESE_DMGEFF_ELECTRIC), + /* Normal shield */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, KEESE_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, KEESE_DMGEFF_NONE), }; static InitChainEntry sInitChain[] = { @@ -265,7 +274,7 @@ void EnFirefly_SetupFlyIdle(EnFirefly* this) { this->timer = Rand_S16Offset(70, 100); this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 1.5f; Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x300); - this->targetPitch = ((this->maxAltitude < this->actor.world.pos.y) ? 0xC00 : -0xC00) + 0x1554; + this->pitchTarget = ((this->maxAltitude < this->actor.world.pos.y) ? 0xC00 : -0xC00) + 0x1554; this->skelAnime.playSpeed = 1.0f; this->actionFunc = EnFirefly_FlyIdle; } @@ -295,25 +304,25 @@ void EnFirefly_FlyIdle(EnFirefly* this, PlayState* play) { // Climb if too close to ground if (this->actor.world.pos.y < this->actor.floorHeight + 20.0f) { - this->targetPitch = 0x954; + this->pitchTarget = 0x954; // Descend if above maxAltitude } else if (this->maxAltitude < this->actor.world.pos.y) { - this->targetPitch = 0x2154; + this->pitchTarget = 0x2154; // Otherwise ascend or descend at random, biased towards ascending } else if (Rand_ZeroOne() > 0.35f) { - this->targetPitch = 0x954; + this->pitchTarget = 0x954; } else { - this->targetPitch = 0x2154; + this->pitchTarget = 0x2154; } } else { if (this->actor.bgCheckFlags & 1) { - this->targetPitch = 0x954; + this->pitchTarget = 0x954; } else if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) { - this->targetPitch = 0x2154; + this->pitchTarget = 0x2154; } } - Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); + Math_ScaledStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0x100); } if (this->actor.bgCheckFlags & 8) { @@ -328,7 +337,7 @@ void EnFirefly_FlyIdle(EnFirefly* this, PlayState* play) { void EnFirefly_SetupFall(EnFirefly* this, PlayState* play) { this->timer = 40; this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelAnime, &object_firefly_Anim_00017C, 0.0f, 6.0f, 6.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &object_firefly_Anim_00017C, 0.0f, 6.0f, 6.0f, ANIMMODE_ONCE, 0.0f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_DEAD); this->actor.flags |= ACTOR_FLAG_10; @@ -338,19 +347,19 @@ void EnFirefly_SetupFall(EnFirefly* this, PlayState* play) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); } - if (this->actor.colChkInfo.damageEffect == 3) { + if (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_ICE) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffScale = 0.55f; - this->drawDmgEffFrozenSteamScale = 0.82500005f; - } else if (this->actor.colChkInfo.damageEffect == 4) { + this->drawDmgEffFrozenSteamScale = 0.55f * 1.5f; + } else if (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_LIGHT) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->drawDmgEffAlpha = 4.0f; this->drawDmgEffScale = 0.55f; Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); - } else if (this->actor.colChkInfo.damageEffect == 2) { + } else if (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_FIRE) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->drawDmgEffAlpha = 4.0f; this->drawDmgEffScale = 0.55f; @@ -409,7 +418,7 @@ void EnFirefly_Die(EnFirefly* this, PlayState* play) { void EnFirefly_SetupDiveAttack(EnFirefly* this) { this->timer = Rand_S16Offset(70, 100); this->skelAnime.playSpeed = 1.0f; - this->targetPitch = ((this->actor.playerHeightRel > 0.0f) ? -0xC00 : 0xC00) + 0x1554; + this->pitchTarget = ((this->actor.playerHeightRel > 0.0f) ? -0xC00 : 0xC00) + 0x1554; this->actionFunc = EnFirefly_DiveAttack; } @@ -427,7 +436,7 @@ void EnFirefly_DiveAttack(EnFirefly* this, PlayState* play) { 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); + Math_ScaledStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0x100); } else if (Actor_IsFacingPlayer(&this->actor, 0x2800)) { if (Animation_OnFrame(&this->skelAnime, 4.0f)) { this->skelAnime.playSpeed = 0.0f; @@ -447,19 +456,19 @@ void EnFirefly_DiveAttack(EnFirefly* this, PlayState* play) { } if (this->actor.bgCheckFlags & 1) { - this->targetPitch = 0x954; + this->pitchTarget = 0x954; } if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) { - this->targetPitch = 0x2154; + this->pitchTarget = 0x2154; } else { - this->targetPitch = 0x954; + this->pitchTarget = 0x954; } - Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); + Math_ScaledStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0x100); } - if ((this->timer == 0) || (Player_GetMask(play) == PLAYER_MASK_STONE) || (player->stateFlags2 & 0x80) || + if ((this->timer == 0) || (Player_GetMask(play) == PLAYER_MASK_STONE) || (player->stateFlags2 & PLAYER_STATE2_80) || (player->actor.freezeTimer > 0)) { EnFirefly_SetupFlyAway(this); } @@ -491,7 +500,7 @@ void EnFirefly_Rebound(EnFirefly* this, PlayState* play) { void EnFirefly_SetupFlyAway(EnFirefly* this) { this->timer = 150; - this->targetPitch = 0x954; + this->pitchTarget = 0x954; this->actionFunc = EnFirefly_FlyAway; this->skelAnime.playSpeed = 1.0f; } @@ -513,11 +522,11 @@ void EnFirefly_FlyAway(EnFirefly* this, PlayState* play) { Math_StepToF(&this->actor.speedXZ, 3.0f, 0.3f); if (this->actor.bgCheckFlags & 1) { - this->targetPitch = 0x954; + this->pitchTarget = 0x954; } else if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) { - this->targetPitch = 0x2154; + this->pitchTarget = 0x2154; } else { - this->targetPitch = 0x954; + this->pitchTarget = 0x954; } if (this->actor.bgCheckFlags & 8) { @@ -526,7 +535,7 @@ void EnFirefly_FlyAway(EnFirefly* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x300); } - Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); + Math_ScaledStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0x100); } void EnFirefly_SetupStunned(EnFirefly* this) { @@ -632,10 +641,10 @@ void EnFirefly_UpdateDamage(EnFirefly* this, PlayState* play) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if (this->actor.colChkInfo.damageEffect == 1) { + if (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_STUN) { this->timer = 40; EnFirefly_SetupStunned(this); - } else if (this->actor.colChkInfo.damageEffect == 5) { + } else if (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_ELECTRIC) { this->timer = 40; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; this->drawDmgEffAlpha = 2.0f; @@ -647,9 +656,9 @@ void EnFirefly_UpdateDamage(EnFirefly* this, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_1; // Negate effects of fire on Fire Keese and Ice on Ice Keese - if (((this->currentType == KEESE_FIRE) && (this->actor.colChkInfo.damageEffect == 2)) || - ((this->currentType == KEESE_ICE) && (this->actor.colChkInfo.damageEffect == 3))) { - this->actor.colChkInfo.damageEffect = 0; + if (((this->currentType == KEESE_FIRE) && (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_FIRE)) || + ((this->currentType == KEESE_ICE) && (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_ICE))) { + this->actor.colChkInfo.damageEffect = KEESE_DMGEFF_NONE; } EnFirefly_SetupFall(this, play); @@ -714,7 +723,7 @@ void EnFirefly_Update(Actor* thisx, PlayState* play2) { Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); - } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.55f / 40.0f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -755,7 +764,7 @@ void EnFirefly_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* if ((this->currentType != KEESE_FIRE) && (limbIndex == 27)) { gSPDisplayList((*gfx)++, object_firefly_DL_001678); - } else if ((this->unk_2F4 != play->gameplayFrames) && + } else if ((this->lastDrawnFrame != play->gameplayFrames) && ((this->auraType == KEESE_AURA_FIRE) || (this->auraType == KEESE_AURA_ICE)) && ((limbIndex == 15) || (limbIndex == 21))) { if (this->actionFunc != EnFirefly_Die) { @@ -832,7 +841,7 @@ void EnFirefly_Draw(Actor* thisx, PlayState* play) { Actor_DrawDamageEffects(play, NULL, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale * this->actor.scale.y * 200.0f, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); - this->unk_2F4 = play->gameplayFrames; + this->lastDrawnFrame = play->gameplayFrames; CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h index cb6019d5e..ffb295e6a 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h @@ -26,14 +26,14 @@ typedef struct EnFirefly { /* 0x18E */ u8 isInvisible; /* 0x18F */ u8 drawDmgEffType; /* 0x190 */ s16 timer; - /* 0x192 */ s16 targetPitch; + /* 0x192 */ s16 pitchTarget; /* 0x194 */ Vec3s jointTable[28]; /* 0x23C */ Vec3s morphTable[28]; /* 0x2E4 */ f32 maxAltitude; /* 0x2E8 */ f32 drawDmgEffAlpha; /* 0x2E8 */ f32 drawDmgEffScale; /* 0x2E8 */ f32 drawDmgEffFrozenSteamScale; - /* 0x2F4 */ u32 unk_2F4; + /* 0x2F4 */ u32 lastDrawnFrame; /* 0x2F8 */ Vec3f limbPos[3]; /* 0x31C */ ColliderSphere collider; } EnFirefly; // size = 0x374 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 7e927e98e..268768660 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -58,7 +58,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -92,12 +92,12 @@ f32 func_8091D630(Vec3f* arg0, Vec3f* arg1) { 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); + Animation_GetLastFrame(&gameplay_keep_Anim_02F0EC), ANIMMODE_LOOP_INTERP, 2.0f); } 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); + Animation_GetLastFrame(&gameplay_keep_Anim_02E65C), ANIMMODE_LOOP_INTERP, 2.0f); } void func_8091D728(EnFish* this) { 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 1fe0c519f..f0e2d5c42 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -95,7 +95,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -107,7 +107,9 @@ void func_80B28370(EnFish2* this, s32 arg0) { &object_fb_Anim_0013AC, &object_fb_Anim_0007D4, &object_fb_Anim_0006D8, &object_fb_Anim_0006D8, &object_fb_Anim_001174, &object_fb_Anim_000ACC, }; - static u8 D_80B2B3A0[] = { 0, 0, 2, 2, 2, 2 }; + static u8 D_80B2B3A0[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, + }; f32 sp34; this->unk_2AC = arg0; @@ -433,7 +435,7 @@ void func_80B29128(EnFish2* this) { } void func_80B2913C(EnFish2* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); func_80B28B5C(this); } @@ -793,13 +795,13 @@ void func_80B2A01C(EnFish2* this, PlayState* play) { } void func_80B2A094(EnFish2* this, PlayState* play) { - Vec3f sp2C; + Vec3f subCamEye; if (this->unk_2B4 == 0) { D_80B2B2E4 = 1; } - this->unk_2CA = ActorCutscene_GetCurrentCamera(this->unk_2BA[0]); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->unk_2BA[0]); if (D_80B2B2EC != 0) { D_80B2B2EC++; @@ -811,17 +813,17 @@ void func_80B2A094(EnFish2* this, PlayState* play) { } if ((this->unk_350 != NULL) && (this->unk_350->update != NULL)) { - Math_Vec3f_Copy(&sp2C, &this->unk_350->world.pos); - sp2C.x += Math_SinS(-0x3A98) * 110.0f; - sp2C.z += Math_CosS(-0x3A98) * 110.0f; - Math_Vec3f_Copy(&this->unk_2DC, &sp2C); - Math_Vec3f_Copy(&sp2C, &this->unk_350->world.pos); - sp2C.x += Math_SinS(-0x3A98) * 10.0f; - sp2C.z += Math_CosS(-0x3A98) * 10.0f; - Math_Vec3f_Copy(&this->unk_2E8, &sp2C); + Math_Vec3f_Copy(&subCamEye, &this->unk_350->world.pos); + subCamEye.x += Math_SinS(-0x3A98) * 110.0f; + subCamEye.z += Math_CosS(-0x3A98) * 110.0f; + Math_Vec3f_Copy(&this->subCamEye, &subCamEye); + Math_Vec3f_Copy(&subCamEye, &this->unk_350->world.pos); + subCamEye.x += Math_SinS(-0x3A98) * 10.0f; + subCamEye.z += Math_CosS(-0x3A98) * 10.0f; + Math_Vec3f_Copy(&this->subCamAt, &subCamEye); } - Play_CameraSetAtEye(play, this->unk_2CA, &this->unk_2E8, &this->unk_2DC); + Play_CameraSetAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); if ((this->unk_350 == NULL) || (this->unk_350->update == NULL)) { this->unk_350 = NULL; this->unk_2B0++; @@ -833,29 +835,29 @@ void func_80B2A094(EnFish2* this, PlayState* play) { } void func_80B2A23C(EnFish2* this, PlayState* play) { - Vec3f sp2C; + Vec3f subCamAt; - Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + Math_Vec3f_Copy(&subCamAt, &this->actor.world.pos); if (D_80B2B2E4 == 2) { - sp2C.x += (Math_SinS(-0x3A98) * 180.0f); - sp2C.y += 90.0f; - sp2C.z += Math_CosS(-0x3A98) * 180.0f; - Math_Vec3f_Copy(&this->unk_2DC, &sp2C); - Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); - sp2C.y += 70.0f; - Math_Vec3f_Copy(&this->unk_2E8, &sp2C); + subCamAt.x += (Math_SinS(-0x3A98) * 180.0f); + subCamAt.y += 90.0f; + subCamAt.z += Math_CosS(-0x3A98) * 180.0f; + Math_Vec3f_Copy(&this->subCamEye, &subCamAt); + Math_Vec3f_Copy(&subCamAt, &this->actor.world.pos); + subCamAt.y += 70.0f; + Math_Vec3f_Copy(&this->subCamAt, &subCamAt); } else if (D_80B2B2F4 != NULL) { - Math_Vec3f_Copy(&sp2C, &D_80B2B2F4->world.pos); - sp2C.x += Math_SinS(-0x3A98) * 110.0f; - sp2C.z += Math_CosS(-0x3A98) * 110.0f; - Math_Vec3f_Copy(&this->unk_2DC, &sp2C); - Math_Vec3f_Copy(&sp2C, &D_80B2B2F4->world.pos); - sp2C.x += Math_SinS(-0x3A98) * 10.0f; - sp2C.z += Math_CosS(-0x3A98) * 10.0f; - Math_Vec3f_Copy(&this->unk_2E8, &sp2C); + Math_Vec3f_Copy(&subCamAt, &D_80B2B2F4->world.pos); + subCamAt.x += Math_SinS(-0x3A98) * 110.0f; + subCamAt.z += Math_CosS(-0x3A98) * 110.0f; + Math_Vec3f_Copy(&this->subCamEye, &subCamAt); + Math_Vec3f_Copy(&subCamAt, &D_80B2B2F4->world.pos); + subCamAt.x += Math_SinS(-0x3A98) * 10.0f; + subCamAt.z += Math_CosS(-0x3A98) * 10.0f; + Math_Vec3f_Copy(&this->subCamAt, &subCamAt); } - Play_CameraSetAtEye(play, this->unk_2CA, &this->unk_2E8, &this->unk_2DC); + Play_CameraSetAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); if ((this->unk_2B4 == 0) && (D_80B2B2E4 == 3)) { D_80B2B2E0 = D_80B2B2EC = D_80B2B2E4 = 0; diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h index ca3ad2bc8..5f79700c9 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h @@ -32,13 +32,13 @@ typedef struct EnFish2 { /* 0x02C0 */ s32 unk_2C0; /* 0x02C4 */ s32 unk_2C4; /* 0x02C8 */ u8 unk_2C8; - /* 0x02CA */ s16 unk_2CA; + /* 0x02CA */ s16 subCamId; /* 0x02CC */ f32 unk_2CC; /* 0x02D0 */ char unk_2D0[0x4]; /* 0x02D4 */ f32 unk_2D4; /* 0x02D8 */ f32 unk_2D8; - /* 0x02DC */ Vec3f unk_2DC; - /* 0x02E8 */ Vec3f unk_2E8; + /* 0x02DC */ Vec3f subCamEye; + /* 0x02E8 */ Vec3f subCamAt; /* 0x02F4 */ Vec3f unk_2F4; /* 0x0300 */ Vec3f unk_300; /* 0x030C */ Vec3f unk_30C; 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 9a3138fe0..7463eaab1 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -4,7 +4,6 @@ * Description: Fishing Pond Elements (Owner, Fish, Props, Effects...) */ -#include "prevent_bss_reordering.h" #include "z_en_fishing.h" #include "z64rumble.h" #include "objects/object_fish/object_fish.h" @@ -139,11 +138,11 @@ u8 D_80911E28; Vec3f sSinkingLurePos[SINKING_LURE_SEG_COUNT]; s16 D_80911F20; f32 sProjectedW; -Vec3f sCameraEye; -Vec3f sCameraAt; -s16 sCameraId; +Vec3f sSubCamEye; +Vec3f sSubCamAt; +s16 sSubCamId; f32 D_80911F48; -f32 D_80911F4C; +f32 sSubCamVelFactor; f32 D_80911F50; Vec3f sSinkingLureBasePos; f32 D_80911F64; @@ -1128,10 +1127,10 @@ void EnFishing_UpdateEffects(FishingEffect* effect, PlayState* play) { Message_StartTextbox(play, 0x40B3, NULL); } - if ((effect->unk_2C >= 100) && (Message_GetState(&play->msgCtx) == 5)) { - if (Message_ShouldAdvance(play) || Message_GetState(&play->msgCtx) == 0) { + if ((effect->unk_2C >= 100) && (Message_GetState(&play->msgCtx) == TEXT_STATE_5)) { + if (Message_ShouldAdvance(play) || (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { func_801477B4(play); - func_801159EC(-50); + Rupees_ChangeBy(-50); effect->unk_2C = -1; } } @@ -2875,7 +2874,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { sp118 = (player->actor.speedXZ * 0.3f) + 0.25f; } - if ((D_80917200 != 0) || (sCameraId != CAM_ID_MAIN) || + if ((D_80917200 != 0) || (sSubCamId != SUB_CAM_ID_DONE) || ((player->actor.world.pos.z > 1150.0f) && (this->unk_150 != 100))) { this->actor.flags &= ~ACTOR_FLAG_1; } else { @@ -3056,7 +3055,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { this->unk_172[1] = 50; } - if (Message_GetState(&play->msgCtx) == 0) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) && (gSaveContext.save.time <= 0xC01B)) { this->unk_150 = 7; this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; @@ -3804,17 +3803,17 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { sp10C.z = 50.0f; } Matrix_RotateYF((player->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); - Matrix_MultVec3f(&sp10C, &sCameraEye); + Matrix_MultVec3f(&sp10C, &sSubCamEye); - sCameraEye.x += player->actor.world.pos.x; - sCameraEye.y += player->actor.world.pos.y; - sCameraEye.z += player->actor.world.pos.z; + sSubCamEye.x += player->actor.world.pos.x; + sSubCamEye.y += player->actor.world.pos.y; + sSubCamEye.z += player->actor.world.pos.z; - sCameraAt = player->actor.world.pos; + sSubCamAt = player->actor.world.pos; if (sLinkAge != 1) { - sCameraAt.y += 40.0f; + sSubCamAt.y += 40.0f; } else { - sCameraAt.y += 25.0f; + sSubCamAt.y += 25.0f; } if (this->unk_172[0] == 90) { @@ -3856,7 +3855,8 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { if (this->unk_172[0] <= 50) { switch (this->unk_1CD) { case 0: - if ((Message_GetState(&play->msgCtx) == 4) || Message_GetState(&play->msgCtx) == 0) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) || + Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if (Message_ShouldAdvance(play)) { func_801477B4(play); if (play->msgCtx.choiceIndex == 0) { @@ -3887,7 +3887,8 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { } break; case 1: - if ((Message_GetState(&play->msgCtx) == 4) || Message_GetState(&play->msgCtx) == 0) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) || + Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if (Message_ShouldAdvance(play)) { func_801477B4(play); if (play->msgCtx.choiceIndex != 0) { @@ -4331,7 +4332,7 @@ void EnFishing_UpdatePondProps(PlayState* play) { prop++; } - if (sCameraId == CAM_ID_MAIN) { + if (sSubCamId == SUB_CAM_ID_DONE) { CollisionCheck_SetOC(play, &play->colChkCtx, &sFishingMain->collider.base); } } @@ -4708,13 +4709,13 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { break; case 1: - if ((Message_GetState(&play->msgCtx) == 4) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { func_801477B4(play); switch (play->msgCtx.choiceIndex) { case 0: if (gSaveContext.save.playerData.rupees >= 20) { - func_801159EC(-20); + Rupees_ChangeBy(-20); if (!Rumble_ControllerOneHasRumblePak()) { this->actor.textId = 0x407C; } else { @@ -4736,7 +4737,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { break; case 2: - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); func_80151938(play, 0x407F); this->unk_154 = 4; @@ -4744,17 +4745,17 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { break; case 3: - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); this->unk_154 = 0; } - if (Message_GetState(&play->msgCtx) == 6) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) { this->unk_154 = 0; } break; case 4: - if ((Message_GetState(&play->msgCtx) == 4) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { func_801477B4(play); switch (play->msgCtx.choiceIndex) { @@ -4771,7 +4772,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { break; case 5: - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); play->interfaceCtx.unk_27E = 1; @@ -4788,7 +4789,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { case 10: if (D_8090CD0C != 0) { - if ((Message_GetState(&play->msgCtx) == 4) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { func_801477B4(play); switch (play->msgCtx.choiceIndex) { @@ -4804,7 +4805,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { } } } else { - if ((Message_GetState(&play->msgCtx) == 4) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { func_801477B4(play); switch (play->msgCtx.choiceIndex) { @@ -4876,7 +4877,8 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { break; case 11: - if (((Message_GetState(&play->msgCtx) == 5) || Message_GetState(&play->msgCtx) == 0) && + if (((Message_GetState(&play->msgCtx) == TEXT_STATE_5) || + Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) && Message_ShouldAdvance(play)) { s32 getItemId; @@ -4952,14 +4954,14 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { break; case 20: - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); this->unk_154 = 0; } break; case 21: - if ((Message_GetState(&play->msgCtx) == 4) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { func_801477B4(play); switch (play->msgCtx.choiceIndex) { @@ -4979,7 +4981,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { break; case 22: - if (Message_GetState(&play->msgCtx) == 0) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { this->unk_154 = 0; if (D_8090CD0C != 0) { D_8090CD08 = 1; @@ -5001,7 +5003,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { case 24: D_8090CCF4 = false; - if ((Message_GetState(&play->msgCtx) == 6) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { if (D_809171D0 == 0) { this->unk_154 = 0; } else { @@ -5035,7 +5037,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { f32 target; f32 camAtFraction; f32 lureDistXZ; - Camera* camera; + Camera* mainCam; Player* player = GET_PLAYER(play); Input* input = CONTROLLER1(&play->state); @@ -5051,13 +5053,13 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { SkelAnime_Update(&this->skelAnime); - if ((D_8090CD04 != 0) || Message_GetState(&play->msgCtx)) { + if ((D_8090CD04 != 0) || Message_GetState(&play->msgCtx) != TEXT_STATE_NONE) { this->actor.flags &= ~ACTOR_FLAG_1; } else { this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_20); } - if ((this->actor.xzDistToPlayer < 120.0f) || Message_GetState(&play->msgCtx)) { + if ((this->actor.xzDistToPlayer < 120.0f) || Message_GetState(&play->msgCtx) != TEXT_STATE_NONE) { headRotTarget = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; } else { headRotTarget = 0; @@ -5153,21 +5155,20 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { break; case 1: - sCameraId = Play_CreateSubCamera(play); - Play_CameraChangeStatus(play, CAM_ID_MAIN, 1); - Play_CameraChangeStatus(play, sCameraId, 7); - camera = Play_GetCamera(play, CAM_ID_MAIN); - sCameraEye.x = camera->eye.x; - sCameraEye.y = camera->eye.y; - sCameraEye.z = camera->eye.z; - sCameraAt.x = camera->at.x; - sCameraAt.y = camera->at.y; - sCameraAt.z = camera->at.z; + sSubCamId = Play_CreateSubCamera(play); + Play_CameraChangeStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_CameraChangeStatus(play, sSubCamId, CAM_STATUS_ACTIVE); + mainCam = Play_GetCamera(play, CAM_ID_MAIN); + sSubCamEye.x = mainCam->eye.x; + sSubCamEye.y = mainCam->eye.y; + sSubCamEye.z = mainCam->eye.z; + sSubCamAt.x = mainCam->at.x; + sSubCamAt.y = mainCam->at.y; + sSubCamAt.z = mainCam->at.z; D_8090CD4C = 2; Interface_ChangeAlpha(12); - D_80911F4C = 0.0f; + sSubCamVelFactor = 0.0f; // fallthrough - case 2: ShrinkWindow_SetLetterboxTarget(27); @@ -5187,9 +5188,9 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { 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); + Math_ApproachF(&sSubCamAt.x, sLurePos.x, camAtFraction, fabsf(spFC.x) * sSubCamVelFactor); + Math_ApproachF(&sSubCamAt.y, sLurePos.y, camAtFraction, 50.0f * sSubCamVelFactor); + Math_ApproachF(&sSubCamAt.z, sLurePos.z, camAtFraction, fabsf(spFC.z) * sSubCamVelFactor); sp114.x = 0.0f - D_80911F50; if (sLinkAge != 1) { @@ -5257,22 +5258,22 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { sp114.z = 100.0f; Matrix_MultVec3f(&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); + Math_ApproachF(&sSubCamEye.x, sp108.x, 0.3f, fabsf(spFC.x) * sSubCamVelFactor); + Math_ApproachF(&sSubCamEye.y, sp108.y, 0.3f, 20.0f * sSubCamVelFactor); + Math_ApproachF(&sSubCamEye.z, sp108.z, 0.3f, fabsf(spFC.z) * sSubCamVelFactor); break; case 3: { - Camera* camera = Play_GetCamera(play, CAM_ID_MAIN); + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); - camera->eye = sCameraEye; - camera->eyeNext = sCameraEye; - camera->at = sCameraAt; + mainCam->eye = sSubCamEye; + mainCam->eyeNext = sSubCamEye; + mainCam->at = sSubCamAt; } - func_80169AFC(play, sCameraId, 0); + func_80169AFC(play, sSubCamId, 0); Cutscene_End(play, &play->csCtx); D_8090CD4C = 0; - sCameraId = CAM_ID_MAIN; + sSubCamId = SUB_CAM_ID_DONE; func_800F6834(play, 0); play->envCtx.lightSettings.fogNear = 0; player->unk_B28 = -5; @@ -5281,37 +5282,39 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { case 10: Cutscene_Start(play, &play->csCtx); - sCameraId = Play_CreateSubCamera(play); - Play_CameraChangeStatus(play, CAM_ID_MAIN, 1); - Play_CameraChangeStatus(play, sCameraId, 7); + sSubCamId = Play_CreateSubCamera(play); + Play_CameraChangeStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_CameraChangeStatus(play, sSubCamId, CAM_STATUS_ACTIVE); func_800B7298(play, &this->actor, 4); - camera = Play_GetCamera(play, CAM_ID_MAIN); - sCameraEye.x = camera->eye.x; - sCameraEye.y = camera->eye.y; - sCameraEye.z = camera->eye.z; - sCameraAt.x = camera->at.x; - sCameraAt.y = camera->at.y; - sCameraAt.z = camera->at.z; + + mainCam = Play_GetCamera(play, CAM_ID_MAIN); + sSubCamEye.x = mainCam->eye.x; + sSubCamEye.y = mainCam->eye.y; + sSubCamEye.z = mainCam->eye.z; + sSubCamAt.x = mainCam->at.x; + sSubCamAt.y = mainCam->at.y; + sSubCamAt.z = mainCam->at.z; + Message_StartTextbox(play, 0x409E, NULL); D_8090CD4C = 11; Rumble_Override(0.0f, 150, 10, 10); // fallthrough - case 11: player->actor.world.pos.z = 1360.0f; player->actor.speedXZ = 0.0f; - if (Message_GetState(&play->msgCtx) == 0) { - Camera* camera = Play_GetCamera(play, CAM_ID_MAIN); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); - camera->eye = sCameraEye; - camera->eyeNext = sCameraEye; - camera->at = sCameraAt; - func_80169AFC(play, sCameraId, 0); + mainCam->eye = sSubCamEye; + mainCam->eyeNext = sSubCamEye; + mainCam->at = sSubCamAt; + + func_80169AFC(play, sSubCamId, 0); Cutscene_End(play, &play->csCtx); func_800B7298(play, &this->actor, 6); D_8090CD4C = 0; - sCameraId = CAM_ID_MAIN; + sSubCamId = SUB_CAM_ID_DONE; D_8090CD50 = 30; func_800F6834(play, 0); play->envCtx.lightSettings.fogNear = 0; @@ -5320,23 +5323,23 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { case 20: Cutscene_Start(play, &play->csCtx); - sCameraId = Play_CreateSubCamera(play); - Play_CameraChangeStatus(play, CAM_ID_MAIN, 1); - Play_CameraChangeStatus(play, sCameraId, 7); + sSubCamId = Play_CreateSubCamera(play); + Play_CameraChangeStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); + Play_CameraChangeStatus(play, sSubCamId, CAM_STATUS_ACTIVE); func_800B7298(play, &this->actor, 4); - camera = Play_GetCamera(play, CAM_ID_MAIN); - sCameraEye.x = camera->eye.x; - sCameraEye.y = camera->eye.y; - sCameraEye.z = camera->eye.z; - sCameraAt.x = camera->at.x; - sCameraAt.y = camera->at.y; - sCameraAt.z = camera->at.z; + + mainCam = Play_GetCamera(play, CAM_ID_MAIN); + sSubCamEye.x = mainCam->eye.x; + sSubCamEye.y = mainCam->eye.y; + sSubCamEye.z = mainCam->eye.z; + sSubCamAt.x = mainCam->at.x; + sSubCamAt.y = mainCam->at.y; + sSubCamAt.z = mainCam->at.z; Message_StartTextbox(play, 0x409A, NULL); D_8090CD4C = 21; D_80911F48 = 45.0f; D_8090CD50 = 10; // fallthrough - case 21: if ((D_8090CD50 == 0) && Message_ShouldAdvance(play)) { D_8090CD4C = 22; @@ -5381,22 +5384,23 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { sp114.z = -35.0f; } - Matrix_MultVec3f(&sp114, &sCameraEye); - sCameraEye.x += player->actor.world.pos.x; - sCameraEye.y += player->actor.world.pos.y; - sCameraEye.z += player->actor.world.pos.z; + Matrix_MultVec3f(&sp114, &sSubCamEye); + sSubCamEye.x += player->actor.world.pos.x; + sSubCamEye.y += player->actor.world.pos.y; + sSubCamEye.z += player->actor.world.pos.z; - sCameraAt = player->actor.world.pos; + sSubCamAt = player->actor.world.pos; if (sLinkAge != 1) { - sCameraAt.y += 62.0f; + sSubCamAt.y += 62.0f; } else { - sCameraAt.y += 40.0f; + sSubCamAt.y += 40.0f; } if (D_8090CD50 == 0) { - if ((Message_GetState(&play->msgCtx) == 4) || Message_GetState(&play->msgCtx) == 0) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) || + Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if (Message_ShouldAdvance(play)) { - Camera* camera = Play_GetCamera(play, CAM_ID_MAIN); + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); func_801477B4(play); if (play->msgCtx.choiceIndex == 0) { @@ -5404,14 +5408,14 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { D_809171D6 = 0; } - camera->eye = sCameraEye; - camera->eyeNext = sCameraEye; - camera->at = sCameraAt; - func_80169AFC(play, sCameraId, 0); + mainCam->eye = sSubCamEye; + mainCam->eyeNext = sSubCamEye; + mainCam->at = sSubCamAt; + func_80169AFC(play, sSubCamId, 0); Cutscene_End(play, &play->csCtx); func_800B7298(play, &this->actor, 6); // arg2 changed from 7 to 6 in MM D_8090CD4C = 0; - sCameraId = CAM_ID_MAIN; + sSubCamId = SUB_CAM_ID_DONE; player->unk_B28 = -5; D_80917200 = 5; D_8090CD54 = 0; @@ -5427,11 +5431,11 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { break; } - if (sCameraId != CAM_ID_MAIN) { - Play_CameraSetAtEye(play, sCameraId, &sCameraAt, &sCameraEye); - Math_ApproachF(&D_80911F4C, 1.0f, 1.0f, 0.02f); + if (sSubCamId != SUB_CAM_ID_DONE) { + Play_CameraSetAtEye(play, sSubCamId, &sSubCamAt, &sSubCamEye); + Math_ApproachF(&sSubCamVelFactor, 1.0f, 1.0f, 0.02f); - if (sCameraEye.y <= (WATER_SURFACE_Y(play) + 1.0f)) { + if (sSubCamEye.y <= (WATER_SURFACE_Y(play) + 1.0f)) { func_800F6834(play, 1); if (D_809171CA != 0) { play->envCtx.lightSettings.fogNear = -0xB2; @@ -5485,7 +5489,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { D_809171CB--; } - if ((D_809171CB == 1) && Message_GetState(&play->msgCtx) == 0 && ((D_8090CD00 & 0xFFF) == 0xFFF)) { + if ((D_809171CB == 1) && (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) && ((D_8090CD00 & 0xFFF) == 0xFFF)) { D_809171CB = 200; if (Rand_ZeroOne() < 0.5f) { @@ -5530,7 +5534,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { if ((u8)D_8090CCD0 > 0) { s32 pad; s16 i; - Camera* camera = Play_GetCamera(play, CAM_ID_MAIN); + Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); Vec3f pos; Vec3f rot; Vec3f projectedPos; @@ -5538,7 +5542,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { rot.x = 1.6707964f; rot.y = 1.0f; - rot.z = (Camera_GetInputDirYaw(camera) * -(M_PI / 32768)) + rot.y; + rot.z = (Camera_GetInputDirYaw(mainCam) * -(M_PI / 0x8000)) + rot.y; for (i = 0; i < (u8)D_8090CCD0; i++) { pos.x = randPlusMinusPoint5Scaled(700.0f) + play->view.eye.x; 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 beb3438b9..5af536dbb 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h @@ -9,56 +9,56 @@ typedef void (*EnFishingActionFunc)(struct EnFishing*, PlayState*); typedef struct EnFishing { /* 0x000 */ Actor actor; - /* 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]; + /* 0x144 */ UNK_TYPE1 unk_144[0x004]; + /* 0x148 */ u8 unk_148; + /* 0x149 */ u8 unk_149; + /* 0x14A */ u8 unk_14A; + /* 0x14C */ s16 unk_14C; + /* 0x14E */ u8 unk_14E; + /* 0x14F */ u8 unk_14F; + /* 0x150 */ s16 unk_150; + /* 0x152 */ s16 unk_152; + /* 0x154 */ s16 unk_154; + /* 0x156 */ s16 unk_156; + /* 0x158 */ s16 unk_158; + /* 0x15A */ s16 unk_15A; + /* 0x15C */ s16 unk_15C; + /* 0x15E */ s16 unk_15E; + /* 0x160 */ s16 unk_160; + /* 0x162 */ s16 unk_162; + /* 0x164 */ s16 unk_164; + /* 0x166 */ s16 unk_166; + /* 0x168 */ s16 unk_168; + /* 0x16A */ s16 unk_16A; + /* 0x16C */ s16 unk_16C; + /* 0x16E */ s16 unk_16E; + /* 0x170 */ s16 unk_170; + /* 0x172 */ s16 unk_172[4]; + /* 0x17C */ f32 unk_17C; + /* 0x180 */ f32 unk_180; + /* 0x184 */ f32 unk_184; + /* 0x188 */ f32 unk_188; + /* 0x18C */ f32 unk_18C; + /* 0x190 */ f32 unk_190; + /* 0x194 */ f32 unk_194; + /* 0x198 */ s16 unk_198; + /* 0x19A */ s16 unk_19A; + /* 0x19C */ s16 unk_19C; + /* 0x1A0 */ f32 unk_1A0; + /* 0x1A4 */ f32 unk_1A4; + /* 0x1A8 */ f32 unk_1A8; + /* 0x1AC */ Vec3f unk_1AC; + /* 0x1B8 */ Vec3f fishMouthPos; + /* 0x1C4 */ s16 unk_1C4[3]; + /* 0x1CA */ u8 unk_1CA; + /* 0x1CB */ u8 unk_1CB; + /* 0x1CC */ u8 unk_1CC; + /* 0x1CD */ u8 unk_1CD; + /* 0x1D0 */ SkelAnime skelAnime; + /* 0x214 */ LightNode* lightNode; + /* 0x218 */ LightInfo lightInfo; + /* 0x228 */ ColliderJntSph collider; + /* 0x248 */ ColliderJntSphElement colliderElements[12]; } EnFishing; // size = 0x548 extern const ActorInit En_Fishing_InitVars; diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h index 47b3af3d2..c4500973f 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h @@ -19,21 +19,21 @@ enum { }; typedef struct EnFloormas { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnFloormasActionFunc actionFunc; - /* 0x018C */ u8 drawDmgEffType; - /* 0x018E */ s16 unk_18E; - /* 0x0190 */ s16 unk_190; - /* 0x0192 */ s16 unk_192; - /* 0x0194 */ s16 unk_194; - /* 0x0196 */ Vec3s jointTable[WALLMASTER_LIMB_MAX]; - /* 0x022C */ Vec3s morphTable[WALLMASTER_LIMB_MAX]; - /* 0x02C4 */ f32 drawDmgEffAlpha; - /* 0x02C8 */ f32 drawDmgEffScale; - /* 0x02CC */ f32 drawDmgEffFrozenSteamScale; - /* 0x02D0 */ Vec3f limbPos[11]; - /* 0x0354 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnFloormasActionFunc actionFunc; + /* 0x18C */ u8 drawDmgEffType; + /* 0x18E */ s16 unk_18E; + /* 0x190 */ s16 unk_190; + /* 0x192 */ s16 unk_192; + /* 0x194 */ s16 unk_194; + /* 0x196 */ Vec3s jointTable[WALLMASTER_LIMB_MAX]; + /* 0x22C */ Vec3s morphTable[WALLMASTER_LIMB_MAX]; + /* 0x2C4 */ f32 drawDmgEffAlpha; + /* 0x2C8 */ f32 drawDmgEffScale; + /* 0x2CC */ f32 drawDmgEffFrozenSteamScale; + /* 0x2D0 */ Vec3f limbPos[11]; + /* 0x354 */ ColliderCylinder collider; } EnFloormas; // size = 0x3A0 extern const ActorInit En_Floormas_InitVars; 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 80964672c..b67c61c43 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -53,20 +53,20 @@ typedef enum { } EnFsnCutsceneState; typedef enum { - /* 00 */ FSN_ANIMATION_IDLE, - /* 01 */ FSN_ANIMATION_SCRATCH_BACK, - /* 02 */ FSN_ANIMATION_TURN_AROUND_FORWARD, - /* 03 */ FSN_ANIMATION_TURN_AROUND_REVERSE, - /* 04 */ FSN_ANIMATION_HANDS_ON_COUNTER_START, - /* 05 */ FSN_ANIMATION_HANDS_ON_COUNTER_LOOP, - /* 06 */ FSN_ANIMATION_HAND_ON_FACE_START, - /* 07 */ FSN_ANIMATION_HAND_ON_FACE_LOOP, - /* 08 */ FSN_ANIMATION_LEAN_FORWARD_START, - /* 09 */ FSN_ANIMATION_LEAN_FORWARD_LOOP, - /* 10 */ FSN_ANIMATION_SLAM_COUNTER_START, - /* 11 */ FSN_ANIMATION_SLAM_COUNTER_LOOP, - /* 12 */ FSN_ANIMATION_MAKE_OFFER, - /* 13 */ FSN_ANIMATION_MAX + /* 0 */ FSN_ANIM_IDLE, + /* 1 */ FSN_ANIM_SCRATCH_BACK, + /* 2 */ FSN_ANIM_TURN_AROUND_FORWARD, + /* 3 */ FSN_ANIM_TURN_AROUND_REVERSE, + /* 4 */ FSN_ANIM_HANDS_ON_COUNTER_START, + /* 5 */ FSN_ANIM_HANDS_ON_COUNTER_LOOP, + /* 6 */ FSN_ANIM_HAND_ON_FACE_START, + /* 7 */ FSN_ANIM_HAND_ON_FACE_LOOP, + /* 8 */ FSN_ANIM_LEAN_FORWARD_START, + /* 9 */ FSN_ANIM_LEAN_FORWARD_LOOP, + /* 10 */ FSN_ANIM_SLAM_COUNTER_START, + /* 11 */ FSN_ANIM_SLAM_COUNTER_LOOP, + /* 12 */ FSN_ANIM_MAKE_OFFER, + /* 13 */ FSN_ANIM_MAX } FsnAnimation; const ActorInit En_Fsn_InitVars = { @@ -209,7 +209,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, PlayState* play) { } void EnFsn_HandleSetupResumeInteraction(EnFsn* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 6 && Message_ShouldAdvance(play) && + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play) && this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { Actor_ProcessTalkRequest(&this->actor, &play->state); func_800B85E0(&this->actor, play, 400.0f, EXCH_ITEM_MINUS1); @@ -392,7 +392,7 @@ void EnFsn_EndInteraction(EnFsn* this, PlayState* play) { } Actor_ProcessTalkRequest(&this->actor, &play->state); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; Interface_ChangeAlpha(50); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; @@ -416,7 +416,7 @@ s32 EnFsn_TestEndInteraction(EnFsn* this, PlayState* play, Input* input) { s32 EnFsn_TestCancelOption(EnFsn* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->actionFunc = this->tmpActionFunc; + this->actionFunc = this->prevActionFunc; func_80151938(play, this->items[this->cursorIdx]->actor.textId); return true; } @@ -467,7 +467,7 @@ s32 EnFsn_HasPlayerSelectedItem(EnFsn* this, PlayState* play, Input* input) { } if (EnFsn_TestItemSelected(play)) { if (!this->items[this->cursorIdx]->isOutOfStock) { - this->tmpActionFunc = this->actionFunc; + this->prevActionFunc = this->actionFunc; func_80151938(play, this->items[this->cursorIdx]->choiceTextId); play_sound(NA_SE_SY_DECIDE); this->stickLeftPrompt.isEnabled = false; @@ -711,7 +711,7 @@ void EnFsn_InitShop(EnFsn* this, PlayState* play) { this->stickAnimTween = this->arrowAnimTween = 0.0f; } this->blinkTimer = 20; - this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; + this->animationIndex = FSN_ANIM_HANDS_ON_COUNTER_START; this->eyeTextureIdx = 0; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnFsn_Idle; @@ -720,11 +720,11 @@ void EnFsn_InitShop(EnFsn* this, PlayState* play) { void EnFsn_Idle(EnFsn* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (this->animationIndex == FSN_ANIMATION_HANDS_ON_COUNTER_START) { + if (this->animationIndex == FSN_ANIM_HANDS_ON_COUNTER_START) { s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (curFrame == frameCount) { - this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + this->animationIndex = FSN_ANIM_HANDS_ON_COUNTER_LOOP; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } return; @@ -762,24 +762,24 @@ void EnFsn_Haggle(EnFsn* this, PlayState* play) { if (this->flags & ENFSN_ANGRY) { this->flags &= ~ENFSN_ANGRY; - this->animationIndex = FSN_ANIMATION_SLAM_COUNTER_LOOP; + this->animationIndex = FSN_ANIM_SLAM_COUNTER_LOOP; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { - if (this->animationIndex == FSN_ANIMATION_SLAM_COUNTER_LOOP && Animation_OnFrame(&this->skelAnime, 18.0f)) { + if (this->animationIndex == FSN_ANIM_SLAM_COUNTER_LOOP && Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } if (this->flags & ENFSN_CALM_DOWN) { this->flags &= ~ENFSN_CALM_DOWN; - this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + this->animationIndex = FSN_ANIM_HANDS_ON_COUNTER_LOOP; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else if (this->flags & ENFSN_OFFER_FINAL_PRICE) { this->flags &= ~ENFSN_OFFER_FINAL_PRICE; - this->animationIndex = FSN_ANIMATION_MAKE_OFFER; + this->animationIndex = FSN_ANIM_MAKE_OFFER; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { - if (this->animationIndex == FSN_ANIMATION_MAKE_OFFER) { + if (this->animationIndex == FSN_ANIM_MAKE_OFFER) { if (curFrame == frameCount) { - this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + this->animationIndex = FSN_ANIM_HANDS_ON_COUNTER_LOOP; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { if (Animation_OnFrame(&this->skelAnime, 28.0f)) { @@ -822,7 +822,7 @@ void EnFsn_StartBuying(EnFsn* this, PlayState* play) { Player* player = GET_PLAYER(play); EnFsn_HandleLookToShopkeeperBuyingCutscene(this); - if (talkState == 5 && Message_ShouldAdvance(play)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (this->actor.textId) { case 0x29CC: this->actor.textId = 0x29CD; @@ -849,7 +849,7 @@ void EnFsn_StartBuying(EnFsn* this, PlayState* play) { void EnFsn_AskBuyOrSell(EnFsn* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - if (talkState == 5) { + if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { switch (this->actor.textId) { case 0x29CC: @@ -880,7 +880,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, PlayState* play) { break; } } - } else if (talkState == 4) { + } else if (talkState == TEXT_STATE_CHOICE) { func_8011552C(play, 6); if (!EnFsn_TestEndInteraction(this, play, CONTROLLER1(&play->state)) && Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { @@ -919,7 +919,7 @@ void EnFsn_DeterminePrice(EnFsn* this, PlayState* play) { s32 itemActionParam; u8 buttonItem; - if (Message_GetState(&play->msgCtx) == 16) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { itemActionParam = func_80123810(play); if (itemActionParam > PLAYER_AP_NONE) { if (player->heldItemButton == 0) { @@ -955,12 +955,12 @@ void EnFsn_MakeOffer(EnFsn* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); Player* player = GET_PLAYER(play); - if (talkState == 4 && Message_ShouldAdvance(play)) { + if (talkState == TEXT_STATE_CHOICE && Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; @@ -1106,7 +1106,7 @@ void EnFsn_BrowseShelf(EnFsn* this, PlayState* play) { this->drawCursor = 0xFF; this->stickLeftPrompt.isEnabled = true; EnFsn_UpdateCursorPos(this, play); - if (talkstate == 5) { + if (talkstate == TEXT_STATE_5) { func_8011552C(play, 6); if (!EnFsn_HasPlayerSelectedItem(this, play, CONTROLLER1(&play->state))) { EnFsn_CursorLeftRight(this); @@ -1160,7 +1160,7 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, PlayState* play) { item->buyFanfareFunc(play, item); Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; Interface_ChangeAlpha(50); this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; @@ -1191,13 +1191,13 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, PlayState* play) { void EnFsn_SetupEndInteraction(EnFsn* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(play)) { + if (((talkState == TEXT_STATE_5) || (talkState == TEXT_STATE_DONE)) && Message_ShouldAdvance(play)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (play->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, play); } else { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; } } else { EnFsn_EndInteraction(this, play); @@ -1208,7 +1208,7 @@ void EnFsn_SetupEndInteraction(EnFsn* this, PlayState* play) { void EnFsn_SelectItem(EnFsn* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - if (EnFsn_TakeItemOffShelf(this) && talkState == 4) { + if (EnFsn_TakeItemOffShelf(this) && (talkState == TEXT_STATE_CHOICE)) { func_8011552C(play, 6); if (!EnFsn_TestCancelOption(this, play, CONTROLLER1(&play->state)) && Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { @@ -1217,7 +1217,7 @@ void EnFsn_SelectItem(EnFsn* this, PlayState* play) { break; case 1: func_8019F230(); - this->actionFunc = this->tmpActionFunc; + this->actionFunc = this->prevActionFunc; func_80151938(play, this->items[this->cursorIdx]->actor.textId); } } @@ -1225,8 +1225,8 @@ void EnFsn_SelectItem(EnFsn* this, PlayState* play) { } void EnFsn_PlayerCannotBuy(EnFsn* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { - this->actionFunc = this->tmpActionFunc; + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + this->actionFunc = this->prevActionFunc; func_80151938(play, this->items[this->cursorIdx]->actor.textId); } } @@ -1246,7 +1246,7 @@ void EnFsn_AskCanBuyMore(EnFsn* this, PlayState* play) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (talkState == 4) { + if (talkState == TEXT_STATE_CHOICE) { if (Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: @@ -1263,13 +1263,13 @@ void EnFsn_AskCanBuyMore(EnFsn* this, PlayState* play) { break; } } - } else if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(play)) { + } else if (((talkState == TEXT_STATE_5) || (talkState == TEXT_STATE_DONE)) && Message_ShouldAdvance(play)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (play->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, play); } else { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; } } else { EnFsn_EndInteraction(this, play); @@ -1292,7 +1292,7 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, PlayState* play) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (talkState == 4) { + if (talkState == TEXT_STATE_CHOICE) { if (Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: @@ -1310,13 +1310,13 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, PlayState* play) { break; } } - } else if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(play)) { + } else if (((talkState == TEXT_STATE_5) || (talkState == TEXT_STATE_DONE)) && Message_ShouldAdvance(play)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (play->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, play); } else { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; } } else { EnFsn_EndInteraction(this, play); @@ -1328,7 +1328,7 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); u8 cursorIdx; - if (talkState == 4) { + if (talkState == TEXT_STATE_CHOICE) { func_8011552C(play, 6); if (!EnFsn_TestEndInteraction(this, play, CONTROLLER1(&play->state)) && (!Message_ShouldAdvance(play) || !EnFsn_FacingShopkeeperDialogResult(this, play)) && @@ -1342,7 +1342,7 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, PlayState* play) { play_sound(NA_SE_SY_CURSOR); } } - } else if (talkState == 5 && Message_ShouldAdvance(play)) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actor.textId = 0x29D6; Message_StartTextbox(play, this->actor.textId, &this->actor); if (play) {} @@ -1350,7 +1350,7 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, PlayState* play) { } void EnFsn_SetupEndInteractionImmediately(EnFsn* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { EnFsn_EndInteraction(this, play); } } @@ -1366,16 +1366,16 @@ void EnFsn_IdleBackroom(EnFsn* this, PlayState* play) { } void EnFsn_ConverseBackroom(EnFsn* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->flags & ENFSN_END_CONVERSATION) { this->flags &= ~ENFSN_END_CONVERSATION; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = EnFsn_IdleBackroom; } else if (this->flags & ENFSN_GIVE_ITEM) { this->flags &= ~ENFSN_GIVE_ITEM; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = EnFsn_GiveItem; } else { EnFsn_HandleConversationBackroom(this, play); @@ -1430,7 +1430,7 @@ void EnFsn_Init(Actor* thisx, PlayState* play) { this->eyeTextureIdx = 0; this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->animationIndex = FSN_ANIMATION_IDLE; + this->animationIndex = FSN_ANIM_IDLE; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnFsn_IdleBackroom; } diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h index 4fc9372f2..f003a7921 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h @@ -22,7 +22,7 @@ typedef struct EnFsn { /* 0x144 */ UNK_TYPE1 pad144[0x4C]; /* 0x190 */ SkelAnime skelAnime; /* 0x1D4 */ EnFsnActionFunc actionFunc; - /* 0x1D8 */ EnFsnActionFunc tmpActionFunc; // Used to return to correct browsing function + /* 0x1D8 */ EnFsnActionFunc prevActionFunc; // Used to return to correct browsing function /* 0x1DC */ ColliderCylinder collider; /* 0x228 */ s16 limbRotYTable[19]; /* 0x24E */ s16 limbRotZTable[19]; 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 476b09856..1fc17535f 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -430,7 +430,7 @@ void func_80962588(EnFu* this, PlayState* play) { if (play->msgCtx.choiceIndex == 0) { if (gSaveContext.save.playerData.rupees >= 10) { func_8019F208(); - func_801159EC(-10); + Rupees_ChangeBy(-10); func_80963DE4(this, play); } else { play_sound(NA_SE_SY_ERROR); @@ -577,24 +577,24 @@ void func_809628BC(EnFu* this) { } void func_809628D0(EnFu* this, PlayState* play) { - u8 sp27 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); - switch (sp27) { - case 0: - case 1: - case 2: - case 3: + switch (talkState) { + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; - case 4: + case TEXT_STATE_CHOICE: func_80962588(this, play); break; - case 5: + case TEXT_STATE_5: func_80962660(this, play); break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { this->unk_54A = 1; switch (this->unk_552) { @@ -617,7 +617,7 @@ void func_809628D0(EnFu* this, PlayState* play) { break; } - if (sp27 != 3) { + if (talkState != TEXT_STATE_3) { func_80964190(this, play); func_8096426C(this, play); } @@ -840,8 +840,9 @@ void func_80963350(EnFu* this, PlayState* play) { static s32 D_80964C24 = 0; BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; - if ((this->unk_54A == 0) && (((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) || - ((Message_GetState(&play->msgCtx) == 2) && (play->msgCtx.unk12023 == 1)))) { + if ((this->unk_54A == 0) && + (((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) || + ((Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) && (play->msgCtx.stateTimer == 1)))) { func_801477B4(play); this->unk_54A = 2; D_80964C24 = 1; @@ -1162,11 +1163,11 @@ void func_80963F44(EnFu* this, PlayState* play) { void func_80963F88(EnFu* this, PlayState* play) { if (this->unk_542 == 1) { - func_800DFAC8(play->cameraPtrs[CAM_ID_MAIN], 75); + Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_HONEY_AND_DARLING_2); play->unk_1887E = 0; } else if (this->unk_542 == 2) { play->unk_1887D = 0; - func_800DFAC8(play->cameraPtrs[CAM_ID_MAIN], 75); + Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_HONEY_AND_DARLING_2); } } diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.h b/src/overlays/actors/ovl_En_Fu/z_en_fu.h index 76c46181d..9ed3b69c5 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.h +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.h @@ -23,33 +23,33 @@ typedef struct { } EnFuUnkStruct; // size = 0x38 typedef struct EnFu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnFuActionFunc actionFunc; - /* 0x01D8 */ Vec3s jointTable[21]; - /* 0x0256 */ Vec3s morphTable[21]; - /* 0x02D4 */ BgFuMizu* unk_2D4; - /* 0x02D8 */ EnFuUnkStruct unk_2D8[10]; - /* 0x0508 */ Vec3f unk_508; - /* 0x0514 */ Vec3f unk_514; - /* 0x0520 */ s32 unk_520; - /* 0x0524 */ s16 unk_524[3]; - /* 0x052A */ s16 unk_52A[3]; - /* 0x0530 */ char unk530[0x8]; - /* 0x0538 */ Vec3s* unk_538; - /* 0x053C */ s16 unk_53C; - /* 0x053E */ s16 unk_53E; - /* 0x0540 */ s16 unk_540; - /* 0x0542 */ s16 unk_542; - /* 0x0544 */ s16 unk_544; - /* 0x0546 */ s16 unk_546; - /* 0x0548 */ s16 unk_548; - /* 0x054A */ s16 unk_54A; - /* 0x054C */ s16 unk_54C; - /* 0x054E */ s16 unk_54E; - /* 0x0550 */ s16 unk_550; - /* 0x0552 */ u16 unk_552; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnFuActionFunc actionFunc; + /* 0x1D8 */ Vec3s jointTable[21]; + /* 0x256 */ Vec3s morphTable[21]; + /* 0x2D4 */ BgFuMizu* unk_2D4; + /* 0x2D8 */ EnFuUnkStruct unk_2D8[10]; + /* 0x508 */ Vec3f unk_508; + /* 0x514 */ Vec3f unk_514; + /* 0x520 */ s32 unk_520; + /* 0x524 */ s16 unk_524[3]; + /* 0x52A */ s16 unk_52A[3]; + /* 0x530 */ char unk530[0x8]; + /* 0x538 */ Vec3s* unk_538; + /* 0x53C */ s16 unk_53C; + /* 0x53E */ s16 unk_53E; + /* 0x540 */ s16 unk_540; + /* 0x542 */ s16 unk_542; + /* 0x544 */ s16 unk_544; + /* 0x546 */ s16 unk_546; + /* 0x548 */ s16 unk_548; + /* 0x54A */ s16 unk_54A; + /* 0x54C */ s16 unk_54C; + /* 0x54E */ s16 unk_54E; + /* 0x550 */ s16 unk_550; + /* 0x552 */ u16 unk_552; } EnFu; // size = 0x554 extern const ActorInit En_Fu_InitVars; diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c index 6ee121a16..a2fc00b22 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c @@ -7,6 +7,7 @@ #include "z_en_fu_kago.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "overlays/actors/ovl_En_Fu/z_en_fu.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_fu_mato/object_fu_mato.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -221,7 +222,7 @@ void func_80ACFA78(EnFuKago* this, PlayState* play) { } this->dyna.actor.freezeTimer = 2; - EffectSsHahen_SpawnBurst(play, &this->dyna.actor.world.pos, 17.0f, 0, 15, 13, 20, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &this->dyna.actor.world.pos, 17.0f, 0, 15, 13, 20, HAHEN_OBJECT_DEFAULT, 10, NULL); this->unk_338 = 60; this->unk_33A = 1; diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h index fa38ef3d7..909e7b24d 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h @@ -18,13 +18,13 @@ typedef struct { } EnFuKagoStruct; // size = 0x40 typedef struct EnFuKago { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ EnFuKagoActionFunc actionFunc; - /* 0x0160 */ ColliderSphere collider; - /* 0x01B8 */ EnFuKagoStruct unk_1B8[6]; - /* 0x0338 */ s16 unk_338; - /* 0x033A */ s16 unk_33A; - /* 0x033C */ s16 unk_33C; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ EnFuKagoActionFunc actionFunc; + /* 0x160 */ ColliderSphere collider; + /* 0x1B8 */ EnFuKagoStruct unk_1B8[6]; + /* 0x338 */ s16 unk_338; + /* 0x33A */ s16 unk_33A; + /* 0x33C */ s16 unk_33C; } EnFuKago; // size = 0x340 extern const ActorInit En_Fu_Kago_InitVars; diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c index 9fa135314..19aa9dd2a 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c @@ -6,6 +6,7 @@ #include "z_en_fu_mato.h" #include "overlays/actors/ovl_En_Fu/z_en_fu.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_fu_mato/object_fu_mato.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -239,7 +240,7 @@ void func_80ACE850(EnFuMato* this, PlayState* play) { } this->dyna.actor.freezeTimer = 2; - EffectSsHahen_SpawnBurst(play, &this->dyna.actor.world.pos, 13.0f, 0, 7, 8, 20, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &this->dyna.actor.world.pos, 13.0f, 0, 7, 8, 20, HAHEN_OBJECT_DEFAULT, 10, NULL); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODPLATE_BROKEN); this->actionFunc = func_80ACECFC; } diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h index cb3acd4c0..d24ac91d5 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h @@ -19,19 +19,19 @@ typedef struct { } EnFuMatoStruct; // size = 0x34 typedef struct EnFuMato { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ EnFuMatoActionFunc actionFunc; - /* 0x0160 */ ColliderSphere collider; - /* 0x01B8 */ EnFuMatoStruct unk_1B8[6]; - /* 0x02F0 */ s32 unk_2F0; - /* 0x02F4 */ s32 unk_2F4; - /* 0x02F8 */ Vec3s* unk_2F8; - /* 0x02FC */ Vec3s unk_2FC; - /* 0x0302 */ s16 unk_302; - /* 0x0304 */ s16 unk_304; - /* 0x0306 */ UNK_TYPE1 unk306[2]; - /* 0x0308 */ s16 unk_308; - /* 0x030A */ s16 unk_30A; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ EnFuMatoActionFunc actionFunc; + /* 0x160 */ ColliderSphere collider; + /* 0x1B8 */ EnFuMatoStruct unk_1B8[6]; + /* 0x2F0 */ s32 unk_2F0; + /* 0x2F4 */ s32 unk_2F4; + /* 0x2F8 */ Vec3s* unk_2F8; + /* 0x2FC */ Vec3s unk_2FC; + /* 0x302 */ s16 unk_302; + /* 0x304 */ s16 unk_304; + /* 0x306 */ UNK_TYPE1 unk306[2]; + /* 0x308 */ s16 unk_308; + /* 0x30A */ s16 unk_30A; } EnFuMato; // size = 0x30C extern const ActorInit En_Fu_Mato_InitVars; diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c index 696f7c6d9..8c7d883da 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c @@ -207,7 +207,7 @@ void EnGakufu_GiveReward(EnGakufu* this, PlayState* play) { play_sound(NA_SE_SY_CORRECT_CHIME); - hour = gSaveContext.save.time * (24.0f / 0x10000); + hour = gSaveContext.save.time * (24.0f / 0x10000); // TIME_TO_HOURS_F for (i = 0; i < 3; i++) { Item_DropCollectible(play, &sRewardDropsSpawnTerminaFieldPos, sRewardDrops[i + sRewardDropsIndex[hour]]); } diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h index 1b8f94368..c9db31b75 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h @@ -10,8 +10,8 @@ typedef void (*EnGakufuActionFunc)(struct EnGakufu*, PlayState*); #define GAKUFU_GET_TYPE(thisx) ((thisx)->params & 0xF) typedef enum { - /* 0x00 */ GAKUFU_TERMINA_FIELD, - /* 0x01 */ GAKUFU_MILK_BAR + /* 0x0 */ GAKUFU_TERMINA_FIELD, + /* 0x1 */ GAKUFU_MILK_BAR } GakufuType; typedef struct EnGakufu { diff --git a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c index c559e7183..c2c42fa59 100644 --- a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c +++ b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c @@ -5,6 +5,7 @@ */ #include "z_en_gamelupy.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -18,8 +19,10 @@ void EnGamelupy_Draw(Actor* thisx, PlayState* play); void func_80AF6958(EnGamelupy* this, PlayState* play); void func_80AF69A8(EnGamelupy* this, PlayState* play); void func_80AF6A78(EnGamelupy* this, PlayState* play); +void func_80AF6944(EnGamelupy* this); +void func_80AF6994(EnGamelupy* this); +void func_80AF6A38(EnGamelupy* this); -#if 0 const ActorInit En_Gamelupy_InitVars = { ACTOR_EN_GAMELUPY, ACTORCAT_PROP, @@ -32,37 +35,158 @@ const ActorInit En_Gamelupy_InitVars = { (ActorFunc)EnGamelupy_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AF6CF0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 30, 0, { 0, 0, 0 } }, }; -#endif +static TexturePtr sRupeeTex[] = { + gameplay_keep_Tex_061FC0, gameplay_keep_Tex_061FE0, gameplay_keep_Tex_062000, + gameplay_keep_Tex_062040, gameplay_keep_Tex_062020, +}; -extern ColliderCylinderInit D_80AF6CF0; +static Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/EnGamelupy_Init.s") +static Color_RGBA8 sEnvColor = { 100, 200, 0, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/EnGamelupy_Destroy.s") +void EnGamelupy_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnGamelupy* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF6854.s") + Actor_SetScale(&this->actor, 0.03f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); + this->actor.shape.yOffset = 700.0f; + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->actor.gravity = -0.5f; + this->actor.shape.rot.y = Rand_Next(); + this->unk_19C = 0; + this->unk_19E = 0; + this->unk_1A0 = 0x7D0; + if (this->actor.params == 1) { + this->rupeeIndex = 1; + } else { + this->rupeeIndex = 0; + } + func_80AF6944(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF6944.s") +void EnGamelupy_Destroy(Actor* thisx, PlayState* play) { + EnGamelupy* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF6958.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF6994.s") +void func_80AF6854(EnGamelupy* this, PlayState* play) { + Vec3f sp4C; + Vec3f sp40; + Vec3f sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF69A8.s") + sp4C = this->actor.world.pos; + sp30.x = Math_SinS(this->unk_19E) * 3.0f; + sp30.y = 5.5f; + sp30.z = Math_CosS(this->unk_19E) * 3.0f; + sp40.x = -0.05f * sp30.x; + sp40.y = -0.4f; + sp40.z = -0.05f * sp30.z; + EffectSsKirakira_SpawnDispersed(play, &sp4C, &sp30, &sp40, &sPrimColor, &sEnvColor, 3000, 40); + this->unk_19E += this->unk_1A0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF6A38.s") +void func_80AF6944(EnGamelupy* this) { + this->actionFunc = func_80AF6958; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF6A78.s") +void func_80AF6958(EnGamelupy* this, PlayState* play) { + s16* unk_198 = func_800B6680(play, ACTOR_EN_GAMELUPY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/func_80AF6B40.s") + if (unk_198 != NULL) { + this->unk_198 = unk_198; + func_80AF6994(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/EnGamelupy_Update.s") +void func_80AF6994(EnGamelupy* this) { + this->actionFunc = func_80AF69A8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gamelupy/EnGamelupy_Draw.s") +void func_80AF69A8(EnGamelupy* this, PlayState* play) { + if (this->collider.base.ocFlags1 & OC1_HIT) { + *this->unk_198 += 0x32; + if (this->rupeeIndex == 1) { + Rupees_ChangeBy(5); + } else { + Rupees_ChangeBy(1); + } + func_80AF6A38(this); + } + this->actor.shape.rot.y += 0x1F4; +} + +void func_80AF6A38(EnGamelupy* this) { + this->unk_19C = 0; + this->actor.gravity = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_GET_RUPY); + this->actionFunc = func_80AF6A78; +} + +void func_80AF6A78(EnGamelupy* this, PlayState* play) { + f32 scale; + Player* player = GET_PLAYER(play); + + if (this->unk_19C > 30) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_19C++; + this->actor.world.pos = player->actor.world.pos; + this->actor.world.pos.y += 40.0f; + scale = (30.0f - this->unk_19C) * 0.001f; + Actor_SetScale(&this->actor, scale); + func_80AF6854(this, play); + } + this->actor.shape.rot.y += 0x3E8; +} + +void func_80AF6B40(EnGamelupy* this, PlayState* play) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); +} + +void EnGamelupy_Update(Actor* thisx, PlayState* play) { + EnGamelupy* this = THIS; + + this->actionFunc(this, play); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 0.0f, 0xC); + func_80AF6B40(this, play); +} + +void EnGamelupy_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnGamelupy* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + func_800B8050(&this->actor, play, 0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sRupeeTex[this->rupeeIndex])); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.h b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.h index b3737d706..4ee6a5b11 100644 --- a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.h +++ b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.h @@ -8,10 +8,14 @@ struct EnGamelupy; typedef void (*EnGamelupyActionFunc)(struct EnGamelupy*, PlayState*); typedef struct EnGamelupy { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; - /* 0x0190 */ EnGamelupyActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x10]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ EnGamelupyActionFunc actionFunc; + /* 0x194 */ s32 rupeeIndex; + /* 0x198 */ s16* unk_198; + /* 0x19C */ s16 unk_19C; + /* 0x19E */ s16 unk_19E; + /* 0x1A0 */ s16 unk_1A0; } EnGamelupy; // size = 0x1A4 extern const ActorInit En_Gamelupy_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 658ee27f7..03a15ad5b 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -357,16 +357,16 @@ void func_80B0FD8C(EnGb2* this, PlayState* play) { void func_80B0FE18(PlayState* play) { func_800FD750(0x38); play->nextEntranceIndex = 0x9C10; - play->unk_1887F = 0x40; - gSaveContext.nextTransition = 0x40; - play->sceneLoadFlag = 0x14; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_64; + play->transitionTrigger = TRANS_TRIGGER_START; } void func_80B0FE7C(PlayState* play) { play->nextEntranceIndex = 0x9C20; - play->unk_1887F = 0x40; - gSaveContext.nextTransition = 0x40; - play->sceneLoadFlag = 0x14; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_64; + play->transitionTrigger = TRANS_TRIGGER_START; } void func_80B0FEBC(EnGb2* this, PlayState* play) { @@ -386,13 +386,13 @@ void func_80B0FEBC(EnGb2* this, PlayState* play) { } void func_80B0FFA8(EnGb2* this, PlayState* play) { - u8 temp_v0 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 5) { + if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { if (this->unk_26C & 2) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_26E = 0x14D1; this->unk_288 = 30; gSaveContext.eventInf[4] &= (u8)~0x80; @@ -403,7 +403,7 @@ void func_80B0FFA8(EnGb2* this, PlayState* play) { Message_StartTextbox(play, this->unk_26E, &this->actor); } } - } else if ((temp_v0 == 4) && Message_ShouldAdvance(play)) { + } else if ((talkState == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { if (this->unk_26E == 0x14D5) { switch (play->msgCtx.choiceIndex) { case 0: @@ -430,9 +430,9 @@ void func_80B0FFA8(EnGb2* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - func_801159EC(-this->unk_288); + Rupees_ChangeBy(-this->unk_288); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; func_800B7298(play, NULL, 7); this->actionFunc = func_80B11344; break; @@ -548,13 +548,13 @@ void func_80B10584(EnGb2* this, PlayState* play) { } void func_80B10634(EnGb2* this, PlayState* play) { - u8 temp_v0 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 5) { + if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { if (this->unk_26C & 2) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_26C &= ~2; if (this->unk_26E == 0x14DD) { this->unk_26E = 0x14DE; @@ -572,7 +572,7 @@ void func_80B10634(EnGb2* this, PlayState* play) { Message_StartTextbox(play, this->unk_26E, &this->actor); } } - } else if ((temp_v0 == 4) && Message_ShouldAdvance(play)) { + } else if ((talkState == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: if (gSaveContext.save.playerData.rupees < this->unk_288) { @@ -582,9 +582,9 @@ void func_80B10634(EnGb2* this, PlayState* play) { Message_StartTextbox(play, this->unk_26E, &this->actor); } else { func_8019F208(); - func_801159EC(-this->unk_288); + Rupees_ChangeBy(-this->unk_288); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; func_800B7298(play, NULL, 7); this->actionFunc = func_80B11344; } @@ -628,7 +628,7 @@ void func_80B10924(EnGb2* this, PlayState* play) { if (sp24 == 12) { gSaveContext.save.weekEventReg[54] |= 0x40; } else { - func_801159EC(50); + Rupees_ChangeBy(50); } this->actionFunc = func_80B109DC; } else { @@ -746,11 +746,11 @@ void func_80B10DAC(EnGb2* this, PlayState* play) { } void func_80B10E98(EnGb2* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_26C & 2) { this->unk_26C &= ~2; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; if ((this->unk_26E != 0x14E8) && (this->unk_26E != 0x14EA)) { ActorCutscene_Stop(this->unk_282[this->unk_290]); this->actionFunc = func_80B10B5C; @@ -790,10 +790,10 @@ void func_80B11048(EnGb2* this, PlayState* play) { } void func_80B110F8(EnGb2* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_26C & 2) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_26C &= ~2; this->actionFunc = func_80B10A48; } else { diff --git a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h index 23cf30641..a3c04a93a 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h @@ -8,9 +8,9 @@ struct EnGe1; typedef void (*EnGe1ActionFunc)(struct EnGe1*, PlayState*); typedef struct EnGe1 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x184]; - /* 0x02C8 */ EnGe1ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x184]; + /* 0x2C8 */ EnGe1ActionFunc actionFunc; } EnGe1; // size = 0x2CC extern const ActorInit En_Ge1_InitVars; diff --git a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.h b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.h index 5596f0b1e..f0d97869d 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.h +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.h @@ -8,9 +8,9 @@ struct EnGe2; typedef void (*EnGe2ActionFunc)(struct EnGe2*, PlayState*); typedef struct EnGe2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C4]; - /* 0x0308 */ EnGe2ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x1C4]; + /* 0x308 */ EnGe2ActionFunc actionFunc; } EnGe2; // size = 0x30C extern const ActorInit En_Ge2_InitVars; diff --git a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.h b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.h index 018d99a67..10912aae0 100644 --- a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.h +++ b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.h @@ -8,9 +8,9 @@ struct EnGe3; typedef void (*EnGe3ActionFunc)(struct EnGe3*, PlayState*); typedef struct EnGe3 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1D8]; - /* 0x031C */ EnGe3ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x1D8]; + /* 0x31C */ EnGe3ActionFunc actionFunc; } EnGe3; // size = 0x320 extern const ActorInit En_Ge3_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 8ccb969da..b3e98dde3 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -6,6 +6,7 @@ #include "z_en_geg.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.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" @@ -372,12 +373,12 @@ s32 func_80BB1D64(EnGeg* this, PlayState* play) { } void func_80BB1FCC(EnGeg* this, PlayState* play) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[this->unk_248].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->unk_248].segment); SkelAnime_Update(&this->skelAnime); } void func_80BB2020(EnGeg* this, PlayState* play) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[this->unk_248].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->unk_248].segment); SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_4AC); } @@ -542,7 +543,7 @@ void func_80BB2520(EnGeg* this, PlayState* play) { } void func_80BB26EC(EnGeg* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (this->unk_496) { case 0xD5E: this->unk_49A = this->unk_49C[1]; @@ -552,7 +553,7 @@ void func_80BB26EC(EnGeg* this, PlayState* play) { case 0xD61: ActorCutscene_Stop(this->unk_498); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_230 &= ~0x10; this->actionFunc = func_80BB221C; return; @@ -564,18 +565,18 @@ void func_80BB26EC(EnGeg* this, PlayState* play) { } void func_80BB27D4(EnGeg* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (this->unk_496) { case 0xD63: play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80BB221C; break; case 0xD69: this->unk_49A = this->unk_49C[6]; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80BB2520; break; @@ -583,7 +584,7 @@ void func_80BB27D4(EnGeg* this, PlayState* play) { case 0xD6F: case 0xD8A: play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80BB31B8; break; @@ -591,7 +592,7 @@ void func_80BB27D4(EnGeg* this, PlayState* play) { case 0xD75: case 0xD8B: play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_230 &= ~0x10; this->unk_49A = this->unk_49C[7]; this->actionFunc = func_80BB2520; @@ -606,7 +607,7 @@ void func_80BB27D4(EnGeg* this, PlayState* play) { } void func_80BB2944(EnGeg* this, PlayState* play) { - u8 sp27 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); s16 curFrame = this->skelAnime.curFrame; s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_4AC].animation); @@ -615,10 +616,10 @@ void func_80BB2944(EnGeg* this, PlayState* play) { this->unk_4AC = 6; func_80BB2020(this, play); } - } else if ((sp27 == 5) && Message_ShouldAdvance(play)) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_496 == 0xD67) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_49A = this->unk_49C[4]; this->actionFunc = func_80BB2520; } else { @@ -629,13 +630,13 @@ void func_80BB2944(EnGeg* this, PlayState* play) { } void func_80BB2A54(EnGeg* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_496 == 0xD65) { ActorCutscene_Stop(this->unk_498); this->unk_230 &= ~0x10; this->unk_244 = 65; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80BB347C; } else { this->unk_496 = func_80BB16D0(this); @@ -692,8 +693,8 @@ void func_80BB2B1C(EnGeg* this, PlayState* play) { this->unk_4C0[i].x *= temp_f20; this->unk_4C0[i].y *= temp_f20; this->unk_4C0[i].z *= temp_f20; - EffectSsHahen_Spawn(play, &this->unk_4B4, &this->unk_4C0[i], &sp74, 1, sp68, 1, 15, - gameplay_keep_DL_06AB30); + EffectSsHahen_Spawn(play, &this->unk_4B4, &this->unk_4C0[i], &sp74, HAHEN_SMALL, sp68, GAMEPLAY_KEEP, + 15, gameplay_keep_DL_06AB30); } } this->unk_4E0--; diff --git a/src/overlays/actors/ovl_En_Gg/z_en_gg.c b/src/overlays/actors/ovl_En_Gg/z_en_gg.c index 031652d05..7e7c7306e 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -247,10 +247,10 @@ void func_80B35450(EnGg* this, PlayState* play) { } void func_80B3556C(EnGg* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_2E6 == 4) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_308 = 0; this->actor.flags &= ~ACTOR_FLAG_80; func_80B35250(this); diff --git a/src/overlays/actors/ovl_En_Gg/z_en_gg.h b/src/overlays/actors/ovl_En_Gg/z_en_gg.h index 4a0d361c3..421168e99 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.h +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.h @@ -24,37 +24,37 @@ typedef struct EnGgStruct { } EnGgStruct; // size == 0x4C typedef struct EnGg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnGgActionFunc actionFunc; - /* 0x01D8 */ Vec3s unk_1D8; - /* 0x01DE */ Vec3s unk_1DE; - /* 0x01E4 */ Vec3s jointTable[20]; - /* 0x025C */ Vec3s morphTable[20]; - /* 0x02D4 */ UNK_TYPE1 unk_2D4[0x6]; - /* 0x02DA */ u8 unk_2DA; - /* 0x02DB */ u8 unk_2DB; - /* 0x02DC */ s16 unk_2DC; - /* 0x02DE */ UNK_TYPE1 unk2DE[4]; - /* 0x02E2 */ s16 unk_2E2; - /* 0x02E4 */ s16 unk_2E4; - /* 0x02E6 */ s16 unk_2E6; - /* 0x02E8 */ s16 unk_2E8; - /* 0x02EA */ UNK_TYPE1 unk2EA[0x1A]; - /* 0x0304 */ s16 unk_304; - /* 0x0306 */ u8 unk_306; - /* 0x0307 */ u8 unk_307; - /* 0x0308 */ u8 unk_308; - /* 0x0309 */ u8 unk_309; - /* 0x030A */ s16 unk_30A; - /* 0x030C */ UNK_TYPE1 unk30C[4]; - /* 0x0310 */ f32 unk_310; - /* 0x0314 */ UNK_TYPE1 unk314[0xC]; - /* 0x0320 */ Vec3f unk_320; - /* 0x032C */ Vec3f unk_32C; - /* 0x0338 */ Vec3f unk_338; - /* 0x0344 */ EnGgStruct unk_344; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnGgActionFunc actionFunc; + /* 0x1D8 */ Vec3s unk_1D8; + /* 0x1DE */ Vec3s unk_1DE; + /* 0x1E4 */ Vec3s jointTable[20]; + /* 0x25C */ Vec3s morphTable[20]; + /* 0x2D4 */ UNK_TYPE1 unk_2D4[0x6]; + /* 0x2DA */ u8 unk_2DA; + /* 0x2DB */ u8 unk_2DB; + /* 0x2DC */ s16 unk_2DC; + /* 0x2DE */ UNK_TYPE1 unk2DE[4]; + /* 0x2E2 */ s16 unk_2E2; + /* 0x2E4 */ s16 unk_2E4; + /* 0x2E6 */ s16 unk_2E6; + /* 0x2E8 */ s16 unk_2E8; + /* 0x2EA */ UNK_TYPE1 unk2EA[0x1A]; + /* 0x304 */ s16 unk_304; + /* 0x306 */ u8 unk_306; + /* 0x307 */ u8 unk_307; + /* 0x308 */ u8 unk_308; + /* 0x309 */ u8 unk_309; + /* 0x30A */ s16 unk_30A; + /* 0x30C */ UNK_TYPE1 unk30C[4]; + /* 0x310 */ f32 unk_310; + /* 0x314 */ UNK_TYPE1 unk314[0xC]; + /* 0x320 */ Vec3f unk_320; + /* 0x32C */ Vec3f unk_32C; + /* 0x338 */ Vec3f unk_338; + /* 0x344 */ EnGgStruct unk_344; } EnGg; // size = 0x390 extern const ActorInit En_Gg_InitVars; diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c index 51aea1b13..9726a693a 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -172,9 +172,9 @@ void func_80B3B05C(EnGg2* this, PlayState* play) { } void func_80B3B0A0(EnGg2* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_2F0 = 0; this->actionFunc = func_80B3B5D4; } diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h index 9cf825b78..21c1f8441 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h @@ -10,29 +10,29 @@ typedef void (*EnGg2ActionFunc)(struct EnGg2*, PlayState*); #define ENGG2_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) typedef struct EnGg2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ UNK_TYPE1 unk144[0x4C]; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnGg2ActionFunc actionFunc; - /* 0x01D8 */ Path* unk_1D8; - /* 0x01DC */ s32 unk_1DC; - /* 0x01E0 */ Vec3s unk_1E0; - /* 0x01E6 */ Vec3s unk_1E6; - /* 0x01EC */ Vec3s jointTable[20]; - /* 0x0264 */ Vec3s morphTable[20]; - /* 0x02DC */ UNK_TYPE1 unk2DC[0x8]; - /* 0x02E4 */ s16 unk_2E4; - /* 0x02E6 */ UNK_TYPE1 unk2E6[4]; - /* 0x02EA */ s16 unk_2EA; - /* 0x02EC */ s16 unk_2EC; - /* 0x02EE */ s16 unk_2EE; - /* 0x02F0 */ u8 unk_2F0; - /* 0x02F1 */ u8 unk_2F1; - /* 0x02F2 */ s16 unk_2F2; - /* 0x02F4 */ s16 unk_2F4; - /* 0x02F6 */ s16 unk_2F6; - /* 0x02F8 */ UNK_TYPE1 unk2F8[0xC]; - /* 0x0304 */ Vec3f unk_304; + /* 0x000 */ Actor actor; + /* 0x144 */ UNK_TYPE1 unk144[0x4C]; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnGg2ActionFunc actionFunc; + /* 0x1D8 */ Path* unk_1D8; + /* 0x1DC */ s32 unk_1DC; + /* 0x1E0 */ Vec3s unk_1E0; + /* 0x1E6 */ Vec3s unk_1E6; + /* 0x1EC */ Vec3s jointTable[20]; + /* 0x264 */ Vec3s morphTable[20]; + /* 0x2DC */ UNK_TYPE1 unk2DC[0x8]; + /* 0x2E4 */ s16 unk_2E4; + /* 0x2E6 */ UNK_TYPE1 unk2E6[4]; + /* 0x2EA */ s16 unk_2EA; + /* 0x2EC */ s16 unk_2EC; + /* 0x2EE */ s16 unk_2EE; + /* 0x2F0 */ u8 unk_2F0; + /* 0x2F1 */ u8 unk_2F1; + /* 0x2F2 */ s16 unk_2F2; + /* 0x2F4 */ s16 unk_2F4; + /* 0x2F6 */ s16 unk_2F6; + /* 0x2F8 */ UNK_TYPE1 unk2F8[0xC]; + /* 0x304 */ Vec3f unk_304; } EnGg2; // size = 0x310 extern const ActorInit En_Gg2_InitVars; diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.c b/src/overlays/actors/ovl_En_Giant/z_en_giant.c index 31b802531..61eac74f8 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -96,7 +96,7 @@ void EnGiant_ChangeAnimation(EnGiant* this, s16 newAnimationId) { 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, sAnimations[newAnimationId], 1.0f, 0.0f, - Animation_GetLastFrame(&sAnimations[newAnimationId]->common), 2, 10.0f); + Animation_GetLastFrame(&sAnimations[newAnimationId]->common), ANIMMODE_ONCE, 10.0f); } else { Animation_PlayOnce(&this->skelAnime, sAnimations[newAnimationId]); } @@ -193,7 +193,7 @@ void EnGiant_Init(Actor* thisx, PlayState* play) { this->actionFunc = EnGiant_PerformClockTowerSuccessActions; Animation_Change(&this->skelAnime, &gGiantRaisedArmsStartAnim, 0.0f, Animation_GetLastFrame(&gGiantRaisedArmsStartAnim) - 1.0f, - Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), 2, 0.0f); + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), ANIMMODE_ONCE, 0.0f); this->actor.draw = EnGiant_Draw; this->actor.velocity.y = 0.0f; this->actor.terminalVelocity = 0.0f; @@ -204,7 +204,7 @@ void EnGiant_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.32f); this->actionFunc = EnGiant_PlayClockTowerFailureAnimation; Animation_Change(&this->skelAnime, &gGiantStruggleLoopAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGiantStruggleStartAnim), 0, 0.0f); + Animation_GetLastFrame(&gGiantStruggleStartAnim), ANIMMODE_LOOP, 0.0f); this->actor.draw = EnGiant_Draw; this->actor.velocity.y = 0.0f; this->actor.terminalVelocity = 0.0f; @@ -305,7 +305,7 @@ void EnGiant_ChangeAnimationBasedOnCsAction(EnGiant* this) { case GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER: Animation_Change(&this->skelAnime, &gGiantRaisedArmsStartAnim, 0.0f, Animation_GetLastFrame(&gGiantRaisedArmsStartAnim) - 1.0f, - Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), 2, 0.0f); + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), ANIMMODE_ONCE, 0.0f); break; } } 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 b07671a18..585f5df17 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 @@ -357,7 +357,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, PlayState* play) { this->isNewAccount = true; } - func_801159EC((s16)-play->msgCtx.bankRupeesSelected); + Rupees_ChangeBy(-play->msgCtx.bankRupeesSelected); this->previousBankValue = gSaveContext.save.bankRupees & 0xFFFF; gSaveContext.save.bankRupees = ((gSaveContext.save.bankRupees & 0xFFFF) + play->msgCtx.bankRupeesSelected) | @@ -425,7 +425,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, PlayState* play) { (((gSaveContext.save.bankRupees & 0xFFFF) - play->msgCtx.bankRupeesSelected) - this->serviceFee) | (gSaveContext.save.bankRupees & 0xFFFF0000); - func_801159EC(play->msgCtx.bankRupeesSelected); + Rupees_ChangeBy(play->msgCtx.bankRupeesSelected); } } else { func_8019F230(); @@ -472,25 +472,30 @@ void EnGinkoMan_SetupDialogue(EnGinkoMan* this) { void EnGinkoMan_Dialogue(EnGinkoMan* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 2: + case TEXT_STATE_CLOSING: EnGinkoMan_SetupIdle(this); break; - case 4: + + case TEXT_STATE_CHOICE: EnGinkoMan_WaitForDialogueInput(this, play); break; - case 5: + + case TEXT_STATE_5: EnGinkoMan_DepositDialogue(this, play); break; - case 6: + + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { this->isStampChecked = false; EnGinkoMan_SetupIdle(this); } break; - case 14: + + case TEXT_STATE_14: EnGinkoMan_WaitForRupeeCount(this, play); break; - case 0: + + case TEXT_STATE_NONE: default: break; } @@ -547,7 +552,7 @@ void EnGinkoMan_BankAward2(EnGinkoMan* this, PlayState* play) { EnGinkoMan_SetupDialogue(this); } else if (this->curTextId == 0x45D) { // saved up 5000 rupees for HP - if ((Message_GetState(&play->msgCtx) == 6) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { if (!(gSaveContext.save.weekEventReg[59] & 8)) { gSaveContext.save.weekEventReg[59] |= 8; } 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 9d159b416..bc95efecd 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -185,7 +185,7 @@ void EnGirlA_Destroy(Actor* thisx, PlayState* play) { } s32 EnGirlA_CanBuyPotionRed(PlayState* play, EnGirlA* this) { - if (!Interface_HasEmptyBottle()) { + if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { @@ -195,7 +195,7 @@ s32 EnGirlA_CanBuyPotionRed(PlayState* play, EnGirlA* this) { } s32 EnGirlA_CanBuyPotionGreen(PlayState* play, EnGirlA* this) { - if (!Interface_HasEmptyBottle()) { + if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { @@ -208,7 +208,7 @@ s32 EnGirlA_CanBuyPotionBlue(PlayState* play, EnGirlA* this) { if (!(gSaveContext.save.weekEventReg[53] & 8)) { return CANBUY_RESULT_CANNOT_GET_NOW; } - if (!Interface_HasEmptyBottle()) { + if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } if (!(gSaveContext.save.weekEventReg[53] & 0x10)) { @@ -240,14 +240,14 @@ s32 EnGirlA_CanBuyNuts(PlayState* play, EnGirlA* this) { if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } - if (func_80114978(ITEM_NUT) == ITEM_NONE) { + if (Item_CheckObtainability(ITEM_NUT) == ITEM_NONE) { return CANBUY_RESULT_SUCCESS_1; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyShieldHero(PlayState* play, EnGirlA* this) { - if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_NONE) { return CANBUY_RESULT_NO_ROOM; } if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { @@ -263,7 +263,7 @@ s32 EnGirlA_CanBuyStick(PlayState* play, EnGirlA* this) { if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } - if (func_80114978(ITEM_STICK) == ITEM_NONE) { + if (Item_CheckObtainability(ITEM_STICK) == ITEM_NONE) { return CANBUY_RESULT_SUCCESS_1; } return CANBUY_RESULT_SUCCESS_2; @@ -322,7 +322,7 @@ s32 EnGirlA_CanBuyBombchus(PlayState* play, EnGirlA* this) { if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } - if (func_80114978(ITEM_BOMBCHU) == ITEM_NONE) { + if (Item_CheckObtainability(ITEM_BOMBCHU) == ITEM_NONE) { return CANBUY_RESULT_SUCCESS_1; } return CANBUY_RESULT_SUCCESS_2; @@ -356,7 +356,7 @@ s32 EnGirlA_CanBuySword(PlayState* play, EnGirlA* this) { } s32 EnGirlA_CanBuyShieldMirror(PlayState* play, EnGirlA* this) { - if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_NONE) { return CANBUY_RESULT_NO_ROOM; } if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { @@ -366,7 +366,7 @@ s32 EnGirlA_CanBuyShieldMirror(PlayState* play, EnGirlA* this) { } s32 EnGirlA_CanBuyFairy(PlayState* play, EnGirlA* this) { - if (!Interface_HasEmptyBottle()) { + if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { @@ -398,12 +398,12 @@ void EnGirlA_BuyBottleItem(PlayState* play, EnGirlA* this) { Item_Give(play, ITEM_FAIRY); break; } - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } void EnGirlA_BuyArrows(PlayState* play, EnGirlA* this) { - func_80115A14(ITEM_BOW, this->itemParams); - func_801159EC(-play->msgCtx.unk1206C); + Inventory_ChangeAmmo(ITEM_BOW, this->itemParams); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } void EnGirlA_BuyNuts(PlayState* play, EnGirlA* this) { @@ -415,22 +415,22 @@ void EnGirlA_BuyNuts(PlayState* play, EnGirlA* this) { Item_Give(play, ITEM_NUTS_10); break; } - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } void EnGirlA_BuyShieldHero(PlayState* play, EnGirlA* this) { Item_Give(play, ITEM_SHIELD_HERO); - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } void EnGirlA_BuyStick(PlayState* play, EnGirlA* this) { Item_Give(play, ITEM_STICK); - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } void EnGirlA_BuyMaskAllNight(PlayState* play, EnGirlA* this) { Item_Give(play, ITEM_MASK_ALL_NIGHT); - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } void EnGirlA_BuyBombBag(PlayState* play, EnGirlA* this) { @@ -446,14 +446,14 @@ void EnGirlA_BuyBombBag(PlayState* play, EnGirlA* this) { Item_Give(play, ITEM_BOMB_BAG_40); break; } - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } void EnGirlA_BuyBombchus(PlayState* play, EnGirlA* this) { if (this->itemParams == 10) { Item_Give(play, ITEM_BOMBCHUS_10); } - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } void EnGirlA_BuyBombs(PlayState* play, EnGirlA* this) { @@ -471,12 +471,12 @@ void EnGirlA_BuyBombs(PlayState* play, EnGirlA* this) { Item_Give(play, ITEM_BOMBS_30); break; } - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } void EnGirlA_BuyBottle(PlayState* play, EnGirlA* this) { Item_Give(play, ITEM_BOTTLE); - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } void EnGirlA_BuySword(PlayState* play, EnGirlA* this) { @@ -494,17 +494,17 @@ void EnGirlA_BuySword(PlayState* play, EnGirlA* this) { Item_Give(play, ITEM_SWORD_GREAT_FAIRY); break; } - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } void EnGirlA_BuyShieldMirror(PlayState* play, EnGirlA* this) { Item_Give(play, ITEM_SHIELD_MIRROR); - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } -// Fanfare is handled by ovl_en_ossan +// Fanfare is handled by the shopkeeper void EnGirlA_BuyFanfare(PlayState* play, EnGirlA* this) { - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } void EnGirlA_DoNothing(EnGirlA* this, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h index 90cc26ffd..cb48f591d 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h @@ -48,63 +48,63 @@ typedef struct EnGirlA { } EnGirlA; // size = 0x1CC typedef enum { - /* 0 */ CANBUY_RESULT_SUCCESS_1, - /* 1 */ CANBUY_RESULT_SUCCESS_2, - /* 2 */ CANBUY_RESULT_NO_ROOM, - /* 3 */ CANBUY_RESULT_NEED_EMPTY_BOTTLE, - /* 4 */ CANBUY_RESULT_NEED_RUPEES, - /* 5 */ CANBUY_RESULT_CANNOT_GET_NOW, - /* 6 */ CANBUY_RESULT_CANNOT_GET_NOW_2, - /* 7 */ CANBUY_RESULT_NO_ROOM_2, - /* 8 */ CANBUY_RESULT_ALREADY_HAVE, - /* 9 */ CANBUY_RESULT_HAVE_BETTER + /* 0x0 */ CANBUY_RESULT_SUCCESS_1, + /* 0x1 */ CANBUY_RESULT_SUCCESS_2, + /* 0x2 */ CANBUY_RESULT_NO_ROOM, + /* 0x3 */ CANBUY_RESULT_NEED_EMPTY_BOTTLE, + /* 0x4 */ CANBUY_RESULT_NEED_RUPEES, + /* 0x5 */ CANBUY_RESULT_CANNOT_GET_NOW, + /* 0x6 */ CANBUY_RESULT_CANNOT_GET_NOW_2, + /* 0x7 */ CANBUY_RESULT_NO_ROOM_2, + /* 0x8 */ CANBUY_RESULT_ALREADY_HAVE, + /* 0x9 */ CANBUY_RESULT_HAVE_BETTER } EnGirlACanBuyResult; typedef enum { - /* 00 */ SI_POTION_RED_1, - /* 01 */ SI_POTION_GREEN_1, - /* 02 */ SI_POTION_BLUE, - /* 03 */ SI_FAIRY_1, - /* 04 */ SI_ARROWS_LARGE_1, - /* 05 */ SI_POTION_GREEN_2, - /* 06 */ SI_SHIELD_HERO_1, - /* 07 */ SI_STICK_1, - /* 08 */ SI_ARROWS_MEDIUM_1, - /* 09 */ SI_NUTS_1, - /* 10 */ SI_POTION_RED_2, - /* 11 */ SI_FAIRY_2, - /* 12 */ SI_ARROWS_MEDIUM_2, - /* 13 */ SI_ARROWS_LARGE_2, - /* 14 */ SI_POTION_GREEN_3, - /* 15 */ SI_NUTS_2, - /* 16 */ SI_STICK_2, - /* 17 */ SI_SHIELD_HERO_2, - /* 18 */ SI_POTION_RED_3, - /* 19 */ SI_MASK_ALL_NIGHT, - /* 20 */ SI_BOMB_BAG_20_1, - /* 21 */ SI_BOMB_BAG_30_1, - /* 22 */ SI_BOMB_BAG_40, - /* 23 */ SI_BOMB_BAG_20_2, - /* 24 */ SI_BOMB_BAG_30_2, - /* 25 */ SI_BOMBCHU, - /* 26 */ SI_BOMB_1, - /* 27 */ SI_SHIELD_HERO_3, - /* 28 */ SI_ARROWS_SMALL_1, - /* 29 */ SI_POTION_RED_4, - /* 30 */ SI_BOMB_2, - /* 31 */ SI_ARROWS_SMALL_2, - /* 32 */ SI_POTION_RED_5, - /* 33 */ SI_BOMB_3, - /* 34 */ SI_ARROWS_SMALL_3, - /* 35 */ SI_POTION_RED_6, - /* 36 */ SI_BOTTLE, - /* 37 */ SI_SWORD_GREAT_FAIRY, - /* 38 */ SI_SWORD_KOKIRI, - /* 39 */ SI_SWORD_RAZOR, - /* 40 */ SI_SWORD_GILDED, - /* 41 */ SI_SHIELD_HERO_4, - /* 42 */ SI_SHIELD_MIRROR, - /* 43 */ SI_MAX + /* 0x00 */ SI_POTION_RED_1, + /* 0x01 */ SI_POTION_GREEN_1, + /* 0x02 */ SI_POTION_BLUE, + /* 0x03 */ SI_FAIRY_1, + /* 0x04 */ SI_ARROWS_LARGE_1, + /* 0x05 */ SI_POTION_GREEN_2, + /* 0x06 */ SI_SHIELD_HERO_1, + /* 0x07 */ SI_STICK_1, + /* 0x08 */ SI_ARROWS_MEDIUM_1, + /* 0x09 */ SI_NUTS_1, + /* 0x0A */ SI_POTION_RED_2, + /* 0x0B */ SI_FAIRY_2, + /* 0x0C */ SI_ARROWS_MEDIUM_2, + /* 0x0D */ SI_ARROWS_LARGE_2, + /* 0x0E */ SI_POTION_GREEN_3, + /* 0x0F */ SI_NUTS_2, + /* 0x10 */ SI_STICK_2, + /* 0x11 */ SI_SHIELD_HERO_2, + /* 0x12 */ SI_POTION_RED_3, + /* 0x13 */ SI_MASK_ALL_NIGHT, + /* 0x14 */ SI_BOMB_BAG_20_1, + /* 0x15 */ SI_BOMB_BAG_30_1, + /* 0x16 */ SI_BOMB_BAG_40, + /* 0x17 */ SI_BOMB_BAG_20_2, + /* 0x18 */ SI_BOMB_BAG_30_2, + /* 0x19 */ SI_BOMBCHU, + /* 0x1A */ SI_BOMB_1, + /* 0x1B */ SI_SHIELD_HERO_3, + /* 0x1C */ SI_ARROWS_SMALL_1, + /* 0x1D */ SI_POTION_RED_4, + /* 0x1E */ SI_BOMB_2, + /* 0x1F */ SI_ARROWS_SMALL_2, + /* 0x20 */ SI_POTION_RED_5, + /* 0x21 */ SI_BOMB_3, + /* 0x22 */ SI_ARROWS_SMALL_3, + /* 0x23 */ SI_POTION_RED_6, + /* 0x24 */ SI_BOTTLE, + /* 0x25 */ SI_SWORD_GREAT_FAIRY, + /* 0x26 */ SI_SWORD_KOKIRI, + /* 0x27 */ SI_SWORD_RAZOR, + /* 0x28 */ SI_SWORD_GILDED, + /* 0x29 */ SI_SHIELD_HERO_4, + /* 0x2A */ SI_SHIELD_MIRROR, + /* 0x2B */ SI_MAX } EnGirlAShopItemId; extern const ActorInit En_GirlA_InitVars; @@ -127,8 +127,8 @@ typedef struct { } StickDirectionPrompt; // size = 0x38 typedef struct ShopItem { - /* 0x00 */ s16 shopItemId; - /* 0x02 */ Vec3s spawnPos; -} ShopItem; // size = 0x8; + /* 0x0 */ s16 shopItemId; + /* 0x2 */ Vec3s spawnPos; +} ShopItem; // size = 0x8 #endif // Z_EN_GIRLA_H diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.c b/src/overlays/actors/ovl_En_Gk/z_en_gk.c index 8f5274860..2ab7b2694 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -168,7 +168,7 @@ u16 func_80B50410(EnGk* this, PlayState* play) { if (player->transformation == PLAYER_FORM_GORON) { if (!(gSaveContext.save.weekEventReg[41] & 4)) { if (this->unk_31C == 0xE88) { - if (!(gSaveContext.save.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { + if (!(gSaveContext.save.weekEventReg[41] & 8) || Inventory_HasEmptyBottle()) { return 0xE89; } gSaveContext.save.weekEventReg[41] |= 4; @@ -179,7 +179,7 @@ u16 func_80B50410(EnGk* this, PlayState* play) { } if ((this->unk_31C == 0xE8D) || (this->unk_31C == 0xE98)) { - if (!(gSaveContext.save.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { + if (!(gSaveContext.save.weekEventReg[41] & 8) || Inventory_HasEmptyBottle()) { return 0xE89; } gSaveContext.save.weekEventReg[41] |= 4; @@ -456,9 +456,6 @@ s32 func_80B5100C(EnGk* this, PlayState* play) { } s32 func_80B5123C(EnGk* this, PlayState* play) { - s16 temp_v0; - s16 phi_v1; - if (DECR(this->unk_34E) != 0) { this->unk_31E = 0; this->unk_320 = 0; @@ -660,9 +657,9 @@ void func_80B51760(EnGk* this, PlayState* play) { } void func_80B51970(EnGk* this, PlayState* play) { - u8 temp_v0 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); - if (((temp_v0 == 6) || (temp_v0 == 5)) && Message_ShouldAdvance(play)) { + if (((talkState == TEXT_STATE_DONE) || (talkState == TEXT_STATE_5)) && Message_ShouldAdvance(play)) { if ((this->unk_31C == 0xE84) || (this->unk_31C == 0xE99)) { ActorCutscene_Stop(this->unk_318); this->unk_318 = ActorCutscene_GetAdditionalCutscene(this->unk_318); @@ -710,9 +707,9 @@ void func_80B51970(EnGk* this, PlayState* play) { } void func_80B51B40(EnGk* this, PlayState* play) { - u8 temp_v0 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 6) { + if (talkState == TEXT_STATE_DONE) { if (Message_ShouldAdvance(play)) { if (this->unk_1E4 & 1) { this->unk_1E4 &= ~1; @@ -724,9 +721,9 @@ void func_80B51B40(EnGk* this, PlayState* play) { if (this->unk_31C == 0xE8F) { play->nextEntranceIndex = 0xD010; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; Parameter_AddMagic(play, ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); } else { @@ -741,7 +738,7 @@ void func_80B51B40(EnGk* this, PlayState* play) { this->unk_1E4 |= 2; } } - } else if ((temp_v0 == 4) && Message_ShouldAdvance(play)) { + } else if ((talkState == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -873,9 +870,9 @@ void func_80B5202C(EnGk* this, PlayState* play) { } void func_80B5216C(EnGk* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80B51698; } } @@ -928,7 +925,7 @@ void func_80B52340(EnGk* this, PlayState* play) { } void func_80B52430(EnGk* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 6) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { switch (this->unk_31C) { case 0xE93: this->unk_31C = 0xE89; @@ -1027,7 +1024,7 @@ void EnGk_Init(Actor* thisx, PlayState* play) { Actor_MarkForDeath(&this->actor); } else { this->unk_318 = this->actor.cutscene; - this->path = SubS_GetPathByIndex(play, ENGK_GET_F0(&this->actor), 15); + this->path = SubS_GetPathByIndex(play, ENGK_GET_F0(&this->actor), 0xF); this->actionFunc = func_80B51760; } } else if (play->sceneNum == SCENE_GORONRACE) { @@ -1159,7 +1156,7 @@ void EnGk_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, } } -void EnGk_TransformDraw(PlayState* play, s32 limbIndex, Actor* thisx) { +void EnGk_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnGk* this = THIS; s32 phi_v0; s32 phi_v1; @@ -1257,7 +1254,7 @@ void EnGk_Draw(Actor* thisx, PlayState* play) { SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGk_OverrideLimbDraw, EnGk_PostLimbDraw, - EnGk_TransformDraw, &this->actor); + EnGk_TransformLimbDraw, &this->actor); if (ENGK_GET_F(&this->actor) != ENGK_F_2) { func_8012C2DC(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.h b/src/overlays/actors/ovl_En_Gk/z_en_gk.h index d61157cca..61610d684 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.h +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.h @@ -21,39 +21,39 @@ enum { }; typedef struct EnGk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnGkActionFunc actionFunc; - /* 0x01D8 */ Vec3s unk_1D8; - /* 0x01DE */ Vec3s unk_1DE; - /* 0x01E4 */ u16 unk_1E4; - /* 0x01E8 */ Path* path; - /* 0x01EC */ s32 unk_1EC; - /* 0x01F0 */ Vec3s jointTable[20]; - /* 0x01F0 */ Vec3s morphTable[20]; - /* 0x02E0 */ s16 unk_2E0; - /* 0x02E2 */ s16 unk_2E2; - /* 0x02E4 */ s16 unk_2E4; - /* 0x02E8 */ Vec3f unk_2E8; - /* 0x02F4 */ Vec3f unk_2F4; - /* 0x0300 */ Vec3f unk_300; - /* 0x030C */ Vec3f unk_30C; - /* 0x0318 */ s16 unk_318; - /* 0x031A */ u8 unk_31A; - /* 0x031B */ u8 unk_31B; - /* 0x031C */ u16 unk_31C; - /* 0x031E */ s16 unk_31E; - /* 0x0320 */ s16 unk_320; - /* 0x0322 */ s16 unk_322; - /* 0x0324 */ s16 unk_324; - /* 0x0328 */ Vec3f unk_328; - /* 0x0334 */ Vec3s unk_334; - /* 0x033C */ Vec3f unk_33C; - /* 0x0348 */ Vec3s unk_348; - /* 0x034E */ s16 unk_34E; - /* 0x0350 */ s16 unk_350; - /* 0x0354 */ f32 unk_354; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnGkActionFunc actionFunc; + /* 0x1D8 */ Vec3s unk_1D8; + /* 0x1DE */ Vec3s unk_1DE; + /* 0x1E4 */ u16 unk_1E4; + /* 0x1E8 */ Path* path; + /* 0x1EC */ s32 unk_1EC; + /* 0x1F0 */ Vec3s jointTable[20]; + /* 0x1F0 */ Vec3s morphTable[20]; + /* 0x2E0 */ s16 unk_2E0; + /* 0x2E2 */ s16 unk_2E2; + /* 0x2E4 */ s16 unk_2E4; + /* 0x2E8 */ Vec3f unk_2E8; + /* 0x2F4 */ Vec3f unk_2F4; + /* 0x300 */ Vec3f unk_300; + /* 0x30C */ Vec3f unk_30C; + /* 0x318 */ s16 unk_318; + /* 0x31A */ u8 unk_31A; + /* 0x31B */ u8 unk_31B; + /* 0x31C */ u16 unk_31C; + /* 0x31E */ s16 unk_31E; + /* 0x320 */ s16 unk_320; + /* 0x322 */ s16 unk_322; + /* 0x324 */ s16 unk_324; + /* 0x328 */ Vec3f unk_328; + /* 0x334 */ Vec3s unk_334; + /* 0x33C */ Vec3f unk_33C; + /* 0x348 */ Vec3s unk_348; + /* 0x34E */ s16 unk_34E; + /* 0x350 */ s16 unk_350; + /* 0x354 */ f32 unk_354; } EnGk; // size = 0x358 extern const ActorInit En_Gk_InitVars; diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index a23e5f784..0a49db1d1 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -466,7 +466,7 @@ s32 func_8094E52C(EnGm* this, PlayState* play) { if (!(gSaveContext.save.weekEventReg[86] & 0x40) && (this->unk_3E0 == 2)) { ActorCutscene_Stop(sp2A); } else { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); } this->unk_3E0++; ret = true; @@ -474,7 +474,7 @@ s32 func_8094E52C(EnGm* this, PlayState* play) { case 1: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), this->actor.child); } this->unk_3E0++; ret = true; @@ -491,7 +491,7 @@ s32 func_8094E52C(EnGm* this, PlayState* play) { } s32 func_8094E69C(EnGm* this, PlayState* play) { - Camera* camera; + Camera* subCam; s16 sp4A = func_8094E4D0(this, 0); s16 sp48; Vec3f sp3C; @@ -533,8 +533,8 @@ s32 func_8094E69C(EnGm* this, PlayState* play) { if (func_8094E454(this, sp4A)) { case 4: case 6: - camera = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(sp4A)); - Camera_SetTargetActor(camera, &this->actor); + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp4A)); + Camera_SetTargetActor(subCam, &this->actor); this->unk_3E0++; ret = true; } @@ -544,8 +544,8 @@ s32 func_8094E69C(EnGm* this, PlayState* play) { case 5: case 7: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - camera = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(sp4A)); - Camera_SetTargetActor(camera, this->actor.child); + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp4A)); + Camera_SetTargetActor(subCam, this->actor.child); } this->unk_3E0++; ret = true; @@ -857,11 +857,11 @@ void func_8094F2E8(EnGm* this) { void func_8094F3D0(EnGm* this, PlayState* play) { Player* player = GET_PLAYER(play); - s32 sp28 = Message_GetState(&play->msgCtx); - s32 var = play->msgCtx.currentTextId; + s32 talkState = Message_GetState(&play->msgCtx); + s32 textId = play->msgCtx.currentTextId; - if ((&this->actor == player->targetActor) && ((var < 0xFF) || (var > 0x200)) && (sp28 == 3) && - (this->unk_3F0 == 3)) { + if ((&this->actor == player->targetActor) && ((textId < 0xFF) || (textId > 0x200)) && (talkState == TEXT_STATE_3) && + (this->prevTalkState == TEXT_STATE_3)) { if ((play->state.frames % 3) == 0) { if (this->unk_3AC == 120.0f) { this->unk_3AC = 0.0f; @@ -872,9 +872,10 @@ void func_8094F3D0(EnGm* this, PlayState* play) { } else { this->unk_3AC = 0.0f; } + Math_SmoothStepToF(&this->unk_3B0, this->unk_3AC, 0.8f, 40.0f, 10.0f); Matrix_Translate(this->unk_3B0, 0.0f, 0.0f, MTXMODE_APPLY); - this->unk_3F0 = sp28; + this->prevTalkState = talkState; } s32 func_8094F4EC(EnGm* this, PlayState* play) { @@ -969,7 +970,7 @@ s32 func_8094F53C(EnGm* this, PlayState* play) { return false; } -s32 func_8094F7D0(EnGm* this, PlayState* play, ScheduleResult* arg2, u8 arg3, s16 arg4) { +s32 func_8094F7D0(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput, u8 arg3, s16 arg4) { u8 sp4F = ENGM_GET_FF(&this->actor); Vec3s* sp48; Vec3f sp3C; @@ -981,8 +982,8 @@ s32 func_8094F7D0(EnGm* this, PlayState* play, ScheduleResult* arg2, u8 arg3, s1 this->timePath = NULL; actor = func_8094DEE0(this, play, arg3, arg4); - if (D_80951A0C[arg2->result] >= 0) { - this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80951A0C[arg2->result]); + if (D_80951A0C[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80951A0C[scheduleOutput->result]); } if ((actor != NULL) && (actor->update != NULL)) { @@ -999,7 +1000,7 @@ s32 func_8094F7D0(EnGm* this, PlayState* play, ScheduleResult* arg2, u8 arg3, s1 return ret; } -s32 func_8094F904(EnGm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_8094F904(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = ENGM_GET_FF(&this->actor); EnDoor* door; @@ -1010,10 +1011,10 @@ s32 func_8094F904(EnGm* this, PlayState* play, ScheduleResult* arg2) { s32 ret = false; this->timePath = NULL; - door = func_8094DF90(play, arg2->result); + door = func_8094DF90(play, scheduleOutput->result); - if (D_80951A0C[arg2->result] >= 0) { - this->timePath = SubS_GetAdditionalPath(play, sp55, D_80951A0C[arg2->result]); + if (D_80951A0C[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp55, D_80951A0C[scheduleOutput->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -1032,8 +1033,8 @@ s32 func_8094F904(EnGm* this, PlayState* play, ScheduleResult* arg2) { this->unk_261 = 75; } - this->unk_3B8 = arg2->time1 - arg2->time0; - this->unk_3BA = sp56 - arg2->time0; + this->unk_3B8 = scheduleOutput->time1 - scheduleOutput->time0; + this->unk_3BA = sp56 - scheduleOutput->time0; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; @@ -1045,16 +1046,17 @@ s32 func_8094F904(EnGm* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_8094FAC4(EnGm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_8094FAC4(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENGM_GET_FF(&this->actor); - s32 pad; + u16 tmp; + s16 pad; s32 ret = false; this->timePath = NULL; - if (D_80951A0C[arg2->result] >= 0) { - this->timePath = SubS_GetAdditionalPath(play, sp2B, D_80951A0C[arg2->result]); + if (D_80951A0C[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp2B, D_80951A0C[scheduleOutput->result]); } if ((this->timePath != NULL) && (this->timePath->count < 3)) { @@ -1065,18 +1067,18 @@ s32 func_8094FAC4(EnGm* this, PlayState* play, ScheduleResult* arg2) { if ((this->unk_258 < 9) && (this->unk_258 != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->time0; + phi_v1 = scheduleOutput->time0; } - if (arg2->time1 < phi_v1) { - this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; + if (scheduleOutput->time1 < phi_v1) { + this->timePathTotalTime = (phi_v1 - scheduleOutput->time1) + 0xFFFF; } else { - this->timePathTotalTime = arg2->time1 - phi_v1; + this->timePathTotalTime = scheduleOutput->time1 - phi_v1; } this->timePathElapsedTime = sp2E - phi_v1; - phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); - this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + tmp = phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / tmp; this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3A4 &= ~0x8; @@ -1091,11 +1093,11 @@ s32 func_8094FAC4(EnGm* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_8094FCC4(EnGm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_8094FCC4(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951D90 = { 64.0f, 0.0f, -122.0f }; s32 ret = false; - if (func_8094F7D0(this, play, arg2, ACTORCAT_NPC, ACTOR_EN_TAB)) { + if (func_8094F7D0(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_TAB)) { if (this->unk_258 == 0) { Math_Vec3f_Copy(&this->actor.world.pos, &D_80951D90); SubS_UpdateFlags(&this->unk_3A4, 3, 7); @@ -1111,10 +1113,10 @@ s32 func_8094FCC4(EnGm* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_8094FD88(EnGm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_8094FD88(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; - if (func_8094F7D0(this, play, arg2, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL)) { + if (func_8094F7D0(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL)) { func_8094E054(this, play, 11); SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= 0x100; @@ -1124,12 +1126,13 @@ s32 func_8094FD88(EnGm* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_8094FE10(EnGm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_8094FE10(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; Actor* al; al = func_8094DEE0(this, play, ACTORCAT_NPC, ACTOR_EN_AL); - if (func_8094F7D0(this, play, arg2, ACTORCAT_NPC, ACTOR_EN_TOTO) && (al != NULL) && (al->update != NULL)) { + if (func_8094F7D0(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_TOTO) && (al != NULL) && + (al->update != NULL)) { func_8094E054(this, play, 11); SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_268 = al; @@ -1145,7 +1148,7 @@ s32 func_8094FE10(EnGm* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_8094FF04(EnGm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_8094FF04(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951D9C = { 64.0f, 0.0f, -122.0f }; u8 sp4F = ENGM_GET_FF(&this->actor); Vec3s* sp48; @@ -1156,8 +1159,8 @@ s32 func_8094FF04(EnGm* this, PlayState* play, ScheduleResult* arg2) { this->timePath = NULL; - if (D_80951A0C[arg2->result] >= 0) { - this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80951A0C[arg2->result]); + if (D_80951A0C[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80951A0C[scheduleOutput->result]); } if (this->timePath != NULL) { @@ -1187,7 +1190,7 @@ s32 func_8094FF04(EnGm* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80950088(EnGm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80950088(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951DA8 = { 278.0f, 0.0f, 223.0f }; static Vec3s D_80951DB4 = { 0x0000, 0xC000, 0x0000 }; s32 pad; @@ -1202,7 +1205,7 @@ s32 func_80950088(EnGm* this, PlayState* play, ScheduleResult* arg2) { return true; } -s32 func_80950120(EnGm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80950120(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951DBC = { -525.0f, 214.0f, 515.0f }; static Vec3s D_80951DC8 = { 0x0000, 0x38E0, 0x0000 }; s32 pad; @@ -1217,7 +1220,7 @@ s32 func_80950120(EnGm* this, PlayState* play, ScheduleResult* arg2) { return true; } -s32 func_809501B8(EnGm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_809501B8(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951DD0 = { -334.0f, 225.0f, 903.0f }; static Vec3s D_80951DDC = { 0x0000, 0x7FFF, 0x0000 }; s32 pad; @@ -1238,7 +1241,7 @@ s32 func_809501B8(EnGm* this, PlayState* play, ScheduleResult* arg2) { return true; } -s32 func_80950280(EnGm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80950280(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 phi_v1; this->actor.flags |= ACTOR_FLAG_1; @@ -1249,33 +1252,33 @@ s32 func_80950280(EnGm* this, PlayState* play, ScheduleResult* arg2) { this->unk_3CC = 8; this->unk_3B4 = 40.0f; - switch (arg2->result) { + switch (scheduleOutput->result) { case 1: - phi_v1 = func_8094FD88(this, play, arg2); + phi_v1 = func_8094FD88(this, play, scheduleOutput); break; case 2: - phi_v1 = func_8094FE10(this, play, arg2); + phi_v1 = func_8094FE10(this, play, scheduleOutput); break; case 3: - phi_v1 = func_8094FCC4(this, play, arg2); + phi_v1 = func_8094FCC4(this, play, scheduleOutput); break; case 5: - phi_v1 = func_8094FF04(this, play, arg2); + phi_v1 = func_8094FF04(this, play, scheduleOutput); break; case 6: - phi_v1 = func_80950088(this, play, arg2); + phi_v1 = func_80950088(this, play, scheduleOutput); break; case 7: - phi_v1 = func_809501B8(this, play, arg2); + phi_v1 = func_809501B8(this, play, scheduleOutput); break; case 8: - phi_v1 = func_80950120(this, play, arg2); + phi_v1 = func_80950120(this, play, scheduleOutput); break; case 9: @@ -1290,7 +1293,7 @@ s32 func_80950280(EnGm* this, PlayState* play, ScheduleResult* arg2) { case 18: case 19: case 20: - phi_v1 = func_8094F904(this, play, arg2); + phi_v1 = func_8094F904(this, play, scheduleOutput); break; case 21: @@ -1303,7 +1306,7 @@ s32 func_80950280(EnGm* this, PlayState* play, ScheduleResult* arg2) { case 28: case 29: case 30: - phi_v1 = func_8094FAC4(this, play, arg2); + phi_v1 = func_8094FAC4(this, play, scheduleOutput); break; default: @@ -1576,7 +1579,7 @@ void func_80950C24(EnGm* this, PlayState* play) { } void func_80950CDC(EnGm* this, PlayState* play) { - ScheduleResult sp20; + ScheduleOutput sp20; this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.h b/src/overlays/actors/ovl_En_Gm/z_en_gm.h index ef70131ad..0f74de16b 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.h +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.h @@ -12,68 +12,68 @@ typedef void (*EnGmUnkFunc2)(struct EnGm*, PlayState*); #define ENGM_GET_FF(thisx) ((thisx)->params & 0xFF) typedef struct EnGm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnGmActionFunc actionFunc; - /* 0x018C */ EnGmUnkFunc2 unk_18C; - /* 0x0190 */ ColliderCylinder colliderCylinder; - /* 0x01DC */ ColliderSphere colliderSphere; - /* 0x0234 */ Path* timePath; - /* 0x0238 */ Vec3f timePathTargetPos; - /* 0x0244 */ f32 timePathProgress; - /* 0x0248 */ s32 timePathTotalTime; - /* 0x024C */ s32 timePathWaypointTime; - /* 0x0250 */ s32 timePathWaypoint; - /* 0x0254 */ s32 timePathElapsedTime; - /* 0x0258 */ u8 unk_258; - /* 0x0259 */ u8 unk_259; - /* 0x025C */ s32 unk_25C; - /* 0x0260 */ s8 unk_260; - /* 0x0261 */ s8 unk_261; - /* 0x0262 */ s8 unk_262; - /* 0x0264 */ s32* unk_264; - /* 0x0268 */ Actor* unk_268; - /* 0x026C */ UNK_TYPE1 unk26C[0xC]; - /* 0x0278 */ Vec3f unk_278; - /* 0x0284 */ Vec3f unk_284; - /* 0x0290 */ Vec3f unk_290; - /* 0x029C */ Vec3f unk_29C; - /* 0x02A8 */ Vec3s unk_2A8; - /* 0x02AE */ Vec3s unk_2AE; - /* 0x02B4 */ Vec3s jointTable[20]; - /* 0x032C */ Vec3s morphTable[20]; - /* 0x03A4 */ u16 unk_3A4; - /* 0x03A6 */ u16 unk_3A6; - /* 0x03A8 */ f32 unk_3A8; - /* 0x03AC */ f32 unk_3AC; - /* 0x03B0 */ f32 unk_3B0; - /* 0x03B4 */ f32 unk_3B4; - /* 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 timePathTimeSpeed; - /* 0x03C6 */ s16 unk_3C6; - /* 0x03C8 */ s16 unk_3C8; - /* 0x03CA */ s16 unk_3CA; - /* 0x03CC */ s16 unk_3CC; - /* 0x03CE */ s16 unk_3CE; - /* 0x03D0 */ s16 unk_3D0; - /* 0x03D2 */ s16 unk_3D2[3]; - /* 0x03D8 */ s16 unk_3D8[3]; - /* 0x03DE */ s16 unk_3DE; - /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 unk_3E2; - /* 0x03E4 */ EnGmUnkFunc unk_3E4; - /* 0x03E8 */ s32 unk_3E8; - /* 0x03EC */ UNK_TYPE1 unk3EC[0x4]; - /* 0x03F0 */ s32 unk_3F0; - /* 0x03F4 */ s32 unk_3F4; - /* 0x03F8 */ s32 unk_3F8; - /* 0x03FC */ s32 unk_3FC; - /* 0x0400 */ s32 unk_400; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnGmActionFunc actionFunc; + /* 0x18C */ EnGmUnkFunc2 unk_18C; + /* 0x190 */ ColliderCylinder colliderCylinder; + /* 0x1DC */ ColliderSphere colliderSphere; + /* 0x234 */ Path* timePath; + /* 0x238 */ Vec3f timePathTargetPos; + /* 0x244 */ f32 timePathProgress; + /* 0x248 */ s32 timePathTotalTime; + /* 0x24C */ s32 timePathWaypointTime; + /* 0x250 */ s32 timePathWaypoint; + /* 0x254 */ s32 timePathElapsedTime; + /* 0x258 */ u8 unk_258; + /* 0x259 */ u8 unk_259; + /* 0x25C */ s32 unk_25C; + /* 0x260 */ s8 unk_260; + /* 0x261 */ s8 unk_261; + /* 0x262 */ s8 unk_262; + /* 0x264 */ s32* unk_264; + /* 0x268 */ Actor* unk_268; + /* 0x26C */ UNK_TYPE1 unk_26C[0xC]; + /* 0x278 */ Vec3f unk_278; + /* 0x284 */ Vec3f unk_284; + /* 0x290 */ Vec3f unk_290; + /* 0x29C */ Vec3f unk_29C; + /* 0x2A8 */ Vec3s unk_2A8; + /* 0x2AE */ Vec3s unk_2AE; + /* 0x2B4 */ Vec3s jointTable[20]; + /* 0x32C */ Vec3s morphTable[20]; + /* 0x3A4 */ u16 unk_3A4; + /* 0x3A6 */ u16 unk_3A6; + /* 0x3A8 */ f32 unk_3A8; + /* 0x3AC */ f32 unk_3AC; + /* 0x3B0 */ f32 unk_3B0; + /* 0x3B4 */ f32 unk_3B4; + /* 0x3B8 */ s16 unk_3B8; + /* 0x3BA */ s16 unk_3BA; + /* 0x3BC */ s16 unk_3BC; + /* 0x3BE */ s16 unk_3BE; + /* 0x3C0 */ s16 unk_3C0; + /* 0x3C2 */ s16 unk_3C2; + /* 0x3C4 */ s16 timePathTimeSpeed; + /* 0x3C6 */ s16 unk_3C6; + /* 0x3C8 */ s16 unk_3C8; + /* 0x3CA */ s16 unk_3CA; + /* 0x3CC */ s16 unk_3CC; + /* 0x3CE */ s16 unk_3CE; + /* 0x3D0 */ s16 unk_3D0; + /* 0x3D2 */ s16 unk_3D2[3]; + /* 0x3D8 */ s16 unk_3D8[3]; + /* 0x3DE */ s16 unk_3DE; + /* 0x3E0 */ s16 unk_3E0; + /* 0x3E2 */ s16 unk_3E2; + /* 0x3E4 */ EnGmUnkFunc unk_3E4; + /* 0x3E8 */ s32 unk_3E8; + /* 0x3EC */ UNK_TYPE1 unk3EC[0x4]; + /* 0x3F0 */ s32 prevTalkState; + /* 0x3F4 */ s32 unk_3F4; + /* 0x3F8 */ s32 unk_3F8; + /* 0x3FC */ s32 unk_3FC; + /* 0x400 */ s32 unk_400; } EnGm; // size = 0x404 extern const ActorInit En_Gm_InitVars; 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 cb2c96cc5..8bd09d36f 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -744,10 +744,10 @@ s32 func_80A12A64(EnGo* this, PlayState* play) { } if (objIdx2 >= 0) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[objIdx2].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objIdx2].segment); this->skelAnime.playSpeed = this->unk_398; ret = SkelAnime_Update(&this->skelAnime); - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[objIdx].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objIdx].segment); } return ret; @@ -790,11 +790,11 @@ s32 func_80A12C48(EnGo* this, PlayState* play, s32 arg2) { } if (objIdx2 >= 0) { - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[objIdx2].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objIdx2].segment); this->unk_3DC = arg2; ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); this->unk_398 = this->skelAnime.playSpeed; - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[objIdx].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objIdx].segment); } return ret; @@ -1195,19 +1195,19 @@ s32 func_80A13B1C(EnGo* this, PlayState* play) { this->unk_3C0++; if (this->unk_3C0 >= 65) { switch (player->transformation) { - case 4: + case PLAYER_FORM_HUMAN: gSaveContext.save.weekEventReg[88] |= 0x80; break; - case 1: + case PLAYER_FORM_GORON: gSaveContext.save.weekEventReg[89] |= 4; break; - case 2: + case PLAYER_FORM_ZORA: gSaveContext.save.weekEventReg[89] |= 2; break; - case 3: + case PLAYER_FORM_DEKU: gSaveContext.save.weekEventReg[89] |= 1; break; } 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 058814107..0278a70df 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.h +++ b/src/overlays/actors/ovl_En_Go/z_en_go.h @@ -46,59 +46,59 @@ typedef struct { } EnGoStruct; // size = 0x3C; typedef struct EnGo { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnGoActionFunc actionFunc; - /* 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]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnGoActionFunc actionFunc; + /* 0x18C */ EnGoActionFunc unk_18C; + /* 0x190 */ EnGoActionFunc unk_190; + /* 0x194 */ ColliderCylinder colliderCylinder; + /* 0x1E0 */ UNK_TYPE1 unk1E0[0x4C]; + /* 0x22C */ ColliderSphere colliderSphere; + /* 0x284 */ Path* unk_284; + /* 0x288 */ s8 unk_288; + /* 0x289 */ s8 unk_289; + /* 0x28C */ s32 unk_28C; + /* 0x290 */ Vec3f unk_290; + /* 0x29C */ Vec3f unk_29C; + /* 0x2A8 */ Vec3s unk_2A8; + /* 0x2AE */ Vec3s unk_2AE; + /* 0x2B4 */ Vec3s jointTable[18]; + /* 0x320 */ Vec3s morphTable[18]; + /* 0x38C */ Actor* unk_38C; + /* 0x390 */ u16 unk_390; + /* 0x392 */ u16 unk_392; + /* 0x394 */ u8 unk_394; + /* 0x398 */ f32 unk_398; + /* 0x39C */ f32 unk_39C; + /* 0x3A0 */ f32 unk_3A0; + /* 0x3A4 */ f32 unk_3A4; + /* 0x3A8 */ f32 unk_3A8; + /* 0x3AC */ UNK_TYPE1 unk3AC[0x2]; + /* 0x3AE */ s16 unk_3AE; + /* 0x3B0 */ s16 unk_3B0; + /* 0x3B2 */ s16 unk_3B2; + /* 0x3B4 */ s16 unk_3B4; + /* 0x3B6 */ s16 unk_3B6; + /* 0x3B8 */ s16 unk_3B8; + /* 0x3BA */ s16 unk_3BA; + /* 0x3BC */ s16 unk_3BC; + /* 0x3BE */ s16 unk_3BE; + /* 0x3C0 */ s16 unk_3C0; + /* 0x3C2 */ s16 unk_3C2; + /* 0x3C4 */ s16 unk_3C4; + /* 0x3C6 */ s16 unk_3C6; + /* 0x3C8 */ s16 unk_3C8[3]; + /* 0x3CE */ s16 unk_3CE[3]; + /* 0x3D4 */ s16 unk_3D4; + /* 0x3D8 */ void* unk_3D8; + /* 0x3DC */ s32 unk_3DC; + /* 0x3E0 */ UNK_TYPE1 unk3E0[0x4]; + /* 0x3E4 */ s32 unk_3E4; + /* 0x3E8 */ s32 unk_3E8; + /* 0x3EC */ s32 unk_3EC; + /* 0x3F0 */ s32 unk_3F0; + /* 0x3F4 */ s32 unk_3F4; + /* 0x3F8 */ 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 0cddfab72..df491dd22 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -67,7 +67,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.h b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.h index db841977c..fc4f66f51 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.h +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.h @@ -54,31 +54,31 @@ typedef struct { } EnGoroiwaStruct; // size = 0x30 typedef struct EnGoroiwa { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderJntSph collider; - /* 0x0164 */ ColliderJntSphElement colliderElements[1]; - /* 0x01A4 */ EnGoroiwaActionFunc actionFunc; - /* 0x01A8 */ Vec3f unk_1A8; - /* 0x01B4 */ Vec3f unk_1B4; - /* 0x01C0 */ f32 unk_1C0; - /* 0x01C4 */ f32 unk_1C4; - /* 0x01C8 */ s16 unk_1C8; - /* 0x01CA */ s16 unk_1CA; - /* 0x01CC */ s16 unk_1CC; - /* 0x01CE */ s16 unk_1CE; - /* 0x01D0 */ Vec3s* unk_1D0; - /* 0x01D4 */ s16 unk_1D4; - /* 0x01D6 */ s16 unk_1D6; - /* 0x01D8 */ s16 unk_1D8; - /* 0x01DA */ s16 unk_1DA; - /* 0x01DC */ f32 unk_1DC; - /* 0x01E0 */ f32 unk_1E0; - /* 0x01E4 */ s8 unk_1E4; - /* 0x01E5 */ u8 unk_1E5; - /* 0x01E6 */ s8 unk_1E6; - /* 0x01E7 */ s8 unk_1E7; - /* 0x01E8 */ EnGoroiwaStruct unk_1E8[2]; - /* 0x0248 */ s32 unk_248; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElements[1]; + /* 0x1A4 */ EnGoroiwaActionFunc actionFunc; + /* 0x1A8 */ Vec3f unk_1A8; + /* 0x1B4 */ Vec3f unk_1B4; + /* 0x1C0 */ f32 unk_1C0; + /* 0x1C4 */ f32 unk_1C4; + /* 0x1C8 */ s16 unk_1C8; + /* 0x1CA */ s16 unk_1CA; + /* 0x1CC */ s16 unk_1CC; + /* 0x1CE */ s16 unk_1CE; + /* 0x1D0 */ Vec3s* unk_1D0; + /* 0x1D4 */ s16 unk_1D4; + /* 0x1D6 */ s16 unk_1D6; + /* 0x1D8 */ s16 unk_1D8; + /* 0x1DA */ s16 unk_1DA; + /* 0x1DC */ f32 unk_1DC; + /* 0x1E0 */ f32 unk_1E0; + /* 0x1E4 */ s8 unk_1E4; + /* 0x1E5 */ u8 unk_1E5; + /* 0x1E6 */ s8 unk_1E6; + /* 0x1E7 */ s8 unk_1E7; + /* 0x1E8 */ EnGoroiwaStruct unk_1E8[2]; + /* 0x248 */ s32 unk_248; } EnGoroiwa; // size = 0x24C extern const ActorInit En_Goroiwa_InitVars; diff --git a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c index 1c37d5c85..be274690c 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c @@ -79,7 +79,7 @@ static ColliderJntSphElementInit D_809A8D1C[2] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809A8D64 = { { COLTYPE_HIT2, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_809A8D1C, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809A8D1C, // sJntSphElementsInit, }; #endif 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 c1be4f1a9..db3639c27 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -181,7 +181,7 @@ void func_80997D14(EnGs* this, PlayState* play) { void func_80997D38(EnGs* this, PlayState* play) { static f32 D_8099A408[] = { 40.0f, 60.0f, 40.0f, 40.0f }; - if (Message_GetState(&play->msgCtx) == 0) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if (this->actor.xzDistToPlayer <= D_8099A408[this->actor.params]) { func_8013E8F8(&this->actor, play, D_8099A408[this->actor.params], D_8099A408[this->actor.params], EXCH_ITEM_NONE, 0x2000, 0x2000); @@ -205,18 +205,18 @@ void func_80997DEC(EnGs* this, PlayState* play) { void func_80997E4C(EnGs* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 0: + case TEXT_STATE_NONE: Message_StartTextbox(play, this->unk_210, &this->actor); break; - case 1: - case 2: - case 3: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; - case 4: - case 5: - case 6: + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x20D0: @@ -533,7 +533,8 @@ s32 func_80998A48(EnGs* this, PlayState* play) { } else if (this->unk_19D == 1) { if (func_80998334(this, play, &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) && !Play_InCsMode(play) && (Message_GetState(&play->msgCtx) == 0)) { + if ((this->actor.params != ENGS_0) && !Play_InCsMode(play) && + (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { this->unk_216 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIVE_LUPY_COUNT); Message_StartTextbox(play, 0x20D2, NULL); @@ -1005,7 +1006,7 @@ void EnGs_Update(Actor* thisx, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { play->msgCtx.msgMode = 0; - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; this->collider.base.acFlags &= ~AC_HIT; func_80997DEC(this, play); } else if (func_800B8718(&this->actor, &play->state)) { diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c index d2d447db5..843657b60 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c @@ -5,6 +5,7 @@ */ #include "z_en_guard_nuts.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_100000 | ACTOR_FLAG_80000000) @@ -222,7 +223,7 @@ void func_80ABB590(EnGuardNuts* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->actor.shape.rot.y, yaw, 1, 0xBB8, 0); } - if (Message_GetState(&play->msgCtx) == 5) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { this->targetHeadPos.y = 0; this->targetHeadPos.x = 0; if ((this->guardTextIndex == 3) && (this->animIndex == WAIT_HEAD_TILT_ANIM)) { @@ -254,7 +255,7 @@ void func_80ABB590(EnGuardNuts* this, PlayState* play) { EnGuardNuts_SetupWait(this); } } - } else if ((Message_GetState(&play->msgCtx) >= 3) && (D_80ABBE20 == 0)) { + } else if ((Message_GetState(&play->msgCtx) >= TEXT_STATE_3) && (D_80ABBE20 == 0)) { if ((this->guardTextIndex == 0) || (this->guardTextIndex == 3) || (this->guardTextIndex >= 7)) { if (this->timer == 0) { this->timer = 2; @@ -273,7 +274,7 @@ void EnGuardNuts_Burrow(EnGuardNuts* this, PlayState* play) { EnGuardNuts_ChangeAnim(this, DIG_ANIM); Math_Vec3f_Copy(&digPos, &this->actor.world.pos); digPos.y = this->actor.floorHeight; - EffectSsHahen_SpawnBurst(play, &digPos, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &digPos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); this->targetHeadPos.y = 0; this->actor.flags |= ACTOR_FLAG_8000000; this->targetHeadPos.x = this->targetHeadPos.y; @@ -304,7 +305,7 @@ void EnGuardNuts_Unburrow(EnGuardNuts* this, PlayState* play) { if ((yawDiff < 0x4000) && ((D_80ABBE20 == 0) || (this->actor.xzDistToPlayer > 150.0f))) { Math_Vec3f_Copy(&digPos, &this->actor.world.pos); digPos.y = this->actor.floorHeight; - EffectSsHahen_SpawnBurst(play, &digPos, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &digPos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); D_80ABBE20 = 0; if (this->guardTextIndex == 9) { 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 270fe3bac..8fe8d58f7 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -63,7 +63,7 @@ static ColliderCylinderInit sCylinderInit = { }; static AnimationHeader* D_80BC79CC[] = { &object_fu_Anim_000B04, &object_fu_Anim_00057C }; -static u8 D_80BC79D4[] = { 0 }; +static u8 D_80BC79D4[] = { ANIMMODE_LOOP, ANIMMODE_LOOP }; static f32 D_80BC79D8[] = { 1.0f, 1.0f }; static TexturePtr sEyeTextures[] = { object_fu_Tex_005F20, object_fu_Tex_006320 }; static TexturePtr sMouthTextures[] = { object_fu_Tex_006720, object_fu_Tex_006920 }; @@ -191,7 +191,7 @@ void func_80BC7068(EnGuruguru* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } else if (this->unusedTimer == 0) { this->unusedTimer = 6; - if (Message_GetState(&play->msgCtx) != 5) { + if (Message_GetState(&play->msgCtx) != TEXT_STATE_5) { if (this->unk266 == 0) { if (this->headZRotTarget != 0) { this->headZRotTarget = 0; @@ -207,7 +207,7 @@ void func_80BC7068(EnGuruguru* this, PlayState* play) { } } } - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); this->headZRotTarget = 0; if ((this->textIdIndex == 13) || (this->textIdIndex == 14)) { diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index a5b8b3c30..174c507d1 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -209,7 +209,7 @@ void func_80B221E8(EnHakurock* this, PlayState* play) { this->actor.shape.rot.y += 0x900; this->actor.shape.rot.z += 0xB00; - if (this->collider.base.atFlags & AT_HIT || ((this->counter == 0) && (this->collider.base.ocFlags1 & OC1_HIT)) || + if ((this->collider.base.atFlags & AT_HIT) || ((this->counter == 0) && (this->collider.base.ocFlags1 & OC1_HIT)) || ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROCK_BROKEN); func_80B21EA4(this, 0); diff --git a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h index 22071de5d..6e5d65e8f 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h @@ -29,26 +29,26 @@ typedef enum { } EnHeishiLimbs; typedef struct EnHeishi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[HEISHI_LIMB_MAX]; - /* 0x01EE */ Vec3s morphTable[HEISHI_LIMB_MAX]; - /* 0x0254 */ EnHeishiActionFunc actionFunc; - /* 0x0258 */ s16 headRotY; - /* 0x025A */ s16 headRotX; - /* 0x025C */ s16 headRotZ; - /* 0x025E */ s16 headRotYTarget; - /* 0x0260 */ s16 headRotXTarget; - /* 0x0262 */ s16 headRotZTarget; - /* 0x0264 */ s32 animIndex; - /* 0x0268 */ s32 paramsCopy; - /* 0x026C */ s32 shouldSetHeadRotation; - /* 0x0270 */ s16 timer; - /* 0x0272 */ s16 yawTowardsPlayer; - /* 0x0274 */ f32 frameCount; - /* 0x0278 */ s16 unk278; // set and not used - /* 0x027C */ UNK_TYPE1 unk_27C[0x8]; - /* 0x0284 */ ColliderCylinder colliderCylinder; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[HEISHI_LIMB_MAX]; + /* 0x1EE */ Vec3s morphTable[HEISHI_LIMB_MAX]; + /* 0x254 */ EnHeishiActionFunc actionFunc; + /* 0x258 */ s16 headRotY; + /* 0x25A */ s16 headRotX; + /* 0x25C */ s16 headRotZ; + /* 0x25E */ s16 headRotYTarget; + /* 0x260 */ s16 headRotXTarget; + /* 0x262 */ s16 headRotZTarget; + /* 0x264 */ s32 animIndex; + /* 0x268 */ s32 paramsCopy; + /* 0x26C */ s32 shouldSetHeadRotation; + /* 0x270 */ s16 timer; + /* 0x272 */ s16 yawTowardsPlayer; + /* 0x274 */ f32 frameCount; + /* 0x278 */ s16 unk278; // set and not used + /* 0x27C */ UNK_TYPE1 unk_27C[0x8]; + /* 0x284 */ ColliderCylinder colliderCylinder; } EnHeishi; // size = 0x2D0 #endif // Z_EN_HEISHI_H diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index 1e73cda44..d3af20a41 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -176,7 +176,7 @@ void func_80BCF4AC(EnHg* this, PlayState* play) { s32 pad; this->actor.speedXZ = 1.6f; - if (!(player->stateFlags2 & 0x08000000) && Message_GetState(&play->msgCtx) == 0) { + if (!(player->stateFlags2 & 0x08000000) && Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if (((this->skelAnime.curFrame > 9.0f) && (this->skelAnime.curFrame < 16.0f)) || ((this->skelAnime.curFrame > 44.0f) && (this->skelAnime.curFrame < 51.0f))) { Actor_MoveWithGravity(&this->actor); @@ -215,7 +215,7 @@ void func_80BCF6D0(EnHg* this, PlayState* play) { } void func_80BCF710(EnHg* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 0) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { Message_StartTextbox(play, 0x24F, &this->actor); } else { diff --git a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c index 9a38aba97..0c9952149 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -175,20 +175,24 @@ void EnHgo_SetupDialogueHandler(EnHgo* this) { void EnHgo_DefaultDialogueHandler(EnHgo* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 0: - case 1: - case 2: - case 3: - case 4: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: break; - case 5: + + case TEXT_STATE_5: func_80BD06FC(this, play); break; - case 6: + + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { func_80BD049C(this); } + break; } + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x71C, 0xB6); this->actor.shape.rot.y = this->actor.world.rot.y; } diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c index a4bd59c84..e07b8ac70 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c @@ -5,6 +5,7 @@ */ #include "z_en_hidden_nuts.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_hintnuts/object_hintnuts.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_2000000) @@ -222,7 +223,7 @@ void func_80BDB59C(EnHiddenNuts* this, PlayState* play) { this->unk_218 = 30; } - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); func_80BDB268(this); } @@ -257,7 +258,7 @@ void func_80BDB7E8(EnHiddenNuts* this, PlayState* play) { Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); sp3C.y = this->actor.floorHeight + 30.0f; - EffectSsHahen_SpawnBurst(play, &sp3C, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &sp3C, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); func_80BDB1B4(this, 7); @@ -304,7 +305,7 @@ void func_80BDBA28(EnHiddenNuts* this, PlayState* play) { Math_Vec3f_Copy(&sp44, &this->actor.world.pos); sp44.y = this->actor.floorHeight + 30.0f; - EffectSsHahen_SpawnBurst(play, &sp44, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &sp44, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); this->unk_208 = 1; @@ -398,7 +399,7 @@ void func_80BDBED4(EnHiddenNuts* this, PlayState* play) { sp38.y = this->actor.floorHeight; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); - EffectSsHahen_SpawnBurst(play, &sp38, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &sp38, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h index 5ed3668f7..a8edd1d75 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h @@ -11,26 +11,26 @@ typedef void (*EnHiddenNutsActionFunc)(struct EnHiddenNuts*, PlayState*); #define ENHIDDENNUTS_GET_F80(thisx) (((thisx)->params >> 7) & 0x1F) typedef struct EnHiddenNuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[10]; - /* 0x01C4 */ Vec3s morphTable[10]; - /* 0x0200 */ EnHiddenNutsActionFunc actionFunc; - /* 0x0204 */ Path* path; - /* 0x0208 */ s16 unk_208; - /* 0x020A */ u8 unk_20A; - /* 0x020C */ Vec3f unk_20C; - /* 0x0218 */ s16 unk_218; - /* 0x021A */ s16 unk_21A; - /* 0x021C */ s16 switchFlag; - /* 0x021E */ s16 unk_21E; - /* 0x0220 */ s32 unk_220; - /* 0x0224 */ s16 unk_224; - /* 0x0226 */ s16 unk_226; - /* 0x0228 */ f32 unk_228; - /* 0x022C */ f32 unk_22C; - /* 0x0230 */ UNK_TYPE1 unk230[4]; - /* 0x0234 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[10]; + /* 0x1C4 */ Vec3s morphTable[10]; + /* 0x200 */ EnHiddenNutsActionFunc actionFunc; + /* 0x204 */ Path* path; + /* 0x208 */ s16 unk_208; + /* 0x20A */ u8 unk_20A; + /* 0x20C */ Vec3f unk_20C; + /* 0x218 */ s16 unk_218; + /* 0x21A */ s16 unk_21A; + /* 0x21C */ s16 switchFlag; + /* 0x21E */ s16 unk_21E; + /* 0x220 */ s32 unk_220; + /* 0x224 */ s16 unk_224; + /* 0x226 */ s16 unk_226; + /* 0x228 */ f32 unk_228; + /* 0x22C */ f32 unk_22C; + /* 0x230 */ UNK_TYPE1 unk230[4]; + /* 0x234 */ ColliderCylinder collider; } EnHiddenNuts; // size = 0x280 extern const ActorInit En_Hidden_Nuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c index 71194f79c..ee337e9a9 100644 --- a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c +++ b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c @@ -5,6 +5,7 @@ */ #include "z_en_hint_skb.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_skb/object_skb.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -84,7 +85,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -223,7 +224,8 @@ void func_80C1FF88(EnHintSkb* this, PlayState* play) { } void func_80C2003C(EnHintSkb* this) { - Animation_Change(&this->skelAnime, &object_skb_Anim_002190, -0.4f, this->skelAnime.curFrame - 1.0f, 0.0f, 3, 0.0f); + Animation_Change(&this->skelAnime, &object_skb_Anim_002190, -0.4f, this->skelAnime.curFrame - 1.0f, 0.0f, + ANIMMODE_ONCE_INTERP, 0.0f); this->collider.base.atFlags &= ~AT_BOUNCED; this->actionFunc = func_80C200B8; } @@ -423,29 +425,29 @@ void func_80C208D0(EnHintSkb* this, PlayState* play) { this->unk_3DE = 0; switch (Message_GetState(&play->msgCtx)) { - case 3: + case TEXT_STATE_3: if ((play->gameplayFrames % 2) != 0) { this->unk_3DE = 1; } break; - case 4: + case TEXT_STATE_CHOICE: func_80C20B88(this, play); break; - case 5: + case TEXT_STATE_5: func_80C20C24(this, play); break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { func_80C2075C(this); } break; - case 0: - case 1: - case 2: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: break; } @@ -707,8 +709,10 @@ void func_80C20E90(EnHintSkb* this, PlayState* play) { this->unk_3E8 |= 1; case 15: - if ((player->swordAnimation == 4) || (player->swordAnimation == 11) || (player->swordAnimation == 22) || - (player->swordAnimation == 23)) { + if ((player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_LEFT_COMBO_2H) || + (player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_RIGHT) || + (player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_LEFT)) { this->unk_3E8 |= 1; } @@ -816,7 +820,8 @@ void func_80C215E4(PlayState* play, EnHintSkb* this, Vec3f* arg2) { sp50.y += (Rand_ZeroOne() - 0.5f) * 4.0f; - EffectSsHahen_Spawn(play, &sp5C, &sp50, &sp44, 0, ((Rand_ZeroOne() * 5.0f) + 12.0f) * 0.8f, -1, 10, NULL); + EffectSsHahen_Spawn(play, &sp5C, &sp50, &sp44, 0, ((Rand_ZeroOne() * 5.0f) + 12.0f) * 0.8f, HAHEN_OBJECT_DEFAULT, + 10, NULL); func_800BBFB0(play, &sp5C, 10.0f, 1, 150, 0, 1); } diff --git a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h index e8ede2226..44fd8c4ef 100644 --- a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h +++ b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h @@ -10,26 +10,26 @@ typedef void (*EnHintSkbActionFunc)(struct EnHintSkb*, PlayState*); #define ENHINTSKB_GET_FF(thisx) ((thisx)->params & 0xFF) typedef struct EnHintSkb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderJntSph collider; - /* 0x0164 */ ColliderJntSphElement colliderElement[2]; - /* 0x01E4 */ SkelAnime skelAnime; - /* 0x0228 */ EnHintSkbActionFunc actionFunc; - /* 0x022C */ Vec3f limbPos[14]; - /* 0x02D4 */ f32 drawDmgEffAlpha; - /* 0x02D8 */ f32 drawDmgEffScale; - /* 0x02DC */ s32 limbCount; - /* 0x02E0 */ Vec3s jointTable[20]; - /* 0x0358 */ Vec3s morphtable[20]; - /* 0x03D0 */ UNK_TYPE1 unk3D0[0xC]; - /* 0x03DC */ s16 unk_3DC; - /* 0x03DE */ s16 unk_3DE; - /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 drawDmgEffTimer; - /* 0x03E4 */ s16 unk_3E4; - /* 0x03E6 */ u16 unk_3E6; - /* 0x03E8 */ u8 unk_3E8; - /* 0x03E9 */ u8 drawDmgEffType; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElement[2]; + /* 0x1E4 */ SkelAnime skelAnime; + /* 0x228 */ EnHintSkbActionFunc actionFunc; + /* 0x22C */ Vec3f limbPos[14]; + /* 0x2D4 */ f32 drawDmgEffAlpha; + /* 0x2D8 */ f32 drawDmgEffScale; + /* 0x2DC */ s32 limbCount; + /* 0x2E0 */ Vec3s jointTable[20]; + /* 0x358 */ Vec3s morphtable[20]; + /* 0x3D0 */ UNK_TYPE1 unk3D0[0xC]; + /* 0x3DC */ s16 unk_3DC; + /* 0x3DE */ s16 unk_3DE; + /* 0x3E0 */ s16 unk_3E0; + /* 0x3E2 */ s16 drawDmgEffTimer; + /* 0x3E4 */ s16 unk_3E4; + /* 0x3E6 */ u16 unk_3E6; + /* 0x3E8 */ u8 unk_3E8; + /* 0x3E9 */ u8 drawDmgEffType; } EnHintSkb; // size = 0x3EC extern const ActorInit En_Hint_Skb_InitVars; diff --git a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.h b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.h index 9985d5180..f48ffbe9d 100644 --- a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.h +++ b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.h @@ -10,9 +10,9 @@ typedef void (*EnHitTagActionFunc)(struct EnHitTag*, PlayState*); #define ENHITTAG_GET_SWITCHFLAG(thisx) (s32)(((thisx)->params & 0xFE00) >> 9) typedef struct EnHitTag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ EnHitTagActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ EnHitTagActionFunc actionFunc; } EnHitTag; // size = 0x194 extern const ActorInit En_Hit_Tag_InitVars; 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 5945af02f..0e85e7dc5 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -96,7 +96,7 @@ static f32 sTranslucencyPlaneDistance = 100.0f; static f32 sTransparencyPlaneDistance = 50.0f; void EnHoll_SetupAction(EnHoll* this) { - this->type = EN_HOLL_GET_TYPE(this); + this->type = EN_HOLL_GET_TYPE(&this->actor); this->actionFunc = sActionFuncs[this->type]; if (EN_HOLL_IS_VISIBLE(this)) { this->alpha = 255; @@ -128,7 +128,7 @@ void EnHoll_Destroy(Actor* thisx, PlayState* play) { EnHoll* this = THIS; if (!EN_HOLL_IS_SCENE_CHANGER(this)) { - u32 enHollId = EN_HOLL_GET_ID_CAST(this); + u32 enHollId = EN_HOLL_GET_ID(&this->actor); play->doorCtx.transitionActorList[enHollId].id = -play->doorCtx.transitionActorList[enHollId].id; if (this == sInstancePlayingSound) { @@ -152,7 +152,7 @@ void EnHoll_VisibleIdle(EnHoll* this, PlayState* play) { if (this->type == EN_HOLL_TYPE_DEFAULT) { u32 actorCtxBitmask = (play->actorCtx.unkC & 0x2AA) >> 1 | (play->actorCtx.unkC & 0x155); - u32 zActorBitmask = D_801AED48[EN_HOLL_GET_Z_ACTOR_BITMASK_INDEX(this)]; + u32 zActorBitmask = D_801AED48[EN_HOLL_GET_Z_ACTOR_BITMASK_INDEX(&this->actor)]; if (!(actorCtxBitmask & zActorBitmask)) { Actor_MarkForDeath(&this->actor); @@ -162,7 +162,7 @@ void EnHoll_VisibleIdle(EnHoll* this, PlayState* play) { func_800B9010(&this->actor, NA_SE_EV_INVISIBLE_MONKEY - SFX_FLAG); } } - if ((play->sceneLoadFlag != 0) || (play->unk_18B4A != 0)) { + if ((play->transitionTrigger != TRANS_TRIGGER_OFF) || (play->transitionMode != TRANS_MODE_OFF)) { this->alpha = 255; } else { f32 enHollBottom = EN_HOLL_BOTTOM_DEFAULT; @@ -177,7 +177,7 @@ void EnHoll_VisibleIdle(EnHoll* this, PlayState* play) { if ((enHollBottom < transformedPlayerPos.y) && (transformedPlayerPos.y < EN_HOLL_TOP_DEFAULT) && (fabsf(transformedPlayerPos.x) < enHollHalfwidth) && (playerDistFromCentralPlane < sActivationPlaneDistance)) { - u32 enHollId = EN_HOLL_GET_ID_AND(this); + u32 enHollId = EN_HOLL_GET_ID(&this->actor); if (sLoadingPlaneDistance < playerDistFromCentralPlane) { if ((play->roomCtx.prevRoom.num >= 0) && (play->roomCtx.unk31 == 0)) { @@ -188,10 +188,10 @@ void EnHoll_VisibleIdle(EnHoll* this, PlayState* play) { func_8012EBF8(play, &play->roomCtx); } } else if (this->type == EN_HOLL_TYPE_SCENE_CHANGER) { - play->nextEntranceIndex = play->setupExitList[EN_HOLL_GET_EXIT_LIST_INDEX(this)]; + play->nextEntranceIndex = play->setupExitList[EN_HOLL_GET_EXIT_LIST_INDEX(&this->actor)]; gSaveContext.unk_3DBB = 1; Scene_SetExitFade(play); - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; play->unk_1878C(play); } else { this->actor.room = play->doorCtx.transitionActorList[enHollId].sides[this->playerSide ^ 1].room; @@ -232,7 +232,7 @@ void EnHoll_TransparentIdle(EnHoll* this, PlayState* play) { if (playerDistFromCentralPlane = fabsf(transformedPlayerPos.z), playerDistFromCentralPlane < EN_HOLL_ACTIVATION_PLANE_DISTANCE && playerDistFromCentralPlane > EN_HOLL_LOADING_PLANE_DISTANCE) { - s32 enHollId = EN_HOLL_GET_ID_CAST(this); + s32 enHollId = EN_HOLL_GET_ID(&this->actor); s32 playerSide = (transformedPlayerPos.z < 0.0f) ? EN_HOLL_BEHIND : EN_HOLL_BEFORE; TransitionActorEntry* transitionActorEntry = &play->doorCtx.transitionActorList[enHollId]; s8 room = transitionActorEntry->sides[playerSide].room; @@ -259,7 +259,7 @@ void EnHoll_VerticalBgCoverIdle(EnHoll* this, PlayState* play) { play->bgCoverAlpha = EN_HOLL_SCALE_BG_COVER_ALPHA(playerDistFromCentralPlane); } if (playerDistFromCentralPlane > EN_HOLL_LOADING_PLANE_DISTANCE_VERTICAL) { - s32 enHollId = EN_HOLL_GET_ID_CAST(this); + s32 enHollId = EN_HOLL_GET_ID(&this->actor); s32 playerSide = (this->actor.playerHeightRel > 0.0f) ? EN_HOLL_ABOVE : EN_HOLL_BELOW; this->actor.room = play->doorCtx.transitionActorList[enHollId].sides[playerSide].room; @@ -283,7 +283,7 @@ void EnHoll_VerticalIdle(EnHoll* this, PlayState* play) { if (playerDistFromCentralPlane < EN_HOLL_ACTIVATION_PLANE_DISTANCE_VERTICAL && playerDistFromCentralPlane > EN_HOLL_LOADING_PLANE_DISTANCE_VERTICAL) { - s32 enHollId = EN_HOLL_GET_ID_CAST(this); + s32 enHollId = EN_HOLL_GET_ID(&this->actor); s32 playerSide = (this->actor.playerHeightRel > 0.0f) ? EN_HOLL_ABOVE : EN_HOLL_BELOW; this->actor.room = play->doorCtx.transitionActorList[enHollId].sides[playerSide].room; @@ -309,7 +309,8 @@ void EnHoll_Update(Actor* thisx, PlayState* play) { EnHoll* this = THIS; Player* player = GET_PLAYER(play); - if ((play->sceneLoadFlag == 0) && (play->unk_18B4A == 0) && !(player->stateFlags1 & 0x200)) { + if ((play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && + !(player->stateFlags1 & 0x200)) { this->actionFunc(this, play); } } diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.h b/src/overlays/actors/ovl_En_Holl/z_en_holl.h index 689c443ef..39c35220c 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.h +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.h @@ -60,11 +60,10 @@ typedef struct EnHoll { #define EN_HOLL_LOADING_PLANE_DISTANCE_VERTICAL 50.0f -#define EN_HOLL_GET_ID_AND(this) ((this->actor.params & 0xFFFF) >> 10) -#define EN_HOLL_GET_ID_CAST(this) ((u16) this->actor.params >> 10) -#define EN_HOLL_GET_TYPE(this) ((this->actor.params >> 7) & 0x7) -#define EN_HOLL_GET_EXIT_LIST_INDEX(this) (this->actor.params & 0x7F) -#define EN_HOLL_GET_Z_ACTOR_BITMASK_INDEX(this) (this->actor.params & 0x7) +#define EN_HOLL_GET_ID(thisx) ((u16)(thisx)->params >> 10) +#define EN_HOLL_GET_TYPE(thisx) (((thisx)->params >> 7) & 0x7) +#define EN_HOLL_GET_EXIT_LIST_INDEX(thisx) ((thisx)->params & 0x7F) +#define EN_HOLL_GET_Z_ACTOR_BITMASK_INDEX(thisx) ((thisx)->params & 0x7) #define EN_HOLL_IS_VISIBLE(this) ((this->type == EN_HOLL_TYPE_DEFAULT) || (this->type == EN_HOLL_TYPE_SCENE_CHANGER)) #define EN_HOLL_IS_SCENE_CHANGER(this) (this->type == EN_HOLL_TYPE_SCENE_CHANGER) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index 9f1566b86..9f6b6b98a 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -58,7 +58,7 @@ static ColliderTrisElementInit D_80930424[2] = { // static ColliderTrisInit sTrisInit = { static ColliderTrisInit D_8093049C = { { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_80930424, // sTrisElementsInit, + ARRAY_COUNT(sTrisElementsInit), D_80930424, // sTrisElementsInit, }; // static ColliderCylinderInit sCylinderInit = { diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h index 4f3fb5b58..bf4b08fd7 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h @@ -8,9 +8,9 @@ struct EnHonotrap; typedef void (*EnHonotrapActionFunc)(struct EnHonotrap*, PlayState*); typedef struct EnHonotrap { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnHonotrapActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x17C]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnHonotrapActionFunc actionFunc; + /* 0x148 */ char unk_148[0x17C]; } EnHonotrap; // size = 0x2C4 extern const ActorInit En_Honotrap_InitVars; diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 21bd48d80..0e63d87c1 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -6,6 +6,7 @@ #include "z_en_horse.h" #include "z64rumble.h" +#include "overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h" #include "objects/object_horse_link_child/object_horse_link_child.h" #define FLAGS (ACTOR_FLAG_10) @@ -202,7 +203,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1 | OC2_UNK1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -740,7 +741,7 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; } else if (thisx->params == ENHORSE_8) { this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP; - if (CHECK_QUEST_ITEM(14)) { + if (CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { this->stateFlags &= ~ENHORSE_CANT_JUMP; this->stateFlags |= ENHORSE_FLAG_26; } @@ -769,7 +770,7 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { this->stateFlags = 0; } - if (((play->sceneNum == SCENE_KOEPONARACE) && ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 1)) || + if (((play->sceneNum == SCENE_KOEPONARACE) && (GET_RACE_FLAGS == 1)) || ((gSaveContext.save.entranceIndex == 0x6400) && Cutscene_GetSceneSetupIndex(play))) { this->stateFlags |= ENHORSE_FLAG_25; } @@ -2451,7 +2452,7 @@ void func_808819D8(EnHorse* this, PlayState* play) { func_8088168C(this); } - if ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 3) { + if (GET_RACE_FLAGS == 3) { this->rider->unk488 = 7; } else { EnHorse_SetIngoAnimation(this->animationIdx, this->skin.skelAnime.curFrame, this->unk_394 & 1, @@ -2907,8 +2908,8 @@ void EnHorse_UpdateHorsebackArchery(EnHorse* this, PlayState* play) { if (((this->hbaFlags & 1) || (this->hbaTimer > 45)) && (sp28 != 1) && (gSaveContext.minigameState != 3)) { gSaveContext.save.cutscene = 0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 0x40; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_64; } if (play->interfaceCtx.hbaAmmo) {} diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index 421772302..278ec7144 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -109,8 +109,8 @@ s32 func_808F8C70(EnHorseGameCheck* this, PlayState* play) { s32 func_808F8CCC(EnHorseGameCheck* this, PlayState* play2) { PlayState* play = play2; s32 pad; - Vec3f sp4C = { -1262.0f, 15.0f, 780.0f }; - Vec3f sp40 = { -1262.0f, -26.0f, 470.0f }; + Vec3f mainCamEye = { -1262.0f, 15.0f, 780.0f }; + Vec3f mainCamAt = { -1262.0f, -26.0f, 470.0f }; this->unk_164 = 0; this->unk_168 = 0; @@ -137,9 +137,9 @@ s32 func_808F8CCC(EnHorseGameCheck* this, PlayState* play2) { } this->unk_17C = -1; - func_800DFAC8(play->cameraPtrs[CAM_ID_MAIN], 10); - Play_CameraSetAtEye(play, 0, &sp40, &sp4C); - Play_CameraSetFov(play, 0, 45.0f); + Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_FREE0); + Play_CameraSetAtEye(play, CAM_ID_MAIN, &mainCamAt, &mainCamEye); + Play_CameraSetFov(play, CAM_ID_MAIN, 45.0f); func_800FE484(); return false; } @@ -157,15 +157,15 @@ s32 func_808F8EB0(EnHorseGameCheck* this, PlayState* play) { } if (GET_RACE_FLAGS == RACE_FLAG_3) { - play->unk_1887F = 0x40; - gSaveContext.nextTransition = 2; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_02; } else if (GET_RACE_FLAGS == RACE_FLAG_2) { - play->unk_1887F = 0x50; - gSaveContext.nextTransition = 3; + play->transitionType = TRANS_TYPE_80; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } else if (GET_RACE_FLAGS == RACE_FLAG_4) { SET_RACE_FLAGS(RACE_FLAG_3); - play->unk_1887F = 2; - gSaveContext.nextTransition = 2; + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_02; } D_801BDA9C = 0; @@ -173,7 +173,7 @@ s32 func_808F8EB0(EnHorseGameCheck* this, PlayState* play) { D_801BDAA0 = 1; } play->nextEntranceIndex = 0xCE20; - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; return false; } @@ -228,7 +228,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { if ((this->unk_17C != -1) && ((this->unk_168 - this->unk_17C) > 10)) { this->unk_17C = -1; - func_800DFAC8(play->cameraPtrs[CAM_ID_MAIN], 4); + Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_HORSE); } this->unk_168++; diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.c b/src/overlays/actors/ovl_En_Hs/z_en_hs.c index f245875e1..15a735128 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -174,7 +174,7 @@ void func_80953098(EnHs* this, PlayState* play) { } void func_80953180(EnHs* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x33F4: // text: laughing that they are all roosters (!) case 0x33F6: // text: Grog regrets not being able to see his chicks reach adult hood @@ -196,7 +196,7 @@ void func_80953180(EnHs* this, PlayState* play) { break; case 0x33F5: // He heard from his gramps (?) the moon is going to fall - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; this->actionFunc = func_80952FE0; this->stateTimer = 0; this->headRot.z = 0; @@ -217,7 +217,7 @@ void EnHs_DoNothing(EnHs* this, PlayState* play) { void EnHs_SceneTransitToBunnyHoodDialogue(EnHs* this, PlayState* play) { if (DECR(this->stateTimer) == 0) { play->nextEntranceIndex = play->setupExitList[HS_GET_EXIT_INDEX(&this->actor)]; - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.save.weekEventReg[25] |= 8; this->actionFunc = EnHs_DoNothing; } diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.h b/src/overlays/actors/ovl_En_Hs/z_en_hs.h index d6979dc32..d72c72d15 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.h +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.h @@ -21,17 +21,17 @@ typedef void (*EnHsActionFunc)(struct EnHs*, PlayState*); // The count of [chicks transformed into adult] is stored in [this->actor.home.rot.x] (incremented by 2) typedef struct EnHs { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ Vec3s jointTable[OBJECT_HS_LIMB_MAX]; - /* 0x0234 */ Vec3s morphTable[OBJECT_HS_LIMB_MAX]; - /* 0x0294 */ Vec3s headRot; - /* 0x029A */ Vec3s unusedRot; // probably not chest, as chest is same limb as lower body - /* 0x02A0 */ u16 stateFlags; - /* 0x02A2 */ s16 stateTimer; // reused for different actionFunc - /* 0x02A4 */ Vec3f nwcPos[20]; // actual chick position are even values, odd values seem to be extra values for smoother chain - /* 0x0394 */ EnHsActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ Vec3s jointTable[OBJECT_HS_LIMB_MAX]; + /* 0x234 */ Vec3s morphTable[OBJECT_HS_LIMB_MAX]; + /* 0x294 */ Vec3s headRot; + /* 0x29A */ Vec3s unusedRot; // probably not chest, as chest is same limb as lower body + /* 0x2A0 */ u16 stateFlags; + /* 0x2A2 */ s16 stateTimer; // reused for different actionFunc + /* 0x2A4 */ Vec3f nwcPos[20]; // actual chick position are even values, odd values seem to be extra values for smoother chain + /* 0x394 */ EnHsActionFunc actionFunc; } EnHs; // size = 0x398 extern const ActorInit En_Hs_InitVars; diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.c b/src/overlays/actors/ovl_En_Ig/z_en_ig.c index 072ec01d4..cf24adfd0 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -362,7 +362,7 @@ s32 func_80BF17BC(EnIg* this, PlayState* play) { case 2: case 4: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentCamera(sp2A)), + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), this->actor.child); } this->unk_3F6++; @@ -376,7 +376,7 @@ s32 func_80BF17BC(EnIg* this, PlayState* play) { ActorCutscene_Stop(sp2A); this->unk_3F6 = 5; } else { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); } this->unk_3F6++; ret = true; @@ -496,7 +496,7 @@ s32 func_80BF1B40(EnIg* this, PlayState* play) { return false; } -s32 func_80BF1C44(EnIg* this, PlayState* play, ScheduleResult* arg2, s32 arg3, s32 arg4) { +s32 func_80BF1C44(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput, s32 arg3, s32 arg4) { u8 sp4F = ENIG_GET_FF(&this->actor); Vec3s* sp48; Vec3f sp3C; @@ -508,8 +508,8 @@ s32 func_80BF1C44(EnIg* this, PlayState* play, ScheduleResult* arg2, s32 arg3, s sp2C = func_80BF1150(this, play, arg3, arg4); this->timePath = NULL; - if (D_80BF3318[arg2->result] >= 0) { - this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80BF3318[arg2->result]); + if (D_80BF3318[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80BF3318[scheduleOutput->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { @@ -526,10 +526,10 @@ s32 func_80BF1C44(EnIg* this, PlayState* play, ScheduleResult* arg2, s32 arg3, s return sp24; } -s32 func_80BF1D78(EnIg* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BF1D78(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 sp2C = 0; - if (func_80BF1C44(this, play, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { + if (func_80BF1C44(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_AN)) { func_80BF1284(this, 0); SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 |= 0x20; @@ -539,7 +539,7 @@ s32 func_80BF1D78(EnIg* this, PlayState* play, ScheduleResult* arg2) { return sp2C; } -s32 func_80BF1DF4(EnIg* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BF1DF4(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = ENIG_GET_FF(&this->actor); EnDoor* door; @@ -550,10 +550,10 @@ s32 func_80BF1DF4(EnIg* this, PlayState* play, ScheduleResult* arg2) { s32 ret = false; this->timePath = NULL; - door = func_80BF1200(play, arg2->result); + door = func_80BF1200(play, scheduleOutput->result); - if (D_80BF3318[arg2->result] >= 0) { - this->timePath = SubS_GetAdditionalPath(play, sp55, D_80BF3318[arg2->result]); + if (D_80BF3318[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp55, D_80BF3318[scheduleOutput->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -572,8 +572,8 @@ s32 func_80BF1DF4(EnIg* this, PlayState* play, ScheduleResult* arg2) { this->unk_2A4 = 75; } - this->unk_3E0 = arg2->time1 - arg2->time0; - this->unk_3E2 = sp56 - arg2->time0; + this->unk_3E0 = scheduleOutput->time1 - scheduleOutput->time0; + this->unk_3E2 = sp56 - scheduleOutput->time0; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3D0 |= 0x100; func_80BF1284(this, 3); @@ -584,17 +584,18 @@ s32 func_80BF1DF4(EnIg* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80BF1FA8(EnIg* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BF1FA8(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENIG_GET_FF(&this->actor); - s32 pad; + u16 tmp; + s16 pad; s32 ret = false; this->timePath = NULL; - if (D_80BF3318[arg2->result] >= 0) { - this->timePath = SubS_GetAdditionalPath(play, sp2B, D_80BF3318[arg2->result]); + if (D_80BF3318[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp2B, D_80BF3318[scheduleOutput->result]); } if ((this->timePath != NULL) && (this->timePath->count < 3)) { @@ -605,20 +606,20 @@ s32 func_80BF1FA8(EnIg* this, PlayState* play, ScheduleResult* arg2) { if ((this->scheduleResult < 10) && (this->scheduleResult != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->time0; + phi_v1 = scheduleOutput->time0; } - if (arg2->time1 < phi_v1) { - this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; + if (scheduleOutput->time1 < phi_v1) { + this->timePathTotalTime = (phi_v1 - scheduleOutput->time1) + 0xFFFF; } else { - this->timePathTotalTime = arg2->time1 - phi_v1; + this->timePathTotalTime = scheduleOutput->time1 - phi_v1; } this->timePathElapsedTime = sp2E - phi_v1; - phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + tmp = phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); - this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + this->timePathWaypointTime = this->timePathTotalTime / tmp; this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); @@ -633,7 +634,7 @@ s32 func_80BF1FA8(EnIg* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80BF219C(EnIg* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BF219C(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { u8 sp4F = ENIG_GET_FF(&this->actor); Vec3f sp40; Vec3f sp34; @@ -643,8 +644,8 @@ s32 func_80BF219C(EnIg* this, PlayState* play, ScheduleResult* arg2) { this->timePath = NULL; - if (D_80BF3318[arg2->result] >= 0) { - this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80BF3318[arg2->result]); + if (D_80BF3318[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80BF3318[scheduleOutput->result]); } if ((this->timePath != 0) && (this->timePath->count >= 2)) { @@ -656,7 +657,7 @@ s32 func_80BF219C(EnIg* this, PlayState* play, ScheduleResult* arg2) { Math_Vec3f_Copy(&this->actor.world.pos, &sp40); Math_Vec3f_Copy(&this->actor.prevPos, &sp40); - switch (arg2->result) { + switch (scheduleOutput->result) { case 2: this->actor.home.rot.y = this->actor.world.rot.y; this->actor.home.rot.y += 0x8000; @@ -678,20 +679,20 @@ s32 func_80BF219C(EnIg* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80BF2368(EnIg* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BF2368(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; this->actor.targetMode = 0; this->unk_3D0 = 0; this->actor.flags |= ACTOR_FLAG_1; - switch (arg2->result) { + switch (scheduleOutput->result) { case 5: case 6: case 7: case 8: case 9: - ret = func_80BF1DF4(this, play, arg2); + ret = func_80BF1DF4(this, play, scheduleOutput); break; case 10: @@ -699,16 +700,16 @@ s32 func_80BF2368(EnIg* this, PlayState* play, ScheduleResult* arg2) { case 12: case 13: case 14: - ret = func_80BF1FA8(this, play, arg2); + ret = func_80BF1FA8(this, play, scheduleOutput); break; case 2: case 4: - ret = func_80BF219C(this, play, arg2); + ret = func_80BF219C(this, play, scheduleOutput); break; case 3: - ret = func_80BF1D78(this, play, arg2); + ret = func_80BF1D78(this, play, scheduleOutput); break; } return ret; @@ -873,7 +874,7 @@ void func_80BF2A50(EnIg* this, PlayState* play) { } void func_80BF2AF8(EnIg* this, PlayState* play) { - ScheduleResult sp20; + ScheduleOutput sp20; this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.h b/src/overlays/actors/ovl_En_Ig/z_en_ig.h index 51004b470..5ff18dfef 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.h +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.h @@ -12,54 +12,54 @@ typedef void (*EnIgUnkFunc2)(struct EnIg*, PlayState*); #define ENIG_GET_FF(thisx) ((thisx)->params & 0xFF) typedef struct EnIg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnIgActionFunc actionFunc; - /* 0x018C */ EnIgUnkFunc2 unk_18C; - /* 0x0190 */ MtxF unk_190; - /* 0x01D0 */ ColliderCylinder collider1; - /* 0x021C */ ColliderSphere collider2; - /* 0x0274 */ Path* timePath; - /* 0x0278 */ Vec3f timePathTargetPos; - /* 0x0284 */ f32 timePathProgress; - /* 0x0288 */ s32 timePathTotalTime; - /* 0x028C */ s32 timePathWaypointTime; - /* 0x0290 */ s32 timePathWaypoint; - /* 0x0294 */ s32 timePathElapsedTime; - /* 0x0298 */ u8 scheduleResult; - /* 0x029C */ s32* unk_29C; - /* 0x02A0 */ s32 unk_2A0; - /* 0x02A4 */ s8 unk_2A4; - /* 0x02A8 */ Actor* unk_2A8; - /* 0x02AC */ UNK_TYPE1 unk2AC[0x4]; - /* 0x02B0 */ Vec3f unk_2B0; - /* 0x02BC */ Vec3f unk_2BC; - /* 0x02C8 */ UNK_TYPE1 unk2C8[0xC]; - /* 0x02D4 */ Vec3f unk_2D4; - /* 0x02E0 */ UNK_TYPE1 unk2E0[0x6]; - /* 0x02E6 */ Vec3s unk_2E6; - /* 0x02EC */ Vec3s jointTable[19]; - /* 0x035E */ Vec3s morphTable[19]; - /* 0x03D0 */ u16 unk_3D0; - /* 0x03D2 */ u16 unk_3D2; - /* 0x03D4 */ f32 unk_3D4; - /* 0x03D8 */ UNK_TYPE1 unk3D8[0x8]; - /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 unk_3E2; - /* 0x03E4 */ s16 unk_3E4; - /* 0x03E6 */ s16 unk_3E6; - /* 0x03E8 */ s16 unk_3E8; - /* 0x03EA */ s16 unk_3EA; - /* 0x03EC */ s16 timePathTimeSpeed; - /* 0x03EE */ s16 unk_3EE; - /* 0x03F0 */ s16 unk_3F0; - /* 0x03F2 */ s16 unk_3F2; - /* 0x03F4 */ s16 unk_3F4; - /* 0x03F6 */ s16 unk_3F6; - /* 0x03F8 */ EnIgUnkFunc unk_3F8; - /* 0x03FC */ s32 unk_3FC; - /* 0x0400 */ UNK_TYPE1 unk400[0x8]; - /* 0x0408 */ s32 unk_408; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnIgActionFunc actionFunc; + /* 0x18C */ EnIgUnkFunc2 unk_18C; + /* 0x190 */ MtxF unk_190; + /* 0x1D0 */ ColliderCylinder collider1; + /* 0x21C */ ColliderSphere collider2; + /* 0x274 */ Path* timePath; + /* 0x278 */ Vec3f timePathTargetPos; + /* 0x284 */ f32 timePathProgress; + /* 0x288 */ s32 timePathTotalTime; + /* 0x28C */ s32 timePathWaypointTime; + /* 0x290 */ s32 timePathWaypoint; + /* 0x294 */ s32 timePathElapsedTime; + /* 0x298 */ u8 scheduleResult; + /* 0x29C */ s32* unk_29C; + /* 0x2A0 */ s32 unk_2A0; + /* 0x2A4 */ s8 unk_2A4; + /* 0x2A8 */ Actor* unk_2A8; + /* 0x2AC */ UNK_TYPE1 unk2AC[0x4]; + /* 0x2B0 */ Vec3f unk_2B0; + /* 0x2BC */ Vec3f unk_2BC; + /* 0x2C8 */ UNK_TYPE1 unk2C8[0xC]; + /* 0x2D4 */ Vec3f unk_2D4; + /* 0x2E0 */ UNK_TYPE1 unk2E0[0x6]; + /* 0x2E6 */ Vec3s unk_2E6; + /* 0x2EC */ Vec3s jointTable[19]; + /* 0x35E */ Vec3s morphTable[19]; + /* 0x3D0 */ u16 unk_3D0; + /* 0x3D2 */ u16 unk_3D2; + /* 0x3D4 */ f32 unk_3D4; + /* 0x3D8 */ UNK_TYPE1 unk3D8[0x8]; + /* 0x3E0 */ s16 unk_3E0; + /* 0x3E2 */ s16 unk_3E2; + /* 0x3E4 */ s16 unk_3E4; + /* 0x3E6 */ s16 unk_3E6; + /* 0x3E8 */ s16 unk_3E8; + /* 0x3EA */ s16 unk_3EA; + /* 0x3EC */ s16 timePathTimeSpeed; + /* 0x3EE */ s16 unk_3EE; + /* 0x3F0 */ s16 unk_3F0; + /* 0x3F2 */ s16 unk_3F2; + /* 0x3F4 */ s16 unk_3F4; + /* 0x3F6 */ s16 unk_3F6; + /* 0x3F8 */ EnIgUnkFunc unk_3F8; + /* 0x3FC */ s32 unk_3FC; + /* 0x400 */ UNK_TYPE1 unk400[0x8]; + /* 0x408 */ s32 unk_408; } EnIg; // size = 0x40C extern const ActorInit En_Ig_InitVars; diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.c b/src/overlays/actors/ovl_En_Ik/z_en_ik.c index 6847c9904..f1f8aff6e 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -16,7 +16,64 @@ void EnIk_Destroy(Actor* thisx, PlayState* play); void EnIk_Update(Actor* thisx, PlayState* play); void EnIk_Draw(Actor* thisx, PlayState* play); -#if 0 +void EnIk_Thaw(EnIk* this, PlayState* play); +s32 EnIk_IsChangingAction(EnIk* this, PlayState* play); +s32 EnIk_ChooseAttack(EnIk* this); +void EnIk_CheckActions(EnIk* this, PlayState* play); +void EnIk_SetupIdle(EnIk* this); +void EnIk_Idle(EnIk* this, PlayState* play); +void EnIk_SetupWalk(EnIk* this); +void EnIk_WalkTowardsPlayer(EnIk* this, PlayState* play); +void EnIk_SetupRun(EnIk* this); +void EnIk_RunTowardsPlayer(EnIk* this, PlayState* play); +void EnIk_SetupVerticalAttack(EnIk* this); +void EnIk_VerticalAttack(EnIk* this, PlayState* play); +void EnIk_SetupTakeOutAxe(EnIk* this); +void EnIk_TakeOutAxe(EnIk* this, PlayState* play); +void EnIk_SetupHorizontalDoubleAttack(EnIk* this); +void EnIk_HorizontalDoubleAttack(EnIk* this, PlayState* play); +void EnIk_SetupSingleHorizontalAttack(EnIk* this); +void EnIk_SingleHorizontalAttack(EnIk* this, PlayState* play); +void EnIk_SetupEndHorizontalAttack(EnIk* this); +void EnIk_EndHorizontalAttack(EnIk* this, PlayState* play); +void EnIk_SetupBlock(EnIk* this); +void EnIk_Block(EnIk* this, PlayState* play); +void EnIk_SetupReactToAttack(EnIk* this, s32 arg1); +void EnIk_ReactToAttack(EnIk* this, PlayState* play); +void EnIk_SetupDie(EnIk* this); +void EnIk_Die(EnIk* this, PlayState* play); +void EnIk_Frozen(EnIk* this, PlayState* play); +void EnIk_SetupCutscene(EnIk* this); +void EnIk_PlayCutscene(EnIk* this, PlayState* play); +void EnIk_UpdateDamage(EnIk* this, PlayState* play); +void EnIk_UpdateArmor(EnIk* this, PlayState* play); + +typedef struct { + /* 0x0 */ Gfx* unk00; + /* 0x4 */ s16 unk04; +} EnIkUnkStruct; // size = 0x8 + +EnIkUnkStruct sIronKnuckleArmorMarkings[] = { + { gIronKnuckleHelmetMarkingDL, 0x0000 }, + { gIronKnuckleFrontTorsoArmorMarkingDL, 0x0000 }, + { gIronKnuckleRearTorsoArmorMarkingDL, 0x7FFF }, + { gIronKnuckleRivetsMarking2DL, 0x4000 }, + { gIronKnuckleRivetsMarking1DL, 0xC000 }, + { NULL, 0x4000 }, + { NULL, 0xC000 }, +}; + +// sIronKnuckleArmorType[PARAM_VALUE][ARMOR_SECTIONS] +// ARMOR SECTIONS: +// 1 - Main armor +// 2 - Armor Accent (Side of armor and boot tips) +// 3 - Axe Color +static Gfx* sIronKnuckleArmorType[3][3] = { + { gIronKnuckleTanArmorMaterialDL, gIronKnuckleBronzeArmorMaterialDL, gIronKnuckleSilverArmorMaterialDL }, + { gIronKnuckleBlackArmorMaterialDL, gIronKnuckleBrownArmorMaterialDL, gIronKnuckleBrownArmorMaterialDL }, + { gIronKnuckleWhiteArmorMaterialDL, gIronKnuckleGoldArmorMaterialDL, gIronKnuckleGoldArmorMaterialDL }, +}; + const ActorInit En_Ik_InitVars = { ACTOR_EN_IK, ACTORCAT_ENEMY, @@ -29,219 +86,1014 @@ const ActorInit En_Ik_InitVars = { (ActorFunc)EnIk_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8092C01C = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 25, 80, 0, { 0, 0, 0 } }, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_8092C048[2] = { +static ColliderTrisElementInit sTrisElementsInit[2] = { { - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -10.0f, 14.0f, 2.0f }, { -10.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, }, { - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -10.0f, -6.0f, 2.0f }, { 9.0f, -6.0f, 2.0f }, { 9.0f, 14.0f, 2.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_8092C0C0 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_2, COLSHAPE_TRIS, }, - 2, D_8092C048, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sTrisElementsInit), + sTrisElementsInit, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_8092C0D0 = { - { COLTYPE_NONE, AT_NONE | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_TYPE_2, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x04, 0x40 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, BUMP_NONE, OCELEM_NONE, }, +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_NONE | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x04, 0x40 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_8092C120 = { - /* Deku Nut */ DMG_ENTRY(0, 0xF), - /* Deku Stick */ DMG_ENTRY(0, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(0, 0xF), - /* Normal arrow */ DMG_ENTRY(0, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(3, 0x0), - /* Fire arrow */ DMG_ENTRY(0, 0xF), - /* Ice arrow */ DMG_ENTRY(0, 0xF), - /* Light arrow */ DMG_ENTRY(1, 0x4), - /* Goron spikes */ DMG_ENTRY(0, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0xF), - /* Deku bubble */ DMG_ENTRY(0, 0xF), - /* Deku launch */ DMG_ENTRY(0, 0xF), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0xF), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(0, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ DMG_EFF_NONE, + /* 0x4 */ DMG_EFF_FIRE = 0x2, + /* 0x0 */ DMG_EFF_ICE, + /* 0x4 */ DMG_EFF_LIGHT_SPARKS, + /* 0xF */ DMG_EFF_IMMUNE = 0xF, + +} EnIkDmgEff; + +static DamageTable sDamageTableArmor = { + /* Deku Nut */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Deku Stick */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Horse trample */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Explosives */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Zora boomerang */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Normal arrow */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Hookshot */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Goron punch */ DMG_ENTRY(2, DMG_EFF_NONE), + /* Sword */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Goron pound */ DMG_ENTRY(3, DMG_EFF_NONE), + /* Fire arrow */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Ice arrow */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Light arrow */ DMG_ENTRY(1, DMG_EFF_LIGHT_SPARKS), + /* Goron spikes */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Deku spin */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Deku bubble */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Deku launch */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Zora barrier */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Normal shield */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Light ray */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Thrown object */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Zora punch */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Spin attack */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Sword beam */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, DMG_EFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, DMG_EFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DMG_EFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, DMG_EFF_NONE), }; -// static DamageTable sDamageTable = { -static DamageTable D_8092C140 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(3, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +static DamageTable sDamageTableNoArmor = { + /* Deku Nut */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Deku Stick */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Horse trample */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Explosives */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, DMG_EFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Hookshot */ DMG_ENTRY(0, DMG_EFF_IMMUNE), + /* Goron punch */ DMG_ENTRY(2, DMG_EFF_NONE), + /* Sword */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Goron pound */ DMG_ENTRY(3, DMG_EFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, DMG_EFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, DMG_EFF_ICE), + /* Light arrow */ DMG_ENTRY(2, DMG_EFF_LIGHT_SPARKS), + /* Goron spikes */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Deku spin */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Deku launch */ DMG_ENTRY(0, DMG_EFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Normal shield */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Light ray */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Thrown object */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Zora punch */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Spin attack */ DMG_ENTRY(1, DMG_EFF_NONE), + /* Sword beam */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, DMG_EFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, DMG_EFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DMG_EFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, DMG_EFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, DMG_EFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8092C160 = { 18, 25, 80, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 18, 25, 80, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8092C168[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2916, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 12, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; -#endif +static EffectBlureInit2 sBlureInit = { + 0, 8, 0, { 255, 255, 150, 200 }, { 255, 255, 255, 64 }, { 255, 255, 150, 0 }, { 255, 255, 255, 0 }, 8, + 0, 2, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, +}; -extern ColliderCylinderInit D_8092C01C; -extern ColliderTrisElementInit D_8092C048[2]; -extern ColliderTrisInit D_8092C0C0; -extern ColliderQuadInit D_8092C0D0; -extern DamageTable D_8092C120; -extern DamageTable D_8092C140; -extern CollisionCheckInfoInit D_8092C160; -extern InitChainEntry D_8092C168[]; +void EnIk_Init(Actor* thisx, PlayState* play) { + static s32 sDisplayListDesegmented = false; + s32 i; + EnIk* this = THIS; -extern UNK_TYPE D_06000CE8; -extern UNK_TYPE D_060015F8; -extern UNK_TYPE D_06001ABC; -extern UNK_TYPE D_06002484; -extern UNK_TYPE D_0600391C; -extern UNK_TYPE D_06004A04; -extern UNK_TYPE D_06005254; -extern UNK_TYPE D_060057F4; -extern UNK_TYPE D_06006294; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(play, &this->skelAnime, &gIronKnuckleSkel, &gIronKnuckleWalkAnim, this->jointTable, + this->morphTable, IRON_KNUCKLE_LIMB_MAX); + Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + Collider_InitAndSetTris(play, &this->colliderTris, &this->actor, &sTrisInit, this->shieldColliderItems); + Collider_InitAndSetQuad(play, &this->colliderQuad, &this->actor, &sQuadInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTableArmor, &sColChkInfoInit); + this->actor.params = IK_GET_ARMOR_TYPE(&this->actor); + this->actor.params--; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/EnIk_Init.s") + Effect_Add(play, &this->effectIndex, EFFECT_BLURE2, 0, 0, &sBlureInit); + if (!sDisplayListDesegmented) { + for (i = 0; i < ARRAY_COUNT(sIronKnuckleArmorType); i++) { + sIronKnuckleArmorType[i][0] = Lib_SegmentedToVirtual(sIronKnuckleArmorType[i][0]); + sIronKnuckleArmorType[i][1] = Lib_SegmentedToVirtual(sIronKnuckleArmorType[i][1]); + sIronKnuckleArmorType[i][2] = Lib_SegmentedToVirtual(sIronKnuckleArmorType[i][2]); + } + sDisplayListDesegmented = true; + } + EnIk_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/EnIk_Destroy.s") +void EnIk_Destroy(Actor* thisx, PlayState* play) { + EnIk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929AF8.s") + Collider_DestroyTris(play, &this->colliderTris); + Collider_DestroyCylinder(play, &this->colliderCylinder); + Collider_DestroyQuad(play, &this->colliderQuad); + Effect_Destroy(play, this->effectIndex); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929B6C.s") +void EnIk_Freeze(EnIk* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.65f; + this->drawDmgEffFrozenSteamScale = 97.5f * 0.01f; + this->drawDmgEffAlpha = 1.0f; + this->timer = 80; + this->actor.flags &= ~ACTOR_FLAG_400; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929BEC.s") +void EnIk_Thaw(EnIk* this, PlayState* play) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); + this->actor.flags |= ACTOR_FLAG_400; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929C80.s") +void EnIk_HitArmor(EnIk* this, PlayState* play) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.65f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->colliderCylinder.info.bumper.hitPos.x, + this->colliderCylinder.info.bumper.hitPos.y, this->colliderCylinder.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929D04.s") +s32 EnIk_IsChangingAction(EnIk* this, PlayState* play) { + if ((this->drawArmorFlags) && (this->actionFunc != EnIk_Block) && + func_800BE184(play, &this->actor, 100.0f, 0x2710, 0x4000, this->actor.shape.rot.y)) { + EnIk_SetupBlock(this); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929E2C.s") +s32 EnIk_ChooseAttack(EnIk* this) { + s32 absYawDiff; + s32 detectionThreshold; // angle threshold an Iron Knuckle will use to trigger a horizontal attack -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929E88.s") + if ((this->actor.xzDistToPlayer < 100.0f) && (fabsf(this->actor.playerHeightRel) < 150.0f)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929F20.s") + detectionThreshold = (this->drawArmorFlags == 0) ? 0xAAA : 0x3FFC; + absYawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_80929FC8.s") + if (detectionThreshold >= absYawDiff) { + if (Rand_ZeroOne() < 0.5f) { + EnIk_SetupVerticalAttack(this); + return true; + } + EnIk_SetupHorizontalDoubleAttack(this); + return true; + } else if ((this->drawArmorFlags) || ((absYawDiff > 0x4000) && (Rand_ZeroOne() < 0.1f))) { + EnIk_SetupSingleHorizontalAttack(this); + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A020.s") +void EnIk_CheckActions(EnIk* this, PlayState* play) { + if (!EnIk_IsChangingAction(this, play) && !EnIk_ChooseAttack(this)) { + if (this->drawArmorFlags) { + EnIk_SetupRun(this); + } else { + EnIk_SetupWalk(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A124.s") +void EnIk_SetupIdle(EnIk* this) { + f32 frameCount = Animation_GetLastFrame(&gIronKnuckleHorizontalAttackAnim); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A188.s") + if (this->drawArmorFlags) { + this->timer = 10; + } else { + this->timer = 0; + } + Animation_Change(&this->skelAnime, &gIronKnuckleEndHorizontalAttackAnim, 1.0f, frameCount, frameCount, + ANIMMODE_ONCE, this->timer); + this->actionFunc = EnIk_Idle; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A28C.s") +void EnIk_Idle(EnIk* this, PlayState* play) { + if (this->timer > 0) { + this->timer--; + SkelAnime_Update(&this->skelAnime); + if (this->timer == 0) { + EnIk_CheckActions(this, play); + } + } else if (this->colliderCylinder.base.acFlags & AC_HIT) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); + func_801A2E54(NA_BGM_MINI_BOSS); + this->actor.hintId = 0x35; + this->colliderCylinder.base.acFlags &= ~AC_HIT; + this->invincibilityFrames = 12; + EnIk_SetupWalk(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A33C.s") +void EnIk_SetupWalk(EnIk* this) { + Animation_MorphToLoop(&this->skelAnime, &gIronKnuckleWalkAnim, -4.0f); + this->actor.speedXZ = 0.9f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnIk_WalkTowardsPlayer; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A570.s") +void EnIk_WalkTowardsPlayer(EnIk* this, PlayState* play) { + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A5BC.s") + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 16.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_WALK); + } + yawDiff = this->actor.wallYaw - this->actor.shape.rot.y; + if ((this->actor.bgCheckFlags & 8) && (ABS_ALT(yawDiff) >= 0x4000)) { + yawDiff = (this->actor.yawTowardsPlayer > 0) ? this->actor.wallYaw - 0x4000 : this->actor.wallYaw + 0x4000; + Math_ScaledStepToS(&this->actor.shape.rot.y, yawDiff, 0x320); + } else { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x320); + } + this->actor.world.rot.y = this->actor.shape.rot.y; + if (!EnIk_IsChangingAction(this, play)) { + EnIk_ChooseAttack(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A680.s") +void EnIk_SetupRun(EnIk* this) { + Animation_MorphToLoop(&this->skelAnime, &gIronKnuckleRunAnim, -4.0f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TWINROBA_SHOOT_VOICE); + this->actor.speedXZ = 2.5f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnIk_RunTowardsPlayer; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A754.s") +void EnIk_RunTowardsPlayer(EnIk* this, PlayState* play) { + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A8D8.s") + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 9.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_WALK); + } + yawDiff = this->actor.wallYaw - this->actor.shape.rot.y; + if ((this->actor.bgCheckFlags & 8) && (ABS_ALT(yawDiff) >= 0x4000)) { + yawDiff = (this->actor.yawTowardsPlayer > 0) ? this->actor.wallYaw - 0x4000 : this->actor.wallYaw + 0x4000; + Math_ScaledStepToS(&this->actor.shape.rot.y, yawDiff, 0x4B0); + } else { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x4B0); + } + this->actor.world.rot.y = this->actor.shape.rot.y; + if (!EnIk_IsChangingAction(this, play)) { + EnIk_ChooseAttack(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092A994.s") +void EnIk_SetupVerticalAttack(EnIk* this) { + s32 pad; + f32 playbackSpeed; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092AA6C.s") + this->actor.speedXZ = 0.0f; + if (this->drawArmorFlags) { + playbackSpeed = 1.5f; + } else { + playbackSpeed = 1.2f; + } + Animation_Change(&this->skelAnime, &gIronKnuckleVerticalAttackAnim, playbackSpeed, 0.0f, + Animation_GetLastFrame(&gIronKnuckleVerticalAttackAnim.common), 3, -4.0f); + this->timer = 0; + this->blurEffectSpawnLock = -1; + this->actionFunc = EnIk_VerticalAttack; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092AB14.s") +void EnIk_VerticalAttack(EnIk* this, PlayState* play) { + Vec3f particlePos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092AB50.s") + this->timer++; + if (!(this->skelAnime.curFrame < 7.0f) || !EnIk_IsChangingAction(this, play)) { + if (Animation_OnFrame(&this->skelAnime, 15.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092ABD8.s") + } else if (Animation_OnFrame(&this->skelAnime, 21.0f)) { + particlePos.x = (Math_SinS((this->actor.shape.rot.y + 0x6A4)) * 70.0f) + this->actor.world.pos.x; + particlePos.z = (Math_CosS((this->actor.shape.rot.y + 0x6A4)) * 70.0f) + this->actor.world.pos.z; + particlePos.y = this->actor.world.pos.y; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_HIT_GND); + Camera_AddQuake(GET_ACTIVE_CAM(play), 2, 25, 5); + Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); + CollisionCheck_SpawnShieldParticles(play, &particlePos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092AC4C.s") + if ((this->skelAnime.curFrame > 13.0f) && (this->skelAnime.curFrame < 23.0f)) { + this->colliderQuad.base.atFlags |= AT_ON; + if (this->drawArmorFlags) { + this->actor.speedXZ = sin_rad((this->skelAnime.curFrame - 13.0f) * (M_PI / 20)) * 10.0f; + } + } else { + this->colliderQuad.base.atFlags &= ~AT_ON; + this->actor.speedXZ = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092ACFC.s") + if ((this->drawArmorFlags) && (this->skelAnime.curFrame < 13.0f)) { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x5DC); + this->actor.world.rot.y = this->actor.shape.rot.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092ADB4.s") + if (SkelAnime_Update(&this->skelAnime)) { + EnIk_SetupTakeOutAxe(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092AE14.s") +void EnIk_SetupTakeOutAxe(EnIk* this) { + Animation_PlayOnce(&this->skelAnime, &gIronKnuckleEndVerticalAttackAnim); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_PULLOUT); + this->actionFunc = EnIk_TakeOutAxe; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092AFB4.s") +void EnIk_TakeOutAxe(EnIk* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->skelAnime.animation == &gIronKnuckleRecoverVerticalAttackAnim) { + EnIk_CheckActions(this, play); + } else { + Animation_Change( + &this->skelAnime, &gIronKnuckleRecoverVerticalAttackAnim, (this->drawArmorFlags) ? 1.5f : 1.0f, 0.0f, + Animation_GetLastFrame(&gIronKnuckleRecoverVerticalAttackAnim.common), ANIMMODE_ONCE_INTERP, 0.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092AFD4.s") +void EnIk_SetupHorizontalDoubleAttack(EnIk* this) { + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skelAnime, &gIronKnuckleHorizontalAttackAnim, (this->drawArmorFlags) ? 1.3f : 1.0f, 0.0f, + Animation_GetLastFrame(&gIronKnuckleHorizontalAttackAnim.common), ANIMMODE_ONCE_INTERP, + (this->drawArmorFlags) ? 4.0f : 10.0f); + this->timer = 0; + this->blurEffectSpawnLock = -1; + this->actionFunc = EnIk_HorizontalDoubleAttack; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092B03C.s") +void EnIk_HorizontalDoubleAttack(EnIk* this, PlayState* play) { + f32 phi_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092B098.s") + this->timer++; + if ((Animation_OnFrame(&this->skelAnime, 1.0f)) || (Animation_OnFrame(&this->skelAnime, 13.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); + } + if (((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 9.0f)) || + ((this->skelAnime.curFrame > 12.0f) && (this->skelAnime.curFrame < 20.0f))) { + if (this->drawArmorFlags) { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x5DC); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (this->skelAnime.curFrame > 12.0f) { + phi_f2 = this->skelAnime.curFrame - 12.0f; + } else { + phi_f2 = this->skelAnime.curFrame - 1.0f; + } + this->actor.speedXZ = sin_rad((M_PI / 8) * phi_f2) * 4.5f; + } + this->colliderQuad.base.atFlags |= AT_ON; + } else { + this->colliderQuad.base.atFlags &= ~AT_ON; + this->actor.speedXZ = 0.0f; + } + if (SkelAnime_Update(&this->skelAnime)) { + EnIk_SetupEndHorizontalAttack(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092B1B4.s") +void EnIk_SetupSingleHorizontalAttack(EnIk* this) { + f32 playSpeed; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092B46C.s") + this->actor.speedXZ = 0.0f; + if (this->drawArmorFlags) { + this->actor.world.rot.z = 0x1000; + playSpeed = 1.3f; + } else { + this->actor.world.rot.z = 0xB00; + playSpeed = 1.0f; + } + Animation_Change(&this->skelAnime, &gIronKnuckleHorizontalAttackAnim, playSpeed, 12.0f, + Animation_GetLastFrame(&gIronKnuckleHorizontalAttackAnim.common), ANIMMODE_ONCE_INTERP, 5.0f); + this->timer = 0; + this->blurEffectSpawnLock = -1; + this->actionFunc = EnIk_SingleHorizontalAttack; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/EnIk_Update.s") +void EnIk_SingleHorizontalAttack(EnIk* this, PlayState* play) { + this->timer++; + if (Animation_OnFrame(&this->skelAnime, 13.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); + } + if ((this->skelAnime.curFrame > 12.0f) && (this->skelAnime.curFrame < 20.0f)) { + this->colliderQuad.base.atFlags |= AT_ON; + } else { + this->colliderQuad.base.atFlags &= ~AT_ON; + } + this->actor.shape.rot.y += this->actor.world.rot.z; + this->actor.world.rot.y = this->actor.shape.rot.y; + if (SkelAnime_Update(&this->skelAnime)) { + EnIk_SetupEndHorizontalAttack(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092B900.s") +void EnIk_SetupEndHorizontalAttack(EnIk* this) { + Animation_Change(&this->skelAnime, &gIronKnuckleEndHorizontalAttackAnim, (this->drawArmorFlags) ? 2.0f : 1.0f, 0.0f, + Animation_GetLastFrame(&gIronKnuckleHorizontalAttackAnim), ANIMMODE_ONCE_INTERP, -4.0f); + this->actionFunc = EnIk_EndHorizontalAttack; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092B93C.s") +void EnIk_EndHorizontalAttack(EnIk* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime)) { + EnIk_CheckActions(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/func_8092BC6C.s") +void EnIk_SetupBlock(EnIk* this) { + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skelAnime, &gIronKnuckleBlockAnim, 2.0f, 0.0f, + Animation_GetLastFrame(&gIronKnuckleBlockAnim), ANIMMODE_ONCE, -2.0f); + this->timer = 20; + this->actionFunc = EnIk_Block; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ik/EnIk_Draw.s") +void EnIk_Block(EnIk* this, PlayState* play) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderTris.base); + if (SkelAnime_Update(&this->skelAnime)) { + this->timer--; + if (this->timer == 0) { + EnIk_CheckActions(this, play); + } + } +} + +void EnIk_SetupReactToAttack(EnIk* this, s32 arg1) { + s16 temp_v0; + + if (arg1) { + func_800BE504(&this->actor, &this->colliderCylinder); + } + this->actor.speedXZ = 6.0f; + temp_v0 = (this->actor.world.rot.y - this->actor.shape.rot.y) + 0x8000; + if (ABS_ALT(temp_v0) <= 0x4000) { + Animation_MorphToPlayOnce(&this->skelAnime, &gIronKnuckleFrontHitAnim, -4.0f); + } else { + Animation_MorphToPlayOnce(&this->skelAnime, &gIronKnuckleBackHitAnim, -4.0f); + } + this->actionFunc = EnIk_ReactToAttack; +} + +void EnIk_ReactToAttack(EnIk* this, PlayState* play) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); + if (this->subCamId != SUB_CAM_ID_DONE) { + Play_CameraSetAtEye(play, this->subCamId, &this->actor.focus.pos, &Play_GetCamera(play, this->subCamId)->eye); + } + if (SkelAnime_Update(&this->skelAnime)) { + if (this->subCamId != SUB_CAM_ID_DONE) { + ActorCutscene_Stop(this->actor.cutscene); + this->subCamId = SUB_CAM_ID_DONE; + EnIk_SetupIdle(this); + } else { + EnIk_CheckActions(this, play); + } + } else { + this->actor.colorFilterTimer = 12; + this->invincibilityFrames = 12; + } +} + +void EnIk_SetupDie(EnIk* this) { + this->actor.speedXZ = 0.0f; + Animation_MorphToPlayOnce(&this->skelAnime, &gIronKnuckleDeathAnim, -4.0f); + this->timer = 24; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_DEAD); + this->actionFunc = EnIk_Die; +} + +void EnIk_Die(EnIk* this, PlayState* play) { + static Vec3f sEffectVelAndAccel = { 0.0f, 0.5f, 0.0f }; + s32 i; + Vec3f effectPos; + + this->invincibilityFrames = 12; + if (SkelAnime_Update(&this->skelAnime)) { + if (this->timer == 24) { + SoundSource_PlaySfxEachFrameAtFixedWorldPos(play, &this->actor.world.pos, 35, + NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } + + if (this->timer != 0) { + this->timer--; + for (i = 6 - (this->timer >> 2); i >= 0; i--) { + effectPos.x = randPlusMinusPoint5Scaled(80.0f) + this->actor.world.pos.x; + effectPos.z = randPlusMinusPoint5Scaled(80.0f) + this->actor.world.pos.z; + effectPos.y = randPlusMinusPoint5Scaled(50.0f) + (this->actor.world.pos.y + 20.0f); + func_800B3030(play, &effectPos, &sEffectVelAndAccel, &sEffectVelAndAccel, 100, 0, 2); + } + if (this->timer == 0) { + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xB0); + ActorCutscene_Stop(this->actor.cutscene); + Actor_MarkForDeath(&this->actor); + } + } + } else if (Animation_OnFrame(&this->skelAnime, 23.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_WALK); + } +} + +void EnIk_SetupFrozen(EnIk* this) { + this->invincibilityFrames = 0; + this->actionFunc = EnIk_Frozen; + this->actor.speedXZ = 0.0f; +} + +void EnIk_Frozen(EnIk* this, PlayState* play) { + if (this->timer != 0) { + this->timer--; + } + if (this->timer == 0) { + EnIk_Thaw(this, play); + if (this->actor.colChkInfo.health == 0) { + EnIk_SetupCutscene(this); + } else { + EnIk_CheckActions(this, play); + } + } +} + +void EnIk_SetupCutscene(EnIk* this) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actor.speedXZ = 0.0f; + if (this->actor.colChkInfo.health != 0) { + func_800BE504(&this->actor, &this->colliderCylinder); + } + this->actionFunc = EnIk_PlayCutscene; +} + +void EnIk_PlayCutscene(EnIk* this, PlayState* play) { + Vec3f subCamEye; + + this->invincibilityFrames = 12; + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + if (this->actor.cutscene != -1) { + ActorCutscene_StartAndSetFlag(this->actor.cutscene, &this->actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + subCamEye.x = (Math_SinS((this->actor.shape.rot.y - 0x2000)) * 120.0f) + this->actor.focus.pos.x; + subCamEye.y = this->actor.focus.pos.y + 20.0f; + subCamEye.z = (Math_CosS((this->actor.shape.rot.y - 0x2000)) * 120.0f) + this->actor.focus.pos.z; + Play_CameraSetAtEye(play, this->subCamId, &this->actor.focus.pos, &subCamEye); + } + if (this->actor.colChkInfo.health != 0) { + EnIk_SetupReactToAttack(this, false); + } else { + EnIk_SetupDie(this); + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void EnIk_UpdateDamage(EnIk* this, PlayState* play) { + s32 pad; + + if (this->actionFunc == EnIk_Idle) { + return; + } + if (this->colliderTris.base.acFlags & AC_BOUNCED) { + f32 frame = Animation_GetLastFrame(&gIronKnuckleBlockAnim) - 2.0f; + + if (this->skelAnime.curFrame < frame) { + this->skelAnime.curFrame = frame; + } + this->colliderTris.base.acFlags &= ~AC_BOUNCED; + this->colliderCylinder.base.acFlags &= ~AC_HIT; + } else if (this->colliderCylinder.base.acFlags & AC_HIT) { + s32 isArmorBroken = false; + + Actor_SetDropFlag(&this->actor, &this->colliderCylinder.info); + this->colliderCylinder.base.acFlags &= ~AC_HIT; + if ((this->actor.colChkInfo.damageEffect != DMG_EFF_IMMUNE) && + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + (!(this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)))) { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 12); + this->invincibilityFrames = 12; + EnIk_Thaw(this, play); + this->colliderQuad.base.atFlags &= ~AT_ON; + if (Actor_ApplyDamage(&this->actor) == 0) { + if (this->drawArmorFlags == 0) { + this->actor.colChkInfo.health = 9; + isArmorBroken = true; + } else { + Enemy_StartFinishingBlow(play, &this->actor); + func_801A2ED8(); + } + } + if (isArmorBroken == true) { + this->drawArmorFlags = 1; + this->colliderCylinder.base.colType = 3; + this->actor.colChkInfo.damageTable = &sDamageTableNoArmor; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_ARMOR_OFF_DEMO); + EnIk_SetupCutscene(this); + } else if (this->drawArmorFlags) { + if (this->actor.colChkInfo.damageEffect == DMG_EFF_ICE) { + EnIk_Freeze(this); + EnIk_SetupFrozen(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->invincibilityFrames = 12; + } + } else { + if (this->actor.colChkInfo.damageEffect == DMG_EFF_FIRE) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.65f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } else if (this->actor.colChkInfo.damageEffect == DMG_EFF_LIGHT_SPARKS) { + EnIk_HitArmor(this, play); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_DAMAGE); + if (this->actor.colChkInfo.health != 0) { + EnIk_SetupReactToAttack(this, true); + } else { + EnIk_SetupCutscene(this); + } + } + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_DAMAGE); + if (this->actor.colChkInfo.damageEffect == 4) { + EnIk_HitArmor(this, play); + } + } + } + } +} + +void EnIk_UpdateArmor(EnIk* this, PlayState* play) { + s32 pad; + s32 i; + IronKnuckleEffect* ikEffect; + Vec3f effectPos; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + ikEffect = &this->effects[i]; + + if (ikEffect->enabled) { + Math_Vec3f_Sum(&ikEffect->pos, &ikEffect->vel, &ikEffect->pos); + ikEffect->vel.y += -1.5f; + if (ikEffect->pos.y < this->actor.floorHeight) { + ikEffect->enabled = false; + ikEffect->pos.y = this->actor.floorHeight; + + for (i = 0; i < 4; i++) { + effectPos.x = randPlusMinusPoint5Scaled(20.0f) + ikEffect->pos.x; + effectPos.y = Rand_ZeroFloat(20.0f) + ikEffect->pos.y; + effectPos.z = randPlusMinusPoint5Scaled(20.0f) + ikEffect->pos.z; + func_800B3030(play, &effectPos, &gZeroVec3f, &gZeroVec3f, 40, 7, 2); + } + + SoundSource_PlaySfxAtFixedWorldPos(play, &ikEffect->pos, 11, NA_SE_EN_EXTINCT); + } + } + } +} + +void EnIk_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnIk* this = THIS; + + if (this->actionFunc != EnIk_PlayCutscene) { + EnIk_UpdateDamage(this, play); + } else { + this->colliderTris.base.acFlags &= ~AC_BOUNCED; + this->colliderCylinder.base.acFlags &= ~AC_HIT; + } + this->actionFunc(this, play); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 75.0f, 30.0f, 30.0f, 0x1D); + this->actor.focus.rot.y = this->actor.shape.rot.y; + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); + if (this->invincibilityFrames == 0) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderCylinder.base); + } else { + this->invincibilityFrames--; + } + if (this->colliderQuad.base.atFlags & AT_ON) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderQuad.base); + } + if (this->actionFunc == EnIk_Block) { + f32 cos; + f32 sin; + Vec3f sp5C; + Vec3f sp50; + Vec3f sp44; + + cos = Math_CosS(this->actor.shape.rot.y); + sin = Math_SinS(this->actor.shape.rot.y); + + sp44.x = (this->actor.world.pos.x - (30.0f * cos)) + (20.0f * sin); + sp44.y = this->actor.world.pos.y; + sp44.z = this->actor.world.pos.z + (30.0f * sin) + (20.0f * cos); + + sp50.x = this->actor.world.pos.x + (30.0f * cos) + (20.0f * sin); + sp50.y = this->actor.world.pos.y + 80.0f; + sp50.z = (this->actor.world.pos.z - (30.0f * sin)) + (20.0f * cos); + + sp5C.x = sp44.x; + sp5C.y = sp50.y; + sp5C.z = sp44.z; + + Collider_SetTrisVertices(&this->colliderTris, 0, &sp44, &sp50, &sp5C); + sp5C.x = sp50.x; + sp5C.y = sp44.y; + sp5C.z = sp50.z; + Collider_SetTrisVertices(&this->colliderTris, 1, &sp44, &sp5C, &sp50); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderTris.base); + } + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.325f; + if ((this->drawDmgEffAlpha + 1.0f) * 0.325f > 0.65f) { + this->drawDmgEffScale = 0.65f; + } else { + this->drawDmgEffScale = this->drawDmgEffScale; + } + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.65f, 0.01625f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + EnIk_UpdateArmor(this, play); +} + +s8 D_8092C1A8[] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 3, 5, 4, 6, 1, 2, -1, -1, 0, 0, +}; + +s32 EnIk_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnIk* this = THIS; + + if (this->drawArmorFlags) { + if (D_8092C1A8[limbIndex] > 0) { + *dList = NULL; + } + } + return false; +} + +void EnIk_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_8092C1C8 = { 2000.0f, -200.0f, -5200.0f }; + static Vec3f D_8092C1D4 = { 300.0f, -200.0f, 0.0f }; + static s8 limbPosIndex[] = { + -1, -1, -1, 0, 1, 2, 3, 4, 5, -1, -1, -1, 6, -1, -1, 7, + -1, -1, 8, -1, 9, 10, -1, 11, -1, 12, -1, -1, -1, -1, 0, 0, + }; + + EnIk* this = THIS; + s32 index = D_8092C1A8[limbIndex]; + Gfx* xlu; + IronKnuckleEffect* ikEffect; + s16 sp76; + Vec3f vtxC; + Vec3f vtxD; + Vec3f vtxB; + Vec3f vtxA; + MtxF* mf; + + if (this->drawArmorFlags == 0x1) { + if (index > 0) { + ikEffect = &this->effects[index]; + mf = Matrix_GetCurrent(); + ikEffect->pos.x = mf->mf[3][0]; + ikEffect->pos.y = mf->mf[3][1]; + ikEffect->pos.z = mf->mf[3][2]; + Matrix_MtxFToYXZRot(mf, &ikEffect->rot, false); + ikEffect->enabled = true; + sp76 = sIronKnuckleArmorMarkings[index].unk04 + (((s32)Rand_Next() >> 0x13) + this->actor.shape.rot.y); + ikEffect->vel.x = Math_SinS(sp76) * 5.0f; + ikEffect->vel.y = 6.0f; + ikEffect->vel.z = Math_CosS(sp76) * 5.0f; + ikEffect->dList = *dList; + } + if (limbIndex == IRON_KNUCKLE_LIMB_WAIST) { + this->drawArmorFlags |= 0x2; + } + } + + if (limbIndex == IRON_KNUCKLE_LIMB_ROOT) { + Matrix_MultZero(&this->actor.focus.pos); + this->colliderCylinder.dim.pos.x = this->actor.focus.pos.x; + this->colliderCylinder.dim.pos.y = this->actor.world.pos.y; + this->colliderCylinder.dim.pos.z = this->actor.focus.pos.z; + } + + if ((limbIndex == IRON_KNUCKLE_LIMB_AXE) && (this->blurEffectSpawnLock != this->timer) && + ((this->actionFunc == EnIk_VerticalAttack) || (this->actionFunc == EnIk_HorizontalDoubleAttack) || + (this->actionFunc == EnIk_SingleHorizontalAttack))) { + Math_Vec3f_Copy(&vtxC, &this->colliderQuad.dim.quad[0]); + Math_Vec3f_Copy(&vtxD, &this->colliderQuad.dim.quad[1]); + Matrix_MultVec3f(&D_8092C1C8, &vtxB); + Matrix_MultVec3f(&D_8092C1D4, &vtxA); + Collider_SetQuadVertices(&this->colliderQuad, &vtxA, &vtxB, &vtxC, &vtxD); + if (this->colliderQuad.base.atFlags & AT_ON) { + EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &vtxB, &vtxA); + } + this->blurEffectSpawnLock = this->timer; + } + + if (limbPosIndex[limbIndex] != -1) { + Matrix_MultZero(&this->limbPos[limbPosIndex[limbIndex]]); + } + + if ((index == 0) || + ((index != -1) && (this->drawArmorFlags == 0) && (sIronKnuckleArmorMarkings[index].unk00 != 0))) { + OPEN_DISPS(play->state.gfxCtx); + + xlu = POLY_XLU_DISP; + + gSPMatrix(&xlu[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&xlu[1], sIronKnuckleArmorMarkings[index].unk00); + POLY_XLU_DISP = &xlu[2]; + + CLOSE_DISPS(play->state.gfxCtx); + } +} + +void EnIk_UpdateArmorDraw(EnIk* this, PlayState* play) { + Gfx* gfxOpa; + Gfx* gfxXlu; + s32 sp54; + IronKnuckleEffect* ikEffect; + s32 i; + + if (this->drawArmorFlags == (0x1 | 0x2)) { + sp54 = 0; + + OPEN_DISPS(play->state.gfxCtx); + gfxOpa = POLY_OPA_DISP; + gfxXlu = POLY_XLU_DISP; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + ikEffect = &this->effects[i]; + if (ikEffect->enabled) { + Matrix_SetTranslateRotateYXZ(ikEffect->pos.x, ikEffect->pos.y, ikEffect->pos.z, &ikEffect->rot); + Matrix_Scale(0.012f, 0.012f, 0.012f, MTXMODE_APPLY); + + gSPMatrix(gfxOpa++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfxOpa++, ikEffect->dList); + + if (sIronKnuckleArmorMarkings[i].unk00 != NULL) { + gSPMatrix(gfxXlu++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfxXlu++, sIronKnuckleArmorMarkings[i].unk00); + } + } else { + sp54++; + } + } + + if (sp54 == ARRAY_COUNT(this->effects)) { + this->drawArmorFlags = (0x1 | 0x4); + } + + POLY_XLU_DISP = gfxXlu; + POLY_OPA_DISP = gfxOpa; + + CLOSE_DISPS(play->state.gfxCtx); + } +} + +void EnIk_Draw(Actor* thisx, PlayState* play) { + static Vec3f D_8092C200 = { 0.53f, 0.53f, 0.53f }; + EnIk* this = THIS; + Gfx* gfx; + Gfx** gfxArmorType; + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_800B8050(&this->actor, play, 0); + func_800B8118(&this->actor, play, 0); + gfx = POLY_XLU_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + POLY_XLU_DISP = &gfx[1]; + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + gfxArmorType = sIronKnuckleArmorType[this->actor.params]; + gSPSegment(&gfx[1], 0x08, gfxArmorType[0]); + gSPSegment(&gfx[2], 0x09, gfxArmorType[1]); + gSPSegment(&gfx[3], 0x0A, gfxArmorType[2]); + POLY_OPA_DISP = &gfx[4]; + + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnIk_OverrideLimbDraw, EnIk_PostLimbDraw, &this->actor); + EnIk_UpdateArmorDraw(this, play); + if (this->actor.colorFilterTimer != 0) { + func_800AE5A0(play); + } + func_800BC620(&this->actor.focus.pos, &D_8092C200, 255, play); + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.h b/src/overlays/actors/ovl_En_Ik/z_en_ik.h index ae6354790..a02c4845e 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.h +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.h @@ -2,16 +2,50 @@ #define Z_EN_IK_H #include "global.h" +#include "objects/object_ik/object_ik.h" struct EnIk; typedef void (*EnIkActionFunc)(struct EnIk*, PlayState*); +#define IK_GET_ARMOR_TYPE(thisx) ((thisx)->params & 0xFF) + +typedef enum { + /* 1 */ IK_TYPE_SILVER = 1, + /* 2 */ IK_TYPE_BLACK, + /* 3 */ IK_TYPE_WHITE +} EnIkType; + +typedef struct { + /* 0x00 */ Gfx* dList; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f vel; + /* 0x1C */ Vec3s rot; + /* 0x24 */ s32 enabled; +} IronKnuckleEffect; // size = 0x28 + typedef struct EnIk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1AC]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[IRON_KNUCKLE_LIMB_MAX]; + /* 0x023C */ Vec3s morphTable[IRON_KNUCKLE_LIMB_MAX]; /* 0x02F0 */ EnIkActionFunc actionFunc; - /* 0x02F4 */ char unk_2F4[0x374]; + /* 0x02F4 */ u8 drawArmorFlags; // Value is 0 when Iron knuckle has armor, then changes to 5 for when armor is lost + /* 0x02F5 */ u8 drawDmgEffType; + /* 0x02F6 */ s16 timer; + /* 0x02F8 */ s16 blurEffectSpawnLock; + /* 0x02FA */ s16 subCamId; + /* 0x02FC */ s16 invincibilityFrames; + /* 0x0300 */ s32 effectIndex; + /* 0x0304 */ f32 drawDmgEffAlpha; + /* 0x0308 */ f32 drawDmgEffScale; + /* 0x030C */ f32 drawDmgEffFrozenSteamScale; + /* 0x0310 */ Vec3f limbPos[13]; + /* 0x03AC */ ColliderCylinder colliderCylinder; + /* 0x03F8 */ ColliderQuad colliderQuad; + /* 0x0478 */ ColliderTris colliderTris; + /* 0x0498 */ ColliderTrisElement shieldColliderItems[2]; + /* 0x0550 */ IronKnuckleEffect effects[7]; } EnIk; // size = 0x668 extern const ActorInit En_Ik_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 54117e8b8..e7d37de26 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -77,7 +77,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -319,7 +319,7 @@ void func_808F374C(EnIn* this, PlayState* play) { this->unk488 %= ARRAY_COUNT(sAnimations); this->unk486 = this->unk488; Animation_Change(&this->skelAnime, sAnimations[this->unk488], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations[this->unk488]), 2, -10.0f); + Animation_GetLastFrame(sAnimations[this->unk488]), ANIMMODE_ONCE, -10.0f); } } @@ -458,84 +458,82 @@ u16 func_808F3DD4(PlayState* play, EnIn* this, u32 arg2) { u16 textId = 0; if (Player_GetMask(play) == PLAYER_MASK_CIRCUS_LEADER) { - s32 requiredScopeTemp; - if (!(gSaveContext.save.weekEventReg[63] & 0x40)) { - return 0x34A9; + textId = 0x34A9; } else if (this->unk4AC & 8) { - return 0x34B1; + textId = 0x34B1; } else { textId = 0x34AF; } - } else { - switch (arg2) { - case 0: - if ((gSaveContext.save.playerForm == PLAYER_FORM_ZORA) || - (gSaveContext.save.playerForm == PLAYER_FORM_GORON)) { - textId = 0x345C; - } else if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { - textId = 0x3460; - } else if (!(gSaveContext.save.weekEventReg[15] & 8)) { - textId = 0x3458; - } else { - textId = 0x345B; - } - break; - case 1: - if (!(gSaveContext.save.weekEventReg[15] & 0x10)) { - textId = 0x3463; - } else { - textId = 0x346B; - } - break; - case 3: - if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { - textId = 0x3485; - } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || - gSaveContext.save.playerForm == PLAYER_FORM_GORON) { - textId = 0x3484; - } else if (!(gSaveContext.save.weekEventReg[56] & 4)) { - textId = 0x346D; - } else { - textId = 0x3482; - } - break; - case 4: - if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || - gSaveContext.save.playerForm == PLAYER_FORM_GORON) { - textId = 0x348A; - } else if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { - textId = 0x348B; - } else if (!(gSaveContext.save.weekEventReg[16] & 1)) { - textId = 0x3486; - } else { - textId = 0x3489; - } - break; - case 5: - if (func_808F33B8()) { - textId = 0x34B3; - } else if (!(gSaveContext.save.weekEventReg[16] & 2)) { - textId = 0x348E; - } else { - textId = 0x3493; - } - break; - case 7: - if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { - textId = 0x34A8; - } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || - gSaveContext.save.playerForm == PLAYER_FORM_GORON) { - textId = 0x34A7; - } else if (!(gSaveContext.save.weekEventReg[16] & 4)) { - textId = 0x3495; - } else { - textId = 0x34A5; - } - } - if (textId == 0) { - textId = 1; - } + return textId; + } + + switch (arg2) { + case 0: + if ((gSaveContext.save.playerForm == PLAYER_FORM_ZORA) || + (gSaveContext.save.playerForm == PLAYER_FORM_GORON)) { + textId = 0x345C; + } else if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + textId = 0x3460; + } else if (!(gSaveContext.save.weekEventReg[15] & 8)) { + textId = 0x3458; + } else { + textId = 0x345B; + } + break; + case 1: + if (!(gSaveContext.save.weekEventReg[15] & 0x10)) { + textId = 0x3463; + } else { + textId = 0x346B; + } + break; + case 3: + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + textId = 0x3485; + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || + gSaveContext.save.playerForm == PLAYER_FORM_GORON) { + textId = 0x3484; + } else if (!(gSaveContext.save.weekEventReg[56] & 4)) { + textId = 0x346D; + } else { + textId = 0x3482; + } + break; + case 4: + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || gSaveContext.save.playerForm == PLAYER_FORM_GORON) { + textId = 0x348A; + } else if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + textId = 0x348B; + } else if (!(gSaveContext.save.weekEventReg[16] & 1)) { + textId = 0x3486; + } else { + textId = 0x3489; + } + break; + case 5: + if (func_808F33B8()) { + textId = 0x34B3; + } else if (!(gSaveContext.save.weekEventReg[16] & 2)) { + textId = 0x348E; + } else { + textId = 0x3493; + } + break; + case 7: + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + textId = 0x34A8; + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || + gSaveContext.save.playerForm == PLAYER_FORM_GORON) { + textId = 0x34A7; + } else if (!(gSaveContext.save.weekEventReg[16] & 4)) { + textId = 0x3495; + } else { + textId = 0x34A5; + } + } + if (textId == 0) { + textId = 1; } return textId; } @@ -579,7 +577,7 @@ s32 func_808F4150(PlayState* play, EnIn* this, s32 arg2, MessageContext* msgCtx) if (msgCtx->choiceIndex == 0) { func_8019F208(); if (gSaveContext.save.playerData.rupees >= play->msgCtx.unk1206C) { - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); if (!(gSaveContext.save.weekEventReg[57] & 1)) { func_808F4108(this, play, 0x3474); } else if (this->unk4AC & 8) { @@ -605,7 +603,7 @@ s32 func_808F4270(PlayState* play, EnIn* this, s32 arg2, MessageContext* msgCtx, if (msgCtx->choiceIndex == 0) { func_8019F208(); if (gSaveContext.save.playerData.rupees >= fee) { - func_801159EC(-fee); + Rupees_ChangeBy(-fee); if (!(gSaveContext.save.weekEventReg[57] & 1)) { if (arg4 != 0) { Actor_ContinueText(play, &this->actor, 0x3474); @@ -750,10 +748,10 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { if (msgCtx->choiceIndex == 0) { func_8019F208(); if (gSaveContext.save.playerData.rupees >= play->msgCtx.unk1206C) { - if (Interface_HasEmptyBottle()) { + if (Inventory_HasEmptyBottle()) { this->actionFunc = func_808F3C40; Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); ret = true; } else { Actor_ContinueText(play, &this->actor, 0x3469); @@ -822,8 +820,8 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { SET_RACE_FLAGS(RACE_FLAG_START); func_800FD750(NA_BGM_HORSE); play->nextEntranceIndex = 0xCE50; - play->unk_1887F = 5; - play->sceneLoadFlag = 0x14; + play->transitionType = TRANS_TYPE_05; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.save.weekEventReg[57] |= 1; break; case 0x3478: @@ -896,7 +894,7 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { break; case 0x347E: func_808F35D8(this, play); - if (Interface_HasEmptyBottle()) { + if (Inventory_HasEmptyBottle()) { this->actionFunc = func_808F3B40; Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); ret = true; @@ -1002,10 +1000,10 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { if (msgCtx->choiceIndex == 0) { func_8019F208(); if (gSaveContext.save.playerData.rupees >= play->msgCtx.unk1206C) { - if (Interface_HasEmptyBottle()) { + if (Inventory_HasEmptyBottle()) { this->actionFunc = func_808F3C40; Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); ret = true; } else { Actor_ContinueText(play, &this->actor, 0x3469); @@ -1069,8 +1067,8 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { SET_RACE_FLAGS(RACE_FLAG_START); func_800FD750(NA_BGM_HORSE); play->nextEntranceIndex = 0xCE50; - play->unk_1887F = 5; - play->sceneLoadFlag = 0x14; + play->transitionType = TRANS_TYPE_05; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.save.weekEventReg[57] |= 1; break; case 0x349D: @@ -1100,7 +1098,7 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { break; case 0x34A1: func_808F35D8(this, play); - if (Interface_HasEmptyBottle()) { + if (Inventory_HasEmptyBottle()) { this->actionFunc = func_808F3B40; Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); ret = true; @@ -1183,12 +1181,12 @@ s32 func_808F5674(PlayState* play, EnIn* this, s32 arg2) { s32 ret = false; switch (Message_GetState(&play->msgCtx)) { - case 2: + case TEXT_STATE_CLOSING: func_808F4054(play, this, arg2, this->actor.textId); ret = true; break; - case 4: - case 5: + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: if (Message_ShouldAdvance(play) && func_808F4414(play, this, arg2)) { func_801477B4(play); ret = true; @@ -1376,7 +1374,7 @@ void EnIn_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); this->unk488 = 1; Animation_Change(&this->skelAnime, &object_in_Anim_016A60, 1.0f, 0.0f, - Animation_GetLastFrame(&object_in_Anim_016A60), 2, 0.0f); + Animation_GetLastFrame(&object_in_Anim_016A60), ANIMMODE_ONCE, 0.0f); Actor_SetScale(&this->actor, 0.01f); this->unk23C = 0; this->unk23D = 1; @@ -1475,23 +1473,22 @@ void EnIn_Update(Actor* thisx, PlayState* play) { void func_808F6334(EnIn* this, PlayState* play) { Player* player = GET_PLAYER(play); - s32 newUnk4C8; + s32 talkState = Message_GetState(&play->msgCtx); - newUnk4C8 = Message_GetState(&play->msgCtx); this->unk4C4 += this->unk4C0 != 0.0f ? 40.0f : -40.0f; this->unk4C4 = CLAMP(this->unk4C4, 0.0f, 80.0f); Matrix_Translate(this->unk4C4, 0.0f, 0.0f, MTXMODE_APPLY); - if (&this->actor == player->targetActor && - !(play->msgCtx.currentTextId >= 0xFF && play->msgCtx.currentTextId <= 0x200) && newUnk4C8 == 3 && - this->unk4C8 == 3) { + if ((&this->actor == player->targetActor) && + !((play->msgCtx.currentTextId >= 0xFF) && (play->msgCtx.currentTextId <= 0x200)) && + (talkState == TEXT_STATE_3) && (this->prevTalkState == TEXT_STATE_3)) { if (!(play->state.frames & 1)) { this->unk4C0 = this->unk4C0 != 0.0f ? 0.0f : 1.0f; } } else { this->unk4C0 = 0.0f; } - this->unk4C8 = newUnk4C8; + this->prevTalkState = talkState; } s32 EnIn_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { diff --git a/src/overlays/actors/ovl_En_In/z_en_in.h b/src/overlays/actors/ovl_En_In/z_en_in.h index 6ffbfdf8d..6c6a2f3dd 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.h +++ b/src/overlays/actors/ovl_En_In/z_en_in.h @@ -59,7 +59,7 @@ typedef struct EnIn { /* 0x4B4 */ Vec3f unk4B4; /* 0x4C0 */ f32 unk4C0; /* 0x4C0 */ f32 unk4C4; - /* 0x4C0 */ s32 unk4C8; + /* 0x4C0 */ s32 prevTalkState; } EnIn; // size = 0x4CC extern const ActorInit En_In_InitVars; diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.c b/src/overlays/actors/ovl_En_Insect/z_en_insect.c index e3a643982..e985f6b5c 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -12,7 +12,7 @@ #define THIS ((EnInsect*)thisx) void EnInsect_Init(Actor* thisx, PlayState* play); -void EnInsect_Destroy(Actor* thisx, PlayState* play); +void EnInsect_Destroy(Actor* thisx, PlayState* play2); void EnInsect_Update(Actor* thisx, PlayState* play); void EnInsect_Draw(Actor* thisx, PlayState* play); @@ -67,7 +67,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -133,7 +133,7 @@ void EnInsect_Init(Actor* thisx, PlayState* play) { SkelAnime_Init(play, &this->skelAnime, &gameplay_keep_Skel_0527A0, &gameplay_keep_Anim_05140C, this->jointTable, this->morphTable, 24); - Animation_Change(&this->skelAnime, &gameplay_keep_Anim_05140C, 1.0f, 0.0f, 0.0f, 1, 0.0f); + Animation_Change(&this->skelAnime, &gameplay_keep_Anim_05140C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, 0.0f); Collider_InitJntSph(play, &this->collider); Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); @@ -165,8 +165,11 @@ void EnInsect_Init(Actor* thisx, PlayState* play) { } } -void EnInsect_Destroy(Actor* thisx, PlayState* play) { - Collider_DestroyJntSph(play, &THIS->collider); +void EnInsect_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnInsect* this = THIS; + + Collider_DestroyJntSph(play, &this->collider); } void func_8091AC78(EnInsect* this) { diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.h b/src/overlays/actors/ovl_En_Insect/z_en_insect.h index 6e30eca32..ae8304cae 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.h +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.h @@ -10,19 +10,19 @@ typedef void (*EnInsectActionFunc)(struct EnInsect*, PlayState*); #define ENINSECT_GET_1(thisx) ((thisx)->params & 1) typedef struct EnInsect { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderJntSph collider; - /* 0x0164 */ ColliderJntSphElement colliderElements[1]; - /* 0x01A4 */ SkelAnime skelAnime; - /* 0x01E8 */ Vec3s jointTable[24]; - /* 0x0278 */ Vec3s morphTable[24]; - /* 0x0308 */ EnInsectActionFunc actionFunc; - /* 0x030C */ u16 unk_30C; - /* 0x030E */ s16 unk_30E; - /* 0x0310 */ s16 unk_310; - /* 0x0312 */ s16 unk_312; - /* 0x0314 */ s16 unk_314; - /* 0x0316 */ s16 unk_316; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElements[1]; + /* 0x1A4 */ SkelAnime skelAnime; + /* 0x1E8 */ Vec3s jointTable[24]; + /* 0x278 */ Vec3s morphTable[24]; + /* 0x308 */ EnInsectActionFunc actionFunc; + /* 0x30C */ u16 unk_30C; + /* 0x30E */ s16 unk_30E; + /* 0x310 */ s16 unk_310; + /* 0x312 */ s16 unk_312; + /* 0x314 */ s16 unk_314; + /* 0x316 */ s16 unk_316; } EnInsect; // size = 0x318 extern const ActorInit En_Insect_InitVars; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 821b02e5f..217f67252 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -618,8 +618,8 @@ unkStruct80B50350 D_80B50350[10]; EnInvadepoh* D_80B503F0; EnInvadepoh* D_80B503F4; EnInvadepoh* D_80B503F8; -AnimatedMaterial* D_80B503FC; -AnimatedMaterial* D_80B50400; +AnimatedMaterial* sAlienEyeBeamTexAnim; +AnimatedMaterial* sAlienEmptyTexAnim; s16 D_80B50404[3]; EnInvadepoh* D_80B5040C; @@ -1225,8 +1225,8 @@ void func_80B44FEC(void) { } void func_80B45080(void) { - D_80B50400 = Lib_SegmentedToVirtual(object_uch_Matanimheader_000560); - D_80B503FC = Lib_SegmentedToVirtual(object_uch_Matanimheader_000550); + sAlienEmptyTexAnim = Lib_SegmentedToVirtual(gAlienEmptyTexAnim); + sAlienEyeBeamTexAnim = Lib_SegmentedToVirtual(gAlienEyeBeamTexAnim); } s32 func_80B450C0(f32* x1, f32* z1, f32 x2, f32 z2, f32 speed) { @@ -1424,11 +1424,11 @@ EnInvadepoh* func_80B458D8(void) { s8 func_80B45980(unkstructInvadepoh1* arg0, s32 arg1) { f32 rand = Rand_ZeroOne(); s32 i; + unkstructInvadepoh1* ptr = arg0; arg1--; - for (i = 0; i < arg1; i++) { - dummy:; - if (arg0[i].unk04 >= rand) { + for (i = 0; i < arg1; i++, ptr++) { + if (ptr->unk04 >= rand) { break; } } @@ -1680,7 +1680,7 @@ void EnInvadepoh_InitAlien(EnInvadepoh* this, PlayState* play) { ActorShape_Init(&this->actor.shape, 6800.0f, ActorShadow_DrawWhiteCircle, 150.0f); this->actor.shape.shadowAlpha = 140; this->actor.flags = (ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_80000000); - if (INVADEPOH_TYPE(this) == TYPE_ALIEN1) { + if (INVADEPOH_TYPE(&this->actor) == TYPE_ALIEN_CARRYING_COW) { this->actor.update = func_80B4D670; this->actor.world.pos.y = this->actor.home.pos.y + 150.0f; } else { @@ -1715,7 +1715,7 @@ void EnInvadepoh_InitChildCow(EnInvadepoh* this, PlayState* play) { void EnInvadepoh_InitRomani(EnInvadepoh* this, PlayState* play) { s32 pad; - s32 temp = INVADEPOH_TYPE(this); + s32 temp = INVADEPOH_TYPE(&this->actor); Actor_ProcessInitChain(&this->actor, sInitChainRomani); @@ -1828,7 +1828,7 @@ void EnInvadepoh_InitCremia(EnInvadepoh* this, PlayState* play) { void EnInvadepoh_Init(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; - D_80B4ECB0[INVADEPOH_TYPE(this)](this, play); + D_80B4ECB0[INVADEPOH_TYPE(&this->actor)](this, play); } void func_80B46BB0(EnInvadepoh* this, PlayState* play) { @@ -1891,7 +1891,7 @@ void func_80B46D28(EnInvadepoh* this, PlayState* play) { void EnInvadepoh_Destroy(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; - D_80B4ECE8[INVADEPOH_TYPE(this)](this, play); + D_80B4ECE8[INVADEPOH_TYPE(&this->actor)](this, play); } void func_80B46DA8(EnInvadepoh* this) { @@ -1997,9 +1997,9 @@ void func_80B47108(EnInvadepoh* this, PlayState* play) { if (this->actionTimer <= 0) { play->nextEntranceIndex = 0x6460; gSaveContext.nextCutsceneIndex = 0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 0x49; - gSaveContext.nextTransition = 0x48; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_73; + gSaveContext.nextTransitionType = TRANS_TYPE_72; D_801BDAA0 = 1; D_801BDA9C = 0; func_80B47248(this); @@ -2015,9 +2015,9 @@ void func_80B471E0(EnInvadepoh* this, PlayState* play) { if (D_80B4E998) { play->nextEntranceIndex = 0x6470; gSaveContext.nextCutsceneIndex = 0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 0x48; - gSaveContext.nextTransition = 0x48; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_72; + gSaveContext.nextTransitionType = TRANS_TYPE_72; func_80B47248(this); } } @@ -2038,9 +2038,9 @@ void func_80B47278(EnInvadepoh* this) { void func_80B47298(EnInvadepoh* this, PlayState* play) { play->nextEntranceIndex = 0x6400; gSaveContext.nextCutsceneIndex = 0xFFF3; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 0x48; - gSaveContext.nextTransition = 0x48; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_72; + gSaveContext.nextTransitionType = TRANS_TYPE_72; gSaveContext.save.weekEventReg[89] |= 0x10; func_80B47304(this); } @@ -2115,7 +2115,7 @@ void func_80B474DC(EnInvadepoh* this, PlayState* play) { } void func_80B47568(EnInvadepoh* this) { - Animation_MorphToLoop(&this->skelAnime, &object_uch_Anim_001D80, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &gAlienFloatAnim, -6.0f); this->collider.base.atFlags &= ~AT_ON; this->collider.base.acFlags &= ~AC_ON; this->collider.base.ocFlags1 &= ~OC1_ON; @@ -2157,8 +2157,8 @@ void func_80B47600(EnInvadepoh* this, PlayState* play) { } void func_80B4770C(EnInvadepoh* this) { - if (this->skelAnime.animation != &object_uch_Anim_001D80) { - Animation_MorphToLoop(&this->skelAnime, &object_uch_Anim_001D80, -6.0f); + if (this->skelAnime.animation != &gAlienFloatAnim) { + Animation_MorphToLoop(&this->skelAnime, &gAlienFloatAnim, -6.0f); } this->collider.base.atFlags |= AT_ON; this->collider.base.acFlags |= AC_ON; @@ -2186,7 +2186,7 @@ void func_80B47830(EnInvadepoh* this) { this->collider.base.atFlags &= ~AT_ON; this->collider.base.acFlags &= ~AC_ON; this->collider.base.ocFlags1 |= OC1_ON; - Animation_PlayLoop(&this->skelAnime, &object_uch_Anim_0006C8); + Animation_PlayLoop(&this->skelAnime, &gAlienJerkingAnim); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); this->alienAlpha = 255; this->actor.draw = func_80B4DB14; @@ -2211,7 +2211,7 @@ void func_80B47938(EnInvadepoh* this) { this->collider.base.atFlags &= ~AT_ON; this->collider.base.acFlags &= ~AC_ON; this->collider.base.ocFlags1 &= ~OC1_ON; - Animation_PlayLoop(&this->skelAnime, &object_uch_Anim_000608); + Animation_PlayLoop(&this->skelAnime, &gAlienDeathAnim); this->actor.flags &= ~ACTOR_FLAG_1; this->actionTimer = 10; this->alienAlpha = 255; @@ -2282,8 +2282,8 @@ void func_80B47BAC(Actor* thisx, PlayState* play) { Actor_SetObjectDependency(play, &this->actor); func_80B45080(); this->actor.update = func_80B47D30; - SkelAnime_InitFlex(play, &this->skelAnime, &object_uch_Skel_004E50, &object_uch_Anim_001D80, this->jointTable, - this->morphTable, 14); + SkelAnime_InitFlex(play, &this->skelAnime, &gAlienSkel, &gAlienFloatAnim, this->jointTable, this->morphTable, + ALIEN_LIMB_MAX); this->skelAnime.curFrame = (this->actor.params & 7) * this->skelAnime.endFrame * 0.125f; func_80B444BC(this, play); func_80B442E4(this); @@ -2475,7 +2475,7 @@ void func_80B4843C(EnInvadepoh* this) { this->behaviorInfo.unk44 = 0.1f; this->behaviorInfo.unk48 = 2000; this->actionTimer = 50; - Animation_Change(&this->skelAnime, &object_ma1_Anim_007328, 2.0f, 0.0f, 0.0f, 0, -5.0f); + Animation_Change(&this->skelAnime, &object_ma1_Anim_007328, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -5.0f); this->actor.draw = func_80B4E324; this->actionFunc = func_80B484EC; } @@ -3402,7 +3402,7 @@ void func_80B4ADB8(EnInvadepoh* this) { } void func_80B4ADCC(EnInvadepoh* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->textId == 0x3331) { if (gSaveContext.save.weekEventReg[22] & 2) { EnInvadepoh_SetTextID(this, play, 0x3334); @@ -3468,7 +3468,8 @@ void func_80B4B048(EnInvadepoh* this, PlayState* play) { if (play->msgCtx.unk120B1 == 0) { if (play->msgCtx.msgMode == 0) { D_80B4E998 = 1; - } else if ((Message_GetState(&play->msgCtx) == 6) || (Message_GetState(&play->msgCtx) == 5)) { + } else if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) || + (Message_GetState(&play->msgCtx) == TEXT_STATE_5)) { D_80B4E998 = 1; } } @@ -3683,7 +3684,7 @@ void func_80B4BA84(Actor* thisx, PlayState* play) { D_80B5040C = func_80B458D8(); if (D_80B5040C == NULL) { - temp_v0_2 = (this->unk3BC < 0) ^ 1; + temp_v0_2 = this->unk3BC >= 0; this->unk3BC = -1; if (temp_v0_2) { func_80B4B820(this); @@ -4147,7 +4148,7 @@ void func_80B4D15C(EnInvadepoh* this) { s32 temp_v1 = this->actor.params & 7; unkstruct80B4EE0C* temp_v0; - Animation_PlayLoop(&this->skelAnime, &object_uch_Anim_001674); + Animation_PlayLoop(&this->skelAnime, &gAlienHoldingCowAnim); this->skelAnime.curFrame = ((this->actor.params & 7) * this->skelAnime.endFrame) * 0.25f; this->alienAlpha = 255; this->actor.draw = func_80B4DB14; @@ -4199,7 +4200,7 @@ void func_80B4D290(EnInvadepoh* this, PlayState* play) { } void func_80B4D3E4(EnInvadepoh* this) { - Animation_PlayLoop(&this->skelAnime, &object_uch_Anim_001674); + Animation_PlayLoop(&this->skelAnime, &gAlienHoldingCowAnim); this->skelAnime.curFrame = (this->actor.params & 7) * this->skelAnime.endFrame * 0.25f; this->alienAlpha = 255; this->actor.draw = NULL; @@ -4276,8 +4277,8 @@ void func_80B4D670(Actor* thisx, PlayState* play) { Actor_SetObjectDependency(play, &this->actor); func_80B45080(); this->actor.update = func_80B4D760; - SkelAnime_InitFlex(play, &this->skelAnime, &object_uch_Skel_004E50, &object_uch_Anim_001674, this->jointTable, - this->morphTable, 14); + SkelAnime_InitFlex(play, &this->skelAnime, &gAlienSkel, &gAlienHoldingCowAnim, this->jointTable, + this->morphTable, ALIEN_LIMB_MAX); if (invadepohType < 3) { func_80B453F4(this, play, invadepohType); func_80B4D15C(this); @@ -4299,7 +4300,6 @@ void func_80B4D760(Actor* thisx, PlayState* play) { } void func_80B4D7B8(PlayState* play) { - s32 temp_v0; u32 temp_s5; u32 temp_s6; unkStruct80B50350* phi_s2; @@ -4309,15 +4309,13 @@ void func_80B4D7B8(PlayState* play) { func_8012C2DC(play->state.gfxCtx); for (phi_s2 = D_80B50350, i = 0; i < 10; phi_s2++, i++) { if (phi_s2->unk1 > 0) { - temp_v0 = play->gameplayFrames; - temp_s5 = (temp_v0 + ((0x10 * i) & 0xFFU)) & 0x7F; - temp_s6 = (u8)(temp_v0 * -0xF); + temp_s5 = (play->gameplayFrames + ((0x10 * i) & 0xFF)) & 0x7F; + temp_s6 = (u8)(play->gameplayFrames * -0xF); Matrix_Translate(phi_s2->unk4.x, phi_s2->unk4.y, phi_s2->unk4.z, MTXMODE_NEW); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, phi_s2->unk2); gDPSetEnvColor(POLY_XLU_DISP++, 255, 50, 0, 0); - temp_v0 = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, 0, temp_s5, 0, 0x20, 0x40, 1, 0, temp_s6, 0x20, 0x40)); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4332,7 +4330,7 @@ void func_80B4D9B4(Actor* thisx, PlayState* play) { } s32 func_80B4D9D8(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { - return 0; + return false; } void func_80B4D9F4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { @@ -4373,14 +4371,14 @@ void func_80B4DB14(Actor* thisx, PlayState* play) { if (this->alienAlpha == 255) { func_8012C28C(play->state.gfxCtx); - AnimatedMat_Draw(play, D_80B50400); + AnimatedMat_Draw(play, sAlienEmptyTexAnim); Scene_SetRenderModeXlu(play, 0, 1); gDPSetEnvColor(spCC->polyOpa.p++, 0, 0, 0, 255); spCC->polyOpa.p = SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80B4D9D8, func_80B4D9F4, &this->actor, spCC->polyOpa.p); } else { - AnimatedMat_Draw(play, D_80B50400); + AnimatedMat_Draw(play, sAlienEmptyTexAnim); Scene_SetRenderModeXlu(play, 1, 2); gDPSetEnvColor(spCC->polyXlu.p++, 0, 0, 0, this->alienAlpha); spCC->polyXlu.p = SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, @@ -4389,7 +4387,7 @@ void func_80B4DB14(Actor* thisx, PlayState* play) { } if (this->alienBeamAlpha != 0) { - AnimatedMat_Draw(play, D_80B503FC); + AnimatedMat_Draw(play, sAlienEyeBeamTexAnim); spB8 = play->state.gfxCtx; gfx = spBC = spB8->polyXlu.p; gDPPipeSync(spBC++); @@ -4397,10 +4395,10 @@ void func_80B4DB14(Actor* thisx, PlayState* play) { gDPSetEnvColor(spBC++, 255, 255, 255, this->alienBeamAlpha * (150.0f / 255.0f)); Matrix_Mult(&D_80B502A0, MTXMODE_NEW); gSPMatrix(spBC++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(spBC++, object_uch_DL_000080); + gSPDisplayList(spBC++, gAlienEyeBeamDL); Matrix_Mult(&D_80B502E0, MTXMODE_NEW); gSPMatrix(spBC++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(spBC++, object_uch_DL_000080); + gSPDisplayList(spBC++, gAlienEyeBeamDL); spB8->polyXlu.p = spBC; } } @@ -4411,7 +4409,7 @@ void func_80B4DB14(Actor* thisx, PlayState* play) { Matrix_Scale(this->alienDeathEffectScale.x, this->alienDeathEffectScale.y, this->alienDeathEffectScale.z, MTXMODE_APPLY); gSPMatrix(spCC->polyXlu.p++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(spCC->polyXlu.p++, object_uch_DL_000720); + gSPDisplayList(spCC->polyXlu.p++, gAlienDeathFlashDL); } if (this->drawAlien) { @@ -4453,7 +4451,7 @@ s32 func_80B4E120(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s EnInvadepoh* this = THIS; rot->x -= this->actor.shape.rot.x; } - return 0; + return false; } void func_80B4E158(Actor* thisx, PlayState* play) { @@ -4485,7 +4483,7 @@ s32 func_80B4E200(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s rot->x += (s16)(this->behaviorInfo.unk34 * this->behaviorInfo.unk20.y); rot->z += this->behaviorInfo.unk40; } - return 0; + return false; } void func_80B4E2AC(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { @@ -4513,7 +4511,8 @@ void func_80B4E324(Actor* thisx, PlayState* play) { } void func_80B4E3F0(Actor* thisx, PlayState* play) { - s32 pad[2]; + s32 pad; + EnInvadepoh* this = THIS; Vec3f sp5C; Matrix_Push(); @@ -4525,7 +4524,7 @@ void func_80B4E3F0(Actor* thisx, PlayState* play) { sp5C.z += thisx->world.pos.z; EnInvadepoh_SetSysMatrix(&sp5C); Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_RotateZS(((EnInvadepoh*)thisx)->unk304, MTXMODE_APPLY); + Matrix_RotateZS(this->unk304, MTXMODE_APPLY); OPEN_DISPS(play->state.gfxCtx); func_8012C2DC(play->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4549,7 +4548,7 @@ s32 func_80B4E5B0(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s rot->z += this->behaviorInfo.unk20.z; } - return 0; + return false; } void func_80B4E61C(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { @@ -4583,7 +4582,7 @@ s32 func_80B4E6E4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s rot->x += (s16)(this->behaviorInfo.unk34 * this->behaviorInfo.unk20.y); } - return 0; + return false; } void func_80B4E784(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h index 8db9b6412..3826397a8 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h @@ -9,7 +9,7 @@ typedef void (*EnInvadepohInitFunc)(struct EnInvadepoh*, PlayState*); typedef void (*EnInvadepohDestroyFunc)(struct EnInvadepoh*, PlayState*); typedef void (*EnInvadepohActionFunc)(struct EnInvadepoh*, PlayState*); -#define INVADEPOH_TYPE(x) (x->actor.params >> 4 & 0xF) +#define INVADEPOH_TYPE(thisx) (((thisx)->params >> 4) & 0xF) typedef enum{ /* 0 */ TYPE_UNK0, @@ -25,7 +25,7 @@ typedef enum{ /* 10 */ TYPE_DOG, /* 11 */ TYPE_CREMIA, /* 12 */ TYPE_ROMANI5, - /* 13 */ TYPE_ALIEN1 + /* 13 */ TYPE_ALIEN_CARRYING_COW } EnInvadepohType; typedef enum { diff --git a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.h b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.h index 2841e39db..35cbb4da9 100644 --- a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.h +++ b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.h @@ -8,9 +8,9 @@ struct EnInvadepohDemo; typedef void (*EnInvadepohDemoActionFunc)(struct EnInvadepohDemo*, PlayState*); typedef struct EnInvadepohDemo { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnInvadepohDemoActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x180]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnInvadepohDemoActionFunc actionFunc; + /* 0x148 */ char unk_148[0x180]; } EnInvadepohDemo; // size = 0x2C8 extern const ActorInit En_Invadepoh_Demo_InitVars; diff --git a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h index c5b9d7733..49d9bd6ef 100644 --- a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h +++ b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h @@ -11,11 +11,11 @@ typedef void (*EnInvisibleRuppeActionFunc)(struct EnInvisibleRuppe*, PlayState*) #define INVISIBLERUPPE_GET_1FC(thisx) (((thisx)->actor.params & 0x1FC) >> 2) typedef struct EnInvisibleRuppe { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ s16 unk_190; - /* 0x0192 */ s16 unk_192; - /* 0x0194 */ EnInvisibleRuppeActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ s16 unk_190; + /* 0x192 */ s16 unk_192; + /* 0x194 */ EnInvisibleRuppeActionFunc actionFunc; } EnInvisibleRuppe; // size = 0x198 extern const ActorInit En_Invisible_Ruppe_InitVars; 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 0652b84bf..080abbf4a 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.h +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.h @@ -19,13 +19,13 @@ typedef void (*EnIshiUnkFunc2)(Actor*, PlayState*); #define ENISHI_GET_FE00(thisx) (((thisx)->params >> 9) & 0x7F) typedef struct EnIshi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ EnIshiActionFunc actionFunc; - /* 0x0194 */ s8 unk_194; - /* 0x0195 */ s8 unk_195; - /* 0x0196 */ s8 unk_196; - /* 0x0197 */ u8 unk_197; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ EnIshiActionFunc actionFunc; + /* 0x194 */ s8 unk_194; + /* 0x195 */ s8 unk_195; + /* 0x196 */ s8 unk_196; + /* 0x197 */ u8 unk_197; } EnIshi; // size = 0x198 extern const ActorInit En_Ishi_InitVars; diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.c b/src/overlays/actors/ovl_En_Ja/z_en_ja.c index 153edf853..aa2dce882 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -216,11 +216,11 @@ s32 func_80BC1D70(EnJa* this, PlayState* play) { void func_80BC1E40(EnJa* this, PlayState* play) { Player* player = GET_PLAYER(play); - s32 sp20 = Message_GetState(&play->msgCtx); + s32 talkState = Message_GetState(&play->msgCtx); f32 phi_f0; - if (((play->msgCtx.currentTextId < 0xFF) || (play->msgCtx.currentTextId > 0x200)) && (sp20 == 3) && - (this->unk_374 == 3) && (&this->actor == player->targetActor)) { + if (((play->msgCtx.currentTextId < 0xFF) || (play->msgCtx.currentTextId > 0x200)) && (talkState == TEXT_STATE_3) && + (this->prevTalkState == TEXT_STATE_3) && (&this->actor == player->targetActor)) { if ((play->state.frames % 2) == 0) { if (this->unk_348 != 0.0f) { this->unk_348 = 0.0f; @@ -236,10 +236,10 @@ void func_80BC1E40(EnJa* this, PlayState* play) { this->unk_34C = CLAMP(this->unk_34C, 0.0f, 120.0f); Matrix_Translate(this->unk_34C, 0.0f, 0.0f, MTXMODE_APPLY); - this->unk_374 = sp20; + this->prevTalkState = talkState; } -s32 func_80BC1FC8(EnJa* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BC1FC8(EnJa* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; if (func_80BC1AE0(this, play)) { @@ -252,7 +252,7 @@ s32 func_80BC1FC8(EnJa* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80BC203C(EnJa* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BC203C(EnJa* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; if (func_80BC1AE0(this, play)) { @@ -269,19 +269,19 @@ s32 func_80BC203C(EnJa* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80BC20D0(EnJa* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BC20D0(EnJa* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; this->unk_340 = 0; - switch (arg2->result) { + switch (scheduleOutput->result) { case 1: - ret = func_80BC1FC8(this, play, arg2); - if (ret == 1) {} + ret = func_80BC1FC8(this, play, scheduleOutput); + if (ret == true) {} break; case 2: - ret = func_80BC203C(this, play, arg2); + ret = func_80BC203C(this, play, scheduleOutput); break; } return ret; @@ -299,7 +299,7 @@ void func_80BC2150(EnJa* this, PlayState* play) { } void func_80BC21A8(EnJa* this, PlayState* play) { - ScheduleResult sp18; + ScheduleOutput sp18; this->unk_35C = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (!Schedule_RunScript(play, D_80BC35F0, &sp18) || diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.h b/src/overlays/actors/ovl_En_Ja/z_en_ja.h index 078863b48..e2fd8287f 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.h +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.h @@ -22,42 +22,42 @@ typedef struct { } EnJaStruct2; // size = 0x10 typedef struct EnJa { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnJaActionFunc actionFunc; - /* 0x018C */ ColliderCylinder collider; - /* 0x01D8 */ EnJaStruct2 unk_1D8; - /* 0x01E4 */ Vec3s unk_1E4; - /* 0x01EC */ Vec3f unk_1EC; - /* 0x01F8 */ Vec3f unk_1F8; - /* 0x0204 */ Vec3f unk_204; - /* 0x0210 */ Vec3f unk_210; - /* 0x021C */ Vec3f unk_21C; - /* 0x0228 */ Vec3f unk_228; - /* 0x0234 */ EnJaStruct unk_234[4]; - /* 0x0274 */ Vec3s unk_274; - /* 0x027A */ Vec3s unk_27A; - /* 0x0280 */ Vec3s jointTable[16]; - /* 0x02E0 */ Vec3s morphTable[16]; - /* 0x0340 */ u16 unk_340; - /* 0x0344 */ f32 unk_344; - /* 0x0348 */ f32 unk_348; - /* 0x034C */ f32 unk_34C; - /* 0x0350 */ UNK_TYPE1 unk350[0x4]; - /* 0x0354 */ s16 unk_354; - /* 0x0356 */ s16 unk_356; - /* 0x0358 */ s16 unk_358; - /* 0x035A */ s16 unk_35A; - /* 0x035C */ s16 unk_35C; - /* 0x035E */ s16 unk_35E; - /* 0x0360 */ s16 unk_360; - /* 0x0362 */ s16 unk_362; - /* 0x0364 */ s16 unk_364; - /* 0x0366 */ s16 unk_366; - /* 0x0368 */ void* unk_368; - /* 0x036C */ s32 unk_36C; - /* 0x0370 */ UNK_TYPE1 unk370[4]; - /* 0x0374 */ s32 unk_374; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnJaActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ EnJaStruct2 unk_1D8; + /* 0x1E4 */ Vec3s unk_1E4; + /* 0x1EC */ Vec3f unk_1EC; + /* 0x1F8 */ Vec3f unk_1F8; + /* 0x204 */ Vec3f unk_204; + /* 0x210 */ Vec3f unk_210; + /* 0x21C */ Vec3f unk_21C; + /* 0x228 */ Vec3f unk_228; + /* 0x234 */ EnJaStruct unk_234[4]; + /* 0x274 */ Vec3s unk_274; + /* 0x27A */ Vec3s unk_27A; + /* 0x280 */ Vec3s jointTable[16]; + /* 0x2E0 */ Vec3s morphTable[16]; + /* 0x340 */ u16 unk_340; + /* 0x344 */ f32 unk_344; + /* 0x348 */ f32 unk_348; + /* 0x34C */ f32 unk_34C; + /* 0x350 */ UNK_TYPE1 unk350[0x4]; + /* 0x354 */ s16 unk_354; + /* 0x356 */ s16 unk_356; + /* 0x358 */ s16 unk_358; + /* 0x35A */ s16 unk_35A; + /* 0x35C */ s16 unk_35C; + /* 0x35E */ s16 unk_35E; + /* 0x360 */ s16 unk_360; + /* 0x362 */ s16 unk_362; + /* 0x364 */ s16 unk_364; + /* 0x366 */ s16 unk_366; + /* 0x368 */ void* unk_368; + /* 0x36C */ s32 unk_36C; + /* 0x370 */ UNK_TYPE1 unk_370[4]; + /* 0x374 */ s32 prevTalkState; } EnJa; // size = 0x378 extern const ActorInit En_Ja_InitVars; diff --git a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c index 8647b553b..99c17772c 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 @@ -109,16 +109,8 @@ void EnJcMato_SetupIdle(EnJcMato* this) { } void EnJcMato_Idle(EnJcMato* this, PlayState* play) { - s16 shouldDespawn; - if (this->hitFlag) { - if (this->despawnTimer == 0) { - shouldDespawn = 0; - } else { - this->despawnTimer--; - shouldDespawn = this->despawnTimer; - } - if (shouldDespawn == 0) { + if (DECR(this->despawnTimer) == 0) { Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.c b/src/overlays/actors/ovl_En_Jg/z_en_jg.c index a66992637..add52b0e4 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -358,11 +358,11 @@ void EnJg_GoronShrineIdle(EnJg* this, PlayState* play) { } void EnJg_GoronShrineTalk(EnJg* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if ((this->textId == 0xDCC) || (this->textId == 0xDDD) || (this->textId == 0xDE0)) { // There is nothing more to say after these lines, so end the current conversation. play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; this->actionFunc = EnJg_GoronShrineIdle; } else { @@ -415,7 +415,7 @@ void EnJg_GoronShrineCheer(EnJg* this, PlayState* play) { * set his speed to 0, causing him to walk in place. */ void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, PlayState* play) { - u8 messageState = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); s16 currentFrame = this->skelAnime.curFrame; s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -425,9 +425,9 @@ void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, PlayState* play) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } } else if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_LOOP) { - if ((messageState == 5) && Message_ShouldAdvance(play)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; this->animationIndex = EN_JG_ANIMATION_WALK; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); @@ -470,7 +470,7 @@ void EnJg_Walk(EnJg* this, PlayState* play) { } void EnJg_Talk(EnJg* this, PlayState* play) { - u8 messageState = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); s16 currentFrame = this->skelAnime.curFrame; s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); u16 temp; @@ -480,12 +480,12 @@ void EnJg_Talk(EnJg* this, PlayState* play) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } - if ((messageState == 5) && Message_ShouldAdvance(play)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { temp = this->textId; if ((temp == 0xDB4) || (temp == 0xDB5) || (temp == 0xDC4) || (temp == 0xDC6)) { // There is nothing more to say after these lines, so end the current conversation. play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; this->actionFunc = EnJg_SetupWalk; return; @@ -497,7 +497,7 @@ void EnJg_Talk(EnJg* this, PlayState* play) { // The player hasn't talked to the Goron Child at least once, so they can't learn // the Lullaby Intro. End the current conversation with the player. play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; this->actionFunc = EnJg_SetupWalk; } else if (((gSaveContext.save.weekEventReg[24] & 0x40)) || @@ -511,7 +511,7 @@ void EnJg_Talk(EnJg* this, PlayState* play) { // already have the Lullaby or Lullaby Intro. End the current conversation and // start the cutscene that teaches the Lullaby Intro. play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; this->cutscene = EnJg_GetCutsceneForTeachingLullabyIntro(this); if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -600,9 +600,9 @@ void EnJg_FrozenIdle(EnJg* this, PlayState* play) { } void EnJg_EndFrozenInteraction(EnJg* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 6 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = EnJg_FrozenIdle; } } diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c index 27027c87f..f6ef666b2 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c @@ -251,21 +251,21 @@ void func_80C14030(EnJgameTsn* this) { void func_80C14044(EnJgameTsn* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 0: - case 1: - case 2: - case 3: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; - case 4: + case TEXT_STATE_CHOICE: func_80C14684(this, play); break; - case 5: + case TEXT_STATE_5: func_80C147B4(this, play); break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { ActorCutscene_Stop(this->actor.cutscene); @@ -303,7 +303,7 @@ void func_80C1418C(EnJgameTsn* this, PlayState* play) { void func_80C141DC(EnJgameTsn* this) { this->unk_218 = Rand_Next() & 3; this->unk_2FC = 0; - *this->unk_208[this->unk_218] |= 1; + *this->unk_208[this->unk_218] |= OBJLUPYGAMELIFT_IGNITE_FIRE; this->actionFunc = func_80C14230; } @@ -324,10 +324,10 @@ void func_80C14230(EnJgameTsn* this, PlayState* play) { for (i = 0; i < ARRAY_COUNT(this->unk_208); i++) { if (i == this->unk_218) { - *this->unk_208[i] |= 1; - *this->unk_208[i] &= ~8; + *this->unk_208[i] |= OBJLUPYGAMELIFT_IGNITE_FIRE; + *this->unk_208[i] &= ~OBJLUPYGAMELIFT_SNUFF_FIRE; } else { - *this->unk_208[i] |= 8; + *this->unk_208[i] |= OBJLUPYGAMELIFT_SNUFF_FIRE; } } } @@ -339,7 +339,7 @@ void func_80C14230(EnJgameTsn* this, PlayState* play) { Message_StartTextbox(play, 0x109F, &this->actor); this->unk_300 = 0x109F; player->stateFlags1 |= 0x20; - *this->unk_208[this->unk_218] &= ~1; + *this->unk_208[this->unk_218] &= ~OBJLUPYGAMELIFT_IGNITE_FIRE; func_801A2C20(); func_80C14030(this); } else if ((player->actor.bgCheckFlags & 0x40) || (player->actor.bgCheckFlags & 0x20)) { @@ -347,7 +347,7 @@ void func_80C14230(EnJgameTsn* this, PlayState* play) { Message_StartTextbox(play, 0x10A0, &this->actor); this->unk_300 = 0x10A0; player->stateFlags1 |= 0x20; - *this->unk_208[this->unk_218] &= ~1; + *this->unk_208[this->unk_218] &= ~OBJLUPYGAMELIFT_IGNITE_FIRE; func_801A2C20(); func_80C14030(this); } @@ -356,7 +356,7 @@ void func_80C14230(EnJgameTsn* this, PlayState* play) { Message_StartTextbox(play, 0x10A1, &this->actor); this->unk_300 = 0x10A1; player->stateFlags1 |= 0x20; - *this->unk_208[this->unk_218] &= ~1; + *this->unk_208[this->unk_218] &= ~OBJLUPYGAMELIFT_IGNITE_FIRE; func_801A2C20(); func_80C14030(this); } @@ -368,9 +368,9 @@ void func_80C144E4(EnJgameTsn* this) { void func_80C144F8(EnJgameTsn* this, PlayState* play) { play->nextEntranceIndex = 0x68D0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 0x50; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_80; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } void func_80C14540(EnJgameTsn* this) { @@ -410,7 +410,7 @@ void func_80C14684(EnJgameTsn* this, PlayState* play) { if (gSaveContext.save.playerData.rupees >= 20) { Message_StartTextbox(play, 0x109E, &this->actor); this->unk_300 = 0x109E; - func_801159EC(-20); + Rupees_ChangeBy(-20); } else { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); Message_StartTextbox(play, 0x109D, &this->actor); @@ -562,17 +562,17 @@ s32 func_80C14BCC(EnJgameTsn* this, PlayState* play) { if (phi_s3 == this->unk_218) { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); - *this->unk_208[phi_s3] |= 2; + *this->unk_208[phi_s3] |= OBJLUPYGAMELIFT_DISPLAY_CORRECT; play->interfaceCtx.unk_25C = 1; return true; } - if (*this->unk_208[phi_s3] & 1) { + if (*this->unk_208[phi_s3] & OBJLUPYGAMELIFT_IGNITE_FIRE) { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); - *this->unk_208[phi_s3] |= 2; + *this->unk_208[phi_s3] |= OBJLUPYGAMELIFT_DISPLAY_CORRECT; play->interfaceCtx.unk_25C = 1; } else { - *this->unk_208[phi_s3] |= 4; + *this->unk_208[phi_s3] |= OBJLUPYGAMELIFT_DISPLAY_INCORRECT; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); } } diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h index 8a6c3ec1e..5fdf911cc 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h @@ -16,25 +16,25 @@ typedef struct { } EnJgameTsnStruct; // size = 0x8 typedef struct EnJgameTsn { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnJgameTsnActionFunc actionFunc; - /* 0x01D8 */ EnJgameTsnStruct unk_1D8[4]; - /* 0x01F8 */ EnJgameTsnStruct unk_1F8; - /* 0x0200 */ EnJgameTsnStruct unk_200; - /* 0x0208 */ u8* unk_208[4]; - /* 0x0218 */ s32 unk_218; - /* 0x021C */ s32 unk_21C; - /* 0x0220 */ Vec3s jointTable[OBJECT_TSN_LIMB_MAX]; - /* 0x0286 */ Vec3s morphTable[OBJECT_TSN_LIMB_MAX]; - /* 0x02EC */ Vec3s unk_2EC; - /* 0x02F2 */ Vec3s unk_2F2; - /* 0x02F8 */ s16 unk_2F8; - /* 0x02FA */ s16 unk_2FA; - /* 0x02FC */ s16 unk_2FC; - /* 0x02FE */ s16 unk_2FE; - /* 0x0300 */ u16 unk_300; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnJgameTsnActionFunc actionFunc; + /* 0x1D8 */ EnJgameTsnStruct unk_1D8[4]; + /* 0x1F8 */ EnJgameTsnStruct unk_1F8; + /* 0x200 */ EnJgameTsnStruct unk_200; + /* 0x208 */ u8* unk_208[4]; + /* 0x218 */ s32 unk_218; + /* 0x21C */ s32 unk_21C; + /* 0x220 */ Vec3s jointTable[OBJECT_TSN_LIMB_MAX]; + /* 0x286 */ Vec3s morphTable[OBJECT_TSN_LIMB_MAX]; + /* 0x2EC */ Vec3s unk_2EC; + /* 0x2F2 */ Vec3s unk_2F2; + /* 0x2F8 */ s16 unk_2F8; + /* 0x2FA */ s16 unk_2FA; + /* 0x2FC */ s16 unk_2FC; + /* 0x2FE */ s16 unk_2FE; + /* 0x300 */ u16 unk_300; } EnJgameTsn; // size = 0x304 extern const ActorInit En_Jgame_Tsn_InitVars; diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.h b/src/overlays/actors/ovl_En_Js/z_en_js.h index 441ec5f17..96c1bbf49 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.h +++ b/src/overlays/actors/ovl_En_Js/z_en_js.h @@ -8,9 +8,9 @@ struct EnJs; typedef void (*EnJsActionFunc)(struct EnJs*, PlayState*); typedef struct EnJs { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x180]; - /* 0x02C4 */ EnJsActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x180]; + /* 0x2C4 */ EnJsActionFunc actionFunc; } EnJs; // size = 0x2C8 extern const ActorInit En_Js_InitVars; diff --git a/src/overlays/actors/ovl_En_Jso/z_en_jso.h b/src/overlays/actors/ovl_En_Jso/z_en_jso.h index 7fd25473e..e2961c3ae 100644 --- a/src/overlays/actors/ovl_En_Jso/z_en_jso.h +++ b/src/overlays/actors/ovl_En_Jso/z_en_jso.h @@ -8,10 +8,10 @@ struct EnJso; typedef void (*EnJsoActionFunc)(struct EnJso*, PlayState*); typedef struct EnJso { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x134]; - /* 0x0278 */ EnJsoActionFunc actionFunc; - /* 0x027C */ char unk_27C[0xD70]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x134]; + /* 0x278 */ EnJsoActionFunc actionFunc; + /* 0x27C */ char unk_27C[0xD70]; } EnJso; // size = 0xFEC extern const ActorInit En_Jso_InitVars; diff --git a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h index 265b55ea3..8ef208926 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h @@ -8,13 +8,13 @@ struct EnKaizoku; typedef void (*EnKaizokuActionFunc)(struct EnKaizoku*, PlayState*); typedef struct EnKaizoku { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x168]; - /* 0x02AC */ EnKaizokuActionFunc actionFunc; - /* 0x02B0 */ char unk_2B0[0x40]; - /* 0x02F0 */ f32 unk_2F0; - /* 0x02F4 */ s16 unk_2F4; - /* 0x02F6 */ char unk_2F6[0x2FA]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x168]; + /* 0x2AC */ EnKaizokuActionFunc actionFunc; + /* 0x2B0 */ char unk_2B0[0x40]; + /* 0x2F0 */ f32 unk_2F0; + /* 0x2F4 */ s16 unk_2F4; + /* 0x2F6 */ char unk_2F6[0x2FA]; } EnKaizoku; // size = 0x5F0 extern const ActorInit En_Kaizoku_InitVars; 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 5f4b0e3f1..befd3aa61 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -4,6 +4,7 @@ * Description: Pierre the Scarecorw */ +#include "prevent_bss_reordering.h" #include "z_en_kakasi.h" #include "objects/object_ka/object_ka.h" @@ -78,7 +79,7 @@ const ActorInit En_Kakasi_InitVars = { (ActorFunc)EnKakasi_Draw, }; -static Vec3f D_80971DCC[] = { +Vec3f D_80971DCC[] = { { 0.0f, 60.0f, 60.0f }, { 40.0f, 40.0f, 50.0f }, { -40.0f, 40.0f, 50.0f }, { 40.0f, 20.0f, 110.0f }, { -40.0f, 20.0f, 110.0f }, { 0.0f, 80.0f, 60.0f }, { 50.0f, 40.0f, -30.0f }, { -50.0f, 40.0f, -30.0f }, { 0.0f, 50.0f, 60.0f }, @@ -148,7 +149,7 @@ void EnKakasi_Init(Actor* thisx, PlayState* play) { Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &D_80971D80); SkelAnime_InitFlex(play, &this->skelanime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, 0, 0, 0); - this->songSummonDist = GET_KAKASI_SUMMON_DISTANCE(this) * 20.0f; + this->songSummonDist = GET_KAKASI_SUMMON_DISTANCE(&this->actor) * 20.0f; if (this->songSummonDist < 40.0f) { this->songSummonDist = 40.0f; } @@ -161,7 +162,7 @@ void EnKakasi_Init(Actor* thisx, PlayState* play) { } this->actor.shape.rot.y = this->actor.world.rot.y; - this->aboveGroundStatus = GET_KAKASI_ABOVE_GROUND(this); + this->aboveGroundStatus = GET_KAKASI_ABOVE_GROUND(&this->actor); this->actor.world.rot.x = 0; this->actor.flags |= ACTOR_FLAG_400; this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -256,19 +257,19 @@ void EnKakasi_CheckPlayerPosition(EnKakasi* this, PlayState* play) { * something to do with cutscene camera? */ void func_8096FAAC(EnKakasi* this, PlayState* play) { - if (this->cutsceneCamId != CAM_ID_MAIN) { - Math_ApproachF(&this->unk214.x, this->unk238.x, 0.4f, 4.0f); - Math_ApproachF(&this->unk214.y, this->unk238.y, 0.4f, 4.0f); - Math_ApproachF(&this->unk214.z, this->unk238.z, 0.4f, 4.0f); + if (this->subCamId != SUB_CAM_ID_DONE) { + Math_ApproachF(&this->subCamEye.x, this->subCamEyeNext.x, 0.4f, 4.0f); + Math_ApproachF(&this->subCamEye.y, this->subCamEyeNext.y, 0.4f, 4.0f); + Math_ApproachF(&this->subCamEye.z, this->subCamEyeNext.z, 0.4f, 4.0f); - Math_ApproachF(&this->unk220.x, this->unk244.x, 0.4f, 4.0f); - Math_ApproachF(&this->unk220.y, this->unk244.y, 0.4f, 4.0f); - Math_ApproachF(&this->unk220.z, this->unk244.z, 0.4f, 4.0f); + Math_ApproachF(&this->subCamAt.x, this->subCamAtNext.x, 0.4f, 4.0f); + Math_ApproachF(&this->subCamAt.y, this->subCamAtNext.y, 0.4f, 4.0f); + Math_ApproachF(&this->subCamAt.z, this->subCamAtNext.z, 0.4f, 4.0f); - Math_ApproachF(&this->unk20C, this->unk210, 0.3f, 10.0f); + Math_ApproachF(&this->subCamFov, this->subCamFovNext, 0.3f, 10.0f); - Play_CameraSetAtEye(play, this->cutsceneCamId, &this->unk220, &this->unk214); - Play_CameraSetFov(play, this->cutsceneCamId, this->unk20C); + Play_CameraSetAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); + Play_CameraSetFov(play, this->subCamId, this->subCamFov); } } @@ -309,7 +310,7 @@ void EnKakasi_TimeSkipDialogue(EnKakasi* this, PlayState* play) { // dialogue after skipped time 'did you feel that? went by in an instant' this->actor.textId = 0x1653; gSaveContext.save.weekEventReg[83] &= (u8)~1; - this->unkMsgState1AC = 5; + this->talkState = TEXT_STATE_5; player->stateFlags1 |= 0x20; this->actor.flags |= ACTOR_FLAG_10000; } @@ -381,7 +382,7 @@ void EnKakasi_SetupDialogue(EnKakasi* this) { EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } - this->unkMsgState1AC = 5; + this->talkState = TEXT_STATE_5; this->unkState196 = 1; EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); this->actionFunc = EnKakasi_RegularDialogue; @@ -415,9 +416,9 @@ void EnKakasi_RegularDialogue(EnKakasi* this, PlayState* play) { this->unkState1A8 = 0; } - if ((this->unkMsgState1AC == Message_GetState(&play->msgCtx)) && Message_ShouldAdvance(play)) { + if ((this->talkState == Message_GetState(&play->msgCtx)) && Message_ShouldAdvance(play)) { func_801477B4(play); - if (this->unkMsgState1AC == 5) { + if (this->talkState == TEXT_STATE_5) { // bad song input if (this->unkState196 == 2 && this->actor.textId == 0x1647) { func_800B7298(play, &this->actor, 6); @@ -458,7 +459,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, PlayState* play) { this->actionFunc = EnKakasi_DancingRemark; } else { ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); - this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); this->actionFunc = EnKakasi_DancingRemark; } } @@ -469,7 +470,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, PlayState* play) { if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } - this->unkMsgState1AC = 4; + this->talkState = TEXT_STATE_CHOICE; } else if (this->actor.textId == 0x1644) { if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { @@ -495,14 +496,14 @@ void EnKakasi_RegularDialogue(EnKakasi* this, PlayState* play) { this->actor.textId = 0x1655; } else if (this->actor.textId == 0x1655) { this->actor.textId = 0x1656; - this->unkMsgState1AC = 4; + this->talkState = TEXT_STATE_CHOICE; } else if (this->actor.textId == 0x1658) { this->actor.textId = 0x1659; } else if (this->actor.textId == 0x165A) { this->actor.textId = 0x165B; } else if (this->actor.textId == 0x165B) { this->actor.textId = 0x165C; - this->unkMsgState1AC = 4; + this->talkState = TEXT_STATE_CHOICE; } else if (this->actor.textId == 0x165E) { this->actor.textId = 0x165F; @@ -511,7 +512,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, PlayState* play) { return; } } else { - this->unkMsgState1AC = 5; + this->talkState = TEXT_STATE_5; if (play->msgCtx.choiceIndex == 1) { func_8019F208(); @@ -547,9 +548,9 @@ void EnKakasi_RegularDialogue(EnKakasi* this, PlayState* play) { void EnKakasi_SetupSongTeach(EnKakasi* this, PlayState* play) { this->actor.textId = 0x1646; Message_StartTextbox(play, this->actor.textId, &this->actor); - this->cutsceneCamId = CAM_ID_MAIN; - this->unk20C = 0.0f; - this->unk210 = 60.0f; + this->subCamId = SUB_CAM_ID_DONE; + this->subCamFov = 0.0f; + this->subCamFovNext = 60.0f; EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); this->unkState196 = 2; this->actionFunc = EnKakasi_OcarinaRemark; @@ -560,7 +561,7 @@ void EnKakasi_SetupSongTeach(EnKakasi* this, PlayState* play) { * before actually teaching */ void EnKakasi_OcarinaRemark(EnKakasi* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_80152434(play, 0x35); this->unkState1A8 = 0; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -575,7 +576,7 @@ void EnKakasi_OcarinaRemark(EnKakasi* this, PlayState* play) { } else { this->unkState1A8 = 1; ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); - this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); this->actionFunc = EnKakasi_TeachingSong; } @@ -598,7 +599,7 @@ void EnKakasi_TeachingSong(EnKakasi* this, PlayState* play) { return; } ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); - this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); this->unkState1A8 = 1; this->unkState1A8 = 1; @@ -606,15 +607,15 @@ void EnKakasi_TeachingSong(EnKakasi* this, PlayState* play) { if (this->unkState1A8 == 1) { this->unk22C.y = this->actor.home.pos.y + 50.0f; - this->unk238.x = D_80971DCC[this->unk190].x; - this->unk238.y = D_80971DCC[this->unk190].y; - this->unk238.z = D_80971DCC[this->unk190].z; + this->subCamEyeNext.x = D_80971DCC[this->unk190].x; + this->subCamEyeNext.y = D_80971DCC[this->unk190].y; + this->subCamEyeNext.z = D_80971DCC[this->unk190].z; - Math_Vec3f_Copy(&tempVec, &this->unk238); - OLib_DbCameraVec3fSum(&this->actor.home, &tempVec, &this->unk238, 1); - Math_Vec3f_Copy(&this->unk244, &this->unk22C); - Math_Vec3f_Copy(&this->unk214, &this->unk238); - Math_Vec3f_Copy(&this->unk220, &this->unk244); + Math_Vec3f_Copy(&tempVec, &this->subCamEyeNext); + OLib_DbCameraVec3fSum(&this->actor.home, &tempVec, &this->subCamEyeNext, 1); + Math_Vec3f_Copy(&this->subCamAtNext, &this->unk22C); + Math_Vec3f_Copy(&this->subCamEye, &this->subCamEyeNext); + Math_Vec3f_Copy(&this->subCamAt, &this->subCamAtNext); func_8096FAAC(this, play); func_8096FBB8(this, play); @@ -625,10 +626,10 @@ void EnKakasi_TeachingSong(EnKakasi* this, PlayState* play) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YASE_DEAD); if (this) {} this->unkState196 = 2; - this->cutsceneCamId = CAM_ID_MAIN; + this->subCamId = SUB_CAM_ID_DONE; this->actor.textId = 0x1647; this->unkState1A8 = 2; - this->unkMsgState1AC = 5; + this->talkState = TEXT_STATE_5; EnKakasi_SetAnimation(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); this->actionFunc = EnKakasi_RegularDialogue; @@ -659,12 +660,12 @@ void EnKakasi_SetupPostSongLearnDialogue(EnKakasi* this, PlayState* play) { this->unk190 = 0; this->unkCounter1A4 = 0; EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); - this->cutsceneCamId = CAM_ID_MAIN; - this->unkMsgState1AC = 5; + this->subCamId = SUB_CAM_ID_DONE; + this->talkState = TEXT_STATE_5; this->unkState1A8 = 1; this->actionFunc = EnKakasi_PostSongLearnDialogue; - this->unk20C = 0.0f; - this->unk210 = 60.0f; + this->subCamFov = 0.0f; + this->subCamFovNext = 60.0f; } void EnKakasi_PostSongLearnDialogue(EnKakasi* this, PlayState* play) { @@ -712,34 +713,34 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, PlayState* play) { } Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); - this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); func_800B7298(play, &this->actor, 0x56); this->unkState1A8 = 1; } - if (this->cutsceneCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { this->unk22C.y = this->actor.home.pos.y + 50.0f; EnKakasi_CheckPlayerPosition(this, play); - this->unk238.x = D_80971FA0[this->unk190].x; - this->unk238.y = D_80971FA0[this->unk190].y; - this->unk238.z = D_80971FA0[this->unk190].z; - Math_Vec3f_Copy(&vec3fCopy, &this->unk238); - OLib_DbCameraVec3fSum(&this->actor.home, &vec3fCopy, &this->unk238, 1); - this->unk244.x = D_80971FE8[this->unk190].x + this->unk22C.x; - this->unk244.y = D_80971FE8[this->unk190].y + this->unk22C.y; - this->unk244.z = D_80971FE8[this->unk190].z + this->unk22C.z; - Math_Vec3f_Copy(&this->unk214, &this->unk238); - Math_Vec3f_Copy(&this->unk220, &this->unk244); + this->subCamEyeNext.x = D_80971FA0[this->unk190].x; + this->subCamEyeNext.y = D_80971FA0[this->unk190].y; + this->subCamEyeNext.z = D_80971FA0[this->unk190].z; + Math_Vec3f_Copy(&vec3fCopy, &this->subCamEyeNext); + OLib_DbCameraVec3fSum(&this->actor.home, &vec3fCopy, &this->subCamEyeNext, 1); + this->subCamAtNext.x = D_80971FE8[this->unk190].x + this->unk22C.x; + this->subCamAtNext.y = D_80971FE8[this->unk190].y + this->unk22C.y; + this->subCamAtNext.z = D_80971FE8[this->unk190].z + this->unk22C.z; + Math_Vec3f_Copy(&this->subCamEye, &this->subCamEyeNext); + Math_Vec3f_Copy(&this->subCamAt, &this->subCamAtNext); } func_8096FAAC(this, play); - if ((this->unkState1A8 != 0) && (Message_GetState(&play->msgCtx) == this->unkMsgState1AC) && + if ((this->unkState1A8 != 0) && (Message_GetState(&play->msgCtx) == this->talkState) && Message_ShouldAdvance(play)) { func_801477B4(play); - if (this->unkMsgState1AC == 5) { + if (this->talkState == TEXT_STATE_5) { this->unk190++; if (this->unk190 > 5) { this->unk190 = 5; @@ -754,7 +755,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, PlayState* play) { } else if (this->actor.textId == 0x1649) { this->actor.textId = 0x1660; - this->unkMsgState1AC = 4; + this->talkState = TEXT_STATE_CHOICE; } else if (this->actor.textId == 0x164A) { this->actor.textId = 0x164B; @@ -771,7 +772,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, PlayState* play) { } } else { - this->unkMsgState1AC = 5; + this->talkState = TEXT_STATE_5; if (play->msgCtx.choiceIndex == 1) { func_8019F208(); // play 0x4808 sfx (decide) and calls func_801A75E8 this->actor.textId = 0x164A; @@ -798,7 +799,7 @@ void EnKakasi_DancingRemark(EnKakasi* this, PlayState* play) { ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); } else { ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); - this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); if (currentDay == 3 && gSaveContext.save.isNight) { EnKakasi_SetupDigAway(this); } else { @@ -811,8 +812,8 @@ void EnKakasi_DancingRemark(EnKakasi* this, PlayState* play) { void EnKakasi_SetupDanceNightAway(EnKakasi* this) { this->unk190 = 0; this->unkCounter1A4 = 0; - this->unk20C = 0.0f; - this->unk210 = 60.0f; + this->subCamFov = 0.0f; + this->subCamFovNext = 60.0f; EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); func_8016566C(0xB4); @@ -829,19 +830,19 @@ void EnKakasi_DancingNightAway(EnKakasi* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 3000, 0); this->unk22C.y = this->actor.home.pos.y + 50.0f; - this->unk238.x = D_80971E38[this->unk190].x; - this->unk238.y = D_80971E38[this->unk190].y; - this->unk238.z = D_80971E38[this->unk190].z; - Math_Vec3f_Copy(&localVec3f, &this->unk238); - OLib_DbCameraVec3fSum(&this->actor.home, &localVec3f, &this->unk238, 1); + this->subCamEyeNext.x = D_80971E38[this->unk190].x; + this->subCamEyeNext.y = D_80971E38[this->unk190].y; + this->subCamEyeNext.z = D_80971E38[this->unk190].z; + Math_Vec3f_Copy(&localVec3f, &this->subCamEyeNext); + OLib_DbCameraVec3fSum(&this->actor.home, &localVec3f, &this->subCamEyeNext, 1); if (1) {} - this->unk244.x = D_80971EEC[this->unk190].x + this->unk22C.x; - this->unk244.y = D_80971EEC[this->unk190].y + this->unk22C.y; - this->unk244.z = D_80971EEC[this->unk190].z + this->unk22C.z; + this->subCamAtNext.x = D_80971EEC[this->unk190].x + this->unk22C.x; + this->subCamAtNext.y = D_80971EEC[this->unk190].y + this->unk22C.y; + this->subCamAtNext.z = D_80971EEC[this->unk190].z + this->unk22C.z; if (this->unk190 != 6 && this->unk190 != 7) { - Math_Vec3f_Copy(&this->unk214, &this->unk238); - Math_Vec3f_Copy(&this->unk220, &this->unk244); + Math_Vec3f_Copy(&this->subCamEye, &this->subCamEyeNext); + Math_Vec3f_Copy(&this->subCamAt, &this->subCamAtNext); } if (this->unk190 >= 7 && this->unk190 != 0xE) { this->actor.shape.rot.y += 0x800; @@ -931,7 +932,7 @@ void EnKakasi_DancingNightAway(EnKakasi* this, PlayState* play) { if (this->unk204 == 0) { player = GET_PLAYER(play); - Play_SetRespawnData(&play->state, RESTART_MODE_DOWN, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, + Play_SetRespawnData(&play->state, RESPAWN_MODE_DOWN, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); func_80169EFC(&play->state); @@ -960,8 +961,8 @@ void EnKakasi_SetupDigAway(EnKakasi* this) { } this->unk190 = 0; this->unkCounter1A4 = 0; - this->unk210 = 60.0f; - this->unk20C = 60.0f; + this->subCamFovNext = 60.0f; + this->subCamFov = 60.0f; Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); this->unkState196 = 4; this->actionFunc = EnKakasi_DiggingAway; @@ -971,19 +972,19 @@ void EnKakasi_DiggingAway(EnKakasi* this, PlayState* play) { Vec3f tempunk238; Vec3f tempWorldPos; - if (this->cutsceneCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { this->unk22C.y = this->actor.home.pos.y + 50.0f; - this->unk238.x = D_80972030.x; - this->unk238.y = D_80972030.y; - this->unk238.z = D_80972030.z; + this->subCamEyeNext.x = D_80972030.x; + this->subCamEyeNext.y = D_80972030.y; + this->subCamEyeNext.z = D_80972030.z; - Math_Vec3f_Copy(&tempunk238, &this->unk238); - OLib_DbCameraVec3fSum(&this->actor.home, &tempunk238, &this->unk238, 1); - this->unk244.x = ((f32)D_8097203C.x) + this->unk22C.x; // cast req - this->unk244.y = ((f32)D_8097203C.y) + this->unk22C.y; - this->unk244.z = ((f32)D_8097203C.z) + this->unk22C.z; - Math_Vec3f_Copy(&this->unk214, &this->unk238); - Math_Vec3f_Copy(&this->unk220, &this->unk244); + Math_Vec3f_Copy(&tempunk238, &this->subCamEyeNext); + OLib_DbCameraVec3fSum(&this->actor.home, &tempunk238, &this->subCamEyeNext, 1); + this->subCamAtNext.x = ((f32)D_8097203C.x) + this->unk22C.x; // cast req + this->subCamAtNext.y = ((f32)D_8097203C.y) + this->unk22C.y; + this->subCamAtNext.z = ((f32)D_8097203C.z) + this->unk22C.z; + Math_Vec3f_Copy(&this->subCamEye, &this->subCamEyeNext); + Math_Vec3f_Copy(&this->subCamAt, &this->subCamAtNext); func_8096FAAC(this, play); } @@ -1101,7 +1102,7 @@ void EnKakasi_IdleRisen(EnKakasi* this, PlayState* play) { void EnKakasi_RisenDialogue(EnKakasi* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); EnKakasi_SetupIdleRisen(this); } @@ -1124,7 +1125,7 @@ void EnKakasi_Update(Actor* thisx, PlayState* play) { if (this->unk1BC.x != 0.0f || this->unk1BC.z != 0.0f) { Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk1BC); this->actor.focus.pos.y += 10.0f; - if (this->cutsceneCamId == CAM_ID_MAIN) { + if (this->subCamId == CAM_ID_MAIN) { Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } else { Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.home.rot); diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h index c6ee704d6..45d7a274b 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h @@ -21,7 +21,7 @@ typedef struct EnKakasi { /* 0x1A0 */ s32 animIndex; /* 0x1A4 */ s32 unkCounter1A4; // counter, counts up to F while he digs away, reused elsewhere /* 0x1A8 */ s32 unkState1A8; - /* 0x1AC */ s16 unkMsgState1AC; // might be dialog state, compared against func(msgCtx) + /* 0x1AC */ s16 talkState; /* 0x1AE */ s16 actorCutscenes[3]; /* 0x1B4 */ f32 animeFrameCount; /* 0x1B8 */ f32 unkHeight; @@ -29,14 +29,14 @@ typedef struct EnKakasi { /* 0x1C8 */ UNK_TYPE1 pad1C8[0x3C]; /* 0x204 */ s16 unk204; // set to A, F, 0x14, 0x28 frequently /* 0x206 */ UNK_TYPE1 pad206[2]; - /* 0x208 */ s16 cutsceneCamId; - /* 0x20C */ f32 unk20C; // passed to unknown function - /* 0x210 */ f32 unk210; // used as a target for 20C to approach - /* 0x214 */ Vec3f unk214; // copied from unk238 regularly - /* 0x220 */ Vec3f unk220; //EnKakasi_TeachingSong - /* 0x22C */ Vec3f unk22C; //actor home copied to here - /* 0x238 */ Vec3f unk238; //copied from D_80971E38[unk190] - /* 0x244 */ Vec3f unk244; + /* 0x208 */ s16 subCamId; + /* 0x20C */ f32 subCamFov; + /* 0x210 */ f32 subCamFovNext; + /* 0x214 */ Vec3f subCamEye; + /* 0x220 */ Vec3f subCamAt; + /* 0x22C */ Vec3f unk22C; + /* 0x238 */ Vec3f subCamEyeNext; + /* 0x244 */ Vec3f subCamAtNext; /* 0x250 */ f32 songSummonDist; /* 0x254 */ ColliderCylinder collider; } EnKakasi; // size = 0x2A0 @@ -45,7 +45,7 @@ extern const ActorInit En_Kakasi_InitVars; #define ENKAKASI_ABOVE_GROUND_TYPE 2 -#define GET_KAKASI_SUMMON_DISTANCE(this) ((this->actor.params >> 0x8) & 0xFF) -#define GET_KAKASI_ABOVE_GROUND(this) (this->actor.params & 0x1) +#define GET_KAKASI_SUMMON_DISTANCE(thisx) (((thisx)->params >> 0x8) & 0xFF) +#define GET_KAKASI_ABOVE_GROUND(thisx) ((thisx)->params & 0x1) #endif // Z_EN_KAKASI_H 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 039a269e3..b6edc7778 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -525,7 +525,7 @@ void func_80AD7FF8(EnKame* this, PlayState* play) { 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); + Animation_Change(&this->skelAnime1, &object_tl_Anim_0008B4, 1.0f, 0.0f, sp36, ANIMMODE_ONCE, -3.0f); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, sp36); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_DAMAGE); this->collider.base.acFlags &= ~AC_ON; 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 1bcdb43f7..6e0aa371b 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.h +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.h @@ -8,29 +8,29 @@ struct EnKame; typedef void (*EnKameActionFunc)(struct EnKame*, PlayState*); typedef struct EnKame { - /* 0x0000 */ Actor actor; - /* 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 */ u8 unk_29C; - /* 0x029D */ u8 drawDmgEffType; - /* 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 drawDmgEffAlpha; - /* 0x02B4 */ f32 drawDmgEffScale; - /* 0x02B8 */ f32 drawDmgEffFrozenSteamScale; - /* 0x02BC */ Vec3f unk_2BC; - /* 0x02C8 */ Vec3f limbPos[10]; - /* 0x0340 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime1; + /* 0x188 */ Vec3s jointTable1[13]; + /* 0x1D6 */ Vec3s morphTable1[13]; + /* 0x224 */ SkelAnime skelAnime2; + /* 0x268 */ Vec3s jointTable2[4]; + /* 0x280 */ Vec3s morphTable2[4]; + /* 0x298 */ EnKameActionFunc actionFunc; + /* 0x29C */ u8 unk_29C; + /* 0x29D */ u8 drawDmgEffType; + /* 0x29E */ s16 unk_29E; + /* 0x2A0 */ s16 unk_2A0; + /* 0x2A2 */ s16 unk_2A2; + /* 0x2A4 */ s16 unk_2A4; + /* 0x2A6 */ s16 unk_2A6; + /* 0x2A8 */ f32 unk_2A8; + /* 0x2AC */ f32 unk_2AC; + /* 0x2B0 */ f32 drawDmgEffAlpha; + /* 0x2B4 */ f32 drawDmgEffScale; + /* 0x2B8 */ f32 drawDmgEffFrozenSteamScale; + /* 0x2BC */ Vec3f unk_2BC; + /* 0x2C8 */ Vec3f limbPos[10]; + /* 0x340 */ 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 103039f56..709f6c7da 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -254,7 +254,7 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { u8 i; if (hitItem->toucher.dmgFlags & 0x200) { - this->cutType = sCutTypes[player->swordAnimation]; + this->cutType = sCutTypes[player->meleeWeaponAnimation]; } else if (hitItem->toucher.dmgFlags & 0x10) { this->invincibilityTimer = 0; this->cutType = this->unk_19A + 3; diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c index 228fad053..5412065f5 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c @@ -5,6 +5,7 @@ */ #include "z_en_karebaba.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_dekubaba/object_dekubaba.h" @@ -254,7 +255,7 @@ void func_808F169C(EnKarebaba* this, PlayState* play) { void func_808F16FC(EnKarebaba* this) { Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, 4.0f, 0.0f, - Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), 0, -3.0f); + Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), ANIMMODE_LOOP, -3.0f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_WAKEUP); this->actionFunc = func_808F1778; } @@ -275,7 +276,7 @@ void func_808F1778(EnKarebaba* this, PlayState* play) { } this->actor.shape.rot.y += 0x1999; - EffectSsHahen_SpawnBurst(play, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); } void func_808F1878(EnKarebaba* this) { @@ -407,7 +408,7 @@ void func_808F1C84(EnKarebaba* this, PlayState* play) { if (this->unk_1EE == 0) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4800, 0x71C); - EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); if ((this->actor.scale.x > 0.005f) && ((this->actor.bgCheckFlags & 2) || (this->actor.bgCheckFlags & 8))) { this->actor.scale.z = 0.0f; @@ -415,7 +416,8 @@ void func_808F1C84(EnKarebaba* this, PlayState* play) { this->actor.scale.x = 0.0f; this->actor.speedXZ = 0.0f; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); - EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 3.0f, 0, 12, 5, 15, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 3.0f, 0, 12, 5, 15, HAHEN_OBJECT_DEFAULT, 10, + NULL); } if (this->actor.bgCheckFlags & 2) { @@ -463,7 +465,7 @@ void func_808F200C(EnKarebaba* this, PlayState* play) { Item_DropCollectible(play, &this->actor.world.pos, ITEM00_NUTS_1); func_808F238C(this); } else { - EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 1.0f); } this->actor.scale.y = this->actor.scale.x; @@ -499,7 +501,7 @@ void func_808F21A4(EnKarebaba* this, PlayState* play) { void func_808F220C(EnKarebaba* this) { Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, -3.0f, - Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), 0.0f, 2, -3.0f); + Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), 0.0f, ANIMMODE_ONCE, -3.0f); func_808F152C(this); this->actionFunc = func_808F228C; } @@ -520,11 +522,11 @@ void func_808F228C(EnKarebaba* this, PlayState* play) { } this->actor.shape.rot.y += 0x1999; - EffectSsHahen_SpawnBurst(play, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); + EffectSsHahen_SpawnBurst(play, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); } void func_808F238C(EnKarebaba* this) { - Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, 0.0f, 0.0f, 0.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); func_808F152C(this); this->actor.shape.rot.x = -0x4000; this->unk_1EE = 200; diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h index a1b3e5a83..9d41245e6 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h @@ -14,20 +14,20 @@ enum { }; typedef struct EnKarebaba { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnKarebabaActionFunc actionFunc; - /* 0x018C */ Vec3s jointTable[8]; - /* 0x01BC */ Vec3s morphTable[8]; - /* 0x01EC */ u8 drawDmgEffType; - /* 0x01EE */ s16 unk_1EE; - /* 0x01F0 */ f32 drawDmgEffAlpha; - /* 0x01F4 */ f32 drawDmgEffScale; - /* 0x01F8 */ f32 drawDmgEffFrozenSteamScale; - /* 0x01FC */ Vec3f limbPos[4]; - /* 0x022C */ CollisionPoly* unk_22C; - /* 0x0230 */ ColliderCylinder collider1; - /* 0x027C */ ColliderCylinder collider2; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnKarebabaActionFunc actionFunc; + /* 0x18C */ Vec3s jointTable[8]; + /* 0x1BC */ Vec3s morphTable[8]; + /* 0x1EC */ u8 drawDmgEffType; + /* 0x1EE */ s16 unk_1EE; + /* 0x1F0 */ f32 drawDmgEffAlpha; + /* 0x1F4 */ f32 drawDmgEffScale; + /* 0x1F8 */ f32 drawDmgEffFrozenSteamScale; + /* 0x1FC */ Vec3f limbPos[4]; + /* 0x22C */ CollisionPoly* unk_22C; + /* 0x230 */ ColliderCylinder collider1; + /* 0x27C */ ColliderCylinder collider2; } EnKarebaba; // size = 0x2C8 extern const ActorInit En_Karebaba_InitVars; diff --git a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h index b3c667929..dbbb96e76 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h @@ -9,18 +9,18 @@ struct EnKbt; typedef void (*EnKbtActionFunc)(struct EnKbt*, PlayState*); typedef struct EnKbt { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[OBJECT_KBT_LIMB_MAX]; - /* 0x0200 */ Vec3s morphTable[OBJECT_KBT_LIMB_MAX]; - /* 0x0278 */ Actor* unk_278; - /* 0x027C */ u16 unk_27C; - /* 0x027E */ u8 unk_27E; - /* 0x027F */ u8 unk_27F; - /* 0x0280 */ s16 unk_280; - /* 0x0282 */ s16 unk_282; - /* 0x0284 */ s16 unk_284; - /* 0x0288 */ EnKbtActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[OBJECT_KBT_LIMB_MAX]; + /* 0x200 */ Vec3s morphTable[OBJECT_KBT_LIMB_MAX]; + /* 0x278 */ Actor* unk_278; + /* 0x27C */ u16 unk_27C; + /* 0x27E */ u8 unk_27E; + /* 0x27F */ u8 unk_27F; + /* 0x280 */ s16 unk_280; + /* 0x282 */ s16 unk_282; + /* 0x284 */ s16 unk_284; + /* 0x288 */ EnKbtActionFunc actionFunc; } EnKbt; // size = 0x28C extern const ActorInit En_Kbt_InitVars; diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c index 0c902754d..1c03c38e0 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c @@ -216,7 +216,7 @@ void func_80B26758(EnKendoJs* this, PlayState* play) { if (Message_ShouldAdvance(play) && (this->unk_288 == 0x2716)) { switch (play->msgCtx.choiceIndex) { case 0: - if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) == EQUIP_SWORD) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_NONE) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x272C, &this->actor); this->unk_288 = 0x272C; @@ -227,14 +227,14 @@ void func_80B26758(EnKendoJs* this, PlayState* play) { this->unk_288 = 0x2718; } else { func_8019F208(); - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); Message_StartTextbox(play, 0x2719, &this->actor); this->unk_288 = 0x2719; } break; case 1: - if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) == EQUIP_SWORD) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_NONE) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x272C, &this->actor); this->unk_288 = 0x272C; @@ -245,7 +245,7 @@ void func_80B26758(EnKendoJs* this, PlayState* play) { this->unk_288 = 0x2718; } else { func_8019F208(); - func_801159EC(-play->msgCtx.unk12070); + Rupees_ChangeBy(-play->msgCtx.unk12070); Message_StartTextbox(play, 0x273A, &this->actor); this->unk_288 = 0x273A; } @@ -317,15 +317,15 @@ void func_80B26AFC(EnKendoJs* this, PlayState* play) { Player* player = GET_PLAYER(play); switch (Message_GetState(&play->msgCtx)) { - case 4: + case TEXT_STATE_CHOICE: func_80B26758(this, play); break; - case 5: + case TEXT_STATE_5: func_80B269A4(this, play); break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { if (this->unk_288 == 0x272C) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -339,10 +339,10 @@ void func_80B26AFC(EnKendoJs* this, PlayState* play) { func_80B26538(this); } - case 0: - case 1: - case 2: - case 3: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; } } @@ -356,7 +356,8 @@ s32 func_80B26BF8(EnKendoJs* this, PlayState* play) { return 0; } - if ((player->swordState != 0) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + if ((player->meleeWeaponState != 0) || (player->stateFlags3 & 0x8000000) || + (player->stateFlags2 & 0x80000)) { return 1; } break; @@ -366,7 +367,7 @@ s32 func_80B26BF8(EnKendoJs* this, PlayState* play) { return 0; } - if ((player->swordState != 0) || (player->stateFlags2 & 0x80000)) { + if ((player->meleeWeaponState != 0) || (player->stateFlags2 & 0x80000)) { return 1; } break; @@ -376,14 +377,16 @@ s32 func_80B26BF8(EnKendoJs* this, PlayState* play) { return 0; } - if ((player->swordState != 0) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + if ((player->meleeWeaponState != 0) || (player->stateFlags3 & 0x8000000) || + (player->stateFlags2 & 0x80000)) { return 1; } this->unk_28E = 0; break; case 3: - if ((this->unk_28E == 1) && ((player->swordAnimation == 4) || (player->swordAnimation == 6))) { + if ((this->unk_28E == 1) && ((player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_COMBO_1H))) { this->unk_28E = 0; return 0; } @@ -395,7 +398,8 @@ s32 func_80B26BF8(EnKendoJs* this, PlayState* play) { break; case 4: - if ((this->unk_28E == 1) && ((player->swordAnimation == 0) || (player->swordAnimation == 2))) { + if ((this->unk_28E == 1) && ((player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_COMBO_1H))) { this->unk_28E = 0; return 0; } @@ -407,7 +411,7 @@ s32 func_80B26BF8(EnKendoJs* this, PlayState* play) { break; case 5: - if ((this->unk_28E == 1) && (player->swordAnimation == 12)) { + if ((this->unk_28E == 1) && (player->meleeWeaponAnimation == PLAYER_MWA_STAB_1H)) { this->unk_28E = 0; return 0; } @@ -419,7 +423,8 @@ s32 func_80B26BF8(EnKendoJs* this, PlayState* play) { break; case 6: - if ((this->unk_28E == 1) && ((player->swordAnimation == 17) || (player->swordAnimation == 20))) { + if ((this->unk_28E == 1) && ((player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) || + (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_FINISH))) { this->unk_28E = 0; return 0; } @@ -449,7 +454,7 @@ s32 func_80B26F6C(EnKendoJs* this, PlayState* play) { switch (this->unk_288) { case 0x271D: - if (func_80124190(player)) { + if (Player_GetMeleeWeaponHeld(player) != 0) { Message_StartTextbox(play, 0x272A, &this->actor); this->unk_288 = 0x272A; return true; @@ -504,7 +509,7 @@ void func_80B2714C(EnKendoJs* this) { void func_80B27188(EnKendoJs* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_288 == 0x2729) { func_80B26F14(this, play); } else if (!func_80B26F6C(this, play)) { @@ -600,8 +605,8 @@ void func_80B274BC(EnKendoJs* this, PlayState* play) { } play_sound(NA_SE_SY_FOUND); - func_80B279F0(this, play, (((s32)Rand_Next() & 0xFF) % 3) + 1); - func_80B279F0(this, play, (((s32)Rand_Next() & 0xFF) % 3) + 4); + func_80B279F0(this, play, ((u8)Rand_Next() % 3) + 1); + func_80B279F0(this, play, ((u8)Rand_Next() % 3) + 4); this->unk_290 = 0; this->unk_284++; } else if (this->unk_290 == 120) { @@ -612,12 +617,13 @@ void func_80B274BC(EnKendoJs* this, PlayState* play) { } if (this->unk_28E == 1) { - if ((player->swordAnimation == 17) || (player->swordAnimation == 20)) { + if ((player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) || + (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_FINISH)) { play->interfaceCtx.unk_25C = 3; if (gSaveContext.minigameScore >= 27) { player->stateFlags1 |= 0x20; } - } else if (player->swordAnimation == 12) { + } else if (player->meleeWeaponAnimation == PLAYER_MWA_STAB_1H) { play->interfaceCtx.unk_25C = 2; } else { play->interfaceCtx.unk_25C = 1; diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h index b811563a9..2d49058e8 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h @@ -13,23 +13,23 @@ typedef void (*EnKendoJsActionFunc)(struct EnKendoJs*, PlayState*); #define ENKENDOJS_FF_1 1 typedef struct EnKendoJs { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnKendoJsActionFunc actionFunc; - /* 0x01D8 */ Vec3s jointTable[13]; - /* 0x0226 */ Vec3s morphTable[13]; - /* 0x0274 */ Vec3s* unk_274; - /* 0x0278 */ Vec3s unk_278; - /* 0x027E */ Vec3s unk_27E; - /* 0x0284 */ s16 unk_284; - /* 0x0286 */ s16 unk_286; - /* 0x0288 */ s16 unk_288; - /* 0x028A */ s16 unk_28A; - /* 0x028C */ s16 unk_28C; - /* 0x028E */ s16 unk_28E; - /* 0x0290 */ s16 unk_290; - /* 0x0292 */ u8 unk_292; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnKendoJsActionFunc actionFunc; + /* 0x1D8 */ Vec3s jointTable[13]; + /* 0x226 */ Vec3s morphTable[13]; + /* 0x274 */ Vec3s* unk_274; + /* 0x278 */ Vec3s unk_278; + /* 0x27E */ Vec3s unk_27E; + /* 0x284 */ s16 unk_284; + /* 0x286 */ s16 unk_286; + /* 0x288 */ s16 unk_288; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ s16 unk_28C; + /* 0x28E */ s16 unk_28E; + /* 0x290 */ s16 unk_290; + /* 0x292 */ u8 unk_292; } EnKendoJs; // size = 0x294 extern const ActorInit En_Kendo_Js_InitVars; diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c index b2a44dd1f..9a63f38a1 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -4,8 +4,6 @@ * Description: Blacksmith - Gabora */ -#include "overlays/actors/ovl_En_Kbt/z_en_kbt.h" -#include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" #include "z_en_kgy.h" #include "objects/object_kgy/object_kgy.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -65,25 +63,25 @@ void EnKgy_Init(Actor* thisx, PlayState* play) { play->envCtx.lightSettingOverride = 1; gSaveContext.save.weekEventReg[21] |= 1; if (!func_80B40D64(play)) { - EnKgy_ChangeAnim(this, 4, 0, 0); + EnKgy_ChangeAnim(this, 4, ANIMMODE_LOOP, 0); this->actionFunc = func_80B425A0; this->actor.textId = 0xC35; } else if (!func_80B40DB4(play)) { - EnKgy_ChangeAnim(this, 6, 2, 0); + EnKgy_ChangeAnim(this, 6, ANIMMODE_ONCE, 0); this->actionFunc = func_80B419B0; this->actor.textId = 0xC4E; this->unk_29C |= 1; this->unk_2EA = 3; } else { - EnKgy_ChangeAnim(this, 4, 0, 0); + EnKgy_ChangeAnim(this, 4, ANIMMODE_LOOP, 0); this->actionFunc = func_80B42714; this->actor.textId = 0xC50; } } else { if (gSaveContext.save.weekEventReg[20] & 0x80) { - EnKgy_ChangeAnim(this, 4, 0, 0); + EnKgy_ChangeAnim(this, 4, ANIMMODE_LOOP, 0); } else { - EnKgy_ChangeAnim(this, 0, 0, 0); + EnKgy_ChangeAnim(this, 0, ANIMMODE_LOOP, 0); } this->actionFunc = func_80B42D28; } @@ -124,7 +122,7 @@ void EnKgy_ChangeAnim(EnKgy* this, s16 animIndex, u8 mode, f32 transitionRate) { void func_80B40BC0(EnKgy* this, s16 arg1) { if (arg1 != this->unk_2D2) { - EnKgy_ChangeAnim(this, arg1, 0, -5.0f); + EnKgy_ChangeAnim(this, arg1, ANIMMODE_LOOP, -5.0f); } } @@ -221,7 +219,7 @@ void func_80B40EE8(EnKgy* this, PlayState* play) { this->unk_2E4--; if ((this->unk_2E4 == 0) && (this->unk_2E2 >= 0)) { if (this->unk_2E2 == 3) { - EnKgy_ChangeAnim(this, 3, 2, -5.0f); + EnKgy_ChangeAnim(this, 3, ANIMMODE_ONCE, -5.0f); } else { func_80B40BC0(this, this->unk_2E2); } @@ -422,14 +420,14 @@ void func_80B4163C(EnKgy* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_2D2 == 6) { if (this->unk_2EA > 0) { - EnKgy_ChangeAnim(this, 6, 2, 0.0f); + EnKgy_ChangeAnim(this, 6, ANIMMODE_ONCE, 0.0f); this->unk_2EA--; } else { - EnKgy_ChangeAnim(this, 9, 2, -5.0f); + EnKgy_ChangeAnim(this, 9, ANIMMODE_ONCE, -5.0f); this->unk_2EA = (s32)Rand_ZeroFloat(3.0f) + 2; } } else { - EnKgy_ChangeAnim(this, 6, 2, -5.0f); + EnKgy_ChangeAnim(this, 6, ANIMMODE_ONCE, -5.0f); } SkelAnime_Update(&this->skelAnime); } @@ -457,7 +455,7 @@ void func_80B4163C(EnKgy* this, PlayState* play) { void func_80B417B8(EnKgy* this, PlayState* play) { func_80B4163C(this, play); - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); func_80B413C8(this); this->actor.flags &= ~ACTOR_FLAG_100; @@ -481,7 +479,7 @@ void func_80B41858(EnKgy* this, PlayState* play) { void func_80B418C4(EnKgy* this, PlayState* play) { func_80B4163C(this, play); if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play) && + (Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play) && ((play->msgCtx.currentTextId == 0xC4E) || (play->msgCtx.currentTextId == 0xC4F))) { func_801477B4(play); this->actor.textId = 0xC4F; @@ -515,7 +513,7 @@ void func_80B41A48(EnKgy* this, PlayState* play) { this->unk_2E4--; } else { play->nextEntranceIndex = play->setupExitList[ENKGY_GET_1F(&this->actor)]; - play->sceneLoadFlag = 20; + play->transitionTrigger = TRANS_TRIGGER_START; } } @@ -524,7 +522,7 @@ void func_80B41ACC(EnKgy* this, PlayState* play) { Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); - if (Message_GetState(&play->msgCtx) == 0x10) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { itemActionParam = func_80123810(play); if (itemActionParam != PLAYER_AP_NONE) { this->actionFunc = func_80B41E18; @@ -556,7 +554,7 @@ void func_80B41ACC(EnKgy* this, PlayState* play) { this->actor.textId = 0xC47; } player->actor.textId = 0; - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80B41368(this, play, 4); } } @@ -605,7 +603,7 @@ void func_80B41D64(EnKgy* this, PlayState* play) { } void func_80B41E18(EnKgy* this, PlayState* play) { - u16 temp; + u16 textId; s32 pad; Player* player = GET_PLAYER(play); @@ -615,11 +613,11 @@ void func_80B41E18(EnKgy* this, PlayState* play) { if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && func_80B40E54(this) == 0) { switch (Message_GetState(&play->msgCtx)) { - case 4: + case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(play)) { - temp = play->msgCtx.currentTextId; + textId = play->msgCtx.currentTextId; - switch (temp) { + switch (textId) { case 0xC3B: switch (play->msgCtx.choiceIndex) { case 0: @@ -629,13 +627,13 @@ void func_80B41E18(EnKgy* this, PlayState* play) { } else { func_8019F208(); func_80B40E74(this, play, 0xC42); - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } break; case 1: func_8019F230(); - func_80B40EBC(this, play, temp); + func_80B40EBC(this, play, textId); break; } break; @@ -657,21 +655,21 @@ void func_80B41E18(EnKgy* this, PlayState* play) { } break; - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { - temp = play->msgCtx.currentTextId; + textId = play->msgCtx.currentTextId; - switch (temp) { + switch (textId) { case 0xC35: - play->msgCtx.unk11F10 = 0; - this->actor.textId = temp; + play->msgCtx.msgLength = 0; + this->actor.textId = textId; this->unk_29C |= 4; this->unk_2E8 = 3; func_80B40E38(this); break; case 0xC36: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80B41368(this, play, 4); this->actor.textId = func_80B41460(); break; @@ -696,7 +694,7 @@ void func_80B41E18(EnKgy* this, PlayState* play) { case 0xC3C: case 0xC3F: case 0xC4C: - func_80B40EBC(this, play, temp); + func_80B40EBC(this, play, textId); break; case 0xC3D: @@ -708,18 +706,18 @@ void func_80B41E18(EnKgy* this, PlayState* play) { break; case 0xC40: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80B41368(this, play, 0); this->actor.textId = 0xC43; break; case 0xC42: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80B41368(this, play, 0); this->actor.textId = 0xC43; CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_NONE; - SET_EQUIP_VALUE(EQUIP_SWORD, 0); - func_80112B40(play, 0); + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_NONE); + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); func_80B40C74(play); break; @@ -728,7 +726,7 @@ void func_80B41E18(EnKgy* this, PlayState* play) { this->unk_29C |= 0x10; case 0xC45: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80B41368(this, play, 3); this->actor.textId = 0xFF; this->actionFunc = func_80B41ACC; @@ -748,11 +746,11 @@ void func_80B41E18(EnKgy* this, PlayState* play) { func_80123D50(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_AP_BOTTLE); player->exchangeItemId = EXCH_ITEM_NONE; this->unk_29C &= ~0x8; - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80B41368(this, play, 4); if (this->unk_29C & 0x10) { this->actor.textId = 0xC56; - func_801159EC(play->msgCtx.unk1206C); + Rupees_ChangeBy(play->msgCtx.unk1206C); } else { this->actor.textId = 0xC42; } @@ -764,19 +762,19 @@ void func_80B41E18(EnKgy* this, PlayState* play) { player->exchangeItemId = EXCH_ITEM_NONE; this->unk_29C &= ~8; } - func_80B40EBC(this, play, temp); + func_80B40EBC(this, play, textId); break; case 0xC48: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80B41368(this, play, 0); - this->actor.textId = temp + 1; + this->actor.textId = textId + 1; break; case 0xC49: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80B41368(this, play, 4); - this->actor.textId = temp + 1; + this->actor.textId = textId + 1; break; case 0xC4A: @@ -805,9 +803,9 @@ void func_80B41E18(EnKgy* this, PlayState* play) { case 0xC51: case 0xC53: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80B41368(this, play, 0); - this->actor.textId = temp + 1; + this->actor.textId = textId + 1; func_80B40D30(play); break; @@ -856,7 +854,7 @@ void func_80B425A0(EnKgy* this, PlayState* play) { void func_80B42660(EnKgy* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); func_80B413C8(this); this->actor.flags &= ~ACTOR_FLAG_100; @@ -885,7 +883,7 @@ void func_80B42714(EnKgy* this, PlayState* play) { void func_80B427C8(EnKgy* this, PlayState* play) { s32 pad; - u16 temp_a2; + u16 textId; if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_2D2 == 5) { @@ -897,26 +895,26 @@ void func_80B427C8(EnKgy* this, PlayState* play) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { - temp_a2 = play->msgCtx.currentTextId; + (Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + textId = play->msgCtx.currentTextId; - switch (temp_a2) { + switch (textId) { case 0xC30: - play->msgCtx.unk11F10 = 0; - this->actor.textId = temp_a2; + play->msgCtx.msgLength = 0; + this->actor.textId = textId; this->unk_29C |= 4; this->unk_2E8 = 3; break; case 0xC31: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80B41368(this, play, 4); - this->actor.textId = temp_a2 + 1; + this->actor.textId = textId + 1; break; case 0xC32: case 0xC33: - func_80B40EBC(this, play, temp_a2); + func_80B40EBC(this, play, textId); break; case 0xC34: @@ -943,7 +941,7 @@ void func_80B4296C(EnKgy* this, PlayState* play) { if (this->unk_2D2 == 4) { func_80B40BC0(this, 7); } else { - EnKgy_ChangeAnim(this, 5, 2, -5.0f); + EnKgy_ChangeAnim(this, 5, ANIMMODE_ONCE, -5.0f); } func_80B411DC(this, play, 0); func_80B40E18(this, this->actor.textId); @@ -955,7 +953,7 @@ void func_80B4296C(EnKgy* this, PlayState* play) { } void func_80B42A8C(EnKgy* this, PlayState* play) { - u16 temp_a2; + u16 textId; s32 pad; if (SkelAnime_Update(&this->skelAnime)) { @@ -969,21 +967,21 @@ void func_80B42A8C(EnKgy* this, PlayState* play) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { - temp_a2 = play->msgCtx.currentTextId; - switch (temp_a2) { + (Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + textId = play->msgCtx.currentTextId; + switch (textId) { case 0xC1D: case 0xC2D: - play->msgCtx.unk11F10 = 0; - this->actor.textId = temp_a2; + play->msgCtx.msgLength = 0; + this->actor.textId = textId; this->unk_29C |= 4; this->unk_2E8 = 3; break; case 0xC1E: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80B41368(this, play, 1); - this->actor.textId = temp_a2 + 1; + this->actor.textId = textId + 1; func_80B40E38(this); break; @@ -991,39 +989,39 @@ void func_80B42A8C(EnKgy* this, PlayState* play) { case 0xC23: case 0xC24: case 0xC27: - func_80B40EBC(this, play, temp_a2); + func_80B40EBC(this, play, textId); break; case 0xC20: case 0xC28: func_80B40BC0(this, 1); - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; this->unk_29C |= 4; this->unk_2E8 = 3; - this->actor.textId = temp_a2; + this->actor.textId = textId; func_80B40E38(this); break; case 0xC21: case 0xC29: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80B41368(this, play, 0); - this->actor.textId = temp_a2 + 1; + this->actor.textId = textId + 1; break; case 0xC22: case 0xC26: case 0xC2B: case 0xC2E: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80B41368(this, play, 1); - this->actor.textId = temp_a2 + 1; + this->actor.textId = textId + 1; break; case 0xC25: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80B41368(this, play, 2); - this->actor.textId = temp_a2 + 1; + this->actor.textId = textId + 1; break; case 0xC2A: @@ -1055,7 +1053,7 @@ void func_80B42D28(EnKgy* this, PlayState* play) { if (this->actor.textId == 0xC2D) { func_80B40BC0(this, 1); } else { - EnKgy_ChangeAnim(this, 5, 2, -5.0f); + EnKgy_ChangeAnim(this, 5, ANIMMODE_ONCE, -5.0f); gSaveContext.save.weekEventReg[20] |= 0x80; } func_80B411DC(this, play, 0); @@ -1075,7 +1073,7 @@ void func_80B42D28(EnKgy* this, PlayState* play) { } if ((this->unk_2D2 == 0) && (this->actor.xzDistToPlayer < 200.0f)) { - EnKgy_ChangeAnim(this, 8, 2, 5.0f); + EnKgy_ChangeAnim(this, 8, ANIMMODE_ONCE, 5.0f); } } } diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h index a6d1703c0..ce7deceb4 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h @@ -2,6 +2,8 @@ #define Z_EN_KGY_H #include "global.h" +#include "overlays/actors/ovl_En_Kbt/z_en_kbt.h" +#include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" struct EnKgy; diff --git a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.h b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.h index 4973a7eda..2ef14c942 100644 --- a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.h +++ b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.h @@ -8,9 +8,9 @@ struct EnKitan; typedef void (*EnKitanActionFunc)(struct EnKitan*, PlayState*); typedef struct EnKitan { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x194]; - /* 0x02D8 */ EnKitanActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x194]; + /* 0x2D8 */ EnKitanActionFunc actionFunc; } EnKitan; // size = 0x2DC extern const ActorInit En_Kitan_InitVars; diff --git a/src/overlays/actors/ovl_En_Knight/z_en_knight.c b/src/overlays/actors/ovl_En_Knight/z_en_knight.c index 9c925c56c..095ca5a98 100644 --- a/src/overlays/actors/ovl_En_Knight/z_en_knight.c +++ b/src/overlays/actors/ovl_En_Knight/z_en_knight.c @@ -129,7 +129,7 @@ static ColliderJntSphElementInit D_809BDB44[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809BDB8C = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809BDB44, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809BDB44, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -143,7 +143,7 @@ static ColliderJntSphElementInit D_809BDB68[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809BDB9C = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809BDB68, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809BDB68, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -157,7 +157,7 @@ static ColliderJntSphElementInit D_809BDBAC[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809BDBD0 = { { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809BDBAC, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809BDBAC, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[2] = { @@ -175,7 +175,7 @@ static ColliderJntSphElementInit D_809BDBE0[2] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_809BDC28 = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_809BDBE0, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_809BDBE0, // sJntSphElementsInit, }; // static ColliderCylinderInit sCylinderInit = { diff --git a/src/overlays/actors/ovl_En_Knight/z_en_knight.h b/src/overlays/actors/ovl_En_Knight/z_en_knight.h index b7faee749..a4fca8554 100644 --- a/src/overlays/actors/ovl_En_Knight/z_en_knight.h +++ b/src/overlays/actors/ovl_En_Knight/z_en_knight.h @@ -8,22 +8,22 @@ struct EnKnight; typedef void (*EnKnightActionFunc)(struct EnKnight*, PlayState*); typedef struct EnKnight { - /* 0x0000 */ Actor actor; - /* 0x0144 */ s16 unk_144; - /* 0x0146 */ char unk_146[0x2]; - /* 0x0148 */ s8 unk_148; - /* 0x0149 */ char pad149[8]; - /* 0x0151 */ s8 unk_151; - /* 0x0152 */ char pad152[1]; - /* 0x0153 */ u8 unk_153; - /* 0x0154 */ u8 unk_154; - /* 0x0155 */ char pad155[0x2CB]; - /* 0x0420 */ EnKnightActionFunc actionFunc; - /* 0x0424 */ char unk_424[0x25C]; - /* 0x0680 */ u8 unk_680; - /* 0x0681 */ char pad681[9]; - /* 0x068A */ s16 unk_68A; - /* 0x068C */ char pad68C[0x48]; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 unk_144; + /* 0x146 */ char unk_146[0x2]; + /* 0x148 */ s8 unk_148; + /* 0x149 */ char pad149[8]; + /* 0x151 */ s8 unk_151; + /* 0x152 */ char pad152[1]; + /* 0x153 */ u8 unk_153; + /* 0x154 */ u8 unk_154; + /* 0x155 */ char pad155[0x2CB]; + /* 0x420 */ EnKnightActionFunc actionFunc; + /* 0x424 */ char unk_424[0x25C]; + /* 0x680 */ u8 unk_680; + /* 0x681 */ char pad681[9]; + /* 0x68A */ s16 unk_68A; + /* 0x68C */ char pad68C[0x48]; } EnKnight; // size = 0x6D4 extern const ActorInit En_Knight_InitVars; diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c index 6032856b6..df95a6988 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c @@ -117,7 +117,7 @@ void EnKujiya_HandlePlayerChoice(EnKujiya* this, PlayState* play) { this->textId = 0x2B62; // Not enough Rupees } else { func_8019F208(); - func_801159EC(-10); + Rupees_ChangeBy(-10); Message_StartTextbox(play, 0x2B5F, &this->actor); this->textId = 0x2B5F; // Enter number } @@ -183,24 +183,24 @@ void EnKujiya_SetupTalk(EnKujiya* this) { void EnKujiya_Talk(EnKujiya* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 0: + case TEXT_STATE_NONE: break; - case 4: + case TEXT_STATE_CHOICE: EnKujiya_HandlePlayerChoice(this, play); break; - case 5: + case TEXT_STATE_5: EnKujiya_ChooseNextDialogue(this, play); break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { EnKujiya_SetupWait(this); } break; - case 17: + case TEXT_STATE_17: if (Message_ShouldAdvance(play)) { Inventory_SaveLotteryCodeGuess(play); Message_StartTextbox(play, 0x2B60, &this->actor); @@ -227,7 +227,7 @@ void EnKujiya_SetupFinishGivePrize(EnKujiya* this) { } void EnKujiya_FinishGivePrize(EnKujiya* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 6) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { EnKujiya_SetupWait(this); } } 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 78825fbe2..ca3d2c326 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -245,7 +245,7 @@ void EnKusa_DropCollectible(EnKusa* this, PlayState* play) { s32 collectableParams; if ((GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_GRASS) || (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_BUSH)) { - if (!(KUSA_GET_PARAMS_0C(&this->actor))) { + if (!KUSA_GET_PARAMS_0C(&this->actor)) { Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, KUSA_GET_RAND_COLLECTIBLE_ID(&this->actor) * 0x10); } diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h index 6f41a6866..a4be56cf6 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h @@ -27,7 +27,7 @@ typedef struct EnKusa { extern const ActorInit En_Kusa_InitVars; -#define KUSA_GET_COLLECTIBLE_ID(thisx) ((((thisx)->params >> 8) & 0x7F)) +#define KUSA_GET_COLLECTIBLE_ID(thisx) (((thisx)->params >> 8) & 0x7F) #define KUSA_GET_RAND_COLLECTIBLE_ID(thisx) (((thisx)->params >> 8) & 0xF) #define KUSA_SHOULD_SPAWN_BUGS(thisx) (((thisx)->params >> 0x4) & 1) #define KUSA_GET_PARAMS_0C(thisx) (((thisx)->params >> 0xC) & 0x1) 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 5a7a0a5c2..73cf73c36 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -391,7 +391,7 @@ EnKusa2UnkBssSubStruct* func_80A5C074(EnKusa2UnkBssStruct* arg0) { 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)) { + if (phi_v1->unk_26 > arg0->unk_0000[i].unk_26) { phi_v1 = &arg0->unk_0000[i]; if (phi_v1->unk_26 <= 0) { break; @@ -407,7 +407,7 @@ EnKusa2UnkBssSubStruct2* func_80A5C0B8(EnKusa2UnkBssStruct* arg0) { 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)) { + 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) { 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 6d62df60a..67e172ee8 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.h +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.h @@ -62,23 +62,23 @@ typedef struct { } EnKusa2UnkBssStruct; // size = 0x1740 typedef struct EnKusa2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ EnKusa2ActionFunc actionFunc; - /* 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; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ EnKusa2ActionFunc actionFunc; + /* 0x194 */ struct EnKusa2* unk_194[9]; + /* 0x1B8 */ EnKusa2UnkBssSubStruct* unk_1B8; + /* 0x1BC */ s16 unk_1BC; + /* 0x1BE */ s8 unk_1BE; + /* 0x1C0 */ struct EnKusa2* unk_1C0; + /* 0x1C4 */ s16 unk_1C4; + /* 0x1C6 */ UNK_TYPE1 unk1C6[0x2]; + /* 0x1C8 */ s16 unk_1C8; + /* 0x1CA */ s16 unk_1CA; + /* 0x1CC */ s16 unk_1CC; + /* 0x1CE */ s8 unk_1CE; + /* 0x1CF */ u8 unk_1CF; + /* 0x1D0 */ s8 unk_1D0; + /* 0x1D1 */ s8 unk_1D1; } EnKusa2; // size = 0x1D4 extern const ActorInit En_Kusa2_InitVars; diff --git a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.h b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.h index a683e3f79..ad6014dd9 100644 --- a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.h +++ b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.h @@ -8,10 +8,10 @@ struct EnLiftNuts; typedef void (*EnLiftNutsActionFunc)(struct EnLiftNuts*, PlayState*); typedef struct EnLiftNuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; - /* 0x01D4 */ EnLiftNutsActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x180]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x90]; + /* 0x1D4 */ EnLiftNutsActionFunc actionFunc; + /* 0x1D8 */ char unk_1D8[0x180]; } EnLiftNuts; // size = 0x358 extern const ActorInit En_Lift_Nuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index 8888ad488..7441a14fd 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -139,7 +139,7 @@ void EnLookNuts_Destroy(Actor* thisx, PlayState* play) { void EnLookNuts_SetupPatrol(EnLookNuts* this) { Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 0, -10.0f); + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), ANIMMODE_LOOP, -10.0f); this->state = PALACE_GUARD_PATROLLING; this->actionFunc = EnLookNuts_Patrol; } @@ -189,7 +189,7 @@ void EnLookNuts_Patrol(EnLookNuts* this, PlayState* play) { void EnLookNuts_SetupStandAndWait(EnLookNuts* this) { Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 2, -10.0f); + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), ANIMMODE_ONCE, -10.0f); this->waitTimer = Rand_S16Offset(1, 3); this->headRotTarget.y = 10000.0f; @@ -262,7 +262,7 @@ void EnLookNuts_StandAndWait(EnLookNuts* this, PlayState* play) { void EnLookNuts_DetectedPlayer(EnLookNuts* this, PlayState* play) { Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 2.0f, 0.0f, - Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 0, -10.0f); + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), ANIMMODE_LOOP, -10.0f); this->state = PALACE_GUARD_RUNNING_TO_PLAYER; this->eventTimer = 300; Message_StartTextbox(play, 0x833, &this->actor); @@ -285,7 +285,7 @@ void EnLookNuts_RunToPlayer(EnLookNuts* this, PlayState* play) { void EnLookNuts_SetupSendPlayerToSpawn(EnLookNuts* this) { Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 2, -10.0f); + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), ANIMMODE_ONCE, -10.0f); this->state = PALACE_GUARD_CAUGHT_PLAYER; this->actionFunc = EnLookNuts_SendPlayerToSpawn; } @@ -293,12 +293,12 @@ void EnLookNuts_SetupSendPlayerToSpawn(EnLookNuts* this) { void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); play->nextEntranceIndex = Entrance_CreateIndexFromSpawn(this->spawnIndex); gSaveContext.nextCutsceneIndex = 0; Scene_SetExitFade(play); - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.save.weekEventReg[17] |= 4; } } diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h index 91b8db871..9d5a1eb24 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h @@ -13,26 +13,26 @@ typedef void (*EnLookNutsActionFunc)(struct EnLookNuts*, PlayState*); #define LOOKNUTS_GET_PATROL_LOCATION(thisx) (((thisx)->params >> 0x7) & 0x1F) typedef struct EnLookNuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[DEKU_PALACE_GUARD_LIMB_MAX]; - /* 0x01CA */ Vec3s morphTable[DEKU_PALACE_GUARD_LIMB_MAX]; - /* 0x020C */ EnLookNutsActionFunc actionFunc; - /* 0x0210 */ Path *path; - /* 0x0214 */ s16 currentPathIndex; // Index for the point where the deku guard is in its path - /* 0x0216 */ s16 eyeState; - /* 0x0218 */ s16 blinkTimer; - /* 0x021A */ s16 eventTimer; // Timer to trigger when another event within the actor will happen - /* 0x021C */ s16 state; - /* 0x021E */ s16 switchFlag; - /* 0x0220 */ s16 pathLocation; // Determines path that a guard will patrol - /* 0x0222 */ s16 isPlayerDetected; - /* 0x0224 */ s16 waitTimer; // Timer for how long the deku guard will take a break for - /* 0x0226 */ s16 spawnIndex; - /* 0x0228 */ UNK_TYPE4 pad228; // Unused necessary padding - /* 0x022C */ Vec3f headRotation; - /* 0x0238 */ Vec3f headRotTarget; // Target value for head rotation - /* 0x0244 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x1CA */ Vec3s morphTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x20C */ EnLookNutsActionFunc actionFunc; + /* 0x210 */ Path *path; + /* 0x214 */ s16 currentPathIndex; // Index for the point where the deku guard is in its path + /* 0x216 */ s16 eyeState; + /* 0x218 */ s16 blinkTimer; + /* 0x21A */ s16 eventTimer; // Timer to trigger when another event within the actor will happen + /* 0x21C */ s16 state; + /* 0x21E */ s16 switchFlag; + /* 0x220 */ s16 pathLocation; // Determines path that a guard will patrol + /* 0x222 */ s16 isPlayerDetected; + /* 0x224 */ s16 waitTimer; // Timer for how long the deku guard will take a break for + /* 0x226 */ s16 spawnIndex; + /* 0x228 */ UNK_TYPE4 pad228; // Unused necessary padding + /* 0x22C */ Vec3f headRotation; + /* 0x238 */ Vec3f headRotTarget; // Target value for head rotation + /* 0x244 */ ColliderCylinder collider; } EnLookNuts; // size = 0x290 extern const ActorInit En_Look_Nuts_InitVars; diff --git a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h index d3b6590d4..14d022770 100644 --- a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h +++ b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.h @@ -8,10 +8,10 @@ struct EnMThunder; typedef void (*EnMThunderActionFunc)(struct EnMThunder*, PlayState*); typedef struct EnMThunder { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x74]; - /* 0x01B8 */ EnMThunderActionFunc actionFunc; - /* 0x01BC */ char unk_1BC[0x8]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x74]; + /* 0x1B8 */ EnMThunderActionFunc actionFunc; + /* 0x1BC */ char unk_1BC[0x8]; } EnMThunder; // size = 0x1C4 extern const ActorInit En_M_Thunder_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 3f92ffd5f..5af78062f 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -628,31 +628,29 @@ void EnMa4_SetupDialogueHandler(EnMa4* this) { } void EnMa4_DialogueHandler(EnMa4* this, PlayState* play) { - s32 temp_v0; - switch (Message_GetState(&play->msgCtx)) { default: break; - case 4: // Player answered a question + case TEXT_STATE_CHOICE: // Player answered a question EnMa4_HandlePlayerChoice(this, play); break; - case 5: // End message block + case TEXT_STATE_5: // End message block EnMa4_ChooseNextDialogue(this, play); break; - case 6: // End conversation + case TEXT_STATE_DONE: // End conversation if (Message_ShouldAdvance(play)) { if ((play->msgCtx.unk120B1 == 0) || !CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { EnMa4_SetupWait(this); } } - case 0: - case 1: - case 2: - case 3: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; } @@ -668,9 +666,9 @@ void EnMa4_SetupBeginHorsebackGame(EnMa4* this) { void EnMa4_BeginHorsebackGame(EnMa4* this, PlayState* play) { play->nextEntranceIndex = 0x6400; gSaveContext.nextCutsceneIndex = 0xFFF0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 0x50; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_80; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } void EnMa4_HorsebackGameCheckPlayerInteractions(EnMa4* this, PlayState* play) { @@ -760,14 +758,14 @@ void EnMa4_HorsebackGameEnd(EnMa4* this, PlayState* play) { play->nextEntranceIndex = 0x6410; gSaveContext.nextCutsceneIndex = 0; sFrameCounter = 0; - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; if (this->poppedBalloonCounter == 10) { - play->unk_1887F = 0x50; - gSaveContext.nextTransition = 3; + play->transitionType = TRANS_TYPE_80; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } else { - play->unk_1887F = 0x40; - gSaveContext.nextTransition = 2; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_02; } this->poppedBalloonCounter = 0; @@ -865,9 +863,9 @@ void EnMa4_SetupBeginDescribeThemCs(EnMa4* this) { void EnMa4_BeginDescribeThemCs(EnMa4* this, PlayState* play) { play->nextEntranceIndex = 0x6400; gSaveContext.nextCutsceneIndex = 0xFFF5; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 0x40; - gSaveContext.nextTransition = 2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_02; } void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { 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 bf3630133..306c9f7a3 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 @@ -409,25 +409,25 @@ void EnMaYto_SetupDefaultDialogueHandler(EnMaYto* this) { void EnMaYto_DefaultDialogueHandler(EnMaYto* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 4: + case TEXT_STATE_CHOICE: EnMaYto_DefaultHandlePlayerChoice(this, play); break; - case 5: + case TEXT_STATE_5: EnMaYto_DefaultChooseNextDialogue(this, play); break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { this->unk31E = 0; EnMaYto_SetupDefaultWait(this); } break; - case 0: - case 1: - case 2: - case 3: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; } @@ -541,24 +541,24 @@ void EnMaYto_SetupDinnerDialogueHandler(EnMaYto* this) { void EnMaYto_DinnerDialogueHandler(EnMaYto* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 4: + case TEXT_STATE_CHOICE: EnMaYto_DinnerHandlePlayerChoice(this, play); break; - case 5: + case TEXT_STATE_5: EnMaYto_DinnerChooseNextDialogue(this, play); break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { EnMaYto_SetupDinnerWait(this); } break; - case 0: - case 1: - case 2: - case 3: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; } } @@ -731,22 +731,22 @@ void EnMaYto_SetupBarnDialogueHandler(EnMaYto* this) { void EnMaYto_BarnDialogueHandler(EnMaYto* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 5: + case TEXT_STATE_5: EnMaYto_BarnChooseNextDialogue(this, play); break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { this->unk31E = 0; EnMaYto_SetupBarnWait(this); } break; - case 0: - case 1: - case 2: - case 3: - case 4: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: break; } } @@ -911,15 +911,15 @@ void EnMaYto_SetupAfterMilkRunDialogueHandler(EnMaYto* this) { void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 6: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: + case TEXT_STATE_DONE: break; - case 5: + case TEXT_STATE_5: EnMaYto_AfterMilkRunChooseNextDialogue(this, play); break; } @@ -1063,14 +1063,14 @@ void EnMaYto_SetupPostMilkRunWaitDialogueEnd(EnMaYto* this) { } void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 6 || Message_GetState(&play->msgCtx) == 5) { - if (Message_ShouldAdvance(play) && Message_GetState(&play->msgCtx) == 5) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE || Message_GetState(&play->msgCtx) == TEXT_STATE_5) { + if (Message_ShouldAdvance(play) && Message_GetState(&play->msgCtx) == TEXT_STATE_5) { func_800B7298(play, &this->actor, 7); func_801477B4(play); } } - if (Message_GetState(&play->msgCtx) == 0 && play->msgCtx.unk120B1 == 0) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE && play->msgCtx.unk120B1 == 0) { EnMaYto_SetupPostMilkRunEnd(this); } } @@ -1088,9 +1088,9 @@ void EnMaYto_PostMilkRunEnd(EnMaYto* this, PlayState* play) { play->nextEntranceIndex = 0x6480; } gSaveContext.nextCutsceneIndex = 0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 0x50; - gSaveContext.nextTransition = 3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_80; + gSaveContext.nextTransitionType = TRANS_TYPE_03; } void EnMaYto_DefaultStartDialogue(EnMaYto* this, PlayState* play) { 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 bac7fc53b..f43d6ca0d 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 @@ -354,21 +354,21 @@ void EnMaYts_SetupDialogueHandler(EnMaYts* this) { void EnMaYts_DialogueHandler(EnMaYts* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 5: // End message block + case TEXT_STATE_5: // End message block EnMaYts_ChooseNextDialogue(this, play); break; - case 6: // End conversation + case TEXT_STATE_DONE: // End conversation if (Message_ShouldAdvance(play)) { EnMaYts_SetupStartDialogue(this); } break; - case 0: - case 1: - case 2: - case 3: - case 4: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: break; } } diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 3d0b11f7b..15af26aff 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -161,8 +161,8 @@ void EnMag_Init(Actor* thisx, PlayState* play) { gSaveContext.unk_3F1E = 0; this->state = MAG_STATE_FADE_IN_MASK; sInputDelayTimer = 20; - gSaveContext.fadeDuration = 1; - gSaveContext.fadeSpeed = 255; + gSaveContext.transFadeDuration = 1; + gSaveContext.transWipeSpeed = 255; } Font_LoadOrderedFont(&this->font); @@ -245,8 +245,8 @@ void EnMag_Update(Actor* thisx, PlayState* play) { this->unk11F00 = 0; this->unk11F02 = 30; sInputDelayTimer = 20; - gSaveContext.fadeDuration = 1; - gSaveContext.fadeSpeed = 255; + gSaveContext.transFadeDuration = 1; + gSaveContext.transWipeSpeed = 255; } } } else { @@ -381,7 +381,7 @@ void EnMag_Update(Actor* thisx, PlayState* play) { if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_START) || CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) || CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_B)) { - if (play->sceneLoadFlag != 0x14) { + if (play->transitionTrigger != TRANS_TRIGGER_START) { Audio_SetCutsceneFlag(false); D_801BB12C++; if (D_801BB12C >= 2) { @@ -389,8 +389,8 @@ void EnMag_Update(Actor* thisx, PlayState* play) { } play_sound(NA_SE_SY_PIECE_OF_HEART); gSaveContext.gameMode = 2; // Go to FileChoose - play->sceneLoadFlag = 0x14; - play->unk_1887F = 2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; play->nextEntranceIndex = 0x1C00; gSaveContext.save.cutscene = 0; gSaveContext.sceneSetupIndex = 0; diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.h b/src/overlays/actors/ovl_En_Mag/z_en_mag.h index c116ae98d..d55d63ccb 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.h +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.h @@ -9,7 +9,6 @@ typedef struct EnMag { /* 0x00000 */ Actor actor; /* 0x00144 */ UNK_TYPE1 unk144[0x2C]; /* 0x00170 */ Font font; - /* 0x11EFC */ UNK_TYPE1 unk11EFC[4]; /* 0x11F00 */ s16 unk11F00; // Set and not used. /* 0x11F02 */ s16 unk11F02; // Set and not used. /* 0x11F04 */ s16 state; // State of whole actor, uses EnMagState enum diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c index c6d6780e4..4c7a1ddf8 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c @@ -58,7 +58,40 @@ u8 D_80B386C0[] = { }; s32 D_80B386CC[] = { - 5, 5, 3, 3, 7, 7, 7, 7, 3, 3, 3, 3, 7, 7, 3, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, + 5, // PLAYER_MWA_FORWARD_SLASH_1H + 5, // PLAYER_MWA_FORWARD_SLASH_2H + 3, // PLAYER_MWA_FORWARD_COMBO_1H + 3, // PLAYER_MWA_FORWARD_COMBO_2H + 7, // PLAYER_MWA_RIGHT_SLASH_1H + 7, // PLAYER_MWA_RIGHT_SLASH_2H + 7, // PLAYER_MWA_RIGHT_COMBO_1H + 7, // PLAYER_MWA_RIGHT_COMBO_2H + 3, // PLAYER_MWA_LEFT_SLASH_1H + 3, // PLAYER_MWA_LEFT_SLASH_2H + 3, // PLAYER_MWA_LEFT_COMBO_1H + 3, // PLAYER_MWA_LEFT_COMBO_2H + 7, // PLAYER_MWA_STAB_1H + 7, // PLAYER_MWA_STAB_2H + 3, // PLAYER_MWA_STAB_COMBO_1H + 3, // PLAYER_MWA_STAB_COMBO_2H + 0, // PLAYER_MWA_FLIPSLASH_START + 0, // PLAYER_MWA_JUMPSLASH_START + 0, // PLAYER_MWA_ZORA_JUMPKICK_START + 0, // PLAYER_MWA_FLIPSLASH_FINISH + 5, // PLAYER_MWA_JUMPSLASH_FINISH + 0, // PLAYER_MWA_ZORA_JUMPKICK_FINISH + 0, // PLAYER_MWA_BACKSLASH_RIGHT + 0, // PLAYER_MWA_BACKSLASH_LEFT + 0, // PLAYER_MWA_GORON_PUNCH_LEFT + 0, // PLAYER_MWA_GORON_PUNCH_RIGHT + 0, // PLAYER_MWA_GORON_PUNCH_BUTT + 0, // PLAYER_MWA_ZORA_PUNCH_LEFT + 0, // PLAYER_MWA_ZORA_PUNCH_COMBO + 0, // PLAYER_MWA_ZORA_PUNCH_KICK + 7, // PLAYER_MWA_SPIN_ATTACK_1H + 7, // PLAYER_MWA_SPIN_ATTACK_2H + 7, // PLAYER_MWA_BIG_SPIN_1H + 7 // PLAYER_MWA_BIG_SPIN_2H }; Vec3f D_80B38754 = { -2.0f, 3.0f, 0.0f }; @@ -328,7 +361,7 @@ void func_80B37590(EnMaruta* this, PlayState* play) { break; case 4: - if (player->swordAnimation == 8) { + if (player->meleeWeaponAnimation == PLAYER_MWA_LEFT_SLASH_1H) { sp48 = D_80B3876C; } else { sp48 = D_80B38778; @@ -337,7 +370,7 @@ void func_80B37590(EnMaruta* this, PlayState* play) { break; case 5: - if (player->swordAnimation == 0) { + if (player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_1H) { sp48 = D_80B38784; } else { sp48 = D_80B38790; @@ -346,7 +379,7 @@ void func_80B37590(EnMaruta* this, PlayState* play) { break; case 6: - if (player->swordAnimation == 0) { + if (player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_1H) { sp48 = D_80B3879C; } else { sp48 = D_80B387A8; @@ -355,7 +388,7 @@ void func_80B37590(EnMaruta* this, PlayState* play) { break; case 8: - if (player->swordAnimation == 4) { + if (player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) { sp48 = D_80B387B4; } else { sp48 = D_80B387C0; @@ -459,8 +492,10 @@ s32 func_80B37B78(EnMaruta* this, PlayState* play) { temp_v1 = BINANG_SUB(temp_v1, player->actor.shape.rot.y); if ((ABS_ALT(temp_v1) < 0x1555) || - ((player->swordState != 0) && ((player->swordAnimation == 4) || (player->swordAnimation == 6) || - (player->swordAnimation == 0x1E) || (player->swordAnimation == 0x20)))) { + ((player->meleeWeaponState != 0) && ((player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_COMBO_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_SPIN_ATTACK_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_BIG_SPIN_1H)))) { return true; } return false; @@ -492,16 +527,17 @@ void func_80B37CA0(EnMaruta* this, PlayState* play) { this->collider.base.acFlags &= ~AC_HIT; Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SWORD_STRIKE); - if (D_80B386CC[player->swordAnimation] != 0) { - s32 temp = D_80B386CC[player->swordAnimation] + 1; + if (D_80B386CC[player->meleeWeaponAnimation] != 0) { + s32 temp = D_80B386CC[player->meleeWeaponAnimation] + 1; temp = (temp << 8) & 0xFF00; - this->unk_210 = D_80B386CC[player->swordAnimation]; + this->unk_210 = D_80B386CC[player->meleeWeaponAnimation]; Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_MARUTA, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, temp); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->unk_210 == 5) || ((this->unk_210 == 7) && (player->swordAnimation == 0xC))) { + if ((this->unk_210 == 5) || + ((this->unk_210 == 7) && (player->meleeWeaponAnimation == PLAYER_MWA_STAB_1H))) { func_80B37590(this, play); } else { func_80B374B8(this); diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h index 2dce575b5..1af506c58 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h @@ -11,20 +11,20 @@ typedef void (*EnMarutaActionFunc)(struct EnMaruta*, PlayState*); #define ENMARUTA_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) typedef struct EnMaruta { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnMarutaActionFunc actionFunc; - /* 0x0148 */ ColliderCylinder collider; - /* 0x0194 */ Vec3f unk_194; - /* 0x01A0 */ Vec3f* unk_1A0; - /* 0x01A4 */ Vec3f unk_1A4[8]; - /* 0x0204 */ Vec3f unk_204; - /* 0x0210 */ s32 unk_210; - /* 0x0214 */ s32 unk_214; - /* 0x0218 */ s16 unk_218; - /* 0x021A */ s16 unk_21A; - /* 0x021C */ s16 unk_21C; - /* 0x021E */ s16 unk_21E; - /* 0x0220 */ s16 unk_220; + /* 0x000 */ Actor actor; + /* 0x144 */ EnMarutaActionFunc actionFunc; + /* 0x148 */ ColliderCylinder collider; + /* 0x194 */ Vec3f unk_194; + /* 0x1A0 */ Vec3f* unk_1A0; + /* 0x1A4 */ Vec3f unk_1A4[8]; + /* 0x204 */ Vec3f unk_204; + /* 0x210 */ s32 unk_210; + /* 0x214 */ s32 unk_214; + /* 0x218 */ s16 unk_218; + /* 0x21A */ s16 unk_21A; + /* 0x21C */ s16 unk_21C; + /* 0x21E */ s16 unk_21E; + /* 0x220 */ s16 unk_220; } EnMaruta; // size = 0x224 extern const ActorInit En_Maruta_InitVars; diff --git a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c index 7cc22b4f3..fd0001166 100644 --- a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c +++ b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c @@ -60,7 +60,7 @@ static ColliderJntSphElementInit D_808CBF50[3] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_808CBFBC = { { COLTYPE_NONE, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 3, D_808CBF50, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_808CBF50, // sJntSphElementsInit, }; // static DamageTable sDamageTable = { diff --git a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.h b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.h index 754b36d30..427bafa1e 100644 --- a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.h +++ b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.h @@ -8,9 +8,9 @@ struct EnMinideath; typedef void (*EnMinideathActionFunc)(struct EnMinideath*, PlayState*); typedef struct EnMinideath { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnMinideathActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x164]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnMinideathActionFunc actionFunc; + /* 0x148 */ char unk_148[0x164]; } EnMinideath; // size = 0x2AC extern const ActorInit En_Minideath_InitVars; 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 2ab7f6233..ad8bd2468 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -112,7 +112,7 @@ void EnMinifrog_Init(Actor* thisx, PlayState* play) { this->timer = 0; if (1) {} - if (!EN_MINIFROG_IS_RETURNED(this)) { + if (!EN_MINIFROG_IS_RETURNED(&this->actor)) { if ((this->frogIndex == MINIFROG_YELLOW) || ((gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & (u8)isFrogReturnedFlags[this->frogIndex]))) { @@ -177,7 +177,7 @@ EnMinifrog* EnMinifrog_GetFrog(PlayState* play) { void EnMinifrog_SetJumpState(EnMinifrog* this) { if (this->jumpState == MINIFROG_STATE_GROUND) { this->jumpState = MINIFROG_STATE_JUMP; - Animation_Change(&this->skelAnime, &object_fr_Anim_0007BC, 1.0f, 0.0f, 7.0f, 2, -5.0f); + Animation_Change(&this->skelAnime, &object_fr_Anim_0007BC, 1.0f, 0.0f, 7.0f, ANIMMODE_ONCE, -5.0f); } } @@ -258,7 +258,7 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, PlayState* play) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { EnMinifrog_SetJumpState(this); switch (play->msgCtx.currentTextId) { @@ -496,13 +496,13 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, PlayState* play) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); switch (Message_GetState(&play->msgCtx)) { - case 4: + case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: // Yes func_8019F208(); this->actionFunc = EnMinifrog_BeginChoirCutscene; - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; break; case 1: // No func_8019F230(); @@ -511,7 +511,8 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, PlayState* play) { } } break; - case 5: + + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { EnMinifrog_SetJumpState(this); switch (play->msgCtx.currentTextId) { @@ -530,7 +531,7 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, PlayState* play) { break; case 0xD77: // "Let us begin our chorus" this->actionFunc = EnMinifrog_BeginChoirCutscene; - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; break; case 0xD7C: // "The conducting was spectacular. And all of our members rose to the occasion!" if (gSaveContext.save.weekEventReg[35] & 0x80) { // Obtained Heart Piece @@ -554,6 +555,7 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, PlayState* play) { break; } } + break; } } diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.h b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.h index 8d63d7783..a71caa650 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.h +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.h @@ -7,7 +7,7 @@ struct EnMinifrog; typedef void (*EnMinifrogActionFunc)(struct EnMinifrog*, PlayState*); -#define EN_MINIFROG_IS_RETURNED(this) ((((this)->actor.params)&0xF0) >> 4) +#define EN_MINIFROG_IS_RETURNED(thisx) ((((thisx)->params) & 0xF0) >> 4) typedef enum { /* 0x00 */ MINIFROG_YELLOW, // Mountain Village diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.c b/src/overlays/actors/ovl_En_Mk/z_en_mk.c index 89c1be02e..03dda25ad 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -168,14 +168,14 @@ void func_809596A0(EnMk* this, PlayState* play) { } switch (Message_GetState(&play->msgCtx)) { - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { func_801477B4(play); this->actionFunc = func_80959774; } break; - case 2: + case TEXT_STATE_CLOSING: this->actionFunc = func_80959774; break; } @@ -268,10 +268,10 @@ void func_80959A24(EnMk* this, PlayState* play) { this->unk_27A |= 1; switch (Message_GetState(&play->msgCtx)) { - case 2: + case TEXT_STATE_CLOSING: break; - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0xFA1: diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.h b/src/overlays/actors/ovl_En_Mk/z_en_mk.h index 9862f3761..ed6cd6997 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.h +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.h @@ -9,16 +9,16 @@ struct EnMk; typedef void (*EnMkActionFunc)(struct EnMk*, PlayState*); typedef struct EnMk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ Vec3s jointTable[OBJECT_MK_LIMB_MAX]; - /* 0x0222 */ Vec3s morphTable[OBJECT_MK_LIMB_MAX]; - /* 0x0270 */ Vec3s unk_270; - /* 0x0276 */ s16 unk_276[2]; - /* 0x027A */ u16 unk_27A; - /* 0x027C */ s16 unk_27C; - /* 0x0280 */ EnMkActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ Vec3s jointTable[OBJECT_MK_LIMB_MAX]; + /* 0x222 */ Vec3s morphTable[OBJECT_MK_LIMB_MAX]; + /* 0x270 */ Vec3s unk_270; + /* 0x276 */ s16 unk_276[2]; + /* 0x27A */ u16 unk_27A; + /* 0x27C */ s16 unk_27C; + /* 0x280 */ EnMkActionFunc actionFunc; } EnMk; // size = 0x284 extern const ActorInit En_Mk_InitVars; diff --git a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.h b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.h index 4dcc552be..200186c44 100644 --- a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.h +++ b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.h @@ -8,9 +8,9 @@ struct EnMkk; typedef void (*EnMkkActionFunc)(struct EnMkk*, PlayState*); typedef struct EnMkk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnMkkActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x8C]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnMkkActionFunc actionFunc; + /* 0x148 */ char unk_148[0x8C]; } EnMkk; // size = 0x1D4 extern const ActorInit En_Mkk_InitVars; diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.h b/src/overlays/actors/ovl_En_Mm/z_en_mm.h index dc028a872..e278c8bfd 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.h +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.h @@ -8,10 +8,10 @@ struct EnMm; typedef void (*EnMmActionFunc)(struct EnMm*, PlayState*); typedef struct EnMm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ s16 unk_190; - /* 0x0194 */ EnMmActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ s16 unk_190; + /* 0x194 */ EnMmActionFunc actionFunc; } EnMm; // size = 0x198 #endif // Z_EN_MM_H 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 46c53796b..d049bdba0 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c @@ -46,15 +46,17 @@ void EnMm2_Destroy(Actor* thisx, PlayState* play) { * Action function whilst Link is reading the letter. */ void EnMm2_Reading(EnMm2* this, PlayState* play) { - u8 talkState = Message_GetState(&play->msgCtx); + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + func_801477B4(play); + this->actionFunc = EnMm2_WaitForRead; + } + break; - if (talkState != 2) { - if (talkState == 5 && Message_ShouldAdvance(play)) { - func_801477B4(play); + case TEXT_STATE_CLOSING: this->actionFunc = EnMm2_WaitForRead; - } - } else { - this->actionFunc = EnMm2_WaitForRead; + break; } } diff --git a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.h b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.h index 981611943..1b3dcc0aa 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.h +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.h @@ -8,10 +8,10 @@ struct EnMm2; typedef void (*EnMm2ActionFunc)(struct EnMm2*, PlayState*); typedef struct EnMm2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnMm2ActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x128]; + /* 0x000 */ Actor actor; + /* 0x144 */ UNK_TYPE1 unk_144[0x44]; + /* 0x188 */ EnMm2ActionFunc actionFunc; + /* 0x18C */ UNK_TYPE1 unk_18C[0x128]; } EnMm2; // size = 0x2B4 extern const ActorInit En_Mm2_InitVars; diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 2931471e9..d263df3c8 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -84,7 +84,7 @@ void EnMm3_Init(Actor* thisx, PlayState* play) { SkelAnime_InitFlex(play, &this->skelAnime, &object_mm_Skel_0096E8, &object_mm_Anim_00A4E0, this->jointTable, this->morphTable, 16); Animation_Change(&this->skelAnime, &object_mm_Anim_00A4E0, -1.0f, Animation_GetLastFrame(&object_mm_Anim_00A4E0), - 0.0f, 2, 0.0f); + 0.0f, ANIMMODE_ONCE, 0.0f); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); @@ -148,7 +148,7 @@ void func_80A6F3B4(EnMm3* this, PlayState* play) { func_8019F208(); Message_StartTextbox(play, 0x2790, &this->actor); this->unk_2B4 = 0x2790; - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } else { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x279C, &this->actor); @@ -174,7 +174,7 @@ void func_80A6F3B4(EnMm3* this, PlayState* play) { func_8019F208(); Message_StartTextbox(play, 0x2790, &this->actor); this->unk_2B4 = 0x2790; - func_801159EC(-play->msgCtx.unk1206C); + Rupees_ChangeBy(-play->msgCtx.unk1206C); } else { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x279C, &this->actor); @@ -314,24 +314,24 @@ void func_80A6F9DC(EnMm3* this, PlayState* play) { this->unk_2B0 &= ~2; switch (Message_GetState(&play->msgCtx)) { - case 0: - case 1: - case 2: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: break; - case 3: + case TEXT_STATE_3: this->unk_2B0 |= 2; break; - case 4: + case TEXT_STATE_CHOICE: func_80A6F3B4(this, play); break; - case 5: + case TEXT_STATE_5: func_80A6F5E4(this, play); break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { if (this->unk_2B4 == 0x2790) { Player* player = GET_PLAYER(play); diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h index fe6fa6978..b6f653935 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h @@ -8,21 +8,21 @@ struct EnMm3; typedef void (*EnMm3ActionFunc)(struct EnMm3*, PlayState*); typedef struct EnMm3 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ ColliderCylinder collider; - /* 0x01D4 */ EnMm3ActionFunc actionFunc; - /* 0x01D8 */ UNK_TYPE1 unk1D8[4]; - /* 0x01DC */ s32 unk_1DC; - /* 0x01E0 */ Vec3s jointTable[16]; - /* 0x0240 */ Vec3s morphTable[16]; - /* 0x02A0 */ Vec3s unk_2A0; - /* 0x02A6 */ Vec3s unk_2A6; - /* 0x02AC */ s16 unk_2AC; - /* 0x02AE */ s16 unk_2AE; - /* 0x02B0 */ u16 unk_2B0; - /* 0x02B2 */ u16 unk_2B2; - /* 0x02B4 */ u16 unk_2B4; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderCylinder collider; + /* 0x1D4 */ EnMm3ActionFunc actionFunc; + /* 0x1D8 */ UNK_TYPE1 unk1D8[4]; + /* 0x1DC */ s32 unk_1DC; + /* 0x1E0 */ Vec3s jointTable[16]; + /* 0x240 */ Vec3s morphTable[16]; + /* 0x2A0 */ Vec3s unk_2A0; + /* 0x2A6 */ Vec3s unk_2A6; + /* 0x2AC */ s16 unk_2AC; + /* 0x2AE */ s16 unk_2AE; + /* 0x2B0 */ u16 unk_2B0; + /* 0x2B2 */ u16 unk_2B2; + /* 0x2B4 */ u16 unk_2B4; } EnMm3; // size = 0x2B8 extern const ActorInit En_Mm3_InitVars; diff --git a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.h b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.h index e61fa6921..495b8f07b 100644 --- a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.h +++ b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.h @@ -8,9 +8,9 @@ struct EnMnk; typedef void (*EnMnkActionFunc)(struct EnMnk*, PlayState*); typedef struct EnMnk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x2A4]; - /* 0x03E8 */ EnMnkActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x2A4]; + /* 0x3E8 */ EnMnkActionFunc actionFunc; } EnMnk; // size = 0x3EC extern const ActorInit En_Mnk_InitVars; 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 3425e6923..0a3573516 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -98,13 +98,13 @@ void EnMs_Wait(EnMs* this, PlayState* play) { void EnMs_Talk(EnMs* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { this->actionFunc = EnMs_Wait; } break; - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { func_801477B4(play); Actor_PickUp(&this->actor, play, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, @@ -113,7 +113,7 @@ void EnMs_Talk(EnMs* this, PlayState* play) { } break; - case 4: + case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: // yes @@ -127,7 +127,7 @@ void EnMs_Talk(EnMs* this, PlayState* play) { } else { func_8019F208(); Actor_PickUp(&this->actor, play, GI_MAGIC_BEANS, 90.0f, 10.0f); - func_801159EC(-10); + Rupees_ChangeBy(-10); this->actionFunc = EnMs_Sell; } break; @@ -140,6 +140,7 @@ void EnMs_Talk(EnMs* this, PlayState* play) { } } break; + default: break; } diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c index 41b1712d2..2200154aa 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c @@ -229,12 +229,12 @@ s32 EnMttag_UpdateCheckpoints(EnMttag* this, PlayState* play) { /** * Exits the race and returns the player back to "normal" gameplay. - * Whether the player won or lost the race is determined by arg1 and nextTransition. + * Whether the player won or lost the race is determined by transitionType and nextTransitionType. */ -s32 EnMttag_ExitRace(PlayState* play, s32 arg1, s32 nextTransition) { +s32 EnMttag_ExitRace(PlayState* play, s32 transitionType, s32 nextTransitionType) { CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; play->nextEntranceIndex = 0xD020; - if ((gSaveContext.save.weekEventReg[33] & 0x80)) { + if (gSaveContext.save.weekEventReg[33] & 0x80) { // Spring gSaveContext.nextCutsceneIndex = 0xFFF0; } else { @@ -242,9 +242,9 @@ s32 EnMttag_ExitRace(PlayState* play, s32 arg1, s32 nextTransition) { gSaveContext.nextCutsceneIndex = 0; } - play->sceneLoadFlag = 0x14; - play->unk_1887F = arg1; - gSaveContext.nextTransition = nextTransition; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = transitionType; + gSaveContext.nextTransitionType = nextTransitionType; func_801477B4(play); return 1; } @@ -398,10 +398,10 @@ void EnMttag_RaceFinish(EnMttag* this, PlayState* play) { if (DECR(this->timer) == 0) { if ((gSaveContext.eventInf[1] & 2)) { // Player won - EnMttag_ExitRace(play, 3, 3); + EnMttag_ExitRace(play, TRANS_TYPE_03, TRANS_TYPE_03); } else { // A non-player Goron won - EnMttag_ExitRace(play, 2, 2); + EnMttag_ExitRace(play, TRANS_TYPE_02, TRANS_TYPE_02); } Actor_MarkForDeath(&this->actor); @@ -416,7 +416,7 @@ void EnMttag_RaceFinish(EnMttag* this, PlayState* play) { void EnMttag_PotentiallyRestartRace(EnMttag* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - if (((talkState == 5 && Message_ShouldAdvance(play)) || talkState == 2)) { + if (((talkState == TEXT_STATE_5 && Message_ShouldAdvance(play)) || talkState == TEXT_STATE_CLOSING)) { if (this->shouldRestartRace) { play->nextEntranceIndex = 0xD010; @@ -428,9 +428,9 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, PlayState* play) { gSaveContext.nextCutsceneIndex = 0; } - play->sceneLoadFlag = 0x14; - play->unk_1887F = 2; - gSaveContext.nextTransition = 2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_02; func_801477B4(play); func_800B7298(play, &this->actor, 7); Parameter_AddMagic(play, @@ -442,7 +442,7 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, PlayState* play) { gSaveContext.eventInf[1] &= (u8)~8; gSaveContext.eventInf[2] = ((gSaveContext.eventInf[2] & 0xF) + 1) | (gSaveContext.eventInf[2] & 0xF0); } else { - EnMttag_ExitRace(play, 2, 2); + EnMttag_ExitRace(play, TRANS_TYPE_02, TRANS_TYPE_02); } Actor_MarkForDeath(&this->actor); } @@ -453,12 +453,12 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, PlayState* play) { * responded to the Goron Elder's son's question. */ void EnMttag_HandleCantWinChoice(EnMttag* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 4) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { if (play->msgCtx.choiceIndex != 0) { // Exit the race func_8019F230(); gSaveContext.unk_3DD0[4] = 0; - EnMttag_ExitRace(play, 2, 2); + EnMttag_ExitRace(play, TRANS_TYPE_02, TRANS_TYPE_02); gSaveContext.eventInf[1] &= (u8)~8; gSaveContext.eventInf[1] |= 4; Actor_MarkForDeath(&this->actor); 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 c47b7ba5b..4e6c471af 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -67,7 +67,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -751,7 +751,7 @@ void EnMushi2_Init(Actor* thisx, PlayState* play) { func_80A68F24(this); SkelAnime_Init(play, &this->skelAnime, &gameplay_keep_Skel_0527A0, &gameplay_keep_Anim_05140C, this->jointTable, this->morphTable, 24); - Animation_Change(&this->skelAnime, &gameplay_keep_Anim_05140C, 1.0f, 0.0f, 0.0f, 1, 0.0f); + Animation_Change(&this->skelAnime, &gameplay_keep_Anim_05140C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, 0.0f); Collider_InitJntSph(play, &this->collider); Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); func_80A68808(this); diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h index d36d385b0..159116928 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h @@ -10,39 +10,39 @@ typedef void (*EnMushi2ActionFunc)(struct EnMushi2*, PlayState*); #define ENMUSHI2_GET_3(thisx) ((thisx)->params & 3) typedef struct { - /* 0x00 */ s16 unk_00; - /* 0x02 */ s16 unk_02; -} EnMushi2Struct; + /* 0x0 */ s16 unk_00; + /* 0x2 */ s16 unk_02; +} EnMushi2Struct; // size = 0x4 typedef struct EnMushi2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[24]; - /* 0x0218 */ Vec3s morphTable[24]; - /* 0x02A8 */ ColliderJntSph collider; - /* 0x02C8 */ ColliderJntSphElement colliderElements[1]; - /* 0x0308 */ EnMushi2ActionFunc actionFunc; - /* 0x030C */ s32 unk_30C; - /* 0x0310 */ Vec3f unk_310; - /* 0x031C */ Vec3f unk_31C; - /* 0x0328 */ Vec3f unk_328; - /* 0x0334 */ CollisionPoly* poly; - /* 0x0338 */ s32 polyBgId; - /* 0x033C */ Vec3f unk_33C; - /* 0x0348 */ f32 unk_348; - /* 0x034C */ struct ObjBean* unk_34C; - /* 0x0350 */ f32 unk_350; - /* 0x0354 */ f32 unk_354; - /* 0x0358 */ f32 unk_358; - /* 0x035C */ f32 unk_35C; - /* 0x0360 */ f32 unk_360; - /* 0x0364 */ s16 unk_364; - /* 0x0366 */ s16 unk_366; - /* 0x0368 */ s16 unk_368; - /* 0x036A */ s16 unk_36A; - /* 0x036C */ s16 unk_36C; - /* 0x036E */ s16 unk_36E; - /* 0x0370 */ s16 unk_370; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[24]; + /* 0x218 */ Vec3s morphTable[24]; + /* 0x2A8 */ ColliderJntSph collider; + /* 0x2C8 */ ColliderJntSphElement colliderElements[1]; + /* 0x308 */ EnMushi2ActionFunc actionFunc; + /* 0x30C */ s32 unk_30C; + /* 0x310 */ Vec3f unk_310; + /* 0x31C */ Vec3f unk_31C; + /* 0x328 */ Vec3f unk_328; + /* 0x334 */ CollisionPoly* poly; + /* 0x338 */ s32 polyBgId; + /* 0x33C */ Vec3f unk_33C; + /* 0x348 */ f32 unk_348; + /* 0x34C */ struct ObjBean* unk_34C; + /* 0x350 */ f32 unk_350; + /* 0x354 */ f32 unk_354; + /* 0x358 */ f32 unk_358; + /* 0x35C */ f32 unk_35C; + /* 0x360 */ f32 unk_360; + /* 0x364 */ s16 unk_364; + /* 0x366 */ s16 unk_366; + /* 0x368 */ s16 unk_368; + /* 0x36A */ s16 unk_36A; + /* 0x36C */ s16 unk_36C; + /* 0x36E */ s16 unk_36E; + /* 0x370 */ s16 unk_370; } EnMushi2; // size = 0x374 extern const ActorInit En_Mushi2_InitVars; 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 1a77cc388..c568e8f6e 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -198,7 +198,7 @@ void EnMuto_SetupDialogue(EnMuto* this, PlayState* play) { void EnMuto_InDialogue(EnMuto* this, PlayState* play) { if (!this->isInMayorsRoom) { this->yawTowardsTarget = this->actor.yawTowardsPlayer; - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); if (this->actor.textId == 0x62C) { @@ -272,7 +272,7 @@ void EnMuto_Update(Actor* thisx, PlayState* play2) { Math_SmoothStepToS(&this->headRot.x, this->headRotTarget.x, 1, 0x3E8, 0); Math_SmoothStepToS(&this->waistRot.y, this->waistRotTarget.y, 1, 0xBB8, 0); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1DU); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); this->actor.uncullZoneForward = 500.0f; diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.h b/src/overlays/actors/ovl_En_Muto/z_en_muto.h index 12517f1e3..e05e29492 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.h +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.h @@ -8,26 +8,26 @@ struct EnMuto; typedef void (*EnMutoActionFunc)(struct EnMuto*, PlayState*); typedef struct EnMuto { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[17]; - /* 0x01EE */ Vec3s morphTable[17]; - /* 0x0254 */ EnMutoActionFunc actionFunc; - /* 0x0258 */ Vec3s headRot; - /* 0x025E */ Vec3s headRotTarget; - /* 0x0262 */ Vec3s waistRot; - /* 0x026A */ Vec3s waistRotTarget; - /* 0x0270 */ s16 unusedCounter; - /* 0x0274 */ f32 frameIndex; - /* 0x0278 */ s16 isInDialogue; - /* 0x027A */ s16 textIdIndex; - /* 0x027C */ s16 yawTowardsTarget; - /* 0x0280 */ s32 isInMayorsRoom; - /* 0x0284 */ s32 shouldSetHeadRotation; - /* 0x0288 */ Actor* targetActor; - /* 0x028C */ s32 cutsceneState; - /* 0x0290 */ s32 animIndex; - /* 0x0294 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[17]; + /* 0x1EE */ Vec3s morphTable[17]; + /* 0x254 */ EnMutoActionFunc actionFunc; + /* 0x258 */ Vec3s headRot; + /* 0x25E */ Vec3s headRotTarget; + /* 0x262 */ Vec3s waistRot; + /* 0x26A */ Vec3s waistRotTarget; + /* 0x270 */ s16 unusedCounter; + /* 0x274 */ f32 frameIndex; + /* 0x278 */ s16 isInDialogue; + /* 0x27A */ s16 textIdIndex; + /* 0x27C */ s16 yawTowardsTarget; + /* 0x280 */ s32 isInMayorsRoom; + /* 0x284 */ s32 shouldSetHeadRotation; + /* 0x288 */ Actor* targetActor; + /* 0x28C */ s32 cutsceneState; + /* 0x290 */ s32 animIndex; + /* 0x294 */ ColliderCylinder collider; } EnMuto; // size = 0x2E0 extern const ActorInit En_Muto_InitVars; diff --git a/src/overlays/actors/ovl_En_Nb/z_en_nb.h b/src/overlays/actors/ovl_En_Nb/z_en_nb.h index 1fab2e649..b094456d9 100644 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.h +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.h @@ -8,10 +8,10 @@ struct EnNb; typedef void (*EnNbActionFunc)(struct EnNb*, PlayState*); typedef struct EnNb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnNbActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x110]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ EnNbActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x110]; } EnNb; // size = 0x29C extern const ActorInit En_Nb_InitVars; 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 09b617c3e..0f392dcfd 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -352,7 +352,8 @@ void EnNiw_UpdateRunning(EnNiw* this, PlayState* play, s32 isStormCucco) { } void EnNiw_SetupIdle(EnNiw* this) { - Animation_Change(&this->skelanime, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), 0, -10.0f); + Animation_Change(&this->skelanime, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), ANIMMODE_LOOP, + -10.0f); this->niwState = NIW_STATE_IDLE; this->actionFunc = EnNiw_Idle; } @@ -656,7 +657,8 @@ void EnNiw_CuccoStorm(EnNiw* this, PlayState* play) { } void EnNiw_SetupRunAway(EnNiw* this) { - Animation_Change(&this->skelanime, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), 0, -10.0f); + Animation_Change(&this->skelanime, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), ANIMMODE_LOOP, + -10.0f); this->isRunningRight = Rand_ZeroFloat(1.99f); this->niwState = NIW_STATE_RUNNING; this->actionFunc = EnNiw_RunAway; diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.h b/src/overlays/actors/ovl_En_Niw/z_en_niw.h index aaa3c0fe6..2be60884e 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.h +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.h @@ -9,15 +9,15 @@ struct EnNiw; typedef void (*EnNiwActionFunc)(struct EnNiw*, PlayState*); typedef struct { - /* 0x0000 */ u8 isEnabled; - /* 0x0004 */ Vec3f pos; - /* 0x0010 */ Vec3f vel; - /* 0x001C */ Vec3f accel; - /* 0x0028 */ s16 life; - /* 0x002A */ s16 zRotStart; - /* 0x002C */ f32 scale; - /* 0x0030 */ f32 zRot; - /* 0x0034 */ u8 timer; + /* 0x00 */ u8 isEnabled; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f vel; + /* 0x1C */ Vec3f accel; + /* 0x28 */ s16 life; + /* 0x2A */ s16 zRotStart; + /* 0x2C */ f32 scale; + /* 0x30 */ f32 zRot; + /* 0x34 */ u8 timer; } EnNiwFeather; // size = 0x38 #define NIW_FEATHER_COUNT 20 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 7f1fe790f..41ae5d99c 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, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - Message_StartTextbox(play, 0x228U, &this->actor); + Message_StartTextbox(play, 0x228, &this->actor); func_80C088A4(this); return; } diff --git a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c index 2bfb7da1d..972513c04 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c @@ -246,7 +246,8 @@ void EnNwc_LoadNiwSkeleton(EnNwc* this, PlayState* play) { SkelAnime_InitFlex(play, &this->niwSkeleton, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, this->morphTable, NIW_LIMB_MAX); - Animation_Change(&this->niwSkeleton, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), 0, 0.0f); + Animation_Change(&this->niwSkeleton, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), + ANIMMODE_LOOP, 0.0f); gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[this->nwcObjectIndex].segment); this->state = NWC_STATE_NIW_LOADED; diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c index 426951a9c..3e977520d 100644 --- a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c @@ -57,8 +57,8 @@ void func_8096B104(EnOkarinaEffect* this, PlayState* play) { void func_8096B174(EnOkarinaEffect* this, PlayState* play) { DECR(this->unk144); - if (!play->pauseCtx.state && !play->gameOverCtx.state && !play->msgCtx.unk11F10 && - !FrameAdvance_IsEnabled(&play->state) && this->unk144 == 0) { + if ((play->pauseCtx.state == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + (play->msgCtx.msgLength == 0) && !FrameAdvance_IsEnabled(&play->state) && this->unk144 == 0) { EnOkarinaEffect_SetupAction(this, func_8096B1FC); } } diff --git a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.h b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.h index 38f19a6b1..6825adb4d 100644 --- a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.h +++ b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.h @@ -8,9 +8,9 @@ struct EnOkarinaTag; typedef void (*EnOkarinaTagActionFunc)(struct EnOkarinaTag*, PlayState*); typedef struct EnOkarinaTag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnOkarinaTagActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x14]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnOkarinaTagActionFunc actionFunc; + /* 0x148 */ char unk_148[0x14]; } EnOkarinaTag; // size = 0x15C extern const ActorInit En_Okarina_Tag_InitVars; diff --git a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.h b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.h index a4b30069a..c23a4db36 100644 --- a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.h +++ b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.h @@ -8,10 +8,10 @@ struct EnOkuta; typedef void (*EnOkutaActionFunc)(struct EnOkuta*, PlayState*); typedef struct EnOkuta { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnOkutaActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x1A8]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ EnOkutaActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x1A8]; } EnOkuta; // size = 0x334 extern const ActorInit En_Okuta_InitVars; diff --git a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c index 25b9c5160..59b3140bc 100644 --- a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c +++ b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c @@ -14,7 +14,8 @@ void EnOnpuman_Init(Actor* thisx, PlayState* play); void EnOnpuman_Destroy(Actor* thisx, PlayState* play); void EnOnpuman_Update(Actor* thisx, PlayState* play); -#if 0 +void func_80B121D8(EnOnpuman* this, PlayState* play); + const ActorInit En_Onpuman_InitVars = { ACTOR_EN_ONPUMAN, ACTORCAT_NPC, @@ -27,29 +28,150 @@ const ActorInit En_Onpuman_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B12390 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +void EnOnpuman_Init(Actor* thisx, PlayState* play) { + EnOnpuman* this = THIS; -extern ColliderCylinderInit D_80B12390; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + this->actor.flags |= ACTOR_FLAG_2000000; + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); + this->actor.targetMode = 6; + this->unk_2A4 = 0; + this->unk_2A0 = NULL; + this->actionFunc = func_80B121D8; + this->actor.velocity.y = -10.0f; + this->actor.terminalVelocity = -10.0f; + this->actor.gravity = -5.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/EnOnpuman_Init.s") +void EnOnpuman_Destroy(Actor* thisx, PlayState* play) { + EnOnpuman* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/EnOnpuman_Destroy.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/func_80B11F44.s") +Actor* func_80B11F44(PlayState* play) { + Actor* itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/func_80B11F78.s") + if (itemAction != NULL) { + if (itemAction->id != ACTOR_EN_GAKUFU) { + itemAction = itemAction->next; + } + return itemAction; + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/func_80B1202C.s") +void func_80B11F78(EnOnpuman* this, PlayState* play) { + if (play->msgCtx.ocarinaMode == 4) { + this->actionFunc = func_80B121D8; + if (this->actor.cutscene != -1) { + ActorCutscene_Stop(this->actor.cutscene); + } + } else if (play->msgCtx.ocarinaMode == 3) { + play_sound(NA_SE_SY_CORRECT_CHIME); + play->msgCtx.ocarinaMode = 4; + if (this->actor.cutscene != -1) { + ActorCutscene_Stop(this->actor.cutscene); + } + this->actionFunc = func_80B121D8; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/func_80B1217C.s") +void func_80B1202C(EnOnpuman* this, PlayState* play2) { + PlayState* play = play2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/func_80B121D8.s") + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && (Message_ShouldAdvance(play))) { + switch (play->msgCtx.currentTextId) { + case 0x8D4: + this->unk_2A4 |= 1; + func_80151938(play, 0x8DA); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Onpuman/EnOnpuman_Update.s") + case 0x8DA: + func_80151938(play, 0x8D6); + if (this->unk_2A0 != NULL) { + this->unk_2A0->home.rot.x = 0x50; + } + break; + + case 0x8D6: + this->actionFunc = func_80B11F78; + func_80152434(play, 0x3A); + if (this->unk_2A0 != NULL) { + this->unk_2A0->home.rot.x = 0; + } + break; + } + } + if (this->unk_2A4 & 1) { + if (this->actor.cutscene == -1) { + this->unk_2A4 &= ~1; + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + this->unk_2A4 &= ~1; + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80B1217C(EnOnpuman* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && (Message_ShouldAdvance(play))) { + this->actionFunc = func_80B121D8; + func_801477B4(play); + } +} + +void func_80B121D8(EnOnpuman* this, PlayState* play) { + s16 yaw; + + if (func_800B8718(&this->actor, &play->state)) { + this->actionFunc = func_80B1202C; + Message_StartTextbox(play, 0x8D4, NULL); + this->unk_2A0 = func_80B11F44(play); + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_80B1217C; + } else { + yaw = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (this->actor.xzDistToPlayer < 200.0f) { + if (ABS_ALT(yaw) <= 0x4300) { + this->actor.textId = 0x8D3; + func_800B8614(&this->actor, play, 100.0f); + func_800B874C(&this->actor, play, 100.0f, 100.0f); + } + } + } +} + +void EnOnpuman_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnOnpuman* this = THIS; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->actionFunc(this, play); +} diff --git a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.h b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.h index fe20760bb..88cd1e4df 100644 --- a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.h +++ b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.h @@ -8,9 +8,12 @@ struct EnOnpuman; typedef void (*EnOnpumanActionFunc)(struct EnOnpuman*, PlayState*); typedef struct EnOnpuman { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x164]; - /* 0x02A8 */ EnOnpumanActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ UNK_TYPE1 pad_144[0x110]; + /* 0x254 */ ColliderCylinder collider; + /* 0x2A0 */ Actor* unk_2A0; + /* 0x2A4 */ u16 unk_2A4; // flags + /* 0x2A8 */ EnOnpumanActionFunc actionFunc; } EnOnpuman; // size = 0x2AC extern const ActorInit En_Onpuman_InitVars; diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.h b/src/overlays/actors/ovl_En_Osk/z_en_osk.h index 32c27d29f..d8a4be4ce 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.h +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.h @@ -13,15 +13,15 @@ typedef void (*EnOskActionFunc)(struct EnOsk*, PlayState*); #define ENOSK_2 2 typedef struct EnOsk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[17]; - /* 0x01EE */ Vec3s morphTable[17]; - /* 0x0254 */ s16 unk_254; - /* 0x0256 */ s16 unk_256; - /* 0x0258 */ u16 unk_258; - /* 0x025C */ f32 unk_25C; - /* 0x0260 */ EnOskActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[17]; + /* 0x1EE */ Vec3s morphTable[17]; + /* 0x254 */ s16 unk_254; + /* 0x256 */ s16 unk_256; + /* 0x258 */ u16 unk_258; + /* 0x25C */ f32 unk_25C; + /* 0x260 */ EnOskActionFunc actionFunc; } EnOsk; // size = 0x264 extern const ActorInit En_Osk_InitVars; diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 5a46d37f6..445787abe 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -29,19 +29,31 @@ const ActorInit En_Osn_InitVars = { }; static AnimationInfo sAnimations[] = { - { &object_osn_Anim_0201BC, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_002F74, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_osn_Anim_0037C4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_004320, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_osn_Anim_004C8C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_0094E4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_osn_Anim_009BB8, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_00AC60, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_osn_Anim_001614, 1.0f, 1.0f, 39.0f, 0, 0.0f }, { &object_osn_Anim_001034, 1.0f, 1.0f, 70.0f, 0, 0.0f }, - { &object_osn_Anim_00AE9C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_003A1C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_osn_Anim_0055F8, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_007220, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_osn_Anim_00A444, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_0000C4, 0.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_osn_Anim_0000C4, 0.0f, 1.0f, 1.0f, 2, 0.0f }, { &object_osn_Anim_006D48, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_osn_Anim_001D6C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_osn_Anim_002634, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_osn_Anim_008D80, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_osn_Anim_005D78, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_osn_Anim_006564, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_00A444, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_osn_Anim_008D80, 0.0f, 77.0f, 0.0f, 2, 0.0f }, + { &object_osn_Anim_0201BC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_002F74, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_0037C4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_004320, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_004C8C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_0094E4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_009BB8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_00AC60, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_001614, 1.0f, 1.0f, 39.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_001034, 1.0f, 1.0f, 70.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_00AE9C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_003A1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_0055F8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_007220, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_00A444, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_0000C4, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_osn_Anim_0000C4, 0.0f, 1.0f, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_osn_Anim_006D48, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_001D6C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_osn_Anim_002634, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_008D80, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_osn_Anim_005D78, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_osn_Anim_006564, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_00A444, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_osn_Anim_008D80, 0.0f, 77.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -747,13 +759,13 @@ void func_80AD16A8(EnOsn* this, PlayState* play) { } void func_80AD19A0(EnOsn* this, PlayState* play) { - u8 temp_v0 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); - if ((temp_v0 == 6 || temp_v0 == 5) && Message_ShouldAdvance(play)) { + if (((talkState == TEXT_STATE_DONE) || (talkState == TEXT_STATE_5)) && Message_ShouldAdvance(play)) { if (this->unk_1EA & 0x20) { this->unk_1EA &= ~0x20; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80AD14C8; } else { func_80AD10FC(this, play); @@ -770,7 +782,7 @@ void EnOsn_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_osn_Skel_0202F0, &object_osn_Anim_0201BC, 0, 0, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &object_osn_Skel_0202F0, &object_osn_Anim_0201BC, NULL, NULL, 0); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -836,7 +848,7 @@ void EnOsn_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); SkelAnime_Update(&this->skelAnime); - if (!(ENOSN_GET_3(&this->actor))) { + if (!ENOSN_GET_3(&this->actor)) { if (sp34 != 0) { this->actor.flags |= ACTOR_FLAG_1; func_80AD0830(this, play); diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.h b/src/overlays/actors/ovl_En_Osn/z_en_osn.h index 4cfacae8b..fdc8ed2c7 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.h +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.h @@ -8,22 +8,22 @@ struct EnOsn; typedef void (*EnOsnActionFunc)(struct EnOsn*, PlayState*); typedef struct EnOsn { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0X0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnOsnActionFunc actionFunc; - /* 0x01D8 */ Vec3s unk_1D8; - /* 0x01DE */ Vec3s unk_1DE; - /* 0x01E4 */ UNK_TYPE1 unk_1E4[0x6]; - /* 0x01EA */ u16 unk_1EA; - /* 0x01EC */ u8 unk_1EC; - /* 0x01ED */ u8 unk_1ED; - /* 0x01EE */ s16 cutscene; - /* 0x01F0 */ u8 unk_1F0; - /* 0x01F1 */ UNK_TYPE1 unk_1F1[0x3]; - /* 0x01F4 */ u16 unk_1F4; - /* 0x01F6 */ s32 unk_1F6; - /* 0x01FA */ u8 unk_1FA; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnOsnActionFunc actionFunc; + /* 0x1D8 */ Vec3s unk_1D8; + /* 0x1DE */ Vec3s unk_1DE; + /* 0x1E4 */ UNK_TYPE1 unk_1E4[0x6]; + /* 0x1EA */ u16 unk_1EA; + /* 0x1EC */ u8 unk_1EC; + /* 0x1ED */ u8 unk_1ED; + /* 0x1EE */ s16 cutscene; + /* 0x1F0 */ u8 unk_1F0; + /* 0x1F1 */ UNK_TYPE1 unk_1F1[0x3]; + /* 0x1F4 */ u16 unk_1F4; + /* 0x1F6 */ s32 unk_1F6; + /* 0x1FA */ u8 unk_1FA; } EnOsn; // size = 0x1FB extern const ActorInit En_Osn_InitVars; 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 796f6e018..8e747abe2 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -19,13 +19,13 @@ void EnOssan_Destroy(Actor* thisx, PlayState* play); void EnOssan_Update(Actor* thisx, PlayState* play); void EnOssan_CuriosityShopMan_Draw(Actor* thisx, PlayState* play); -void EnOssan_PartTimeWorker_Draw(Actor* thisx, PlayState* play); +void EnOssan_PartTimer_Draw(Actor* thisx, PlayState* play); void EnOssan_CuriosityShopMan_Init(EnOssan* this, PlayState* play); u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, PlayState* play); -void EnOssan_PartTimeWorker_Init(EnOssan* this, PlayState* play); -u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, PlayState* play); +void EnOssan_PartTimer_Init(EnOssan* this, PlayState* play); +u16 EnOssan_PartTimer_GetWelcome(EnOssan* this, PlayState* play); void EnOssan_InitShop(EnOssan* this, PlayState* play); void EnOssan_Idle(EnOssan* this, PlayState* play); @@ -104,7 +104,7 @@ const ActorInit En_Ossan_InitVars = { (ActorFunc)NULL, }; -static AnimationInfoS sAnimationsCuriosityShopMan[] = { +static AnimationInfoS sCuriosityShopManAnimations[] = { { &gFsnIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gFsnScratchBackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gFsnTurnAroundAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, @@ -120,7 +120,7 @@ static AnimationInfoS sAnimationsCuriosityShopMan[] = { { &gFsnMakeOfferAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; -static AnimationInfoS sAnimationsPartTimeWorker[] = { +static AnimationInfoS sPartTimerAnimations[] = { { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, @@ -137,7 +137,7 @@ static AnimationInfoS sAnimationsPartTimeWorker[] = { static s16 sObjectIds[] = { OBJECT_FSN, OBJECT_ANI }; -static AnimationInfoS* sAnimations[] = { sAnimationsCuriosityShopMan, sAnimationsPartTimeWorker }; +static AnimationInfoS* sAnimations[] = { sCuriosityShopManAnimations, sPartTimerAnimations }; static f32 sActorScales[] = { 0.01f, 0.01f }; @@ -161,31 +161,31 @@ static ShopItem sShops[][8] = { { SI_POTION_RED_3, { -80, 92, -195 } } }, }; -static u16 sWelcomeHumanTextIds[] = { 0X06A4, 0X06C1 }; +static u16 sWelcomeHumanTextIds[] = { 0x06A4, 0x06C1 }; -static u16 sTalkOptionTextIds[] = { 0X06AB, 0X06C8 }; +static u16 sTalkOptionTextIds[] = { 0x06AB, 0x06C8 }; -static u16 sWelcomeGoronFirstTimeTextIds[] = { 0X06A5, 0X06C2 }; +static u16 sWelcomeGoronFirstTimeTextIds[] = { 0x06A5, 0x06C2 }; -static u16 sWelcomeZoraFirstTimeTextIds[] = { 0X06A7, 0X06C4 }; +static u16 sWelcomeZoraFirstTimeTextIds[] = { 0x06A7, 0x06C4 }; -static u16 sWelcomeDekuFirstTimeTextIds[] = { 0X06A9, 0X06C6 }; +static u16 sWelcomeDekuFirstTimeTextIds[] = { 0x06A9, 0x06C6 }; -static u16 sWelcomeGoronTextIds[] = { 0X06A6, 0X06C3 }; +static u16 sWelcomeGoronTextIds[] = { 0x06A6, 0x06C3 }; -static u16 sWelcomeZoraTextIds[] = { 0X06A8, 0X06C5 }; +static u16 sWelcomeZoraTextIds[] = { 0x06A8, 0x06C5 }; -static u16 sWelcomeDekuTextIds[] = { 0X06AA, 0X06C7 }; +static u16 sWelcomeDekuTextIds[] = { 0x06AA, 0x06C7 }; -static u16 sNeedEmptyBottleTextIds[] = { 0X06BC, 0X06D9 }; +static u16 sNeedEmptyBottleTextIds[] = { 0x06BC, 0x06D9 }; -static u16 sNeedRupeesTextIds[] = { 0X06BD, 0X06DA }; +static u16 sNeedRupeesTextIds[] = { 0x06BD, 0x06DA }; -static u16 sNoRoomTextIds[] = { 0X06BE, 0X06DB }; +static u16 sNoRoomTextIds[] = { 0x06BE, 0x06DB }; -static u16 sBuySuccessTextIds[] = { 0X06BF, 0X06DC }; +static u16 sBuySuccessTextIds[] = { 0x06BF, 0x06DC }; -static u16 sCannotGetNowTextIds[] = { 0X06C0, 0X06DD }; +static u16 sCannotGetNowTextIds[] = { 0x06C0, 0x06DD }; static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), @@ -236,12 +236,12 @@ void EnOssan_RotateHead(EnOssan* this, PlayState* play) { if (this->actor.params == ENOSSAN_PART_TIME_WORKER) { if (player->transformation == PLAYER_FORM_ZORA) { - Math_SmoothStepToS(&this->headRotPartTimeWorker.y, this->headRot.y, 3, 2000, 0); + Math_SmoothStepToS(&this->partTimerHeadRot.y, this->headRot.y, 3, 2000, 0); } else if (this->flags & LOOKED_AT_PLAYER) { - Math_SmoothStepToS(&this->headRotPartTimeWorker.y, 8000, 3, 2000, 0); + Math_SmoothStepToS(&this->partTimerHeadRot.y, 8000, 3, 2000, 0); } else { - Math_SmoothStepToS(&this->headRotPartTimeWorker.y, this->headRot.y, 3, 2000, 0); - if (ABS_ALT(this->headRotPartTimeWorker.y - this->headRot.y) < 16) { + Math_SmoothStepToS(&this->partTimerHeadRot.y, this->headRot.y, 3, 2000, 0); + if (ABS_ALT(this->partTimerHeadRot.y - this->headRot.y) < 16) { this->flags |= LOOKED_AT_PLAYER; } } @@ -301,7 +301,7 @@ void EnOssan_EndInteraction(PlayState* play, EnOssan* this) { Actor_ProcessTalkRequest(&this->actor, &play->state); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; Interface_ChangeAlpha(50); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; @@ -331,7 +331,7 @@ s32 EnOssan_TestEndInteraction(EnOssan* this, PlayState* play, Input* input) { s32 EnOssan_TestCancelOption(EnOssan* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->actionFunc = this->tmpActionFunc; + this->actionFunc = this->prevActionFunc; func_80151938(play, this->items[this->cursorIdx]->actor.textId); return true; } @@ -383,7 +383,7 @@ void EnOssan_Idle(EnOssan* this, PlayState* play) { func_800B8614(&this->actor, play, 100.0f); } if (this->actor.params == ENOSSAN_PART_TIME_WORKER) { - Math_SmoothStepToS(&this->headRotPartTimeWorker.y, 8000, 3, 2000, 0); + Math_SmoothStepToS(&this->partTimerHeadRot.y, 8000, 3, 2000, 0); } } } @@ -446,7 +446,7 @@ void EnOssan_BeginInteraction(EnOssan* this, PlayState* play) { } } else { EnOssan_SetHaveMet(this); - this->textId = EnOssan_PartTimerWorker_GetWelcome(this, play); + this->textId = EnOssan_PartTimer_GetWelcome(this, play); Message_StartTextbox(play, this->textId, &this->actor); EnOssan_SetupStartShopping(play, this, false); } @@ -563,7 +563,7 @@ void EnOssan_Hello(EnOssan* this, PlayState* play) { Player* player = GET_PLAYER(play); EnOssan_RotateHead(this, play); - if (talkState == 5 && Message_ShouldAdvance(play)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if ((this->animationIndex == ANI_ANIMATION_APOLOGY_LOOP) && (this->actor.params == ENOSSAN_PART_TIME_WORKER)) { this->animationIndex = ANI_ANIMATION_STANDING_NORMAL_LOOP_2; SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); @@ -580,7 +580,7 @@ void EnOssan_Hello(EnOssan* this, PlayState* play) { return; } } - if ((talkState == 10) && (this->actor.params == ENOSSAN_PART_TIME_WORKER) && + if ((talkState == TEXT_STATE_10) && (this->actor.params == ENOSSAN_PART_TIME_WORKER) && (player->transformation == PLAYER_FORM_ZORA) && Message_ShouldAdvance(play)) { this->animationIndex = ANI_ANIMATION_APOLOGY_LOOP; SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, ANI_ANIMATION_APOLOGY_LOOP); @@ -629,7 +629,7 @@ void EnOssan_FaceShopkeeper(EnOssan* this, PlayState* play) { ActorCutscene_SetIntentToPlay(this->cutscene); this->cutsceneState = ENOSSAN_CUTSCENESTATE_WAITING; } else { - if (talkState == 4) { + if (talkState == TEXT_STATE_CHOICE) { func_8011552C(play, 6); if (!EnOssan_TestEndInteraction(this, play, CONTROLLER1(&play->state)) && (!Message_ShouldAdvance(play) || !EnOssan_FacingShopkeeperDialogResult(this, play))) { @@ -657,7 +657,7 @@ void EnOssan_FaceShopkeeper(EnOssan* this, PlayState* play) { } } if (this->actor.params == ENOSSAN_PART_TIME_WORKER && player->transformation != PLAYER_FORM_ZORA) { - Math_SmoothStepToS(&this->headRotPartTimeWorker.y, 8000, 3, 2000, 0); + Math_SmoothStepToS(&this->partTimerHeadRot.y, 8000, 3, 2000, 0); } } } @@ -665,7 +665,7 @@ void EnOssan_FaceShopkeeper(EnOssan* this, PlayState* play) { void EnOssan_TalkToShopkeeper(EnOssan* this, PlayState* play) { AnimationInfoS* animations = sAnimations[this->actor.params]; - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if ((this->animationIndex == ANI_ANIMATION_APOLOGY_LOOP) && (this->actor.params == ENOSSAN_PART_TIME_WORKER)) { this->animationIndex = ANI_ANIMATION_STANDING_NORMAL_LOOP_2; SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); @@ -823,7 +823,7 @@ s32 EnOssan_HasPlayerSelectedItem(PlayState* play, EnOssan* this, Input* input) } if (EnOssan_TestItemSelected(play)) { if (!item->isOutOfStock) { - this->tmpActionFunc = this->actionFunc; + this->prevActionFunc = this->actionFunc; func_80151938(play, this->items[this->cursorIdx]->choiceTextId); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -852,7 +852,7 @@ void EnOssan_BrowseLeftShelf(EnOssan* this, PlayState* play) { this->drawCursor = 0xFF; this->stickRightPrompt.isEnabled = true; EnOssan_UpdateCursorPos(play, this); - if (talkState == 5) { + if (talkState == TEXT_STATE_5) { func_8011552C(play, 6); if (!EnOssan_HasPlayerSelectedItem(play, this, CONTROLLER1(&play->state))) { if (this->moveHorizontal) { @@ -910,7 +910,7 @@ void EnOssan_BrowseRightShelf(EnOssan* this, PlayState* play) { this->drawCursor = 0xFF; this->stickLeftPrompt.isEnabled = true; EnOssan_UpdateCursorPos(play, this); - if (talkState == 5) { + if (talkState == TEXT_STATE_5) { func_8011552C(play, 6); if (!EnOssan_HasPlayerSelectedItem(play, this, CONTROLLER1(&play->state))) { if (this->moveHorizontal != 0) { @@ -983,7 +983,7 @@ void EnOssan_SetupBuyItemWithFanfare(PlayState* play, EnOssan* this) { Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~0x20000000; Interface_ChangeAlpha(50); this->drawCursor = 0; @@ -1051,7 +1051,7 @@ void EnOssan_HandleCanBuyItem(PlayState* play, EnOssan* this) { void EnOssan_SelectItem(EnOssan* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - if (EnOssan_TakeItemOffShelf(this) && talkState == 4) { + if (EnOssan_TakeItemOffShelf(this) && (talkState == TEXT_STATE_CHOICE)) { func_8011552C(play, 6); if (!EnOssan_TestCancelOption(this, play, CONTROLLER1(&play->state)) && Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { @@ -1060,7 +1060,7 @@ void EnOssan_SelectItem(EnOssan* this, PlayState* play) { break; case 1: func_8019F230(); - this->actionFunc = this->tmpActionFunc; + this->actionFunc = this->prevActionFunc; func_80151938(play, this->items[this->cursorIdx]->actor.textId); break; } @@ -1069,8 +1069,8 @@ void EnOssan_SelectItem(EnOssan* this, PlayState* play) { } void EnOssan_CannotBuy(EnOssan* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { - this->actionFunc = this->tmpActionFunc; + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + this->actionFunc = this->prevActionFunc; func_80151938(play, this->items[this->cursorIdx]->actor.textId); } } @@ -1078,12 +1078,12 @@ void EnOssan_CannotBuy(EnOssan* this, PlayState* play) { void EnOssan_CanBuy(EnOssan* this, PlayState* play) { EnGirlA* item; - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->shopItemSelectedTween = 0.0f; EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(play, item); - this->actionFunc = this->tmpActionFunc; + this->actionFunc = this->prevActionFunc; func_80151938(play, this->items[this->cursorIdx]->actor.textId); } } @@ -1098,9 +1098,9 @@ void EnOssan_BuyItemWithFanfare(EnOssan* this, PlayState* play) { } void EnOssan_SetupItemPurchased(EnOssan* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 6 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; EnOssan_SetupAction(this, EnOssan_ItemPurchased); if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -1118,7 +1118,7 @@ void EnOssan_ContinueShopping(EnOssan* this, PlayState* play) { Player* player = GET_PLAYER(play); EnGirlA* item; - if (talkState == 4) { + if (talkState == TEXT_STATE_CHOICE) { func_8011552C(play, 6); if (Message_ShouldAdvance(play)) { EnOssan_ResetItemPosition(this); @@ -1142,7 +1142,7 @@ void EnOssan_ContinueShopping(EnOssan* this, PlayState* play) { } } } - } else if (talkState == 5 && Message_ShouldAdvance(play)) { + } else if (talkState == TEXT_STATE_5 && Message_ShouldAdvance(play)) { EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(play, item); @@ -1368,10 +1368,10 @@ void EnOssan_CuriosityShopMan_Init(EnOssan* this, PlayState* play) { this->actor.draw = EnOssan_CuriosityShopMan_Draw; } -void EnOssan_PartTimeWorker_Init(EnOssan* this, PlayState* play) { +void EnOssan_PartTimer_Init(EnOssan* this, PlayState* play) { SkelAnime_InitFlex(play, &this->skelAnime, &gAniSkeleton, &gAniStandingNormalAnim, this->jointTable, this->morphTable, 16); - this->actor.draw = EnOssan_PartTimeWorker_Draw; + this->actor.draw = EnOssan_PartTimer_Draw; } u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, PlayState* play) { @@ -1407,7 +1407,7 @@ u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, PlayState* play) { return sWelcomeHumanTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } -u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, PlayState* play) { +u16 EnOssan_PartTimer_GetWelcome(EnOssan* this, PlayState* play) { Player* player = GET_PLAYER(play); u16 textId = Text_GetFaceReaction(play, 0x36); @@ -1459,7 +1459,7 @@ void EnOssan_SetHaveMet(EnOssan* this) { } void EnOssan_InitShop(EnOssan* this, PlayState* play) { - static EnOssanActionFunc sInitFuncs[] = { EnOssan_CuriosityShopMan_Init, EnOssan_PartTimeWorker_Init }; + static EnOssanActionFunc sInitFuncs[] = { EnOssan_CuriosityShopMan_Init, EnOssan_PartTimer_Init }; ShopItem* shopItems; if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { @@ -1678,13 +1678,13 @@ s32 EnOssan_CuriosityShopMan_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gf return false; } -s32 EnOssan_PartTimeWorker_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnOssan_PartTimer_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { EnOssan* this = THIS; if (limbIndex == ANI_LIMB_HEAD) { - Matrix_RotateXS(this->headRotPartTimeWorker.y, MTXMODE_APPLY); - Matrix_RotateZS(this->headRotPartTimeWorker.x, MTXMODE_APPLY); + Matrix_RotateXS(this->partTimerHeadRot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->partTimerHeadRot.x, MTXMODE_APPLY); } return false; } @@ -1698,12 +1698,12 @@ void EnOssan_CuriosityShopMan_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** } } -void EnOssan_PartTimeWorker_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - static Vec3f sPartTimeWorkerFocusOffset = { 800.0f, 500.0f, 0.0f }; +void EnOssan_PartTimer_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f sFocusOffset = { 800.0f, 500.0f, 0.0f }; EnOssan* this = THIS; if (limbIndex == ANI_LIMB_HEAD) { - Matrix_MultVec3f(&sPartTimeWorkerFocusOffset, &this->actor.focus.pos); + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); } } @@ -1723,7 +1723,7 @@ void EnOssan_CuriosityShopMan_Draw(Actor* thisx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -void EnOssan_PartTimeWorker_Draw(Actor* thisx, PlayState* play) { +void EnOssan_PartTimer_Draw(Actor* thisx, PlayState* play) { static TexturePtr sEyeTextures[] = { gAniOpenEyeTex, gAniClosingEyeTex, gAniClosedEyeTex }; s32 pad; EnOssan* this = THIS; @@ -1732,7 +1732,7 @@ void EnOssan_PartTimeWorker_Draw(Actor* thisx, PlayState* play) { func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnOssan_PartTimeWorker_OverrideLimbDraw, EnOssan_PartTimeWorker_PostLimbDraw, &this->actor); + EnOssan_PartTimer_OverrideLimbDraw, EnOssan_PartTimer_PostLimbDraw, &this->actor); EnOssan_DrawCursor(play, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnOssan_DrawStickDirectionPrompts(play, this); CLOSE_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h index 5ef81ebf2..32c6fc288 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h @@ -18,7 +18,7 @@ typedef struct EnOssan { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnOssanActionFunc actionFunc; - /* 0x18C */ EnOssanActionFunc tmpActionFunc; // Used to restore back to correct browsing function + /* 0x18C */ EnOssanActionFunc prevActionFunc; // Used to restore back to correct browsing function /* 0x190 */ ColliderCylinder collider; /* 0x1DC */ s16 delayTimer; /* 0x1DE */ s8 objIndex; @@ -57,7 +57,7 @@ typedef struct EnOssan { /* 0x31E */ Vec3s jointTable[ENOSSAN_LIMB_MAX]; /* 0x390 */ Vec3s morphTable[ENOSSAN_LIMB_MAX]; /* 0x402 */ s16 animationIndex; - /* 0x404 */ Vec3s headRotPartTimeWorker; + /* 0x404 */ Vec3s partTimerHeadRot; /* 0x40A */ u16 flags; } EnOssan; // size = 0x40C 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 e708b22af..dcef97ec1 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -644,7 +644,7 @@ void func_80B5CD40(EnOt* this, PlayState* play) { s32 temp; switch (Message_GetState(&play->msgCtx)) { - case 0: + case TEXT_STATE_NONE: temp = Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))), 3, 0xE38, 0x38E); this->actor.world.rot.y = this->actor.shape.rot.y; @@ -655,14 +655,14 @@ void func_80B5CD40(EnOt* this, PlayState* play) { } break; - case 1: - case 2: - case 3: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; - case 4: - case 5: - case 6: + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x1069)) { this->unk_32C |= 4; ActorCutscene_Stop(this->cutscenes[0]); @@ -740,10 +740,10 @@ void func_80B5D160(EnOt* this, PlayState* play) { s32 temp; switch (Message_GetState(&play->msgCtx)) { - case 0: + case TEXT_STATE_NONE: temp = Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); this->actor.world.rot.y = this->actor.shape.rot.y; - if (!temp) { + if (temp == 0) { switch (this->unk_384) { case 0: if ((this->unk_33C != 1) && (this->unk_33C == 2)) { @@ -778,14 +778,14 @@ void func_80B5D160(EnOt* this, PlayState* play) { } break; - case 1: - case 2: - case 3: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; - case 4: - case 5: - case 6: + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { default: diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.h b/src/overlays/actors/ovl_En_Ot/z_en_ot.h index 4f940fda8..6f4bf2105 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.h +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.h @@ -29,39 +29,39 @@ typedef struct { } EnOtUnkStruct; // size = 0x5C typedef struct EnOt { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnOtActionFunc actionFunc; - /* 0x0148 */ SkelAnime skelAnime; - /* 0x018C */ ColliderCylinder collider; - /* 0x01D8 */ Vec3s jointTable[19]; - /* 0x024A */ Vec3s morphTable[19]; - /* 0x02BC */ s32 animIdx; - /* 0x02C0 */ ActorPathing actorPath; - /* 0x032C */ u16 unk_32C; - /* 0x0330 */ Vec3f unk_330; - /* 0x033C */ s32 unk_33C; - /* 0x0340 */ s32 unk_340; - /* 0x0344 */ s16 unk_344; - /* 0x0346 */ s16 unk_346; - /* 0x0348 */ Vec3f unk_348; - /* 0x0354 */ s16 unk_354; - /* 0x0356 */ s16 cutscenes[4]; - /* 0x0360 */ struct EnOt* unk_360; - /* 0x0364 */ LightNode* lightNode; - /* 0x0368 */ LightInfo lightInfo; - /* 0x0378 */ Vec3f unk_378; - /* 0x0384 */ u8 unk_384; - /* 0x0388 */ s32 unk_388; - /* 0x038C */ s32 unk_38C; - /* 0x0390 */ s16 unk_390; - /* 0x0394 */ Vec3f unk_394; - /* 0x03A0 */ s16 unk_3A0; - /* 0x03A4 */ EnOtUnkStruct unk_3A4[10]; - /* 0x073C */ s16 unk_73C; - /* 0x0740 */ f32 unk_740; - /* 0x0744 */ Color_RGB8 unk_744; - /* 0x0747 */ Color_RGB8 unk_747; - /* 0x074C */ Vec3f unk_74C; + /* 0x000 */ Actor actor; + /* 0x144 */ EnOtActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ Vec3s jointTable[19]; + /* 0x24A */ Vec3s morphTable[19]; + /* 0x2BC */ s32 animIdx; + /* 0x2C0 */ ActorPathing actorPath; + /* 0x32C */ u16 unk_32C; + /* 0x330 */ Vec3f unk_330; + /* 0x33C */ s32 unk_33C; + /* 0x340 */ s32 unk_340; + /* 0x344 */ s16 unk_344; + /* 0x346 */ s16 unk_346; + /* 0x348 */ Vec3f unk_348; + /* 0x354 */ s16 unk_354; + /* 0x356 */ s16 cutscenes[4]; + /* 0x360 */ struct EnOt* unk_360; + /* 0x364 */ LightNode* lightNode; + /* 0x368 */ LightInfo lightInfo; + /* 0x378 */ Vec3f unk_378; + /* 0x384 */ u8 unk_384; + /* 0x388 */ s32 unk_388; + /* 0x38C */ s32 unk_38C; + /* 0x390 */ s16 unk_390; + /* 0x394 */ Vec3f unk_394; + /* 0x3A0 */ s16 unk_3A0; + /* 0x3A4 */ EnOtUnkStruct unk_3A4[10]; + /* 0x73C */ s16 unk_73C; + /* 0x740 */ f32 unk_740; + /* 0x744 */ Color_RGB8 unk_744; + /* 0x747 */ Color_RGB8 unk_747; + /* 0x74C */ Vec3f unk_74C; } EnOt; // size = 0x758 extern const ActorInit En_Ot_InitVars; 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 521624025..6b9bce5ab 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -324,7 +324,7 @@ void func_8095ACEC(EnOwl* this) { } void func_8095AD54(EnOwl* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 4) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case OWL_REPEAT: func_80151938(play, 0x7D1); @@ -340,14 +340,14 @@ void func_8095AD54(EnOwl* this, PlayState* play) { } void func_8095AE00(EnOwl* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_80151938(play, 0x7D2); this->actionFunc = func_8095AD54; } } void func_8095AE60(EnOwl* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_80151938(play, 0x7D1); this->actionFunc = func_8095AE00; } @@ -363,7 +363,7 @@ void func_8095AEC0(EnOwl* this, PlayState* play) { void func_8095AF2C(EnOwl* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { if (play->msgCtx.currentTextId == 0xBFE) { func_8095ACEC(this); @@ -375,7 +375,7 @@ void func_8095AF2C(EnOwl* this, PlayState* play) { } break; - case 6: + case TEXT_STATE_DONE: func_8095ACEC(this); this->actionFunc = func_8095ABF0; break; @@ -457,7 +457,7 @@ void func_8095B2F8(EnOwl* this, PlayState* play) { if ((this->actor.shape.rot.y == this->unk_3EC) && (this->actionFlags & 1)) { this->actionFunc = func_8095B254; Animation_Change(this->skelAnime3, this->skelAnime3->animation, 1.0f, 19.0f, - Animation_GetLastFrame(&object_owl_Anim_001168), 2, 0.0f); + Animation_GetLastFrame(&object_owl_Anim_001168), ANIMMODE_ONCE, 0.0f); this->unk_414 = func_8095C484; } @@ -467,7 +467,7 @@ void func_8095B2F8(EnOwl* this, PlayState* play) { void func_8095B3DC(EnOwl* this, PlayState* play) { if (this->actionFlags & 1) { this->actionFunc = func_8095B2F8; - Animation_Change(this->skelAnime3, &object_owl_Anim_001168, 1.0f, 0.0f, 35.0f, 2, 0.0f); + Animation_Change(this->skelAnime3, &object_owl_Anim_001168, 1.0f, 0.0f, 35.0f, ANIMMODE_ONCE, 0.0f); this->unk_414 = func_8095C408; this->unk_3EC = 0x5500; this->actor.world.pos.y += 100.0f; @@ -524,7 +524,7 @@ void func_8095B650(EnOwl* this, PlayState* play) { void func_8095B6C8(EnOwl* this, PlayState* play) { if (this->actionFlags & 1) { Animation_Change(this->skelAnime3, &object_owl_Anim_00CB94, -1.0f, - Animation_GetLastFrame(&object_owl_Anim_00CB94), 0.0f, 2, 0.0f); + Animation_GetLastFrame(&object_owl_Anim_00CB94), 0.0f, ANIMMODE_ONCE, 0.0f); this->unk_414 = func_8095C484; this->actionFunc = func_8095B650; } @@ -596,7 +596,7 @@ void func_8095B960(EnOwl* this, PlayState* play) { void func_8095B9FC(EnOwl* this, PlayState* play) { if (this->actionFlags & 1) { this->actionFunc = func_8095B960; - Animation_Change(this->skelAnime3, &object_owl_Anim_001168, 1.0f, 0.0f, 35.0f, 2, 0.0f); + Animation_Change(this->skelAnime3, &object_owl_Anim_001168, 1.0f, 0.0f, 35.0f, ANIMMODE_ONCE, 0.0f); this->unk_414 = func_8095C408; func_8095B0C8(this); } @@ -606,7 +606,7 @@ void func_8095BA84(EnOwl* this, PlayState* play) { func_8095A920(this, play); switch (Message_GetState(&play->msgCtx)) { - case 4: + case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0xBEC: @@ -645,7 +645,7 @@ void func_8095BA84(EnOwl* this, PlayState* play) { } break; - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0xBEA: @@ -803,7 +803,7 @@ void func_8095C258(EnOwl* this) { this->unk_414 = func_8095C328; this->unk_3EA = 6; Animation_Change(this->skelAnime3, &object_owl_Anim_001ADC, 1.0f, 0.0f, - Animation_GetLastFrame(&object_owl_Anim_001ADC), 2, 5.0f); + Animation_GetLastFrame(&object_owl_Anim_001ADC), ANIMMODE_ONCE, 5.0f); } } @@ -812,19 +812,19 @@ void func_8095C328(EnOwl* this) { if (this->unk_3EA > 0) { this->unk_3EA--; Animation_Change(this->skelAnime3, this->skelAnime3->animation, 1.0f, 0.0f, - Animation_GetLastFrame(this->skelAnime3->animation), 2, 0.0f); + Animation_GetLastFrame(this->skelAnime3->animation), ANIMMODE_ONCE, 0.0f); } else { this->unk_3EA = 160; this->unk_414 = func_8095C258; Animation_Change(this->skelAnime3, &object_owl_Anim_00C6D4, 1.0f, 0.0f, - Animation_GetLastFrame(&object_owl_Anim_00C6D4), 0, 5.0f); + Animation_GetLastFrame(&object_owl_Anim_00C6D4), ANIMMODE_LOOP, 5.0f); } } } void func_8095C408(EnOwl* this) { if (SkelAnime_Update(this->skelAnime3)) { - Animation_Change(this->skelAnime3, this->skelAnime3->animation, 1.0f, 18.0f, 35.0f, 2, 0.0f); + Animation_Change(this->skelAnime3, this->skelAnime3->animation, 1.0f, 18.0f, 35.0f, ANIMMODE_ONCE, 0.0f); this->actionFlags |= 1; } else { this->actionFlags &= ~1; @@ -834,7 +834,7 @@ void func_8095C408(EnOwl* this) { void func_8095C484(EnOwl* this) { if (SkelAnime_Update(this->skelAnime3)) { Animation_Change(this->skelAnime3, this->skelAnime3->animation, 1.0f, 0.0f, - Animation_GetLastFrame(this->skelAnime3->animation), 2, 0.0f); + Animation_GetLastFrame(this->skelAnime3->animation), ANIMMODE_ONCE, 0.0f); this->actionFlags |= 1; } else { this->actionFlags &= ~1; @@ -1193,7 +1193,8 @@ void func_8095D074(Actor* thisx, PlayState* play) { void EnOwl_ChangeMode(EnOwl* this, EnOwlActionFunc actionFunc, EnOwlFunc unkFunc, SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames) { this->skelAnime3 = skelAnime; - Animation_Change(this->skelAnime3, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), 2, morphFrames); + Animation_Change(this->skelAnime3, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, + morphFrames); this->actionFunc = actionFunc; this->unk_414 = unkFunc; } diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.h b/src/overlays/actors/ovl_En_Owl/z_en_owl.h index 9da8ed9d7..781fd308c 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.h +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.h @@ -21,39 +21,39 @@ typedef enum { } EnOwlType; typedef struct EnOwl { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime1; - /* 0x01D4 */ Vec3s jointTable1[21]; - /* 0x0252 */ Vec3s morphTable1[21]; - /* 0x02D0 */ SkelAnime skelAnime2; - /* 0x0314 */ Vec3s jointTable2[16]; - /* 0x0374 */ Vec3s morphTable2[16]; - /* 0x03D4 */ SkelAnime* skelAnime3; - /* 0x03D8 */ s16 unk_3D8; - /* 0x03DA */ s16 unk_3DA; - /* 0x03DC */ s16 unk_3DC; - /* 0x03DE */ s16 unk_3DE; - /* 0x03E0 */ s16 eyeTexIndex; - /* 0x03E2 */ s16 blinkTimer; - /* 0x03E4 */ f32 unk_3E4; - /* 0x03E8 */ u16 actionFlags; - /* 0x03EA */ s16 unk_3EA; - /* 0x03EC */ s16 unk_3EC; - /* 0x03F0 */ f32 unk_3F0; - /* 0x03F4 */ Path* path; - /* 0x03F8 */ s32 unk_3F8; - /* 0x03FC */ s32 unk_3FC; - /* 0x0400 */ s16 unk_400[3]; - /* 0x0406 */ s16 unk_406; - /* 0x0408 */ u8 unk_408; - /* 0x0409 */ u8 unk_409; - /* 0x040A */ u8 unk_40A; - /* 0x040B */ u8 unk_40B; - /* 0x040C */ u8 unk_40C; - /* 0x040D */ u8 unk_40D; - /* 0x0410 */ EnOwlActionFunc actionFunc; - /* 0x0414 */ EnOwlFunc unk_414; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime1; + /* 0x1D4 */ Vec3s jointTable1[21]; + /* 0x252 */ Vec3s morphTable1[21]; + /* 0x2D0 */ SkelAnime skelAnime2; + /* 0x314 */ Vec3s jointTable2[16]; + /* 0x374 */ Vec3s morphTable2[16]; + /* 0x3D4 */ SkelAnime* skelAnime3; + /* 0x3D8 */ s16 unk_3D8; + /* 0x3DA */ s16 unk_3DA; + /* 0x3DC */ s16 unk_3DC; + /* 0x3DE */ s16 unk_3DE; + /* 0x3E0 */ s16 eyeTexIndex; + /* 0x3E2 */ s16 blinkTimer; + /* 0x3E4 */ f32 unk_3E4; + /* 0x3E8 */ u16 actionFlags; + /* 0x3EA */ s16 unk_3EA; + /* 0x3EC */ s16 unk_3EC; + /* 0x3F0 */ f32 unk_3F0; + /* 0x3F4 */ Path* path; + /* 0x3F8 */ s32 unk_3F8; + /* 0x3FC */ s32 unk_3FC; + /* 0x400 */ s16 unk_400[3]; + /* 0x406 */ s16 unk_406; + /* 0x408 */ u8 unk_408; + /* 0x409 */ u8 unk_409; + /* 0x40A */ u8 unk_40A; + /* 0x40B */ u8 unk_40B; + /* 0x40C */ u8 unk_40C; + /* 0x40D */ u8 unk_40D; + /* 0x410 */ EnOwlActionFunc actionFunc; + /* 0x414 */ EnOwlFunc unk_414; } EnOwl; // size = 0x418 extern const ActorInit En_Owl_InitVars; 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 8bd89fe6b..a848f43a3 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -241,7 +241,7 @@ void func_80BD8758(EnPamera* this, PlayState* play) { if (this->hideInisdeTimer++ > 1800) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0]) && (this->cutscenes[0] != -1)) { ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[0], &this->actor); - Camera_SetToTrackActor(Play_GetCamera(play, ActorCutscene_GetCurrentCamera(this->cutscenes[0])), + Camera_SetToTrackActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->cutscenes[0])), &this->actor); this->actor.speedXZ = 1.5f; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); @@ -428,7 +428,7 @@ void func_80BD90AC(EnPamera* this, PlayState* play) { (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 200.0f)))) { if ((ActorCutscene_GetCanPlayNext(this->cutscenes[1])) && ((this->cutscenes[1] != -1))) { ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[1], &this->actor); - Camera_SetToTrackActor(Play_GetCamera(play, ActorCutscene_GetCurrentCamera(this->cutscenes[1])), + Camera_SetToTrackActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->cutscenes[1])), &this->actor); EnPamera_LookDownWell(this); } else if (this->cutscenes[1] != -1) { @@ -628,20 +628,23 @@ void func_80BD9A9C(EnPamera* this) { void EnPamera_HandleDialogue(EnPamera* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 0: - case 1: - case 2: - case 3: - case 4: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: break; - case 5: + + case TEXT_STATE_5: func_80BD9B4C(this, play); break; - case 6: + + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { func_80BD9938(this); } break; + default: break; } @@ -683,9 +686,9 @@ void func_80BD9B4C(EnPamera* this, PlayState* play) { void func_80BD9C70(EnPamera* this, PlayState* play) { play->nextEntranceIndex = 0x2020; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 0x46; - gSaveContext.nextTransition = 2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_70; + gSaveContext.nextTransitionType = TRANS_TYPE_02; } s32 func_80BD9CB8(EnPamera* this, PlayState* play) { 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 1f92d4f56..e47ca26b8 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -157,7 +157,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -339,10 +339,10 @@ void EnPametfrog_ShakeCamera(EnPametfrog* this, PlayState* play, f32 magShakeXZ, void EnPametfrog_StopCutscene(EnPametfrog* this, PlayState* play) { Camera* subCam; - if (this->subCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { subCam = Play_GetCamera(play, this->subCamId); Play_CameraSetAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye); - this->subCamId = CAM_ID_MAIN; + this->subCamId = SUB_CAM_ID_DONE; ActorCutscene_Stop(this->cutscene); func_800B724C(play, &this->actor, 6); } @@ -534,7 +534,7 @@ void EnPametfrog_FallOffSnapper(EnPametfrog* this, PlayState* play) { } void EnPametfrog_SetupJumpToWall(EnPametfrog* this) { - Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 2.0f, 0.0f, 0.0f, 0, -2.0f); + Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f); this->actor.shape.rot.x = 0; this->actor.shape.rot.z = 0; this->actor.bgCheckFlags &= ~8; @@ -701,7 +701,7 @@ void EnPametfrog_SetupClimbDownWall(EnPametfrog* this) { s16 yaw; Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 0.0f, 0.0f, - Animation_GetLastFrame(&gGekkoJumpForwardAnim), 2, 0.0f); + Animation_GetLastFrame(&gGekkoJumpForwardAnim), ANIMMODE_ONCE, 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; @@ -735,7 +735,7 @@ void EnPametfrog_ClimbDownWall(EnPametfrog* this, PlayState* play) { } void EnPametfrog_SetupRunToSnapper(EnPametfrog* this) { - Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 2.0f, 0.0f, 0.0f, 0, -2.0f); + Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f); this->actor.params = GEKKO_RETURN_TO_SNAPPER; this->actionFunc = EnPametfrog_RunToSnapper; } @@ -827,7 +827,7 @@ void EnPametfrog_SetupFallInAir(EnPametfrog* this, PlayState* play) { yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); this->actor.world.pos.x += 30.0f * Math_SinS(yaw); this->actor.world.pos.z += 30.0f * Math_CosS(yaw); - if (this->subCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { xzDist = sqrtf(SQXZ(this->unk_2DC)); if (xzDist > 0.001f) { xzDist = 200.0f / xzDist; @@ -857,7 +857,7 @@ void EnPametfrog_FallInAir(EnPametfrog* this, PlayState* play) { } } else { this->spinYaw += 0xF00; - if (this->subCamId != CAM_ID_MAIN) { + if (this->subCamId != SUB_CAM_ID_DONE) { Play_CameraSetAtEye(play, this->subCamId, &this->actor.world.pos, &Play_GetCamera(play, this->subCamId)->eye); } @@ -1006,7 +1006,7 @@ void EnPametfrog_SetupCutscene(EnPametfrog* this) { void EnPametfrog_PlayCutscene(EnPametfrog* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->actor); - this->subCamId = ActorCutscene_GetCurrentCamera(this->cutscene); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->cutscene); func_800B724C(play, &this->actor, 7); if (this->actor.colChkInfo.health == 0) { if (this->actor.params == GEKKO_PRE_SNAPPER) { diff --git a/src/overlays/actors/ovl_En_Paper/z_en_paper.h b/src/overlays/actors/ovl_En_Paper/z_en_paper.h index 292358e4a..9c4e6cc50 100644 --- a/src/overlays/actors/ovl_En_Paper/z_en_paper.h +++ b/src/overlays/actors/ovl_En_Paper/z_en_paper.h @@ -8,9 +8,9 @@ struct EnPaper; typedef void (*EnPaperActionFunc)(struct EnPaper*, PlayState*); typedef struct EnPaper { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnPaperActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xC40]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnPaperActionFunc actionFunc; + /* 0x148 */ char unk_148[0xC40]; } EnPaper; // size = 0xD88 extern const ActorInit En_Paper_InitVars; diff --git a/src/overlays/actors/ovl_En_Part/z_en_part.c b/src/overlays/actors/ovl_En_Part/z_en_part.c index 2967f3645..a2f2c618f 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.c +++ b/src/overlays/actors/ovl_En_Part/z_en_part.c @@ -15,7 +15,9 @@ void EnPart_Destroy(Actor* thisx, PlayState* play); void EnPart_Update(Actor* thisx, PlayState* play); void EnPart_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_80865390(EnPart* this, PlayState* play); +void func_808654C4(EnPart* this, PlayState* play); + const ActorInit En_Part_InitVars = { ACTOR_EN_PART, ACTORCAT_ITEMACTION, @@ -28,16 +30,109 @@ const ActorInit En_Part_InitVars = { (ActorFunc)EnPart_Draw, }; -#endif +void EnPart_Init(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Part/EnPart_Init.s") +void EnPart_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Part/EnPart_Destroy.s") +void func_80865390(EnPart* this, PlayState* play) { + this->actionFuncIndex = 1; + this->actor.world.rot.y = Rand_ZeroOne() * 20000.0f; + switch (this->actor.params) { + case ENPART_TYPE_1: + case ENPART_TYPE_4: + this->unk146 += (s16)(Rand_ZeroOne() * 17.0f) + 5; + this->actor.velocity.y = Rand_ZeroOne() * 5.0f + 4.0f; + this->actor.gravity = -0.6f - (Rand_ZeroOne() * 0.5f); + this->unk14C = 0.15f; + break; + case ENPART_TYPE_15: + this->actor.world.rot.y = this->actor.parent->shape.rot.y + 0x8000; + this->unk146 = 100; + this->actor.velocity.y = 7.0f; + this->actor.speedXZ = 2.0f; + this->actor.gravity = -1.0f; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Part/func_80865390.s") +void func_808654C4(EnPart* this, PlayState* play) { + s16 effectScale; + Vec3f effectPos; + Vec3f effectVelocity = { 0.0f, 0.0f, 0.0f }; + s32 i; + Vec3f pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Part/func_808654C4.s") + if (this->actor.params == ENPART_TYPE_15) { + this->unk146--; + if (this->unk146 > 0) { + this->actor.shape.rot.x += 0x3A98; + this->actor.shape.rot.y = this->actor.shape.rot.y; + this->actor.shape.rot.z = this->actor.shape.rot.z; + if (BgCheck_SphVsFirstPoly(&play->colCtx, &this->actor.world.pos, 20.0f)) { + this->unk146 = 0; + } + } else { + Math_Vec3f_Copy(&pos, &this->actor.world.pos); + pos.y = this->actor.floorHeight; + func_800B3030(play, &pos, &gZeroVec3f, &gZeroVec3f, this->actor.scale.y * 1400.0f, 7, 0); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 10, NA_SE_EN_EXTINCT); + Actor_MarkForDeath(&this->actor); + } + } else if (this->unk146 <= 0) { + switch (this->actor.params) { + case ENPART_TYPE_1: + func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, this->actor.scale.y * 4000.0f, 7, + 1); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 10, NA_SE_EN_EXTINCT); + break; + case ENPART_TYPE_4: + for (i = 7; i >= 0; i--) { + effectPos.x = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.x; + effectPos.y = randPlusMinusPoint5Scaled(50.0f) + + (this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y)); + effectPos.z = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.z; + effectVelocity.y = Rand_ZeroOne() + 1.0f; + effectScale = Rand_S16Offset(80, 100); + EffectSsDtBubble_SpawnColorProfile(play, &effectPos, &effectVelocity, &gZeroVec3f, effectScale, 25, + 0, 1); + } + break; + } + Actor_MarkForDeath(&this->actor); + } else { + this->unk146--; + this->zRot += this->unk14C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Part/EnPart_Update.s") +EnPartActionFunc sActionFuncs[] = { func_80865390, func_808654C4 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Part/EnPart_Draw.s") +void EnPart_Update(Actor* thisx, PlayState* play) { + EnPart* this = THIS; + + Actor_MoveWithGravity(&this->actor); + (*sActionFuncs[this->actionFuncIndex])(this, play); +} + +void EnPart_Draw(Actor* thisx, PlayState* play) { + EnPart* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + if (this->actor.params > ENPART_TYPE_0) { + Matrix_RotateZF(this->zRot, MTXMODE_APPLY); + } + func_8012C28C(play->state.gfxCtx); + func_800B8050(&this->actor, play, 0); + if (this->actor.params == ENPART_TYPE_15) { + gSPSegment(POLY_OPA_DISP++, 0x0C, gEmptyDL); + } + if (this->dList != NULL) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->dList); + } + + CLOSE_DISPS(play->state.gfxCtx); +} 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 fa3dd410f..53a03f281 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.h +++ b/src/overlays/actors/ovl_En_Part/z_en_part.h @@ -5,10 +5,22 @@ struct EnPart; +typedef void (*EnPartActionFunc)(struct EnPart*, PlayState*); + +typedef enum { + ENPART_TYPE_0 = 0, + ENPART_TYPE_1 = 1, + ENPART_TYPE_4 = 4, + ENPART_TYPE_15 = 15 +} EnPartParams; + typedef struct EnPart { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xC]; - /* 0x150 */ Gfx* unk_150; + /* 0x144 */ u8 actionFuncIndex; + /* 0x146 */ s16 unk146; + /* 0x148 */ f32 zRot; + /* 0x14C */ f32 unk14C; + /* 0x150 */ Gfx* dList; } 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 a19b484fd..d0598ce79 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -6,6 +6,7 @@ #include "z_en_peehat.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_ph/object_ph.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) @@ -123,7 +124,7 @@ static ColliderTrisInit sTrisInit = { OC2_TYPE_1, COLSHAPE_TRIS, }, - 2, + ARRAY_COUNT(sTrisElementsInit), sTrisElementsInit, }; @@ -260,7 +261,8 @@ void func_80897258(PlayState* play, EnPeehat* this, Vec3f* arg2, f32 arg3, f32 a D_80899564.z = randPlusMinusPoint5Scaled(1.05f); D_80899558.y = randPlusMinusPoint5Scaled(4.0f) + 8.0f; - EffectSsHahen_Spawn(play, &sp44, &D_80899558, &D_80899564, 0, (Rand_ZeroFloat(5.0f) + 12.0f) * arg4, -1, 10, NULL); + EffectSsHahen_Spawn(play, &sp44, &D_80899558, &D_80899564, 0, (Rand_ZeroFloat(5.0f) + 12.0f) * arg4, + HAHEN_OBJECT_DEFAULT, 10, NULL); } void func_80897390(EnPeehat* this, PlayState* play) { @@ -286,7 +288,7 @@ void func_80897390(EnPeehat* this, PlayState* play) { 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); + Animation_GetLastFrame(&object_ph_Anim_0009C4), ANIMMODE_ONCE, 0.0f); this->unk_2B0 = 0; this->unk_2AD = 1; this->colliderCylinder.base.acFlags &= ~AC_HIT; @@ -322,7 +324,7 @@ void func_80897520(EnPeehat* this, PlayState* play) { 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); + Animation_GetLastFrame(&object_ph_Anim_0009C4), ANIMMODE_ONCE, 0.0f); } this->unk_2B0 = 16; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIHAT_UP); 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 b5e4f95a6..e1eadb5cf 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -833,7 +833,7 @@ s32 func_80AF81E8(EnPm* this, PlayState* play) { case 4: case 6: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), this->actor.child); } this->unk_378++; ret = true; @@ -845,7 +845,7 @@ s32 func_80AF81E8(EnPm* this, PlayState* play) { if ((gSaveContext.save.weekEventReg[86] & 8) && (this->unk_378 == 3)) { ActorCutscene_Stop(sp2A); } else { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); } this->unk_378++; ret = true; @@ -875,7 +875,7 @@ s32 func_80AF8348(EnPm* this, PlayState* play) { case 4: case 6: case 8: - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); this->unk_378++; ret = true; break; @@ -885,7 +885,7 @@ s32 func_80AF8348(EnPm* this, PlayState* play) { case 5: case 7: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), this->actor.child); } this->unk_378++; ret = true; @@ -1132,11 +1132,11 @@ void func_80AF8BA8(s32 arg0) { void func_80AF8C68(EnPm* this, PlayState* play) { Player* player = GET_PLAYER(play); - s32 sp28 = Message_GetState(&play->msgCtx); - u16 temp_a0 = play->msgCtx.currentTextId; + s32 talkState = Message_GetState(&play->msgCtx); + u16 textId = play->msgCtx.currentTextId; - if ((player->targetActor == &this->actor) && ((temp_a0 < 255) || (temp_a0 > 512)) && (sp28 == 3) && - (this->unk_388 == 3)) { + if ((player->targetActor == &this->actor) && ((textId < 0xFF) || (textId > 0x200)) && (talkState == TEXT_STATE_3) && + (this->prevTalkState == TEXT_STATE_3)) { if ((play->state.frames % 3) == 0) { if (this->unk_360 == 120.0f) { this->unk_360 = 0.0f; @@ -1149,7 +1149,7 @@ void func_80AF8C68(EnPm* this, PlayState* play) { } Math_SmoothStepToF(&this->unk_364, this->unk_360, 0.8f, 40.0f, 10.0f); Matrix_Translate(this->unk_364, 0.0f, 0.0f, MTXMODE_APPLY); - this->unk_388 = sp28; + this->prevTalkState = talkState; } s32 func_80AF8D84(EnPm* this, PlayState* play) { @@ -1167,20 +1167,20 @@ s32 func_80AF8D84(EnPm* this, PlayState* play) { s32 func_80AF8DD4(EnPm* this, PlayState* play) { Player* player = GET_PLAYER(play); - u16 temp = play->msgCtx.currentTextId; + u16 textId = play->msgCtx.currentTextId; s32 pad; if (player->stateFlags1 & (0x400 | 0x40)) { this->unk_356 |= 0x400; - if (this->unk_358 != temp) { + if (this->unk_358 != textId) { if ((this->unk_384 == 0) || (this->unk_384 == 1)) { func_80AF7E98(this, 7); } - if ((temp == 0x277C) || (temp == 0x277D)) { + if ((textId == 0x277C) || (textId == 0x277D)) { func_80AF7E98(this, 10); } } - this->unk_358 = temp; + this->unk_358 = textId; } else { if (this->unk_356 & 0x400) { this->unk_358 = 0; @@ -1196,7 +1196,7 @@ s32 func_80AF8DD4(EnPm* this, PlayState* play) { return 0; } -s32 func_80AF8ED4(EnPm* this, PlayState* play, ScheduleResult* arg2, u8 actorCat, s16 actorId) { +s32 func_80AF8ED4(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput, u8 actorCat, s16 actorId) { u8 sp4F = this->actor.params & 0xFF; Vec3s* sp48; Vec3f sp3C; @@ -1207,8 +1207,8 @@ s32 func_80AF8ED4(EnPm* this, PlayState* play, ScheduleResult* arg2, u8 actorCat this->timePath = NULL; sp2C = func_80AF7CB0(this, play, actorCat, actorId); - if (D_80AFB430[arg2->result] >= 0) { - this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80AFB430[arg2->result]); + if (D_80AFB430[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80AFB430[scheduleOutput->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { @@ -1226,7 +1226,7 @@ s32 func_80AF8ED4(EnPm* this, PlayState* play, ScheduleResult* arg2, u8 actorCat return ret; } -s32 func_80AF9008(EnPm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80AF9008(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = this->actor.params & 0xFF; EnDoor* door; @@ -1237,9 +1237,9 @@ s32 func_80AF9008(EnPm* this, PlayState* play, ScheduleResult* arg2) { s32 ret = false; this->timePath = NULL; - door = func_80AF7D60(play, arg2->result); - if (D_80AFB430[arg2->result] >= 0) { - this->timePath = SubS_GetAdditionalPath(play, sp55, D_80AFB430[arg2->result]); + door = func_80AF7D60(play, scheduleOutput->result); + if (D_80AFB430[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp55, D_80AFB430[scheduleOutput->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -1258,8 +1258,8 @@ s32 func_80AF9008(EnPm* this, PlayState* play, ScheduleResult* arg2) { this->unk_260 = 0x4B; } - this->unk_36C = arg2->time1 - arg2->time0; - this->unk_36E = sp56 - arg2->time0; + this->unk_36C = scheduleOutput->time1 - scheduleOutput->time0; + this->unk_36E = sp56 - scheduleOutput->time0; this->actor.flags &= ~ACTOR_FLAG_1; if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; @@ -1274,17 +1274,18 @@ s32 func_80AF9008(EnPm* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80AF91E8(EnPm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80AF91E8(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = this->actor.params & 0xFF; - s32 pad; + u16 tmp; + s16 pad; s32 ret = false; this->timePath = NULL; - if (D_80AFB430[arg2->result] >= 0) { - this->timePath = SubS_GetAdditionalPath(play, sp2B, D_80AFB430[arg2->result]); + if (D_80AFB430[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp2B, D_80AFB430[scheduleOutput->result]); } if ((this->timePath != NULL) && (this->timePath->count < 3)) { @@ -1295,18 +1296,18 @@ s32 func_80AF91E8(EnPm* this, PlayState* play, ScheduleResult* arg2) { if ((this->unk_258 < 38) && (this->unk_258 != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->time0; + phi_v1 = scheduleOutput->time0; } - if (arg2->time1 < phi_v1) { - this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; + if (scheduleOutput->time1 < phi_v1) { + this->timePathTotalTime = (phi_v1 - scheduleOutput->time1) + 0xFFFF; } else { - this->timePathTotalTime = arg2->time1 - phi_v1; + this->timePathTotalTime = scheduleOutput->time1 - phi_v1; } this->timePathElapsedTime = sp2E - phi_v1; - phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); - this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + tmp = phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / tmp; this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_356 &= ~8; @@ -1316,7 +1317,7 @@ s32 func_80AF91E8(EnPm* this, PlayState* play, ScheduleResult* arg2) { Flags_UnsetSwitch(play, 0); } - switch (arg2->result) { + switch (scheduleOutput->result) { case 83: case 84: case 85: @@ -1355,7 +1356,7 @@ s32 func_80AF91E8(EnPm* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80AF94AC(EnPm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80AF94AC(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { u8 sp4F = this->actor.params & 0xFF; Vec3f sp40; Vec3f sp34; @@ -1364,8 +1365,8 @@ s32 func_80AF94AC(EnPm* this, PlayState* play, ScheduleResult* arg2) { s32 ret = false; this->timePath = NULL; - if (D_80AFB430[arg2->result] >= 0) { - this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80AFB430[arg2->result]); + if (D_80AFB430[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80AFB430[scheduleOutput->result]); } if ((this->timePath != 0) && (this->timePath->count >= 2)) { @@ -1376,7 +1377,7 @@ s32 func_80AF94AC(EnPm* this, PlayState* play, ScheduleResult* arg2) { Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); Math_Vec3f_Copy(&this->actor.prevPos, &sp40); - if (arg2->result == 24) { + if (scheduleOutput->result == 24) { Flags_UnsetSwitch(play, 0); Flags_UnsetSwitch(play, 1); this->unk_394 = EXCH_ITEM_NONE; @@ -1388,7 +1389,7 @@ s32 func_80AF94AC(EnPm* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80AF95E8(EnPm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80AF95E8(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { u8 sp4F = this->actor.params & 0xFF; Vec3f sp40; Vec3f sp34; @@ -1397,13 +1398,13 @@ s32 func_80AF95E8(EnPm* this, PlayState* play, ScheduleResult* arg2) { s32 ret = false; s32 phi_a3 = -1; - switch (arg2->result) { + switch (scheduleOutput->result) { case 3: case 4: case 5: case 6: case 7: - phi_a3 = arg2->result - 3; + phi_a3 = scheduleOutput->result - 3; break; case 19: @@ -1416,7 +1417,7 @@ s32 func_80AF95E8(EnPm* this, PlayState* play, ScheduleResult* arg2) { } this->timePath = NULL; - phi_a3 = D_80AFB430[arg2->result]; + phi_a3 = D_80AFB430[scheduleOutput->result]; if (phi_a3 >= 0) { this->timePath = SubS_GetAdditionalPath(play, sp4F, phi_a3); } @@ -1430,7 +1431,7 @@ s32 func_80AF95E8(EnPm* this, PlayState* play, ScheduleResult* arg2) { Math_Vec3f_Copy(&this->actor.world.pos, &sp40); Math_Vec3f_Copy(&this->actor.prevPos, &sp40); - switch (arg2->result) { + switch (scheduleOutput->result) { case 27: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); Flags_SetSwitch(play, 0); @@ -1462,7 +1463,7 @@ s32 func_80AF95E8(EnPm* this, PlayState* play, ScheduleResult* arg2) { gSaveContext.save.weekEventReg[60] |= 4; default: - if (arg2->result == 0x1D) { + if (scheduleOutput->result == 29) { this->actor.world.rot.y = BINANG_ROT180(this->actor.world.rot.y); } SubS_UpdateFlags(&this->unk_356, 3, 7); @@ -1475,7 +1476,7 @@ s32 func_80AF95E8(EnPm* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80AF98A0(EnPm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80AF98A0(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_MM3, 116.0f, 26.0f, -219.0f, 0, -0x3F46, 0, @@ -1486,7 +1487,7 @@ s32 func_80AF98A0(EnPm* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80AF992C(EnPm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80AF992C(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80AFB8EC = { 116.0f, 26.0f, -219.0f }; static Vec3s D_80AFB8F8 = { 0x0000, 0xC0BA, 0x0000 }; s32 pad; @@ -1498,7 +1499,7 @@ s32 func_80AF992C(EnPm* this, PlayState* play, ScheduleResult* arg2) { this->actor.targetMode = 6; this->actor.gravity = -1.0f; this->unk_368 = 80.0f; - if (arg2->result == 14) { + if (scheduleOutput->result == 14) { this->unk_356 &= ~0x200; func_80AF7E98(this, 13); } else { @@ -1508,10 +1509,10 @@ s32 func_80AF992C(EnPm* this, PlayState* play, ScheduleResult* arg2) { return true; } -s32 func_80AF9A0C(EnPm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80AF9A0C(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; - if (func_80AF8ED4(this, play, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { + if (func_80AF8ED4(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_AN)) { SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x20; this->unk_356 |= 0x9000; @@ -1526,10 +1527,10 @@ s32 func_80AF9A0C(EnPm* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80AF9AB0(EnPm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80AF9AB0(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; - if (func_80AF8ED4(this, play, arg2, ACTORCAT_NPC, ACTOR_EN_TEST3)) { + if (func_80AF8ED4(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_TEST3)) { SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x20; this->unk_356 |= 0x9000; @@ -1544,10 +1545,10 @@ s32 func_80AF9AB0(EnPm* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80AF9B54(EnPm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80AF9B54(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; - if (func_80AF8ED4(this, play, arg2, ACTORCAT_NPC, ACTOR_EN_AL)) { + if (func_80AF8ED4(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_AL)) { SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x9000; this->unk_356 |= 0x20; @@ -1562,7 +1563,7 @@ s32 func_80AF9B54(EnPm* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80AF9BF8(EnPm* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80AF9BF8(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret; this->actor.flags |= ACTOR_FLAG_1; @@ -1571,25 +1572,25 @@ s32 func_80AF9BF8(EnPm* this, PlayState* play, ScheduleResult* arg2) { this->unk_356 = 0; this->unk_368 = 40.0f; - switch (arg2->result) { + switch (scheduleOutput->result) { case 16: - ret = func_80AF9A0C(this, play, arg2); + ret = func_80AF9A0C(this, play, scheduleOutput); break; case 17: - ret = func_80AF9AB0(this, play, arg2); + ret = func_80AF9AB0(this, play, scheduleOutput); break; case 28: - ret = func_80AF9B54(this, play, arg2); + ret = func_80AF9B54(this, play, scheduleOutput); break; case 24: - ret = func_80AF94AC(this, play, arg2); + ret = func_80AF94AC(this, play, scheduleOutput); break; case 29: - ret = func_80AF95E8(this, play, arg2); + ret = func_80AF95E8(this, play, scheduleOutput); break; case 1: @@ -1604,7 +1605,7 @@ s32 func_80AF9BF8(EnPm* this, PlayState* play, ScheduleResult* arg2) { case 35: case 36: case 37: - ret = func_80AF9008(this, play, arg2); + ret = func_80AF9008(this, play, scheduleOutput); break; case 3: @@ -1617,11 +1618,11 @@ s32 func_80AF9BF8(EnPm* this, PlayState* play, ScheduleResult* arg2) { case 23: case 25: case 27: - ret = func_80AF95E8(this, play, arg2); + ret = func_80AF95E8(this, play, scheduleOutput); break; case 8: - ret = func_80AF98A0(this, play, arg2); + ret = func_80AF98A0(this, play, scheduleOutput); break; case 9: @@ -1629,7 +1630,7 @@ s32 func_80AF9BF8(EnPm* this, PlayState* play, ScheduleResult* arg2) { case 20: case 21: case 22: - ret = func_80AF992C(this, play, arg2); + ret = func_80AF992C(this, play, scheduleOutput); break; case 38: @@ -1686,7 +1687,7 @@ s32 func_80AF9BF8(EnPm* this, PlayState* play, ScheduleResult* arg2) { case 89: case 90: case 91: - ret = func_80AF91E8(this, play, arg2); + ret = func_80AF91E8(this, play, scheduleOutput); break; default: @@ -1699,7 +1700,7 @@ s32 func_80AF9BF8(EnPm* this, PlayState* play, ScheduleResult* arg2) { s32 func_80AF9D04(EnPm* this, PlayState* play) { EnDoor* door = (EnDoor*)func_80AF7D60(play, this->unk_258); Vec3f sp38; - Vec3f* sp28; + s32 pad; f32 temp; if (!SubS_InCsMode(play) && (this->timePathTimeSpeed != 0)) { @@ -1988,7 +1989,7 @@ void func_80AFA4D0(EnPm* this, PlayState* play) { }; u16 time = gSaveContext.save.time; u16 sp3C = 0; - ScheduleResult sp2C; + ScheduleOutput sp2C; this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (this->unk_38C != 0) { diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.h b/src/overlays/actors/ovl_En_Pm/z_en_pm.h index 1a16ece45..de7359d93 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.h +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.h @@ -10,52 +10,52 @@ typedef s32 (*EnPmFunc)(struct EnPm*, PlayState*); typedef s32 (*EnPmFunc2)(struct EnPm*, PlayState*); typedef struct EnPm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnPmActionFunc actionFunc; - /* 0x018C */ EnPmFunc2 unk_18C; - /* 0x0190 */ ColliderCylinder colliderCylinder; - /* 0x01DC */ ColliderSphere colliderSphere; - /* 0x0234 */ Path* timePath; - /* 0x0238 */ Vec3f timePathTargetPos; - /* 0x0244 */ f32 timePathProgress; - /* 0x0248 */ s32 timePathTotalTime; - /* 0x024C */ s32 timePathWaypointTime; - /* 0x0250 */ s32 timePathWaypoint; - /* 0x0254 */ s32 timePathElapsedTime; - /* 0x0258 */ u8 unk_258; - /* 0x025C */ UNK_TYPE* unk_25C; - /* 0x0260 */ s8 unk_260; - /* 0x0264 */ s32 unk_264; - /* 0x0268 */ Actor* unk_268; - /* 0x026C */ Vec3f unk_26C; - /* 0x0278 */ Vec3f unk_278; - /* 0x0284 */ Vec3f unk_284; - /* 0x0290 */ Vec3s unk_290; - /* 0x0296 */ Vec3s jointTable[16]; - /* 0x02F6 */ Vec3s morphTable[16]; - /* 0x0356 */ u16 unk_356; - /* 0x0358 */ u16 unk_358; - /* 0x035C */ f32 unk_35C; - /* 0x0360 */ f32 unk_360; - /* 0x0364 */ f32 unk_364; - /* 0x0368 */ f32 unk_368; - /* 0x036C */ s16 unk_36C; - /* 0x036E */ s16 unk_36E; - /* 0x0370 */ s16 unk_370; - /* 0x0372 */ s16 unk_372; - /* 0x0374 */ s16 timePathTimeSpeed; - /* 0x0376 */ s16 unk_376; - /* 0x0378 */ s16 unk_378; - /* 0x037C */ EnPmFunc unk_37C; - /* 0x0380 */ s32 unk_380; - /* 0x0384 */ s32 unk_384; - /* 0x0388 */ s32 unk_388; - /* 0x038C */ s32 unk_38C; - /* 0x0390 */ UNK_TYPE1 unk390[0x4]; - /* 0x0394 */ s32 unk_394; - /* 0x0398 */ s32 unk_398; - /* 0x039C */ UNK_TYPE1 unk39C[0x4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnPmActionFunc actionFunc; + /* 0x18C */ EnPmFunc2 unk_18C; + /* 0x190 */ ColliderCylinder colliderCylinder; + /* 0x1DC */ ColliderSphere colliderSphere; + /* 0x234 */ Path* timePath; + /* 0x238 */ Vec3f timePathTargetPos; + /* 0x244 */ f32 timePathProgress; + /* 0x248 */ s32 timePathTotalTime; + /* 0x24C */ s32 timePathWaypointTime; + /* 0x250 */ s32 timePathWaypoint; + /* 0x254 */ s32 timePathElapsedTime; + /* 0x258 */ u8 unk_258; + /* 0x25C */ UNK_TYPE* unk_25C; + /* 0x260 */ s8 unk_260; + /* 0x264 */ s32 unk_264; + /* 0x268 */ Actor* unk_268; + /* 0x26C */ Vec3f unk_26C; + /* 0x278 */ Vec3f unk_278; + /* 0x284 */ Vec3f unk_284; + /* 0x290 */ Vec3s unk_290; + /* 0x296 */ Vec3s jointTable[16]; + /* 0x2F6 */ Vec3s morphTable[16]; + /* 0x356 */ u16 unk_356; + /* 0x358 */ u16 unk_358; + /* 0x35C */ f32 unk_35C; + /* 0x360 */ f32 unk_360; + /* 0x364 */ f32 unk_364; + /* 0x368 */ f32 unk_368; + /* 0x36C */ s16 unk_36C; + /* 0x36E */ s16 unk_36E; + /* 0x370 */ s16 unk_370; + /* 0x372 */ s16 unk_372; + /* 0x374 */ s16 timePathTimeSpeed; + /* 0x376 */ s16 unk_376; + /* 0x378 */ s16 unk_378; + /* 0x37C */ EnPmFunc unk_37C; + /* 0x380 */ s32 unk_380; + /* 0x384 */ s32 unk_384; + /* 0x388 */ s32 prevTalkState; + /* 0x38C */ s32 unk_38C; + /* 0x390 */ UNK_TYPE1 unk_390[0x4]; + /* 0x394 */ s32 unk_394; + /* 0x398 */ s32 unk_398; + /* 0x39C */ UNK_TYPE1 unk_39C[0x4]; } EnPm; // size = 0x3A0 extern const ActorInit En_Pm_InitVars; diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index b828bfc90..e18897cf2 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -58,7 +58,7 @@ static ColliderJntSphElementInit D_80BC67AC[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80BC67D0 = { { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80BC67AC, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80BC67AC, // sJntSphElementsInit, }; // sColChkInfoInit diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h index 88d240c58..3d70aa8a4 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h @@ -8,10 +8,10 @@ struct EnPoComposer; typedef void (*EnPoComposerActionFunc)(struct EnPoComposer*, PlayState*); typedef struct EnPoComposer { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xF0]; - /* 0x0234 */ EnPoComposerActionFunc actionFunc; - /* 0x0238 */ char unk_238[0x108]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0xF0]; + /* 0x234 */ EnPoComposerActionFunc actionFunc; + /* 0x238 */ char unk_238[0x108]; } EnPoComposer; // size = 0x340 extern const ActorInit En_Po_Composer_InitVars; 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 2a7ba2d9b..955b7d524 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 @@ -12,9 +12,6 @@ #define THIS ((EnPoFusen*)thisx) -#define GET_FUSE_LEN_PARAM(this) (((Actor*)(this))->params & 0x3FF) -#define GET_IS_FUSE_TYPE_PARAM(this) (((Actor*)(this))->params & 0x8000) - void EnPoFusen_Init(Actor* thisx, PlayState* play); void EnPoFusen_Destroy(Actor* thisx, PlayState* play); void EnPoFusen_Update(Actor* thisx, PlayState* play); @@ -113,7 +110,7 @@ void EnPoFusen_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); - if (EnPoFusen_CheckParent(this, play) == 0) { + if (!EnPoFusen_CheckParent(this, play)) { Actor_MarkForDeath(&this->actor); } @@ -122,9 +119,9 @@ void EnPoFusen_Init(Actor* thisx, PlayState* play) { this->actor.home.pos.y = heightTemp; } - this->randScaleChange = ((Rand_Next() % 0xFFFEU) - 0x7FFF); - this->randYRotChange = ((Rand_Next() % 0x4B0U) - 0x258); - this->avgBaseRotation = 0x1555; + this->randScaleChange = (Rand_Next() % 0xFFFE) - 0x7FFF; + this->randYRotChange = (Rand_Next() % 0x4B0) - 0x258; + this->avgBaseRotation = 0x10000 / 12; this->limb3Rot = 0; this->limb46Rot = 0; this->limb57Rot = 0; @@ -132,7 +129,7 @@ void EnPoFusen_Init(Actor* thisx, PlayState* play) { this->limb9Rot = 0x71C; this->randBaseRotChange = 0; - if (GET_IS_FUSE_TYPE_PARAM(this)) { + if (GET_IS_FUSE_TYPE_PARAM(&this->actor)) { EnPoFusen_InitFuse(this); return; } @@ -142,6 +139,7 @@ void EnPoFusen_Init(Actor* thisx, PlayState* play) { void EnPoFusen_Destroy(Actor* thisx, PlayState* play) { EnPoFusen* this = THIS; + Collider_DestroySphere(play, &this->collider); } @@ -149,26 +147,24 @@ u16 EnPoFusen_CheckParent(EnPoFusen* this, PlayState* play) { Actor* actorPtr; actorPtr = play->actorCtx.actorLists[ACTORCAT_NPC].first; - if (GET_IS_FUSE_TYPE_PARAM(this)) { - return 1; + if (GET_IS_FUSE_TYPE_PARAM(&this->actor)) { + return true; } - if (actorPtr != 0) { - do { - if (actorPtr->id == ACTOR_EN_MA4) { - this->actor.parent = actorPtr; - return 1; - } - actorPtr = actorPtr->next; - } while (actorPtr != 0); + while (actorPtr != NULL) { + if (actorPtr->id == ACTOR_EN_MA4) { + this->actor.parent = actorPtr; + return true; + } + actorPtr = actorPtr->next; } - return 0; + return false; } u16 EnPoFusen_CheckCollision(EnPoFusen* this, PlayState* play) { if (this->actionFunc == EnPoFusen_IdleFuse) { - return 0; + return false; } this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; @@ -177,13 +173,13 @@ u16 EnPoFusen_CheckCollision(EnPoFusen* this, PlayState* play) { if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { this->collider.base.acFlags &= ~AC_HIT; - return 1; + return true; } CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); - return 0; + return false; } void EnPoFusen_InitNoFuse(EnPoFusen* this) { @@ -247,9 +243,9 @@ void EnPoFusen_Pop(EnPoFusen* this, PlayState* play) { void EnPoFusen_InitFuse(EnPoFusen* this) { s16 rotZ = this->actor.shape.rot.z; - this->fuse = GET_FUSE_LEN_PARAM(this); + this->fuse = GET_FUSE_LEN_PARAM(&this->actor); this->actor.shape.rot.z = 0; - this->randScaleChange = rotZ & 0xFFFFu; + this->randScaleChange = rotZ & 0xFFFF; this->actionFunc = EnPoFusen_IdleFuse; } @@ -263,7 +259,7 @@ void EnPoFusen_IdleFuse(EnPoFusen* this, PlayState* play) { void EnPoFusen_Update(Actor* thisx, PlayState* play) { EnPoFusen* this = THIS; this->actionFunc(this, play); - if (EnPoFusen_CheckCollision(this, play) != 0) { + if (EnPoFusen_CheckCollision(this, play)) { EnPoFusen_IncrementRomaniPop(this); } } diff --git a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h index ea07ce18a..92f75afab 100644 --- a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h +++ b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h @@ -5,6 +5,9 @@ struct EnPoFusen; +#define GET_FUSE_LEN_PARAM(thisx) ((thisx)->params & 0x3FF) +#define GET_IS_FUSE_TYPE_PARAM(thisx) ((thisx)->params & 0x8000) + typedef void (*EnPoFusenActionFunc)(struct EnPoFusen*, PlayState*); typedef struct EnPoFusen { 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 7a2f56299..9a70ce02c 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 @@ -212,7 +212,7 @@ void func_80B1A768(EnPoSisters* this, PlayState* play) { f32 sp20; if ((this->unk_18D == 0) || (this->actionFunc != func_80B1B444)) { - if (((player->swordState == 0) || (player->swordAnimation >= 30)) && + if (((player->meleeWeaponState == 0) || (player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H)) && ((player->actor.world.pos.y - player->actor.floorHeight) < 1.0f)) { Math_StepToF(&this->unk_2EC, 110.0f, 3.0f); } else { @@ -537,7 +537,7 @@ void func_80B1B628(EnPoSisters* this, PlayState* play) { void func_80B1B70C(EnPoSisters* this) { Animation_Change(&this->skelAnime, &object_po_sisters_Anim_00119C, 1.5f, 0.0f, - Animation_GetLastFrame(&object_po_sisters_Anim_00119C.common), 2, -3.0f); + Animation_GetLastFrame(&object_po_sisters_Anim_00119C.common), ANIMMODE_ONCE, -3.0f); this->unk_194 = 100; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -562,7 +562,7 @@ void func_80B1B7BC(EnPoSisters* this, PlayState* play) { void func_80B1B860(EnPoSisters* this, PlayState* play) { Animation_Change(&this->skelAnime, &object_po_sisters_Anim_00119C, 1.5f, 0.0f, - Animation_GetLastFrame(&object_po_sisters_Anim_00119C.common), 2, -3.0f); + Animation_GetLastFrame(&object_po_sisters_Anim_00119C.common), ANIMMODE_ONCE, -3.0f); if (this->unk_18C == 0) { this->unk_2EC = 110.0f; func_80B1A768(this, play); diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h index 8923a7099..67e84d0dc 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h @@ -12,32 +12,32 @@ typedef void (*EnPoSistersActionFunc)(struct EnPoSisters*, PlayState*); #define ENPOSISTERS_GET_1000(thisx) ((thisx)->params & 0x1000) typedef struct EnPoSisters { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnPoSistersActionFunc actionFunc; - /* 0x018C */ u8 unk_18C; - /* 0x018D */ u8 unk_18D; - /* 0x018E */ u8 unk_18E; - /* 0x018F */ u8 unk_18F; - /* 0x0190 */ u8 unk_190; - /* 0x0191 */ u8 unk_191; - /* 0x0192 */ s16 unk_192; - /* 0x0194 */ s16 unk_194; - /* 0x0196 */ Vec3s jointTable[12]; - /* 0x01DE */ Vec3s morphTable[12]; - /* 0x0226 */ u8 unk_226; - /* 0x0227 */ u8 unk_227; - /* 0x0228 */ u8 unk_228; - /* 0x0229 */ u8 unk_229; - /* 0x022C */ Vec3f unk_22C[8]; - /* 0x028C */ Vec3f limbPos[8]; - /* 0x02EC */ f32 unk_2EC; - /* 0x02F0 */ f32 drawDmgEffAlpha; - /* 0x02F4 */ f32 drawDmgEffScale; - /* 0x02F8 */ LightNode* lightNode; - /* 0x02FC */ LightInfo lightInfo; - /* 0x030C */ ColliderCylinder collider; - /* 0x0358 */ MtxF unk_358; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnPoSistersActionFunc actionFunc; + /* 0x18C */ u8 unk_18C; + /* 0x18D */ u8 unk_18D; + /* 0x18E */ u8 unk_18E; + /* 0x18F */ u8 unk_18F; + /* 0x190 */ u8 unk_190; + /* 0x191 */ u8 unk_191; + /* 0x192 */ s16 unk_192; + /* 0x194 */ s16 unk_194; + /* 0x196 */ Vec3s jointTable[12]; + /* 0x1DE */ Vec3s morphTable[12]; + /* 0x226 */ u8 unk_226; + /* 0x227 */ u8 unk_227; + /* 0x228 */ u8 unk_228; + /* 0x229 */ u8 unk_229; + /* 0x22C */ Vec3f unk_22C[8]; + /* 0x28C */ Vec3f limbPos[8]; + /* 0x2EC */ f32 unk_2EC; + /* 0x2F0 */ f32 drawDmgEffAlpha; + /* 0x2F4 */ f32 drawDmgEffScale; + /* 0x2F8 */ LightNode* lightNode; + /* 0x2FC */ LightInfo lightInfo; + /* 0x30C */ ColliderCylinder collider; + /* 0x358 */ MtxF unk_358; } EnPoSisters; // size = 0x398 extern const ActorInit En_Po_Sisters_InitVars; 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 31e86b8c8..d165c12d5 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -101,7 +101,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.h b/src/overlays/actors/ovl_En_Poh/z_en_poh.h index fc0e7db74..083b44f3f 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.h +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.h @@ -8,33 +8,33 @@ struct EnPoh; typedef void (*EnPohActionFunc)(struct EnPoh*, PlayState*); typedef struct EnPoh { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnPohActionFunc actionFunc; - /* 0x018C */ u8 unk_18C; - /* 0x018D */ u8 unk_18D; - /* 0x018E */ s16 unk_18E; - /* 0x0190 */ s16 unk_190; - /* 0x0192 */ s16 unk_192; - /* 0x0194 */ u8 unk_194; - /* 0x0195 */ u8 unk_195; - /* 0x0196 */ u8 unk_196; - /* 0x0197 */ u8 unk_197; - /* 0x0198 */ u8 unk_198; - /* 0x0199 */ u8 unk_199; - /* 0x019A */ u8 unk_19A; - /* 0x019B */ u8 unk_19B; - /* 0x019C */ Vec3s jointTable[21]; - /* 0x021A */ Vec3s morphTable[21]; - /* 0x0298 */ f32 drawDmgEffAlpha; - /* 0x029C */ f32 drawDmgEffScale; - /* 0x02A0 */ Vec3f limbPos[10]; - /* 0x0318 */ LightNode* lightNode; - /* 0x031C */ LightInfo lightInfo; - /* 0x032C */ ColliderCylinder colliderCylinder; - /* 0x0378 */ ColliderJntSph colliderSph; - /* 0x0398 */ ColliderJntSphElement colliderSphElements[1]; - /* 0x03D8 */ MtxF unk_3D8; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnPohActionFunc actionFunc; + /* 0x18C */ u8 unk_18C; + /* 0x18D */ u8 unk_18D; + /* 0x18E */ s16 unk_18E; + /* 0x190 */ s16 unk_190; + /* 0x192 */ s16 unk_192; + /* 0x194 */ u8 unk_194; + /* 0x195 */ u8 unk_195; + /* 0x196 */ u8 unk_196; + /* 0x197 */ u8 unk_197; + /* 0x198 */ u8 unk_198; + /* 0x199 */ u8 unk_199; + /* 0x19A */ u8 unk_19A; + /* 0x19B */ u8 unk_19B; + /* 0x19C */ Vec3s jointTable[21]; + /* 0x21A */ Vec3s morphTable[21]; + /* 0x298 */ f32 drawDmgEffAlpha; + /* 0x29C */ f32 drawDmgEffScale; + /* 0x2A0 */ Vec3f limbPos[10]; + /* 0x318 */ LightNode* lightNode; + /* 0x31C */ LightInfo lightInfo; + /* 0x32C */ ColliderCylinder colliderCylinder; + /* 0x378 */ ColliderJntSph colliderSph; + /* 0x398 */ ColliderJntSphElement colliderSphElements[1]; + /* 0x3D8 */ MtxF unk_3D8; } EnPoh; // size = 0x418 extern const ActorInit En_Poh_InitVars; diff --git a/src/overlays/actors/ovl_En_Pp/z_en_pp.c b/src/overlays/actors/ovl_En_Pp/z_en_pp.c index bd94fbc4a..ee58c770a 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.c +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.c @@ -75,7 +75,7 @@ static ColliderJntSphElementInit D_80B21664[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80B21688 = { { COLTYPE_HARD, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80B21664, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80B21664, // sJntSphElementsInit, }; // static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -89,7 +89,7 @@ static ColliderJntSphElementInit D_80B21698[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80B216BC = { { COLTYPE_HARD, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80B21698, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80B21698, // sJntSphElementsInit, }; // static ColliderQuadInit sQuadInit = { diff --git a/src/overlays/actors/ovl_En_Pp/z_en_pp.h b/src/overlays/actors/ovl_En_Pp/z_en_pp.h index bf70acb8d..4fab409b2 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.h +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.h @@ -8,10 +8,10 @@ struct EnPp; typedef void (*EnPpActionFunc)(struct EnPp*, PlayState*); typedef struct EnPp { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x17C]; - /* 0x02C0 */ EnPpActionFunc actionFunc; - /* 0x02C4 */ char unk_2C4[0x328]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x17C]; + /* 0x2C0 */ EnPpActionFunc actionFunc; + /* 0x2C4 */ char unk_2C4[0x328]; } EnPp; // size = 0x5EC extern const ActorInit En_Pp_InitVars; diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.c b/src/overlays/actors/ovl_En_Pr/z_en_pr.c index d2fd48ad3..c7fae7c88 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -106,7 +106,7 @@ static AnimationHeader* sAnimations[] = { }; u8 D_80A33934[] = { - 0, 2, 0, 0, 2, + ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, }; void EnPr_Init(Actor* thisx, PlayState* play2) { diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.h b/src/overlays/actors/ovl_En_Pr/z_en_pr.h index 4b36fee9c..6a5fe8b5a 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.h +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.h @@ -13,45 +13,45 @@ typedef void (*EnPrActionFunc)(struct EnPr*, PlayState*); #define ENPR_FF00_MIN 0 typedef struct EnPr { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[10]; - /* 0x01C4 */ Vec3s morphTable[10]; - /* 0x0200 */ EnPrActionFunc actionFunc; - /* 0x0204 */ u8 unk_204; - /* 0x0206 */ s16 unk_206; - /* 0x0208 */ s16 unk_208; - /* 0x020A */ s16 unk_20A; - /* 0x020C */ s16 unk_20C; - /* 0x020E */ s16 unk_20E; - /* 0x0210 */ s16 unk_210; - /* 0x0212 */ s16 unk_212; - /* 0x0214 */ s16 unk_214; - /* 0x0216 */ s16 unk_216; - /* 0x0218 */ UNK_TYPE1 unk218[4]; - /* 0x021C */ s32 unk_21C; - /* 0x0220 */ UNK_TYPE1 unk220[0x8]; - /* 0x0228 */ s32 unk_228; - /* 0x022C */ s16 unk_22C; - /* 0x022E */ s16 drawDmgEffAlpha; - /* 0x0230 */ s16 drawDmgEffType; - /* 0x0234 */ f32 unk_234; - /* 0x0238 */ f32 unk_238; - /* 0x023C */ Vec3f limbPos[10]; - /* 0x02B4 */ f32 unk_2B4; - /* 0x02B8 */ f32 unk_2B8; - /* 0x02BC */ f32 unk_2BC; - /* 0x02C0 */ f32 unk_2C0; - /* 0x02C4 */ f32 unk_2C4; - /* 0x02C8 */ f32 unk_2C8; - /* 0x02CC */ f32 unk_2CC; - /* 0x02D0 */ s16 unk_2D0; - /* 0x02D2 */ s16 unk_2D2; - /* 0x02D4 */ Vec3f unk_2D4; - /* 0x02E0 */ Vec3f unk_2E0; - /* 0x02EC */ UNK_TYPE1 unk2EC[0xC]; - /* 0x02F8 */ Actor* unk_2F8; - /* 0x02FC */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[10]; + /* 0x1C4 */ Vec3s morphTable[10]; + /* 0x200 */ EnPrActionFunc actionFunc; + /* 0x204 */ u8 unk_204; + /* 0x206 */ s16 unk_206; + /* 0x208 */ s16 unk_208; + /* 0x20A */ s16 unk_20A; + /* 0x20C */ s16 unk_20C; + /* 0x20E */ s16 unk_20E; + /* 0x210 */ s16 unk_210; + /* 0x212 */ s16 unk_212; + /* 0x214 */ s16 unk_214; + /* 0x216 */ s16 unk_216; + /* 0x218 */ UNK_TYPE1 unk218[4]; + /* 0x21C */ s32 unk_21C; + /* 0x220 */ UNK_TYPE1 unk220[0x8]; + /* 0x228 */ s32 unk_228; + /* 0x22C */ s16 unk_22C; + /* 0x22E */ s16 drawDmgEffAlpha; + /* 0x230 */ s16 drawDmgEffType; + /* 0x234 */ f32 unk_234; + /* 0x238 */ f32 unk_238; + /* 0x23C */ Vec3f limbPos[10]; + /* 0x2B4 */ f32 unk_2B4; + /* 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 */ s16 unk_2D0; + /* 0x2D2 */ s16 unk_2D2; + /* 0x2D4 */ Vec3f unk_2D4; + /* 0x2E0 */ Vec3f unk_2E0; + /* 0x2EC */ UNK_TYPE1 unk2EC[0xC]; + /* 0x2F8 */ Actor* unk_2F8; + /* 0x2FC */ ColliderCylinder collider; } EnPr; // size = 0x348 extern const ActorInit En_Pr_InitVars; diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c index 76fd61744..2454639c5 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -99,7 +99,7 @@ static AnimationHeader* sAnimations[] = { &object_pr_Anim_003904, }; -u8 D_80A75C38[] = { 0, 0, 2, 0 }; +u8 D_80A75C38[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP }; s16 D_80A75C3C[] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, @@ -520,7 +520,8 @@ void func_80A751B4(EnPr2* this) { func_80A74510(this, 2); } else { this->unk_1F8 = Animation_GetLastFrame(&object_pr_Anim_003904); - Animation_Change(&this->skelAnime, &object_pr_Anim_003904, 1.0f, this->unk_1F8, this->unk_1F8, 2, 0.0f); + Animation_Change(&this->skelAnime, &object_pr_Anim_003904, 1.0f, this->unk_1F8, this->unk_1F8, ANIMMODE_ONCE, + 0.0f); this->unk_1D8 = Rand_S16Offset(20, 30); this->unk_1E4 = 0x4000; if (Rand_ZeroOne() < 0.5f) { diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h index 3721a98cc..df5afef4e 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h @@ -11,44 +11,44 @@ typedef void (*EnPr2ActionFunc)(struct EnPr2*, PlayState*); #define ENPR2_GET_FF0(thisx) (((thisx)->params >> 4) & 0xFF) typedef struct EnPr2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[5]; - /* 0x01A6 */ Vec3s morphtable[5]; - /* 0x01C4 */ EnPr2ActionFunc actionFunc; - /* 0x01C8 */ s16 unk_1C8; - /* 0x01CC */ Path* path; - /* 0x01D0 */ s32 unk_1D0; - /* 0x01D4 */ s16 unk_1D4; - /* 0x01D6 */ s16 unk_1D6; - /* 0x01D8 */ s16 unk_1D8; - /* 0x01DA */ s16 unk_1DA; - /* 0x01DC */ s16 unk_1DC; - /* 0x01DE */ s16 unk_1DE; - /* 0x01E0 */ s16 unk_1E0; - /* 0x01E2 */ UNK_TYPE1 unk1E2[2]; - /* 0x01E4 */ s16 unk_1E4; - /* 0x01E6 */ s16 unk_1E6; - /* 0x01E8 */ UNK_TYPE1 unk1E8[4]; - /* 0x01EC */ s16 unk_1EC; - /* 0x01EE */ s16 unk_1EE; - /* 0x01F0 */ s16 unk_1F0; - /* 0x01F2 */ s16 unk_1F2; - /* 0x01F4 */ s16 unk_1F4; - /* 0x01F8 */ f32 unk_1F8; - /* 0x01FC */ f32 unk_1FC; - /* 0x0200 */ f32 unk_200; - /* 0x0204 */ f32 unk_204; - /* 0x0208 */ f32 unk_208; - /* 0x020C */ f32 unk_20C; - /* 0x0210 */ s32 unk_210; - /* 0x0214 */ UNK_TYPE1 unk214[4]; - /* 0x0218 */ s32 unk_218; - /* 0x021C */ Vec3f unk_21C; - /* 0x0228 */ Vec3f unk_228; - /* 0x0234 */ Vec3f unk_234[5]; - /* 0x0270 */ Vec3f unk_270; - /* 0x027C */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[5]; + /* 0x1A6 */ Vec3s morphtable[5]; + /* 0x1C4 */ EnPr2ActionFunc actionFunc; + /* 0x1C8 */ s16 unk_1C8; + /* 0x1CC */ Path* path; + /* 0x1D0 */ s32 unk_1D0; + /* 0x1D4 */ s16 unk_1D4; + /* 0x1D6 */ s16 unk_1D6; + /* 0x1D8 */ s16 unk_1D8; + /* 0x1DA */ s16 unk_1DA; + /* 0x1DC */ s16 unk_1DC; + /* 0x1DE */ s16 unk_1DE; + /* 0x1E0 */ s16 unk_1E0; + /* 0x1E2 */ UNK_TYPE1 unk1E2[2]; + /* 0x1E4 */ s16 unk_1E4; + /* 0x1E6 */ s16 unk_1E6; + /* 0x1E8 */ UNK_TYPE1 unk1E8[4]; + /* 0x1EC */ s16 unk_1EC; + /* 0x1EE */ s16 unk_1EE; + /* 0x1F0 */ s16 unk_1F0; + /* 0x1F2 */ s16 unk_1F2; + /* 0x1F4 */ s16 unk_1F4; + /* 0x1F8 */ f32 unk_1F8; + /* 0x1FC */ f32 unk_1FC; + /* 0x200 */ f32 unk_200; + /* 0x204 */ f32 unk_204; + /* 0x208 */ f32 unk_208; + /* 0x20C */ f32 unk_20C; + /* 0x210 */ s32 unk_210; + /* 0x214 */ UNK_TYPE1 unk214[4]; + /* 0x218 */ s32 unk_218; + /* 0x21C */ Vec3f unk_21C; + /* 0x228 */ Vec3f unk_228; + /* 0x234 */ Vec3f unk_234[5]; + /* 0x270 */ Vec3f unk_270; + /* 0x27C */ ColliderCylinder collider; } EnPr2; // size = 0x2C8 extern const ActorInit En_Pr2_InitVars; diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.c b/src/overlays/actors/ovl_En_Prz/z_en_prz.c index 98593e85d..6fc5ea24a 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -96,7 +96,7 @@ const ActorInit En_Prz_InitVars = { AnimationHeader* D_80A77240[] = { &object_pr_Anim_004340, &object_pr_Anim_004274 }; -u8 D_80A77248[] = { 0, 0 }; +u8 D_80A77248[] = { ANIMMODE_LOOP, ANIMMODE_LOOP }; Vec3f D_80A7724C = { 0.0f, 0.0f, 0.0f }; diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.h b/src/overlays/actors/ovl_En_Prz/z_en_prz.h index 3d9e740d1..75087c9bc 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.h +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.h @@ -10,36 +10,36 @@ typedef void (*EnPrzActionFunc)(struct EnPrz*, PlayState*); #define ENPRZ_GET(thisx) ((thisx)->params & 0xFF) typedef struct EnPrz { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[5]; - /* 0x01A6 */ Vec3s morphTable[5]; - /* 0x01C4 */ EnPrzActionFunc actionFunc; - /* 0x01C8 */ u8 unk_1C8; - /* 0x01CC */ Vec3f unk_1CC; - /* 0x01D8 */ Vec3f unk_1D8; - /* 0x01E4 */ s16 unk_1E4; - /* 0x01E6 */ s16 unk_1E6; - /* 0x01E8 */ s16 unk_1E8; - /* 0x01EA */ s16 unk_1EA; - /* 0x01EC */ s16 unk_1EC; - /* 0x01EE */ s16 unk_1EE; - /* 0x01F0 */ UNK_TYPE1 unk1F0[2]; - /* 0x01F2 */ s16 unk_1F2; - /* 0x01F4 */ UNK_TYPE1 unk1F4[8]; - /* 0x01FC */ s16 unk_1FC; - /* 0x01FE */ s16 unk_1FE; - /* 0x0200 */ UNK_TYPE1 unk200[2]; - /* 0x0202 */ s16 unk_202; - /* 0x0204 */ s32 unk_204; - /* 0x0208 */ f32 unk_208; - /* 0x020C */ f32 unk_20C; - /* 0x0210 */ f32 unk_210; - /* 0x0214 */ f32 unk_214; - /* 0x0218 */ f32 unk_218; - /* 0x021C */ UNK_TYPE1 unk21C[4]; - /* 0x0220 */ Actor* unk_220; - /* 0x0224 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[5]; + /* 0x1A6 */ Vec3s morphTable[5]; + /* 0x1C4 */ EnPrzActionFunc actionFunc; + /* 0x1C8 */ u8 unk_1C8; + /* 0x1CC */ Vec3f unk_1CC; + /* 0x1D8 */ Vec3f unk_1D8; + /* 0x1E4 */ s16 unk_1E4; + /* 0x1E6 */ s16 unk_1E6; + /* 0x1E8 */ s16 unk_1E8; + /* 0x1EA */ s16 unk_1EA; + /* 0x1EC */ s16 unk_1EC; + /* 0x1EE */ s16 unk_1EE; + /* 0x1F0 */ UNK_TYPE1 unk1F0[2]; + /* 0x1F2 */ s16 unk_1F2; + /* 0x1F4 */ UNK_TYPE1 unk1F4[8]; + /* 0x1FC */ s16 unk_1FC; + /* 0x1FE */ s16 unk_1FE; + /* 0x200 */ UNK_TYPE1 unk200[2]; + /* 0x202 */ s16 unk_202; + /* 0x204 */ s32 unk_204; + /* 0x208 */ f32 unk_208; + /* 0x20C */ f32 unk_20C; + /* 0x210 */ f32 unk_210; + /* 0x214 */ f32 unk_214; + /* 0x218 */ f32 unk_218; + /* 0x21C */ UNK_TYPE1 unk21C[4]; + /* 0x220 */ Actor* unk_220; + /* 0x224 */ ColliderCylinder collider; } EnPrz; // size = 0x270 extern const ActorInit En_Prz_InitVars; diff --git a/src/overlays/actors/ovl_En_Pst/z_en_pst.h b/src/overlays/actors/ovl_En_Pst/z_en_pst.h index cba584667..ba60b4bf0 100644 --- a/src/overlays/actors/ovl_En_Pst/z_en_pst.h +++ b/src/overlays/actors/ovl_En_Pst/z_en_pst.h @@ -8,10 +8,10 @@ struct EnPst; typedef void (*EnPstActionFunc)(struct EnPst*, PlayState*); typedef struct EnPst { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnPstActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x94]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x44]; + /* 0x188 */ EnPstActionFunc actionFunc; + /* 0x18C */ char unk_18C[0x94]; } EnPst; // size = 0x220 extern const ActorInit En_Pst_InitVars; diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index 7b7d7a76b..529ac9f4e 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -30,11 +30,11 @@ void EnRacedog_CheckForFinish(EnRacedog* this); void EnRacedog_UpdateRunAnimationPlaySpeed(EnRacedog* this); s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* arg1); void EnRacedog_SpawnFloorDustRing(EnRacedog* this, PlayState* play); -void EnRacedog_PlayWalkSfx(EnRacedog* this); +void EnRacedog_PlaySfxWalk(EnRacedog* this); /** - * Dogs can be in three conditions, which is indicated by the message it says when - * you pick it up prior to entering the race. + * Dogs can be in three conditions, which is, for the most part, indicated by the + * message it says when you pick it up prior to entering the race. * If it starts with "Ruff!", it's in good condition. * If it starts with "Rrr-Ruff!", it's in normal condition. * If it starts with "Hoo-whine", it's in bad condition. @@ -42,30 +42,21 @@ void EnRacedog_PlayWalkSfx(EnRacedog* this); * - 0x3538 - 0x353D: Good condition * - 0x353E - 0x3541: Normal condition * - 0x3542 - 0x3546: Bad condition + * + * There are two caveats, though, that are useful to keep in mind: + * - Because of differences between how EnDg computes the text ID and how EnRacedog + * computes it, there are two dogs whose text upon picking them up does not + * accurately reflect their condition during the race. Check the comment above + * EnRacedog_UpdateTextId for more information on this phenomenon. + * - Note that text ID 0x353D is actually used for the Romani Ranch dog; its text + * just so happens to be in the middle of the race dog text block. In EnDg, the + * dog that gets this text ID will instead use text ID 0x3538 when the player + * picks it up. Since EnRacedog cannot be picked up, however, it can use 0x353D + * as an additional good condition text ID. */ #define DOG_IS_IN_GOOD_CONDITION(this) (sDogInfo[this->index].textId < 0x353E) #define DOG_IS_IN_BAD_CONDITION(this) (sDogInfo[this->index].textId >= 0x3542) -typedef enum { - /* 0 */ RACEDOG_ANIMATION_IDLE, - /* 1 */ RACEDOG_ANIMATION_WALK_1, - /* 2 */ RACEDOG_ANIMATION_RUN, - /* 3 */ RACEDOG_ANIMATION_BARK, - /* 4 */ RACEDOG_ANIMATION_SIT_DOWN_1, - /* 5 */ RACEDOG_ANIMATION_SIT_DOWN_2, - /* 6 */ RACEDOG_ANIMATION_LYING_DOWN_START_1, - /* 7 */ RACEDOG_ANIMATION_LYING_DOWN_LOOP, - /* 8 */ RACEDOG_ANIMATION_LYING_DOWN_START_2, - /* 9 */ RACEDOG_ANIMATION_LYING_DOWN_START_3, - /* 10 */ RACEDOG_ANIMATION_LYING_DOWN_START_4, - /* 11 */ RACEDOG_ANIMATION_WALK_2, - /* 12 */ RACEDOG_ANIMATION_JUMP, - /* 13 */ RACEDOG_ANIMATION_LONG_JUMP, - /* 14 */ RACEDOG_ANIMATION_JUMP_2, - /* 15 */ RACEDOG_ANIMATION_WALK_3, - /* 16 */ RACEDOG_ANIMATION_MAX -} RacedogAnimationIndex; - /** * Stores various information for each dog in the race, mostly related to speed. */ @@ -212,6 +203,26 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; +typedef enum { + /* 0 */ RACEDOG_ANIMATION_IDLE, + /* 1 */ RACEDOG_ANIMATION_WALK_1, // unused + /* 2 */ RACEDOG_ANIMATION_RUN, + /* 3 */ RACEDOG_ANIMATION_BARK, // unused + /* 4 */ RACEDOG_ANIMATION_SIT_DOWN_ONCE, // unused + /* 5 */ RACEDOG_ANIMATION_SIT_DOWN, // unused + /* 6 */ RACEDOG_ANIMATION_LYING_DOWN_START_1, // unused + /* 7 */ RACEDOG_ANIMATION_LYING_DOWN_LOOP, // unused + /* 8 */ RACEDOG_ANIMATION_LYING_DOWN_START_2, // unused + /* 9 */ RACEDOG_ANIMATION_LYING_DOWN_START_3, // unused + /* 10 */ RACEDOG_ANIMATION_LYING_DOWN_START_4, // unused + /* 11 */ RACEDOG_ANIMATION_WALK_BACKWARDS, // unused + /* 12 */ RACEDOG_ANIMATION_JUMP, + /* 13 */ RACEDOG_ANIMATION_LONG_JUMP, // unused + /* 14 */ RACEDOG_ANIMATION_JUMP_ATTACK, // unused + /* 15 */ RACEDOG_ANIMATION_SWIM, // unused + /* 16 */ RACEDOG_ANIMATION_MAX +} RacedogAnimationIndex; + static AnimationInfoS sAnimations[] = { { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, { &gDogRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogBarkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, @@ -220,7 +231,7 @@ static AnimationInfoS sAnimations[] = { { &gDogLyingDownAnim, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, { &gDogWalkAnim, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, { &gDogJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogLongJumpAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, - { &gDogJump2Anim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDogJumpAttackAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, }; static InitChainEntry sInitChain[] = { @@ -255,27 +266,27 @@ void EnRacedog_UpdateCollision(EnRacedog* this, PlayState* play) { */ s16 EnRacedog_GetYRotation(Path* path, s32 pointIndex, Vec3f* pos, f32* distSQ) { Vec3s* point; - f32 xDiffRand; - f32 zDiffRand; - f32 xDiff; - f32 zDiff; + f32 diffXRand; + f32 diffZRand; + f32 diffX; + f32 diffZ; if (path != NULL) { point = Lib_SegmentedToVirtual(path->points); point = &point[pointIndex]; - xDiffRand = (randPlusMinusPoint5Scaled(100.0f) + point->x) - pos->x; - zDiffRand = (randPlusMinusPoint5Scaled(100.0f) + point->z) - pos->z; - xDiff = point->x - pos->x; - zDiff = point->z - pos->z; + diffXRand = (randPlusMinusPoint5Scaled(100.0f) + point->x) - pos->x; + diffZRand = (randPlusMinusPoint5Scaled(100.0f) + point->z) - pos->z; + diffX = point->x - pos->x; + diffZ = point->z - pos->z; } else { - xDiffRand = 0.0f; - zDiffRand = 0.0f; - xDiff = 0.0f; - zDiff = 0.0f; + diffXRand = 0.0f; + diffZRand = 0.0f; + diffX = 0.0f; + diffZ = 0.0f; } - *distSQ = SQ(xDiff) + SQ(zDiff); - return RADF_TO_BINANG(Math_Acot2F(zDiffRand, xDiffRand)); + *distSQ = SQ(diffX) + SQ(diffZ); + return RADF_TO_BINANG(Math_Acot2F(diffZRand, diffXRand)); } void EnRacedog_GetFloorRot(EnRacedog* this, Vec3f* floorRot) { @@ -409,7 +420,7 @@ void EnRacedog_Race(EnRacedog* this, PlayState* play) { } EnRacedog_UpdateRunAnimationPlaySpeed(this); - EnRacedog_PlayWalkSfx(this); + EnRacedog_PlaySfxWalk(this); EnRacedog_SpawnFloorDustRing(this, play); } @@ -417,18 +428,26 @@ void EnRacedog_Race(EnRacedog* this, PlayState* play) { * Updates the text ID in sDogInfo based on what was set in the weekEventRegs by * En_Aob_01. This makes it so sDogInfo can be used in other functions to determine * the condition of the dog. + * + * Note that the text IDs generated by this function are off-by-one compared to the + * similar function in EnDg. The end result of this is that one of the dogs that says + * it's in good condition when you pick it up is actually in normal condition once the + * race starts, and one of the dogs that says it's in normal condition when you pick + * it up is actually in bad condition. It's unknown whether this is a simple oversight + * or an intentional choice to introduce a bit of extra variance to the race. */ void EnRacedog_UpdateTextId(EnRacedog* this) { + // Assuming that the weekEventRegs haven't been tampered with, then this will produce a text ID in the + // range of 0x3539 to 0x3546. if (this->index % 2) { sDogInfo[this->index].textId = - (((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & (0x10 | 0x20 | 0x40 | 0x80)) >> 4) + 0x3539; + (((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & 0xF0) >> 4) + 0x3539; } else { - sDogInfo[this->index].textId = - ((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & (1 | 2 | 4 | 8)) + 0x3539; + sDogInfo[this->index].textId = ((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & 0x0F) + 0x3539; } - // This makes sure the text ID is something in the range of 0x3539 to 0x3547. - if ((sDogInfo[this->index].textId >= 0x3547) || (sDogInfo[this->index].textId < 0x3539)) { + // As a sanity check, this makes sure the text ID is something in the expected range of 0x3539 to 0x3546. + if ((sDogInfo[this->index].textId > 0x3546) || (sDogInfo[this->index].textId < 0x3539)) { sDogInfo[this->index].textId = 0x353E; } @@ -650,7 +669,7 @@ void EnRacedog_SpawnFloorDustRing(EnRacedog* this, PlayState* play) { } } -void EnRacedog_PlayWalkSfx(EnRacedog* this) { +void EnRacedog_PlaySfxWalk(EnRacedog* this) { s16 curFrame = this->skelAnime.curFrame; if ((curFrame == 1) || (curFrame == 7)) { 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 6365bac8b..1c8756148 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,8 +4,8 @@ * Description: Ikana Graveyard - Circle of Stalchildren */ -#include "overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h" #include "z_en_rail_skb.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_skb/object_skb.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) @@ -112,7 +112,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -513,26 +513,26 @@ void func_80B717E0(EnRailSkb* this, PlayState* play) { this->unk_3FA = 0; switch (Message_GetState(&play->msgCtx)) { - case 0: - case 1: - case 2: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: break; - case 3: + case TEXT_STATE_3: if ((play->gameplayFrames % 2) != 0) { this->unk_3FA = 1; } break; - case 4: + case TEXT_STATE_CHOICE: func_80B72100(this, play); break; - case 5: + case TEXT_STATE_5: func_80B71F3C(this, play); break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { func_80B71650(this); } @@ -848,7 +848,7 @@ void func_80B72430(EnRailSkb* this, PlayState* play, s32 arg2) { sp50.y += Rand_Centered() * 4.0f; - EffectSsHahen_Spawn(play, &sp5C, &sp50, &sp44, 0, (Rand_Next() & 7) + 10, -1, 10, NULL); + EffectSsHahen_Spawn(play, &sp5C, &sp50, &sp44, 0, (Rand_Next() & 7) + 10, HAHEN_OBJECT_DEFAULT, 10, NULL); func_800BBFB0(play, &sp5C, 10.0f, 1, 150, 0, 1); } } @@ -1035,8 +1035,10 @@ void func_80B72970(EnRailSkb* this, PlayState* play) { this->unk_402 |= 1; case 15: - if ((player->swordAnimation == 4) || (player->swordAnimation == 11) || (player->swordAnimation == 22) || - (player->swordAnimation == 23)) { + if ((player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_LEFT_COMBO_2H) || + (player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_RIGHT) || + (player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_LEFT)) { this->unk_402 |= 1; } 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 db170806c..09d3b4c4c 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 @@ -2,6 +2,7 @@ #define Z_EN_RAIL_SKB_H #include "global.h" +#include "overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h" struct EnRailSkb; 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 b634d3e0f..1a197d6b5 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -6,7 +6,7 @@ #include "z_en_railgibud.h" #include "z64rumble.h" -#include "objects/object_rd/object_rd.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) @@ -674,7 +674,7 @@ void EnRailgibud_SpawnEffectsForSinkingIntoTheGround(EnRailgibud* this, PlayStat rockFragmentAccel.z = Rand_Centered(); rockFragmentVelocity.y += Rand_Centered() * 4.0f; EffectSsHahen_Spawn(play, &rockFragmentPos, &rockFragmentVelocity, &rockFragmentAccel, 0, - (Rand_Next() & 7) + 10, -1, 10, NULL); + (Rand_Next() & 7) + 10, HAHEN_OBJECT_DEFAULT, 10, NULL); EnRailgibud_SpawnDust(play, &rockFragmentPos, 10.0f, 10, 150, 0); } } @@ -968,14 +968,14 @@ void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, PlayState* play) { } } else { switch (Message_GetState(&play->msgCtx)) { - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { Message_StartTextbox(play, 0x13B3, &this->actor); this->textId = 0x13B3; } break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { this->textId = 0; this->isInvincible = false; @@ -983,11 +983,11 @@ void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, PlayState* play) { } break; - case 0: - case 1: - case 2: - case 3: - case 4: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: break; } } @@ -1112,6 +1112,7 @@ void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, PlayState* play) { Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + if (gSaveContext.save.entranceIndex != 0x2090) { // NOT Cutscene: Music Box House Opens Actor_MarkForDeath(&this->actor); } 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 9ff585d6b..65e8e9736 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h @@ -13,29 +13,29 @@ typedef void (*EnRailgibudActionFunc)(struct EnRailgibud*, PlayState*); #define ENRAILGIBUD_GET_PATH(thisx) (((thisx)->params & 0xFF00) >> 8) typedef struct EnRailgibud { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnRailgibudActionFunc actionFunc; - /* 0x01D8 */ Vec3f limbPos[15]; - /* 0x028C */ s32 limbIndex; - /* 0x0290 */ UNK_TYPE1 unk290[0x4]; - /* 0x0294 */ Vec3s* points; - /* 0x0298 */ s32 currentPoint; - /* 0x029C */ s32 pathCount; - /* 0x02A0 */ f32 drawDmgEffAlpha; - /* 0x02A4 */ f32 drawDmgEffScale; - /* 0x02A8 */ Vec3s jointTable[GIBDO_LIMB_MAX]; - /* 0x0344 */ Vec3s morphTable[GIBDO_LIMB_MAX]; - /* 0x03E0 */ Vec3s headRotation; - /* 0x03E6 */ Vec3s upperBodyRotation; - /* 0x03EC */ s16 shouldWalkForward; // Only used by the "main" Gibdo - /* 0x03EE */ s16 shouldWalkForwardNextFrame; // Only used by the "main" Gibdo - /* 0x03F0 */ union { + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnRailgibudActionFunc actionFunc; + /* 0x1D8 */ Vec3f limbPos[15]; + /* 0x28C */ s32 limbIndex; + /* 0x290 */ UNK_TYPE1 unk290[0x4]; + /* 0x294 */ Vec3s* points; + /* 0x298 */ s32 currentPoint; + /* 0x29C */ s32 pathCount; + /* 0x2A0 */ f32 drawDmgEffAlpha; + /* 0x2A4 */ f32 drawDmgEffScale; + /* 0x2A8 */ Vec3s jointTable[GIBDO_LIMB_MAX]; + /* 0x344 */ Vec3s morphTable[GIBDO_LIMB_MAX]; + /* 0x3E0 */ Vec3s headRotation; + /* 0x3E6 */ Vec3s upperBodyRotation; + /* 0x3EC */ s16 shouldWalkForward; // Only used by the "main" Gibdo + /* 0x3EE */ s16 shouldWalkForwardNextFrame; // Only used by the "main" Gibdo + /* 0x3F0 */ union { s16 grabState; s16 cutsceneAnimationIndex; }; - /* 0x03F2 */ union { + /* 0x3F2 */ union { s16 playerStunWaitTimer; // Cannot stun the player if this is non-zero s16 grabDamageTimer; s16 headShakeTimer; @@ -43,16 +43,16 @@ typedef struct EnRailgibud { s16 deathTimer; s16 sinkTimer; }; - /* 0x03F4 */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero - /* 0x03F6 */ s16 drawDmgEffTimer; - /* 0x03F8 */ s16 type; - /* 0x03FA */ s16 isInvincible; - /* 0x03FC */ u16 actorActionCommand; - /* 0x03FE */ u16 csAction; - /* 0x0400 */ u16 textId; - /* 0x0402 */ s16 timeInitialized; // unused other than setting it - /* 0x0404 */ u8 drawDmgEffType; - /* 0x0405 */ s8 unk_405; // related to player->unk_ADD + /* 0x3F4 */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x3F6 */ s16 drawDmgEffTimer; + /* 0x3F8 */ s16 type; + /* 0x3FA */ s16 isInvincible; + /* 0x3FC */ u16 actorActionCommand; + /* 0x3FE */ u16 csAction; + /* 0x400 */ u16 textId; + /* 0x402 */ s16 timeInitialized; // unused other than setting it + /* 0x404 */ u8 drawDmgEffType; + /* 0x405 */ s8 unk_405; // related to player->unk_ADD } EnRailgibud; // size = 0x408 extern const ActorInit En_Railgibud_InitVars; diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index f7ec893ed..1f4c10281 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -440,7 +440,7 @@ void EnRd_SquattingDance(EnRd* this, PlayState* play) { } else { this->actor.hintId = 0x2A; } - Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, ANIMMODE_ONCE, -10.0f); this->actionFunc = EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose; } @@ -484,7 +484,7 @@ void EnRd_ClappingDance(EnRd* this, PlayState* play) { } else { this->actor.hintId = 0x2A; } - Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, ANIMMODE_ONCE, -10.0f); this->actionFunc = EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose; } @@ -582,7 +582,7 @@ void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, PlayState* play) { this->pirouetteRotationalVelocity -= 0x64; if ((this->pirouetteRotationalVelocity < 0x834) && (this->pirouetteRotationalVelocity >= 0x7D0)) { - Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, ANIMMODE_ONCE, -10.0f); } else if (this->pirouetteRotationalVelocity < 0x3E8) { if ((EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) && (!this->isMourning)) { EnRd_SetupAttemptPlayerFreeze(this); @@ -594,7 +594,7 @@ void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, PlayState* play) { void EnRd_SetupRiseFromCoffin(EnRd* this) { Animation_Change(&this->skelAnime, &gGibdoRedeadIdleAnim, 0.0f, 0.0f, Animation_GetLastFrame(&gGibdoRedeadIdleAnim), - 0, -6.0f); + ANIMMODE_LOOP, -6.0f); this->action = EN_RD_ACTION_RISING_FROM_COFFIN; this->coffinRiseForwardAccelTimer = 6; this->actor.shape.rot.x = -0x4000; @@ -630,7 +630,7 @@ void EnRd_RiseFromCoffin(EnRd* this, PlayState* play) { void EnRd_SetupWalkToPlayer(EnRd* this, PlayState* play) { f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 1.0f, 4.0f, frameCount, 1, -4.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 1.0f, 4.0f, frameCount, ANIMMODE_LOOP_INTERP, -4.0f); this->actor.speedXZ = 0.4f; this->action = EN_RD_ACTION_WALKING_TO_PLAYER_OR_RELEASING_GRAB; this->actionFunc = EnRd_WalkToPlayer; @@ -707,7 +707,7 @@ void EnRd_WalkToPlayer(EnRd* this, PlayState* play) { void EnRd_SetupWalkToHome(EnRd* this, PlayState* play) { Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, Animation_GetLastFrame(&gGibdoRedeadWalkAnim), - 1, -4.0f); + ANIMMODE_LOOP_INTERP, -4.0f); this->action = EN_RD_ACTION_WALKING_TO_HOME; this->actionFunc = EnRd_WalkToHome; } @@ -759,7 +759,7 @@ void EnRd_WalkToHome(EnRd* this, PlayState* play) { void EnRd_SetupWalkToParent(EnRd* this) { f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, frameCount, 1, -4.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, frameCount, ANIMMODE_LOOP_INTERP, -4.0f); this->action = EN_RD_ACTION_WALKING_TO_PARENT; this->isMourning = true; this->actionFunc = EnRd_WalkToParent; @@ -844,7 +844,7 @@ void EnRd_Grab(EnRd* this, PlayState* play) { player->unk_AE8 = 100; } Animation_Change(&this->skelAnime, &gGibdoRedeadGrabEndAnim, 0.5f, 0.0f, - Animation_GetLastFrame(&gGibdoRedeadGrabEndAnim), 3, 0.0f); + Animation_GetLastFrame(&gGibdoRedeadGrabEndAnim), ANIMMODE_ONCE_INTERP, 0.0f); this->grabState++; this->action = EN_RD_ACTION_WALKING_TO_PLAYER_OR_RELEASING_GRAB; break; @@ -905,7 +905,7 @@ void EnRd_Grab(EnRd* this, PlayState* play) { void EnRd_SetupAttemptPlayerFreeze(EnRd* this) { Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, - Animation_GetLastFrame(&gGibdoRedeadLookBackAnim), 2, 0.0f); + Animation_GetLastFrame(&gGibdoRedeadLookBackAnim), ANIMMODE_ONCE, 0.0f); this->action = EN_RD_ACTION_ATTEMPTING_PLAYER_STUN; this->actionFunc = EnRd_AttemptPlayerFreeze; } @@ -952,7 +952,7 @@ void EnRd_GrabFail(EnRd* this, PlayState* play) { void EnRd_SetupTurnAwayAndShakeHead(EnRd* this) { f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, frameCount, 1, -4.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, frameCount, ANIMMODE_LOOP_INTERP, -4.0f); this->action = EN_RD_ACTION_TURNING_AWAY_AND_SHAKING_HEAD; this->headShakeTimer = 0; this->actionFunc = EnRd_TurnAwayAndShakeHead; @@ -989,7 +989,7 @@ void EnRd_StandUp(EnRd* this, PlayState* play) { void EnRd_SetupCrouch(EnRd* this) { Animation_Change(&this->skelAnime, &gGibdoRedeadStandUpAnim, -1.0f, - Animation_GetLastFrame(&gGibdoRedeadStandUpAnim), 0.0f, 2, -4.0f); + Animation_GetLastFrame(&gGibdoRedeadStandUpAnim), 0.0f, ANIMMODE_ONCE, -4.0f); this->action = EN_RD_ACTION_CROUCHING; this->actionFunc = EnRd_Crouch; } diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.h b/src/overlays/actors/ovl_En_Rd/z_en_rd.h index 94076046a..0affac4f1 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.h +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.h @@ -31,45 +31,45 @@ typedef enum { } EnRdType; typedef struct EnRd { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnRdActionFunc actionFunc; - /* 0x018C */ EnRdSetupDanceFunc setupDanceFunc; - /* 0x0190 */ ColliderCylinder collider; - /* 0x01DC */ Vec3f limbPos[15]; - /* 0x0290 */ s32 limbIndex; - /* 0x0294 */ f32 drawDmgEffAlpha; - /* 0x0298 */ f32 drawDmgEffScale; - /* 0x029C */ Vec3s jointTable[REDEAD_LIMB_MAX]; - /* 0x0338 */ Vec3s morphTable[REDEAD_LIMB_MAX]; - /* 0x03D4 */ s16 headShakeTimer; - /* 0x03D6 */ union { + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnRdActionFunc actionFunc; + /* 0x18C */ EnRdSetupDanceFunc setupDanceFunc; + /* 0x190 */ ColliderCylinder collider; + /* 0x1DC */ Vec3f limbPos[15]; + /* 0x290 */ s32 limbIndex; + /* 0x294 */ f32 drawDmgEffAlpha; + /* 0x298 */ f32 drawDmgEffScale; + /* 0x29C */ Vec3s jointTable[REDEAD_LIMB_MAX]; + /* 0x338 */ Vec3s morphTable[REDEAD_LIMB_MAX]; + /* 0x3D4 */ s16 headShakeTimer; + /* 0x3D6 */ union { s16 animationJudderTimer; s16 stunTimer; s16 deathTimer; s16 coffinRiseForwardAccelTimer; }; - /* 0x03D8 */ s16 headYRotation; - /* 0x03DA */ s16 upperBodyYRotation; - /* 0x03DC */ s16 flags; - /* 0x03DE */ s16 alpha; - /* 0x03E0 */ s16 sunsSongStunTimer; - /* 0x03E2 */ UNK_TYPE1 unk3E2[0x2]; - /* 0x03E4 */ union { + /* 0x3D8 */ s16 headYRotation; + /* 0x3DA */ s16 upperBodyYRotation; + /* 0x3DC */ s16 flags; + /* 0x3DE */ s16 alpha; + /* 0x3E0 */ s16 sunsSongStunTimer; + /* 0x3E2 */ UNK_TYPE1 unk3E2[0x2]; + /* 0x3E4 */ union { s16 danceEndTimer; s16 pirouetteRotationalVelocity; }; - /* 0x03E6 */ s16 drawDmgEffTimer; - /* 0x03E8 */ u8 drawDmgEffType; - /* 0x03E9 */ u8 stunnedBySunsSong; - /* 0x03EA */ u8 grabDamageTimer; - /* 0x03EB */ u8 grabState; - /* 0x03EC */ u8 isMourning; - /* 0x03ED */ u8 playerStunWaitTimer; // Cannot stun the player if this is non-zero - /* 0x03EE */ u8 grabWaitTimer; // Cannot grab the player if this is non-zero - /* 0x03EF */ u8 action; - /* 0x03F0 */ u8 damageEffect; - /* 0x03F1 */ s8 unk_3F1; // related to player->unk_ADD + /* 0x3E6 */ s16 drawDmgEffTimer; + /* 0x3E8 */ u8 drawDmgEffType; + /* 0x3E9 */ u8 stunnedBySunsSong; + /* 0x3EA */ u8 grabDamageTimer; + /* 0x3EB */ u8 grabState; + /* 0x3EC */ u8 isMourning; + /* 0x3ED */ u8 playerStunWaitTimer; // Cannot stun the player if this is non-zero + /* 0x3EE */ u8 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x3EF */ u8 action; + /* 0x3F0 */ u8 damageEffect; + /* 0x3F1 */ s8 unk_3F1; // related to player->unk_ADD } EnRd; // size = 0x3F4 extern const ActorInit En_Rd_InitVars; diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 8e2f06ff4..d817d1df4 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -41,7 +41,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 1000, ICHAIN_STOP), }; -static s32 texturesDesegmented = false; +static s32 sTexturesDesegmented = false; void EnRecepgirl_Init(Actor* thisx, PlayState* play) { EnRecepgirl* this = THIS; @@ -52,11 +52,11 @@ void EnRecepgirl_Init(Actor* thisx, PlayState* play) { SkelAnime_InitFlex(play, &this->skelAnime, &object_bg_Skel_011B60, &object_bg_Anim_009890, this->jointTable, this->morphTable, 24); - if (!texturesDesegmented) { + if (!sTexturesDesegmented) { for (i = 0; i < ARRAY_COUNT(sEyeTextures); i++) { sEyeTextures[i] = Lib_SegmentedToVirtual(sEyeTextures[i]); } - texturesDesegmented = true; + sTexturesDesegmented = true; } this->eyeTexIndex = 2; @@ -141,10 +141,10 @@ void EnRecepgirl_Talk(EnRecepgirl* this, PlayState* play) { } talkState = Message_GetState(&play->msgCtx); - if (talkState == 2) { + if (talkState == TEXT_STATE_CLOSING) { this->actor.textId = 0x2ADC; // hear directions again? EnRecepgirl_SetupWait(this); - } else if ((talkState == 5) && Message_ShouldAdvance(play)) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(play, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.h b/src/overlays/actors/ovl_En_Rg/z_en_rg.h index f3a7bd54d..fe0a000b6 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.h +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.h @@ -22,34 +22,34 @@ typedef struct { } EnRgStruct; // size = 0x3C typedef struct EnRg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnRgActionFunc actionFunc; - /* 0x018C */ Actor* unk_18C; - /* 0x0190 */ ColliderCylinder collider1; - /* 0x01DC */ ColliderSphere collider2; - /* 0x0234 */ Path* path; - /* 0x0238 */ Vec3s jointTable[18]; - /* 0x02A4 */ Vec3s morphTable[18]; - /* 0x0310 */ u16 unk_310; - /* 0x0314 */ f32 unk_314; - /* 0x0318 */ s16 unk_318; - /* 0x031A */ UNK_TYPE1 unk31A[2]; - /* 0x031C */ s16 unk_31C; - /* 0x031E */ s16 unk_31E; - /* 0x0320 */ s16 unk_320; - /* 0x0322 */ s16 unk_322; - /* 0x0324 */ s16 unk_324; - /* 0x0326 */ s16 unk_326; - /* 0x0328 */ s16 unk_328[3]; - /* 0x032E */ s16 unk_32E[3]; - /* 0x0334 */ s32 unk_334; - /* 0x0338 */ UNK_TYPE1 unk338[4]; - /* 0x033C */ s32 unk_33C; - /* 0x0340 */ s32 unk_340; - /* 0x0344 */ s32 unk_344; - /* 0x0348 */ s32 numCheckpointsAheadOfPlayer; - /* 0x034C */ EnRgStruct unk_34C[32]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnRgActionFunc actionFunc; + /* 0x18C */ Actor* unk_18C; + /* 0x190 */ ColliderCylinder collider1; + /* 0x1DC */ ColliderSphere collider2; + /* 0x234 */ Path* path; + /* 0x238 */ Vec3s jointTable[18]; + /* 0x2A4 */ Vec3s morphTable[18]; + /* 0x310 */ u16 unk_310; + /* 0x314 */ f32 unk_314; + /* 0x318 */ s16 unk_318; + /* 0x31A */ UNK_TYPE1 unk31A[2]; + /* 0x31C */ s16 unk_31C; + /* 0x31E */ s16 unk_31E; + /* 0x320 */ s16 unk_320; + /* 0x322 */ s16 unk_322; + /* 0x324 */ s16 unk_324; + /* 0x326 */ s16 unk_326; + /* 0x328 */ s16 unk_328[3]; + /* 0x32E */ s16 unk_32E[3]; + /* 0x334 */ s32 unk_334; + /* 0x338 */ UNK_TYPE1 unk338[4]; + /* 0x33C */ s32 unk_33C; + /* 0x340 */ s32 unk_340; + /* 0x344 */ s32 unk_344; + /* 0x348 */ s32 numCheckpointsAheadOfPlayer; + /* 0x34C */ EnRgStruct unk_34C[32]; } EnRg; // size = 0xACC extern const ActorInit En_Rg_InitVars; diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index 51ea07366..8fc202ddd 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -306,14 +306,14 @@ void func_808FA4F4(EnRr* this, PlayState* play) { this->unk_20C = 0x800; if (((this->unk_1E2 == 0) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) && - (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) == 1)) { + (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) == EQUIP_VALUE_SHIELD_HERO)) { sp34 = true; - this->unk_1E2 = Inventory_DeleteEquipment(play, 1); + this->unk_1E2 = Inventory_DeleteEquipment(play, EQUIP_VALUE_SHIELD_HERO); } else { sp34 = false; } - if (sp34 && (Message_GetState(&play->msgCtx) == 0)) { + if (sp34 && (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { Message_StartTextbox(play, 0xF6, NULL); } diff --git a/src/overlays/actors/ovl_En_Ru/z_en_ru.h b/src/overlays/actors/ovl_En_Ru/z_en_ru.h index 319c6a1bc..29c903aff 100644 --- a/src/overlays/actors/ovl_En_Ru/z_en_ru.h +++ b/src/overlays/actors/ovl_En_Ru/z_en_ru.h @@ -8,9 +8,9 @@ struct EnRu; typedef void (*EnRuActionFunc)(struct EnRu*, PlayState*); typedef struct EnRu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnRuActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x30C]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnRuActionFunc actionFunc; + /* 0x148 */ char unk_148[0x30C]; } EnRu; // size = 0x454 extern const ActorInit En_Ru_InitVars; 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 9a49375f9..421f2f3c0 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -75,7 +75,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -440,7 +440,7 @@ void EnRuppecrow_HandleDeath(EnRuppecrow* this) { this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, 0x1, -3.0f); + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); this->actor.shape.yOffset = 0.0f; this->actor.targetArrowOffset = 0.0f; @@ -543,7 +543,7 @@ void EnRuppecrow_FlyWhileDroppingRupees(EnRuppecrow* this, PlayState* play) { // 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 + //! @bug: Source of the "Termina Field Guay Glitch"; guay will no longer fall if killed after this point this->actor.gravity = 0.0f; Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); diff --git a/src/overlays/actors/ovl_En_Rz/z_en_rz.h b/src/overlays/actors/ovl_En_Rz/z_en_rz.h index c65985904..5106d1413 100644 --- a/src/overlays/actors/ovl_En_Rz/z_en_rz.h +++ b/src/overlays/actors/ovl_En_Rz/z_en_rz.h @@ -8,9 +8,9 @@ struct EnRz; typedef void (*EnRzActionFunc)(struct EnRz*, PlayState*); typedef struct EnRz { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x2EC]; - /* 0x0430 */ EnRzActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x2EC]; + /* 0x430 */ EnRzActionFunc actionFunc; } EnRz; // size = 0x434 extern const ActorInit En_Rz_InitVars; diff --git a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h index cd9d8e0c9..7d8e7627f 100644 --- a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h +++ b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h @@ -10,10 +10,10 @@ struct EnSGoro; typedef void (*EnSGoroActionFunc)(struct EnSGoro*, PlayState*); typedef struct EnSGoro { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x48]; - /* 0x018C */ EnSGoroActionFunc actionFunc; - /* 0x0190 */ char unk_190[0x180]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x48]; + /* 0x18C */ EnSGoroActionFunc actionFunc; + /* 0x190 */ char unk_190[0x180]; } EnSGoro; // size = 0x310 extern const ActorInit En_S_Goro_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 4c7fe5d0d..acd645d63 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -145,14 +145,14 @@ void EnSb_SpawnBubbles(PlayState* play, EnSb* this) { void EnSb_SetupWaitClosed(EnSb* this) { Animation_Change(&this->skelAnime, &object_sb_Anim_00004C, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_00004C), - 2, 0.0f); + ANIMMODE_ONCE, 0.0f); this->state = SHELLBLADE_WAIT_CLOSED; this->actionFunc = EnSb_Idle; } void EnSb_SetupOpen(EnSb* this) { Animation_Change(&this->skelAnime, &object_sb_Anim_000194, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_000194), - 2, 0.0f); + ANIMMODE_ONCE, 0.0f); this->state = SHELLBLADE_OPEN; this->actionFunc = EnSb_Open; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); @@ -160,7 +160,7 @@ void EnSb_SetupOpen(EnSb* this) { void EnSb_SetupWaitOpen(EnSb* this) { Animation_Change(&this->skelAnime, &object_sb_Anim_002C8C, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_002C8C), - 0, 0.0f); + ANIMMODE_LOOP, 0.0f); this->state = SHELLBLADE_WAIT_OPEN; this->actionFunc = EnSb_WaitOpen; } @@ -169,7 +169,7 @@ void EnSb_SetupLunge(EnSb* this) { f32 frameCount = Animation_GetLastFrame(&object_sb_Anim_000124); f32 playbackSpeed = this->actor.depthInWater > 0.0f ? 1.0f : 0.0f; - Animation_Change(&this->skelAnime, &object_sb_Anim_000124, playbackSpeed, 0.0f, frameCount, 2, 0); + Animation_Change(&this->skelAnime, &object_sb_Anim_000124, playbackSpeed, 0.0f, frameCount, ANIMMODE_ONCE, 0); this->state = SHELLBLADE_LUNGE; this->actionFunc = EnSb_Lunge; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); @@ -177,7 +177,7 @@ void EnSb_SetupLunge(EnSb* this) { void EnSb_SetupBounce(EnSb* this) { Animation_Change(&this->skelAnime, &object_sb_Anim_0000B4, 1.0f, 0, Animation_GetLastFrame(&object_sb_Anim_0000B4), - 2, 0.0f); + ANIMMODE_ONCE, 0.0f); this->state = SHELLBLADE_BOUNCE; this->actionFunc = EnSb_Bounce; } @@ -186,7 +186,7 @@ void EnSb_SetupIdle(EnSb* this, s32 changeSpeed) { f32 frameCount = Animation_GetLastFrame(&object_sb_Anim_00004C); if (this->state != SHELLBLADE_WAIT_CLOSED) { - Animation_Change(&this->skelAnime, &object_sb_Anim_00004C, 1.0f, 0, frameCount, 2, 0.0f); + Animation_Change(&this->skelAnime, &object_sb_Anim_00004C, 1.0f, 0, frameCount, ANIMMODE_ONCE, 0.0f); } this->state = SHELLBLADE_WAIT_CLOSED; if (changeSpeed) { @@ -390,7 +390,7 @@ void EnSb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, s8 phi_a2; EnSb* this = THIS; - if (this->isDrawn != false) { + if (this->isDrawn) { if (limbIndex < 7) { phi_a2 = (this->actor.depthInWater > 0) ? 4 : 1; Actor_SpawnBodyParts(thisx, play, phi_a2, dList); diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.h b/src/overlays/actors/ovl_En_Sb/z_en_sb.h index df9bd6801..f2b3e68e8 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.h +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.h @@ -8,11 +8,11 @@ struct EnSb; typedef void (*EnSbActionFunc)(struct EnSb*, PlayState*); typedef enum { - /* 0x00 */ SHELLBLADE_OPEN, - /* 0x01 */ SHELLBLADE_WAIT_CLOSED, - /* 0x02 */ SHELLBLADE_WAIT_OPEN, - /* 0x03 */ SHELLBLADE_LUNGE, - /* 0x04 */ SHELLBLADE_BOUNCE + /* 0x0 */ SHELLBLADE_OPEN, + /* 0x1 */ SHELLBLADE_WAIT_CLOSED, + /* 0x2 */ SHELLBLADE_WAIT_OPEN, + /* 0x3 */ SHELLBLADE_LUNGE, + /* 0x4 */ SHELLBLADE_BOUNCE } ShellbladeState; typedef struct EnSb { diff --git a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c index 11b9095c6..5aa54307a 100644 --- a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c +++ b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c @@ -117,7 +117,7 @@ void func_80BD6A8C(EnScRuppe* this, PlayState* play) { this->ruppeDisplayTime = 0; this->actor.gravity = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_GET_RUPY); - func_801159EC(sRupeeInfo[this->ruppeIndex].amount); + Rupees_ChangeBy(sRupeeInfo[this->ruppeIndex].amount); this->actionFunc = func_80BD6B18; } this->actor.shape.rot.y += 0x1F4; diff --git a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h index c48d628be..80d7ed20e 100644 --- a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h +++ b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h @@ -10,9 +10,9 @@ struct EnScRuppe; typedef void (*EnScRuppeActionFunc)(struct EnScRuppe*, PlayState*); typedef struct EnScRuppe { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ EnScRuppeActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ EnScRuppeActionFunc actionFunc; /* 0x194 */ s16 ruppeDisplayTime; /* 0x196 */ s16 ruppeIndex; } EnScRuppe; // size = 0x198 diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index 4c119e341..2954bc041 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -121,7 +121,7 @@ void func_80BCAC40(EnScopenuts* this, PlayState* play) { sp54.x = Rand_Centered() * 10.0f; sp54.y = 2.0f * Rand_Centered(); sp54.z = Rand_Centered() * 10.0f; - EffectSsHahen_Spawn(play, &sp60, &sp54, &D_80BCCCE4, 0, 0x96, 1, 0x10, D_80BCCCDC[i & 1]); + EffectSsHahen_Spawn(play, &sp60, &sp54, &D_80BCCCE4, 0, 150, GAMEPLAY_KEEP, 16, D_80BCCCDC[i & 1]); } } @@ -312,14 +312,14 @@ void func_80BCB52C(EnScopenuts* this, PlayState* play) { } void func_80BCB6D0(EnScopenuts* this, PlayState* play) { - u8 temp_v0 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 5) { + if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { if (this->unk_328 & 1) { this->unk_328 &= ~1; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_328 &= ~4; this->unk_348 = 8; @@ -330,7 +330,7 @@ void func_80BCB6D0(EnScopenuts* this, PlayState* play) { Message_StartTextbox(play, this->unk_33C, &this->actor); } } - } else if (temp_v0 == 4) { + } else if (talkState == TEXT_STATE_CHOICE) { if (Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: @@ -342,8 +342,8 @@ void func_80BCB6D0(EnScopenuts* this, PlayState* play) { } else { func_8019F208(); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; - func_801159EC(this->unk_358 * -1); + play->msgCtx.stateTimer = 4; + Rupees_ChangeBy(-this->unk_358); this->actionFunc = func_80BCB90C; } break; @@ -359,7 +359,7 @@ void func_80BCB6D0(EnScopenuts* this, PlayState* play) { break; } } - } else if (temp_v0 == 6) { + } else if (talkState == TEXT_STATE_DONE) { func_800B85E0(&this->actor, play, 400.0f, -1); this->actionFunc = func_80BCB980; } diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.h b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.h index c3f66a6ce..3f6f43544 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.h +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.h @@ -14,37 +14,37 @@ typedef void (*EnScopenutsActionFunc)(struct EnScopenuts*, PlayState*); #define ENSCOPENUTS_3E0_1 1 typedef struct EnScopenuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[28]; - /* 0x0230 */ Vec3s morphTable[28]; - /* 0x02D8 */ EnScopenutsActionFunc actionFunc; - /* 0x02DC */ ColliderCylinder collider; - /* 0x0328 */ u16 unk_328; - /* 0x032C */ f32 unk_32C; - /* 0x0330 */ Path* path; - /* 0x0334 */ s32 unk_334; - /* 0x0338 */ s16 unk_338; - /* 0x033A */ UNK_TYPE1 unk33A[2]; - /* 0x033C */ u16 unk_33C; - /* 0x033E */ s16 unk_33E; - /* 0x0340 */ s16 unk_340; - /* 0x0342 */ UNK_TYPE1 unk342[0x6]; - /* 0x0348 */ s32 unk_348; - /* 0x034C */ s16 unk_34C; - /* 0x034E */ s16 unk_34E; - /* 0x0350 */ f32 unk_350; - /* 0x0354 */ UNK_TYPE1 unk354[4]; - /* 0x0358 */ s16 unk_358; - /* 0x035A */ s16 unk_35A; - /* 0x035C */ f32 unk_35C; - /* 0x0360 */ f32 unk_360; - /* 0x0364 */ f32 unk_364; - /* 0x0368 */ f32 unk_368; - /* 0x036C */ s16 unk_36C; - /* 0x036E */ s16 unk_36E; - /* 0x0370 */ s16 unk_370; - /* 0x0372 */ s16 unk_372; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[28]; + /* 0x230 */ Vec3s morphTable[28]; + /* 0x2D8 */ EnScopenutsActionFunc actionFunc; + /* 0x2DC */ ColliderCylinder collider; + /* 0x328 */ u16 unk_328; + /* 0x32C */ f32 unk_32C; + /* 0x330 */ Path* path; + /* 0x334 */ s32 unk_334; + /* 0x338 */ s16 unk_338; + /* 0x33A */ UNK_TYPE1 unk33A[2]; + /* 0x33C */ u16 unk_33C; + /* 0x33E */ s16 unk_33E; + /* 0x340 */ s16 unk_340; + /* 0x342 */ UNK_TYPE1 unk342[0x6]; + /* 0x348 */ s32 unk_348; + /* 0x34C */ s16 unk_34C; + /* 0x34E */ s16 unk_34E; + /* 0x350 */ f32 unk_350; + /* 0x354 */ UNK_TYPE1 unk354[4]; + /* 0x358 */ s16 unk_358; + /* 0x35A */ s16 unk_35A; + /* 0x35C */ f32 unk_35C; + /* 0x360 */ f32 unk_360; + /* 0x364 */ f32 unk_364; + /* 0x368 */ f32 unk_368; + /* 0x36C */ s16 unk_36C; + /* 0x36E */ s16 unk_36E; + /* 0x370 */ s16 unk_370; + /* 0x372 */ s16 unk_372; } EnScopenuts; // size = 0x374 extern const ActorInit En_Scopenuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c index e33da1073..8e0ad276c 100644 --- a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c +++ b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c @@ -5,6 +5,11 @@ */ #include "z_en_sekihi.h" +#include "objects/object_sekihil/object_sekihil.h" +#include "objects/object_sekihig/object_sekihig.h" +#include "objects/object_sekihin/object_sekihin.h" +#include "objects/object_sekihiz/object_sekihiz.h" +#include "objects/object_zog/object_zog.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -13,13 +18,12 @@ void EnSekihi_Init(Actor* thisx, PlayState* play); void EnSekihi_Destroy(Actor* thisx, PlayState* play); void EnSekihi_Update(Actor* thisx, PlayState* play); +void EnSekihi_Draw(Actor* thisx, PlayState* play); void func_80A44DE8(EnSekihi* this, PlayState* play); -void func_80A44F40(EnSekihi* this, PlayState* play); void func_80A450B0(EnSekihi* this, PlayState* play); -void func_80A45130(EnSekihi* this, PlayState* play); +void EnSekihi_DoNothing(EnSekihi* this, PlayState* play); -#if 0 const ActorInit En_Sekihi_InitVars = { ACTOR_EN_SEKIHI, ACTORCAT_PROP, @@ -32,20 +36,150 @@ const ActorInit En_Sekihi_InitVars = { (ActorFunc)NULL, }; -#endif +static s16 sObjectIds[] = { OBJECT_SEKIHIL, OBJECT_SEKIHIG, OBJECT_SEKIHIN, OBJECT_SEKIHIZ, OBJECT_ZOG }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/EnSekihi_Init.s") +static Gfx* sOpaDLists[] = { + gGraveTriforceSymbolDL, gGraveGoronSymbolDL, gGraveKokiriSymbolDL, gTombSongOfSoaringDL, gMikauGraveDL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/EnSekihi_Destroy.s") +static Gfx* sXluDLists[] = { + gSunSongTriforceSymbolDL, gSunSongGoronSymbolDL, gSunSongKokiriSymbolDL, gSekihizEmptyDL, gMikauGraveDirtDL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/func_80A44DE8.s") +static u16 sTextIds[] = { 0, 0, 0, 0, 0x1018 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/func_80A44F40.s") +void EnSekihi_Init(Actor* thisx, PlayState* play) { + EnSekihi* this = THIS; + s32 params = ENSIKIHI_GET_TYPE(thisx); + s32 objectIndex; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/func_80A450B0.s") + if ((params < SEKIHI_TYPE_0 || params >= SEKIHI_TYPE_MAX) || sOpaDLists[params] == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + if ((params == SEKIHI_TYPE_4) && (((gSaveContext.save.skullTokenCount & 0xFFFF)) >= 30)) { + gSaveContext.save.weekEventReg[13] |= 0x20; + } + objectIndex = Object_GetIndex(&play->objectCtx, sObjectIds[params]); + if (objectIndex >= 0) { + this->objectIndex = objectIndex; + } + this->actionFunc = func_80A44DE8; + this->opaDList = sOpaDLists[params]; + this->xluDList = sXluDLists[params]; + this->dyna.actor.textId = sTextIds[params]; + this->dyna.actor.focus.pos.y = this->dyna.actor.world.pos.y + 60.0f; + Actor_SetScale(&this->dyna.actor, 0.1f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/func_80A45130.s") +void EnSekihi_Destroy(Actor* thisx, PlayState* play) { + EnSekihi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/EnSekihi_Update.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/func_80A45164.s") +void func_80A44DE8(EnSekihi* this, PlayState* play) { + CollisionHeader* colHeader = NULL; + s32 params; + CollisionHeader* colHeaders[] = { + &gSekihilCol, &gSekihigCol, &gSekihinCol, &gSekihizCol, &gObjectZogCol, + }; + + params = ENSIKIHI_GET_TYPE(&this->dyna.actor); + if (Object_IsLoaded(&play->objectCtx, this->objectIndex)) { + this->dyna.actor.objBankIndex = this->objectIndex; + this->dyna.actor.draw = EnSekihi_Draw; + if (params == SEKIHI_TYPE_4) { + this->actionFunc = func_80A450B0; + } else { + this->actionFunc = EnSekihi_DoNothing; + } + + Actor_SetObjectDependency(play, &this->dyna.actor); + DynaPolyActor_Init(&this->dyna, 0); + if (colHeaders[params] != NULL) { + CollisionHeader_GetVirtual(colHeaders[params], &colHeader); + } + + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + if ((params == SEKIHI_TYPE_4) && (INV_CONTENT(ITEM_MASK_ZORA) != ITEM_MASK_ZORA)) { + Actor_MarkForDeath(&this->dyna.actor); + } + } +} + +void func_80A44F40(EnSekihi* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x1019)) { + switch (play->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + func_80151938(play, 0x101A); + break; + case 1: + func_8019F208(); + func_80151938(play, 0x101B); + break; + case 2: + func_8019F230(); + func_801477B4(play); + this->actionFunc = func_80A450B0; + break; + } + } else { + break; + } + break; + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x1018: + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + case 0x101A: + case 0x101B: + func_801477B4(play); + this->actionFunc = func_80A450B0; + break; + } + } + break; + } +} + +void func_80A450B0(EnSekihi* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->dyna.actor, &play->state)) { + this->actionFunc = func_80A44F40; + } else if ((this->dyna.actor.xzDistToPlayer < 100.0f) && (Player_IsFacingActor(&this->dyna.actor, 0x2600, play))) { + func_800B8614(&this->dyna.actor, play, 120.0f); + } +} + +void EnSekihi_DoNothing(EnSekihi* this, PlayState* play) { +} + +void EnSekihi_Update(Actor* thisx, PlayState* play) { + EnSekihi* this = THIS; + + this->actionFunc(this, play); +} + +void EnSekihi_Draw(Actor* thisx, PlayState* play) { + EnSekihi* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + if (this->xluDList != NULL) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(play->state.gfxCtx); + gSPDisplayList(POLY_XLU_DISP++, this->xluDList); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(play->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, this->opaDList); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.h b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.h index 0835f6135..e626b616d 100644 --- a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.h +++ b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.h @@ -3,16 +3,29 @@ #include "global.h" +#define ENSIKIHI_GET_TYPE(thisx) ((thisx)->params & 0xF) + struct EnSekihi; typedef void (*EnSekihiActionFunc)(struct EnSekihi*, PlayState*); typedef struct EnSekihi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x24]; - /* 0x0168 */ EnSekihiActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ Gfx* opaDList; + /* 0x160 */ Gfx* xluDList; + /* 0x164 */ s8 objectIndex; + /* 0x168 */ EnSekihiActionFunc actionFunc; } EnSekihi; // size = 0x16C +typedef enum SekihiType { + /* 0x0 */ SEKIHI_TYPE_0, + /* 0x1 */ SEKIHI_TYPE_1, + /* 0x2 */ SEKIHI_TYPE_2, + /* 0x3 */ SEKIHI_TYPE_3, + /* 0x4 */ SEKIHI_TYPE_4, + /* 0x5 */ SEKIHI_TYPE_MAX +} SekihiType; + extern const ActorInit En_Sekihi_InitVars; #endif // Z_EN_SEKIHI_H 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 3faeedd7e..aacfa5685 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -341,7 +341,7 @@ void func_80ADB544(EnSellnuts* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x7D0, 0); this->actor.world.rot.y = this->actor.shape.rot.y; if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - if (Player_GetExchangeItemId(play) == EXCH_ITEM_2A) { + if (Player_GetExchangeItemId(play) == EXCH_ITEM_MOON_TEAR) { player->actor.textId = D_80ADD928[this->unk_33A]; this->unk_340 = player->actor.textId; this->actionFunc = func_80ADBAB8; @@ -382,7 +382,7 @@ void func_80ADB544(EnSellnuts* this, PlayState* play) { } 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, play, 80.0f, EXCH_ITEM_2A); + func_800B85E0(&this->actor, play, 80.0f, EXCH_ITEM_MOON_TEAR); if (player->transformation == PLAYER_FORM_DEKU) { if (gSaveContext.save.day == 3) { this->unk_33A = 2; @@ -416,13 +416,13 @@ void func_80ADB544(EnSellnuts* this, PlayState* play) { void func_80ADB924(EnSellnuts* this, PlayState* play) { Player* player = GET_PLAYER(play); - u8 msgState = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); s32 item; - if (msgState == 0x10) { + if (talkState == TEXT_STATE_16) { item = func_80123810(play); if (item > EXCH_ITEM_NONE) { - if (item == EXCH_ITEM_2A) { + if (item == EXCH_ITEM_MOON_TEAR) { player->actor.textId = D_80ADD928[this->unk_33A]; this->unk_340 = player->actor.textId; player->exchangeItemId = item; @@ -438,7 +438,7 @@ void func_80ADB924(EnSellnuts* this, PlayState* play) { func_80151938(play, this->unk_340); this->actionFunc = func_80ADB0D8; } - } else if ((msgState == 5) && Message_ShouldAdvance(play)) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_340 == D_80ADD910[this->unk_33A]) { this->unk_340 = D_80ADD938[this->unk_33A]; func_80151938(play, this->unk_340); @@ -452,7 +452,7 @@ void func_80ADB924(EnSellnuts* this, PlayState* play) { } void func_80ADBAB8(EnSellnuts* this, PlayState* play) { - u8 sp27 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); s16 currentFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); @@ -468,9 +468,9 @@ void func_80ADBAB8(EnSellnuts* this, PlayState* play) { SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 6); } - if ((sp27 == 5) && Message_ShouldAdvance(play)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = func_80ADBBEC; func_800B7298(play, NULL, 0x13); } @@ -497,7 +497,7 @@ void func_80ADBC60(EnSellnuts* this, PlayState* play) { } void func_80ADBCE4(EnSellnuts* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 6) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { func_800B85E0(&this->actor, play, 400.0f, EXCH_ITEM_MINUS1); this->unk_340 = D_80ADD930[this->unk_33A]; this->actionFunc = func_80ADBC60; @@ -505,7 +505,7 @@ void func_80ADBCE4(EnSellnuts* this, PlayState* play) { } void func_80ADBD64(EnSellnuts* this, PlayState* play) { - u8 sp27 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); s16 currentFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); @@ -514,9 +514,9 @@ void func_80ADBD64(EnSellnuts* this, PlayState* play) { SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); } - if ((sp27 == 5) && Message_ShouldAdvance(play)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_338 &= ~2; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_34C = 8; @@ -556,9 +556,9 @@ void func_80ADBE80(EnSellnuts* this, PlayState* play) { } void func_80ADBFA0(EnSellnuts* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; if (this->unk_34C == 0) { this->actionFunc = func_80ADB544; } else { @@ -719,9 +719,9 @@ void func_80ADC5A4(EnSellnuts* this, PlayState* play) { void func_80ADC6D0(EnSellnuts* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; if (player->transformation == PLAYER_FORM_DEKU) { if (gSaveContext.save.day == 3) { this->unk_33A = 2; @@ -737,7 +737,7 @@ void func_80ADC6D0(EnSellnuts* this, PlayState* play) { } void func_80ADC7B4(EnSellnuts* this, PlayState* play) { - s32 temp = Message_GetState(&play->msgCtx); + s32 talkState = Message_GetState(&play->msgCtx); if (this->unk_366 == 0) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -749,9 +749,9 @@ void func_80ADC7B4(EnSellnuts* this, PlayState* play) { } ActorCutscene_SetIntentToPlay(this->cutscene); } - } else if ((this->unk_366 == 1) && (temp == 5) && Message_ShouldAdvance(play)) { + } else if ((this->unk_366 == 1) && (talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_366 = 0; ActorCutscene_Stop(this->cutscene); this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.h b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.h index bce0273c6..49023ce7f 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.h +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.h @@ -11,39 +11,39 @@ typedef void (*EnSellnutsActionFunc)(struct EnSellnuts*, PlayState*); #define ENSELLNUTS_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) typedef struct EnSellnuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[28]; - /* 0x0230 */ Vec3s morphTable[28]; - /* 0x02D8 */ EnSellnutsActionFunc actionFunc; - /* 0x02DC */ ColliderCylinder collider; - /* 0x0328 */ s16 unk_328; - /* 0x032C */ f32 unk_32C; - /* 0x0330 */ Path* path; - /* 0x0334 */ s32 unk_334; - /* 0x0338 */ u16 unk_338; - /* 0x033A */ u16 unk_33A; - /* 0x033C */ s16 cutscene; - /* 0x033E */ UNK_TYPE1 unk33E[0x2]; - /* 0x0340 */ u16 unk_340; - /* 0x0342 */ u16 unk_342; - /* 0x0344 */ s16 unk_344; - /* 0x0346 */ UNK_TYPE1 unk346[0x4]; - /* 0x034A */ s16 unk_34A; - /* 0x034C */ s16 unk_34C; - /* 0x034E */ s16 unk_34E; - /* 0x0350 */ s16 unk_350; - /* 0x0354 */ f32 unk_354; - /* 0x0358 */ f32 unk_358; - /* 0x035C */ f32 unk_35C; - /* 0x0360 */ f32 unk_360; - /* 0x0364 */ s16 unk_364; - /* 0x0366 */ s16 unk_366; - /* 0x0368 */ s16 unk_368; - /* 0x036A */ UNK_TYPE1 unk36A[0x2]; - /* 0x036C */ f32 unk_36C; - /* 0x0370 */ f32 unk_370; - /* 0x0374 */ f32 unk_374; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[28]; + /* 0x230 */ Vec3s morphTable[28]; + /* 0x2D8 */ EnSellnutsActionFunc actionFunc; + /* 0x2DC */ ColliderCylinder collider; + /* 0x328 */ s16 unk_328; + /* 0x32C */ f32 unk_32C; + /* 0x330 */ Path* path; + /* 0x334 */ s32 unk_334; + /* 0x338 */ u16 unk_338; + /* 0x33A */ u16 unk_33A; + /* 0x33C */ s16 cutscene; + /* 0x33E */ UNK_TYPE1 unk33E[0x2]; + /* 0x340 */ u16 unk_340; + /* 0x342 */ u16 unk_342; + /* 0x344 */ s16 unk_344; + /* 0x346 */ UNK_TYPE1 unk346[0x4]; + /* 0x34A */ s16 unk_34A; + /* 0x34C */ s16 unk_34C; + /* 0x34E */ s16 unk_34E; + /* 0x350 */ s16 unk_350; + /* 0x354 */ f32 unk_354; + /* 0x358 */ f32 unk_358; + /* 0x35C */ f32 unk_35C; + /* 0x360 */ f32 unk_360; + /* 0x364 */ s16 unk_364; + /* 0x366 */ s16 unk_366; + /* 0x368 */ s16 unk_368; + /* 0x36A */ UNK_TYPE1 unk36A[0x2]; + /* 0x36C */ f32 unk_36C; + /* 0x370 */ f32 unk_370; + /* 0x374 */ f32 unk_374; } EnSellnuts; // size = 0x378 extern const ActorInit En_Sellnuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index 720a94c80..51faf709c 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -177,17 +177,16 @@ void func_80AE63A8(EnShn* this, PlayState* play) { void func_80AE6488(EnShn* this, PlayState* play) { Player* player = GET_PLAYER(play); - s32 tempMsgState; + s32 talkState = Message_GetState(&play->msgCtx); f32 phi_f0_2; f32 phi_f0; - tempMsgState = Message_GetState(&play->msgCtx); this->unk_2D4 += (this->unk_2D0 != 0.0f) ? 40.0f : -40.0f; this->unk_2D4 = CLAMP(this->unk_2D4, 0.0f, 80.0f); Matrix_Translate(this->unk_2D4, 0.0f, 0.0f, MTXMODE_APPLY); if ((&this->actor == player->targetActor) && - ((play->msgCtx.currentTextId < 0xFF) || (play->msgCtx.currentTextId >= 0x201)) && (tempMsgState == 3) && - (this->msgState == 3)) { + ((play->msgCtx.currentTextId < 0xFF) || (play->msgCtx.currentTextId >= 0x201)) && (talkState == TEXT_STATE_3) && + (this->prevTalkState == TEXT_STATE_3)) { if (play->state.frames % 2 == 0) { if (this->unk_2D0 != 0.0f) { this->unk_2D0 = 0.0f; @@ -198,7 +197,7 @@ void func_80AE6488(EnShn* this, PlayState* play) { } else { this->unk_2D0 = 0.0f; } - this->msgState = tempMsgState; + this->prevTalkState = talkState; } s32 func_80AE65F4(EnShn* this, PlayState* play) { @@ -235,7 +234,7 @@ s32 func_80AE6704(EnShn* thisx, PlayState* play) { switch (this->unk_2C6) { case 0: - if (!CHECK_QUEST_ITEM(QUEST_UNK_19)) { + if (!CHECK_QUEST_ITEM(QUEST_PICTOGRAPH)) { this->unk_2C6 = 6; ret = 1; } else { @@ -250,7 +249,7 @@ s32 func_80AE6704(EnShn* thisx, PlayState* play) { if (func_8013A4C4(D_80AE7258[this->unk_2C6])) { this->unk_2C6 = 6; ret = 1; - REMOVE_QUEST_ITEM(QUEST_UNK_19); + REMOVE_QUEST_ITEM(QUEST_PICTOGRAPH); } else { this->unk_2C6++; } @@ -260,9 +259,9 @@ s32 func_80AE6704(EnShn* thisx, PlayState* play) { func_800B7298(play, &this->actor, 7); play->nextEntranceIndex = 0x8460; gSaveContext.nextCutsceneIndex = 0; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 3; - gSaveContext.nextTransition = 7; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_07; this->unk_2C6++; break; } diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.h b/src/overlays/actors/ovl_En_Shn/z_en_shn.h index eb0e46ee7..cc7c37ac4 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.h +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.h @@ -35,7 +35,7 @@ typedef struct EnShn { /* 0x2D0 */ f32 unk_2D0; /* 0x2D4 */ f32 unk_2D4; /* 0x2D8 */ s32 unk_2D8; - /* 0x2DC */ s32 msgState; + /* 0x2DC */ s32 prevTalkState; /* 0x2E0 */ s32 unk_2E0; /* 0x2E4 */ s32 unk_2E4; /* 0x2E8 */ s32 unk_2E8; diff --git a/src/overlays/actors/ovl_En_Si/z_en_si.h b/src/overlays/actors/ovl_En_Si/z_en_si.h index 03e776373..032e1f116 100644 --- a/src/overlays/actors/ovl_En_Si/z_en_si.h +++ b/src/overlays/actors/ovl_En_Si/z_en_si.h @@ -8,9 +8,9 @@ struct EnSi; typedef void (*EnSiActionFunc)(struct EnSi*, PlayState*); typedef struct EnSi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnSiActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x58]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnSiActionFunc actionFunc; + /* 0x148 */ char unk_148[0x58]; } EnSi; // size = 0x1A0 extern const ActorInit En_Si_InitVars; 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 0c79b6a4e..21df2d8f9 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -106,7 +106,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -363,14 +363,14 @@ void func_80995068(EnSkb* this, PlayState* play) { void func_80995190(EnSkb* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 0: - case 1: - case 2: - case 3: - case 4: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: break; - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { Message_StartTextbox(play, 0x13F7, &this->actor); if (this->unk_3DE == 2) { @@ -379,7 +379,7 @@ void func_80995190(EnSkb* this, PlayState* play) { } break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { this->actionFunc = func_80995244; } @@ -536,7 +536,7 @@ void func_80995818(EnSkb* this, PlayState* play) { void func_809958F4(EnSkb* this) { Animation_Change(&this->skelAnime, &object_skb_Anim_003584, -1.0f, Animation_GetLastFrame(&object_skb_Anim_003584), - 0.0f, 2, -4.0f); + 0.0f, ANIMMODE_ONCE, -4.0f); this->unk_3E4 = 0; this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; @@ -620,7 +620,8 @@ void func_80995C84(EnSkb* this, PlayState* play) { } void func_80995D3C(EnSkb* this) { - Animation_Change(&this->skelAnime, &object_skb_Anim_002190, -0.4f, this->skelAnime.curFrame - 1.0f, 0.0f, 3, 0.0f); + Animation_Change(&this->skelAnime, &object_skb_Anim_002190, -0.4f, this->skelAnime.curFrame - 1.0f, 0.0f, + ANIMMODE_ONCE_INTERP, 0.0f); this->collider.base.atFlags &= ~AT_BOUNCED; this->unk_3DE = 4; this->unk_3E4 = 0; @@ -798,7 +799,7 @@ void func_80996474(EnSkb* this) { } void func_809964A0(EnSkb* this, PlayState* play) { - if ((this->unk_3D0++ < 19) ^ 1) { + if (this->unk_3D0++ >= 19) { Actor_MarkForDeath(&this->actor); } } @@ -961,8 +962,10 @@ void func_8099672C(EnSkb* this, PlayState* play) { this->unk_3D8 |= 1; case 15: - if ((player->swordAnimation == 4) || (player->swordAnimation == 11) || - (player->swordAnimation == 22) || (player->swordAnimation == 23)) { + if ((player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_LEFT_COMBO_2H) || + (player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_RIGHT) || + (player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_LEFT)) { this->unk_3D8 |= 1; } diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.h b/src/overlays/actors/ovl_En_Skb/z_en_skb.h index 2e3d8e10a..002604838 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.h +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.h @@ -10,30 +10,30 @@ typedef void (*EnSkbActionFunc)(struct EnSkb*, PlayState*); #define ENSKB_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) typedef struct EnSkb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ ColliderJntSph collider; - /* 0x01A8 */ ColliderJntSphElement colliderElements[2]; - /* 0x0228 */ EnSkbActionFunc actionFunc; - /* 0x022C */ f32 drawDmgEffAlpha; - /* 0x0230 */ f32 drawDmgEffScale; - /* 0x0234 */ Vec3f limbPos[14]; - /* 0x02DC */ s32 limbCount; - /* 0x02E0 */ Vec3s jointTable[20]; - /* 0x0358 */ Vec3s morphTable[20]; - /* 0x03D0 */ s16 unk_3D0; - /* 0x03D2 */ s16 drawDmgEffTimer; - /* 0x03D4 */ s16 unk_3D4; - /* 0x03D6 */ s16 unk_3D6; - /* 0x03D8 */ s16 unk_3D8; - /* 0x03DA */ s16 unk_3DA; - /* 0x03DC */ s16 unk_3DC; - /* 0x03DE */ s16 unk_3DE; - /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 unk_3E2; - /* 0x03E4 */ u8 unk_3E4; - /* 0x03E5 */ u8 unk_3E5; - /* 0x03E6 */ u8 drawDmgEffType; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderJntSph collider; + /* 0x1A8 */ ColliderJntSphElement colliderElements[2]; + /* 0x228 */ EnSkbActionFunc actionFunc; + /* 0x22C */ f32 drawDmgEffAlpha; + /* 0x230 */ f32 drawDmgEffScale; + /* 0x234 */ Vec3f limbPos[14]; + /* 0x2DC */ s32 limbCount; + /* 0x2E0 */ Vec3s jointTable[20]; + /* 0x358 */ Vec3s morphTable[20]; + /* 0x3D0 */ s16 unk_3D0; + /* 0x3D2 */ s16 drawDmgEffTimer; + /* 0x3D4 */ s16 unk_3D4; + /* 0x3D6 */ s16 unk_3D6; + /* 0x3D8 */ s16 unk_3D8; + /* 0x3DA */ s16 unk_3DA; + /* 0x3DC */ s16 unk_3DC; + /* 0x3DE */ s16 unk_3DE; + /* 0x3E0 */ s16 unk_3E0; + /* 0x3E2 */ s16 unk_3E2; + /* 0x3E4 */ u8 unk_3E4; + /* 0x3E5 */ u8 unk_3E5; + /* 0x3E6 */ u8 drawDmgEffType; } EnSkb; // size = 0x3E8 extern const ActorInit En_Skb_InitVars; diff --git a/src/overlays/actors/ovl_En_Slime/z_en_slime.h b/src/overlays/actors/ovl_En_Slime/z_en_slime.h index c90c49340..dacbd824c 100644 --- a/src/overlays/actors/ovl_En_Slime/z_en_slime.h +++ b/src/overlays/actors/ovl_En_Slime/z_en_slime.h @@ -8,9 +8,9 @@ struct EnSlime; typedef void (*EnSlimeActionFunc)(struct EnSlime*, PlayState*); typedef struct EnSlime { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnSlimeActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xC0]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnSlimeActionFunc actionFunc; + /* 0x148 */ char unk_148[0xC0]; } EnSlime; // size = 0x208 extern const ActorInit En_Slime_InitVars; diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c index 5d656af95..b07a1667e 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -328,7 +328,7 @@ void EnSnowman_SpawnBigSnowballFragmentEffects(EnSnowman* this, PlayState* play) pos.y = (Rand_ZeroFloat(8.0f) * velocity.y) + this->snowballPos.y; pos.z = (Rand_ZeroFloat(10.0f) * velocity.z) + this->snowballPos.z; EffectSsHahen_Spawn(play, &pos, &velocity, &sAccel, 0, - Rand_S16Offset((((i % 3) * 50) + 50), (((i % 3) * 25) + 25)), 452, 20, + Rand_S16Offset((((i % 3) * 50) + 50), (((i % 3) * 25) + 25)), OBJECT_SNOWMAN, 20, sSnowballFragmentDLs[i % 3]); } @@ -755,7 +755,7 @@ void EnSnowman_Dead(EnSnowman* this, PlayState* play) { pos.y = (Rand_ZeroFloat(3.0f) * velocity.y) + this->actor.world.pos.y; pos.z = (Rand_ZeroFloat(6.0f) * velocity.z) + this->actor.world.pos.z; EffectSsHahen_Spawn(play, &pos, &velocity, &sAccel, 0, - Rand_S16Offset((((i % 3) * 20) + 20), (((i % 3) * 10) + 10)), 452, 20, + Rand_S16Offset((((i % 3) * 20) + 20), (((i % 3) * 10) + 10)), OBJECT_SNOWMAN, 20, sSnowballFragmentDLs[i % 3]); } @@ -1086,7 +1086,7 @@ void EnSnowman_UpdateSnowball(Actor* thisx, PlayState* play) { if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { scale = 10; for (i = 0; i < 3; i++) { - EffectSsHahen_SpawnBurst(play, &thisx->world.pos, 5.0f, 0, scale, scale >> 1, 3, 452, 20, + EffectSsHahen_SpawnBurst(play, &thisx->world.pos, 5.0f, 0, scale, scale >> 1, 3, OBJECT_SNOWMAN, 20, sSnowballFragmentDLs[i]); scale *= 2; } diff --git a/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.h b/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.h index d344f034a..6706de846 100644 --- a/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.h +++ b/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.h @@ -8,9 +8,9 @@ struct EnSnowwd; typedef void (*EnSnowwdActionFunc)(struct EnSnowwd*, PlayState*); typedef struct EnSnowwd { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x50]; - /* 0x0194 */ EnSnowwdActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x50]; + /* 0x194 */ EnSnowwdActionFunc actionFunc; } EnSnowwd; // size = 0x198 extern const ActorInit En_Snowwd_InitVars; 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 aa26c1a43..ce8cb0cf6 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -441,7 +441,7 @@ void EnSob1_EndInteraction(PlayState* play, EnSob1* this) { } Actor_ProcessTalkRequest(&this->actor, &play->state); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; Interface_ChangeAlpha(50); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; @@ -466,7 +466,7 @@ s32 EnSob1_TestEndInteraction(EnSob1* this, PlayState* play, Input* input) { s32 EnSob1_TestCancelOption(EnSob1* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->actionFunc = this->tmpActionFunc; + this->actionFunc = this->prevActionFunc; func_80151938(play, this->items[this->cursorIndex]->actor.textId); return true; } @@ -506,7 +506,7 @@ void EnSob1_SetupLookToShopkeeperFromShelf(PlayState* play, EnSob1* this) { } void EnSob1_EndingInteraction(EnSob1* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 6 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { EnSob1_EndInteraction(play, this); } } @@ -610,7 +610,7 @@ void EnSob1_Hello(EnSob1* this, PlayState* play) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if ((talkState == 5) && Message_ShouldAdvance(play) && + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play) && !EnSob1_TestEndInteraction(this, play, CONTROLLER1(&play->state))) { if (this->welcomeTextId == 0x68A) { // Welcome text when wearing Kafei's mask EnSob1_EndInteraction(play, this); @@ -659,7 +659,7 @@ void EnSob1_FaceShopkeeper(EnSob1* this, PlayState* play) { ActorCutscene_SetIntentToPlay(this->cutscene); this->cutsceneState = ENSOB1_CUTSCENESTATE_WAITING; } else { - if (talkState == 4) { + if (talkState == TEXT_STATE_CHOICE) { func_8011552C(play, 6); if (!EnSob1_TestEndInteraction(this, play, CONTROLLER1(&play->state))) { if (!Message_ShouldAdvance(play) || !EnSob1_FacingShopkeeperDialogResult(this, play)) { @@ -680,7 +680,7 @@ void EnSob1_FaceShopkeeper(EnSob1* this, PlayState* play) { } void EnSob1_TalkingToShopkeeper(EnSob1* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { EnSob1_StartShopping(play, this); } } @@ -882,7 +882,7 @@ s32 EnSob1_HasPlayerSelectedItem(PlayState* play, EnSob1* this, Input* input) { } if (EnSob1_TestItemSelected(play)) { if (!item->isOutOfStock) { - this->tmpActionFunc = this->actionFunc; + this->prevActionFunc = this->actionFunc; func_80151938(play, this->items[this->cursorIndex]->choiceTextId); play_sound(NA_SE_SY_DECIDE); this->stickLeftPrompt.isEnabled = false; @@ -911,7 +911,7 @@ void EnSob1_BrowseShelf(EnSob1* this, PlayState* play) { this->drawCursor = 0xFF; this->stickLeftPrompt.isEnabled = true; EnSob1_UpdateCursorPos(play, this); - if (talkState == 5) { + if (talkState == TEXT_STATE_5) { func_8011552C(play, 6); if (!EnSob1_HasPlayerSelectedItem(play, this, CONTROLLER1(&play->state))) { EnSob1_CursorLeftRight(play, this); @@ -930,7 +930,7 @@ void EnSob1_SetupBuyItemWithFanfare(PlayState* play, EnSob1* this) { Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~0x20000000; Interface_ChangeAlpha(50); this->drawCursor = 0; @@ -1019,7 +1019,7 @@ void EnSob1_HandleCanBuyItem(PlayState* play, EnSob1* this) { void EnSob1_SelectItem(EnSob1* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - if (EnSob1_TakeItemOffShelf(this) && talkState == 4) { + if (EnSob1_TakeItemOffShelf(this) && (talkState == TEXT_STATE_CHOICE)) { func_8011552C(play, 6); if (!EnSob1_TestCancelOption(this, play, CONTROLLER1(&play->state)) && Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { @@ -1028,7 +1028,7 @@ void EnSob1_SelectItem(EnSob1* this, PlayState* play) { break; case 1: func_8019F230(); - this->actionFunc = this->tmpActionFunc; + this->actionFunc = this->prevActionFunc; func_80151938(play, this->items[this->cursorIndex]->actor.textId); break; } @@ -1037,9 +1037,9 @@ void EnSob1_SelectItem(EnSob1* this, PlayState* play) { } void EnSob1_CannotBuy(EnSob1* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { - this->actionFunc = this->tmpActionFunc; + this->actionFunc = this->prevActionFunc; func_80151938(play, this->items[this->cursorIndex]->actor.textId); } } @@ -1048,12 +1048,12 @@ void EnSob1_CannotBuy(EnSob1* this, PlayState* play) { void EnSob1_CanBuy(EnSob1* this, PlayState* play) { EnGirlA* item; - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->shopItemSelectedTween = 0.0f; EnSob1_ResetItemPosition(this); item = this->items[this->cursorIndex]; item->restockFunc(play, item); - this->actionFunc = this->tmpActionFunc; + this->actionFunc = this->prevActionFunc; func_80151938(play, this->items[this->cursorIndex]->actor.textId); } } @@ -1068,9 +1068,9 @@ void EnSob1_BuyItemWithFanfare(EnSob1* this, PlayState* play) { } void EnSob1_SetupItemPurchased(EnSob1* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 6 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; EnSob1_SetupAction(this, EnSob1_ItemPurchased); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -1087,7 +1087,7 @@ void EnSob1_ContinueShopping(EnSob1* this, PlayState* play) { Player* player = GET_PLAYER(play); EnGirlA* item; - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { EnSob1_ResetItemPosition(this); item = this->items[this->cursorIndex]; item->restockFunc(play, item); diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h index c06f56280..6cb615d6f 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h @@ -28,7 +28,7 @@ typedef struct EnSob1 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnSob1ActionFunc actionFunc; - /* 0x18C */ EnSob1ActionFunc tmpActionFunc; // Used to restore back to correct browsing function + /* 0x18C */ EnSob1ActionFunc prevActionFunc; // Used to restore back to correct browsing function /* 0x190 */ EnSob1ActionFunc changeObjectFunc; /* 0x194 */ ColliderCylinder collider; /* 0x1E0 */ Path* path; @@ -88,8 +88,6 @@ typedef enum { /* 2 */ ENSOB1_CUTSCENESTATE_PLAYING } EnSob1CutsceneState; -//! @TODO: Add enum for objIndices index based on what the object is for - extern const ActorInit En_Sob1_InitVars; #endif // Z_EN_SOB1_H 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 4a64f1df6..d7c41603e 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -102,7 +102,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -683,7 +683,7 @@ void EnSsh_Wait(EnSsh* this, PlayState* play) { void EnSsh_Talk(EnSsh* this, PlayState* play) { EnSsh_Bob(this, play); - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x904: case 0x905: 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 45122c4c3..72a82e692 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h @@ -14,46 +14,46 @@ typedef void (*EnSshActionFunc)(struct EnSsh*, PlayState*); #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 + /* 0x0 */ SSH_ANIM_UNK0, // Unused animation. Possibly being knocked back? + /* 0x1 */ SSH_ANIM_UP, + /* 0x2 */ SSH_ANIM_WAIT, + /* 0x3 */ SSH_ANIM_LAND, + /* 0x4 */ SSH_ANIM_DROP, + /* 0x5 */ SSH_ANIM_UNK5, // Slower version of ANIM_DROP + /* 0x6 */ 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 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[30]; - /* 0x023C */ Vec3s morphtable[30]; - /* 0x02F0 */ EnSshActionFunc actionFunc; - /* 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; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[30]; + /* 0x23C */ Vec3s morphtable[30]; + /* 0x2F0 */ EnSshActionFunc actionFunc; + /* 0x2F4 */ ColliderCylinder collider1[6]; + /* 0x4BC */ ColliderJntSph collider2; + /* 0x4DC */ ColliderJntSphElement collider2Elements[1]; + /* 0x51C */ s16 initialYaw; + /* 0x51E */ s16 maxTurnRate; + /* 0x520 */ s16 unkTimer; + /* 0x522 */ s16 spinTimer; + /* 0x524 */ s16 hitTimer; + /* 0x526 */ s16 invincibilityTimer; + /* 0x528 */ s16 sfxTimer; + /* 0x52A */ s16 stunTimer; + /* 0x52C */ s16 animTimer; + /* 0x52E */ s16 swayTimer; + /* 0x530 */ s32 blureIdx; + /* 0x534 */ f32 colliderScale; + /* 0x538 */ f32 floorHeightOffset; + /* 0x53C */ Vec3f ceilingPos; + /* 0x548 */ UNK_TYPE1 unk_548[0x78]; + /* 0x5C0 */ s16 swayAngle; + /* 0x5C2 */ u16 stateFlags; + /* 0x5C4 */ u8 hitCount; + /* 0x5C6 */ s16 blinkState; + /* 0x5C8 */ 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 95c39ee76..e8c9eaeb9 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -242,7 +242,7 @@ void func_808A54B0(EnSt* this, PlayState* play) { if ((this->unk_18C & 1) && (this->actor.colChkInfo.health != 0)) { OPEN_DISPS(play->state.gfxCtx); - gSegments[6] = PHYSICAL_TO_VIRTUAL2(play->objectCtx.status[this->unk_2C0].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->unk_2C0].segment); gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[this->unk_2C0].segment); diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 4d80d0049..664a74aa1 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -179,8 +179,8 @@ s32 func_80B6703C(EnSth* this, PlayState* play) { void func_80B670A4(EnSth* this, s16 arg1) { if ((arg1 >= 0) && (arg1 < ARRAY_COUNT(D_80B6D1C8)) && (arg1 != this->unk_29A)) { - Animation_Change(&this->skelAnime, D_80B6D1C8[arg1], 1.0f, 0.0f, Animation_GetLastFrame(D_80B6D1C8[arg1]), 0, - -5.0f); + Animation_Change(&this->skelAnime, D_80B6D1C8[arg1], 1.0f, 0.0f, Animation_GetLastFrame(D_80B6D1C8[arg1]), + ANIMMODE_LOOP, -5.0f); this->unk_29A = arg1; } } @@ -200,7 +200,7 @@ void func_80B67148(EnSth* this, PlayState* play) { void func_80B671A0(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actionFunc = func_80B67208; func_801477B4(play); } @@ -312,7 +312,7 @@ void func_80B67540(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); switch (Message_GetState(&play->msgCtx)) { - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x1134: @@ -382,7 +382,7 @@ void func_80B67540(EnSth* this, PlayState* play) { } break; - case 2: + case TEXT_STATE_CLOSING: this->actionFunc = func_80B677BC; this->unk_29C |= 2; break; @@ -403,7 +403,7 @@ void func_80B677BC(EnSth* this, PlayState* play) { void func_80B67838(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actionFunc = func_80B678A8; func_801477B4(play); } @@ -494,7 +494,7 @@ void func_80B67C1C(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x90C: func_80B670A4(this, 2); diff --git a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c index 4cf9cb5fd..3ce5ba447 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c @@ -13,8 +13,11 @@ void EnSth2_Init(Actor* thisx, PlayState* play); void EnSth2_Destroy(Actor* thisx, PlayState* play); void EnSth2_Update(Actor* thisx, PlayState* play); +void EnSth2_Draw(Actor* thisx, PlayState* play2); + +void EnSth2_UpdateSkelAnime(EnSth2* this, PlayState* play); +void EnSth2_UpdateActionFunc(Actor* thisx, PlayState* play); -#if 0 const ActorInit En_Sth2_InitVars = { ACTOR_EN_STH2, ACTORCAT_NPC, @@ -27,22 +30,95 @@ const ActorInit En_Sth2_InitVars = { (ActorFunc)NULL, }; -#endif +#include "overlays/ovl_En_Sth2/ovl_En_Sth2.c" -extern UNK_TYPE D_060031F8; +void EnSth2_Init(Actor* thisx, PlayState* play) { + EnSth2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/EnSth2_Init.s") + this->objIndex = Object_GetIndex(&play->objectCtx, OBJECT_STH); + Actor_SetScale(&this->actor, 0.01f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + this->unused = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/EnSth2_Destroy.s") + if (play->actorCtx.unk5 & 2) { + this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); + } else { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc = EnSth2_UpdateSkelAnime; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF75A0.s") +void EnSth2_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/EnSth2_Update.s") +void EnSth2_UpdateSkelAnime(EnSth2* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF7688.s") +void EnSth2_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnSth2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF76AC.s") + if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { + this->actor.objBankIndex = this->objIndex; + Actor_SetObjectDependency(play, &this->actor); + SkelAnime_InitFlex(play, &this->skelAnime, &object_sth_Skel_0031F8, &gEnSth2WavingHandAnim, this->jointTable, + this->morphTable, OBJECT_STH_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gEnSth2WavingHandAnim); + this->actor.update = EnSth2_UpdateActionFunc; + this->actor.draw = EnSth2_Draw; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF77AC.s") +void EnSth2_UpdateActionFunc(Actor* thisx, PlayState* play) { + EnSth2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF7814.s") + this->actionFunc(this, play); +} + +s32 EnSth2_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + s32 pad; + + if (limbIndex == OBJECT_STH_LIMB_0F) { + *dList = gEnSth2HeadDL; + } + if ((limbIndex == OBJECT_STH_LIMB_08) || (limbIndex == OBJECT_STH_LIMB_0A) || (limbIndex == OBJECT_STH_LIMB_0D)) { + rot->y += (s16)(Math_SinS((play->state.frames * ((limbIndex * 50) + 0x814))) * 200.0f); + rot->z += (s16)(Math_CosS((play->state.frames * ((limbIndex * 50) + 0x940))) * 200.0f); + } + return false; +} + +void EnSth2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f focusOffset = { 700.0f, 400.0f, 0.0f }; + + if (limbIndex == OBJECT_STH_LIMB_0F) { + Matrix_MultVec3f(&focusOffset, &thisx->focus.pos); + + OPEN_DISPS(play->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, gEnSth2HairDL); + + CLOSE_DISPS(play->state.gfxCtx); + } +} + +void EnSth2_Draw(Actor* thisx, PlayState* play2) { + static Color_RGB8 sEnvColors[] = { + { 190, 110, 0 }, { 0, 180, 110 }, { 0, 255, 80 }, { 255, 160, 60 }, { 190, 230, 250 }, { 240, 230, 120 }, + }; + PlayState* play = play2; + EnSth2* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_EnvColor(play->state.gfxCtx, sEnvColors[1].r, sEnvColors[1].g, sEnvColors[1].b, 255)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(play->state.gfxCtx, 90, 110, 130, 255)); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnSth2_OverrideLimbDraw, EnSth2_PostLimbDraw, &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.h b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.h index 1788c486c..1166c9d29 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.h +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.h @@ -2,12 +2,20 @@ #define Z_EN_STH2_H #include "global.h" +#include "objects/object_sth/object_sth.h" struct EnSth2; +typedef void (*EnSth2ActionFunc)(struct EnSth2*, PlayState*); + typedef struct EnSth2 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x10C]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[OBJECT_STH_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[OBJECT_STH_LIMB_MAX]; + /* 0x248 */ s16 unused; + /* 0x24A */ u8 objIndex; + /* 0x24C */ EnSth2ActionFunc actionFunc; } EnSth2; // size = 0x250 extern const ActorInit En_Sth2_InitVars; diff --git a/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.h b/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.h index b858117b4..f4eb8e5f2 100644 --- a/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.h +++ b/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.h @@ -8,10 +8,10 @@ struct EnStoneheishi; typedef void (*EnStoneheishiActionFunc)(struct EnStoneheishi*, PlayState*); typedef struct EnStoneheishi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x110]; - /* 0x0254 */ EnStoneheishiActionFunc actionFunc; - /* 0x0258 */ char unk_258[0x6C]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x110]; + /* 0x254 */ EnStoneheishiActionFunc actionFunc; + /* 0x258 */ char unk_258[0x6C]; } EnStoneheishi; // size = 0x2C4 extern const ActorInit En_Stone_heishi_InitVars; diff --git a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.h b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.h index 93e1f32ba..5c2b639ef 100644 --- a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.h +++ b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.h @@ -8,10 +8,10 @@ struct EnStopheishi; typedef void (*EnStopheishiActionFunc)(struct EnStopheishi*, PlayState*); typedef struct EnStopheishi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x110]; - /* 0x0254 */ EnStopheishiActionFunc actionFunc; - /* 0x0258 */ char unk_258[0x90]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x110]; + /* 0x254 */ EnStopheishiActionFunc actionFunc; + /* 0x258 */ char unk_258[0x90]; } EnStopheishi; // size = 0x2E8 extern const ActorInit En_Stop_heishi_InitVars; 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 8d370985d..3fed1f8f2 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -224,9 +224,9 @@ Actor* EnSuttari_GetActorById(PlayState* play, s16 actorId) { void EnSuttari_SetNextEntrance(PlayState* play, u16 nextEntranceIndex) { play->nextEntranceIndex = nextEntranceIndex; - play->unk_1887F = 0x40; - gSaveContext.nextTransition = 0x40; - play->sceneLoadFlag = 0x14; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_64; + play->transitionTrigger = TRANS_TRIGGER_START; } void EnSuttari_UpdateTime(void) { @@ -673,16 +673,14 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { } } -s32 func_80BABC48(EnSuttari* this, PlayState* play, ScheduleResult* scheduleResult) { +s32 func_80BABC48(EnSuttari* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp26 = SCHEDULE_TIME_NOW; - u16 pad1; - u8 sp23 = ENSUTTARI_GET_PATH(&this->actor); - u16 pad2; - s32 sp1C = D_80BAE8F8[scheduleResult->result]; u16 phi_a0; + u8 sp23 = ENSUTTARI_GET_PATH(&this->actor); + u16 tmp; - if (sp1C >= 0) { - this->timePath = SubS_GetAdditionalPath(play, sp23, sp1C); + if (D_80BAE8F8[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp23, D_80BAE8F8[scheduleOutput->result]); } if (this->timePath == NULL) { return 0; @@ -690,23 +688,23 @@ s32 func_80BABC48(EnSuttari* this, PlayState* play, ScheduleResult* scheduleResu if ((this->unk428 != 0 && this->unk428 < 0xC) && (this->timePathTimeSpeed >= 0)) { phi_a0 = sp26; } else { - phi_a0 = scheduleResult->time0; + phi_a0 = scheduleOutput->time0; } - if (scheduleResult->time1 < phi_a0) { - this->timePathTotalTime = (phi_a0 - scheduleResult->time1) + 0xFFFF; + if (scheduleOutput->time1 < phi_a0) { + this->timePathTotalTime = (phi_a0 - scheduleOutput->time1) + 0xFFFF; } else { - this->timePathTotalTime = scheduleResult->time1 - phi_a0; + this->timePathTotalTime = scheduleOutput->time1 - phi_a0; } this->timePathElapsedTime = sp26 - phi_a0; - phi_a0 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + tmp = phi_a0 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); this->unk42C = 0; - this->timePathWaypointTime = this->timePathTotalTime / phi_a0; + this->timePathWaypointTime = this->timePathTotalTime / tmp; this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk430 = 0; return 1; } -s32 func_80BABDD8(EnSuttari* this, PlayState* play, ScheduleResult* scheduleResult) { +s32 func_80BABDD8(EnSuttari* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 pad; EnDoor* sp48; u8 sp47 = ENSUTTARI_GET_PATH(&this->actor); @@ -720,7 +718,7 @@ s32 func_80BABDD8(EnSuttari* this, PlayState* play, ScheduleResult* scheduleResu return 0; } sp48 = (EnDoor*)SubS_FindNearestActor(&this->actor, play, ACTORCAT_DOOR, ACTOR_EN_DOOR); - sp24 = D_80BAE8F8[scheduleResult->result]; + sp24 = D_80BAE8F8[scheduleOutput->result]; if ((sp48 != NULL) && (sp24 >= 0)) { this->timePath = SubS_GetAdditionalPath(play, sp47, sp24); } @@ -730,9 +728,9 @@ s32 func_80BABDD8(EnSuttari* this, PlayState* play, ScheduleResult* scheduleResu sp28 = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp38, &sp28[0]); Math_Vec3s_ToVec3f(&sp2C, &sp28[1]); - this->unk434 = sp44 - scheduleResult->time0; - this->unk436 = scheduleResult->time1 - scheduleResult->time0; - if (scheduleResult->result != 10 && scheduleResult->result != 11) { + this->unk434 = sp44 - scheduleOutput->time0; + this->unk436 = scheduleOutput->time1 - scheduleOutput->time0; + if (scheduleOutput->result != 10 && scheduleOutput->result != 11) { sp48->unk_1A7 = 0x4B; } Math_Vec3f_Copy(&this->unk438, &sp38); @@ -742,15 +740,15 @@ s32 func_80BABDD8(EnSuttari* this, PlayState* play, ScheduleResult* scheduleResu return 1; } -s32 func_80BABF64(EnSuttari* this, PlayState* play, ScheduleResult* scheduleResult) { +s32 func_80BABF64(EnSuttari* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret; - switch (scheduleResult->result) { + switch (scheduleOutput->result) { case 15: case 14: case 13: case 12: - ret = func_80BABC48(this, play, scheduleResult); + ret = func_80BABC48(this, play, scheduleOutput); break; case 11: case 10: @@ -758,7 +756,7 @@ s32 func_80BABF64(EnSuttari* this, PlayState* play, ScheduleResult* scheduleResu case 8: case 7: case 6: - ret = func_80BABDD8(this, play, scheduleResult); + ret = func_80BABDD8(this, play, scheduleOutput); break; case 5: case 4: @@ -1020,7 +1018,8 @@ void func_80BACA14(EnSuttari* this, PlayState* play) { this->unk3F2 = this->headRot.y; this->actionFunc = func_80BACBB0; } - } else if ((player->transformation == PLAYER_FORM_HUMAN) && GET_CUR_EQUIP_VALUE(EQUIP_SWORD) != 0) { + } else if ((player->transformation == PLAYER_FORM_HUMAN) && + (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) != EQUIP_VALUE_SWORD_NONE)) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk3F2 = this->headRot.y; func_80BAAB78(this, play); @@ -1099,17 +1098,17 @@ void func_80BACE4C(EnSuttari* this, PlayState* play) { } void func_80BACEE0(EnSuttari* this, PlayState* play) { - ScheduleResult scheduleResult; + ScheduleOutput scheduleOutput; this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(play, D_80BAE820, &scheduleResult) || - ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, play, &scheduleResult))) { + if (!Schedule_RunScript(play, D_80BAE820, &scheduleOutput) || + ((this->unk428 != scheduleOutput.result) && !func_80BABF64(this, play, &scheduleOutput))) { this->actor.flags &= ~ACTOR_FLAG_1; - scheduleResult.result = 0; + scheduleOutput.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = scheduleResult.result; + this->unk428 = scheduleOutput.result; func_80BAC2FC(this, play); func_80BAB434(this); if (this->unk428 == 5) { @@ -1123,17 +1122,17 @@ void func_80BACEE0(EnSuttari* this, PlayState* play) { } void func_80BAD004(EnSuttari* this, PlayState* play) { - ScheduleResult scheduleResult; + ScheduleOutput scheduleOutput; this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(play, D_80BAE820, &scheduleResult) || - ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, play, &scheduleResult))) { + if (!Schedule_RunScript(play, D_80BAE820, &scheduleOutput) || + ((this->unk428 != scheduleOutput.result) && !func_80BABF64(this, play, &scheduleOutput))) { this->actor.flags &= ~ACTOR_FLAG_1; - scheduleResult.result = 0; + scheduleOutput.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = scheduleResult.result; + this->unk428 = scheduleOutput.result; func_80BAC2FC(this, play); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { Message_StartTextbox(play, 0x2A3A, &this->actor); @@ -1147,9 +1146,9 @@ void func_80BAD004(EnSuttari* this, PlayState* play) { void func_80BAD130(EnSuttari* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(play)) { + if (((talkState == TEXT_STATE_5) || (talkState == TEXT_STATE_DONE)) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; if (this->flags1 & 8) { this->actionFunc = func_80BAD004; } else if (this->flags1 & 4) { @@ -1178,7 +1177,7 @@ void func_80BAD230(EnSuttari* this, PlayState* play) { } void func_80BAD2B4(EnSuttari* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->textId == 0x2A30) { ActorCutscene_Stop(this->cutscenes[0]); ActorCutscene_SetIntentToPlay(this->cutscenes[1]); @@ -1186,7 +1185,7 @@ void func_80BAD2B4(EnSuttari* this, PlayState* play) { } else { ActorCutscene_Stop(this->cutscenes[1]); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->flags1 |= 0x40; this->actionFunc = func_80BAD380; } @@ -1204,13 +1203,13 @@ void func_80BAD380(EnSuttari* this, PlayState* play) { } else { this->flags1 &= ~0x8000; func_80BABA90(this, 1, 1); - if ((this->flags1 & 0x4000) && (talkState == 5) && Message_ShouldAdvance(play)) { + if ((this->flags1 & 0x4000) && (talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->flags2 &= ~0x10; player->stateFlags1 &= ~0x10000000; this->flags1 &= ~0x4000; ActorCutscene_Stop(this->cutscenes[1]); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->flags1 |= 0x40; } if (this->flags1 & 0x100) { @@ -1244,7 +1243,7 @@ void func_80BAD380(EnSuttari* this, PlayState* play) { } void func_80BAD5F8(EnSuttari* this, PlayState* play) { - ScheduleResult scheduleResult; + ScheduleOutput scheduleOutput; s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -1253,21 +1252,21 @@ void func_80BAD5F8(EnSuttari* this, PlayState* play) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(play, D_80BAE820, &scheduleResult) || - ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, play, &scheduleResult))) { + if (!Schedule_RunScript(play, D_80BAE820, &scheduleOutput) || + ((this->unk428 != scheduleOutput.result) && !func_80BABF64(this, play, &scheduleOutput))) { this->actor.flags &= ~ACTOR_FLAG_1; - scheduleResult.result = 0; + scheduleOutput.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = scheduleResult.result; + this->unk428 = scheduleOutput.result; func_80BAC2FC(this, play); if ((this->unk430 == 1) && (this->timePath->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } func_80BAB434(this); - if ((this->flags1 & 0x20) && (this->unk430 == 0) && (scheduleResult.result != 7)) { + if ((this->flags1 & 0x20) && (this->unk430 == 0) && (scheduleOutput.result != 7)) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { Message_StartTextbox(play, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; @@ -1279,7 +1278,7 @@ void func_80BAD5F8(EnSuttari* this, PlayState* play) { } void func_80BAD7F8(EnSuttari* this, PlayState* play) { - ScheduleResult scheduleResult; + ScheduleOutput scheduleOutput; s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -1291,20 +1290,20 @@ void func_80BAD7F8(EnSuttari* this, PlayState* play) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(play, D_80BAE820, &scheduleResult) || - ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, play, &scheduleResult))) { + if (!Schedule_RunScript(play, D_80BAE820, &scheduleOutput) || + ((this->unk428 != scheduleOutput.result) && !func_80BABF64(this, play, &scheduleOutput))) { this->actor.flags &= ~ACTOR_FLAG_1; - scheduleResult.result = 0; + scheduleOutput.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = scheduleResult.result; + this->unk428 = scheduleOutput.result; func_80BAC2FC(this, play); if ((this->unk430 == 1) && (this->timePath->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } - if ((this->flags1 & 0x20) && (scheduleResult.result != 9)) { + if ((this->flags1 & 0x20) && (scheduleOutput.result != 9)) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { Message_StartTextbox(play, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; @@ -1339,7 +1338,7 @@ void func_80BADA9C(EnSuttari* this, PlayState* play) { this->animationIndex = 1; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - if (talkstate == 5) { + if (talkstate == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { if (this->flags1 & 0x400) { if (this->textId == 0x29EE) { @@ -1351,7 +1350,7 @@ void func_80BADA9C(EnSuttari* this, PlayState* play) { this->flags2 &= ~1; } play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->textId = 0; if (this->flags1 & 1) { this->actionFunc = func_80BACA14; @@ -1362,7 +1361,7 @@ void func_80BADA9C(EnSuttari* this, PlayState* play) { } func_80BAAB78(this, play); } - } else if ((talkstate == 4) && Message_ShouldAdvance(play)) { + } else if ((talkstate == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index 1ffc67ae2..7bf39b6c2 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -14,40 +14,40 @@ typedef void (*EnSwActionFunc)(struct EnSw*, PlayState*); #define ENSW_GET_FF00(thisx) ((((thisx)->params & 0xFF00) >> 8) & 0xFF) typedef struct EnSw { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnSwActionFunc actionFunc; - /* 0x018C */ ColliderSphere collider; - /* 0x01E4 */ Path* unk_1E4; - /* 0x01E8 */ Vec3s jointTable[30]; - /* 0x029C */ Vec3s morphTable[30]; - /* 0x0350 */ Vec3f unk_350; - /* 0x035C */ Vec3f unk_35C; - /* 0x0368 */ Vec3f unk_368; - /* 0x0374 */ Vec3f unk_374; - /* 0x0380 */ Vec3f unk_380[12]; - /* 0x0410 */ u16 unk_410; - /* 0x0412 */ u8 drawDmgEffType; - /* 0x0414 */ f32 unk_414; - /* 0x0418 */ f32 drawDmgEffFrozenSteamScales[12]; - /* 0x0448 */ f32 unk_448; - /* 0x044C */ f32 unk_44C; - /* 0x0450 */ f32 unk_450; - /* 0x0454 */ s16 unk_454; - /* 0x0456 */ s16 unk_456; - /* 0x0458 */ s16 unk_458; - /* 0x045A */ s16 unk_45A; - /* 0x045C */ s16 unk_45C; - /* 0x045E */ s16 unk_45E; - /* 0x0460 */ s16 unk_460; - /* 0x0462 */ s16 unk_462; - /* 0x0464 */ s16 unk_464[12]; - /* 0x047C */ s16 unk_47C[12]; - /* 0x0494 */ s16 unk_494; - /* 0x0496 */ s16 unk_496; - /* 0x0498 */ s16 unk_498; - /* 0x049C */ s32 unk_49C; - /* 0x04A0 */ s32 unk_4A0; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnSwActionFunc actionFunc; + /* 0x18C */ ColliderSphere collider; + /* 0x1E4 */ Path* unk_1E4; + /* 0x1E8 */ Vec3s jointTable[30]; + /* 0x29C */ Vec3s morphTable[30]; + /* 0x350 */ Vec3f unk_350; + /* 0x35C */ Vec3f unk_35C; + /* 0x368 */ Vec3f unk_368; + /* 0x374 */ Vec3f unk_374; + /* 0x380 */ Vec3f unk_380[12]; + /* 0x410 */ u16 unk_410; + /* 0x412 */ u8 drawDmgEffType; + /* 0x414 */ f32 unk_414; + /* 0x418 */ f32 drawDmgEffFrozenSteamScales[12]; + /* 0x448 */ f32 unk_448; + /* 0x44C */ f32 unk_44C; + /* 0x450 */ f32 unk_450; + /* 0x454 */ s16 unk_454; + /* 0x456 */ s16 unk_456; + /* 0x458 */ s16 unk_458; + /* 0x45A */ s16 unk_45A; + /* 0x45C */ s16 unk_45C; + /* 0x45E */ s16 unk_45E; + /* 0x460 */ s16 unk_460; + /* 0x462 */ s16 unk_462; + /* 0x464 */ s16 unk_464[12]; + /* 0x47C */ s16 unk_47C[12]; + /* 0x494 */ s16 unk_494; + /* 0x496 */ s16 unk_496; + /* 0x498 */ s16 unk_498; + /* 0x49C */ s32 unk_49C; + /* 0x4A0 */ s32 unk_4A0; } EnSw; // size = 0x4A4 extern const ActorInit En_Sw_InitVars; diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c index 10dc40483..65b11055c 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c @@ -61,7 +61,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -225,7 +225,7 @@ void func_809CAAF8(EnSyatekiCrow* this) { this->unk_1C2 = 0; this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, 1, -3.0f); + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); this->actor.bgCheckFlags &= ~1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); 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 a615b7b52..3a1409e10 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 @@ -267,11 +267,11 @@ void func_809C6A04(EnSyatekiMan* this, PlayState* play) { this->unk_26A = 3; } else { func_8019F208(); - func_801159EC(-20); + Rupees_ChangeBy(-20); gSaveContext.save.weekEventReg[63] |= 1; gSaveContext.save.weekEventReg[63] &= (u8)~2; play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_26A = 7; player->stateFlags1 |= 0x20; this->actionFunc = func_809C7FFC; @@ -320,7 +320,7 @@ void func_809C6C2C(EnSyatekiMan* this, PlayState* play) { case 0xA2C: case 0xA35: play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; player->actor.freezeTimer = 0; func_80112AFC(play); play->interfaceCtx.hbaAmmo = 80; @@ -353,7 +353,7 @@ void func_809C6C2C(EnSyatekiMan* this, PlayState* play) { case 0xA34: play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; player->actor.freezeTimer = 0; gSaveContext.minigameState = 3; player->stateFlags1 |= 0x20; @@ -372,23 +372,23 @@ void func_809C6E30(EnSyatekiMan* this, PlayState* play) { } switch (Message_GetState(&play->msgCtx)) { - case 2: + case TEXT_STATE_CLOSING: this->actionFunc = func_809C6848; this->unk_26A = 0; break; - case 4: + case TEXT_STATE_CHOICE: func_809C6A04(this, play); break; - case 5: + case TEXT_STATE_5: func_809C6C2C(this, play); break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; player->stateFlags1 &= ~0x20; gSaveContext.save.weekEventReg[63] &= (u8)~1; gSaveContext.save.weekEventReg[63] &= (u8)~2; @@ -397,13 +397,13 @@ void func_809C6E30(EnSyatekiMan* this, PlayState* play) { } break; - case 0: - case 1: - case 3: - case 7: - case 8: - case 9: - case 10: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_3: + case TEXT_STATE_7: + case TEXT_STATE_8: + case TEXT_STATE_9: + case TEXT_STATE_10: break; } @@ -546,7 +546,7 @@ void func_809C7380(EnSyatekiMan* this, PlayState* play) { this->unk_26A = 3; } else { func_8019F208(); - func_801159EC(-20); + Rupees_ChangeBy(-20); this->unk_26A = 2; if (!(this->unk_282 & 0x10)) { this->unk_282 |= 0x10; @@ -628,7 +628,7 @@ void func_809C7620(EnSyatekiMan* this, PlayState* play) { } } else { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; player->actor.freezeTimer = 0; this->unk_26A = 7; player->stateFlags1 |= 0x20; @@ -641,7 +641,7 @@ void func_809C7620(EnSyatekiMan* this, PlayState* play) { case 0x3FE: case 0x400: play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; player->actor.freezeTimer = 0; this->unk_27E = 0; func_80112AFC(play); @@ -688,7 +688,7 @@ void func_809C7620(EnSyatekiMan* this, PlayState* play) { case 0x406: case 0x407: play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; player->actor.freezeTimer = 0; gSaveContext.minigameState = 3; this->actionFunc = func_809C7D14; @@ -706,20 +706,20 @@ void func_809C7990(EnSyatekiMan* this, PlayState* play) { } switch (Message_GetState(&play->msgCtx)) { - case 2: + case TEXT_STATE_CLOSING: this->actionFunc = func_809C72D8; this->unk_26A = 0; break; - case 4: + case TEXT_STATE_CHOICE: func_809C7380(this, play); break; - case 5: + case TEXT_STATE_5: func_809C7620(this, play); break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { gSaveContext.save.weekEventReg[63] &= (u8)~1; gSaveContext.save.weekEventReg[63] &= (u8)~2; @@ -729,13 +729,13 @@ void func_809C7990(EnSyatekiMan* this, PlayState* play) { } break; - case 0: - case 1: - case 3: - case 7: - case 8: - case 9: - case 10: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_3: + case TEXT_STATE_7: + case TEXT_STATE_8: + case TEXT_STATE_9: + case TEXT_STATE_10: break; } } @@ -831,7 +831,7 @@ void func_809C7EB4(EnSyatekiMan* this, PlayState* play) { Player* player = GET_PLAYER(play); if (CURRENT_DAY != 3) { - if ((Message_GetState(&play->msgCtx) == 6) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { player->stateFlags1 &= ~0x20; this->unk_280 = 0; this->unk_26A = 0; diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h index c2f02c068..1719f8161 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h @@ -17,36 +17,36 @@ typedef struct { /* 0x08 */ f32 y; /* 0x0C */ f32 z; /* 0x10 */ s32 variable; -} EnSyatekiManUnkStruct; +} EnSyatekiManUnkStruct; // size = 0x14 typedef struct EnSyatekiMan { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnSyatekiManActionFunc actionFunc; - /* 0x018C */ Path* path; - /* 0x0190 */ s32 unk_190; - /* 0x0194 */ s32 unk_194; - /* 0x0198 */ Vec3s jointTable[BURLY_GUY_LIMB_MAX]; - /* 0x01F8 */ Vec3s morphTable[BURLY_GUY_LIMB_MAX]; - /* 0x0258 */ Vec3s unk_258; - /* 0x025E */ Vec3s unk_25E; - /* 0x0264 */ s16 eyeIndex; - /* 0x0266 */ s16 blinkTimer; - /* 0x0268 */ UNK_TYPE1 unk268[0x2]; - /* 0x026A */ s16 unk_26A; - /* 0x026C */ s16 unk_26C; - /* 0x026E */ s16 unk_26E; - /* 0x0270 */ s16 unk_270; - /* 0x0272 */ s16 unk_272; - /* 0x0274 */ s16 unk_274; - /* 0x0276 */ s16 unk_276; - /* 0x0278 */ s16 unk_278; - /* 0x027A */ s16 unk_27A; - /* 0x027C */ s16 unk_27C; - /* 0x027E */ s16 unk_27E; - /* 0x0280 */ s16 unk_280; - /* 0x0282 */ s16 unk_282; - /* 0x0284 */ s16 unk_284; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnSyatekiManActionFunc actionFunc; + /* 0x18C */ Path* path; + /* 0x190 */ s32 unk_190; + /* 0x194 */ s32 unk_194; + /* 0x198 */ Vec3s jointTable[BURLY_GUY_LIMB_MAX]; + /* 0x1F8 */ Vec3s morphTable[BURLY_GUY_LIMB_MAX]; + /* 0x258 */ Vec3s unk_258; + /* 0x25E */ Vec3s unk_25E; + /* 0x264 */ s16 eyeIndex; + /* 0x266 */ s16 blinkTimer; + /* 0x268 */ UNK_TYPE1 unk268[0x2]; + /* 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 */ s16 unk_276; + /* 0x278 */ s16 unk_278; + /* 0x27A */ s16 unk_27A; + /* 0x27C */ s16 unk_27C; + /* 0x27E */ s16 unk_27E; + /* 0x280 */ s16 unk_280; + /* 0x282 */ s16 unk_282; + /* 0x284 */ s16 unk_284; } EnSyatekiMan; // size = 0x288 extern const ActorInit En_Syateki_Man_InitVars; diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c index 56abe8814..e40cc9570 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c @@ -73,7 +73,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index f79639543..7d2bbb9bb 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -261,7 +261,7 @@ void func_80BE09A8(EnTab* this, PlayState* play) { void func_80BE0A98(EnTab* this, PlayState* play) { Player* player = GET_PLAYER(play); - s32 sp20 = Message_GetState(&play->msgCtx); + s32 talkState = Message_GetState(&play->msgCtx); this->unk_308 += (this->unk_304 != 0.0f) ? 40.0f : -40.0f; this->unk_308 = CLAMP(this->unk_308, 0.0f, 80.0f); @@ -269,8 +269,8 @@ void func_80BE0A98(EnTab* this, PlayState* play) { Matrix_Translate(this->unk_308, 0.0f, 0.0f, MTXMODE_APPLY); if ((&this->actor == player->targetActor) && - ((play->msgCtx.currentTextId < 0xFF) || (play->msgCtx.currentTextId > 0x200)) && (sp20 == 3) && - (this->unk_334 == 3)) { + ((play->msgCtx.currentTextId < 0xFF) || (play->msgCtx.currentTextId > 0x200)) && (talkState == TEXT_STATE_3) && + (this->prevTalkState == TEXT_STATE_3)) { if ((play->state.frames % 2) == 0) { if (this->unk_304 != 0.0f) { this->unk_304 = 0.0f; @@ -281,7 +281,7 @@ void func_80BE0A98(EnTab* this, PlayState* play) { } else { this->unk_304 = 0.0f; } - this->unk_334 = sp20; + this->prevTalkState = talkState; } s32 func_80BE0C04(EnTab* this, Actor* actor, f32 arg2) { @@ -314,7 +314,7 @@ s32 func_80BE0C04(EnTab* this, Actor* actor, f32 arg2) { } s32 func_80BE0D38(EnTab* this, PlayState* play) { - return Interface_HasEmptyBottle(); + return Inventory_HasEmptyBottle(); } s32 func_80BE0D60(EnTab* this, PlayState* play) { @@ -366,7 +366,7 @@ s32* func_80BE0E04(EnTab* this, PlayState* play) { return NULL; } -s32 func_80BE0F04(EnTab* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BE0F04(EnTab* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; EnGm* sp28 = func_80BE04E0(this, play, ACTORCAT_NPC, ACTOR_EN_GM); @@ -385,7 +385,7 @@ s32 func_80BE0F04(EnTab* this, PlayState* play, ScheduleResult* arg2) { return ret; } -s32 func_80BE0FC4(EnTab* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BE0FC4(EnTab* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BE1B04); @@ -399,18 +399,18 @@ s32 func_80BE0FC4(EnTab* this, PlayState* play, ScheduleResult* arg2) { return true; } -s32 func_80BE1060(EnTab* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80BE1060(EnTab* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret; this->unk_2FC = 0; - switch (arg2->result) { + switch (scheduleOutput->result) { case 1: - ret = func_80BE0F04(this, play, arg2); + ret = func_80BE0F04(this, play, scheduleOutput); break; case 2: - ret = func_80BE0FC4(this, play, arg2); + ret = func_80BE0FC4(this, play, scheduleOutput); break; default: @@ -472,7 +472,7 @@ void func_80BE1224(EnTab* this, PlayState* play) { } void func_80BE127C(EnTab* this, PlayState* play) { - ScheduleResult sp18; + ScheduleOutput sp18; this->unk_31A = REG(15) + ((void)0, gSaveContext.save.daySpeed); @@ -581,7 +581,7 @@ void EnTab_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, } } -void EnTab_TransformDraw(PlayState* play, s32 limbIndex, Actor* thisx) { +void EnTab_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnTab* this = THIS; s32 rotStep; s32 overrideStep; @@ -624,7 +624,7 @@ void EnTab_Draw(Actor* thisx, PlayState* play) { SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTab_OverrideLimbDraw, EnTab_PostLimbDraw, - EnTab_TransformDraw, &this->actor); + EnTab_TransformLimbDraw, &this->actor); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.h b/src/overlays/actors/ovl_En_Tab/z_en_tab.h index 3e06c0b2a..81ce92006 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.h +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.h @@ -10,39 +10,39 @@ typedef void (*EnTabActionFunc)(struct EnTab*, PlayState*); typedef s32 (*EnTabUnkFunc)(struct EnTab*, PlayState*); typedef struct EnTab { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnTabActionFunc actionFunc; - /* 0x018C */ ColliderCylinder collider; - /* 0x01D8 */ u8 unk_1D8; - /* 0x01DC */ s32 unk_1DC; - /* 0x01E0 */ Actor* unk_1E0; - /* 0x01E4 */ EnGm* unk_1E4; - /* 0x01E8 */ Vec3f unk_1E8[2]; - /* 0x0200 */ Vec3s unk_200[2]; - /* 0x020C */ Vec3s jointTable[20]; - /* 0x0284 */ Vec3s morphTable[20]; - /* 0x02FC */ u16 unk_2FC; - /* 0x0300 */ f32 unk_300; - /* 0x0304 */ f32 unk_304; - /* 0x0308 */ f32 unk_308; - /* 0x030C */ s16 unk_30C; - /* 0x030E */ UNK_TYPE1 unk30E[4]; - /* 0x0312 */ s16 unk_312; - /* 0x0314 */ s16 unk_314; - /* 0x0316 */ s16 unk_316; - /* 0x0318 */ s16 unk_318; - /* 0x031A */ s16 unk_31A; - /* 0x031C */ s16 unk_31C; - /* 0x031E */ s16 unk_31E; - /* 0x0320 */ s16 unk_320; - /* 0x0322 */ s16 unk_322; - /* 0x0324 */ s16 unk_324; - /* 0x0328 */ EnTabUnkFunc unk_328; - /* 0x032C */ s32 unk_32C; - /* 0x0330 */ UNK_TYPE1 unk330[4]; - /* 0x0334 */ s32 unk_334; - /* 0x0338 */ s32 unk_338; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnTabActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ u8 unk_1D8; + /* 0x1DC */ s32 unk_1DC; + /* 0x1E0 */ Actor* unk_1E0; + /* 0x1E4 */ EnGm* unk_1E4; + /* 0x1E8 */ Vec3f unk_1E8[2]; + /* 0x200 */ Vec3s unk_200[2]; + /* 0x20C */ Vec3s jointTable[20]; + /* 0x284 */ Vec3s morphTable[20]; + /* 0x2FC */ u16 unk_2FC; + /* 0x300 */ f32 unk_300; + /* 0x304 */ f32 unk_304; + /* 0x308 */ f32 unk_308; + /* 0x30C */ s16 unk_30C; + /* 0x30E */ UNK_TYPE1 unk30E[4]; + /* 0x312 */ s16 unk_312; + /* 0x314 */ s16 unk_314; + /* 0x316 */ s16 unk_316; + /* 0x318 */ s16 unk_318; + /* 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 */ EnTabUnkFunc unk_328; + /* 0x32C */ s32 unk_32C; + /* 0x330 */ UNK_TYPE1 unk330[4]; + /* 0x334 */ s32 prevTalkState; + /* 0x338 */ s32 unk_338; } EnTab; // size = 0x33C extern const ActorInit En_Tab_InitVars; diff --git a/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c b/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c index 3b94c70cf..db6a9d172 100644 --- a/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c +++ b/src/overlays/actors/ovl_En_Tag_Obj/z_en_tag_obj.c @@ -49,7 +49,7 @@ const ActorInit En_Tag_Obj_InitVars = { void EnTagObj_Init(Actor* thisx, PlayState* play) { EnTagObj* this = THIS; - this->hasSpawnedSeahorse = 0; + this->hasSpawnedSeahorse = false; } void EnTagObj_Destroy(Actor* thisx, PlayState* play) { @@ -61,6 +61,6 @@ void EnTagObj_Update(Actor* thisx, PlayState* play) { if (!this->hasSpawnedSeahorse) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_OT, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); - this->hasSpawnedSeahorse = 1; + this->hasSpawnedSeahorse = true; } } diff --git a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.h b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.h index f81e7d697..cc707f027 100644 --- a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.h +++ b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.h @@ -8,10 +8,10 @@ struct EnTakaraya; typedef void (*EnTakarayaActionFunc)(struct EnTakaraya*, PlayState*); typedef struct EnTakaraya { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x164]; - /* 0x02A8 */ EnTakarayaActionFunc actionFunc; - /* 0x02AC */ char unk_2AC[0x10]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x164]; + /* 0x2A8 */ EnTakarayaActionFunc actionFunc; + /* 0x2AC */ char unk_2AC[0x10]; } EnTakaraya; // size = 0x2BC extern const ActorInit En_Takaraya_InitVars; 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 38ac58764..393a457b5 100644 --- a/src/overlays/actors/ovl_En_Talk/z_en_talk.h +++ b/src/overlays/actors/ovl_En_Talk/z_en_talk.h @@ -10,8 +10,8 @@ struct EnTalk; typedef void (*EnTalkActionFunc)(struct EnTalk*, PlayState*); typedef struct EnTalk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnTalkActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTalkActionFunc actionFunc; } EnTalk; // size = 0x148 extern const ActorInit En_Talk_InitVars; 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 042ac0f95..fff6d29fa 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 @@ -609,7 +609,7 @@ void EnTalkGibud_Dead(EnTalkGibud* this, PlayState* play) { void EnTalkGibud_SetupRevive(EnTalkGibud* this) { Animation_Change(&this->skelAnime, &gGibdoRedeadDeathAnim, -1.0f, Animation_GetLastFrame(&gGibdoRedeadDeathAnim), - 0.0f, 2, -8.0f); + 0.0f, ANIMMODE_ONCE, -8.0f); this->actor.flags |= ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_REVERSE); this->deathTimer = 0; @@ -714,7 +714,7 @@ s32 EnTalkGibud_PresentedItemMatchesRequest(EnTalkGibud* this, PlayState* play, return EN_TALK_GIBUD_REQUESTED_ITEM_NOT_ENOUGH_AMMO; } } - if (Interface_HasItemInBottle(requestedItem->item)) { + if (Inventory_HasItemInBottle(requestedItem->item)) { return EN_TALK_GIBUD_REQUESTED_ITEM_MET; } } @@ -796,31 +796,31 @@ void EnTalkGibud_Talk(EnTalkGibud* this, PlayState* play) { EnTalkGibudRequestedItem* requestedItem; switch (Message_GetState(&play->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: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: + case TEXT_STATE_7: + case TEXT_STATE_8: + case TEXT_STATE_9: + case TEXT_STATE_10: + case TEXT_STATE_11: + case TEXT_STATE_12: + case TEXT_STATE_13: break; - case 5: + case TEXT_STATE_5: EnTalkGibud_GetNextTextBoxId(this, play); break; - case 6: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { 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); + Inventory_ChangeAmmo(requestedItem->item, -requestedItem->amount); } else { func_80123D50(play, player, ITEM_BOTTLE, PLAYER_AP_BOTTLE); } @@ -834,7 +834,7 @@ void EnTalkGibud_Talk(EnTalkGibud* this, PlayState* play) { } break; - case 16: + case TEXT_STATE_16: EnTalkGibud_CheckPresentedItem(this, play); break; } diff --git a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c index cbc467097..d45cc854c 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c @@ -150,9 +150,9 @@ void EnTanron1_Update(Actor* thisx, PlayState* play) { } if ((player->itemActionParam == 7) && (player->unk_B28 != 0)) { - this->unk_14C.x = player->swordInfo[0].tip.x; - this->unk_14C.y = player->swordInfo[0].tip.y; - this->unk_14C.z = player->swordInfo[0].tip.z; + this->unk_14C.x = player->meleeWeaponInfo[0].tip.x; + this->unk_14C.y = player->meleeWeaponInfo[0].tip.y; + this->unk_14C.z = player->meleeWeaponInfo[0].tip.z; this->unk_158 = 0x5000; this->unk_15C = 50.0f; @@ -207,8 +207,8 @@ void func_80BB5318(EnTanron1* this, PlayState* play) { f32 temp_f30 = this->unk_15C; if (player->unk_ADC != 0) { - phi_s2 = &player->swordInfo[0].tip; - if (player->swordAnimation >= 30) { + phi_s2 = &player->meleeWeaponInfo[0].tip; + if (player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H) { phi_f28 = 2500.0f; } else { phi_f28 = 400.0f; diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c index 5f6d54b07..4f19b73a8 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -594,7 +594,7 @@ void EnTanron2_Draw(Actor* thisx, PlayState* play2) { func_8012C2DC(play->state.gfxCtx); - gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_003450); + gSPDisplayList(POLY_XLU_DISP++, gWartBubbleMaterialDL); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 150); tanron2 = play->actorCtx.actorLists[ACTORCAT_BOSS].first; @@ -633,14 +633,14 @@ void EnTanron2_Draw(Actor* thisx, PlayState* play2) { Matrix_RotateZS(-D_80BB8458[i]->unk_14A, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_0034C8); + gSPDisplayList(POLY_XLU_DISP++, gWartBubbleModelDL); } } func_8012C448(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 150); - gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004510); + gSPDisplayList(POLY_XLU_DISP++, gWartShadowMaterialDL); tanron2 = play->actorCtx.actorLists[ACTORCAT_BOSS].first; while (tanron2 != NULL) { @@ -649,7 +649,7 @@ void EnTanron2_Draw(Actor* thisx, PlayState* play2) { Matrix_Scale(0.6f, 0.0f, 0.6f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004550); + gSPDisplayList(POLY_XLU_DISP++, gWartShadowModelDL); } tanron2 = tanron2->next; } @@ -670,7 +670,7 @@ void EnTanron2_Draw(Actor* thisx, PlayState* play2) { Matrix_Scale(D_80BB8454, 0.0f, D_80BB8454, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0377B0); + gSPDisplayList(POLY_XLU_DISP++, gEffWaterRippleDL); } tanron2 = tanron2->next; } diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h index 1bbb3ad2e..efbcc3108 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h @@ -8,24 +8,24 @@ struct EnTanron2; typedef void (*EnTanron2ActionFunc)(struct EnTanron2*, PlayState*); typedef struct EnTanron2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnTanron2ActionFunc actionFunc; - /* 0x0148 */ s16 unk_148; - /* 0x014A */ s16 unk_14A; - /* 0x014C */ s16 unk_14C; - /* 0x014E */ s16 unk_14E; - /* 0x0150 */ s16 unk_150; - /* 0x0152 */ s16 unk_152; - /* 0x0154 */ s16 unk_154; - /* 0x0156 */ s16 unk_156; - /* 0x0158 */ u8 unk_158; - /* 0x0159 */ u8 unk_159; - /* 0x015A */ u8 unk_15A; - /* 0x015B */ u8 unk_15B; - /* 0x015C */ f32 unk_15C; - /* 0x0160 */ f32 unk_160; - /* 0x0164 */ ColliderCylinder collider1; - /* 0x01B0 */ ColliderCylinder collider2; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTanron2ActionFunc actionFunc; + /* 0x148 */ s16 unk_148; + /* 0x14A */ s16 unk_14A; + /* 0x14C */ s16 unk_14C; + /* 0x14E */ s16 unk_14E; + /* 0x150 */ s16 unk_150; + /* 0x152 */ s16 unk_152; + /* 0x154 */ s16 unk_154; + /* 0x156 */ s16 unk_156; + /* 0x158 */ u8 unk_158; + /* 0x159 */ u8 unk_159; + /* 0x15A */ u8 unk_15A; + /* 0x15B */ u8 unk_15B; + /* 0x15C */ f32 unk_15C; + /* 0x160 */ f32 unk_160; + /* 0x164 */ ColliderCylinder collider1; + /* 0x1B0 */ ColliderCylinder collider2; } EnTanron2; // size = 0x1FC extern const ActorInit En_Tanron2_InitVars; diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h index 576309694..9f9e47021 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h @@ -15,14 +15,14 @@ struct EnTanron5; typedef struct EnTanron5 { /* 0x000 */ Actor actor; - /* 0x0144 */ s16 unk_144; - /* 0x0148 */ Gfx* unk_148; - /* 0x014C */ ColliderCylinder collider; - /* 0x0198 */ s16 unk_198; - /* 0x019A */ s16 unk_19A; - /* 0x019C */ f32 unk_19C; - /* 0x01A0 */ u8 unk_1A0; - /* 0x01A1 */ u8 unk_1A1; + /* 0x144 */ s16 unk_144; + /* 0x148 */ Gfx* unk_148; + /* 0x14C */ ColliderCylinder collider; + /* 0x198 */ s16 unk_198; + /* 0x19A */ s16 unk_19A; + /* 0x19C */ f32 unk_19C; + /* 0x1A0 */ u8 unk_1A0; + /* 0x1A1 */ u8 unk_1A1; } EnTanron5; // size = 0x1A4 extern const ActorInit En_Tanron5_InitVars; diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.h b/src/overlays/actors/ovl_En_Test/z_en_test.h index bcb0c4a1e..e01c44c6a 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.h +++ b/src/overlays/actors/ovl_En_Test/z_en_test.h @@ -21,7 +21,7 @@ typedef struct EnTest { /* 0x144 */ SkeletonInfo skeletonInfo; /* 0x174 */ s32 unk_174; /* 0x178 */ Vec3s unk_178[12]; - /* 0x1C0 */ s16 unk_1C0[36]; + /* 0x1C0 */ Vec3s unk_1C0[12]; /* 0x208 */ u8 unk_208; /* 0x209 */ u8 unk_209; /* 0x20A */ u8 unk_20A; diff --git a/src/overlays/actors/ovl_En_Test3/z_en_test3.h b/src/overlays/actors/ovl_En_Test3/z_en_test3.h index a2731c795..9d902bad1 100644 --- a/src/overlays/actors/ovl_En_Test3/z_en_test3.h +++ b/src/overlays/actors/ovl_En_Test3/z_en_test3.h @@ -8,10 +8,10 @@ struct EnTest3; typedef void (*EnTest3ActionFunc)(struct EnTest3*, PlayState*); typedef struct EnTest3 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x628]; - /* 0x076C */ EnTest3ActionFunc actionFunc; - /* 0x0770 */ char unk_770[0x648]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x628]; + /* 0x76C */ EnTest3ActionFunc actionFunc; + /* 0x770 */ char unk_770[0x648]; } EnTest3; // size = 0xDB8 extern const ActorInit En_Test3_InitVars; diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 6895ee112..ef8224453 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -368,8 +368,8 @@ void EnTest4_Destroy(Actor* thisx, PlayState* play) { void func_80A42AB8(EnTest4* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((play->unk_18B4A == 0) && !Play_InCsMode(play) && (play->numSetupActors <= 0) && (play->roomCtx.unk31 == 0) && - (!Play_IsDebugCamEnabled())) { + if ((play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play) && (play->numSetupActors <= 0) && + (play->roomCtx.unk31 == 0) && !Play_IsDebugCamEnabled()) { s16 temp_a2; u16 temp_a0 = D_80A43364[this->unk_144]; s16 temp_a3; @@ -398,7 +398,7 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { func_80A41FA4(this, play); } else { gSaveContext.screenScale = 0.0f; - Play_SetRespawnData(&play->state, RESTART_MODE_DOWN, Entrance_CreateIndexFromSpawn(0), + Play_SetRespawnData(&play->state, RESPAWN_MODE_DOWN, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); func_80169EFC(&play->state); if (player->stateFlags1 & 0x800000) { @@ -447,7 +447,7 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { } else { playerParams = 0xBFF; } - Play_SetRespawnData(&play->state, RESTART_MODE_RETURN, entranceIndex, player->unk_3CE, playerParams, + Play_SetRespawnData(&play->state, RESPAWN_MODE_RETURN, entranceIndex, player->unk_3CE, playerParams, &player->unk_3C0, player->unk_3CC); if ((play->sceneNum == SCENE_TENMON_DAI) || (play->sceneNum == SCENE_00KEIKOKU)) { @@ -456,8 +456,8 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { play->nextEntranceIndex = 0xD800; } gSaveContext.nextCutsceneIndex = 0xFFF1; - play->sceneLoadFlag = 0x14; - play->unk_1887F = 2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; player->stateFlags1 |= 0x200; Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.h b/src/overlays/actors/ovl_En_Test4/z_en_test4.h index e26331ed5..5f39f9f56 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.h +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.h @@ -8,14 +8,14 @@ struct EnTest4; typedef void (*EnTest4ActionFunc)(struct EnTest4*, PlayState*); typedef struct EnTest4 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ s8 unk_144; // 0 on night, 1 on day - /* 0x0145 */ u8 transitionCsTimer; - /* 0x0146 */ u16 unk_146; - /* 0x0148 */ u16 nextBellTime; // Next time the bell will sound - /* 0x014A */ u16 lastBellTime; // Last time the bell sounded - /* 0x014C */ u8 state; - /* 0x0150 */ EnTest4ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s8 unk_144; // 0 on night, 1 on day + /* 0x145 */ u8 transitionCsTimer; + /* 0x146 */ u16 unk_146; + /* 0x148 */ u16 nextBellTime; // Next time the bell will sound + /* 0x14A */ u16 lastBellTime; // Last time the bell sounded + /* 0x14C */ u8 state; + /* 0x150 */ EnTest4ActionFunc actionFunc; } EnTest4; // size = 0x154 typedef enum { diff --git a/src/overlays/actors/ovl_En_Test5/z_en_test5.h b/src/overlays/actors/ovl_En_Test5/z_en_test5.h index 6481e254b..bcfcd98e3 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.h +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.h @@ -10,11 +10,11 @@ struct EnTest5; // SpringWaterModifier typedef void (*EnTest5ActionFunc)(struct EnTest5*, PlayState*); typedef struct EnTest5 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ Vec3f minPos; - /* 0x0150 */ f32 xLength; - /* 0x0154 */ f32 zLength; - /* 0x0158 */ EnTest5ActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ Vec3f minPos; + /* 0x150 */ f32 xLength; + /* 0x154 */ f32 zLength; + /* 0x158 */ EnTest5ActionFunc actionFunc; } EnTest5; // size = 0x15C extern const ActorInit En_Test5_InitVars; diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 91632c680..7d26a6fb8 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -96,7 +96,7 @@ Color_RGB8 D_80A94050 = { 0, 0, 0 }; s16 D_80A94054 = 500; s16 D_80A94058 = 1500; -Vec3f D_80A9405C = { 0.0f, 1.0f, 0.0f }; +static Vec3f sSubCamUp = { 0.0f, 1.0f, 0.0f }; Color_RGB8 D_80A94068 = { 225, 230, 225 }; Color_RGB8 D_80A9406C = { 120, 120, 100 }; @@ -359,7 +359,7 @@ void func_80A9156C(EnTest6* this, PlayState* play) { ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); } else { ActorCutscene_Start(play->playerActorCsIds[8], NULL); - this->unk_284 = ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8]); + this->subCamId = ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8]); EnTest6_SetupAction(this, func_80A91760); } break; @@ -369,7 +369,7 @@ void func_80A9156C(EnTest6* this, PlayState* play) { ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); } else { ActorCutscene_Start(play->playerActorCsIds[8], NULL); - this->unk_284 = ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8]); + this->subCamId = ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8]); EnTest6_SetupAction(this, func_80A92188); } break; @@ -410,15 +410,15 @@ void func_80A91760(EnTest6* this, PlayState* play) { Input* input = CONTROLLER1(&play->state); s16 temp_s0; Player* player = GET_PLAYER(play); - Camera* sp78; - Vec3f sp6C; - Vec3f sp60; + Camera* mainCam; + Vec3f subCamAt; + Vec3f subCamEye; Vec3f sp54; s32 i; f32 sp4C; - Camera* temp_s3 = Play_GetCamera(play, this->unk_284); + Camera* subCam = Play_GetCamera(play, this->subCamId); - sp78 = Play_GetCamera(play, CAM_ID_MAIN); + mainCam = Play_GetCamera(play, CAM_ID_MAIN); switch (this->unk_274) { case 90: @@ -459,12 +459,12 @@ void func_80A91760(EnTest6* this, PlayState* play) { this->unk_254 = ZeldaArena_Malloc(sizeof(Vec3f) * 64); if (this->unk_254 != NULL) { for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { - (*this->unk_254)[i].x = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + temp_s3->eye.x + - ((temp_s3->at.x - temp_s3->eye.x) * 0.2f); - (*this->unk_254)[i].y = (((2.0f * Rand_ZeroOne()) - 1.0f) * 120.0f) + temp_s3->eye.y + - ((temp_s3->at.y - temp_s3->eye.y) * 0.2f) + sp4C; - (*this->unk_254)[i].z = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + temp_s3->eye.z + - ((temp_s3->at.z - temp_s3->eye.z) * 0.2f); + (*this->unk_254)[i].x = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + subCam->eye.x + + ((subCam->at.x - subCam->eye.x) * 0.2f); + (*this->unk_254)[i].y = (((2.0f * Rand_ZeroOne()) - 1.0f) * 120.0f) + subCam->eye.y + + ((subCam->at.y - subCam->eye.y) * 0.2f) + sp4C; + (*this->unk_254)[i].z = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + subCam->eye.z + + ((subCam->at.z - subCam->eye.z) * 0.2f); } } func_80A90C08(0x78); @@ -562,29 +562,29 @@ void func_80A91760(EnTest6* this, PlayState* play) { } if (this->unk_27A > 80) { - temp_s3->fov += (90.0f - temp_s3->fov) / (this->unk_27A - 80); + subCam->fov += (90.0f - subCam->fov) / (this->unk_27A - 80); } else if (this->unk_27A > 60) { sp4C = 1.0f / (this->unk_27A - 60); - sp6C.x = temp_s3->at.x + ((player->actor.world.pos.x - temp_s3->at.x) * sp4C); - sp6C.y = temp_s3->at.y + (((player->actor.focus.pos.y - temp_s3->at.y) - 20.0f) * sp4C); - sp6C.z = temp_s3->at.z + ((player->actor.world.pos.z - temp_s3->at.z) * sp4C); + subCamAt.x = subCam->at.x + ((player->actor.world.pos.x - subCam->at.x) * sp4C); + subCamAt.y = subCam->at.y + (((player->actor.focus.pos.y - subCam->at.y) - 20.0f) * sp4C); + subCamAt.z = subCam->at.z + ((player->actor.world.pos.z - subCam->at.z) * sp4C); - sp54.x = (Math_SinS(player->actor.world.rot.y) * 80.0f) + sp6C.x; - sp54.y = sp6C.y + 20.0f; - sp54.z = (Math_CosS(player->actor.world.rot.y) * 80.0f) + sp6C.z; + sp54.x = (Math_SinS(player->actor.world.rot.y) * 80.0f) + subCamAt.x; + sp54.y = subCamAt.y + 20.0f; + sp54.z = (Math_CosS(player->actor.world.rot.y) * 80.0f) + subCamAt.z; sp4C *= 0.75f; - VEC3F_LERPIMPDST(&sp60, &temp_s3->eye, &sp54, sp4C); + VEC3F_LERPIMPDST(&subCamEye, &subCam->eye, &sp54, sp4C); - Play_CameraSetAtEye(play, this->unk_284, &sp6C, &sp60); + Play_CameraSetAtEye(play, this->subCamId, &subCamAt, &subCamEye); } else if ((this->unk_27A < 11) && (this->unk_27A > 0)) { - temp_s3->fov += (sp78->fov - temp_s3->fov) / this->unk_27A; + subCam->fov += (mainCam->fov - subCam->fov) / this->unk_27A; } if (this->unk_286 != 0) { func_80A90C54(play, this->unk_286 * 0.05f); - temp_s3->fov += (sp78->fov - temp_s3->fov) * 0.05f; + subCam->fov += (mainCam->fov - subCam->fov) * 0.05f; this->unk_286++; if (this->unk_286 >= 20) { this->unk_27A = 1; @@ -630,10 +630,10 @@ void func_80A92118(EnTest6* this, PlayState* play) { void func_80A92188(EnTest6* this, PlayState* play) { Input* input = CONTROLLER1(&play->state); Player* player = GET_PLAYER(play); - Camera* camera; + Camera* subCam; s32 pad; - s16 sp46; - s16 sp44; + s16 subCamId; + s16 pad2; if (this->unk_27A > 115) { this->unk_160 += 0.2f; @@ -736,23 +736,23 @@ void func_80A92188(EnTest6* this, PlayState* play) { func_80A92950(this, play); if (this->unk_27A == 115) { - sp44 = ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8]); - camera = Play_GetCamera(play, sp44); + subCamId = ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8]); + subCam = Play_GetCamera(play, subCamId); - this->unk_258 = camera->at; - this->unk_264 = camera->eye; - this->unk_270 = camera->fov; - func_8016119C(camera, &this->unk_18C); + this->subCamAt = subCam->at; + this->subCamEye = subCam->eye; + this->subCamFov = subCam->fov; + func_8016119C(subCam, &this->unk_18C); } if ((this->unk_27A <= 115) && (this->unk_27A >= 16)) { func_80161998(D_80A93E80, &this->unk_18C); } else if (this->unk_27A < 16) { - sp46 = ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8]); + subCamId = ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8]); - Play_CameraSetAtEyeUp(play, sp46, &this->unk_258, &this->unk_264, &D_80A9405C); - Play_CameraSetFov(play, sp46, this->unk_270); - Play_CameraSetRoll(play, sp46, 0); + Play_CameraSetAtEyeUp(play, subCamId, &this->subCamAt, &this->subCamEye, &sSubCamUp); + Play_CameraSetFov(play, subCamId, this->subCamFov); + Play_CameraSetRoll(play, subCamId, 0); } switch (this->unk_27A) { @@ -979,9 +979,9 @@ void func_80A92950(EnTest6* this, PlayState* play) { Play_SetRespawnData(&play->state, 1, ((void)0, gSaveContext.save.entranceIndex & 0xFFFF), player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); this->unk_276 = 99; - play->sceneLoadFlag = 0x14; - play->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; - play->unk_1887F = 2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_RETURN].entranceIndex; + play->transitionType = TRANS_TYPE_02; if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { gSaveContext.respawnFlag = -0x63; gSaveContext.eventInf[2] |= 0x80; @@ -1060,9 +1060,9 @@ void func_80A92950(EnTest6* this, PlayState* play) { Play_SetRespawnData(&play->state, 1, ((void)0, gSaveContext.save.entranceIndex & 0xFFFF), player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); this->unk_276 = 99; - play->sceneLoadFlag = 0x14; - play->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; - play->unk_1887F = 2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_RETURN].entranceIndex; + play->transitionType = TRANS_TYPE_02; gSaveContext.respawnFlag = 2; play->msgCtx.ocarinaMode = 4; } diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.h b/src/overlays/actors/ovl_En_Test6/z_en_test6.h index c34b6b8fb..ad596960e 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.h +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.h @@ -18,35 +18,35 @@ enum { typedef struct { /* 0x00 */ LightNode* node; /* 0x04 */ LightInfo info; -} EnTest6Light; +} EnTest6Light; // size = 0x14 typedef struct EnTest6 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnTest6ActionFunc actionFunc; - /* 0x0148 */ Gfx* unk_148; - /* 0x014C */ f32 unk_14C; - /* 0x0150 */ f32 unk_150; - /* 0x0154 */ f32 unk_154; - /* 0x0158 */ f32 unk_158; - /* 0x015C */ f32 unk_15C; - /* 0x0160 */ f32 unk_160; - /* 0x0164 */ EnTest6Light lights[2]; - /* 0x018C */ DbCameraUnkStruct unk_18C; - /* 0x020C */ Vec3f unk_20C[6]; - /* 0x0254 */ Vec3f (*unk_254)[64]; - /* 0x0258 */ Vec3f unk_258; - /* 0x0264 */ Vec3f unk_264; - /* 0x0270 */ f32 unk_270; - /* 0x0274 */ s16 unk_274; - /* 0x0276 */ s16 unk_276; - /* 0x0278 */ s16 unk_278; - /* 0x027A */ s16 unk_27A; - /* 0x027C */ s16 unk_27C; - /* 0x027E */ s16 unk_27E; - /* 0x0280 */ s16 unk_280; - /* 0x0282 */ s16 unk_282; - /* 0x0284 */ s16 unk_284; - /* 0x0286 */ s16 unk_286; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTest6ActionFunc actionFunc; + /* 0x148 */ Gfx* unk_148; + /* 0x14C */ f32 unk_14C; + /* 0x150 */ f32 unk_150; + /* 0x154 */ f32 unk_154; + /* 0x158 */ f32 unk_158; + /* 0x15C */ f32 unk_15C; + /* 0x160 */ f32 unk_160; + /* 0x164 */ EnTest6Light lights[2]; + /* 0x18C */ DbCameraUnkStruct unk_18C; + /* 0x20C */ Vec3f unk_20C[6]; + /* 0x254 */ Vec3f (*unk_254)[64]; + /* 0x258 */ Vec3f subCamAt; + /* 0x264 */ Vec3f subCamEye; + /* 0x270 */ f32 subCamFov; + /* 0x274 */ s16 unk_274; + /* 0x276 */ s16 unk_276; + /* 0x278 */ s16 unk_278; + /* 0x27A */ s16 unk_27A; + /* 0x27C */ s16 unk_27C; + /* 0x27E */ s16 unk_27E; + /* 0x280 */ s16 unk_280; + /* 0x282 */ s16 unk_282; + /* 0x284 */ s16 subCamId; + /* 0x286 */ s16 unk_286; } EnTest6; // size = 0x288 extern const ActorInit En_Test6_InitVars; diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/src/overlays/actors/ovl_En_Test7/z_en_test7.c index bafcfff11..c0953a117 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -452,11 +452,11 @@ void func_80AF1A2C(EnTest7* this, PlayState* play) { func_800FD698(play, 2000, 4000, sp2C); if (this->unk_1E54 >= 10) { - Camera* camera = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8])); + Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); - this->unk_1E60 = camera->eye; - this->unk_1E6C = camera->at; - this->unk_1E78 = camera->fov; + this->subCamEye = subCam->eye; + this->subCamAt = subCam->at; + this->subCamFov = subCam->fov; func_80AF082C(this, func_80AF1CA0); this->unk_144 |= 0x20; @@ -514,12 +514,12 @@ void func_80AF1CA0(EnTest7* this, PlayState* play) { } if (Rand_ZeroOne() < 0.3f) { - Camera* camera = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8])); + Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); f32 rand = Rand_ZeroOne(); - sp34.x = ((camera->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; - sp34.y = ((camera->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; - sp34.z = ((camera->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; + sp34.x = ((subCam->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; + sp34.y = ((subCam->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; + sp34.z = ((subCam->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; func_80AF0C30(this->unk_15C, &sp34, 1); this->unk_144 |= 8; @@ -531,17 +531,17 @@ void func_80AF1CA0(EnTest7* this, PlayState* play) { void func_80AF1E44(EnTest7* this, PlayState* play) { Vec3f sp34; - Camera* camera; + Camera* subCam; f32 rand; func_80AF1B68(this, play); if (Rand_ZeroOne() < 0.3f) { - camera = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8])); + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); rand = Rand_ZeroOne(); - sp34.x = ((camera->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; - sp34.y = ((camera->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; - sp34.z = ((camera->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; + sp34.x = ((subCam->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; + sp34.y = ((subCam->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; + sp34.z = ((subCam->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; func_80AF0C30(this->unk_15C, &sp34, 1); } @@ -576,7 +576,7 @@ void func_80AF2030(EnTest7* this, PlayState* play) { s32 temp = this->unk_1E54 - 96; f32 four = 4; f32 sp1C = 1.0f - (temp / four); - Camera* camera; + Camera* subCam; f32 temp_f2; f32 temp_f4; @@ -585,13 +585,13 @@ void func_80AF2030(EnTest7* this, PlayState* play) { this->unk_148.unk_10 -= 0x2EE0; this->actor.world.pos.y += 100.0f; - camera = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8])); - camera->player = NULL; + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + subCam->focalActor = NULL; - camera->eye.x = ((camera->eye.x - this->unk_1E60.x) * sp1C) + this->unk_1E60.x; - camera->eye.y = ((camera->eye.y - this->unk_1E60.y) * sp1C) + this->unk_1E60.y; - camera->eye.z = ((camera->eye.z - this->unk_1E60.z) * sp1C) + this->unk_1E60.z; - camera->fov = ((camera->fov - this->unk_1E78) * sp1C) + this->unk_1E78; + subCam->eye.x = ((subCam->eye.x - this->subCamEye.x) * sp1C) + this->subCamEye.x; + subCam->eye.y = ((subCam->eye.y - this->subCamEye.y) * sp1C) + this->subCamEye.y; + subCam->eye.z = ((subCam->eye.z - this->subCamEye.z) * sp1C) + this->subCamEye.z; + subCam->fov = ((subCam->fov - this->subCamFov) * sp1C) + this->subCamFov; if (this->unk_1E54 >= 100) { MREG(64) = 1; @@ -669,8 +669,8 @@ void func_80AF2350(EnTest7* this, PlayState* play) { } } - play->sceneLoadFlag = 0x14; - play->unk_1887F = 2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; gSaveContext.seqIndex = 0xFF; gSaveContext.nightSeqIndex = 0xFF; } @@ -679,31 +679,31 @@ void func_80AF24D8(EnTest7* this, PlayState* play, f32 arg2) { Vec3f sp3C; Vec3f* pos; Player* player = GET_PLAYER(play); - Camera* camera = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8])); + Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); pos = &player->actor.world.pos; - camera->player = NULL; + subCam->focalActor = NULL; sp3C.x = ((180.0f * Math_SinS(this->unk_1E8E)) * Math_CosS(0xFA0)) + pos->x; sp3C.y = (Math_SinS(0xFA0) * 180.0f) + pos->y; sp3C.z = ((180.0f * Math_CosS(this->unk_1E8E)) * Math_CosS(0xFA0)) + pos->z; - camera->eye.x = ((sp3C.x - camera->eye.x) * arg2) + camera->eye.x; - camera->eye.y = ((sp3C.y - camera->eye.y) * arg2) + camera->eye.y; - camera->eye.z = ((sp3C.z - camera->eye.z) * arg2) + camera->eye.z; + subCam->eye.x = ((sp3C.x - subCam->eye.x) * arg2) + subCam->eye.x; + subCam->eye.y = ((sp3C.y - subCam->eye.y) * arg2) + subCam->eye.y; + subCam->eye.z = ((sp3C.z - subCam->eye.z) * arg2) + subCam->eye.z; - camera->fov = ((this->unk_1E78 - camera->fov) * arg2) + camera->fov; - camera->at.y += 1.4444444f; + subCam->fov = ((this->subCamFov - subCam->fov) * arg2) + subCam->fov; + subCam->at.y += 1.4444444f; } void func_80AF2654(EnTest7* this, PlayState* play, f32 arg2) { Vec3f* pos; Player* player = GET_PLAYER(play); - Camera* camera; + Camera* subCam; Vec3f sp30; - camera = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8])); - camera->player = NULL; + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + subCam->focalActor = NULL; pos = &player->actor.world.pos; @@ -711,15 +711,15 @@ void func_80AF2654(EnTest7* this, PlayState* play, f32 arg2) { sp30.y = (Math_SinS(0xBB8) * 80.0f) + pos->y; sp30.z = ((80.0f * Math_CosS(this->unk_1E8E)) * Math_CosS(0xBB8)) + pos->z; - camera->eye.x = ((sp30.x - camera->eye.x) * arg2) + camera->eye.x; - camera->eye.y = ((sp30.y - camera->eye.y) * arg2) + camera->eye.y; - camera->eye.z = ((sp30.z - camera->eye.z) * arg2) + camera->eye.z; + subCam->eye.x = ((sp30.x - subCam->eye.x) * arg2) + subCam->eye.x; + subCam->eye.y = ((sp30.y - subCam->eye.y) * arg2) + subCam->eye.y; + subCam->eye.z = ((sp30.z - subCam->eye.z) * arg2) + subCam->eye.z; - camera->at.x = ((pos->x - camera->at.x) * arg2) + camera->at.x; - camera->at.y = (((pos->y + 40.0f) - camera->at.y) * arg2) + camera->at.y; - camera->at.z = ((pos->z - camera->at.z) * arg2) + camera->at.z; + subCam->at.x = ((pos->x - subCam->at.x) * arg2) + subCam->at.x; + subCam->at.y = (((pos->y + 40.0f) - subCam->at.y) * arg2) + subCam->at.y; + subCam->at.z = ((pos->z - subCam->at.z) * arg2) + subCam->at.z; - camera->fov = ((this->unk_1E78 - camera->fov) * arg2) + camera->fov; + subCam->fov = ((this->subCamFov - subCam->fov) * arg2) + subCam->fov; } void func_80AF2808(EnTest7* this, PlayState* play, f32 arg2) { @@ -771,19 +771,19 @@ void func_80AF29C0(EnTest7* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); Vec3f* pos = &player->actor.world.pos; - Camera* temp_s0 = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8])); + Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); - temp_s0->at.x = ((D_80AF3454 * Math_SinS(D_80AF3450[0]) * Math_CosS(D_80AF3450[1]))) + pos->x; - temp_s0->at.y = (Math_SinS(D_80AF3450[1]) * D_80AF3454) + pos->y; - temp_s0->at.z = ((D_80AF3454 * Math_CosS(D_80AF3450[0])) * Math_CosS(D_80AF3450[1])) + pos->z; + subCam->at.x = ((D_80AF3454 * Math_SinS(D_80AF3450[0]) * Math_CosS(D_80AF3450[1]))) + pos->x; + subCam->at.y = (Math_SinS(D_80AF3450[1]) * D_80AF3454) + pos->y; + subCam->at.z = ((D_80AF3454 * Math_CosS(D_80AF3450[0])) * Math_CosS(D_80AF3450[1])) + pos->z; - this->actor.world.pos.x = temp_s0->at.x; - this->actor.world.pos.y = temp_s0->at.y - 40.0f; - this->actor.world.pos.z = temp_s0->at.z; + this->actor.world.pos.x = subCam->at.x; + this->actor.world.pos.y = subCam->at.y - 40.0f; + this->actor.world.pos.z = subCam->at.z; } void func_80AF2AE8(EnTest7* this, PlayState* play) { - Camera* camera; + Camera* subCam; if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[8])) { ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); @@ -793,9 +793,9 @@ void func_80AF2AE8(EnTest7* this, PlayState* play) { ActorCutscene_Start(play->playerActorCsIds[8], NULL); func_80AF082C(this, func_80AF2C48); - camera = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8])); - this->unk_1E60 = camera->eye; - this->unk_1E6C = camera->at; + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + this->subCamEye = subCam->eye; + this->subCamAt = subCam->at; func_80AF29C0(this, play); } @@ -804,21 +804,21 @@ void func_80AF2BAC(EnTest7* this, PlayState* play, Vec3f* arg2, f32 arg3) { f32 x; f32 y; f32 z; - Camera* camera = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8])); + Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); - camera->player = NULL; - x = ((camera->at.x - arg2->x) * arg3) + arg2->x; - y = ((camera->at.y - arg2->y) * arg3) + arg2->y; - z = ((camera->at.z - arg2->z) * arg3) + arg2->z; + subCam->focalActor = NULL; + x = ((subCam->at.x - arg2->x) * arg3) + arg2->x; + y = ((subCam->at.y - arg2->y) * arg3) + arg2->y; + z = ((subCam->at.z - arg2->z) * arg3) + arg2->z; - camera->at.x = x; - camera->at.y = y; - camera->at.z = z; + subCam->at.x = x; + subCam->at.y = y; + subCam->at.z = z; } void func_80AF2C48(EnTest7* this, PlayState* play) { f32 sp24 = (40 - this->unk_1E54) / 40.0f; - Camera* camera; + Camera* subCam; this->unk_148.unk_00 = 11.0f; this->unk_144 |= 4; @@ -830,12 +830,12 @@ void func_80AF2C48(EnTest7* this, PlayState* play) { this->actor.world.pos.y = ((this->actor.world.pos.y - this->actor.home.pos.y) * sp24) + this->actor.home.pos.y; this->actor.world.pos.z = ((this->actor.world.pos.z - this->actor.home.pos.z) * sp24) + this->actor.home.pos.z; - camera = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8])); + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); func_80AF2BAC(this, play, &this->actor.home.pos, sp24); - camera->at.x = this->actor.world.pos.x; - camera->at.y = this->actor.world.pos.y + 40.0f; - camera->at.z = this->actor.world.pos.z; + subCam->at.x = this->actor.world.pos.x; + subCam->at.y = this->actor.world.pos.y + 40.0f; + subCam->at.z = this->actor.world.pos.z; func_800B9010(&this->actor, NA_SE_PL_WARP_WING_ROLL_2 - SFX_FLAG); if (this->unk_1E54 >= 40) { @@ -845,23 +845,23 @@ void func_80AF2C48(EnTest7* this, PlayState* play) { } void func_80AF2DB4(EnTest7* this, PlayState* play) { - Camera* camera; + Camera* subCam; Player* player = GET_PLAYER(play); Vec3f* pos = &player->actor.world.pos; - camera = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8])); + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); - camera->eye.x = (Math_SinS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->x; - camera->eye.y = pos->y + 108.8042f; - camera->eye.z = (Math_CosS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->z; + subCam->eye.x = (Math_SinS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->x; + subCam->eye.y = pos->y + 108.8042f; + subCam->eye.z = (Math_CosS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->z; - camera->at.x = pos->x; - camera->at.y = pos->y + 40.0f; - camera->at.z = pos->z; + subCam->at.x = pos->x; + subCam->at.y = pos->y + 40.0f; + subCam->at.z = pos->z; } void func_80AF2EC8(EnTest7* this, PlayState* play) { - Camera* camera; + Camera* subCam; if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[8])) { ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); @@ -869,9 +869,9 @@ void func_80AF2EC8(EnTest7* this, PlayState* play) { ActorCutscene_Start(play->playerActorCsIds[8], NULL); func_80AF082C(this, func_80AF2F98); - camera = Play_GetCamera(play, ActorCutscene_GetCurrentCamera(play->playerActorCsIds[8])); - this->unk_1E60 = camera->eye; - this->unk_1E6C = camera->at; + subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + this->subCamEye = subCam->eye; + this->subCamAt = subCam->at; this->unk_1E54 = 40; func_80AF2DB4(this, play); diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.h b/src/overlays/actors/ovl_En_Test7/z_en_test7.h index ed12ab059..da6dec94b 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.h +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.h @@ -47,13 +47,13 @@ typedef struct EnTest7 { /* 0x015C */ EnTest7Struct2 unk_15C[100]; /* 0x18CC */ SkeletonInfo unk_18CC; /* 0x18FC */ Vec3s unk_18FC[114]; - /* 0x1BA8 */ s16 unk_1BA8[342]; + /* 0x1BA8 */ Vec3s unk_1BA8[114]; /* 0x1E54 */ s32 unk_1E54; /* 0x1E58 */ EnTest7UnkFunc unk_1E58; /* 0x1E5C */ EnTest7ActionFunc actionFunc; - /* 0x1E60 */ Vec3f unk_1E60; - /* 0x1E6C */ Vec3f unk_1E6C; - /* 0x1E78 */ f32 unk_1E78; + /* 0x1E60 */ Vec3f subCamEye; + /* 0x1E6C */ Vec3f subCamAt; + /* 0x1E78 */ f32 subCamFov; /* 0x1E7C */ LightNode* lightNode; /* 0x1E80 */ LightInfo lightInfo; /* 0x1E8E */ s16 unk_1E8E; diff --git a/src/overlays/actors/ovl_En_Tg/z_en_tg.h b/src/overlays/actors/ovl_En_Tg/z_en_tg.h index b2303d0b5..2798b99b3 100644 --- a/src/overlays/actors/ovl_En_Tg/z_en_tg.h +++ b/src/overlays/actors/ovl_En_Tg/z_en_tg.h @@ -8,9 +8,9 @@ struct EnTg; typedef void (*EnTgActionFunc)(struct EnTg*, PlayState*); typedef struct EnTg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnTgActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x400]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTgActionFunc actionFunc; + /* 0x148 */ char unk_148[0x400]; } EnTg; // size = 0x548 extern const ActorInit En_Tg_InitVars; 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 8eb883a8a..849795b06 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -90,7 +90,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 3, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -223,7 +223,7 @@ s32 func_80C10B0C(EnThiefbird* this, PlayState* play) { } if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { - phi_a3 = GET_CUR_EQUIP_VALUE(EQUIP_SWORD); + phi_a3 = GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD); if (INV_CONTENT(ITEM_SWORD_GREAT_FAIRY) == ITEM_SWORD_GREAT_FAIRY) { phi_a3 += 4; } @@ -238,9 +238,9 @@ s32 func_80C10B0C(EnThiefbird* this, PlayState* play) { } if (isItemFound) { - func_801149A0(itemId2, slotId); + Inventory_DeleteItem(itemId2, slotId); this->unk_3E8 = object_thiefbird_DL_0033B0; - if (Message_GetState(&play->msgCtx) == 0) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { Message_StartTextbox(play, 0xF4, NULL); } itemId1 = ITEM_BOTTLE; @@ -255,16 +255,16 @@ s32 func_80C10B0C(EnThiefbird* this, PlayState* play) { itemId1 = phi_a3 + (ITEM_SWORD_KOKIRI - 1); if (phi_a3 == 4) { - func_801149A0(ITEM_SWORD_GREAT_FAIRY, SLOT_SWORD_GREAT_FAIRY); + Inventory_DeleteItem(ITEM_SWORD_GREAT_FAIRY, SLOT_SWORD_GREAT_FAIRY); this->unk_3E8 = object_thiefbird_DL_003D58; itemId1 = ITEM_SWORD_GREAT_FAIRY; } else { CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_NONE; - SET_EQUIP_VALUE(EQUIP_SWORD, 0); + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_NONE); this->unk_3E8 = D_80C13680[phi_a3 - 1]; } - if (Message_GetState(&play->msgCtx) == 0) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { Message_StartTextbox(play, 0xF5, NULL); } } else { @@ -404,7 +404,7 @@ s32 func_80C10E98(PlayState* play) { AMMO(ITEM_BOMB) -= spB0 * 5; AMMO(ITEM_BOW) -= spAC * 10; - func_801159EC(-((phi_s0_2 * 50) + (spA0 * 20) + (phi_s2 * 5) + spA8)); + Rupees_ChangeBy(-((phi_s0_2 * 50) + (spA0 * 20) + (phi_s2 * 5) + spA8)); return true; } @@ -776,7 +776,7 @@ void func_80C12378(EnThiefbird* this, PlayState* play) { } void func_80C1242C(EnThiefbird* this) { - Animation_Change(&this->skelAnime, &object_thiefbird_Anim_000278, 2.0f, 0.0f, 0.0f, 0, -4.0f); + Animation_Change(&this->skelAnime, &object_thiefbird_Anim_000278, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f); this->actor.flags |= ACTOR_FLAG_10; this->collider.base.acFlags |= AC_ON; this->actionFunc = func_80C124B0; @@ -837,7 +837,7 @@ void func_80C126D8(EnThiefbird* this, PlayState* play) { void func_80C12744(EnThiefbird* this) { Animation_MorphToLoop(&this->skelAnime, &object_thiefbird_Anim_000604, -4.0f); - Animation_Change(&this->skelAnime, &object_thiefbird_Anim_000604, 1.0f, 0.0f, 0.0f, 1, -4.0f); + Animation_Change(&this->skelAnime, &object_thiefbird_Anim_000604, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -4.0f); this->unk_190 = 0; this->collider.base.acFlags |= AC_ON; this->actor.flags |= ACTOR_FLAG_10; diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h index 6684f630b..698d963be 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h @@ -18,28 +18,28 @@ typedef struct { } EnThiefbirdUnkStruct; // size = 0x24 typedef struct EnThiefbird { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnThiefbirdActionFunc actionFunc; - /* 0x018C */ u8 drawDmgEffType; - /* 0x018E */ s16 unk_18E; - /* 0x0190 */ s16 unk_190; - /* 0x0192 */ s16 unk_192; - /* 0x0194 */ s16 unk_194; - /* 0x0196 */ s16 unk_196[6]; - /* 0x01A2 */ Vec3s jointTable[17]; - /* 0x0208 */ Vec3s morphTable[17]; - /* 0x0270 */ ColliderJntSph collider; - /* 0x0290 */ ColliderJntSphElement colliderElements[3]; - /* 0x0350 */ Vec3f limbPos[11]; - /* 0x03D4 */ f32 drawDmgEffAlpha; - /* 0x03D8 */ f32 drawDmgEffScale; - /* 0x03DC */ f32 drawDmgEffFrozenSteamScale; - /* 0x03E0 */ f32 unk_3E0; - /* 0x03E4 */ Gfx* unk_3E4; - /* 0x03E8 */ Gfx* unk_3E8; - /* 0x03EC */ EnItem00* unk_3EC; - /* 0x03F0 */ EnThiefbirdUnkStruct unk_3F0[40]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnThiefbirdActionFunc actionFunc; + /* 0x18C */ u8 drawDmgEffType; + /* 0x18E */ s16 unk_18E; + /* 0x190 */ s16 unk_190; + /* 0x192 */ s16 unk_192; + /* 0x194 */ s16 unk_194; + /* 0x196 */ s16 unk_196[6]; + /* 0x1A2 */ Vec3s jointTable[17]; + /* 0x208 */ Vec3s morphTable[17]; + /* 0x270 */ ColliderJntSph collider; + /* 0x290 */ ColliderJntSphElement colliderElements[3]; + /* 0x350 */ Vec3f limbPos[11]; + /* 0x3D4 */ f32 drawDmgEffAlpha; + /* 0x3D8 */ f32 drawDmgEffScale; + /* 0x3DC */ f32 drawDmgEffFrozenSteamScale; + /* 0x3E0 */ f32 unk_3E0; + /* 0x3E4 */ Gfx* unk_3E4; + /* 0x3E8 */ Gfx* unk_3E8; + /* 0x3EC */ EnItem00* unk_3EC; + /* 0x3F0 */ EnThiefbirdUnkStruct unk_3F0[40]; } EnThiefbird; // size = 0x990 extern const ActorInit En_Thiefbird_InitVars; diff --git a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c index d6ac47218..d4b50ff35 100644 --- a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c +++ b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c @@ -134,7 +134,7 @@ void func_80ACA184(EnTimeTag* this, PlayState* play) { } void func_80ACA208(EnTimeTag* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); this->actionFunc = func_80ACA268; } @@ -171,17 +171,17 @@ void func_80ACA348(EnTimeTag* this, PlayState* play) { } void func_80ACA3C0(EnTimeTag* this, PlayState* play) { - if ((play->msgCtx.unk11F00->unk01 == 0) && (play->msgCtx.msgMode == 0x1B)) { + if ((play->msgCtx.unk11F00->state == 0) && (play->msgCtx.msgMode == 0x1B)) { this->actor.home.rot.x = 5; this->actionFunc = func_80ACA348; - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; play->msgCtx.msgMode = 0; } } void func_80ACA418(EnTimeTag* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x101C: @@ -216,7 +216,7 @@ void func_80ACA418(EnTimeTag* this, PlayState* play) { } break; - case 2: + case TEXT_STATE_CLOSING: this->actionFunc = func_80ACA5F8; break; } @@ -262,9 +262,9 @@ void func_80ACA714(EnTimeTag* this, PlayState* play) { } void func_80ACA724(EnTimeTag* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { play->nextEntranceIndex = play->setupExitList[ENTIMETAG_GET_1F(&this->actor)]; - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; if (!ENTIMETAG_GET_E000(&this->actor)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_OC_DOOR_OPEN); } diff --git a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h index 7f420bc90..6ee46c1d3 100644 --- a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h +++ b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h @@ -13,8 +13,8 @@ typedef void (*EnTimeTagActionFunc)(struct EnTimeTag*, PlayState*); #define ENTIMETAG_GET_E000(thisx) (((thisx)->params & 0xE000) >> 0xD) typedef struct EnTimeTag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnTimeTagActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTimeTagActionFunc actionFunc; } EnTimeTag; // size = 0x148 extern const ActorInit En_Time_Tag_InitVars; 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 09e3bef20..2b1385965 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -811,7 +811,7 @@ void func_80895A10(EnTite* this) { s32 pad; s16 rand; - Animation_Change(&this->skelAnime, &object_tite_Anim_000A14, 2.0f, 0.0f, 0.0f, 0, 4.0f); + Animation_Change(&this->skelAnime, &object_tite_Anim_000A14, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 4.0f); this->actor.speedXZ = 0.0f; rand = Rand_S16Offset(20, 20); this->unk_2BC = ((Rand_ZeroOne() < 0.5f) ? -1 : 1) * rand; diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.h b/src/overlays/actors/ovl_En_Tite/z_en_tite.h index c17955ec8..2d3a13a37 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.h +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.h @@ -16,25 +16,25 @@ enum { }; typedef struct EnTite { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[25]; - /* 0x021E */ Vec3s morphTable[25]; - /* 0x02B4 */ EnTiteActionFunc actionFunc; - /* 0x02B8 */ u8 unk_2B8; - /* 0x02B9 */ u8 unk_2B9; - /* 0x02BA */ s8 unk_2BA; - /* 0x02BB */ u8 drawDmgEffType; - /* 0x02BC */ s16 unk_2BC; - /* 0x02BE */ s16 unk_2BE; - /* 0x02C0 */ s32 unk_2C0; - /* 0x02C4 */ f32 drawDmgEffAlpha; - /* 0x02C8 */ f32 drawDmgEffScale; - /* 0x02CC */ f32 drawDmgEffFrozenSteamScale; - /* 0x02D0 */ Vec3f limbPos[9]; - /* 0x033C */ Vec3f unk_33C[9]; - /* 0x03A8 */ Gfx* unk_3A8; - /* 0x03AC */ ColliderSphere collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[25]; + /* 0x21E */ Vec3s morphTable[25]; + /* 0x2B4 */ EnTiteActionFunc actionFunc; + /* 0x2B8 */ u8 unk_2B8; + /* 0x2B9 */ u8 unk_2B9; + /* 0x2BA */ s8 unk_2BA; + /* 0x2BB */ u8 drawDmgEffType; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s32 unk_2C0; + /* 0x2C4 */ f32 drawDmgEffAlpha; + /* 0x2C8 */ f32 drawDmgEffScale; + /* 0x2CC */ f32 drawDmgEffFrozenSteamScale; + /* 0x2D0 */ Vec3f limbPos[9]; + /* 0x33C */ Vec3f unk_33C[9]; + /* 0x3A8 */ Gfx* unk_3A8; + /* 0x3AC */ ColliderSphere collider; } EnTite; // size = 0x404 extern const ActorInit En_Tite_InitVars; 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 a0b83ff6d..52ffa365f 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -24,8 +24,8 @@ void func_80AECB0C(EnTk* this, PlayState* play); void func_80AECB6C(EnTk* this, PlayState* play); void func_80AECE0C(EnTk* this, PlayState* play); s32 func_80AECE60(EnTk* this, PlayState* play); -s32 func_80AED354(EnTk* this, PlayState* play, ScheduleResult* arg2); -s32 func_80AED38C(EnTk* this, PlayState* play, ScheduleResult* arg2); +s32 func_80AED354(EnTk* this, PlayState* play, ScheduleOutput* scheduleOutput); +s32 func_80AED38C(EnTk* this, PlayState* play, ScheduleOutput* scheduleOutput); void func_80AED4F8(EnTk* this, PlayState* play); void func_80AED610(EnTk* this, PlayState* play); void func_80AED898(EnTk* this, PlayState* play); @@ -227,7 +227,7 @@ void EnTk_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_InitFlex(play, &this->skelAnime, &object_tk_Skel_00B9E8, NULL, this->jointTable, this->morphTable, 18); Animation_Change(&this->skelAnime, &object_tk_Anim_0030A4, 1.0f, 0.0f, - Animation_GetLastFrame(&object_tk_Anim_0030A4.common), 0, 0.0f); + Animation_GetLastFrame(&object_tk_Anim_0030A4.common), ANIMMODE_LOOP, 0.0f); this->unk_318 = 0; this->unk_2D4 = -1; Actor_SetScale(&this->actor, 0.01f); @@ -291,7 +291,7 @@ void func_80AECA3C(EnTk* this, PlayState* play) { void func_80AECA90(EnTk* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { play->msgCtx.msgMode = 0; - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80AEDE10(this, play); } else if (this->actor.xzDistToPlayer < 100.0f) { func_800B8614(&this->actor, play, 100.0f); @@ -312,13 +312,13 @@ void func_80AECB6C(EnTk* this, PlayState* play) { s32 temp3; f32 sp48; f32 sp44; - ScheduleResult sp34; + ScheduleOutput sp34; u8 temp4; this->actor.textId = 0; if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { play->msgCtx.msgMode = 0; - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80AED4F8(this, play); return; } @@ -411,7 +411,7 @@ s32 func_80AECE60(EnTk* this, PlayState* play) { this->unk_3CE |= 4; } - if ((play->unk_18B4A != 0) || (this->timePathTimeSpeed == 0)) { + if ((play->transitionMode != TRANS_MODE_OFF) || (this->timePathTimeSpeed == 0)) { sp78 = this->timePathElapsedTime; sp74 = this->timePathWaypoint; timePathTargetPos = this->actor.world.pos; @@ -429,7 +429,7 @@ s32 func_80AECE60(EnTk* this, PlayState* play) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp94, &sp88); } - if ((play->unk_18B4A != 0) || (this->timePathTimeSpeed == 0)) { + if ((play->transitionMode != TRANS_MODE_OFF) || (this->timePathTimeSpeed == 0)) { this->timePathElapsedTime = sp78; this->timePathWaypoint = sp74; this->timePathTargetPos = timePathTargetPos; @@ -492,22 +492,23 @@ s32 func_80AECE60(EnTk* this, PlayState* play) { return false; } -s32 func_80AED354(EnTk* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80AED354(EnTk* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 phi_v1 = false; - if (arg2->result != 0) { - phi_v1 = func_80AED38C(this, play, arg2); + if (scheduleOutput->result != 0) { + phi_v1 = func_80AED38C(this, play, scheduleOutput); } return phi_v1; } -s32 func_80AED38C(EnTk* this, PlayState* play, ScheduleResult* arg2) { +s32 func_80AED38C(EnTk* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp1E = SCHEDULE_TIME_NOW; u8 params = ENTK_GET_F800(&this->actor); u16 phi_a1; - s32 idx = arg2->result - 1; + s32 index = scheduleOutput->result - 1; + u16 tmp; - this->timePath = SubS_GetAdditionalPath(play, params, D_80AEF8E8[idx + 1]); + this->timePath = SubS_GetAdditionalPath(play, params, D_80AEF8E8[index + 1]); if (this->timePath == NULL) { return false; } @@ -515,13 +516,13 @@ s32 func_80AED38C(EnTk* this, PlayState* play, ScheduleResult* arg2) { if ((this->unk_3CC <= 0) && (this->unk_3CC != 0) && (this->timePathTimeSpeed >= 0)) { phi_a1 = sp1E; } else { - phi_a1 = arg2->time0; + phi_a1 = scheduleOutput->time0; } - this->timePathTotalTime = arg2->time1 - phi_a1; + this->timePathTotalTime = scheduleOutput->time1 - phi_a1; this->timePathElapsedTime = sp1E - phi_a1; - phi_a1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); - this->timePathWaypointTime = this->timePathTotalTime / phi_a1; + tmp = phi_a1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / tmp; this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3CE &= ~4; this->unk_3CE &= ~8; @@ -554,7 +555,7 @@ void func_80AED610(EnTk* this, PlayState* play) { } switch (Message_GetState(&play->msgCtx)) { - case 0: + case TEXT_STATE_NONE: if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 0x71C)) { if (Player_GetMask(play) == PLAYER_MASK_CAPTAIN) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); @@ -571,14 +572,14 @@ void func_80AED610(EnTk* this, PlayState* play) { break; } - case 1: - case 2: - case 3: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; - case 4: - case 5: - case 6: + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x13FD: @@ -593,7 +594,7 @@ void func_80AED610(EnTk* this, PlayState* play) { break; case 0x1413: - func_801159EC(30); + Rupees_ChangeBy(30); gSaveContext.save.weekEventReg[60] |= 2; func_80151938(play, 0x13FF); break; @@ -691,7 +692,7 @@ void func_80AED940(EnTk* this, PlayState* play) { this->unk_2CA &= ~0x80; this->actor.flags &= ~ACTOR_FLAG_10000; play->msgCtx.msgMode = 0; - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; func_80AEDE10(this, play); } else if (!(this->unk_2CA & 0x80)) { if (this->actor.xzDistToPlayer < 100.0f) { @@ -794,7 +795,7 @@ void func_80AEDF5C(EnTk* this, PlayState* play) { } switch (Message_GetState(&play->msgCtx)) { - case 0: + case TEXT_STATE_NONE: switch (this->unk_2E6) { case 0x1404: case 0x1405: @@ -820,14 +821,14 @@ void func_80AEDF5C(EnTk* this, PlayState* play) { } break; - case 1: - case 2: - case 3: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: break; - case 4: - case 5: - case 6: + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x1404: @@ -1189,7 +1190,7 @@ void func_80AEED38(EnTk* this, PlayState* play) { this->actor.shape.rot.y = this->actor.world.rot.y; } - if (Message_GetState(&play->msgCtx) == 0 && !Play_InCsMode(play) && (this->unk_2C6-- <= 0)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) && !Play_InCsMode(play) && (this->unk_2C6-- <= 0)) { Message_StartTextbox(play, 0x140C, NULL); this->unk_2CA |= 0x4000; this->unk_2C6 = 200; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.h b/src/overlays/actors/ovl_En_Tk/z_en_tk.h index a5ff1b817..279cd0810 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.h +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.h @@ -13,54 +13,54 @@ typedef void (*EnTkUnkFunc)(struct EnTk*, PlayState*); #define ENTK_GET_F800(thisx) ((((thisx)->params >> 0xB) & 0x1F) & 0xFF) typedef struct EnTk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnTkActionFunc actionFunc; - /* 0x018C */ ColliderCylinder collider; - /* 0x01D8 */ Vec3s jointTable[18]; - /* 0x0244 */ Vec3s morphTable[18]; - /* 0x02B0 */ s8 unk_2B0; - /* 0x02B1 */ s8 unk_2B1; - /* 0x02B4 */ Vec3f unk_2B4; - /* 0x02C0 */ s16 unk_2C0; - /* 0x02C2 */ s16 unk_2C2; - /* 0x02C4 */ s16 unk_2C4; - /* 0x02C6 */ s16 unk_2C6; - /* 0x02C8 */ UNK_TYPE1 unk2C8[0x2]; - /* 0x02CA */ u16 unk_2CA; - /* 0x02CC */ s16 unk_2CC; - /* 0x02D0 */ s32 unk_2D0; - /* 0x02D4 */ s32 unk_2D4; - /* 0x02D8 */ f32 unk_2D8; - /* 0x02DC */ f32 unk_2DC; - /* 0x02E0 */ s32 unk_2E0; - /* 0x02E4 */ s16 unk_2E4; - /* 0x02E6 */ u16 unk_2E6; - /* 0x02E8 */ s16 unk_2E8; - /* 0x02EC */ Vec3f unk_2EC; - /* 0x02F8 */ Vec3s unk_2F8; - /* 0x0300 */ Vec3f unk_300; - /* 0x030C */ EnTkUnkFunc unk_30C; - /* 0x0310 */ s16 unk_310; - /* 0x0312 */ s16 cutscenes[2]; - /* 0x0316 */ s16 unk_316; - /* 0x0318 */ s16 unk_318; - /* 0x031A */ s16 unk_31A; - /* 0x031C */ s16 unk_31C; - /* 0x0320 */ f32 unk_320; - /* 0x0324 */ Vec3f unk_324[6]; - /* 0x036C */ s32 unk_36C; - /* 0x0370 */ UNK_TYPE1 unk370[0x58]; - /* 0x03C8 */ Path* timePath; - /* 0x03CC */ u8 unk_3CC; - /* 0x03CE */ u16 unk_3CE; - /* 0x03D0 */ s32 timePathTimeSpeed; - /* 0x03D4 */ Vec3f timePathTargetPos; - /* 0x03E0 */ f32 timePathProgress; - /* 0x03E4 */ s32 timePathTotalTime; - /* 0x03E8 */ s32 timePathWaypointTime; - /* 0x03EC */ s32 timePathWaypoint; - /* 0x03F0 */ s32 timePathElapsedTime; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnTkActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ Vec3s jointTable[18]; + /* 0x244 */ Vec3s morphTable[18]; + /* 0x2B0 */ s8 unk_2B0; + /* 0x2B1 */ s8 unk_2B1; + /* 0x2B4 */ Vec3f unk_2B4; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C2 */ s16 unk_2C2; + /* 0x2C4 */ s16 unk_2C4; + /* 0x2C6 */ s16 unk_2C6; + /* 0x2C8 */ UNK_TYPE1 unk2C8[0x2]; + /* 0x2CA */ u16 unk_2CA; + /* 0x2CC */ s16 unk_2CC; + /* 0x2D0 */ s32 unk_2D0; + /* 0x2D4 */ s32 unk_2D4; + /* 0x2D8 */ f32 unk_2D8; + /* 0x2DC */ f32 unk_2DC; + /* 0x2E0 */ s32 unk_2E0; + /* 0x2E4 */ s16 unk_2E4; + /* 0x2E6 */ u16 unk_2E6; + /* 0x2E8 */ s16 unk_2E8; + /* 0x2EC */ Vec3f unk_2EC; + /* 0x2F8 */ Vec3s unk_2F8; + /* 0x300 */ Vec3f unk_300; + /* 0x30C */ EnTkUnkFunc unk_30C; + /* 0x310 */ s16 unk_310; + /* 0x312 */ s16 cutscenes[2]; + /* 0x316 */ s16 unk_316; + /* 0x318 */ s16 unk_318; + /* 0x31A */ s16 unk_31A; + /* 0x31C */ s16 unk_31C; + /* 0x320 */ f32 unk_320; + /* 0x324 */ Vec3f unk_324[6]; + /* 0x36C */ s32 unk_36C; + /* 0x370 */ UNK_TYPE1 unk370[0x58]; + /* 0x3C8 */ Path* timePath; + /* 0x3CC */ u8 unk_3CC; + /* 0x3CE */ u16 unk_3CE; + /* 0x3D0 */ s32 timePathTimeSpeed; + /* 0x3D4 */ Vec3f timePathTargetPos; + /* 0x3E0 */ f32 timePathProgress; + /* 0x3E4 */ s32 timePathTotalTime; + /* 0x3E8 */ s32 timePathWaypointTime; + /* 0x3EC */ s32 timePathWaypoint; + /* 0x3F0 */ s32 timePathElapsedTime; } EnTk; // size = 0x3F4 extern const ActorInit En_Tk_InitVars; diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index 72129f213..753b5a664 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -139,7 +139,7 @@ static EnTotoText D_80BA50BC[] = { }; static EnTotoUnkStruct2 D_80BA50DC[] = { - { 0x2B2F, 0x2B30, 0X2B31, { 0xFF96, 0x0016, 0xFE16 } }, + { 0x2B2F, 0x2B30, 0x2B31, { 0xFF96, 0x0016, 0xFE16 } }, { 0x2B26, 0x2B27, 0x2B28, { 0x0072, 0x0016, 0xFE3C } }, { 0x2B29, 0x2B2A, 0x2B2B, { 0xFF67, 0x0016, 0xFE6E } }, { 0x2B2C, 0x2B2D, 0x2B2E, { 0xFFF1, 0x0016, 0xFE74 } }, @@ -408,21 +408,21 @@ s32 func_80BA407C(EnToto* this, PlayState* play) { } s32 func_80BA40D4(EnToto* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { return 1; } return 0; } s32 func_80BA4128(EnToto* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 2) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { return 1; } return 0; } s32 func_80BA415C(EnToto* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 4 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { if (play->msgCtx.choiceIndex != 0) { func_8019F230(); } else { @@ -464,14 +464,14 @@ s32 func_80BA42BC(EnToto* this, PlayState* play) { } } } - func_80122744(play, this->unk2BC, phi_s0, end - phi_s0); + func_80122744(play, &this->unk_2BC, phi_s0, end - phi_s0); this->spotlights = Actor_Spawn(&play->actorCtx, play, ACTOR_DM_CHAR07, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0xF02); return 0; } s32 func_80BA43F4(EnToto* this, PlayState* play) { func_80BA3C88(this); - if (func_80122760(play, this->unk2BC, 60.0f)) { + if (func_80122760(play, &this->unk_2BC, 60.0f)) { func_800B7298(play, NULL, 0x13); return func_80BA4204(this, play); } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.h b/src/overlays/actors/ovl_En_Toto/z_en_toto.h index aed6af1ca..94c80ef4a 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.h +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.h @@ -37,7 +37,7 @@ typedef struct EnToto { /* 0x2B6 */ u8 unk2B6; /* 0x2B7 */ u8 unk2B7; /* 0x2B8 */ EnTotoText* text; - /* 0x2BC */ char unk2BC[0x8]; // Some z_player_lib struct size 0x8 more info from func_80122744 and func_80122760 + /* 0x2BC */ struct_80122744_arg1 unk_2BC; /* 0x2C4 */ Actor* spotlights; /* 0x2C8 */ s32 pad2C8; } EnToto; // size = 0x2CC 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 12a95cb20..b1f2fbeaf 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -205,7 +205,7 @@ void EnTrt_EndInteraction(PlayState* play, EnTrt* this) { } Actor_ProcessTalkRequest(&this->actor, &play->state); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; Interface_ChangeAlpha(50); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; @@ -232,7 +232,7 @@ s32 EnTrt_TestEndInteraction(EnTrt* this, PlayState* play, Input* input) { s32 EnTrt_TestCancelOption(EnTrt* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { - this->actionFunc = this->tmpActionFunc; + this->actionFunc = this->prevActionFunc; func_80151938(play, EnTrt_GetItemTextId(this)); return true; } @@ -312,7 +312,7 @@ void EnTrt_Hello(EnTrt* this, PlayState* play) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (talkState == 5 && Message_ShouldAdvance(play)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play_sound(NA_SE_SY_MESSAGE_PASS); if (!EnTrt_TestEndInteraction(this, play, CONTROLLER1(&play->state))) { EnTrt_StartShopping(play, this); @@ -330,7 +330,7 @@ void EnTrt_GetMushroom(EnTrt* this, PlayState* play) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { player->stateFlags2 &= ~0x20000000; } - } else if (talkState == 5 && Message_ShouldAdvance(play)) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (this->textId) { case 0x883: this->textId = 0x884; @@ -348,7 +348,7 @@ void EnTrt_GetMushroom(EnTrt* this, PlayState* play) { this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = EnTrt_PayForMushroom; break; default: @@ -370,7 +370,7 @@ void EnTrt_PayForMushroom(EnTrt* this, PlayState* play) { } void EnTrt_Goodbye(EnTrt* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (this->textId) { case 0x886: this->textId = 0x887; @@ -385,18 +385,18 @@ void EnTrt_Goodbye(EnTrt* this, PlayState* play) { } void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->textId == 0x88F) { - if (Interface_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { + if (Inventory_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = EnTrt_GiveRedPotionForKoume; } else { - this->tmpTextId = this->textId; + this->prevTextId = this->textId; this->textId = 0x88E; gSaveContext.save.weekEventReg[85] |= 8; Message_StartTextbox(play, this->textId, &this->actor); @@ -408,7 +408,7 @@ void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, PlayState* play) { EnTrt_SetupStartShopping(play, this, 0); } else if (gSaveContext.save.weekEventReg[84] & 0x40) { this->textId = 0x83B; - if (Interface_HasItemInBottle(ITEM_POTION_RED)) { + if (Inventory_HasItemInBottle(ITEM_POTION_RED)) { EnTrt_SetupStartShopping(play, this, false); } else { this->actionFunc = EnTrt_TryToGiveRedPotion; @@ -450,7 +450,7 @@ void EnTrt_GivenRedPotionForKoume(EnTrt* this, PlayState* play) { //! @bug: player is set to NULL not PLAYER Player* player = NULL; - if (Message_GetState(&play->msgCtx) == 6 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); @@ -474,11 +474,11 @@ void EnTrt_GivenRedPotionForKoume(EnTrt* this, PlayState* play) { void EnTrt_EndConversation(EnTrt* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - if (talkState == 5) { + if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { EnTrt_EndInteraction(play, this); } - } else if (talkState == 6) { + } else if (talkState == TEXT_STATE_DONE) { if (Message_ShouldAdvance(play)) { EnTrt_EndInteraction(play, this); } @@ -518,7 +518,7 @@ void EnTrt_FaceShopkeeper(EnTrt* this, PlayState* play) { this->cutscene = this->lookForwardCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_WAITING; - } else if (talkState == 4) { + } else if (talkState == TEXT_STATE_CHOICE) { func_8011552C(play, 6); if (!EnTrt_TestEndInteraction(this, play, CONTROLLER1(&play->state))) { if ((!Message_ShouldAdvance(play) || !EnTrt_FacingShopkeeperDialogResult(this, play)) && @@ -591,7 +591,7 @@ s32 EnTrt_HasPlayerSelectedItem(PlayState* play, EnTrt* this, Input* input) { } if (EnTrt_TestItemSelected(play)) { if (item->actor.params != SI_POTION_BLUE || (this->flags & ENTRT_GIVEN_MUSHROOM)) { - this->tmpActionFunc = this->actionFunc; + this->prevActionFunc = this->actionFunc; func_80151938(play, EnTrt_GetItemChoiceTextId(this)); play_sound(NA_SE_SY_DECIDE); this->stickLeftPrompt.isEnabled = false; @@ -620,7 +620,7 @@ void EnTrt_BrowseShelf(EnTrt* this, PlayState* play) { this->drawCursor = 0xFF; this->stickLeftPrompt.isEnabled = true; EnTrt_UpdateCursorPos(play, this); - if (talkState == 5) { + if (talkState == TEXT_STATE_5) { func_8011552C(play, 6); if (!EnTrt_HasPlayerSelectedItem(play, this, CONTROLLER1(&play->state))) { EnTrt_CursorLeftRight(play, this); @@ -638,7 +638,7 @@ void EnTrt_SetupBuyItemWithFanfare(PlayState* play, EnTrt* this) { Actor_PickUp(&this->actor, play, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~0x20000000; Interface_ChangeAlpha(50); this->drawCursor = 0; @@ -705,7 +705,7 @@ void EnTrt_SelectItem(EnTrt* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); if (EnTrt_TakeItemOffShelf(this)) { - if (talkState == 4) { + if (talkState == TEXT_STATE_CHOICE) { func_8011552C(play, 6); if (!EnTrt_TestCancelOption(this, play, CONTROLLER1(&play->state)) && Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { @@ -714,13 +714,13 @@ void EnTrt_SelectItem(EnTrt* this, PlayState* play) { break; case 1: func_8019F230(); - this->actionFunc = this->tmpActionFunc; + this->actionFunc = this->prevActionFunc; func_80151938(play, EnTrt_GetItemTextId(this)); break; } } - } else if (talkState == 5 && Message_ShouldAdvance(play)) { - if (!Interface_HasEmptyBottle()) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + if (!Inventory_HasEmptyBottle()) { play_sound(NA_SE_SY_ERROR); EnTrt_SetupCannotBuy(play, this, 0x846); } else { @@ -755,7 +755,7 @@ void EnTrt_IdleSleeping(EnTrt* this, PlayState* play) { } else { this->talkOptionTextId = 0x885; } - this->tmpTextId = this->textId; + this->prevTextId = this->textId; if (player->transformation == PLAYER_FORM_GORON || player->transformation == PLAYER_FORM_ZORA || player->transformation == PLAYER_FORM_DEKU) { @@ -803,7 +803,7 @@ void EnTrt_IdleAwake(EnTrt* this, PlayState* play) { if (Player_GetMask(play) == PLAYER_MASK_SCENTS) { this->textId = 0x890; } else { - this->textId = this->tmpTextId; + this->textId = this->prevTextId; } } else { this->textId = 0x850; @@ -930,15 +930,15 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); this->blinkFunc = EnTrt_Blink; - if (talkState == 6 && Message_ShouldAdvance(play)) { - if (Interface_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { + if ((talkState == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + if (Inventory_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } this->actionFunc = EnTrt_GiveRedPotionForKoume; } else { - this->tmpTextId = this->textId; + this->prevTextId = this->textId; this->textId = 0x88E; gSaveContext.save.weekEventReg[85] |= 8; Message_StartTextbox(play, this->textId, &this->actor); @@ -948,18 +948,18 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, PlayState* play) { } void EnTrt_TryToGiveRedPotion(EnTrt* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->textId == 0x83C) { - if (Interface_HasEmptyBottle()) { + if (Inventory_HasEmptyBottle()) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->actionFunc = EnTrt_GiveRedPotionForKoume; } else { - this->tmpTextId = this->textId; + this->prevTextId = this->textId; this->textId = 0x88E; gSaveContext.save.weekEventReg[85] |= 8; Message_StartTextbox(play, this->textId, &this->actor); @@ -1015,7 +1015,7 @@ void EnTrt_ItemGiven(EnTrt* this, PlayState* play) { } void EnTrt_SetupEndInteraction(EnTrt* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { EnTrt_EndInteraction(play, this); } } @@ -1032,21 +1032,21 @@ void EnTrt_ShopkeeperGone(EnTrt* this, PlayState* play) { func_800B8614(&this->actor, play, 200.0f); } } - if (talkState == 6 && Message_ShouldAdvance(play)) { + if ((talkState == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { if (gSaveContext.save.weekEventReg[20] & 2) { play->nextEntranceIndex = 0xC50; } else { play->nextEntranceIndex = 0x8450; } - play->unk_1887F = 0x40; - gSaveContext.nextTransition = 0x40; - play->sceneLoadFlag = 0x14; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_64; + play->transitionTrigger = TRANS_TRIGGER_START; } } void EnTrt_CannotBuy(EnTrt* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { - this->actionFunc = this->tmpActionFunc; + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + this->actionFunc = this->prevActionFunc; func_80151938(play, EnTrt_GetItemTextId(this)); } } @@ -1054,12 +1054,12 @@ void EnTrt_CannotBuy(EnTrt* this, PlayState* play) { void EnTrt_CanBuy(EnTrt* this, PlayState* play) { EnGirlA* item; - if (Message_GetState(&play->msgCtx) == 5 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->shopItemSelectedTween = 0.0f; EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(play, item); - this->actionFunc = this->tmpActionFunc; + this->actionFunc = this->prevActionFunc; func_80151938(play, EnTrt_GetItemTextId(this)); } } @@ -1074,7 +1074,7 @@ void EnTrt_BuyItemWithFanfare(EnTrt* this, PlayState* play) { } void EnTrt_SetupItemGiven(EnTrt* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 6 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { this->actionFunc = EnTrt_ItemGiven; if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -1092,7 +1092,7 @@ void EnTrt_ContinueShopping(EnTrt* this, PlayState* play) { Player* player = GET_PLAYER(play); EnGirlA* item; - if (talkState == 4) { + if (talkState == TEXT_STATE_CHOICE) { func_8011552C(play, 6); if (Message_ShouldAdvance(play)) { EnTrt_ResetItemPosition(this); @@ -1116,7 +1116,7 @@ void EnTrt_ContinueShopping(EnTrt* this, PlayState* play) { } } } - } else if (talkState == 5) { + } else if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1361,7 +1361,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, PlayState* play) { Player* player = GET_PLAYER(play); s32 itemGiven; - if (talkState == 5) { + if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { if (this->talkOptionTextId == 0x845 || this->talkOptionTextId == 0x882) { func_80151938(play, 0xFF); @@ -1369,7 +1369,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, PlayState* play) { EnTrt_StartShopping(play, this); } } - } else if (talkState == 16) { + } else if (talkState == TEXT_STATE_16) { itemGiven = func_80123810(play); if (itemGiven > EXCH_ITEM_NONE) { if (itemGiven == EXCH_ITEM_1E) { diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.h b/src/overlays/actors/ovl_En_Trt/z_en_trt.h index 6dc3bd82c..13af94bcc 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.h +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.h @@ -12,7 +12,7 @@ typedef void (*EnTrtBlinkFunc)(struct EnTrt*); typedef struct EnTrt { /* 0x000 */ Actor actor; /* 0x144 */ EnTrtActionFunc actionFunc; - /* 0x148 */ EnTrtActionFunc tmpActionFunc; + /* 0x148 */ EnTrtActionFunc prevActionFunc; /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ ColliderCylinder collider; /* 0x1DC */ UNK_TYPE1 pad1DC[0x154]; @@ -43,7 +43,7 @@ typedef struct EnTrt { /* 0x402 */ s16 timer; /* 0x404 */ s16 animationIndex; /* 0x406 */ u16 textId; - /* 0x408 */ u16 tmpTextId; + /* 0x408 */ u16 prevTextId; /* 0x40A */ u16 talkOptionTextId; /* 0x40C */ s16 lookForwardCutscene; /* 0x40E */ s16 lookToShelfCutscene; diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index f108498e8..02f34c1bb 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -326,15 +326,15 @@ void func_80AD3C94(EnTrt2* this, PlayState* play) { } void func_80AD3CEC(EnTrt2* this, PlayState* play) { - u8 sp27 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); func_80AD46F8(this); if (this->unk_3D8) { Message_StartTextbox(play, this->unk_3A8, &this->actor); this->unk_3D8 = false; - } else if ((sp27 == 5) && Message_ShouldAdvance(play)) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; func_80AD3380(&this->skelAnime, sAnimations, 6); this->unk_3B2 = 4; } @@ -348,7 +348,7 @@ void func_80AD3DA4(EnTrt2* this, PlayState* play) { this->unk_3B2 = 11; return; } else if (this->unk_3A8 == 0x88F) { - if (Interface_HasEmptyBottle()) { + if (Inventory_HasEmptyBottle()) { this->unk_3B2 = 11; } else { this->unk_3B2 = 10; @@ -359,10 +359,10 @@ void func_80AD3DA4(EnTrt2* this, PlayState* play) { } void func_80AD3E34(EnTrt2* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { - if (Interface_HasEmptyBottle()) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + if (Inventory_HasEmptyBottle()) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_3B2 = 12; } else { gSaveContext.save.weekEventReg[85] |= 0x10; @@ -374,11 +374,11 @@ void func_80AD3E34(EnTrt2* this, PlayState* play) { } void func_80AD3EF0(EnTrt2* this, PlayState* play) { - u8 temp_v0 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); - if (temp_v0 == 6) { + if (talkState == TEXT_STATE_DONE) { if (Message_ShouldAdvance(play)) { - if ((Interface_HasEmptyBottle() && !(gSaveContext.save.weekEventReg[84] & 0x40)) || + if ((Inventory_HasEmptyBottle() && !(gSaveContext.save.weekEventReg[84] & 0x40)) || !(gSaveContext.save.weekEventReg[12] & 0x10)) { this->unk_3B2 = 12; } else { @@ -388,9 +388,9 @@ void func_80AD3EF0(EnTrt2* this, PlayState* play) { this->unk_3B2 = 10; } } - } else if ((temp_v0 == 5) && Message_ShouldAdvance(play)) { + } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; this->unk_3B2 = 12; } } @@ -411,7 +411,7 @@ void func_80AD3FF4(EnTrt2* this, PlayState* play) { } void func_80AD40AC(EnTrt2* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 6) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { func_800B85E0(&this->actor, play, 400.0f, -1); this->unk_3B2 = 13; } @@ -428,13 +428,13 @@ void func_80AD4110(EnTrt2* this, PlayState* play) { } void func_80AD417C(EnTrt2* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_3A8 == 0x84B) { func_80AD349C(this); func_80AD3DA4(this, play); } else { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; if (this->unk_3A8 == 0x84C) { func_80AD3380(&this->skelAnime, sAnimations, 6); this->path = SubS_GetPathByIndex(play, ENTRT2_GET_FC00(&this->actor), 0x3F); @@ -507,16 +507,16 @@ void func_80AD434C(EnTrt2* this, PlayState* play) { void func_80AD4550(EnTrt2* this, PlayState* play) { Player* player = GET_PLAYER(play); - u8 sp23 = Message_GetState(&play->msgCtx); + u8 talkState = Message_GetState(&play->msgCtx); if ((player->transformation != PLAYER_FORM_HUMAN) && (player->transformation != PLAYER_FORM_FIERCE_DEITY)) { func_80AD3380(&this->skelAnime, sAnimations, 7); this->unk_3B2 = 17; } - if ((sp23 == 5) && Message_ShouldAdvance(play)) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; } } 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 03ca4215a..943742da3 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -806,31 +806,33 @@ s32 func_80A875AC(Actor* thisx, PlayState* play) { s32 func_80A8777C(Actor* thisx, PlayState* play) { EnTru* this = THIS; s32 ret = 0; - s32 temp_v0 = Message_GetState(&play->msgCtx); + s32 temp_v0; - switch (temp_v0) { - case 4: - case 5: - if (Message_ShouldAdvance(play)) { - case 16: - temp_v0 = func_80123810(play); - if ((temp_v0 == 35) || (temp_v0 == 36)) { - this->unk_34E |= 8; - if (temp_v0 == 35) { - this->unk_390 = 1; - } else { - this->unk_390 = 2; - } - this->unk_378 = func_80A87880; - this->unk_364 = 0; - ret = 1; - } else if (temp_v0 < 0) { - ret = 3; - } else if (temp_v0 != 0) { - ret = 2; - } - break; + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + if (!Message_ShouldAdvance(play)) { + break; } + // Fallthrough + case TEXT_STATE_16: + temp_v0 = func_80123810(play); + if ((temp_v0 == 35) || (temp_v0 == 36)) { + this->unk_34E |= 8; + if (temp_v0 == 35) { + this->unk_390 = 1; + } else { + this->unk_390 = 2; + } + this->unk_378 = func_80A87880; + this->unk_364 = 0; + ret = 1; + } else if (temp_v0 < 0) { + ret = 3; + } else if (temp_v0 != 0) { + ret = 2; + } + break; } return ret; @@ -876,7 +878,7 @@ s32 func_80A87880(Actor* thisx, PlayState* play) { } else if (Animation_OnFrame(&this->skelAnime, 12.0f) && !(this->unk_34E & 0x800)) { this->unk_34E |= 0x400; this->unk_34E |= 0x800; - func_80123AA4(player, 3); + Player_SetModels(player, 3); } break; diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.h b/src/overlays/actors/ovl_En_Tru/z_en_tru.h index 5e64c3a90..7e1c23380 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.h +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.h @@ -22,41 +22,41 @@ typedef struct { } EnTruUnkStruct; // size = 0x30 typedef struct EnTru { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ EnTruActionFunc actionFunc; - /* 0x018C */ ColliderSphere collider; - /* 0x01E4 */ Path* path; - /* 0x01E8 */ s32 unk_1E8; - /* 0x01EC */ Vec3f unk_1EC; - /* 0x01F8 */ Vec3f unk_1F8; - /* 0x0204 */ Vec3s unk_204; - /* 0x020A */ Vec3s jointTable[27]; - /* 0x02AC */ Vec3s morphTable[27]; - /* 0x034E */ u16 unk_34E; - /* 0x0350 */ UNK_TYPE1 unk350[0x4]; - /* 0x0354 */ s32* unk_354; - /* 0x0358 */ f32 unk_358; - /* 0x035C */ f32 unk_35C; - /* 0x0360 */ s16 unk_360; - /* 0x0362 */ s16 unk_362; - /* 0x0364 */ s16 unk_364; - /* 0x0366 */ s16 unk_366; - /* 0x0368 */ s16 unk_368; - /* 0x036A */ s16 unk_36A; - /* 0x036C */ s16 unk_36C; - /* 0x036E */ s16 unk_36E; - /* 0x0370 */ s16 unk_370; - /* 0x0372 */ s16 unk_372; - /* 0x0374 */ s16 unk_374; - /* 0x0378 */ EnTruUnkFunc unk_378; - /* 0x037C */ s32 unk_37C; - /* 0x0380 */ UNK_TYPE1 unk380[0x4]; - /* 0x0384 */ s32 unk_384; - /* 0x0388 */ s32 unk_388; - /* 0x038C */ s32 unk_38C; - /* 0x0390 */ s32 unk_390; - /* 0x0394 */ EnTruUnkStruct unk_394[30]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnTruActionFunc actionFunc; + /* 0x18C */ ColliderSphere collider; + /* 0x1E4 */ Path* path; + /* 0x1E8 */ s32 unk_1E8; + /* 0x1EC */ Vec3f unk_1EC; + /* 0x1F8 */ Vec3f unk_1F8; + /* 0x204 */ Vec3s unk_204; + /* 0x20A */ Vec3s jointTable[27]; + /* 0x2AC */ Vec3s morphTable[27]; + /* 0x34E */ u16 unk_34E; + /* 0x350 */ UNK_TYPE1 unk350[0x4]; + /* 0x354 */ s32* unk_354; + /* 0x358 */ f32 unk_358; + /* 0x35C */ f32 unk_35C; + /* 0x360 */ s16 unk_360; + /* 0x362 */ s16 unk_362; + /* 0x364 */ s16 unk_364; + /* 0x366 */ s16 unk_366; + /* 0x368 */ s16 unk_368; + /* 0x36A */ s16 unk_36A; + /* 0x36C */ s16 unk_36C; + /* 0x36E */ s16 unk_36E; + /* 0x370 */ s16 unk_370; + /* 0x372 */ s16 unk_372; + /* 0x374 */ s16 unk_374; + /* 0x378 */ EnTruUnkFunc unk_378; + /* 0x37C */ s32 unk_37C; + /* 0x380 */ UNK_TYPE1 unk380[0x4]; + /* 0x384 */ s32 unk_384; + /* 0x388 */ s32 unk_388; + /* 0x38C */ s32 unk_38C; + /* 0x390 */ s32 unk_390; + /* 0x394 */ EnTruUnkStruct unk_394[30]; } EnTru; // size = 0x934 extern const ActorInit En_Tru_InitVars; diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index 2b8b2980d..f2159e4d3 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -371,12 +371,12 @@ void func_80B76A64(EnTruMt* this, PlayState* play) { } void func_80B76BB8(EnTruMt* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { play->nextEntranceIndex = 0xA810; - play->unk_1887F = 3; - gSaveContext.nextTransition = 3; - play->sceneLoadFlag = 0x14; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionTrigger = TRANS_TRIGGER_START; } } } diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h index 657049aa2..670d0d728 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h @@ -12,33 +12,33 @@ typedef void (*EnTruMtActionFunc)(struct EnTruMt*, PlayState*); #define ENTRUMT_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) typedef struct EnTruMt { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnTruMtActionFunc actionFunc; - /* 0x0148 */ SkelAnime skelAnime; - /* 0x018C */ ColliderSphere collider; - /* 0x01E4 */ Vec3s jointTable[OBJECT_TRU_LIMB_MAX]; - /* 0x0286 */ Vec3s morphTable[OBJECT_TRU_LIMB_MAX]; - /* 0x0328 */ u16 unk_328; - /* 0x032A */ UNK_TYPE1 unk32A[0xC]; - /* 0x0336 */ Vec3s unk_336; - /* 0x033C */ Vec3f unk_33C; - /* 0x0348 */ s16 unk_348; - /* 0x034A */ s16 unk_34A; - /* 0x034C */ s16 unk_34C; - /* 0x034E */ s16 unk_34E; - /* 0x0350 */ Vec3f unk_350; - /* 0x035C */ Vec3f unk_35C; - /* 0x0368 */ Path* path; - /* 0x036C */ s32 unk_36C; - /* 0x0370 */ Vec3f unk_370; - /* 0x037C */ UNK_TYPE1 unk37C[0xC]; - /* 0x0388 */ s16 unk_388; - /* 0x038A */ s16 unk_38A; - /* 0x038C */ s16 unk_38C; - /* 0x038E */ Vec3s unk_38E; - /* 0x0394 */ s16 unk_394; - /* 0x0398 */ Vec3f unk_398; - /* 0x03A4 */ u8 unk_3A4; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTruMtActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderSphere collider; + /* 0x1E4 */ Vec3s jointTable[OBJECT_TRU_LIMB_MAX]; + /* 0x286 */ Vec3s morphTable[OBJECT_TRU_LIMB_MAX]; + /* 0x328 */ u16 unk_328; + /* 0x32A */ UNK_TYPE1 unk32A[0xC]; + /* 0x336 */ Vec3s unk_336; + /* 0x33C */ Vec3f unk_33C; + /* 0x348 */ s16 unk_348; + /* 0x34A */ s16 unk_34A; + /* 0x34C */ s16 unk_34C; + /* 0x34E */ s16 unk_34E; + /* 0x350 */ Vec3f unk_350; + /* 0x35C */ Vec3f unk_35C; + /* 0x368 */ Path* path; + /* 0x36C */ s32 unk_36C; + /* 0x370 */ Vec3f unk_370; + /* 0x37C */ UNK_TYPE1 unk37C[0xC]; + /* 0x388 */ s16 unk_388; + /* 0x38A */ s16 unk_38A; + /* 0x38C */ s16 unk_38C; + /* 0x38E */ Vec3s unk_38E; + /* 0x394 */ s16 unk_394; + /* 0x398 */ Vec3f unk_398; + /* 0x3A4 */ u8 unk_3A4; } EnTruMt; // size = 0x3A8 extern const ActorInit En_Tru_Mt_InitVars; diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index f0ceee7d9..5800f897f 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -193,7 +193,7 @@ void func_80AE0010(EnTsn* this, PlayState* play) { break; } - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x107F: case 0x1081: @@ -313,7 +313,7 @@ void func_80AE04FC(EnTsn* this, PlayState* play) { s32 sp24; Player* player = GET_PLAYER(play); - if (Message_GetState(&play->msgCtx) == 0x10) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { sp24 = func_80123810(play); if (sp24 != 0) { gSaveContext.save.weekEventReg[26] |= 2; @@ -323,7 +323,7 @@ void func_80AE04FC(EnTsn* this, PlayState* play) { func_801477B4(play); this->actionFunc = func_80AE0704; if (sp24 == 19) { - if (CHECK_QUEST_ITEM(QUEST_UNK_19)) { + if (CHECK_QUEST_ITEM(QUEST_PICTOGRAPH)) { if (func_8013A4C4(1 | 8)) { player->actor.textId = 0x107B; return; @@ -381,10 +381,10 @@ void func_80AE0704(EnTsn* this, PlayState* play) { } switch (Message_GetState(&play->msgCtx)) { - case 2: + case TEXT_STATE_CLOSING: break; - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x106E: @@ -424,7 +424,7 @@ void func_80AE0704(EnTsn* this, PlayState* play) { break; case 0x107C: - if (Interface_HasEmptyBottle()) { + if (Inventory_HasEmptyBottle()) { gSaveContext.save.weekEventReg[26] |= 8; func_801477B4(play); this->actionFunc = func_80AE0460; @@ -433,7 +433,7 @@ void func_80AE0704(EnTsn* this, PlayState* play) { this->actor.focus.pos = this->actor.world.pos; ActorCutscene_Stop(this->actor.cutscene); this->actor.flags &= ~ACTOR_FLAG_100; - REMOVE_QUEST_ITEM(QUEST_UNK_19); + REMOVE_QUEST_ITEM(QUEST_PICTOGRAPH); } else { func_80151938(play, 0x10A8); } @@ -501,6 +501,7 @@ void func_80AE0704(EnTsn* this, PlayState* play) { break; } } + break; } if (this->unk_220 & 2) { @@ -539,7 +540,7 @@ void func_80AE0C88(EnTsn* this, PlayState* play) { } void func_80AE0D10(EnTsn* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); this->actionFunc = func_80AE0D78; ActorCutscene_Stop(this->actor.cutscene); diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h index 199f98ce7..ce6137649 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h @@ -16,17 +16,17 @@ typedef void (*EnTsnActionFunc)(struct EnTsn*, PlayState*); #define ENTSN_F_1 1 typedef struct EnTsn { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ EnTsnActionFunc actionFunc; - /* 0x01D8 */ struct EnTsn* unk_1D8; - /* 0x01DC */ UNK_TYPE1 unk1DC[0x44]; - /* 0x0220 */ u16 unk_220; - /* 0x0222 */ Vec3s unk_222; - /* 0x0228 */ Vec3s unk_228; - /* 0x022E */ s16 unk_22E; - /* 0x0230 */ s16 unk_230; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnTsnActionFunc actionFunc; + /* 0x1D8 */ struct EnTsn* unk_1D8; + /* 0x1DC */ UNK_TYPE1 unk1DC[0x44]; + /* 0x220 */ u16 unk_220; + /* 0x222 */ Vec3s unk_222; + /* 0x228 */ Vec3s unk_228; + /* 0x22E */ s16 unk_22E; + /* 0x230 */ s16 unk_230; } EnTsn; // size = 0x234 extern const ActorInit En_Tsn_InitVars; diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h index 2d0b771b2..db3b9cbe4 100644 --- a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h @@ -8,11 +8,11 @@ struct EnTuboTrap; typedef void (*EnTuboTrapActionFunc)(struct EnTuboTrap*, PlayState*); typedef struct EnTuboTrap { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnTuboTrapActionFunc actionFunc; - /* 0x0148 */ f32 targetHeight; - /* 0x014C */ Vec3f originPos; - /* 0x0158 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTuboTrapActionFunc actionFunc; + /* 0x148 */ f32 targetHeight; + /* 0x14C */ Vec3f originPos; + /* 0x158 */ ColliderCylinder collider; } EnTuboTrap; // size = 0x1A4 extern const ActorInit En_Tubo_Trap_InitVars; diff --git a/src/overlays/actors/ovl_En_Twig/z_en_twig.h b/src/overlays/actors/ovl_En_Twig/z_en_twig.h index 31328b99e..2caebeb82 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.h +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.h @@ -8,10 +8,10 @@ struct EnTwig; typedef void (*EnTwigActionFunc)(struct EnTwig*, PlayState*); typedef struct EnTwig { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ EnTwigActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x2C]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x18]; + /* 0x15C */ EnTwigActionFunc actionFunc; + /* 0x160 */ char unk_160[0x2C]; } EnTwig; // size = 0x18C extern const ActorInit En_Twig_InitVars; diff --git a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h index 9c8293874..17cd47230 100644 --- a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h +++ b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h @@ -8,9 +8,9 @@ struct EnViewer; typedef void (*EnViewerActionFunc)(struct EnViewer*, PlayState*); typedef struct EnViewer { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnViewerActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x10]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnViewerActionFunc actionFunc; + /* 0x148 */ char unk_148[0x10]; } EnViewer; // size = 0x158 extern const ActorInit En_Viewer_InitVars; diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.c b/src/overlays/actors/ovl_En_Vm/z_en_vm.c index 4b43ec95a..4e7e85147 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -75,7 +75,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -102,7 +102,7 @@ static ColliderTrisInit sTrisInit = { OC2_NONE, COLSHAPE_TRIS, }, - 1, + ARRAY_COUNT(sTrisElementsInit), sTrisElementsInit, }; diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.h b/src/overlays/actors/ovl_En_Vm/z_en_vm.h index 69c16dd71..dd1c36aa2 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.h +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.h @@ -14,25 +14,25 @@ typedef void (*EnVmActionFunc)(struct EnVm*, PlayState*); #define ENVM_FF00_FF 0xFF typedef struct EnVm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[11]; - /* 0x01CA */ Vec3s morphTable[11]; - /* 0x020C */ EnVmActionFunc actionFunc; - /* 0x0210 */ u8 unk_210; - /* 0x0212 */ s16 unk_212; - /* 0x0214 */ s16 unk_214; - /* 0x0216 */ s16 unk_216; - /* 0x0218 */ s16 unk_218; - /* 0x021C */ f32 unk_21C; - /* 0x0220 */ f32 unk_220; - /* 0x0224 */ f32 unk_224; - /* 0x0228 */ Vec3f unk_228; - /* 0x0234 */ Vec3f unk_234; - /* 0x0240 */ ColliderJntSph colliderJntSph; - /* 0x0260 */ ColliderJntSphElement colliderJntSphElements[2]; - /* 0x02E0 */ ColliderTris colliderTris; - /* 0x0300 */ ColliderTrisElement colliderTrisElements[1]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[11]; + /* 0x1CA */ Vec3s morphTable[11]; + /* 0x20C */ EnVmActionFunc actionFunc; + /* 0x210 */ u8 unk_210; + /* 0x212 */ s16 unk_212; + /* 0x214 */ s16 unk_214; + /* 0x216 */ s16 unk_216; + /* 0x218 */ s16 unk_218; + /* 0x21C */ f32 unk_21C; + /* 0x220 */ f32 unk_220; + /* 0x224 */ f32 unk_224; + /* 0x228 */ Vec3f unk_228; + /* 0x234 */ Vec3f unk_234; + /* 0x240 */ ColliderJntSph colliderJntSph; + /* 0x260 */ ColliderJntSphElement colliderJntSphElements[2]; + /* 0x2E0 */ ColliderTris colliderTris; + /* 0x300 */ ColliderTrisElement colliderTrisElements[1]; } EnVm; // size = 0x35C extern const ActorInit En_Vm_InitVars; diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c index 4ab04487c..b59b68410 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -629,7 +629,7 @@ void EnWallmas_Update(Actor* thisx, PlayState* play) { } if (this->actionFunc != EnWallmas_Drop) { - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 25.0f, 0.0f, 0x1DU); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 25.0f, 0.0f, 0x1D); } if ((this->actionFunc != EnWallmas_Die) && (this->actionFunc != EnWallmas_Drop)) { diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h index 64ca9b58b..af7c6f18c 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h @@ -25,9 +25,9 @@ * the timer to 130 frames if the player strays too far from the Wallmaster's current position. */ typedef enum { - /* 0x00 */ WALLMASTER_TYPE_TIMER_ONLY, - /* 0x01 */ WALLMASTER_TYPE_PROXIMITY, - /* 0x02 */ WALLMASTER_TYPE_FLAG + /* 0x0 */ WALLMASTER_TYPE_TIMER_ONLY, + /* 0x1 */ WALLMASTER_TYPE_PROXIMITY, + /* 0x2 */ WALLMASTER_TYPE_FLAG } WallmasterType; struct EnWallmas; 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 65bca693a..e67d8a630 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 @@ -112,7 +112,7 @@ void func_80A66278(EnWarpUzu* this, PlayState* play) { void func_80A66384(EnWarpUzu* this, PlayState* play) { play->nextEntranceIndex = 0x22A0; - gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = play->nextEntranceIndex; + gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex = play->nextEntranceIndex; func_80169EFC(&play->state); gSaveContext.respawnFlag = -2; this->actionFunc = EnWarpUzu_DoNothing; diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c index fd9226483..3430e15f4 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c @@ -91,7 +91,7 @@ void EnWarpTag_CheckDungeonKeepObject(EnWarptag* this, PlayState* play) { } void EnWarpTag_WaitForPlayer(EnWarptag* this, PlayState* play) { - if (!Player_InCsMode(&play->state) && (this->dyna.actor.xzDistToPlayer <= 30.0f) && + if (!Player_InCsMode(play) && (this->dyna.actor.xzDistToPlayer <= 30.0f) && (this->dyna.actor.playerHeightRel <= 10.0f)) { if (GET_WARPTAG_INVISIBLE(&this->dyna.actor)) { func_800B7298(play, NULL, 0x51); @@ -243,7 +243,7 @@ void EnWarpTag_GrottoReturn(EnWarptag* this, PlayState* play) { if (this->grottoExitDelay++ == 10) { play->nextEntranceIndex = play->setupExitList[GET_WARPTAG_EXIT_INDEX(&this->dyna.actor)]; Scene_SetExitFade(play); - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; func_8019F128(NA_SE_OC_SECRET_HOLE_OUT); func_801A4058(5); if (1) {} @@ -264,7 +264,7 @@ void EnWarpTag_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWarpTagRainbowAnimMat)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(&gWarpTagRainbowTexAnim)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gWarpTagGoronTrialBaseDL); 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 d17a3780a..499ca365f 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 @@ -89,23 +89,23 @@ void EnWaterEffect_Init(Actor* thisx, PlayState* play) { 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)) { + } else if ((this->actor.params == ENWATEREFFECT_309) || (this->actor.params == ENWATEREFFECT_30A) || + (this->actor.params == ENWATEREFFECT_30B) || (this->actor.params == ENWATEREFFECT_30C)) { 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); - if (this->actor.params == ENWATEREFFECT_777) { + if (this->actor.params == ENWATEREFFECT_309) { Actor_Spawn(&play->actorCtx, play, 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(&play->actorCtx, play, 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) { + } else if (this->actor.params == ENWATEREFFECT_30A) { this->unk_DC4 = -3; - } else if (this->actor.params == ENWATEREFFECT_779) { + } else if (this->actor.params == ENWATEREFFECT_30B) { this->unk_DC4 = -6; - } else if (this->actor.params == ENWATEREFFECT_780) { + } else if (this->actor.params == ENWATEREFFECT_30C) { this->unk_DC4 = 23; } @@ -620,7 +620,7 @@ void func_80A5A6B8(Actor* thisx, PlayState* play2) { Matrix_Push(); Matrix_Push(); - if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_778)) { + if ((this->actor.params == ENWATEREFFECT_309) || (this->actor.params == ENWATEREFFECT_30A)) { if (this->unk_E2C > 1.0f) { func_8012C2DC(play->state.gfxCtx); AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_water_effect_Matanimheader_000DE0)); @@ -648,7 +648,7 @@ void func_80A5A6B8(Actor* thisx, PlayState* play2) { Matrix_Pop(); } - if ((this->unk_E34 > 1.0f) && (this->actor.params != ENWATEREFFECT_780)) { + if ((this->unk_E34 > 1.0f) && (this->actor.params != ENWATEREFFECT_30C)) { func_8012C2DC(play->state.gfxCtx); AnimatedMat_Draw(play, 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); @@ -660,7 +660,7 @@ void func_80A5A6B8(Actor* thisx, PlayState* play2) { Matrix_Pop(); - if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_780)) { + if ((this->actor.params == ENWATEREFFECT_309) || (this->actor.params == ENWATEREFFECT_30C)) { func_8012C2DC(play->state.gfxCtx); AnimatedMat_Draw(play, 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); @@ -670,7 +670,7 @@ void func_80A5A6B8(Actor* thisx, PlayState* play2) { gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000CD8); } - if (this->actor.params == ENWATEREFFECT_777) { + if (this->actor.params == ENWATEREFFECT_309) { func_8012C2DC(play->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { 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 774b858cd..35aebd83e 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 @@ -19,11 +19,11 @@ typedef struct { } EnWaterEffectStruct; // size = 0x40 enum { - /* 0x 1 */ ENWATEREFFECT_1 = 1, - /* 0x309 */ ENWATEREFFECT_777 = 777, - /* 0x30A */ ENWATEREFFECT_778, - /* 0x30B */ ENWATEREFFECT_779, - /* 0x30C */ ENWATEREFFECT_780, + /* 0x001 */ ENWATEREFFECT_1 = 1, + /* 0x309 */ ENWATEREFFECT_309 = 0x309, + /* 0x30A */ ENWATEREFFECT_30A, + /* 0x30B */ ENWATEREFFECT_30B, + /* 0x30C */ ENWATEREFFECT_30C, }; typedef struct EnWaterEffect { diff --git a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c index ba5a16db3..a4cf5379a 100644 --- a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c +++ b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c @@ -63,7 +63,7 @@ static ColliderJntSphElementInit D_80AF63E0[7] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80AF64DC = { { COLTYPE_HIT0, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 7, D_80AF63E0, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80AF63E0, // sJntSphElementsInit, }; // sColChkInfoInit diff --git a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.h b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.h index cf15b0224..adf19ce8c 100644 --- a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.h +++ b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.h @@ -8,10 +8,10 @@ struct EnWdhand; typedef void (*EnWdhandActionFunc)(struct EnWdhand*, PlayState*); typedef struct EnWdhand { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xA4]; - /* 0x01E8 */ EnWdhandActionFunc actionFunc; - /* 0x01EC */ char unk_1EC[0x268]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0xA4]; + /* 0x1E8 */ EnWdhandActionFunc actionFunc; + /* 0x1EC */ char unk_1EC[0x268]; } EnWdhand; // size = 0x454 extern const ActorInit En_Wdhand_InitVars; diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index 152fba147..b1a989045 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -481,7 +481,7 @@ void EnWeatherTag_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); if ((play->actorCtx.unk5 & 2) && (play->msgCtx.msgMode != 0) && (play->msgCtx.currentTextId == 0x5E6) && - (!FrameAdvance_IsEnabled(&play->state)) && (play->sceneLoadFlag == 0) && + (!FrameAdvance_IsEnabled(&play->state)) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (ActorCutscene_GetCurrentIndex() == -1) && (play->csCtx.state == 0)) { gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); 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 3abb119ed..8a5da16c5 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -123,7 +123,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 4, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -411,7 +411,7 @@ s32 func_80990948(PlayState* play, EnWf* this, s16 arg2) { } if (func_800BE184(play, &this->actor, 100.0f, 10000, 12000, this->actor.shape.rot.y) && - ((player->swordAnimation == 0x11) || ((play->gameplayFrames % 2) != 0))) { + ((player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) || ((play->gameplayFrames % 2) != 0))) { func_8099282C(this); return true; } @@ -424,7 +424,7 @@ s32 func_80990948(PlayState* play, EnWf* this, s16 arg2) { return true; } - if ((player->swordAnimation == 0x11) || ((play->gameplayFrames % 2) != 0)) { + if ((player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) || ((play->gameplayFrames % 2) != 0)) { func_8099282C(this); return true; } @@ -549,7 +549,7 @@ void func_80990F50(EnWf* this, PlayState* play) { } void func_80990FC8(EnWf* this) { - Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, 3, 0.0f); + Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, ANIMMODE_ONCE_INTERP, 0.0f); this->unk_2A0 = 5; this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80991040; @@ -572,7 +572,7 @@ void func_80991040(EnWf* this, PlayState* play) { void func_809910F0(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, 3, -5.0f); + Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, ANIMMODE_ONCE_INTERP, -5.0f); this->unk_2A0 = 5; this->actionFunc = func_80991174; } @@ -615,7 +615,7 @@ void func_80991280(EnWf* this, PlayState* play) { if (!func_8099408C(play, this) && !func_80990948(play, this, 0)) { phi_v1 = ABS_ALT(BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y)); - if ((this->actor.xzDistToPlayer < 80.0f) && (player->swordState != 0) && (phi_v1 >= 0x1F40)) { + if ((this->actor.xzDistToPlayer < 80.0f) && (player->meleeWeaponState != 0) && (phi_v1 >= 0x1F40)) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; func_80991948(this); @@ -665,7 +665,7 @@ void func_8099149C(EnWf* this, PlayState* play) { sp28 = ABS_ALT(BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y)); - if ((this->actor.xzDistToPlayer < (150.0f + sp2C)) && (player->swordState != 0) && (sp28 >= 0x1F40)) { + if ((this->actor.xzDistToPlayer < (150.0f + sp2C)) && (player->meleeWeaponState != 0) && (sp28 >= 0x1F40)) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; if (Rand_ZeroOne() > 0.7f) { @@ -879,7 +879,8 @@ void func_80991FD8(EnWf* this) { if (this->skelAnime.curFrame > 15.0f) { phi_f0 = 15.0f; } - Animation_Change(&this->skelAnime, &gWolfosSlashingAnim, -0.5f, this->skelAnime.curFrame - 1.0f, phi_f0, 3, 0.0f); + Animation_Change(&this->skelAnime, &gWolfosSlashingAnim, -0.5f, this->skelAnime.curFrame - 1.0f, phi_f0, + ANIMMODE_ONCE_INTERP, 0.0f); this->collider1.base.atFlags &= ~AT_ON; this->actionFunc = func_80992068; } @@ -1021,7 +1022,7 @@ void func_809924EC(EnWf* this, PlayState* play) { void func_809926D0(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; Animation_Change(&this->skelAnime, &gWolfosBackflippingAnim, -1.0f, - Animation_GetLastFrame(&gWolfosBackflippingAnim.common), 0.0f, 2, -3.0f); + Animation_GetLastFrame(&gWolfosBackflippingAnim.common), 0.0f, ANIMMODE_ONCE, -3.0f); this->unk_2A0 = 0; this->actor.speedXZ = 6.5f; this->actor.velocity.y = 15.0f; @@ -1053,7 +1054,7 @@ void func_8099282C(EnWf* this) { this->unk_2A0 = 10; this->actor.speedXZ = 0.0f; Animation_Change(&this->skelAnime, &gWolfosBlockingAnim, -1.0f, Animation_GetLastFrame(&gWolfosBlockingAnim.common), - 0.0f, 2, -2.0f); + 0.0f, ANIMMODE_ONCE, -2.0f); this->actionFunc = func_809928CC; } @@ -1065,7 +1066,7 @@ void func_809928CC(EnWf* this, PlayState* play) { if (this->unk_2A0 != 0) { this->unk_2A0--; } else if (func_800BE184(play, &this->actor, 100.0f, 10000, 0x4000, this->actor.shape.rot.y)) { - if ((player->swordAnimation != 0x11) || ((play->gameplayFrames % 2) != 0)) { + if ((player->meleeWeaponAnimation != PLAYER_MWA_JUMPSLASH_START) || ((play->gameplayFrames % 2) != 0)) { this->unk_2A0 = 10; } else { func_8099223C(this); diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.h b/src/overlays/actors/ovl_En_Wf/z_en_wf.h index d4666db0a..38570dd9e 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.h +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.h @@ -11,30 +11,30 @@ typedef void (*EnWfActionFunc)(struct EnWf*, PlayState*); #define ENWF_GET_80(thisx) ((thisx)->params & 0x80) typedef struct EnWf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[WOLFOS_NORMAL_LIMB_MAX]; - /* 0x020C */ Vec3s morphTable[WOLFOS_NORMAL_LIMB_MAX]; - /* 0x0290 */ EnWfActionFunc actionFunc; - /* 0x0294 */ u8 eyeIndex; - /* 0x0295 */ u8 unk_295; - /* 0x0296 */ u8 drawDmgEffType; - /* 0x0298 */ s16 unk_298; - /* 0x029A */ s16 unk_29A; - /* 0x029C */ s16 unk_29C; - /* 0x029E */ s16 unk_29E; - /* 0x02A0 */ s16 unk_2A0; - /* 0x02A2 */ u16 unk_2A2; - /* 0x02A4 */ f32 unk_2A4; - /* 0x02A8 */ f32 unk_2A8; - /* 0x02AC */ f32 drawDmgEffAlpha; - /* 0x02B0 */ f32 drawDmgEffScale; - /* 0x02B4 */ f32 drawDmgEffFrozenSteamScale; - /* 0x02B8 */ Vec3f limbPos[10]; - /* 0x0330 */ ColliderJntSph collider1; - /* 0x0350 */ ColliderJntSphElement collider1Elements[4]; - /* 0x0450 */ ColliderCylinder collider2; - /* 0x049C */ ColliderCylinder collider3; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[WOLFOS_NORMAL_LIMB_MAX]; + /* 0x20C */ Vec3s morphTable[WOLFOS_NORMAL_LIMB_MAX]; + /* 0x290 */ EnWfActionFunc actionFunc; + /* 0x294 */ u8 eyeIndex; + /* 0x295 */ u8 unk_295; + /* 0x296 */ u8 drawDmgEffType; + /* 0x298 */ s16 unk_298; + /* 0x29A */ s16 unk_29A; + /* 0x29C */ s16 unk_29C; + /* 0x29E */ s16 unk_29E; + /* 0x2A0 */ s16 unk_2A0; + /* 0x2A2 */ u16 unk_2A2; + /* 0x2A4 */ f32 unk_2A4; + /* 0x2A8 */ f32 unk_2A8; + /* 0x2AC */ f32 drawDmgEffAlpha; + /* 0x2B0 */ f32 drawDmgEffScale; + /* 0x2B4 */ f32 drawDmgEffFrozenSteamScale; + /* 0x2B8 */ Vec3f limbPos[10]; + /* 0x330 */ ColliderJntSph collider1; + /* 0x350 */ ColliderJntSphElement collider1Elements[4]; + /* 0x450 */ ColliderCylinder collider2; + /* 0x49C */ ColliderCylinder collider3; } EnWf; // size = 0x4E8 extern const ActorInit En_Wf_InitVars; diff --git a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c index 0000cb3a3..82cc5f2e2 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c @@ -77,7 +77,7 @@ static ColliderJntSphElementInit D_80A48B50[10] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A48CB8 = { { COLTYPE_HIT2, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 10, D_80A48B50, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A48B50, // sJntSphElementsInit, }; // static ColliderCylinderInit sCylinderInit = { 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 835007d0b..a1ae32032 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h @@ -8,16 +8,16 @@ struct EnWiz; typedef void (*EnWizActionFunc)(struct EnWiz*, PlayState*); typedef struct EnWiz { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x268]; - /* 0x03AC */ EnWizActionFunc actionFunc; - /* 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]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x268]; + /* 0x3AC */ EnWizActionFunc actionFunc; + /* 0x3B0 */ char unk_3B0[0xA]; + /* 0x3BA */ s16 unk_3BA; + /* 0x3BC */ char unk_3BC[0x8C]; + /* 0x448 */ s32 unk_448; + /* 0x44C */ char unk_44C[0x2FE]; + /* 0x74A */ s16 unk_74A; + /* 0x74C */ 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 5f1a280fb..666a5156b 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 @@ -72,7 +72,7 @@ void EnWizFire_Init(Actor* thisx, PlayState* play) { this->unk_1FC = 255.0f; this->actor.flags &= ~ACTOR_FLAG_1; - if (!func_8012405C(play)) { + if (!Player_HasMirrorShieldEquipped(play)) { this->collider.info.toucher.dmgFlags = 0x20000000; } @@ -266,7 +266,7 @@ void func_80A49A44(EnWizFire* this, PlayState* play) { } } - if (func_8012405C(play) && (this->collider.base.atFlags & AT_BOUNCED)) { + if (Player_HasMirrorShieldEquipped(play) && (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; diff --git a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c index 6bd72ae1a..3098b9a6a 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c @@ -463,23 +463,21 @@ void EnWood02_Update(Actor* thisx, PlayState* play2) { } void EnWood02_Draw(Actor* thisx, PlayState* play) { + EnWood02* this = THIS; GraphicsContext* gfxCtx = play->state.gfxCtx; - s16 type; - s16 pad; u8 red; u8 green; u8 blue; OPEN_DISPS(gfxCtx); - type = thisx->params; - if ((type == WOOD_TREE_OVAL_GREEN_SPAWNER) || (type == WOOD_TREE_OVAL_GREEN_SPAWNED) || - (type == WOOD_TREE_OVAL_GREEN) || (type == WOOD_LEAF_GREEN)) { + if ((thisx->params == WOOD_TREE_OVAL_GREEN_SPAWNER) || (thisx->params == WOOD_TREE_OVAL_GREEN_SPAWNED) || + (thisx->params == WOOD_TREE_OVAL_GREEN) || (thisx->params == WOOD_LEAF_GREEN)) { red = 50; green = 170; blue = 70; - } else if ((type == WOOD_TREE_OVAL_YELLOW_SPAWNER) || (type == WOOD_TREE_OVAL_YELLOW_SPAWNED) || - (type == WOOD_LEAF_YELLOW)) { + } else if ((thisx->params == WOOD_TREE_OVAL_YELLOW_SPAWNER) || (thisx->params == WOOD_TREE_OVAL_YELLOW_SPAWNED) || + (thisx->params == WOOD_LEAF_YELLOW)) { red = 180; green = 155; blue = 0; @@ -495,17 +493,17 @@ void EnWood02_Draw(Actor* thisx, PlayState* play) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, red, green, blue, 127); Gfx_DrawDListOpa(play, object_wood02_DL_000700); - } else if (D_808C4D70[THIS->drawType & 0xF] != NULL) { - Gfx_DrawDListOpa(play, D_808C4D54[THIS->drawType & 0xF]); + } else if (D_808C4D70[this->drawType & 0xF] != NULL) { + Gfx_DrawDListOpa(play, D_808C4D54[this->drawType & 0xF]); gDPSetEnvColor(POLY_XLU_DISP++, red, green, blue, 0); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_808C4D70[THIS->drawType & 0xF]); + gSPDisplayList(POLY_XLU_DISP++, D_808C4D70[this->drawType & 0xF]); } else { func_8012C2DC(gfxCtx); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_808C4D54[THIS->drawType & 0xF]); + gSPDisplayList(POLY_XLU_DISP++, D_808C4D54[this->drawType & 0xF]); } CLOSE_DISPS(gfxCtx); diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index d78daa080..bf9fc46b5 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -287,7 +287,7 @@ void EnYb_Talk(EnYb* this, PlayState* play) { this->actor.world.rot.y = this->actor.shape.rot.y; EnYb_UpdateAnimation(this, play); - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x147D: // I am counting on you func_801477B4(play); diff --git a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.h b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.h index 1541e1cd4..eeb272579 100644 --- a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.h +++ b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.h @@ -8,10 +8,10 @@ struct EnZl4; typedef void (*EnZl4ActionFunc)(struct EnZl4*, PlayState*); typedef struct EnZl4 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x14C]; - /* 0x0290 */ EnZl4ActionFunc actionFunc; - /* 0x0294 */ char unk_294[0x60]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x14C]; + /* 0x290 */ EnZl4ActionFunc actionFunc; + /* 0x294 */ char unk_294[0x60]; } EnZl4; // size = 0x2F4 extern const ActorInit En_Zl4_InitVars; diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 72b55a036..68051705e 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -205,11 +205,11 @@ void EnZo_LookAtPlayer(EnZo* this, PlayState* play) { } void EnZo_Walk(EnZo* this, PlayState* play) { - if (ENZO_GET_PATH(&this->actor) != ENZO_NO_PATH) { + if (ENZO_GET_PATH(&this->actor) != 0x3F) { EnZo_SetAnimation(&this->skelAnime, 6); } - if (ENZO_GET_PATH(&this->actor) != ENZO_NO_PATH) { + if (ENZO_GET_PATH(&this->actor) != 0x3F) { this->actionFunc = EnZo_FollowPath; } else { this->actionFunc = EnZo_DoNothing; @@ -263,7 +263,7 @@ void EnZo_Init(Actor* thisx, PlayState* play) { Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->path = SubS_GetPathByIndex(play, ENZO_GET_PATH(&this->actor), ENZO_NO_PATH); + this->path = SubS_GetPathByIndex(play, ENZO_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = EnZo_Walk; diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.h b/src/overlays/actors/ovl_En_Zo/z_en_zo.h index 0dc75a730..bfd0c79dd 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.h +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.h @@ -9,32 +9,31 @@ struct EnZo; typedef void (*EnZoActionFunc)(struct EnZo*, PlayState*); #define ENZO_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) -#define ENZO_NO_PATH 0x3F typedef struct EnZo { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnZoActionFunc actionFunc; - /* 0x0148 */ SkelAnime skelAnime; - /* 0x0194 */ ColliderCylinder collider; - /* 0x01D8 */ UNK_TYPE1 unk_1D8[0x4]; - /* 0x01DC */ Path* path; - /* 0x01E0 */ s16 waypoint; - /* 0x01E4 */ Vec3f leftFootPos; - /* 0x01F0 */ Vec3f rightFootPos; - /* 0x01FC */ u8 isLeftFootGrounded; - /* 0x01FD */ u8 isRightFootGrounded; - /* 0x01FE */ Vec3s jointTable[ZORA_LIMB_MAX]; - /* 0x0276 */ Vec3s morphTable[ZORA_LIMB_MAX]; - /* 0x02EE */ Vec3s trackTarget; - /* 0x02F4 */ Vec3s headRot; - /* 0x02FA */ Vec3s upperBodyRot; - /* 0x0300 */ UNK_TYPE1 unk_300[0x12]; - /* 0x0312 */ s16 limbRotY[20]; - /* 0x033A */ s16 limbRotZ[20]; - /* 0x0364 */ Vec3f bodyPartsPos[15]; - /* 0x041A */ UNK_TYPE1 unk_41A[0x6]; - /* 0x041E */ s16 eyeIndex; - /* 0x0420 */ s16 blinkTimer; + /* 0x000 */ Actor actor; + /* 0x144 */ EnZoActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x194 */ ColliderCylinder collider; + /* 0x1D8 */ UNK_TYPE1 unk_1D8[0x4]; + /* 0x1DC */ Path* path; + /* 0x1E0 */ s16 waypoint; + /* 0x1E4 */ Vec3f leftFootPos; + /* 0x1F0 */ Vec3f rightFootPos; + /* 0x1FC */ u8 isLeftFootGrounded; + /* 0x1FD */ u8 isRightFootGrounded; + /* 0x1FE */ Vec3s jointTable[ZORA_LIMB_MAX]; + /* 0x276 */ Vec3s morphTable[ZORA_LIMB_MAX]; + /* 0x2EE */ Vec3s trackTarget; + /* 0x2F4 */ Vec3s headRot; + /* 0x2FA */ Vec3s upperBodyRot; + /* 0x300 */ UNK_TYPE1 unk_300[0x12]; + /* 0x312 */ s16 limbRotY[20]; + /* 0x33A */ s16 limbRotZ[20]; + /* 0x364 */ Vec3f bodyPartsPos[15]; + /* 0x41A */ UNK_TYPE1 unk_41A[0x6]; + /* 0x41E */ s16 eyeIndex; + /* 0x420 */ s16 blinkTimer; } EnZo; // size = 0x424 #endif // Z_EN_ZO_H diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index ca2c62e22..1970e53df 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -96,7 +96,7 @@ void EnZob_Init(Actor* thisx, PlayState* play) { this->unk_304 = 0; this->actor.terminalVelocity = -4.0f; this->actor.gravity = -4.0f; - func_80B9F7E4(this, 6, 2); + func_80B9F7E4(this, 6, ANIMMODE_ONCE); this->actionFunc = func_80BA0728; this->actor.textId = 0; @@ -130,7 +130,7 @@ void EnZob_Init(Actor* thisx, PlayState* play) { this->actionFunc = func_80BA0CF4; this->unk_2F4 |= 0x20; this->unk_312 = -1; - func_80B9F7E4(this, 0, 2); + func_80B9F7E4(this, 0, ANIMMODE_ONCE); this->unk_304 = 5; break; @@ -161,9 +161,9 @@ void func_80B9F86C(EnZob* this) { case 0: if (Rand_ZeroFloat(1.0f) > 0.7f) { if (this->unk_302 == 6) { - func_80B9F7E4(this, 7, 2); + func_80B9F7E4(this, 7, ANIMMODE_ONCE); } else { - func_80B9F7E4(this, 6, 2); + func_80B9F7E4(this, 6, ANIMMODE_ONCE); } } else { func_80B9F7E4(this, this->unk_302, 2); @@ -171,32 +171,32 @@ void func_80B9F86C(EnZob* this) { break; case 1: - func_80B9F7E4(this, 3, 0); + func_80B9F7E4(this, 3, ANIMMODE_LOOP); break; case 2: - func_80B9F7E4(this, 4, 0); + func_80B9F7E4(this, 4, ANIMMODE_LOOP); break; case 3: - func_80B9F7E4(this, 5, 0); + func_80B9F7E4(this, 5, ANIMMODE_LOOP); break; case 4: if (this->unk_302 == 3) { - func_80B9F7E4(this, 0, 0); + func_80B9F7E4(this, 0, ANIMMODE_LOOP); } else { - func_80B9F7E4(this, 3, 2); + func_80B9F7E4(this, 3, ANIMMODE_ONCE); } break; case 5: if (Rand_ZeroFloat(1.0f) < 0.8f) { - func_80B9F7E4(this, this->unk_302, 2); + func_80B9F7E4(this, this->unk_302, ANIMMODE_ONCE); } else if (this->unk_302 == 0) { - func_80B9F7E4(this, 1, 2); + func_80B9F7E4(this, 1, ANIMMODE_ONCE); } else { - func_80B9F7E4(this, 0, 2); + func_80B9F7E4(this, 0, ANIMMODE_ONCE); } break; } @@ -217,36 +217,36 @@ void func_80B9FA3C(EnZob* this, PlayState* play) { textId = 0x11F8; } this->unk_304 = 3; - func_80B9F7E4(this, 5, 0); + func_80B9F7E4(this, 5, ANIMMODE_LOOP); } else if (this->unk_2F4 & 0x10) { textId = 0x1210; this->unk_304 = 3; - func_80B9F7E4(this, 5, 2); + func_80B9F7E4(this, 5, ANIMMODE_ONCE); } else if (gSaveContext.save.weekEventReg[31] & 8) { textId = 0x1205; this->unk_304 = 1; - func_80B9F7E4(this, 3, 0); + func_80B9F7E4(this, 3, ANIMMODE_LOOP); } else if (this->unk_2F4 & 8) { textId = 0x1215; this->unk_304 = 3; - func_80B9F7E4(this, 5, 2); + func_80B9F7E4(this, 5, ANIMMODE_ONCE); } else if (this->unk_2F4 & 2) { textId = 0x1203; this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); } else if (gSaveContext.save.weekEventReg[30] & 8) { textId = 0x11FA; this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); } else if (!(gSaveContext.save.weekEventReg[30] & 4)) { gSaveContext.save.weekEventReg[30] |= 4; textId = 0x11FB; this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); } else { textId = 0x1201; this->unk_304 = 3; - func_80B9F7E4(this, 4, 2); + func_80B9F7E4(this, 4, ANIMMODE_ONCE); } Message_StartTextbox(play, textId, &this->actor); @@ -273,7 +273,7 @@ void func_80B9FCA0(EnZob* this, PlayState* play) { this->unk_2F4 &= ~1; this->actionFunc = func_80BA0728; this->unk_304 = 0; - func_80B9F7E4(this, 6, 2); + func_80B9F7E4(this, 6, ANIMMODE_ONCE); func_800B8718(&this->actor, &play->state); } @@ -292,11 +292,11 @@ void func_80B9FD24(EnZob* this, PlayState* play) { this->unk_310 = action; switch (action) { case 1: - func_80B9F7E4(this, 8, 0); + func_80B9F7E4(this, 8, ANIMMODE_LOOP); break; case 2: - func_80B9F7E4(this, 7, 0); + func_80B9F7E4(this, 7, ANIMMODE_LOOP); break; } } @@ -316,21 +316,21 @@ void func_80B9FE1C(EnZob* this, PlayState* play) { void func_80B9FE5C(EnZob* this, PlayState* play) { func_80B9F86C(this); if (play->msgCtx.ocarinaMode == 3) { - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; this->actionFunc = func_80B9FDDC; func_80B9FC70(this, 0); - } else if (Message_GetState(&play->msgCtx) == 11) { - play->msgCtx.unk11F10 = 0; + } else if (Message_GetState(&play->msgCtx) == TEXT_STATE_11) { + play->msgCtx.msgLength = 0; this->actionFunc = func_80B9FE1C; this->unk_304 = 3; - func_80B9F7E4(this, 5, 2); + func_80B9F7E4(this, 5, ANIMMODE_ONCE); func_80B9FC70(this, 0); } } void func_80B9FF20(EnZob* this, PlayState* play) { func_80B9F86C(this); - if (Message_GetState(&play->msgCtx) == 7) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_7) { func_80152434(play, 0x42); this->actionFunc = func_80B9FE5C; func_80B9FC70(this, 2); @@ -342,21 +342,21 @@ void func_80B9FF80(EnZob* this, PlayState* play) { if (play->msgCtx.ocarinaMode == 3) { this->actionFunc = func_80B9FF20; this->unk_304 = 6; - func_80B9F7E4(this, 1, 0); + func_80B9F7E4(this, 1, ANIMMODE_LOOP); func_80152434(play, 0x3E); func_80B9FC70(this, 1); - } else if (Message_GetState(&play->msgCtx) == 11) { - play->msgCtx.unk11F10 = 0; + } else if (Message_GetState(&play->msgCtx) == TEXT_STATE_11) { + play->msgCtx.msgLength = 0; this->actionFunc = func_80B9FE1C; this->unk_304 = 3; - func_80B9F7E4(this, 5, 2); + func_80B9F7E4(this, 5, ANIMMODE_ONCE); func_80B9FC70(this, 0); } } void func_80BA005C(EnZob* this, PlayState* play) { func_80B9F86C(this); - if (Message_GetState(&play->msgCtx) == 7) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_7) { func_80152434(play, 0x41); this->actionFunc = func_80B9FF80; func_80B9FC70(this, 2); @@ -367,14 +367,14 @@ void func_80BA00BC(EnZob* this, PlayState* play) { func_80B9F86C(this); switch (Message_GetState(&play->msgCtx)) { - case 4: + case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x1212)) { switch (play->msgCtx.choiceIndex) { case 1: func_8019F208(); func_80151938(play, 0x1209); this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); break; case 0: @@ -385,7 +385,7 @@ void func_80BA00BC(EnZob* this, PlayState* play) { } break; - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x1208: @@ -395,9 +395,9 @@ void func_80BA00BC(EnZob* this, PlayState* play) { break; case 0x120C: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; this->actionFunc = func_80B9FD24; - func_80B9F7E4(this, 8, 0); + func_80B9F7E4(this, 8, ANIMMODE_LOOP); func_80B9FC70(this, 3); break; @@ -407,7 +407,7 @@ void func_80BA00BC(EnZob* this, PlayState* play) { case 0x1217: func_80151938(play, play->msgCtx.currentTextId + 1); this->unk_304 = 3; - func_80B9F7E4(this, 4, 2); + func_80B9F7E4(this, 4, ANIMMODE_ONCE); break; case 0x1218: @@ -428,7 +428,7 @@ void func_80BA00BC(EnZob* this, PlayState* play) { case 0x1209: func_80152434(play, 0x3D); this->unk_304 = 4; - func_80B9F7E4(this, 0, 0); + func_80B9F7E4(this, 0, ANIMMODE_LOOP); this->actionFunc = func_80BA005C; func_80B9FC70(this, 1); break; @@ -441,7 +441,7 @@ void func_80BA00BC(EnZob* this, PlayState* play) { void func_80BA0318(EnZob* this, PlayState* play) { func_80152434(play, 0x3D); this->unk_304 = 4; - func_80B9F7E4(this, 0, 0); + func_80B9F7E4(this, 0, ANIMMODE_LOOP); this->actionFunc = func_80BA005C; func_80B9FC70(this, 1); } @@ -452,13 +452,13 @@ void func_80BA0374(EnZob* this, PlayState* play) { func_80B9F86C(this); switch (Message_GetState(&play->msgCtx)) { - case 4: + case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x1205)) { switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); func_80151938(play, 0x1207); - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); break; case 1: @@ -469,7 +469,7 @@ void func_80BA0374(EnZob* this, PlayState* play) { } break; - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x11F8: @@ -481,7 +481,7 @@ void func_80BA0374(EnZob* this, PlayState* play) { func_801477B4(play); this->actionFunc = func_80BA0728; this->unk_304 = 0; - func_80B9F7E4(this, 6, 2); + func_80B9F7E4(this, 6, ANIMMODE_ONCE); this->unk_2F4 &= ~1; break; @@ -495,13 +495,13 @@ void func_80BA0374(EnZob* this, PlayState* play) { case 0x11FD: this->unk_304 = 3; - func_80B9F7E4(this, 4, 2); + func_80B9F7E4(this, 4, ANIMMODE_ONCE); func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x11FE: this->unk_304 = 1; - func_80B9F7E4(this, 3, 0); + func_80B9F7E4(this, 3, ANIMMODE_LOOP); func_80151938(play, play->msgCtx.currentTextId + 1); break; @@ -516,7 +516,7 @@ void func_80BA0374(EnZob* this, PlayState* play) { func_801477B4(play); this->actionFunc = func_80BA0728; this->unk_304 = 0; - func_80B9F7E4(this, 6, 2); + func_80B9F7E4(this, 6, ANIMMODE_ONCE); this->unk_2F4 &= ~1; this->unk_2F4 |= 2; break; @@ -539,7 +539,7 @@ void func_80BA0610(EnZob* this, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_10000; Message_StartTextbox(play, 0x120D, &this->actor); this->unk_304 = 3; - func_80B9F7E4(this, 5, 2); + func_80B9F7E4(this, 5, ANIMMODE_ONCE); func_80B9FC70(this, 0); this->actionFunc = func_80BA00BC; } else { @@ -571,7 +571,7 @@ void func_80BA0728(EnZob* this, PlayState* play) { } this->actionFunc = func_80BA00BC; this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); this->unk_30E = 0; this->unk_2F4 |= 1; } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { @@ -598,21 +598,21 @@ void func_80BA08E8(EnZob* this, PlayState* play) { if (gSaveContext.save.weekEventReg[79] & 1) { textId = 0x1257; this->unk_304 = 3; - func_80B9F7E4(this, 4, 2); + func_80B9F7E4(this, 4, ANIMMODE_ONCE); } else if (gSaveContext.save.weekEventReg[78] & 0x40) { textId = 0x1256; this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); } else { textId = 0x1255; gSaveContext.save.weekEventReg[78] |= 0x40; this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); + func_80B9F7E4(this, 2, ANIMMODE_ONCE); } } else { textId = 0x1254; this->unk_304 = 3; - func_80B9F7E4(this, 5, 2); + func_80B9F7E4(this, 5, ANIMMODE_ONCE); } Message_StartTextbox(play, textId, &this->actor); @@ -623,24 +623,25 @@ void func_80BA09E0(EnZob* this, PlayState* play) { } void func_80BA0A04(EnZob* this, PlayState* play) { - u8 temp_v0; - func_80B9F86C(this); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); this->actor.world.rot.y = this->actor.shape.rot.y; - temp_v0 = Message_GetState(&play->msgCtx); - if (temp_v0 != 2) { - if ((temp_v0 == 5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + func_801477B4(play); + this->actionFunc = func_80BA0AD8; + this->unk_304 = 0; + func_80B9F7E4(this, 6, ANIMMODE_ONCE); + } + break; + + case TEXT_STATE_CLOSING: this->actionFunc = func_80BA0AD8; this->unk_304 = 0; - func_80B9F7E4(this, 6, 2); - } - } else { - this->actionFunc = func_80BA0AD8; - this->unk_304 = 0; - func_80B9F7E4(this, 6, 2); + func_80B9F7E4(this, 6, ANIMMODE_ONCE); + break; } } @@ -665,7 +666,7 @@ void func_80BA0BB4(EnZob* this, PlayState* play) { func_80B9F86C(this); if (gSaveContext.save.weekEventReg[79] & 1) { this->actionFunc = func_80BA09E0; - func_80B9F7E4(this, 0, 2); + func_80B9F7E4(this, 0, ANIMMODE_ONCE); this->unk_304 = 5; } } diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.h b/src/overlays/actors/ovl_En_Zob/z_en_zob.h index 7c34efb85..cd9ccc908 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.h +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.h @@ -15,21 +15,21 @@ enum { }; typedef struct EnZob { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[24]; - /* 0x0218 */ Vec3s morphTable[24]; - /* 0x02A8 */ ColliderCylinder collider; - /* 0x02F4 */ u16 unk_2F4; - /* 0x02F6 */ Vec3s unk_2F6; - /* 0x02FC */ Vec3s unk_2FC; - /* 0x0302 */ s16 unk_302; - /* 0x0304 */ u16 unk_304; - /* 0x0306 */ s16 unk_306[4]; - /* 0x030E */ s16 unk_30E; - /* 0x0310 */ s16 unk_310; - /* 0x0312 */ s16 unk_312; - /* 0x0314 */ EnZobActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[24]; + /* 0x218 */ Vec3s morphTable[24]; + /* 0x2A8 */ ColliderCylinder collider; + /* 0x2F4 */ u16 unk_2F4; + /* 0x2F6 */ Vec3s unk_2F6; + /* 0x2FC */ Vec3s unk_2FC; + /* 0x302 */ s16 unk_302; + /* 0x304 */ u16 unk_304; + /* 0x306 */ s16 unk_306[4]; + /* 0x30E */ s16 unk_30E; + /* 0x310 */ s16 unk_310; + /* 0x312 */ s16 unk_312; + /* 0x314 */ EnZobActionFunc actionFunc; } EnZob; // size = 0x318 extern const ActorInit En_Zob_InitVars; diff --git a/src/overlays/actors/ovl_En_Zod/z_en_zod.h b/src/overlays/actors/ovl_En_Zod/z_en_zod.h index 9e50b085c..2fd9b7400 100644 --- a/src/overlays/actors/ovl_En_Zod/z_en_zod.h +++ b/src/overlays/actors/ovl_En_Zod/z_en_zod.h @@ -8,9 +8,9 @@ struct EnZod; typedef void (*EnZodActionFunc)(struct EnZod*, PlayState*); typedef struct EnZod { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x158]; - /* 0x029C */ EnZodActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x158]; + /* 0x29C */ EnZodActionFunc actionFunc; } EnZod; // size = 0x2A0 extern const ActorInit En_Zod_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 4ad110889..0c01c96b3 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -429,7 +429,7 @@ s32 func_80B93EA0(EnZog* this, PlayState* play) { break; case 17: - Animation_Change(&this->skelAnime, *D_80B958DC, 0.0f, 0.0f, 0.0f, 0, 0.0f); + Animation_Change(&this->skelAnime, *D_80B958DC, 0.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f); break; } break; @@ -503,37 +503,37 @@ s32 func_80B93EA0(EnZog* this, PlayState* play) { switch (this->unk_306) { case 1: - func_80B939C0(this, 7, 0); + func_80B939C0(this, 7, ANIMMODE_LOOP); this->unk_31C = 2; this->unk_31E = 0; break; case 2: - func_80B939C0(this, 11, 2); + func_80B939C0(this, 11, ANIMMODE_ONCE); this->unk_31C = 1; this->unk_31E = 0; break; case 3: - func_80B939C0(this, 15, 2); + func_80B939C0(this, 15, ANIMMODE_ONCE); this->unk_31C = 0; this->unk_31E = 1; break; case 4: - func_80B939C0(this, 13, 2); + func_80B939C0(this, 13, ANIMMODE_ONCE); this->unk_31C = 2; this->unk_31E = 1; break; case 5: - func_80B939C0(this, 16, 2); + func_80B939C0(this, 16, ANIMMODE_ONCE); this->unk_31C = 2; this->unk_31E = 1; break; case 6: - func_80B939C0(this, 8, 2); + func_80B939C0(this, 8, ANIMMODE_ONCE); this->unk_31C = 1; this->unk_31E = 0; break; @@ -546,14 +546,14 @@ s32 func_80B93EA0(EnZog* this, PlayState* play) { case 9: this->unk_322 = 0; this->unk_30A |= 8; - func_80B939C0(this, 18, 0); + func_80B939C0(this, 18, ANIMMODE_LOOP); this->unk_31C = 0; this->unk_31E = 0; this->unk_30A &= ~2; break; case 10: - func_80B939C0(this, 14, 0); + func_80B939C0(this, 14, ANIMMODE_LOOP); this->unk_31C = 0; this->unk_30A |= 2; this->unk_31E = 1; @@ -612,7 +612,7 @@ void func_80B943EC(EnZog* this, PlayState* play) { } void func_80B94470(EnZog* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 5) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x103C)) { func_801477B4(play); this->actionFunc = func_80B9451C; @@ -663,12 +663,12 @@ void func_80B946B4(EnZog* this, PlayState* play) { void func_80B946FC(EnZog* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 4: + case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; this->actionFunc = func_80B946B4; func_80B93BA8(this, 1); break; @@ -681,7 +681,7 @@ void func_80B946FC(EnZog* this, PlayState* play) { } break; - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x1008: @@ -827,7 +827,7 @@ void func_80B94D0C(EnZog* this, PlayState* play) { this->unk_31E = 0; } - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->unk_320 = 5; switch (play->msgCtx.currentTextId) { case 0x1004: diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c index 29490e964..f20b953ba 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -96,14 +96,14 @@ void EnZoraegg_Init(Actor* thisx, PlayState* play) { this->actor.gravity = -5.0f; switch (ENZORAEGG_GET_1F(&this->actor)) { - case ENZORAEGG_1F_0: + case ENZORAEGG_1F_00: if (Flags_GetSwitch(play, ENZORAEGG_GET_FE00(&this->actor))) { Actor_MarkForDeath(&this->actor); return; } break; - case ENZORAEGG_1F_17: + case ENZORAEGG_1F_11: if (func_80B319A8(play) >= 7) { Actor_MarkForDeath(&this->actor); this->actor.home.rot.z = 1; @@ -111,26 +111,26 @@ void EnZoraegg_Init(Actor* thisx, PlayState* play) { } break; - case ENZORAEGG_1F_3: - case ENZORAEGG_1F_4: - case ENZORAEGG_1F_5: - case ENZORAEGG_1F_6: - case ENZORAEGG_1F_7: - case ENZORAEGG_1F_8: - case ENZORAEGG_1F_9: + case ENZORAEGG_1F_03: + case ENZORAEGG_1F_04: + case ENZORAEGG_1F_05: + case ENZORAEGG_1F_06: + case ENZORAEGG_1F_07: + case ENZORAEGG_1F_08: + case ENZORAEGG_1F_09: if (gSaveContext.save.weekEventReg[19] & 0x40) { Actor_MarkForDeath(&this->actor); return; } break; + case ENZORAEGG_1F_0A: + case ENZORAEGG_1F_0B: + case ENZORAEGG_1F_0C: + case ENZORAEGG_1F_0D: + case ENZORAEGG_1F_0E: + case ENZORAEGG_1F_0F: case ENZORAEGG_1F_10: - case ENZORAEGG_1F_11: - case ENZORAEGG_1F_12: - case ENZORAEGG_1F_13: - case ENZORAEGG_1F_14: - case ENZORAEGG_1F_15: - case ENZORAEGG_1F_16: if (!(gSaveContext.save.weekEventReg[19] & 0x40)) { Actor_MarkForDeath(&this->actor); return; @@ -139,49 +139,49 @@ void EnZoraegg_Init(Actor* thisx, PlayState* play) { } switch (ENZORAEGG_GET_1F(&this->actor)) { - case ENZORAEGG_1F_0: + case ENZORAEGG_1F_00: this->actionFunc = func_80B320E0; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.targetMode = 3; break; - case ENZORAEGG_1F_1: + case ENZORAEGG_1F_01: this->actionFunc = func_80B322BC; func_80B31590(this); break; - case ENZORAEGG_1F_2: + case ENZORAEGG_1F_02: this->actionFunc = func_80B32390; func_80B31590(this); break; - case ENZORAEGG_1F_3: - case ENZORAEGG_1F_4: - case ENZORAEGG_1F_5: - case ENZORAEGG_1F_6: - case ENZORAEGG_1F_7: - case ENZORAEGG_1F_8: - case ENZORAEGG_1F_9: - this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_3]; + case ENZORAEGG_1F_03: + case ENZORAEGG_1F_04: + case ENZORAEGG_1F_05: + case ENZORAEGG_1F_06: + case ENZORAEGG_1F_07: + case ENZORAEGG_1F_08: + case ENZORAEGG_1F_09: + this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_03]; Animation_PlayOnce(&this->skelAnime, &object_zoraegg_Anim_001E08); this->unk_1EC = 1; this->unk_1EE = 0; this->unk_1EF = 0; this->actionFunc = func_80B32B10; - if (((ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_3) >= func_80B319A8(play)) { + if (((ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_03) >= func_80B319A8(play)) { this->actionFunc = func_80B32B3C; this->actor.draw = NULL; } break; + case ENZORAEGG_1F_0A: + case ENZORAEGG_1F_0B: + case ENZORAEGG_1F_0C: + case ENZORAEGG_1F_0D: + case ENZORAEGG_1F_0E: + case ENZORAEGG_1F_0F: case ENZORAEGG_1F_10: - case ENZORAEGG_1F_11: - case ENZORAEGG_1F_12: - case ENZORAEGG_1F_13: - case ENZORAEGG_1F_14: - case ENZORAEGG_1F_15: - case ENZORAEGG_1F_16: - this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_10]; + this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_0A]; this->unk_1EC = 2; this->actionFunc = func_80B324B0; Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); @@ -190,7 +190,7 @@ void EnZoraegg_Init(Actor* thisx, PlayState* play) { this->unk_1EA |= 3; break; - case ENZORAEGG_1F_17: + case ENZORAEGG_1F_11: Actor_SetScale(&this->actor, 0.0006f); this->actionFunc = func_80B32D08; this->actor.world.pos.y -= this->actor.shape.yOffset * this->actor.scale.y; @@ -251,7 +251,7 @@ Actor* func_80B31CB4(PlayState* play) { Actor* actor = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (actor != NULL) { - if ((actor->id == ACTOR_EN_ZORAEGG) && (ENZORAEGG_GET_1F(actor) == ENZORAEGG_1F_17) && + if ((actor->id == ACTOR_EN_ZORAEGG) && (ENZORAEGG_GET_1F(actor) == ENZORAEGG_1F_11) && (actor->home.rot.z == 0)) { actor->home.rot.z = 1; return actor; @@ -265,7 +265,7 @@ Actor* func_80B31D14(PlayState* play) { Actor* actor = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (actor != NULL) { - if ((actor->id == ACTOR_EN_ZORAEGG) && (ENZORAEGG_GET_1F(actor) == ENZORAEGG_1F_3)) { + if ((actor->id == ACTOR_EN_ZORAEGG) && (ENZORAEGG_GET_1F(actor) == ENZORAEGG_1F_03)) { return actor; } actor = actor->next; @@ -326,7 +326,7 @@ void func_80B32084(EnZoraegg* this, PlayState* play) { } void func_80B32094(EnZoraegg* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 2) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { this->actionFunc = func_80B320E0; } func_80B31C40(this, play); @@ -472,7 +472,7 @@ void func_80B326F4(EnZoraegg* this, PlayState* play) { if (Cutscene_CheckActorAction(play, this->actorActionCmd) && (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCmd)]->action == 3)) { Animation_Change(&this->skelAnime, &object_zoraegg_Anim_004D20, 1.0f, 0.0f, - Animation_GetLastFrame(&object_zoraegg_Anim_004D20), 2, 5.0f); + Animation_GetLastFrame(&object_zoraegg_Anim_004D20), ANIMMODE_ONCE, 5.0f); this->unk_1E8 = 0; this->actionFunc = func_80B32644; gSaveContext.save.weekEventReg[19] |= 0x40; @@ -493,7 +493,7 @@ void func_80B32820(EnZoraegg* this, PlayState* play) { if (this->unk_1E8 >= 2) { this->actionFunc = func_80B326F4; Animation_Change(&this->skelAnime, &object_zoraegg_Anim_005098, 1.0f, 0.0f, - Animation_GetLastFrame(&object_zoraegg_Anim_005098), 0, 10.0f); + Animation_GetLastFrame(&object_zoraegg_Anim_005098), ANIMMODE_LOOP, 10.0f); this->unk_1E8 = 0; SkelAnime_Update(&this->skelAnime); return; diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h index e5e638a22..b5b19afde 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h @@ -11,52 +11,52 @@ typedef void (*EnZoraeggActionFunc)(struct EnZoraegg*, PlayState*); #define ENZORAEGG_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) enum { - /* 0 */ ENZORAEGG_1F_0, - /* 1 */ ENZORAEGG_1F_1, - /* 2 */ ENZORAEGG_1F_2, - /* 3 */ ENZORAEGG_1F_3, - /* 4 */ ENZORAEGG_1F_4, - /* 5 */ ENZORAEGG_1F_5, - /* 6 */ ENZORAEGG_1F_6, - /* 7 */ ENZORAEGG_1F_7, - /* 8 */ ENZORAEGG_1F_8, - /* 9 */ ENZORAEGG_1F_9, - /* 10 */ ENZORAEGG_1F_10, - /* 11 */ ENZORAEGG_1F_11, - /* 12 */ ENZORAEGG_1F_12, - /* 13 */ ENZORAEGG_1F_13, - /* 14 */ ENZORAEGG_1F_14, - /* 15 */ ENZORAEGG_1F_15, - /* 16 */ ENZORAEGG_1F_16, - /* 17 */ ENZORAEGG_1F_17, - /* 18 */ ENZORAEGG_1F_18, - /* 19 */ ENZORAEGG_1F_19, - /* 20 */ ENZORAEGG_1F_20, - /* 21 */ ENZORAEGG_1F_21, - /* 22 */ ENZORAEGG_1F_22, - /* 23 */ ENZORAEGG_1F_23, - /* 24 */ ENZORAEGG_1F_24, - /* 25 */ ENZORAEGG_1F_25, + /* 0x00 */ ENZORAEGG_1F_00, + /* 0x01 */ ENZORAEGG_1F_01, + /* 0x02 */ ENZORAEGG_1F_02, + /* 0x03 */ ENZORAEGG_1F_03, + /* 0x04 */ ENZORAEGG_1F_04, + /* 0x05 */ ENZORAEGG_1F_05, + /* 0x06 */ ENZORAEGG_1F_06, + /* 0x07 */ ENZORAEGG_1F_07, + /* 0x08 */ ENZORAEGG_1F_08, + /* 0x09 */ ENZORAEGG_1F_09, + /* 0x0A */ ENZORAEGG_1F_0A, + /* 0x0B */ ENZORAEGG_1F_0B, + /* 0x0C */ ENZORAEGG_1F_0C, + /* 0x0D */ ENZORAEGG_1F_0D, + /* 0x0E */ ENZORAEGG_1F_0E, + /* 0x0F */ ENZORAEGG_1F_0F, + /* 0x10 */ ENZORAEGG_1F_10, + /* 0x11 */ ENZORAEGG_1F_11, + /* 0x12 */ ENZORAEGG_1F_12, + /* 0x13 */ ENZORAEGG_1F_13, + /* 0x14 */ ENZORAEGG_1F_14, + /* 0x15 */ ENZORAEGG_1F_15, + /* 0x16 */ ENZORAEGG_1F_16, + /* 0x17 */ ENZORAEGG_1F_17, + /* 0x18 */ ENZORAEGG_1F_18, + /* 0x19 */ ENZORAEGG_1F_19, }; typedef struct EnZoraegg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[7]; - /* 0x01B2 */ Vec3s morphTable[7]; - /* 0x01DC */ Actor* unk_1DC; - /* 0x01E0 */ f32 unk_1E0; - /* 0x01E4 */ f32 unk_1E4; - /* 0x01E8 */ s16 unk_1E8; - /* 0x01EA */ u16 unk_1EA; - /* 0x01EC */ u8 unk_1EC; - /* 0x01ED */ u8 unk_1ED; - /* 0x01EE */ u8 unk_1EE; - /* 0x01EF */ u8 unk_1EF; - /* 0x01F0 */ u16 actorActionCmd; - /* 0x01F2 */ s16 unk_1F2; - /* 0x01F4 */ s16 unk_1F4; - /* 0x01F8 */ EnZoraeggActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[7]; + /* 0x1B2 */ Vec3s morphTable[7]; + /* 0x1DC */ Actor* unk_1DC; + /* 0x1E0 */ f32 unk_1E0; + /* 0x1E4 */ f32 unk_1E4; + /* 0x1E8 */ s16 unk_1E8; + /* 0x1EA */ u16 unk_1EA; + /* 0x1EC */ u8 unk_1EC; + /* 0x1ED */ u8 unk_1ED; + /* 0x1EE */ u8 unk_1EE; + /* 0x1EF */ u8 unk_1EF; + /* 0x1F0 */ u16 actorActionCmd; + /* 0x1F2 */ s16 unk_1F2; + /* 0x1F4 */ s16 unk_1F4; + /* 0x1F8 */ EnZoraeggActionFunc actionFunc; } EnZoraegg; // size = 0x1FC extern const ActorInit En_Zoraegg_InitVars; diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.c b/src/overlays/actors/ovl_En_Zos/z_en_zos.c index ffb3dee88..cf1913e1c 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -80,7 +80,7 @@ void EnZos_Init(Actor* thisx, PlayState* play) { this->unk_2B6 = 0; this->actor.terminalVelocity = -4.0f; this->actor.gravity = -4.0f; - func_80BBAE84(this, 0, 2); + func_80BBAE84(this, 0, ANIMMODE_ONCE); switch (ENZOS_GET_F(&this->actor)) { case ENZOS_F_1: @@ -93,12 +93,12 @@ void EnZos_Init(Actor* thisx, PlayState* play) { } else { this->actionFunc = func_80BBC14C; } - func_80BBAE84(this, 0, 2); + func_80BBAE84(this, 0, ANIMMODE_ONCE); break; case ENZOS_F_2: this->actionFunc = func_80BBC37C; - func_80BBAE84(this, 7, 2); + func_80BBAE84(this, 7, ANIMMODE_ONCE); this->unk_2BC = -1; this->unk_2B6 |= 0x40; break; @@ -153,19 +153,19 @@ s32 func_80BBAFFC(EnZos* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { switch ((s16)Rand_ZeroFloat(4.0f)) { case 0: - func_80BBAE84(this, 7, 2); + func_80BBAE84(this, 7, ANIMMODE_ONCE); break; case 1: - func_80BBAE84(this, 8, 2); + func_80BBAE84(this, 8, ANIMMODE_ONCE); break; case 2: - func_80BBAE84(this, 11, 2); + func_80BBAE84(this, 11, ANIMMODE_ONCE); break; default: - func_80BBAE84(this, 12, 2); + func_80BBAE84(this, 12, ANIMMODE_ONCE); break; } return true; @@ -176,9 +176,9 @@ s32 func_80BBAFFC(EnZos* this, PlayState* play) { void func_80BBB0D4(EnZos* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if (Rand_ZeroFloat(1.0f) < 0.9f) { - func_80BBAE84(this, 0, 2); + func_80BBAE84(this, 0, ANIMMODE_ONCE); } else { - func_80BBAE84(this, 1, 2); + func_80BBAE84(this, 1, ANIMMODE_ONCE); } SkelAnime_Update(&this->skelAnime); } @@ -190,31 +190,31 @@ void func_80BBB15C(EnZos* this, PlayState* play) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (this->unk_2B6 & 8) { textId = 0x1235; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); this->unk_2B6 |= 2; } else if (this->unk_2B6 & 4) { textId = 0x123E; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); this->unk_2B6 |= 2; } else if (gSaveContext.save.weekEventReg[40] & 0x20) { textId = 0x1236; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); this->unk_2B6 |= 0x80; } else { textId = 0x1231; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); this->unk_2B6 |= 0x80; } } else { this->unk_2B6 &= ~2; if (gSaveContext.save.weekEventReg[39] & 0x10) { textId = 0x1243; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); this->unk_2B6 |= 0x80; } else { textId = 0x1244; gSaveContext.save.weekEventReg[39] |= 0x10; - func_80BBAE84(this, 4, 0); + func_80BBAE84(this, 4, ANIMMODE_LOOP); this->unk_2B6 |= 0x10; } } @@ -232,7 +232,7 @@ void func_80BBB2C4(EnZos* this, PlayState* play) { } void func_80BBB354(EnZos* this, PlayState* play) { - s32 item; + s32 getItemId; if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; @@ -242,11 +242,11 @@ void func_80BBB354(EnZos* this, PlayState* play) { func_800B8500(&this->actor, play, 1000.0f, 1000.0f, -1); } else { if (gSaveContext.save.weekEventReg[39] & 0x20) { - item = GI_RUPEE_PURPLE; + getItemId = GI_RUPEE_PURPLE; } else { - item = GI_HEART_PIECE; + getItemId = GI_HEART_PIECE; } - Actor_PickUp(&this->actor, play, item, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, play, getItemId, 10000.0f, 50.0f); } } @@ -261,11 +261,11 @@ void func_80BBB414(EnZos* this, PlayState* play) { switch (action) { case 1: - func_80BBAE84(this, 1, 0); + func_80BBAE84(this, 1, ANIMMODE_LOOP); break; case 2: - func_80BBAE84(this, 10, 0); + func_80BBAE84(this, 10, ANIMMODE_LOOP); break; } } @@ -301,11 +301,11 @@ void func_80BBB574(EnZos* this, PlayState* play) { } } - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x124B: if (this->unk_2B8 == 9) { - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; this->unk_2B6 |= 0x20; } else { func_80151938(play, 0x124C); @@ -313,14 +313,14 @@ void func_80BBB574(EnZos* this, PlayState* play) { break; case 0x124C: - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; this->actionFunc = func_80BBB4CC; - func_80BBAE84(this, 10, 0); + func_80BBAE84(this, 10, ANIMMODE_LOOP); break; case 0x124D: this->unk_2B6 &= ~0x10; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); func_80151938(play, 0x124E); break; @@ -339,14 +339,14 @@ void func_80BBB718(EnZos* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Message_GetState(&play->msgCtx) == 0x10) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { sp24 = func_80123810(play); if (sp24 > 0) { func_801477B4(play); if (sp24 == 25) { player->actor.textId = 0x1232; - func_80BBAE84(this, 5, 0); + func_80BBAE84(this, 5, ANIMMODE_LOOP); this->unk_2B6 |= 8; gSaveContext.save.weekEventReg[40] |= 0x20; } else if (gSaveContext.save.weekEventReg[39] & 8) { @@ -354,7 +354,7 @@ void func_80BBB718(EnZos* this, PlayState* play) { } else { player->actor.textId = 0x1237; gSaveContext.save.weekEventReg[39] |= 8; - func_80BBAE84(this, 4, 0); + func_80BBAE84(this, 4, ANIMMODE_LOOP); this->unk_2B6 |= 4; } this->actionFunc = func_80BBB8AC; @@ -364,7 +364,7 @@ void func_80BBB718(EnZos* this, PlayState* play) { } else { func_80151938(play, 0x1237); gSaveContext.save.weekEventReg[39] |= 8; - func_80BBAE84(this, 4, 0); + func_80BBAE84(this, 4, ANIMMODE_LOOP); this->unk_2B6 |= 4; } this->actionFunc = func_80BBB8AC; @@ -382,11 +382,11 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); this->actor.world.rot.y = this->actor.shape.rot.y; if ((this->unk_2B6 & 0x80) && (this->actor.yawTowardsPlayer == this->actor.shape.rot.y)) { - func_80BBAE84(this, 3, 0); + func_80BBAE84(this, 3, ANIMMODE_LOOP); } } - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x1237: player->exchangeItemId = 0; @@ -402,7 +402,7 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { case 0x1244: this->unk_2B6 &= ~0x10; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); func_80151938(play, play->msgCtx.currentTextId + 1); break; @@ -412,18 +412,18 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { case 0x1239: case 0x1246: - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1233: - func_80BBAE84(this, 5, 0); + func_80BBAE84(this, 5, ANIMMODE_LOOP); func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1245: case 0x1248: - func_80BBAE84(this, 3, 0); + func_80BBAE84(this, 3, ANIMMODE_LOOP); func_80151938(play, play->msgCtx.currentTextId + 1); break; @@ -434,7 +434,7 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { case 0x1243: case 0x1249: - func_80BBAE84(this, 2, 0); + func_80BBAE84(this, 2, ANIMMODE_LOOP); func_801477B4(play); this->actionFunc = func_80BBBDE0; this->unk_2B6 |= 1; @@ -443,7 +443,7 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { case 0x1234: case 0x123D: case 0x1242: - func_80BBAE84(this, 2, 0); + func_80BBAE84(this, 2, ANIMMODE_LOOP); Actor_ProcessTalkRequest(&this->actor, &play->state); func_801477B4(play); this->actionFunc = func_80BBBDE0; @@ -451,7 +451,7 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { break; case 0x1236: - func_80BBAE84(this, 2, 0); + func_80BBAE84(this, 2, ANIMMODE_LOOP); func_801477B4(play); this->actionFunc = func_80BBBDE0; this->unk_2B6 |= 1; @@ -473,17 +473,17 @@ void func_80BBBB84(EnZos* this, PlayState* play) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { Message_StartTextbox(play, 0x1248, &this->actor); this->actionFunc = func_80BBB8AC; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); this->unk_2B6 |= 2; } else if (gSaveContext.save.weekEventReg[41] & 0x10) { Message_StartTextbox(play, 0x124A, &this->actor); this->actionFunc = func_80BBB8AC; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); } else { gSaveContext.save.weekEventReg[41] |= 0x10; Message_StartTextbox(play, 0x124B, &this->actor); this->actionFunc = func_80BBB574; - func_80BBAE84(this, 9, 2); + func_80BBAE84(this, 9, ANIMMODE_ONCE); this->unk_2B6 |= 0x10; } } else { @@ -494,7 +494,7 @@ void func_80BBBB84(EnZos* this, PlayState* play) { void func_80BBBCBC(EnZos* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_80BBAE84(this, 5, 0); + func_80BBAE84(this, 5, ANIMMODE_LOOP); Message_StartTextbox(play, 0x124D, &this->actor); this->actionFunc = func_80BBB574; } else { @@ -519,7 +519,7 @@ void func_80BBBDE0(EnZos* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x1000, 0x200); this->actor.world.rot.y = thisx->shape.rot.y; if (this->actor.home.rot.y == thisx->shape.rot.y) { - func_80BBAE84(this, 0, 2); + func_80BBAE84(this, 0, ANIMMODE_ONCE); this->unk_2B6 &= ~1; } } @@ -567,10 +567,10 @@ void func_80BBBFBC(EnZos* this, PlayState* play) { textId = 0x1259; gSaveContext.save.weekEventReg[78] |= 0x80; } - func_80BBAE84(this, 5, 0); + func_80BBAE84(this, 5, ANIMMODE_LOOP); } else { textId = 0x1258; - func_80BBAE84(this, 6, 0); + func_80BBAE84(this, 6, ANIMMODE_LOOP); } Message_StartTextbox(play, textId, &this->actor); } @@ -581,17 +581,17 @@ void func_80BBC070(EnZos* this, PlayState* play) { this->actor.world.rot.y = this->actor.shape.rot.y; switch (Message_GetState(&play->msgCtx)) { - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { - func_80BBAE84(this, 2, 0); + func_80BBAE84(this, 2, ANIMMODE_LOOP); func_801477B4(play); this->actionFunc = func_80BBC14C; this->unk_2B6 |= 1; } break; - case 2: - func_80BBAE84(this, 2, 0); + case TEXT_STATE_CLOSING: + func_80BBAE84(this, 2, ANIMMODE_LOOP); this->actionFunc = func_80BBC14C; this->unk_2B6 |= 1; break; @@ -605,7 +605,7 @@ void func_80BBC14C(EnZos* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x1000, 0x200); this->actor.world.rot.y = thisx->shape.rot.y; if (this->actor.home.rot.y == this->actor.shape.rot.y) { - func_80BBAE84(this, 0, 2); + func_80BBAE84(this, 0, ANIMMODE_ONCE); this->unk_2B6 &= ~1; } } @@ -628,7 +628,7 @@ void func_80BBC24C(EnZos* this, PlayState* play) { func_80BBB0D4(this, play); if (gSaveContext.save.weekEventReg[79] & 1) { this->actionFunc = func_80BBC22C; - func_80BBAE84(this, 7, 2); + func_80BBAE84(this, 7, ANIMMODE_ONCE); } } diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.h b/src/overlays/actors/ovl_En_Zos/z_en_zos.h index 92dc2c062..99125aad3 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.h +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.h @@ -15,19 +15,19 @@ enum { }; typedef struct EnZos { - /* 0x0000 */ Actor actor; - /* 0x0144 */ Vec3s jointTable[18]; - /* 0x01B0 */ Vec3s morphTable[18]; - /* 0x021C */ SkelAnime skelAnime; - /* 0x0260 */ ColliderCylinder collider; - /* 0x02AC */ s16 unk_2AC; - /* 0x02AE */ s16 unk_2AE; - /* 0x02B0 */ UNK_TYPE1 unk2B0[6]; - /* 0x02B6 */ u16 unk_2B6; - /* 0x02B8 */ s16 unk_2B8; - /* 0x02BA */ s16 unk_2BA; - /* 0x02BC */ s16 unk_2BC; - /* 0x02C0 */ EnZosActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ Vec3s jointTable[18]; + /* 0x1B0 */ Vec3s morphTable[18]; + /* 0x21C */ SkelAnime skelAnime; + /* 0x260 */ ColliderCylinder collider; + /* 0x2AC */ s16 unk_2AC; + /* 0x2AE */ s16 unk_2AE; + /* 0x2B0 */ UNK_TYPE1 unk2B0[6]; + /* 0x2B6 */ u16 unk_2B6; + /* 0x2B8 */ s16 unk_2B8; + /* 0x2BA */ s16 unk_2BA; + /* 0x2BC */ s16 unk_2BC; + /* 0x2C0 */ EnZosActionFunc actionFunc; } EnZos; // size = 0x2C4 extern const ActorInit En_Zos_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 4aff29b1a..0933d2240 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -138,25 +138,25 @@ void EnZot_Init(Actor* thisx, PlayState* play2) { } else { this->path = NULL; } - func_80B96BEC(this, 5, 0); + func_80B96BEC(this, 5, ANIMMODE_LOOP); break; case 6: this->actionFunc = func_80B98998; - func_80B96BEC(this, 2, 0); + func_80B96BEC(this, 2, ANIMMODE_LOOP); this->actor.colChkInfo.cylRadius = 0; this->actor.shape.yOffset = -1400.0f; break; case 7: this->actionFunc = func_80B98998; - func_80B96BEC(this, 0, 0); + func_80B96BEC(this, 0, ANIMMODE_LOOP); break; case 8: this->actor.flags |= ACTOR_FLAG_2000000; this->actionFunc = func_80B98CA8; - func_80B96BEC(this, 5, 0); + func_80B96BEC(this, 5, ANIMMODE_LOOP); break; case 9: @@ -165,7 +165,7 @@ void EnZot_Init(Actor* thisx, PlayState* play2) { case 10: this->actionFunc = func_80B992C0; - func_80B96BEC(this, 1, 0); + func_80B96BEC(this, 1, ANIMMODE_LOOP); if (ENZOT_GET_FC00(&this->actor) != 0x3F) { this->path = &play->setupPathList[ENZOT_GET_FC00(&this->actor)]; } else { @@ -181,7 +181,7 @@ void EnZot_Init(Actor* thisx, PlayState* play2) { case 16: case 17: this->actionFunc = func_80B98998; - func_80B96BEC(this, 2, 0); + func_80B96BEC(this, 2, ANIMMODE_LOOP); this->actor.colChkInfo.cylRadius = 0; this->actor.shape.yOffset = -1400.0f; if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { @@ -197,15 +197,15 @@ void EnZot_Init(Actor* thisx, PlayState* play2) { break; case 19: - func_80B96BEC(this, 7, 0); + func_80B96BEC(this, 7, ANIMMODE_LOOP); break; case 20: - func_80B96BEC(this, 8, 2); + func_80B96BEC(this, 8, ANIMMODE_ONCE); break; case 21: - func_80B96BEC(this, 9, 2); + func_80B96BEC(this, 9, ANIMMODE_ONCE); break; case 22: @@ -378,7 +378,7 @@ void func_80B97110(EnZot* this, PlayState* play) { } void func_80B97194(EnZot* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x125C: case 0x125F: @@ -447,7 +447,7 @@ void func_80B973BC(EnZot* this, PlayState* play) { func_80B96D4C(this); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x126E: case 0x1270: @@ -461,7 +461,7 @@ void func_80B973BC(EnZot* this, PlayState* play) { break; case 0x126F: - func_801159EC(90); + Rupees_ChangeBy(90); func_80151938(play, 0x1270); break; @@ -470,7 +470,7 @@ void func_80B973BC(EnZot* this, PlayState* play) { func_80151938(play, 0x1277); } else { func_80151938(play, 0x1278); - func_801159EC(-10); + Rupees_ChangeBy(-10); } break; @@ -521,7 +521,7 @@ void func_80B975F8(EnZot* this, PlayState* play) { void func_80B9765C(EnZot* this, PlayState* play) { func_80B96D4C(this); - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { s32 requiredScopeTemp; switch (play->msgCtx.currentTextId) { @@ -650,7 +650,7 @@ void func_80B9787C(EnZot* this, PlayState* play) { void func_80B979DC(EnZot* this, PlayState* play) { if (func_80B96E5C(this)) { this->actionFunc = func_80B97B5C; - func_80B96BEC(this, 0, 0); + func_80B96BEC(this, 0, ANIMMODE_LOOP); this->actor.speedXZ = 0.0f; } else { this->actor.speedXZ = 1.5f; @@ -658,7 +658,7 @@ void func_80B979DC(EnZot* this, PlayState* play) { } void func_80B97A44(EnZot* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x1279: case 0x127C: @@ -679,7 +679,7 @@ void func_80B97A44(EnZot* this, PlayState* play) { if (!(this->unk_2F2 & 2)) { this->unk_2F2 |= 2; this->actionFunc = func_80B979DC; - func_80B96BEC(this, 1, 0); + func_80B96BEC(this, 1, ANIMMODE_LOOP); } else { this->actionFunc = func_80B97B5C; } @@ -718,7 +718,7 @@ void func_80B97BF8(EnZot* this, PlayState* play) { void func_80B97C40(EnZot* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_801477B4(play); this->actionFunc = func_80B97CC8; } @@ -737,7 +737,7 @@ void func_80B97D6C(EnZot* this, PlayState* play) { if (func_80B96E5C(this)) { this->actionFunc = func_80B97CC8; this->actor.speedXZ = 0.0f; - func_80B96BEC(this, 0, 0); + func_80B96BEC(this, 0, ANIMMODE_LOOP); } else { this->actor.speedXZ = 8.0f; } @@ -750,16 +750,15 @@ void func_80B97D6C(EnZot* this, PlayState* play) { void func_80B97E0C(EnZot* this, PlayState* play) { if (this->unk_2F2 & 0x40) { this->actionFunc = func_80B97D6C; - func_80B96BEC(this, 3, 0); + func_80B96BEC(this, 3, ANIMMODE_LOOP); } } void func_80B97E4C(EnZot* this, PlayState* play) { - if (1) { - do { } while (0); } + if (1) {} if (this->unk_2F2 & 0x40) { - func_80B96BEC(this, 0, 0); + func_80B96BEC(this, 0, ANIMMODE_LOOP); } if (!(this->unk_2F2 & 4)) { @@ -767,11 +766,11 @@ void func_80B97E4C(EnZot* this, PlayState* play) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x128C: this->unk_2F2 &= ~4; - func_80B96BEC(this, 6, 2); + func_80B96BEC(this, 6, ANIMMODE_ONCE); func_80151938(play, play->msgCtx.currentTextId + 1); break; @@ -785,7 +784,7 @@ void func_80B97E4C(EnZot* this, PlayState* play) { func_801477B4(play); this->actionFunc = func_80B97D6C; this->unk_2F2 |= 4; - func_80B96BEC(this, 3, 0); + func_80B96BEC(this, 3, ANIMMODE_LOOP); gSaveContext.save.weekEventReg[38] |= 8; break; @@ -807,7 +806,7 @@ void func_80B97FD0(EnZot* this, PlayState* play) { if ((this->actor.xzDistToPlayer < 120.0f) && (gSaveContext.save.playerForm == PLAYER_FORM_ZORA)) { this->unk_2F2 |= 4; this->actionFunc = func_80B97E0C; - func_80B96BEC(this, 6, 2); + func_80B96BEC(this, 6, ANIMMODE_ONCE); } } else if (Player_IsFacingActor(&this->actor, 0x3000, play) && (this->actor.xzDistToPlayer < 100.0f)) { func_800B8614(&this->actor, play, 120.0f); @@ -823,7 +822,7 @@ void func_80B980FC(EnZot* this, PlayState* play) { } else { this->actor.speedXZ = 8.0f; if (this->unk_2F0 != 3) { - func_80B96BEC(this, 3, 0); + func_80B96BEC(this, 3, ANIMMODE_LOOP); } } } @@ -952,17 +951,17 @@ void func_80B985EC(EnZot* this, PlayState* play) { Player* player = GET_PLAYER(play); func_80B98348(this, play); - if (Message_GetState(&play->msgCtx) == 0x10) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { itemActionParam = func_80123810(play); if (itemActionParam > PLAYER_AP_NONE) { func_801477B4(play); - if ((itemActionParam == PLAYER_AP_PICTO_BOX) && CHECK_QUEST_ITEM(QUEST_UNK_19) && func_8013A4C4(4)) { + if ((itemActionParam == PLAYER_AP_PICTO_BOX) && CHECK_QUEST_ITEM(QUEST_PICTOGRAPH) && func_8013A4C4(4)) { if (func_8013A4C4(5) && func_8013A4C4(6)) { player->actor.textId = 0x12AE; } else { player->actor.textId = 0x12AC; } - REMOVE_QUEST_ITEM(QUEST_UNK_19); + REMOVE_QUEST_ITEM(QUEST_PICTOGRAPH); } else { player->actor.textId = 0x12AB; } @@ -978,7 +977,7 @@ void func_80B98728(EnZot* this, PlayState* play) { func_80B98348(this, play); switch (Message_GetState(&play->msgCtx)) { - case 4: + case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x1293)) { switch (play->msgCtx.choiceIndex) { case 0: @@ -994,7 +993,7 @@ void func_80B98728(EnZot* this, PlayState* play) { } break; - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x1291: @@ -1091,7 +1090,7 @@ void func_80B98A4C(EnZot* this, PlayState* play) { } void func_80B98AD0(EnZot* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x12B1: case 0x12B4: @@ -1213,7 +1212,7 @@ void func_80B98F94(EnZot* this, PlayState* play) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x12BB: this->unk_2F2 &= ~4; @@ -1274,7 +1273,7 @@ void func_80B991E4(EnZot* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { u16 temp = play->msgCtx.currentTextId; u32 temp2; @@ -1284,7 +1283,7 @@ void func_80B991E4(EnZot* this, PlayState* play) { } else { func_801477B4(play); this->actionFunc = func_80B992C0; - func_80B96BEC(this, 1, 0); + func_80B96BEC(this, 1, ANIMMODE_LOOP); } } } @@ -1294,7 +1293,7 @@ void func_80B992C0(EnZot* this, PlayState* play) { this->actionFunc = func_80B991E4; func_80B99160(this, play); this->actor.speedXZ = 0.0f; - func_80B96BEC(this, 0, 0); + func_80B96BEC(this, 0, ANIMMODE_LOOP); } else { if (Player_IsFacingActor(&this->actor, 0x3000, play) && (this->actor.xzDistToPlayer < 100.0f)) { func_800B8614(&this->actor, play, 120.0f); diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.h b/src/overlays/actors/ovl_En_Zot/z_en_zot.h index 14da492d8..b72328b20 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.h +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.h @@ -11,22 +11,22 @@ typedef void (*EnZotActionFunc)(struct EnZot*, PlayState*); #define ENZOT_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) typedef struct EnZot { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ ColliderCylinder collider; - /* 0x01D4 */ Vec3s jointTable[20]; - /* 0x024C */ Vec3s morphTable[20]; - /* 0x02C4 */ Vec3s unk_2C4; - /* 0x02CA */ Vec3s unk_2CA; - /* 0x02D0 */ Path* path; - /* 0x02D4 */ s32 unk_2D4; - /* 0x02D8 */ Actor* unk_2D8[5]; - /* 0x02EC */ s16 unk_2EC; - /* 0x02EE */ s16 unk_2EE; - /* 0x02F0 */ s16 unk_2F0; - /* 0x02F2 */ u16 unk_2F2; - /* 0x02F4 */ s16 unk_2F4; - /* 0x02F8 */ EnZotActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderCylinder collider; + /* 0x1D4 */ Vec3s jointTable[20]; + /* 0x24C */ Vec3s morphTable[20]; + /* 0x2C4 */ Vec3s unk_2C4; + /* 0x2CA */ Vec3s unk_2CA; + /* 0x2D0 */ Path* path; + /* 0x2D4 */ s32 unk_2D4; + /* 0x2D8 */ Actor* unk_2D8[5]; + /* 0x2EC */ s16 unk_2EC; + /* 0x2EE */ s16 unk_2EE; + /* 0x2F0 */ s16 unk_2F0; + /* 0x2F2 */ u16 unk_2F2; + /* 0x2F4 */ s16 unk_2F4; + /* 0x2F8 */ EnZotActionFunc actionFunc; } EnZot; // size = 0x2FC extern const ActorInit En_Zot_InitVars; diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index 407b5562a..e026843e2 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -106,7 +106,7 @@ void EnZov_Init(Actor* thisx, PlayState* play) { switch (ENZOV_GET_F(&this->actor)) { case ENZOV_F_1: this->actionFunc = func_80BD1F1C; - func_80BD1570(this, 9, 0); + func_80BD1570(this, 9, ANIMMODE_LOOP); if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); return; @@ -150,7 +150,7 @@ void func_80BD1440(EnZov* this, s16 arg1) { void func_80BD1470(EnZov* this, s16 index, u8 mode, f32 transitionRate) { f32 frame; - if (((index != this->unk_322) || mode) && (index >= 0) && (index < ARRAY_COUNT(D_80BD270C))) { + if (((index != this->unk_322) || (mode != ANIMMODE_LOOP)) && (index >= 0) && (index < ARRAY_COUNT(D_80BD270C))) { switch (index) { case 6: frame = 30.0f; @@ -190,25 +190,25 @@ void func_80BD160C(EnZov* this, PlayState* play) { if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { textId = 0x1024; if ((this->unk_322 == 0) || (this->unk_322 == 4)) { - func_80BD1570(this, 4, 2); + func_80BD1570(this, 4, ANIMMODE_ONCE); } else { - func_80BD1570(this, 6, 2); + func_80BD1570(this, 6, ANIMMODE_ONCE); } } else if (this->unk_320 & 4) { textId = 0x1023; } else { textId = 0x1022; this->unk_320 |= 4; - func_80BD1570(this, 3, 2); + func_80BD1570(this, 3, ANIMMODE_ONCE); } } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - func_80BD1570(this, 2, 2); + func_80BD1570(this, 2, ANIMMODE_ONCE); this->actionFunc = func_80BD19FC; this->unk_324 = 10; func_80BD1440(this, 0); } else { textId = 0x1020; - func_80BD1570(this, 5, 2); + func_80BD1570(this, 5, ANIMMODE_ONCE); } this->unk_320 |= 1; @@ -222,32 +222,32 @@ void func_80BD1764(EnZov* this) { switch (this->unk_322) { case 1: case 6: - func_80BD1570(this, 6, 2); + func_80BD1570(this, 6, ANIMMODE_ONCE); break; case 3: case 7: - func_80BD1570(this, 7, 2); + func_80BD1570(this, 7, ANIMMODE_ONCE); break; case 4: - func_80BD1570(this, 0, 0); + func_80BD1570(this, 0, ANIMMODE_LOOP); break; case 8: - func_80BD1570(this, 9, 0); + func_80BD1570(this, 9, ANIMMODE_LOOP); break; case 10: - func_80BD1570(this, 11, 0); + func_80BD1570(this, 11, ANIMMODE_LOOP); break; case 12: - func_80BD1570(this, 13, 0); + func_80BD1570(this, 13, ANIMMODE_LOOP); break; default: - func_80BD1570(this, 0, 0); + func_80BD1570(this, 0, ANIMMODE_LOOP); this->unk_320 &= ~1; break; } @@ -260,7 +260,7 @@ void func_80BD187C(EnZov* this, PlayState* play) { func_80BD1764(this); switch (Message_GetState(&play->msgCtx)) { - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x1022: @@ -269,7 +269,7 @@ void func_80BD187C(EnZov* this, PlayState* play) { case 0x1023: if ((this->unk_322 != 6) && (this->unk_322 != 1)) { - func_80BD1570(this, 1, 2); + func_80BD1570(this, 1, ANIMMODE_ONCE); } func_801477B4(play); this->actionFunc = func_80BD1C84; @@ -277,7 +277,7 @@ void func_80BD187C(EnZov* this, PlayState* play) { case 0x1024: if (this->unk_322 != 6) { - func_80BD1570(this, 0, 0); + func_80BD1570(this, 0, ANIMMODE_LOOP); } func_801477B4(play); this->actionFunc = func_80BD1C84; @@ -285,7 +285,7 @@ void func_80BD187C(EnZov* this, PlayState* play) { default: this->unk_320 &= ~1; - func_80BD1570(this, 0, 0); + func_80BD1570(this, 0, ANIMMODE_LOOP); func_801477B4(play); this->actionFunc = func_80BD1C84; break; @@ -293,11 +293,11 @@ void func_80BD187C(EnZov* this, PlayState* play) { } break; - case 2: + case TEXT_STATE_CLOSING: func_801477B4(play); this->actionFunc = func_80BD1C84; this->unk_320 &= ~1; - func_80BD1570(this, 0, 0); + func_80BD1570(this, 0, ANIMMODE_LOOP); break; } } @@ -335,20 +335,20 @@ s32 func_80BD1AE0(EnZov* this, PlayState* play) { this->unk_326 = action; switch (this->unk_326) { case 1: - func_80BD1570(this, 0, 0); + func_80BD1570(this, 0, ANIMMODE_LOOP); break; case 2: - func_80BD1570(this, 8, 2); + func_80BD1570(this, 8, ANIMMODE_ONCE); this->unk_320 |= 0x10; break; case 3: - func_80BD1470(this, 10, 2, 0.0f); + func_80BD1470(this, 10, ANIMMODE_ONCE, 0.0f); break; case 4: - func_80BD1570(this, 12, 2); + func_80BD1570(this, 12, ANIMMODE_ONCE); break; } } @@ -360,7 +360,7 @@ s32 func_80BD1AE0(EnZov* this, PlayState* play) { void func_80BD1BF0(EnZov* this, PlayState* play) { if (!func_80BD1AE0(this, play)) { - func_80BD1570(this, 0, 0); + func_80BD1570(this, 0, ANIMMODE_LOOP); this->actionFunc = func_80BD1C84; } } @@ -411,7 +411,7 @@ void func_80BD1DB8(EnZov* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&play->msgCtx) == 5) && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x1033: case 0x1034: @@ -424,11 +424,11 @@ void func_80BD1DB8(EnZov* this, PlayState* play) { case 0x1039: play->nextEntranceIndex = play->setupExitList[ENZOV_GET_FE00(&this->actor)]; - play->unk_1887F = 5; - play->sceneLoadFlag = 0x14; + play->transitionType = TRANS_TYPE_05; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.save.weekEventReg[78] |= 1; this->actionFunc = func_80BD1D94; - play->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; Audio_QueueSeqCmd(0x101400FF); break; diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.h b/src/overlays/actors/ovl_En_Zov/z_en_zov.h index 4078424d9..cabb82b43 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.h +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.h @@ -15,26 +15,26 @@ typedef s32 (*EnZovUnkFunc)(PlayState*, struct EnZov*); #define ENZOV_F_2 2 typedef struct EnZov { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnZovUnkFunc unk_144; - /* 0x0148 */ Vec3s jontTable[23]; - /* 0x01D2 */ Vec3s morphTable[23]; - /* 0x025C */ SkelAnime skelAnime; - /* 0x02A0 */ ColliderCylinder collider; - /* 0x02EC */ s16 unk_2EC; - /* 0x02EE */ s16 unk_2EE; - /* 0x02F0 */ Vec3s unk_2F0; - /* 0x02F6 */ Vec3s unk_2F6; - /* 0x02FC */ Vec3f unk_2FC; - /* 0x0308 */ Vec3f unk_308; - /* 0x0314 */ Vec3f unk_314; - /* 0x0320 */ u16 unk_320; - /* 0x0322 */ s16 unk_322; - /* 0x0324 */ s16 unk_324; - /* 0x0326 */ s16 unk_326; - /* 0x0328 */ s16 unk_328[2]; - /* 0x032C */ s16 unk_32C; - /* 0x0330 */ EnZovActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ EnZovUnkFunc unk_144; + /* 0x148 */ Vec3s jontTable[23]; + /* 0x1D2 */ Vec3s morphTable[23]; + /* 0x25C */ SkelAnime skelAnime; + /* 0x2A0 */ ColliderCylinder collider; + /* 0x2EC */ s16 unk_2EC; + /* 0x2EE */ s16 unk_2EE; + /* 0x2F0 */ Vec3s unk_2F0; + /* 0x2F6 */ Vec3s unk_2F6; + /* 0x2FC */ Vec3f unk_2FC; + /* 0x308 */ Vec3f unk_308; + /* 0x314 */ Vec3f unk_314; + /* 0x320 */ u16 unk_320; + /* 0x322 */ s16 unk_322; + /* 0x324 */ s16 unk_324; + /* 0x326 */ s16 unk_326; + /* 0x328 */ s16 unk_328[2]; + /* 0x32C */ s16 unk_32C; + /* 0x330 */ EnZovActionFunc actionFunc; } EnZov; // size = 0x334 extern const ActorInit En_Zov_InitVars; diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index fa90b6a7f..4779fdedd 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -439,9 +439,9 @@ void func_80BDD490(EnZow* this, PlayState* play) { this->actor.velocity.y = 0.0f; if (this->actor.xzDistToPlayer > 440.0f) { this->actionFunc = func_80BDD350; - func_80BDD04C(this, 2, 2); + func_80BDD04C(this, 2, ANIMMODE_ONCE); } else if (this->unk_2CA & 2) { - func_80BDD04C(this, 0, 0); + func_80BDD04C(this, 0, ANIMMODE_LOOP); } if ((play->gameplayFrames & 7) == 0) { @@ -459,7 +459,7 @@ void func_80BDD570(EnZow* this, PlayState* play) { func_80BDD490(this, play); switch (Message_GetState(&play->msgCtx)) { - case 5: + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x12E8: @@ -487,7 +487,7 @@ void func_80BDD570(EnZow* this, PlayState* play) { } break; - case 2: + case TEXT_STATE_CLOSING: this->actionFunc = func_80BDD634; break; } @@ -513,7 +513,7 @@ void func_80BDD6BC(EnZow* this, PlayState* play) { if (this->actor.depthInWater < 54.0f) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); func_80BDCDA8(this, this->unk_2D0); - func_80BDD04C(this, 1, 2); + func_80BDD04C(this, 1, ANIMMODE_ONCE); this->actor.flags |= ACTOR_FLAG_1; this->actor.velocity.y = 0.0f; this->actionFunc = func_80BDD634; diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.h b/src/overlays/actors/ovl_En_Zow/z_en_zow.h index 8faeae73f..777a0aa9d 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.h +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.h @@ -24,19 +24,19 @@ typedef struct { } EnZowStruct; // size = 0x38 typedef struct EnZow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ ColliderCylinder collider; - /* 0x01D4 */ Vec3s jointTable[20]; - /* 0x024C */ Vec3s morphTable[20]; - /* 0x02C4 */ s16 unk_2C4; - /* 0x02C6 */ s16 unk_2C6; - /* 0x02C8 */ s16 unk_2C8; - /* 0x02CA */ u16 unk_2CA; - /* 0x02CC */ s16 unk_2CC; - /* 0x02CE */ s16 unk_2CE; - /* 0x02D0 */ EnZowStruct unk_2D0[15]; - /* 0x0618 */ EnZowActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderCylinder collider; + /* 0x1D4 */ Vec3s jointTable[20]; + /* 0x24C */ Vec3s morphTable[20]; + /* 0x2C4 */ s16 unk_2C4; + /* 0x2C6 */ s16 unk_2C6; + /* 0x2C8 */ s16 unk_2C8; + /* 0x2CA */ u16 unk_2CA; + /* 0x2CC */ s16 unk_2CC; + /* 0x2CE */ s16 unk_2CE; + /* 0x2D0 */ EnZowStruct unk_2D0[15]; + /* 0x618 */ EnZowActionFunc actionFunc; } EnZow; // size = 0x61C extern const ActorInit En_Zow_InitVars; diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h index d859b5713..aac8d0834 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h @@ -11,20 +11,20 @@ struct ItemEtcetera; typedef void (*ItemEtceteraActionFunc)(struct ItemEtcetera*, PlayState*); typedef enum { - /* 0x00 */ ITEM_ETC_BOTTLE_1, - /* 0x01 */ ITEM_ETC_BOTTLE_2, - /* 0x02 */ ITEM_ETC_BOTTLE_3, - /* 0x03 */ ITEM_ETC_BOTTLE_4, - /* 0x04 */ ITEM_ETC_BOTTLE_5, - /* 0x05 */ ITEM_ETC_BOTTLE_6, - /* 0x06 */ ITEM_ETC_KEY_SMALL, - /* 0x07 */ ITEM_ETC_ARROW_FIRE, - /* 0x08 */ ITEM_ETC_RUPEE_GREEN_CHEST_GAME, - /* 0x09 */ ITEM_ETC_RUPEE_BLUE_CHEST_GAME, - /* 0x0A */ ITEM_ETC_RUPEE_RED_CHEST_GAME, - /* 0x0B */ ITEM_ETC_RUPEE_PURPLE_CHEST_GAME, - /* 0x0C */ ITEM_ETC_HEART_PIECE_CHEST_GAME, - /* 0x0D */ ITEM_ETC_KEY_SMALL_CHEST_GAME + /* 0x0 */ ITEM_ETC_BOTTLE_1, + /* 0x1 */ ITEM_ETC_BOTTLE_2, + /* 0x2 */ ITEM_ETC_BOTTLE_3, + /* 0x3 */ ITEM_ETC_BOTTLE_4, + /* 0x4 */ ITEM_ETC_BOTTLE_5, + /* 0x5 */ ITEM_ETC_BOTTLE_6, + /* 0x6 */ ITEM_ETC_KEY_SMALL, + /* 0x7 */ ITEM_ETC_ARROW_FIRE, + /* 0x8 */ ITEM_ETC_RUPEE_GREEN_CHEST_GAME, + /* 0x9 */ ITEM_ETC_RUPEE_BLUE_CHEST_GAME, + /* 0xA */ ITEM_ETC_RUPEE_RED_CHEST_GAME, + /* 0xB */ ITEM_ETC_RUPEE_PURPLE_CHEST_GAME, + /* 0xC */ ITEM_ETC_HEART_PIECE_CHEST_GAME, + /* 0xD */ ITEM_ETC_KEY_SMALL_CHEST_GAME } ItemEtceteraType; typedef struct ItemEtcetera { diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c index fa7bf1adb..5160dc074 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -98,7 +98,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_NONE, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -602,7 +602,7 @@ void MirRay_Draw(Actor* thisx, PlayState* play) { this->reflectIntensity = 0.0f; - if (!D_808E3BF0 && !this->unLit && func_80124088(play)) { + if (!D_808E3BF0 && !this->unLit && Player_IsHoldingMirrorShield(play)) { Matrix_Mult(&player->shieldMf, MTXMODE_NEW); MirRay_SetIntensity(this, play); diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h index 4d748e3b5..3ba21c444 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h @@ -9,35 +9,35 @@ struct MirRay; // Locations of light beams in sMirRayData typedef enum { - /* 0 */ MIRRAY_SPIRIT_BOMBCHUIWAROOM_DOWNLIGHT, - /* 1 */ MIRRAY_SPIRIT_SUNBLOCKROOM_DOWNLIGHT, - /* 2 */ MIRRAY_SPIRIT_SINGLECOBRAROOM_DOWNLIGHT, - /* 3 */ MIRRAY_SPIRIT_ARMOSROOM_DOWNLIGHT, - /* 4 */ MIRRAY_SPIRIT_TOPROOM_DOWNLIGHT, - /* 5 */ MIRRAY_SPIRIT_TOPROOM_CEILINGMIRROR, - /* 6 */ MIRRAY_SPIRIT_SINGLECOBRAROOM_COBRA, - /* 7 */ MIRRAY_SPIRIT_TOPROOM_COBRA1, - /* 8 */ MIRRAY_SPIRIT_TOPROOM_COBRA2, - /* 9 */ MIRRAY_GANONSCASTLE_SPIRITTRIAL_DOWNLIGHT, - /* 10 */ MIRRAY_MAX, + /* 0x0 */ MIRRAY_SPIRIT_BOMBCHUIWAROOM_DOWNLIGHT, + /* 0x1 */ MIRRAY_SPIRIT_SUNBLOCKROOM_DOWNLIGHT, + /* 0x2 */ MIRRAY_SPIRIT_SINGLECOBRAROOM_DOWNLIGHT, + /* 0x3 */ MIRRAY_SPIRIT_ARMOSROOM_DOWNLIGHT, + /* 0x4 */ MIRRAY_SPIRIT_TOPROOM_DOWNLIGHT, + /* 0x5 */ MIRRAY_SPIRIT_TOPROOM_CEILINGMIRROR, + /* 0x6 */ MIRRAY_SPIRIT_SINGLECOBRAROOM_COBRA, + /* 0x7 */ MIRRAY_SPIRIT_TOPROOM_COBRA1, + /* 0x8 */ MIRRAY_SPIRIT_TOPROOM_COBRA2, + /* 0x9 */ MIRRAY_GANONSCASTLE_SPIRITTRIAL_DOWNLIGHT, + /* 0xA */ MIRRAY_MAX, } MirRayBeamLocations; typedef struct MirRay { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderJntSph collider1; - /* 0x0164 */ ColliderJntSphElement collider1Elements[1]; - /* 0x01A4 */ ColliderQuad collider2; - /* 0x0224 */ f32 reflectIntensity; // Reflection occurs if it is positive, brightness depends on it - /* 0x0228 */ Vec3f shieldCorners[6]; - /* 0x0270 */ f32 reflectRange; - /* 0x0274 */ Vec3f sourcePt; - /* 0x0280 */ Vec3f poolPt; - /* 0x028C */ s16 sourceEndRad; - /* 0x028E */ s16 poolEndRad; - /* 0x0290 */ s16 lightPointRad; - /* 0x0294 */ LightNode* lightNode; - /* 0x0298 */ LightInfo lightInfo; - /* 0x02A6 */ u8 unLit; // Conditioned on. set in Cobra? + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider1; + /* 0x164 */ ColliderJntSphElement collider1Elements[1]; + /* 0x1A4 */ ColliderQuad collider2; + /* 0x224 */ f32 reflectIntensity; // Reflection occurs if it is positive, brightness depends on it + /* 0x228 */ Vec3f shieldCorners[6]; + /* 0x270 */ f32 reflectRange; + /* 0x274 */ Vec3f sourcePt; + /* 0x280 */ Vec3f poolPt; + /* 0x28C */ s16 sourceEndRad; + /* 0x28E */ s16 poolEndRad; + /* 0x290 */ s16 lightPointRad; + /* 0x294 */ LightNode* lightNode; + /* 0x298 */ LightInfo lightInfo; + /* 0x2A6 */ u8 unLit; // Conditioned on. set in Cobra? } MirRay; // size = 0x2A8 extern const ActorInit Mir_Ray_InitVars; diff --git a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c index 3361e3a1f..6acbc2689 100644 --- a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c +++ b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c @@ -39,7 +39,7 @@ static ColliderJntSphElementInit D_80AF4350[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80AF4374 = { { COLTYPE_NONE, AT_ON | AT_TYPE_OTHER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 1, D_80AF4350, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80AF4350, // sJntSphElementsInit, }; #endif diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c index 1127be69e..66a14a2a6 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c @@ -127,7 +127,7 @@ void MirRay3_Update(Actor* thisx, PlayState* play) { this->unk_210 &= ~2; - if (func_8012405C(play)) { + if (Player_HasMirrorShieldEquipped(play)) { if (this->colliderCylinder.base.acFlags & AC_HIT) { this->unk_210 |= 2; } @@ -353,7 +353,7 @@ void MirRay3_Draw(Actor* thisx, PlayState* play) { f32 temp; u16 time; - if (!(this->unk_210 & 1) && func_8012405C(play)) { + if (!(this->unk_210 & 1) && Player_HasMirrorShieldEquipped(play)) { Matrix_Mult(&player->shieldMf, MTXMODE_NEW); func_80B9E544(this, play); 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 262de706c..7c7359040 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -267,7 +267,7 @@ void ObjAqua_Draw(Actor* thisx, PlayState* play) { ObjAqua* this = THIS; s32 framesTemp; s32 pad; - s16 yaw = Camera_GetCamDirYaw(play->cameraPtrs[play->activeCamera]) + 0x8000; + s16 yaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000; s32 actionFuncTemp = this->actionFunc == func_80ACBDFC; OPEN_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h index bffe794d5..fa2b1c636 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h @@ -11,12 +11,12 @@ struct ObjAqua; typedef void (*ObjAquaActionFunc)(struct ObjAqua*, PlayState*); typedef struct ObjAqua { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ ObjAquaActionFunc actionFunc; - /* 0x0194 */ s16 counter; - /* 0x0196 */ u8 alpha; - /* 0x0198 */ s16 unk_198; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ ObjAquaActionFunc actionFunc; + /* 0x194 */ s16 counter; + /* 0x196 */ u8 alpha; + /* 0x198 */ s16 unk_198; } ObjAqua; // size = 0x19C extern const ActorInit Obj_Aqua_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h index ab92c6b85..a0c91f214 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h @@ -23,19 +23,19 @@ enum { }; typedef struct ObjArmos { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ SkelAnime skelAnime; - /* 0x01A0 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; - /* 0x01F4 */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; - /* 0x0248 */ ObjArmosActionFunc actionFunc; - /* 0x024C */ u32 unk_24C; - /* 0x0250 */ Vec3f unk_250; - /* 0x025C */ f32* unk_25C; - /* 0x0260 */ f32 unk_260; - /* 0x0264 */ s16 unk_264; - /* 0x0266 */ s16 unk_266[4]; - /* 0x026E */ s16 unk_26E; - /* 0x0270 */ s16 unk_270; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; + /* 0x1F4 */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; + /* 0x248 */ ObjArmosActionFunc actionFunc; + /* 0x24C */ u32 unk_24C; + /* 0x250 */ Vec3f unk_250; + /* 0x25C */ f32* unk_25C; + /* 0x260 */ f32 unk_260; + /* 0x264 */ s16 unk_264; + /* 0x266 */ s16 unk_266[4]; + /* 0x26E */ s16 unk_26E; + /* 0x270 */ s16 unk_270; } ObjArmos; // size = 0x274 extern const ActorInit Obj_Armos_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.h b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.h index 7ff2610aa..5af772007 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.h +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.h @@ -17,9 +17,9 @@ typedef void (*ObjBeanUnkFunc)(struct ObjBean*); #define OBJBEAN_GET_3(thisx) ((thisx)->home.rot.z & 3) enum { - /* 0x00 */ ENOBJBEAN_GET_C000_0, - /* 0x01 */ ENOBJBEAN_GET_C000_1, - /* 0x02 */ ENOBJBEAN_GET_C000_2, + /* 0x0 */ ENOBJBEAN_GET_C000_0, + /* 0x1 */ ENOBJBEAN_GET_C000_1, + /* 0x2 */ ENOBJBEAN_GET_C000_2, }; typedef struct ObjBean { diff --git a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c index e1edaf0f7..7f59fe579 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c @@ -6,6 +6,7 @@ #include "z_obj_bigicicle.h" #include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_bigicicle/object_bigicicle.h" #define FLAGS 0x00000000 @@ -166,8 +167,8 @@ void func_80AE8DE4(ObjBigicicle* this, PlayState* play) { sp8C.y = Rand_ZeroFloat(2.0f); sp8C.z = randPlusMinusPoint5Scaled(13.0f); - EffectSsHahen_Spawn(play, &sp98, &sp8C, &D_80AE987C, 2, (Rand_ZeroFloat(20.0f) + 30.0f) * temp_f20, - OBJECT_BIGICICLE, 0x28, object_bigicicle_DL_0009B0); + EffectSsHahen_Spawn(play, &sp98, &sp8C, &D_80AE987C, HAHEN_XLU, (Rand_ZeroFloat(20.0f) + 30.0f) * temp_f20, + OBJECT_BIGICICLE, 40, object_bigicicle_DL_0009B0); } sp98.x = this->actor.world.pos.x; @@ -278,7 +279,7 @@ void func_80AE939C(ObjBigicicle* this, PlayState* play) { sp98.y = this->actor.world.pos.y + (sp8C.y * 7.0f * temp_f20); sp98.z = this->actor.world.pos.z + (sp8C.z * 5.0f * temp_f20); - EffectSsHahen_Spawn(play, &sp98, &sp8C, &D_80AE987C, 2, (Rand_ZeroFloat(30.0f) + 40.0f) * temp_f20, + EffectSsHahen_Spawn(play, &sp98, &sp8C, &D_80AE987C, HAHEN_XLU, (Rand_ZeroFloat(30.0f) + 40.0f) * temp_f20, OBJECT_BIGICICLE, 30, object_bigicicle_DL_0009B0); } diff --git a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h index 3023ab085..7e28abd45 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h @@ -10,13 +10,13 @@ typedef void (*ObjBigicicleActionFunc)(struct ObjBigicicle*, PlayState*); #define OBJBIGICLE_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) typedef struct ObjBigicicle { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjBigicicleActionFunc actionFunc; - /* 0x0148 */ u8 unk_148; - /* 0x0149 */ u8 unk_149; - /* 0x014A */ s16 unk_14A; - /* 0x014C */ ColliderCylinder collider1; - /* 0x0198 */ ColliderCylinder collider2; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjBigicicleActionFunc actionFunc; + /* 0x148 */ u8 unk_148; + /* 0x149 */ u8 unk_149; + /* 0x14A */ s16 unk_14A; + /* 0x14C */ ColliderCylinder collider1; + /* 0x198 */ ColliderCylinder collider2; } ObjBigicicle; // size = 0x1E4 extern const ActorInit Obj_Bigicicle_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.h b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.h index 6f191f79a..95af6757c 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.h +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.h @@ -8,8 +8,8 @@ struct ObjBlockstop; typedef void (*ObjBlockstopActionFunc)(struct ObjBlockstop*, PlayState*); typedef struct ObjBlockstop { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjBlockstopActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjBlockstopActionFunc actionFunc; } ObjBlockstop; // size = 0x148 extern const ActorInit Obj_Blockstop_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h index 110b89dde..a3ed2b147 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h @@ -18,7 +18,7 @@ typedef struct ObjBoat { /* 0x162 */ UNK_TYPE1 pad_162; /* 0x163 */ u8 unk_163; /* 0x164 */ Vec3s* unk_164; -} ObjBoat; +} ObjBoat; // size = 0x168 extern const ActorInit Obj_Boat_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c index 8706fd696..27f3e13aa 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c @@ -12,7 +12,7 @@ #define THIS ((ObjBombiwa*)thisx) void ObjBombiwa_Init(Actor* thisx, PlayState* play); -void ObjBombiwa_Destroy(Actor* thisx, PlayState* play); +void ObjBombiwa_Destroy(Actor* thisx, PlayState* play2); void ObjBombiwa_Update(Actor* thisx, PlayState* play); s32 func_809393B0(Actor* thisx); @@ -206,8 +206,11 @@ void ObjBombiwa_Init(Actor* thisx, PlayState* play) { func_80939EE0(this); } -void ObjBombiwa_Destroy(Actor* thisx, PlayState* play) { - Collider_DestroyCylinder(play, &THIS->collider); +void ObjBombiwa_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + ObjBombiwa* this = THIS; + + Collider_DestroyCylinder(play, &this->collider); } void func_80939794(ObjBombiwa* this, PlayState* play) { diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h index 602b3a788..50e0bbf92 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h @@ -22,14 +22,14 @@ typedef struct { } ObjBombiwaStruct; // size = 0x1C typedef struct ObjBombiwa { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ ObjBombiwaStruct unk_190[4]; - /* 0x0200 */ s8 unk_200; - /* 0x0201 */ s8 unk_201; - /* 0x0202 */ s8 unk_202; - /* 0x0203 */ u8 unk_203; - /* 0x0204 */ ObjBombiwaActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ ObjBombiwaStruct unk_190[4]; + /* 0x200 */ s8 unk_200; + /* 0x201 */ s8 unk_201; + /* 0x202 */ s8 unk_202; + /* 0x203 */ u8 unk_203; + /* 0x204 */ ObjBombiwaActionFunc actionFunc; } ObjBombiwa; // size = 0x208 extern const ActorInit Obj_Bombiwa_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.h b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.h index e3104d723..69e188530 100644 --- a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.h +++ b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.h @@ -10,7 +10,7 @@ typedef void (*BumperCollideActorFunc)(struct ObjBoyo*, void*); typedef struct { /* 0x0 */ s16 id; /* 0x4 */ BumperCollideActorFunc actorCollideFunc; -} BumperCollideInfo; +} BumperCollideInfo; // size = 0x8 typedef struct ObjBoyo { /* 0x000 */ Actor actor; diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index 0e6b48356..7bfeaf96c 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -426,7 +426,7 @@ void ObjChan_DrawFire(ObjChan* this, PlayState* play) { dl = func_8012C2B4(POLY_XLU_DISP); gSPMatrix(&dl[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); - gMoveWd(&dl[1], 6, 32, Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0U, -sp4C * 20, 32, 128)); + gSPSegment(&dl[1], 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, -sp4C * 20, 32, 128)); gDPSetPrimColor(&dl[2], 128, 128, 255, 255, 0, 255); gDPSetEnvColor(&dl[3], 255, 0, 0, 0); gSPDisplayList(&dl[4], &gGameplayKeepDrawFlameDL); diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h index 4a689fa09..a3a4e6d93 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h @@ -39,22 +39,22 @@ struct ObjChan; typedef void (*ObjChanActionFunc)(struct ObjChan*, PlayState*); typedef struct ObjChan { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjChanActionFunc actionFunc; - /* 0x0148 */ ColliderCylinder collider; - /* 0x0194 */ u8 myPotIndex; // For OBJCHAN_SUBTYPE_POT: which pot is this? - /* 0x0196 */ s16 fireDelayFrames; - /* 0x0198 */ UNK_TYPE1 unk198[0x12]; - /* 0x01AA */ u8 stateFlags; - /* 0x01AC */ struct ObjChan* pots[5]; // For OBJCHAN_SUBTYPE_BODY: pointers to pot actors - /* 0x01C0 */ Vec3f unk1C0; - /* 0x01CC */ f32 unk1CC; - /* 0x01D0 */ f32 unk1D0; - /* 0x01D4 */ s16 unk1D4; - /* 0x01D8 */ f32 flameSize; - /* 0x01DC */ s16 rotationSpeed; // Main object only. Slowly ramps up under some circumstances. In other circumstances it's immediately set to maximum speed. - /* 0x01DE */ s16 rotation; // Increases as the chandelier spins. Don't know why they didn't use the actor's rotation variable. - /* 0x01E0 */ s16 cutscenes[2]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjChanActionFunc actionFunc; + /* 0x148 */ ColliderCylinder collider; + /* 0x194 */ u8 myPotIndex; // For OBJCHAN_SUBTYPE_POT: which pot is this? + /* 0x196 */ s16 fireDelayFrames; + /* 0x198 */ UNK_TYPE1 unk198[0x12]; + /* 0x1AA */ u8 stateFlags; + /* 0x1AC */ struct ObjChan* pots[5]; // For OBJCHAN_SUBTYPE_BODY: pointers to pot actors + /* 0x1C0 */ Vec3f unk1C0; + /* 0x1CC */ f32 unk1CC; + /* 0x1D0 */ f32 unk1D0; + /* 0x1D4 */ s16 unk1D4; + /* 0x1D8 */ f32 flameSize; + /* 0x1DC */ s16 rotationSpeed; // Main object only. Slowly ramps up under some circumstances. In other circumstances it's immediately set to maximum speed. + /* 0x1DE */ s16 rotation; // Increases as the chandelier spins. Don't know why they didn't use the actor's rotation variable. + /* 0x1E0 */ s16 cutscenes[2]; } ObjChan; // size = 0x1E4 extern const ActorInit Obj_Chan_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c index ee48a2c40..769266e97 100644 --- a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c +++ b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c @@ -5,6 +5,7 @@ */ #include "z_obj_chikuwa.h" +#include "objects/object_d_lift/object_d_lift.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,6 @@ void ObjChikuwa_Destroy(Actor* thisx, PlayState* play); void ObjChikuwa_Update(Actor* thisx, PlayState* play); void ObjChikuwa_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Obj_Chikuwa_InitVars = { ACTOR_OBJ_CHIKUWA, ACTORCAT_BG, @@ -28,31 +28,206 @@ const ActorInit Obj_Chikuwa_InitVars = { (ActorFunc)ObjChikuwa_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809B1FC0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +Vec3f D_809B1FD0 = { 0.0f, -0.3f, 0.0f }; +Vec3f D_809B1FDC = { 0.0f, 0.7f, 0.0f }; -extern InitChainEntry D_809B1FC0[]; +void func_809B1550(Actor* thisx, PlayState* play) { + ObjChikuwa* this = THIS; + f32 sp18; -extern UNK_TYPE D_06000D10; -extern UNK_TYPE D_06000F00; + if (this->unk_2A0 < this->unk_29C) { + thisx->scale.z = (this->unk_29C - this->unk_2A0) * 0.05f; + sp18 = (((this->unk_29C + this->unk_2A0) * 60) - 60) * 0.5f; + thisx->world.pos.x = (Math_SinS(thisx->shape.rot.y) * sp18) + thisx->home.pos.x; + thisx->world.pos.z = (Math_CosS(thisx->shape.rot.y) * sp18) + thisx->home.pos.z; + } else { + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chikuwa/func_809B1550.s") +void ObjChikuwa_Init(Actor* thisx, PlayState* play) { + ObjChikuwa* this = THIS; + s32 i; + s32 val; + ObjChikuwaStruct* temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chikuwa/ObjChikuwa_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chikuwa/ObjChikuwa_Destroy.s") + this->dyna.actor.scale.x = 0.15f; + this->dyna.actor.scale.y = 0.2f; + this->dyna.actor.scale.z = 0.05f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chikuwa/func_809B17D0.s") + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, &gDampeGraveBrownElevatorCol); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chikuwa/func_809B1AA0.s") + this->dyna.actor.home.rot.y += 0x2000; + this->dyna.actor.home.rot.y &= 0xC000; + this->unk_29C = 20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chikuwa/ObjChikuwa_Update.s") + this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y; + this->dyna.actor.world.rot.y = this->dyna.actor.home.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chikuwa/ObjChikuwa_Draw.s") + for (val = 0, i = 0; i < this->unk_29C; i++, val += 7) { + temp = &this->unk_15C[i]; + + temp->unk_00.x = thisx->home.pos.x + (Math_SinS(thisx->shape.rot.y) * (i * 60)); + temp->unk_00.y = thisx->home.pos.y; + temp->unk_00.z = thisx->home.pos.z + (Math_CosS(thisx->shape.rot.y) * (i * 60)); + temp->unk_0C = val + 100; + } + + func_809B1550(thisx, play); +} + +void ObjChikuwa_Destroy(Actor* thisx, PlayState* play) { + ObjChikuwa* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} + +void func_809B17D0(PlayState* play, ObjChikuwa* this, Vec3f* arg2) { + ObjChikuwaStruct2* temp_s0; + f32 var_fs2; + f32 temp; + s32 i; + + for (i = 0, var_fs2 = -78.75f; i < 8; var_fs2 += 22.5f) { + temp_s0 = &this->unk_2A4[this->unk_9A4]; + + temp_s0->unk_00.x = (Rand_ZeroOne() * 0.05f) + 0.01f; + temp_s0->unk_00.y = (Rand_ZeroOne() * 0.16f) + 0.04f; + temp_s0->unk_00.z = (Rand_ZeroOne() * 0.05f) + 0.01f; + + temp_s0->unk_0C.x = (Math_CosS(this->dyna.actor.shape.rot.y) * var_fs2) + arg2->x; + temp_s0->unk_0C.y = arg2->y; + temp_s0->unk_0C.z = (Math_SinS(this->dyna.actor.shape.rot.y) * var_fs2) + arg2->z; + + temp_s0->unk_18 = (2.0f * Rand_ZeroOne()) - 1.0f; + temp_s0->unk_1C = (Rand_ZeroOne() * 4.0f) - 1.0f; + temp_s0->unk_20 = (2.0f * Rand_ZeroOne()) - 1.0f; + + temp = Math3D_Vec3fMagnitude(&temp_s0->unk_00); + temp_s0->unk_24 = (-Rand_ZeroOne() * 0.5f) - temp * 25.0f; + + temp_s0->unk_28.x = this->dyna.actor.shape.rot.x; + temp_s0->unk_28.y = this->dyna.actor.shape.rot.y; + temp_s0->unk_28.z = this->dyna.actor.shape.rot.z; + + temp_s0->unk_2E.x = (Rand_ZeroOne() - 0.5f) * 5000.0f; + temp_s0->unk_2E.y = (Rand_ZeroOne() - 0.5f) * 5000.0f; + temp_s0->unk_2E.z = (Rand_ZeroOne() - 0.5f) * 5000.0f; + + temp_s0->unk_34 = 80; + func_800B1210(play, &temp_s0->unk_0C, &D_809B1FDC, &D_809B1FD0, (Rand_ZeroOne() * 60.0f) + 80.0f, + (Rand_ZeroOne() * 30.0f) + 60.0f); + this->unk_9A4 = (this->unk_9A4 + 1) & 0x1F; + i++; + } +} + +void func_809B1AA0(ObjChikuwa* this) { + ObjChikuwaStruct2* temp_v0; + s32 i; + + this->unk_9A6 = 0; + + for (i = 0; i < ARRAY_COUNT(this->unk_2A4); i++) { + temp_v0 = &this->unk_2A4[i]; + if (temp_v0->unk_34 > 0) { + temp_v0->unk_34--; + this->unk_9A6 = 1; + temp_v0->unk_1C += temp_v0->unk_24; + temp_v0->unk_0C.x += temp_v0->unk_18; + temp_v0->unk_0C.y += temp_v0->unk_1C; + temp_v0->unk_0C.z += temp_v0->unk_20; + temp_v0->unk_28.x += temp_v0->unk_2E.x; + temp_v0->unk_28.y += temp_v0->unk_2E.y; + temp_v0->unk_28.z += temp_v0->unk_2E.z; + } + } +} + +void ObjChikuwa_Update(Actor* thisx, PlayState* play) { + ObjChikuwa* this = THIS; + ObjChikuwaStruct* temp; + f32 temp_fs0; + s16 var_s2; + s32 i; + s32 quake; + + this->unk_29E++; + + for (i = 0; i < this->unk_29C; i++) { + temp = &this->unk_15C[i]; + if ((this->unk_29E >= temp->unk_0C) && !(temp->unk_0E & 1)) { + temp->unk_0E |= 1; + this->unk_2A0++; + func_809B1550(&this->dyna.actor, play); + func_809B17D0(play, this, &temp->unk_00); + temp_fs0 = Math3D_Vec3fDistSq(&temp->unk_00, &GET_PLAYER(play)->actor.world.pos); + if (temp_fs0 < SQ(240.0f)) { + quake = Quake_Add(GET_ACTIVE_CAM(play), 3); + if (temp_fs0 < SQ(120.0f)) { + var_s2 = 4; + } else { + var_s2 = 3; + } + + Quake_SetSpeed(quake, 0x4350); + Quake_SetQuakeValues(quake, var_s2, 0, 0, 0); + Quake_SetCountdown(quake, 7); + } + } + } + + func_809B1AA0(this); +} + +void ObjChikuwa_Draw(Actor* thisx, PlayState* play) { + ObjChikuwa* this = THIS; + ObjChikuwaStruct* temp; + ObjChikuwaStruct2* temp2; + s32 i; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + if (this->unk_2A0 < this->unk_29C) { + for (i = 0; i < this->unk_29C; i++) { + temp = &this->unk_15C[i]; + if (!(temp->unk_0E & 1)) { + Matrix_SetTranslateRotateYXZ(temp->unk_00.x, temp->unk_00.y, temp->unk_00.z, + &this->dyna.actor.shape.rot); + Matrix_Scale(0.15f, 0.2f, 0.05f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDampeGraveBrownElevatorDL); + } + } + } + + if (this->unk_9A6 != 0) { + for (i = 0; i < ARRAY_COUNT(this->unk_2A4); i++) { + temp2 = &this->unk_2A4[i]; + if (temp2->unk_34 > 0) { + Matrix_SetTranslateRotateYXZ(temp2->unk_0C.x, temp2->unk_0C.y, temp2->unk_0C.z, &temp2->unk_28); + Matrix_Scale(temp2->unk_00.x, temp2->unk_00.y, temp2->unk_00.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDampeGraveBrownElevatorDL); + } + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.h b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.h index 1e869a220..7ebba3021 100644 --- a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.h +++ b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.h @@ -5,9 +5,33 @@ struct ObjChikuwa; +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ u8 unk_0E; +} ObjChikuwaStruct; // size = 0x10 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ f32 unk_20; + /* 0x24 */ f32 unk_24; + /* 0x28 */ Vec3s unk_28; + /* 0x2E */ Vec3s unk_2E; + /* 0x34 */ s16 unk_34; +} ObjChikuwaStruct2; // size = 0x38 + typedef struct ObjChikuwa { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x864]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjChikuwaStruct unk_15C[20]; + /* 0x29C */ s16 unk_29C; + /* 0x29E */ s16 unk_29E; + /* 0x2A0 */ s16 unk_2A0; + /* 0x2A4 */ ObjChikuwaStruct2 unk_2A4[32]; + /* 0x9A4 */ s16 unk_9A4; + /* 0x9A6 */ u8 unk_9A6; } ObjChikuwa; // size = 0x9A8 extern const ActorInit Obj_Chikuwa_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c index 9b5c302d3..2ce8f6ef3 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -12,7 +12,7 @@ #define THIS ((ObjComb*)thisx) void ObjComb_Init(Actor* thisx, PlayState* play); -void ObjComb_Destroy(Actor* thisx, PlayState* play); +void ObjComb_Destroy(Actor* thisx, PlayState* play2); void ObjComb_Update(Actor* thisx, PlayState* play); void ObjComb_Draw(Actor* thisx, PlayState* play); @@ -57,7 +57,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -352,8 +352,11 @@ void ObjComb_Init(Actor* thisx, PlayState* play) { func_8098DC44(this); } -void ObjComb_Destroy(Actor* thisx, PlayState* play) { - Collider_DestroyJntSph(play, &THIS->collider); +void ObjComb_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + ObjComb* this = THIS; + + Collider_DestroyJntSph(play, &this->collider); } void func_8098DC44(ObjComb* this) { diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h index 709740b59..ed5188576 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h @@ -16,22 +16,22 @@ typedef void (*ObjCombActionFunc)(struct ObjComb*, PlayState*); #define OBJCOMB_GET_8000(thisx) (((thisx)->params >> 0xE) & 2) typedef struct ObjComb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjCombActionFunc actionFunc; - /* 0x0148 */ ColliderJntSph collider; - /* 0x0168 */ ColliderJntSphElement colliderElement; - /* 0x01A8 */ s16 unk_1A8; - /* 0x01AA */ s16 unk_1AA; - /* 0x01AC */ s16 unk_1AC; - /* 0x01AE */ s16 unk_1AE; - /* 0x01B0 */ s16 unk_1B0; - /* 0x01B2 */ s8 unk_1B2; - /* 0x01B3 */ s8 unk_1B3; - /* 0x01B4 */ s8 unk_1B4; - /* 0x01B5 */ s8 unk_1B5; - /* 0x01B6 */ s8 unk_1B6; - /* 0x01B7 */ s8 unk_1B7; - /* 0x01B8 */ s8 unk_1B8; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjCombActionFunc actionFunc; + /* 0x148 */ ColliderJntSph collider; + /* 0x168 */ ColliderJntSphElement colliderElement; + /* 0x1A8 */ s16 unk_1A8; + /* 0x1AA */ s16 unk_1AA; + /* 0x1AC */ s16 unk_1AC; + /* 0x1AE */ s16 unk_1AE; + /* 0x1B0 */ s16 unk_1B0; + /* 0x1B2 */ s8 unk_1B2; + /* 0x1B3 */ s8 unk_1B3; + /* 0x1B4 */ s8 unk_1B4; + /* 0x1B5 */ s8 unk_1B5; + /* 0x1B6 */ s8 unk_1B6; + /* 0x1B7 */ s8 unk_1B7; + /* 0x1B8 */ s8 unk_1B8; } ObjComb; // size = 0x1BC extern const ActorInit Obj_Comb_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.h b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.h index ee687ae6e..8b915a184 100644 --- a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.h +++ b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.h @@ -8,10 +8,10 @@ struct ObjDanpeilift; typedef void (*ObjDanpeiliftActionFunc)(struct ObjDanpeilift*, PlayState*); typedef struct ObjDanpeilift { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjDanpeiliftActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x2C]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x18]; + /* 0x15C */ ObjDanpeiliftActionFunc actionFunc; + /* 0x160 */ char unk_160[0x2C]; } ObjDanpeilift; // size = 0x18C extern const ActorInit Obj_Danpeilift_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c index 387ee5dbe..5783118de 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c @@ -15,8 +15,8 @@ void ObjDemo_Update(Actor* thisx, PlayState* play); void func_80983678(ObjDemo* this, PlayState* play); void func_80983704(ObjDemo* this, PlayState* play); +void func_80983634(PlayState* play); -#if 0 const ActorInit Obj_Demo_InitVars = { ACTOR_OBJ_DEMO, ACTORCAT_PROP, @@ -29,14 +29,88 @@ const ActorInit Obj_Demo_InitVars = { (ActorFunc)NULL, }; -#endif +void ObjDemo_Init(Actor* thisx, PlayState* play) { + ObjDemo* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/ObjDemo_Init.s") + thisx->params = OBJDEMO_GET_FF(thisx); + if ((thisx->params != OBJDEMO_FF_FF) && (Flags_GetSwitch(play, thisx->params))) { + Actor_MarkForDeath(&this->actor); + return; + } + if (thisx->shape.rot.x < 0) { + this->unk_148 = 1; + thisx->shape.rot.x = -thisx->shape.rot.x; + } + if (thisx->shape.rot.x == 0) { + this->xzRange = 80.0f; + } else { + this->xzRange = thisx->shape.rot.x * 4.0f; + thisx->shape.rot.x = 0; + thisx->world.rot.x = 0; + } + if (thisx->shape.rot.z == 0) { + this->yRange = 60.0f; + } else { + this->yRange = thisx->shape.rot.z * 4.0f; + thisx->shape.rot.z = 0; + thisx->world.rot.z = 0; + } + func_80983634(play); + this->actionFunc = func_80983678; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/func_80983634.s") +void func_80983634(PlayState* play) { + if ((play->sceneNum == SCENE_CASTLE) && (func_801A8A50(0) == NA_BGM_IKANA_CASTLE)) { + Audio_QueueSeqCmd(0x100100FF); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/func_80983678.s") +void func_80983678(ObjDemo* this, PlayState* play) { + func_80983634(play); + if ((this->actor.xzDistToPlayer < this->xzRange) && (fabsf(this->actor.playerHeightRel) < this->yRange)) { + if (this->unk_148 == 1) { + ActorCutscene_Stop(0x7D); + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_80983704; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/func_80983704.s") +void func_80983704(ObjDemo* this, PlayState* play) { + if ((this->unk_148 == 1) && (ActorCutscene_GetCurrentIndex() == 0x7D)) { + ActorCutscene_Stop(0x7D); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + if (this->unk_148 == 1) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + func_800E0348(play->cameraPtrs[CAM_ID_MAIN]); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } + if (play->sceneNum == SCENE_CASTLE) { + Audio_QueueSeqCmd(NA_BGM_IKANA_CASTLE | 0x8000); + } + this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + if (this->actor.cutscene == -1) { + if (this->actor.params != 0xFF) { + Flags_SetSwitch(play, this->actor.params); + } + Actor_MarkForDeath(&this->actor); + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + func_80983634(play); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Demo/ObjDemo_Update.s") +void ObjDemo_Update(Actor* thisx, PlayState* play) { + ObjDemo* this = THIS; + + if ((this->actor.params != 0xFF) && Flags_GetSwitch(play, this->actor.params)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc(this, play); +} diff --git a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h index 62f105c91..be774bf07 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h @@ -3,14 +3,18 @@ #include "global.h" +#define OBJDEMO_GET_FF(thisx) ((thisx)->params & 0xFF) +#define OBJDEMO_FF_FF 0xFF struct ObjDemo; typedef void (*ObjDemoActionFunc)(struct ObjDemo*, PlayState*); typedef struct ObjDemo { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjDemoActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xC]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjDemoActionFunc actionFunc; + /* 0x148 */ s32 unk_148; + /* 0x14C */ f32 xzRange; + /* 0x150 */ f32 yRange; } ObjDemo; // size = 0x154 extern const ActorInit Obj_Demo_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c index af2908ecf..c8b9926c5 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c @@ -125,7 +125,7 @@ static ColliderTrisInit sTrisInit = { OC2_TYPE_1, COLSHAPE_TRIS, }, - 6, + ARRAY_COUNT(sTrisElementsInit), sTrisElementsInit, }; diff --git a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h index 2d1e43dcc..ece93f627 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h @@ -8,17 +8,17 @@ struct ObjDora; typedef void (*ObjDoraActionFunc)(struct ObjDora*, PlayState*); typedef struct ObjDora { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderTris colliderTris; - /* 0x0164 */ ColliderTrisElement colliderTrisElements[6]; - /* 0x038C */ ObjDoraActionFunc actionFunc; - /* 0x0390 */ Vec3f gongForce; - /* 0x039C */ Vec2s gongAngle; - /* 0x03A0 */ s16 lastGongHitType; - /* 0x03A2 */ Vec2s gongRotation; // gongAngle * gongForce. Used in ObjDora_Draw. - /* 0x03A6 */ s16 rupeeDropTimer; - /* 0x03A8 */ s16 collisionCooldownTimer; - /* 0x03AA */ s16 unk3AA; // Set but not used + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderTris colliderTris; + /* 0x164 */ ColliderTrisElement colliderTrisElements[6]; + /* 0x38C */ ObjDoraActionFunc actionFunc; + /* 0x390 */ Vec3f gongForce; + /* 0x39C */ Vec2s gongAngle; + /* 0x3A0 */ s16 lastGongHitType; + /* 0x3A2 */ Vec2s gongRotation; // gongAngle * gongForce. Used in ObjDora_Draw. + /* 0x3A6 */ s16 rupeeDropTimer; + /* 0x3A8 */ s16 collisionCooldownTimer; + /* 0x3AA */ s16 unk3AA; // Set but not used } ObjDora; // size = 0x3AC extern const ActorInit Obj_Dora_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h index 42dc3e181..e2f37350a 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h @@ -42,18 +42,18 @@ typedef struct { } ObjDrifticeStruct; // size = 0xCC typedef struct ObjDriftice { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ObjDrifticeActionFunc actionFunc; - /* 0x0160 */ s32 unk_160; - /* 0x0164 */ s32 unk_164; - /* 0x0168 */ s32 unk_168; - /* 0x016C */ Vec3s* unk_16C; - /* 0x0170 */ ObjDrifticeStruct unk_170; - /* 0x023C */ f32 unk_23C; - /* 0x0240 */ f32 unk_240; - /* 0x0244 */ s16 unk_244; - /* 0x0248 */ s32 unk_248; - /* 0x024C */ s32 unk_24C; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjDrifticeActionFunc actionFunc; + /* 0x160 */ s32 unk_160; + /* 0x164 */ s32 unk_164; + /* 0x168 */ s32 unk_168; + /* 0x16C */ Vec3s* unk_16C; + /* 0x170 */ ObjDrifticeStruct unk_170; + /* 0x23C */ f32 unk_23C; + /* 0x240 */ f32 unk_240; + /* 0x244 */ s16 unk_244; + /* 0x248 */ s32 unk_248; + /* 0x24C */ s32 unk_24C; } ObjDriftice; // size = 0x250 extern const ActorInit Obj_Driftice_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c index fb7681f31..f8a7d38d7 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c @@ -5,7 +5,6 @@ */ #include "z_obj_etcetera.h" -#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -80,10 +79,12 @@ void ObjEtcetera_Init(Actor* thisx, PlayState* play) { if ((type < DEKU_FLOWER_TYPE_PINK) || (type >= DEKU_FLOWER_TYPE_MAX)) { type = DEKU_FLOWER_TYPE_PINK; } + objectIndex = Object_GetIndex(&play->objectCtx, objectIds[type]); if (objectIndex >= 0) { this->objIndex = objectIndex; } + pos.x = this->dyna.actor.world.pos.x; pos.y = this->dyna.actor.world.pos.y + 10.0f; pos.z = this->dyna.actor.world.pos.z; @@ -125,7 +126,7 @@ void ObjEtcetera_DoNormalOscillation(ObjEtcetera* this, PlayState* play) { void ObjEtcetera_StartRustleAnimation(ObjEtcetera* this) { Animation_Change(&this->skelAnime, &gDekuFlowerRustleAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDekuFlowerRustleAnim), 2, 0.0f); + Animation_GetLastFrame(&gDekuFlowerRustleAnim), ANIMMODE_ONCE, 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; this->actionFunc = ObjEtcetera_PlayRustleAnimation; } @@ -137,7 +138,7 @@ void ObjEtcetera_Idle(ObjEtcetera* this, PlayState* play) { if ((player->stateFlags3 & 0x200) && (this->dyna.actor.xzDistToPlayer < 20.0f)) { // Player is launching out of the Deku Flower Animation_Change(&this->skelAnime, &gDekuFlowerBounceAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDekuFlowerBounceAnim), 2, 0.0f); + Animation_GetLastFrame(&gDekuFlowerBounceAnim), ANIMMODE_ONCE, 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; this->actionFunc = ObjEtcetera_DoBounceOscillation; Actor_SetScale(&this->dyna.actor, 0.01f); @@ -163,6 +164,7 @@ void ObjEtcetera_Idle(ObjEtcetera* this, PlayState* play) { // start of launching this->oscillationTimer = 10; } + this->burrowFlag |= 1; } else { if (this->burrowFlag & 1) { @@ -170,13 +172,16 @@ void ObjEtcetera_Idle(ObjEtcetera* this, PlayState* play) { this->oscillationTimer = 10; ObjEtcetera_StartRustleAnimation(this); } + this->burrowFlag &= ~1; } } + if ((this->collider.base.acFlags & AC_HIT)) { this->oscillationTimer = 10; ObjEtcetera_StartRustleAnimation(this); } + ObjEtcetera_DoNormalOscillation(this, play); } @@ -186,10 +191,12 @@ void ObjEtcetera_PlayRustleAnimation(ObjEtcetera* this, PlayState* play) { } else { this->burrowFlag &= ~1; } + if (SkelAnime_Update(&this->skelAnime)) { this->dyna.actor.draw = ObjEtcetera_DrawIdle; this->actionFunc = ObjEtcetera_Idle; } + ObjEtcetera_DoNormalOscillation(this, play); } @@ -210,7 +217,9 @@ void ObjEtcetera_DoBounceOscillation(ObjEtcetera* this, PlayState* play) { } else { this->burrowFlag &= ~1; } + SkelAnime_Update(&this->skelAnime); + if (this->oscillationTimer > 0) { this->oscillationTimer--; } else { @@ -222,6 +231,7 @@ void ObjEtcetera_DoBounceOscillation(ObjEtcetera* this, PlayState* play) { this->bounceOscillationScale = 0.0f; return; } + this->bounceOscillationScale *= 0.8f; this->bounceOscillationScale -= (this->dyna.actor.scale.x - 0.01f) * 0.4f; scaleTemp = dyna->actor.scale.x + this->bounceOscillationScale; @@ -251,24 +261,26 @@ void ObjEtcetera_Setup(ObjEtcetera* this, PlayState* play) { Actor_SetObjectDependency(play, &this->dyna.actor); DynaPolyActor_Init(&this->dyna, 1); thisCollisionHeader = collisionHeaders[type]; - if (thisCollisionHeader != 0) { + if (thisCollisionHeader != NULL) { CollisionHeader_GetVirtual(thisCollisionHeader, &colHeader); } + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); type = DEKU_FLOWER_TYPE(&this->dyna.actor); switch (type) { case DEKU_FLOWER_TYPE_PINK: - case DEKU_FLOWER_TYPE_PINK_SPAWNED_FROM_MAD_SCRUB: + case DEKU_FLOWER_TYPE_PINK_WITH_INITIAL_BOUNCE: SkelAnime_Init(play, &this->skelAnime, &gPinkDekuFlowerSkel, &gDekuFlowerBounceAnim, this->jointTable, - this->morphTable, DEKU_FLOWER_LIMB_MAX); + this->morphTable, PINK_DEKU_FLOWER_LIMB_MAX); this->dList = gPinkDekuFlowerIdleDL; break; + case DEKU_FLOWER_TYPE_GOLD: - case DEKU_FLOWER_TYPE_GOLD_SPAWNED_FROM_MAD_SCRUB: + case DEKU_FLOWER_TYPE_GOLD_WITH_INITIAL_BOUNCE: this->dList = gGoldDekuFlowerIdleDL; SkelAnime_Init(play, &this->skelAnime, &gGoldDekuFlowerSkel.sh, &gDekuFlowerBounceAnim, - this->jointTable, this->morphTable, DEKU_FLOWER_LIMB_MAX); + this->jointTable, this->morphTable, GOLD_DEKU_FLOWER_LIMB_MAX); this->collider.dim.height = 20; break; } @@ -284,10 +296,11 @@ void ObjEtcetera_Setup(ObjEtcetera* this, PlayState* play) { this->dyna.actor.focus.pos.y = this->dyna.actor.home.pos.y + 10.0f; this->dyna.actor.targetMode = 3; break; - case DEKU_FLOWER_TYPE_PINK_SPAWNED_FROM_MAD_SCRUB: - case DEKU_FLOWER_TYPE_GOLD_SPAWNED_FROM_MAD_SCRUB: + + case DEKU_FLOWER_TYPE_PINK_WITH_INITIAL_BOUNCE: + case DEKU_FLOWER_TYPE_GOLD_WITH_INITIAL_BOUNCE: Animation_Change(&this->skelAnime, &gDekuFlowerBounceAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gDekuFlowerBounceAnim), 2, 0.0f); + Animation_GetLastFrame(&gDekuFlowerBounceAnim), ANIMMODE_ONCE, 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; this->actionFunc = ObjEtcetera_DoBounceOscillation; Actor_SetScale(&this->dyna.actor, 0.0f); @@ -311,6 +324,7 @@ void ObjEtcetera_Update(Actor* thisx, PlayState* play) { func_800FAAB4(play, SurfaceType_GetLightSettingIndex(&play->colCtx, floorPoly, floorBgId)); } } + this->actionFunc(this, play); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } 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 83bcba080..33810ae06 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h @@ -2,37 +2,19 @@ #define Z_OBJ_ETCETERA_H #include "global.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define DEKU_FLOWER_TYPE(thisx) (((thisx)->params & 0xFF80) >> 7) +#define DEKU_FLOWER_PARAMS(type) (((type) << 7) & 0xFF80) typedef enum { /* 0 */ DEKU_FLOWER_TYPE_PINK, - /* 1 */ DEKU_FLOWER_TYPE_PINK_SPAWNED_FROM_MAD_SCRUB, + /* 1 */ DEKU_FLOWER_TYPE_PINK_WITH_INITIAL_BOUNCE, /* 2 */ DEKU_FLOWER_TYPE_GOLD, - /* 3 */ DEKU_FLOWER_TYPE_GOLD_SPAWNED_FROM_MAD_SCRUB, + /* 3 */ DEKU_FLOWER_TYPE_GOLD_WITH_INITIAL_BOUNCE, /* 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*, PlayState*); @@ -41,8 +23,8 @@ typedef struct ObjEtcetera { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ SkelAnime skelAnime; /* 0x1A0 */ ColliderCylinder collider; - /* 0x1EC */ Vec3s jointTable[DEKU_FLOWER_LIMB_MAX]; - /* 0x22E */ Vec3s morphTable[DEKU_FLOWER_LIMB_MAX]; + /* 0x1EC */ Vec3s jointTable[PINK_DEKU_FLOWER_LIMB_MAX]; + /* 0x22E */ Vec3s morphTable[PINK_DEKU_FLOWER_LIMB_MAX]; /* 0x270 */ f32 bounceOscillationScale; /* 0x274 */ s16 oscillationTimer; /* 0x276 */ u16 burrowFlag; diff --git a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h index 4d6a971eb..bc01ceac4 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h @@ -15,17 +15,17 @@ typedef void (*ObjFireshieldActionFunc)(struct ObjFireshield*); #define OBJFIRESHIELD_GET_ROTX(thisx) ((thisx)->home.rot.x & 1) typedef struct ObjFireshield { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ ObjFireshieldActionFunc actionFunc; - /* 0x0194 */ s32 unk_194; - /* 0x0198 */ f32 unk_198; - /* 0x019C */ s32 unk_19C; - /* 0x01A0 */ s32 unk_1A0; - /* 0x01A4 */ s16 unk_1A4; - /* 0x01A6 */ u8 unk_1A6; - /* 0x01A7 */ s8 unk_1A7; - /* 0x01A8 */ s8 unk_1A8; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ ObjFireshieldActionFunc actionFunc; + /* 0x194 */ s32 unk_194; + /* 0x198 */ f32 unk_198; + /* 0x19C */ s32 unk_19C; + /* 0x1A0 */ s32 unk_1A0; + /* 0x1A4 */ s16 unk_1A4; + /* 0x1A6 */ u8 unk_1A6; + /* 0x1A7 */ s8 unk_1A7; + /* 0x1A8 */ s8 unk_1A8; } ObjFireshield; // size = 0x1AC extern const ActorInit Obj_Fireshield_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index 14cab51c3..87433b988 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -4,6 +4,7 @@ * Description: Breakable Pot With Grass */ +#include "prevent_bss_reordering.h" #include "z_obj_flowerpot.h" #include "objects/object_flowerpot/object_flowerpot.h" @@ -23,13 +24,13 @@ void func_80A1CC0C(ObjFlowerpot* this, PlayState* play); void func_80A1CD10(ObjFlowerpot* this); void func_80A1CEF4(ObjFlowerpot* this2, PlayState* play); -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; +u32 D_80A1D830; +MtxF D_80A1D838[8]; +s16 D_80A1DA38; +s16 D_80A1DA3A; +s16 D_80A1DA3C; +s16 D_80A1DA3E; +s16 D_80A1DA40; const ActorInit Obj_Flowerpot_InitVars = { ACTOR_OBJ_FLOWERPOT, @@ -77,19 +78,19 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; -static s16 D_80A1D3F8 = 0; +s16 D_80A1D3F8 = 0; -static s16 D_80A1D3FC = 0; +s16 D_80A1D3FC = 0; -static s16 D_80A1D400 = 0; +s16 D_80A1D400 = 0; -static u8 D_80A1D404 = true; +u8 D_80A1D404 = true; -static Vec3f D_80A1D408 = { 0.0f, 20.0f, 0.0f }; +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), @@ -177,8 +178,8 @@ void func_80A1B3D0(void) { void func_80A1B840(MtxF* matrix) { MtxF* temp = Matrix_GetCurrent(); - f32* tmp = (f32*)&temp->mf[0]; - f32* tmp2 = (f32*)&matrix->mf[0]; + f32* tmp = &temp->xx; + f32* tmp2 = &matrix->xx; s32 i; for (i = 0; i < 16; i++) { 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 93a095d03..3e803672c 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h @@ -11,14 +11,14 @@ typedef void (*ObjFlowerpotActionFunc)(struct ObjFlowerpot*, PlayState*); #define ENOBJFLOWERPOT_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) typedef struct ObjFlowerpot { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderJntSph collider; - /* 0x0164 */ ColliderJntSphElement colliderElements[2]; - /* 0x01E4 */ ObjFlowerpotActionFunc actionFunc; - /* 0x01E8 */ s16 unk_1E8; - /* 0x01EA */ u8 unk_1EA; - /* 0x01EB */ s8 unk_1EB; - /* 0x01EC */ s8 unk_1EC; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElements[2]; + /* 0x1E4 */ ObjFlowerpotActionFunc actionFunc; + /* 0x1E8 */ s16 unk_1E8; + /* 0x1EA */ u8 unk_1EA; + /* 0x1EB */ s8 unk_1EB; + /* 0x1EC */ 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 fba15eac7..343a8f61e 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -97,13 +97,13 @@ void func_80B3C39C(ObjGhaka* this, PlayState* play) { void func_80B3C4E0(ObjGhaka* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - if (talkState == 5) { + if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; func_80B3C260(this); } - } else if (talkState == 4) { + } else if (talkState == TEXT_STATE_CHOICE) { if (Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: @@ -111,16 +111,19 @@ void func_80B3C4E0(ObjGhaka* this, PlayState* play) { this->dyna.actor.textId = 0xCF5; Message_StartTextbox(play, this->dyna.actor.textId, &this->dyna.actor); break; + case 1: func_8019F208(); this->dyna.actor.textId = 0xCF7; Message_StartTextbox(play, this->dyna.actor.textId, &this->dyna.actor); break; + case 2: func_8019F230(); play->msgCtx.msgMode = 0x43; - play->msgCtx.unk12023 = 4; + play->msgCtx.stateTimer = 4; func_80B3C260(this); + break; } } } diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index 53dad10d9..5fec022ad 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -4,6 +4,7 @@ * Description: "Master" instance of grass for unit spawned by Obj_Grass_Unit */ +#include "prevent_bss_reordering.h" #include "z_obj_grass.h" #include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h" #include "objects/gameplay_keep/gameplay_keep.h" diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h index 1c87108df..be73c70b5 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h @@ -13,7 +13,6 @@ typedef struct ObjGrassStruct1_1 { /* 0x0E */ s8 unk_0E; /* 0x0F */ u8 unk_0F; /* 0x10 */ u8 unk_10; - /* 0x11 */ UNK_TYPE1 unk_11[0x3]; } ObjGrassStruct1_1; // size = 0x14 typedef struct { diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h index f46940f1b..0e59033fc 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h @@ -10,13 +10,13 @@ struct ObjGrassStruct1_1; typedef void (*ObjGrassCarryActionFunc)(struct ObjGrassCarry*, PlayState*); typedef struct ObjGrassCarry { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ struct ObjGrass* unk_190; - /* 0x0194 */ struct ObjGrassStruct1_1* unk_194; - /* 0x0198 */ s16 unk_198; - /* 0x019A */ s16 unk_19A; - /* 0x019C */ ObjGrassCarryActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ struct ObjGrass* unk_190; + /* 0x194 */ struct ObjGrassStruct1_1* unk_194; + /* 0x198 */ s16 unk_198; + /* 0x19A */ s16 unk_19A; + /* 0x19C */ ObjGrassCarryActionFunc actionFunc; } ObjGrassCarry; // size = 0x1A0 extern const ActorInit Obj_Grass_Carry_InitVars; 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 4de9a0d80..a4e5d233c 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h @@ -11,17 +11,17 @@ typedef void (*ObjHakaisiActionFunc)(struct ObjHakaisi*, PlayState*); #define OBJHAKAISI_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFF00) >> 8) typedef struct ObjHakaisi { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ObjHakaisiActionFunc actionFunc; - /* 0x0160 */ Vec3f unk_160[3]; - /* 0x0184 */ Vec3f unk_184; - /* 0x0190 */ s32 switchFlag; - /* 0x0194 */ s16 unk_194; - /* 0x0196 */ s16 unk_196; - /* 0x0198 */ s16 unk_198; - /* 0x019A */ s16 unk_19A; - /* 0x019C */ s16 unk_19C; - /* 0x019E */ u8 unk_19E; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjHakaisiActionFunc actionFunc; + /* 0x160 */ Vec3f unk_160[3]; + /* 0x184 */ Vec3f unk_184; + /* 0x190 */ s32 switchFlag; + /* 0x194 */ s16 unk_194; + /* 0x196 */ s16 unk_196; + /* 0x198 */ s16 unk_198; + /* 0x19A */ s16 unk_19A; + /* 0x19C */ s16 unk_19C; + /* 0x19E */ u8 unk_19E; } ObjHakaisi; // size = 0x1A0 extern const ActorInit Obj_Hakaisi_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c index aefec238e..11baddb38 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -12,7 +12,7 @@ #define THIS ((ObjHamishi*)thisx) void ObjHamishi_Init(Actor* thisx, PlayState* play); -void ObjHamishi_Destroy(Actor* thisx, PlayState* play); +void ObjHamishi_Destroy(Actor* thisx, PlayState* play2); void ObjHamishi_Update(Actor* thisx, PlayState* play); void ObjHamishi_Draw(Actor* thisx, PlayState* play); @@ -192,8 +192,11 @@ void ObjHamishi_Init(Actor* thisx, PlayState* play) { } } -void ObjHamishi_Destroy(Actor* thisx, PlayState* play) { - Collider_DestroyCylinder(play, &THIS->collider); +void ObjHamishi_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + ObjHamishi* this = THIS; + + Collider_DestroyCylinder(play, &this->collider); } void ObjHamishi_Update(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h index ae3fcf160..5d9a8e39b 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h @@ -8,12 +8,12 @@ struct ObjHariko; typedef void (*ObjHarikoActionFunc)(struct ObjHariko*, PlayState*); typedef struct ObjHariko { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjHarikoActionFunc actionFunc; - /* 0x0148 */ f32 bobbleStep; - /* 0x014C */ Vec3s headRotation; - /* 0x0152 */ s16 headOffset; - /* 0x0154 */ s16 unk154; // Set but not used + /* 0x000 */ Actor actor; + /* 0x144 */ ObjHarikoActionFunc actionFunc; + /* 0x148 */ f32 bobbleStep; + /* 0x14C */ Vec3s headRotation; + /* 0x152 */ s16 headOffset; + /* 0x154 */ s16 unk154; // Set but not used } ObjHariko; // size = 0x158 extern const ActorInit Obj_Hariko_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c index d67da8560..3339d1440 100644 --- a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c +++ b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c @@ -5,6 +5,7 @@ */ #include "z_obj_hsblock.h" +#include "objects/object_d_hsblock/object_d_hsblock.h" #define FLAGS 0x00000000 @@ -17,9 +18,11 @@ void ObjHsblock_Draw(Actor* thisx, PlayState* play); void func_8093E0A0(ObjHsblock* this, PlayState* play); -void ObjHsblock_SetupAction(ObjHsblock* this, ObjHsblockActionFunc actionFunc); +void func_8093E03C(ObjHsblock* this); +void func_8093E05C(ObjHsblock* this); +void func_8093E0E8(ObjHsblock* this); +void func_8093E10C(ObjHsblock* this, PlayState* play); -#if 0 const ActorInit Obj_Hsblock_InitVars = { ACTOR_OBJ_HSBLOCK, ACTORCAT_BG, @@ -32,36 +35,120 @@ const ActorInit Obj_Hsblock_InitVars = { (ActorFunc)ObjHsblock_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8093E33C[] = { +static f32 sFocusHeights[] = { 85.0f, 85.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +static CollisionHeader* sColHeaders[] = { + &gHookshotPostCol, + &gHookshotPostCol, + &gHookshotTargetCol, +}; -extern InitChainEntry D_8093E33C[]; +static Gfx* sDisplayLists[] = { gHookshotPostDL, gHookshotPostDL, gHookshotTargetDL }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_SetupAction.s") +void ObjHsblock_SetupAction(ObjHsblock* this, ObjHsblockActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093DEAC.s") +void func_8093DEAC(ObjHsblock* this, PlayState* play) { + if (OBJHSBLOCK_GET_5(&this->dyna.actor) != 0) { + Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_OBJ_ICE_POLY, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, this->dyna.actor.world.rot.x, + this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, 0xFF64); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_Init.s") +void ObjHsblock_Init(Actor* thisx, PlayState* play) { + ObjHsblock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_Destroy.s") + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, sColHeaders[OBJHSBLOCK_GET_3(thisx)]); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + func_8093DEAC(this, play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E03C.s") + switch (OBJHSBLOCK_GET_3(&this->dyna.actor)) { + case 0: + case 2: + func_8093E03C(this); + break; + case 1: + if (Flags_GetSwitch(play, OBJHSBLOCK_GET_SWITCH(thisx))) { + func_8093E03C(this); + } else { + func_8093E05C(this); + } + break; + default: + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E05C.s") +void ObjHsblock_Destroy(Actor* thisx, PlayState* play) { + ObjHsblock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E0A0.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E0E8.s") +void func_8093E03C(ObjHsblock* this) { + ObjHsblock_SetupAction(this, NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E10C.s") +void func_8093E05C(ObjHsblock* this) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 105.0f; + ObjHsblock_SetupAction(this, func_8093E0A0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_Update.s") +void func_8093E0A0(ObjHsblock* this, PlayState* play) { + if (Flags_GetSwitch(play, OBJHSBLOCK_GET_SWITCH(&this->dyna.actor))) { + func_8093E0E8(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_Draw.s") +void func_8093E0E8(ObjHsblock* this) { + ObjHsblock_SetupAction(this, func_8093E10C); +} + +void func_8093E10C(ObjHsblock* this, PlayState* play) { + Math_SmoothStepToF(&this->dyna.actor.velocity.y, 16.0f, 0.1f, 0.8f, 0.0f); + if (fabsf(Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 0.3f, + this->dyna.actor.velocity.y, 0.3f)) < 0.001f) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + func_8093E03C(this); + this->dyna.actor.flags &= ~ACTOR_FLAG_10; + } +} + +void ObjHsblock_Update(Actor* thisx, PlayState* play) { + ObjHsblock* this = THIS; + + if (this->actionFunc != NULL) { + this->actionFunc(this, play); + } + Actor_SetFocus(&this->dyna.actor, sFocusHeights[OBJHSBLOCK_GET_3(thisx)]); +} + +void ObjHsblock_Draw(Actor* thisx, PlayState* play) { + static Color_RGB8 sEnvColors[] = { + { 60, 60, 120 }, + { 120, 100, 70 }, + { 100, 150, 120 }, + { 255, 255, 255 }, + }; + Color_RGB8* envColor = &sEnvColors[OBJHSBLOCK_GET_6(thisx)]; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(POLY_OPA_DISP++, envColor->r, envColor->g, envColor->b, 255); + gSPDisplayList(POLY_OPA_DISP++, sDisplayLists[OBJHSBLOCK_GET_3(thisx)]); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.h b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.h index e5fcb433b..0411cc9e4 100644 --- a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.h +++ b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.h @@ -3,14 +3,18 @@ #include "global.h" +#define OBJHSBLOCK_GET_SWITCH(thisx) (((thisx)->params >> 8) & 0x7F) +#define OBJHSBLOCK_GET_3(thisx) ((thisx)->params & 3) +#define OBJHSBLOCK_GET_5(thisx) (((thisx)->params >> 5) & 1) +#define OBJHSBLOCK_GET_6(thisx) (((thisx)->params >> 6) & 3) + struct ObjHsblock; typedef void (*ObjHsblockActionFunc)(struct ObjHsblock*, PlayState*); typedef struct ObjHsblock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjHsblockActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjHsblockActionFunc actionFunc; } ObjHsblock; // size = 0x160 extern const ActorInit Obj_Hsblock_InitVars; 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 5ef9b2717..67b428182 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.h +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.h @@ -20,13 +20,13 @@ typedef struct { } EnHugebombiwaStruct; // size = 0x28 typedef struct ObjHugebombiwa { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ EnHugebombiwaStruct unk_190[20]; - /* 0x04B0 */ s16 unk_4B0; - /* 0x04B2 */ s8 unk_4B2; - /* 0x04B3 */ s8 unk_4B3; - /* 0x04B4 */ ObjHugebombiwaActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ EnHugebombiwaStruct unk_190[20]; + /* 0x4B0 */ s16 unk_4B0; + /* 0x4B2 */ s8 unk_4B2; + /* 0x4B3 */ s8 unk_4B3; + /* 0x4B4 */ ObjHugebombiwaActionFunc actionFunc; } ObjHugebombiwa; // size = 0x4B8 extern const ActorInit Obj_Hugebombiwa_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c index ef3a5b79e..a013560a4 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c @@ -4,7 +4,6 @@ * Description: Switch-Activated Geyser */ -#include "prevent_bss_reordering.h" #include "z_obj_hunsui.h" #include "objects/object_hunsui/object_hunsui.h" diff --git a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h index a2d5ebd11..d84069ec0 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h @@ -23,35 +23,35 @@ enum { }; typedef struct ObjHunsui { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ObjHunsuiActionFunc actionFunc; - /* 0x0160 */ s16 unk_160; - /* 0x0164 */ s32 unk_164; - /* 0x0168 */ s32 unk_168; - /* 0x016C */ s8 unk_16C; - /* 0x016D */ s8 unk_16D; - /* 0x016E */ s8 unk_16E; - /* 0x0170 */ s16 unk_170; - /* 0x0172 */ u16 unk_172; - /* 0x0174 */ f32 unk_174; - /* 0x0178 */ f32 unk_178; - /* 0x017C */ s16 unk_17C; - /* 0x0180 */ s32 unk_180; - /* 0x0184 */ s16 unk_184; - /* 0x0186 */ s16 unk_186; - /* 0x0188 */ s16 unk_188; - /* 0x018A */ s16 unk_18A; - /* 0x018C */ s16 unk_18C; - /* 0x0190 */ f32 unk_190; - /* 0x0194 */ f32 unk_194; - /* 0x0198 */ f32 unk_198; - /* 0x019C */ f32 unk_19C; - /* 0x01A0 */ f32 unk_1A0; - /* 0x01A4 */ s16 unk_1A4; - /* 0x0196 */ UNK_TYPE1 unk1A6[0x6]; - /* 0x01AC */ f32 unk_1AC; - /* 0x01B0 */ f32 unk_1B0; - /* 0x01B4 */ BgDblueMovebg* unk_1B4; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjHunsuiActionFunc actionFunc; + /* 0x160 */ s16 unk_160; + /* 0x164 */ s32 unk_164; + /* 0x168 */ s32 unk_168; + /* 0x16C */ s8 unk_16C; + /* 0x16D */ s8 unk_16D; + /* 0x16E */ s8 unk_16E; + /* 0x170 */ s16 unk_170; + /* 0x172 */ u16 unk_172; + /* 0x174 */ f32 unk_174; + /* 0x178 */ f32 unk_178; + /* 0x17C */ s16 unk_17C; + /* 0x180 */ s32 unk_180; + /* 0x184 */ s16 unk_184; + /* 0x186 */ s16 unk_186; + /* 0x188 */ s16 unk_188; + /* 0x18A */ s16 unk_18A; + /* 0x18C */ s16 unk_18C; + /* 0x190 */ f32 unk_190; + /* 0x194 */ f32 unk_194; + /* 0x198 */ f32 unk_198; + /* 0x19C */ f32 unk_19C; + /* 0x1A0 */ f32 unk_1A0; + /* 0x1A4 */ s16 unk_1A4; + /* 0x196 */ UNK_TYPE1 unk1A6[0x6]; + /* 0x1AC */ f32 unk_1AC; + /* 0x1B0 */ f32 unk_1B0; + /* 0x1B4 */ BgDblueMovebg* unk_1B4; } ObjHunsui; // size = 0x1B8 extern const ActorInit Obj_Hunsui_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h index c1efd768d..601c5c9e7 100644 --- a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h +++ b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h @@ -12,13 +12,13 @@ typedef void (*ObjIcePolyActionFunc)(struct ObjIcePoly*, PlayState*); #define OBJICEPOLY_FF_FF 0xFF typedef struct ObjIcePoly { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjIcePolyActionFunc actionFunc; - /* 0x0148 */ u8 unk_148; - /* 0x0149 */ u8 unk_149; - /* 0x014A */ s16 unk_14A; - /* 0x014C */ ColliderCylinder colliders1[2]; - /* 0x01E4 */ ColliderCylinder colliders2[2]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjIcePolyActionFunc actionFunc; + /* 0x148 */ u8 unk_148; + /* 0x149 */ u8 unk_149; + /* 0x14A */ s16 unk_14A; + /* 0x14C */ ColliderCylinder colliders1[2]; + /* 0x1E4 */ ColliderCylinder colliders2[2]; } ObjIcePoly; // size = 0x27C extern const ActorInit Obj_Ice_Poly_InitVars; 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 c5a11c8e3..394172d72 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -1204,7 +1204,7 @@ void func_80A25FD4(ObjIceblock* this, PlayState* play) { if (sp2C == -1) { sp30 = false; } else if (!(this->unk_1B0 & 2) && (this->unk_26E[sp2C] >= 11) && !func_80A24118(this, play, 2.0f, &sp20) && - !Player_InCsMode(&play->state)) { + !Player_InCsMode(play)) { func_80A23370(this, sp2C); func_80A260E8(this); sp30 = false; 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 31ef0d80f..fa817781a 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h @@ -27,8 +27,8 @@ typedef struct { } ObjIceBlockUnkStruct2; // size = 0x10 typedef struct { - f32 unk_00; - f32 unk_04; + /* 0x0 */ f32 unk_00; + /* 0x4 */ f32 unk_04; } ObjIceBlockUnkStruct3; // size = 0x8 typedef struct { @@ -48,34 +48,34 @@ typedef struct { } ObjIceBlockUnkStruct4; // size = 0x24 typedef struct ObjIceblock { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ ObjIceblockActionFunc actionFunc; - /* 0x01AC */ ObjIceblockExtendedDrawFunc extendedDrawFunc; - /* 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 stateTimer; // re-used per-actionFunc - /* 0x02A2 */ s16 unk_2A2; - /* 0x02A4 */ f32 unk_2A4; - /* 0x02A8 */ f32 unk_2A8; - /* 0x02AC */ s16 unk_2AC; - /* 0x02AE */ s16 meltTimer; // starts at 450 frames = 22 seconds - /* 0x02B0 */ s8 unk_2B0; - /* 0x02B1 */ s8 spawnCutsceneTimer; - /* 0x02B4 */ f32 unk_2B4; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ ObjIceblockActionFunc actionFunc; + /* 0x1AC */ ObjIceblockExtendedDrawFunc extendedDrawFunc; + /* 0x1B0 */ s32 unk_1B0; + /* 0x1B4 */ ObjIceBlockUnkStruct unk_1B4[4]; + /* 0x1F4 */ ObjIceBlockUnkStruct2 unk_1F4[5]; + /* 0x244 */ f32 unk_244; + /* 0x248 */ Vec3f unk_248; + /* 0x254 */ Vec3s unk_254; + /* 0x25C */ f32 unk_25C; + /* 0x260 */ f32 unk_260; + /* 0x264 */ f32* unk_264; + /* 0x268 */ f32 unk_268; + /* 0x26C */ s16 unk_26C; + /* 0x26E */ s16 unk_26E[4]; + /* 0x276 */ s16 unk_276; + /* 0x278 */ s16 unk_278; + /* 0x27C */ ObjIceBlockUnkStruct4 unk_27C; + /* 0x2A0 */ s16 stateTimer; // re-used per-actionFunc + /* 0x2A2 */ s16 unk_2A2; + /* 0x2A4 */ f32 unk_2A4; + /* 0x2A8 */ f32 unk_2A8; + /* 0x2AC */ s16 unk_2AC; + /* 0x2AE */ s16 meltTimer; // starts at 450 frames = 22 seconds + /* 0x2B0 */ s8 unk_2B0; + /* 0x2B1 */ s8 spawnCutsceneTimer; + /* 0x2B4 */ 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 64a6b8b11..497d9a219 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 @@ -38,9 +38,10 @@ void ObjJgGakki_Init(Actor* thisx, PlayState* play2) { if (((play->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7)) && (play->csCtx.currentCsIndex == 0)) { - Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, frameCount, frameCount, 2, 0.0f); + Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, frameCount, frameCount, ANIMMODE_ONCE, + 0.0f); } else if ((play->sceneNum == SCENE_17SETUGEN) || (play->sceneNum == SCENE_10YUKIYAMANOMURA)) { - Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, 0.0f, frameCount, 2, 0.0f); + Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); } else { Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c index 1d34515c9..cc65a7730 100644 --- a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c +++ b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c @@ -5,17 +5,28 @@ */ #include "z_obj_jgame_light.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_syokudai/object_syokudai.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjJgameLight*)thisx) +typedef enum { + /* 0x0 */ OBJJGAMELIGHT_NONE, + /* 0x1 */ OBJJGAMELIGHT_CORRECT, + /* 0x2 */ OBJJGAMELIGHT_INCORRECT, +} ObjJgameLightSignal; + void ObjJgameLight_Init(Actor* thisx, PlayState* play); void ObjJgameLight_Destroy(Actor* thisx, PlayState* play); void ObjJgameLight_Update(Actor* thisx, PlayState* play); void ObjJgameLight_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_80C15474(ObjJgameLight* this, PlayState* play); +void ObjJgameLight_UpdateCollision(ObjJgameLight* this, PlayState* play); +void func_80C15718(ObjJgameLight* this, PlayState* play); + const ActorInit Obj_Jgame_Light_InitVars = { ACTOR_OBJ_JGAME_LIGHT, ACTORCAT_PROP, @@ -28,29 +39,172 @@ const ActorInit Obj_Jgame_Light_InitVars = { (ActorFunc)ObjJgameLight_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C15BC0 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00100000, 0x00, 0x00 }, { 0xF6CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00100000, 0x00, 0x00 }, + { 0xF6CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 12, 45, 0, { 0, 0, 0 } }, }; -#endif +#include "assets/overlays/ovl_Obj_Jgame_Light/ovl_Obj_Jgame_Light.c" -extern ColliderCylinderInit D_80C15BC0; +void ObjJgameLight_Init(Actor* thisx, PlayState* play) { + ObjJgameLight* this = THIS; + LightInfo* lights = &this->lightInfo; -extern UNK_TYPE D_060003A0; + Actor_SetScale(&this->actor, 1.0f); + func_800B4AEC(play, &this->actor, 50.0f); + ActorShape_Init(&this->actor.shape, 0.0f, func_800B4B50, 1.0f); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + Lights_PointGlowSetInfo(lights, this->actor.world.pos.x, (this->actor.world.pos.y + 70.0f), this->actor.world.pos.z, + 255, 255, 180, -1); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); + Actor_SetFocus(&this->actor, 60.0f); + this->actor.colChkInfo.health = 0; + this->prevHealth = 0; + this->isOn = false; + this->lightRadius = 0; + this->alpha = 0; + this->signal = OBJJGAMELIGHT_NONE; + this->flameScaleProportion = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jgame_Light/ObjJgameLight_Init.s") +void ObjJgameLight_Destroy(Actor* thisx, PlayState* play) { + ObjJgameLight* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jgame_Light/ObjJgameLight_Destroy.s") + Collider_DestroyCylinder(play, &this->collider); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jgame_Light/func_80C15474.s") +void func_80C15474(ObjJgameLight* this, PlayState* play) { + u8 temp_a1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jgame_Light/func_80C156C4.s") + if ((this->actor.colChkInfo.health & OBJLUPYGAMELIFT_IGNITE_FIRE) && (this->isOn == false)) { + if (this->lightRadius < 160) { + this->lightRadius += 40; + } else { + this->lightRadius = 200; + this->isOn = true; + } + if (this->flameScaleProportion < 0.7f) { + this->flameScaleProportion += 0.3f; + } else { + this->flameScaleProportion = 1.0f; + } + } else if (this->actor.colChkInfo.health & OBJLUPYGAMELIFT_SNUFF_FIRE) { + if (this->lightRadius > 40) { + this->lightRadius -= 40; + } else { + this->lightRadius = -1; + if (this->flameScaleProportion == 0.0f) { + this->isOn = false; + this->actor.colChkInfo.health &= ~OBJLUPYGAMELIFT_IGNITE_FIRE; + this->actor.colChkInfo.health &= ~OBJLUPYGAMELIFT_SNUFF_FIRE; + } + } + if (this->flameScaleProportion > 0.3f) { + this->flameScaleProportion -= 0.3f; + } else { + this->flameScaleProportion = 0.0f; + } + } + if (this->flameScaleProportion > 0.1f) { + func_800B9010(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + } + temp_a1 = (s32)(Rand_ZeroOne() * 127.0f) + 128; + Lights_PointSetColorAndRadius(&this->lightInfo, temp_a1, temp_a1 * 0.7f, 0, this->lightRadius); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jgame_Light/func_80C15718.s") +void ObjJgameLight_UpdateCollision(ObjJgameLight* this, PlayState* play) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jgame_Light/ObjJgameLight_Update.s") +void func_80C15718(ObjJgameLight* this, PlayState* play) { + if ((this->actor.colChkInfo.health & OBJLUPYGAMELIFT_IGNITE_FIRE) && + !(this->prevHealth & OBJLUPYGAMELIFT_IGNITE_FIRE)) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_FLAME_IGNITION); + this->prevHealth = this->actor.colChkInfo.health; + } + if (this->actor.colChkInfo.health & OBJLUPYGAMELIFT_DISPLAY_CORRECT) { + this->actor.colChkInfo.health &= ~OBJLUPYGAMELIFT_DISPLAY_CORRECT; + this->alpha = 300; + this->signal = OBJJGAMELIGHT_CORRECT; + } else if (this->actor.colChkInfo.health & OBJLUPYGAMELIFT_DISPLAY_INCORRECT) { + this->actor.colChkInfo.health &= ~OBJLUPYGAMELIFT_DISPLAY_INCORRECT; + this->alpha = 300; + this->signal = OBJJGAMELIGHT_INCORRECT; + } + if (this->alpha > 15) { + this->alpha -= 15; + } else { + this->alpha = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jgame_Light/ObjJgameLight_Draw.s") +void ObjJgameLight_Update(Actor* thisx, PlayState* play) { + ObjJgameLight* this = THIS; + + func_80C15718(this, play); + func_80C15474(this, play); + ObjJgameLight_UpdateCollision(this, play); + this->flameScroll++; +} + +void ObjJgameLight_Draw(Actor* thisx, PlayState* play) { + s32 pad; + ObjJgameLight* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gObjectSyokudaiTypeSwitchCausesFlameDL); + if (this->alpha > 0) { + func_8012C2DC(play->state.gfxCtx); + if (this->alpha > 255) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, this->alpha); + } + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (this->signal == OBJJGAMELIGHT_CORRECT) { + gSPDisplayList(POLY_XLU_DISP++, gObjJgameLightCorrectDL); + } else if (this->signal == OBJJGAMELIGHT_INCORRECT) { + gSPDisplayList(POLY_XLU_DISP++, gObjJgameLightIncorrectDL); + } + } + if (this->flameScaleProportion != 0.0f) { + f32 scale; + + func_8012C2DC(play->state.gfxCtx); + scale = (this->flameScaleProportion * 27.0f) / 10000.0f; + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (this->flameScroll * -20) & 0x1FF, + 0x20, 0x80)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + Matrix_Translate(0.0f, 52.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateYS(((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) - this->actor.shape.rot.y) + 0x8000), + MTXMODE_APPLY); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + } + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h index 50023c252..a81bbf3cc 100644 --- a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h +++ b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h @@ -6,10 +6,25 @@ struct ObjJgameLight; #define OBJJGAMELIGHT_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJLUPYGAMELIFT_IGNITE_FIRE (1 << 0) +#define OBJLUPYGAMELIFT_DISPLAY_CORRECT (1 << 1) +#define OBJLUPYGAMELIFT_DISPLAY_INCORRECT (1 << 2) +#define OBJLUPYGAMELIFT_SNUFF_FIRE (1 << 3) typedef struct ObjJgameLight { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x78]; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ UNK_TYPE1 pad_190[4]; + /* 0x194 */ LightNode* lightNode; + /* 0x198 */ LightInfo lightInfo; + /* 0x1A8 */ f32 flameScaleProportion; + /* 0x1AC */ s16 lightRadius; + /* 0x1AE */ s16 flameScroll; + /* 0x1B0 */ UNK_TYPE1 pad_1B0[2]; + /* 0x1B2 */ s16 alpha; + /* 0x1B4 */ s16 signal; + /* 0x1B6 */ s16 isOn; + /* 0x1B8 */ u8 prevHealth; } ObjJgameLight; // size = 0x1BC extern const ActorInit Obj_Jgame_Light_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c index 24584c1d4..bc1d353fd 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c @@ -94,7 +94,7 @@ static ColliderTrisInit sTrisInit = { OC2_TYPE_1, COLSHAPE_TRIS, }, - 2, + ARRAY_COUNT(sTrisElementsInit), sTrisElementsInit, }; @@ -228,7 +228,9 @@ void func_80B658A4(ObjKendoKanban* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->unk_30C == OBJKENDOKANBAN_F_0) { - if ((player->swordAnimation == 0) || (player->swordAnimation == 1) || (player->swordAnimation == 0x14)) { + if ((player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_2H) || + (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_FINISH)) { this->unk_30C = (OBJKENDOKANBAN_F_4 | OBJKENDOKANBAN_F_1); this->unk_304 = 0x71C; this->actor.velocity = D_80B6666C; diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h index 3a250b2ff..8526f4976 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h @@ -16,25 +16,25 @@ typedef void (*ObjKendoKanbanActionFunc)(struct ObjKendoKanban*, PlayState*); #define OBJKENDOKANBAN_F_8 (1 << 3) typedef struct ObjKendoKanban { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder colliderCylinder; - /* 0x0190 */ ColliderTris colliderTris; - /* 0x01B0 */ ColliderTrisElement colliderTrisElements[2]; - /* 0x0268 */ ObjKendoKanbanActionFunc actionFunc; - /* 0x026C */ Vec3f unk_26C[4]; - /* 0x029C */ Vec3f unk_29C[4]; - /* 0x02CC */ Vec3f unk_2CC; - /* 0x02D8 */ Vec3f unk_2D8; - /* 0x02E4 */ Vec3f unk_2E4; - /* 0x02F0 */ Vec3f unk_2F0; - /* 0x02FC */ s32 unk_2FC; - /* 0x0300 */ s16 unk_300; - /* 0x0302 */ s16 unk_302; - /* 0x0304 */ s16 unk_304; - /* 0x0306 */ UNK_TYPE1 pad306[2]; - /* 0x0308 */ s16 unk_308; - /* 0x030A */ s16 unk_30A; - /* 0x030C */ u8 unk_30C; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder colliderCylinder; + /* 0x190 */ ColliderTris colliderTris; + /* 0x1B0 */ ColliderTrisElement colliderTrisElements[2]; + /* 0x268 */ ObjKendoKanbanActionFunc actionFunc; + /* 0x26C */ Vec3f unk_26C[4]; + /* 0x29C */ Vec3f unk_29C[4]; + /* 0x2CC */ Vec3f unk_2CC; + /* 0x2D8 */ Vec3f unk_2D8; + /* 0x2E4 */ Vec3f unk_2E4; + /* 0x2F0 */ Vec3f unk_2F0; + /* 0x2FC */ s32 unk_2FC; + /* 0x300 */ s16 unk_300; + /* 0x302 */ s16 unk_302; + /* 0x304 */ s16 unk_304; + /* 0x306 */ UNK_TYPE1 pad306[2]; + /* 0x308 */ s16 unk_308; + /* 0x30A */ s16 unk_30A; + /* 0x30C */ u8 unk_30C; } ObjKendoKanban; // size = 0x310 extern const ActorInit Obj_Kendo_Kanban_InitVars; 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 9cbd57ef7..5f319558e 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.h +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.h @@ -9,8 +9,8 @@ #define KIBAKO2_CONTENTS(thisx) (((thisx)->params >> 0xF) & 1) typedef enum { - /* 0 */ CONTENTS_COLLECTIBLE, - /* 1 */ CONTENTS_SKULLTULA + /* 0 */ CONTENTS_COLLECTIBLE, + /* 1 */ CONTENTS_SKULLTULA } ObjKibako2Contents; struct ObjKibako2; diff --git a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c index 5c10fbd16..deb315bc4 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c @@ -64,7 +64,7 @@ void ObjKinoko_Update(Actor* thisx, PlayState* play) { } thisx->scale.y = thisx->scale.x; thisx->scale.z = thisx->scale.x; - thisx->shape.rot.y = Camera_GetCamDirYaw(play->cameraPtrs[play->activeCamera]) + 0x8000; + thisx->shape.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000; } } diff --git a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.h b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.h index dad54478c..c4a9298fa 100644 --- a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.h +++ b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.h @@ -10,11 +10,11 @@ struct ObjKzsaku; typedef void (*ObjKzsakuActionFunc)(struct ObjKzsaku*, PlayState*); typedef struct ObjKzsaku { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ObjKzsakuActionFunc actionFunc; - /* 0x0160 */ f32 raisedAmount; - /* 0x0164 */ s32 switchFlag; - /* 0x0168 */ s16 timer; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjKzsakuActionFunc actionFunc; + /* 0x160 */ f32 raisedAmount; + /* 0x164 */ s32 switchFlag; + /* 0x168 */ s16 timer; } ObjKzsaku; // size = 0x16C extern const ActorInit Obj_Kzsaku_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 28a45984e..f7056b147 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -5,6 +5,7 @@ */ #include "z_obj_lift.h" +#include "objects/object_d_lift/object_d_lift.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,16 @@ void ObjLift_Destroy(Actor* thisx, PlayState* play); void ObjLift_Update(Actor* thisx, PlayState* play); void ObjLift_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_8093D760(ObjLift* this); +void func_8093D7A0(ObjLift* this, PlayState* play); +void func_8093D9C0(ObjLift* this); +void func_8093D8B4(ObjLift* this, PlayState* play); +void func_8093D88C(ObjLift* this); +void func_8093DA48(ObjLift* this, PlayState* play); +void func_8093DB70(ObjLift* this); +void func_8093DB90(ObjLift* this, PlayState* play); +void func_8093DC90(Actor* thisx, PlayState* play); + const ActorInit Obj_Lift_InitVars = { ACTOR_OBJ_LIFT, ACTORCAT_BG, @@ -28,46 +38,207 @@ const ActorInit Obj_Lift_InitVars = { (ActorFunc)ObjLift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8093DD84[] = { - ICHAIN_F32_DIV1000(gravity, -600, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(terminalVelocity, -15000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 350, ICHAIN_CONTINUE), +static s16 D_8093DD50[] = { 0, 10, 20, 30, 40, 50, 60 }; + +Vec2s D_8093DD60[] = { + { 120, -120 }, { 120, 0 }, { 120, 120 }, { 0, -120 }, { 0, 0 }, + { 0, 120 }, { -120, -120 }, { -120, 0 }, { -120, 120 }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -600, 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), }; -#endif +static f32 D_8093DD98[] = { 0.1f, 0.05f }; -extern InitChainEntry D_8093DD84[]; +static f32 yOffsets[] = { -18.0f, -9.0f }; -extern UNK_TYPE D_06000D10; -extern UNK_TYPE D_06000F00; +void func_8093D3C0(ObjLift* this, PlayState* play) { + Vec3f pos; + Vec3f vel; + Vec3f* actorPos = &this->dyna.actor.world.pos; + s32 i; + s32 rand; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093D3C0.s") + for (i = 0; i < ARRAY_COUNT(D_8093DD60); i++) { + pos.x = (D_8093DD60[i].x * this->dyna.actor.scale.x) + actorPos->x; + pos.y = actorPos->y; + pos.z = (D_8093DD60[i].z * this->dyna.actor.scale.z) + actorPos->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/ObjLift_Init.s") + vel.x = D_8093DD60[i].x * this->dyna.actor.scale.x * 0.8f; + vel.y = (Rand_ZeroOne() * 10.0f) + 6.0f; + vel.z = D_8093DD60[i].z * this->dyna.actor.scale.z * 0.8f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/ObjLift_Destroy.s") + if ((s32)Rand_Next() > 0) { + rand = 0x40; + } else { + rand = 0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093D760.s") + EffectSsKakera_Spawn(play, &pos, &vel, actorPos, -0x100, rand, 15, 15, 0, + ((Rand_ZeroOne() * 50.0f) + 50.0f) * this->dyna.actor.scale.x, 0, 32, 50, -1, + OBJECT_D_LIFT, gDampeGraveBrownElevatorDL); + } + if (OBJLIFT_GET_1(&this->dyna.actor) == 0) { + func_800BBFB0(play, &this->dyna.actor.world.pos, 120.0f, 12, 120, 100, 1); + } else if (OBJLIFT_GET_1(&this->dyna.actor) == 1) { + func_800BBFB0(play, &this->dyna.actor.world.pos, 60.0f, 8, 60, 100, 1); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093D7A0.s") +void ObjLift_Init(Actor* thisx, PlayState* play) { + f32 temp_fv0; + ObjLift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093D88C.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.scale.x = this->dyna.actor.scale.z = D_8093DD98[OBJLIFT_GET_1(&this->dyna.actor)]; + this->dyna.actor.scale.y = 5.0f / 90.0f; + this->dyna.actor.shape.rot.z = 0; + this->unk_178 = this->dyna.actor.home.rot.z; + this->dyna.actor.home.rot.z = this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z; + DynaPolyActor_Init(&this->dyna, 1); + if ((this->unk_178 <= 0) && (Flags_GetSwitch(play, OBJLIFT_GET_7F(&this->dyna.actor)))) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + DynaPolyActor_LoadMesh(play, &this->dyna, &gDampeGraveBrownElevatorCol); + this->unk_160 = Rand_Next() >> 0x10; + this->unk_162 = Rand_Next() >> 0x10; + this->unk_164 = Rand_Next() >> 0x10; + func_8093D760(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093D8B4.s") +void ObjLift_Destroy(Actor* thisx, PlayState* play) { + ObjLift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093D9C0.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093DA48.s") +void func_8093D760(ObjLift* this) { + this->timer = D_8093DD50[OBJLIFT_GET_7(&this->dyna.actor)]; + this->actionFunc = func_8093D7A0; + this->dyna.actor.draw = ObjLift_Draw; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093DB70.s") +void func_8093D7A0(ObjLift* this, PlayState* play) { + s32 pad; + s16 quake; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093DB90.s") + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (this->timer <= 0) { + if (OBJLIFT_GET_7(&this->dyna.actor) == 7) { + func_8093D9C0(this); + } else { + quake = Quake_Add(GET_ACTIVE_CAM(play), 1); + Quake_SetSpeed(quake, 10000); + Quake_SetQuakeValues(quake, 2, 0, 0, 0); + Quake_SetCountdown(quake, 20); + func_8093D88C(this); + } + } + } else { + this->timer = D_8093DD50[OBJLIFT_GET_7(&this->dyna.actor)]; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/ObjLift_Update.s") +void func_8093D88C(ObjLift* this) { + this->timer = 20; + this->actionFunc = func_8093D8B4; + this->dyna.actor.draw = func_8093DC90; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/ObjLift_Draw.s") +void func_8093D8B4(ObjLift* this, PlayState* play) { + if (this->timer <= 0) { + func_8093D9C0(this); + } else { + this->unk_160 += 0x2710; + this->unk_174 = Math_SinS(this->unk_160) * 300.0f; + this->unk_176 = Math_CosS(this->unk_160) * 300.0f; + this->unk_162 += 0x4650; + this->unk_168.y = Math_SinS(this->unk_162); + this->unk_164 += 0x4650; + this->unk_168.x = Math_SinS(this->unk_164) * 3.0f; + this->unk_168.z = Math_CosS(this->unk_164) * 3.0f; + } + if ((this->timer & 3) == 3) { + SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 16, NA_SE_EV_BLOCK_SHAKE); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093DC90.s") +void func_8093D9C0(ObjLift* this) { + this->actionFunc = func_8093DA48; + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos); + this->dyna.actor.shape.rot = this->dyna.actor.world.rot = this->dyna.actor.home.rot; + this->dyna.actor.draw = ObjLift_Draw; +} + +void func_8093DA48(ObjLift* this, PlayState* play) { + s32 pad; + s32 sp38; + Vec3f pos; + + Actor_MoveWithGravity(&this->dyna.actor); + Math_Vec3f_Copy(&pos, &this->dyna.actor.prevPos); + pos.y += yOffsets[OBJLIFT_GET_1(&this->dyna.actor)]; + this->dyna.actor.floorHeight = + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->dyna.actor.floorPoly, &sp38, &this->dyna.actor, &pos); + if ((yOffsets[OBJLIFT_GET_1(&this->dyna.actor)] - 0.001f) <= + (this->dyna.actor.floorHeight - this->dyna.actor.world.pos.y)) { + func_8093D3C0(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 20, NA_SE_EV_BOX_BREAK); + if (this->unk_178 > 0) { + func_8093DB70(this); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + } else { + Flags_SetSwitch(play, OBJLIFT_GET_7F(&this->dyna.actor)); + Actor_MarkForDeath(&this->dyna.actor); + } + } +} + +void func_8093DB70(ObjLift* this) { + this->timer = this->unk_178; + this->actionFunc = func_8093DB90; + this->dyna.actor.draw = NULL; +} + +void func_8093DB90(ObjLift* this, PlayState* play) { + if (this->timer <= 0) { + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos); + this->dyna.actor.world.rot = this->dyna.actor.shape.rot = this->dyna.actor.home.rot; + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + func_8093D760(this); + } +} + +void ObjLift_Update(Actor* thisx, PlayState* play) { + ObjLift* this = THIS; + + if (this->timer > 0) { + this->timer--; + } + this->actionFunc(this, play); +} + +void ObjLift_Draw(Actor* thisx, PlayState* play) { + ObjLift* this = THIS; + + Gfx_DrawDListOpa(play, gDampeGraveBrownElevatorDL); +} + +void func_8093DC90(Actor* thisx, PlayState* play) { + ObjLift* this = THIS; + Vec3f pos; + Vec3s rot; + + Math_Vec3f_Sum(&this->dyna.actor.world.pos, &this->unk_168, &pos); + rot.x = this->unk_174 + this->dyna.actor.home.rot.x; + rot.y = this->dyna.actor.home.rot.y; + rot.z = this->unk_176 + this->dyna.actor.home.rot.z; + Matrix_SetTranslateRotateYXZ(pos.x, pos.y, pos.z, &rot); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + Gfx_DrawDListOpa(play, gDampeGraveBrownElevatorDL); +} diff --git a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.h b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.h index 4abba15fd..ea29a9cb9 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.h +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.h @@ -3,15 +3,25 @@ #include "global.h" +#define OBJLIFT_GET_1(thisx) ((thisx)->params & 1) +#define OBJLIFT_GET_7(thisx) (((thisx)->params >> 8) & 7) +#define OBJLIFT_GET_7F(thisx) (((thisx)->params >> 1) & 0x7F) + struct ObjLift; typedef void (*ObjLiftActionFunc)(struct ObjLift*, PlayState*); typedef struct ObjLift { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjLiftActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjLiftActionFunc actionFunc; + /* 0x160 */ s16 unk_160; + /* 0x162 */ s16 unk_162; + /* 0x164 */ s16 unk_164; + /* 0x166 */ s16 timer; + /* 0x168 */ Vec3f unk_168; + /* 0x174 */ s16 unk_174; + /* 0x176 */ s16 unk_176; + /* 0x178 */ s16 unk_178; } ObjLift; // size = 0x17C extern const ActorInit Obj_Lift_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.h b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.h index c8a0b23df..eb16a7a92 100644 --- a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.h +++ b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.h @@ -11,12 +11,12 @@ struct ObjLightblock; typedef void (*ObjLightblockActionFunc)(struct ObjLightblock*, PlayState*); typedef struct ObjLightblock { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ ObjLightblockActionFunc actionFunc; - /* 0x01AC */ s8 timer; - /* 0x01AD */ u8 alpha; - /* 0x01AE */ s8 collisionCounter; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ ObjLightblockActionFunc actionFunc; + /* 0x1AC */ s8 timer; + /* 0x1AD */ u8 alpha; + /* 0x1AE */ s8 collisionCounter; } ObjLightblock; // size = 0x1B0 extern const ActorInit Obj_Lightblock_InitVars; 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 470e22662..b6fd674ef 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -62,7 +62,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -100,9 +100,9 @@ void ObjLightswitch_UpdateSwitchFlags(ObjLightswitch* this, PlayState* play, s32 if (this) {} if (set) { - Flags_SetSwitch(play, GET_LIGHTSWITCH_SWITCHFLAG(this)); + Flags_SetSwitch(play, GET_LIGHTSWITCH_SWITCHFLAG(&this->actor)); } else { - Flags_UnsetSwitch(play, GET_LIGHTSWITCH_SWITCHFLAG(this)); + Flags_UnsetSwitch(play, GET_LIGHTSWITCH_SWITCHFLAG(&this->actor)); } } @@ -150,13 +150,13 @@ void ObjLightswitch_Init(Actor* thisx, PlayState* play) { u32 isSwitchActivated; s32 isTriggered; - isSwitchActivated = Flags_GetSwitch(play, GET_LIGHTSWITCH_SWITCHFLAG(this)); + isSwitchActivated = Flags_GetSwitch(play, GET_LIGHTSWITCH_SWITCHFLAG(&this->actor)); isTriggered = false; Actor_ProcessInitChain(&this->actor, sInitChain); Actor_SetFocus(&this->actor, 0.0f); if (isSwitchActivated) { - if (GET_LIGHTSWITCH_TYPE(this) == LIGHTSWITCH_TYPE_FAKE) { + if (GET_LIGHTSWITCH_TYPE(&this->actor) == LIGHTSWITCH_TYPE_FAKE) { isTriggered = true; } else { ObjLightSwitch_SetupEnabled(this); @@ -167,7 +167,7 @@ void ObjLightswitch_Init(Actor* thisx, PlayState* play) { ObjLightswitch_InitCollider(this, play); - if (GET_LIGHTSWITCH_INVISIBLE(this)) { + if (GET_LIGHTSWITCH_INVISIBLE(&this->actor)) { // the stone tower exterior switch is part of the scene mesh, the actor is invisble on top this->actor.draw = NULL; } @@ -209,7 +209,7 @@ void ObjLightswitch_SetupIdle(ObjLightswitch* this) { } void ObjLightswitch_Idle(ObjLightswitch* this, PlayState* play) { - s32 actorType = GET_LIGHTSWITCH_TYPE(this); + s32 actorType = GET_LIGHTSWITCH_TYPE(&this->actor); if (this->hitState >= 10) { if (actorType == LIGHTSWITCH_TYPE_FAKE) { @@ -260,11 +260,11 @@ void ObjLightSwitch_SetupEnabled(ObjLightswitch* this) { } void ObjLightSwitch_Enabled(ObjLightswitch* this, PlayState* play) { - s32 actorType = GET_LIGHTSWITCH_TYPE(this); + s32 actorType = GET_LIGHTSWITCH_TYPE(&this->actor); if (actorType == LIGHTSWITCH_TYPE_REGULAR) { // switch can be disabled outside of this actor by flag - if (!Flags_GetSwitch(play, GET_LIGHTSWITCH_SWITCHFLAG(this))) { + if (!Flags_GetSwitch(play, GET_LIGHTSWITCH_SWITCHFLAG(&this->actor))) { ObjLightSwitch_SetupDisabled(this); } } else if (actorType == LIGHTSWITCH_TYPE_FLIP) { @@ -329,7 +329,7 @@ void ObjLightswitch_Update(Actor* thisx, PlayState* play) { // dmgFlags enum doesn't exist yet, 0x2000 is light arrows if ((this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x2000) != 0) { this->hitState = 10; - } else if (GET_LIGHTSWITCH_TYPE(this) == LIGHTSWITCH_TYPE_FLIP) { + } else if (GET_LIGHTSWITCH_TYPE(&this->actor) == LIGHTSWITCH_TYPE_FLIP) { if (this->hitState == 0) { if ((this->previousACFlags & AC_HIT) == 0) { this->hitState = 1; @@ -438,7 +438,7 @@ void ObjLightswitch_Draw(Actor* thisx, PlayState* play) { ObjLightswitch* this = THIS; s32 alpha = (u8)(this->colorAlpha >> 6); - if ((GET_LIGHTSWITCH_TYPE(this) == LIGHTSWITCH_TYPE_FAKE) && (alpha > 0) && (alpha < 255)) { + if ((GET_LIGHTSWITCH_TYPE(&this->actor) == LIGHTSWITCH_TYPE_FAKE) && (alpha > 0) && (alpha < 255)) { ObjLightSwitch_DrawXlu(this, play); } else { ObjLightSwitch_DrawOpa(this, play); diff --git a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.h b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.h index 319b1d643..7a8e0043f 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.h +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.h @@ -40,8 +40,8 @@ extern const ActorInit Obj_Lightswitch_InitVars; #define LIGHTSWITCH_TYPE_UNK2 2 #define LIGHTSWITCH_TYPE_FAKE 3 -#define GET_LIGHTSWITCH_TYPE(this) (((this)->actor.params >> 4) & 0x3) -#define GET_LIGHTSWITCH_INVISIBLE(this) (((this)->actor.params >> 3) & 1) -#define GET_LIGHTSWITCH_SWITCHFLAG(this) (((this)->actor.params >> 8) & 0x7F) +#define GET_LIGHTSWITCH_TYPE(thisx) (((thisx)->params >> 4) & 0x3) +#define GET_LIGHTSWITCH_INVISIBLE(thisx) (((thisx)->params >> 3) & 1) +#define GET_LIGHTSWITCH_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) #endif // Z_OBJ_LIGHTSWITCH_H diff --git a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c index e6976c177..697c73f6a 100644 --- a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c +++ b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c @@ -5,6 +5,7 @@ */ #include "z_obj_lupygamelift.h" +#include "objects/object_raillift/object_raillift.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,11 @@ void ObjLupygamelift_Destroy(Actor* thisx, PlayState* play); void ObjLupygamelift_Update(Actor* thisx, PlayState* play); void ObjLupygamelift_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_80AF04BC(ObjLupygamelift* this); +void func_80AF04D8(ObjLupygamelift* this, PlayState* play); +void func_80AF0514(ObjLupygamelift* this); +void func_80AF0530(ObjLupygamelift* this, PlayState* play); + const ActorInit Obj_Lupygamelift_InitVars = { ACTOR_OBJ_LUPYGAMELIFT, ACTORCAT_BG, @@ -28,35 +33,142 @@ const ActorInit Obj_Lupygamelift_InitVars = { (ActorFunc)ObjLupygamelift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AF0740[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void ObjLupygamelift_Init(Actor* thisx, PlayState* play) { + s32 pad; + ObjLupygamelift* this = THIS; + Path* path; + s32 params; -extern InitChainEntry D_80AF0740[]; + Actor_ProcessInitChain(thisx, sInitChain); + this->dyna.actor.scale.y = 0.15f; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.rot.z = 0; + this->timer = 0; + Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, 4); + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawSquare, 0.0f); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_raillift_Colheader_0048D0); + this->targetSpeedXZ = thisx->home.rot.z * 0.1f; + if (this->targetSpeedXZ < 0.0f) { + this->targetSpeedXZ = -this->targetSpeedXZ; + } + this->dyna.actor.home.rot.x = 0; + this->dyna.actor.home.rot.y = 0; + this->dyna.actor.home.rot.z = 0; -extern UNK_TYPE D_060048D0; -extern UNK_TYPE D_060071B8; + path = &play->setupPathList[OBJLUPYGAMELIFT_GET_PATH(thisx)]; + this->pointIndex = OBJLUPYGAMELIFT_GET_7(thisx); + this->count = path->count; + if (this->pointIndex >= this->count) { + this->pointIndex = 0; + } + this->points = Lib_SegmentedToVirtual(path->points); + Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_OBJ_ETCETERA, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, this->dyna.actor.shape.rot.x, + this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, 0); + if (OBJLUPYGAMELIFT_GET_C(thisx) != 0) { + params = 1; + } else { + params = 0; + } + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_GAMELUPY, this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.y, + this->dyna.actor.home.pos.z, 0, 0, 0, params); + func_80AF04BC(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/ObjLupygamelift_Init.s") +void ObjLupygamelift_Destroy(Actor* thisx, PlayState* play) { + ObjLupygamelift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/ObjLupygamelift_Destroy.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF0394.s") +void func_80AF0394(ObjLupygamelift* this) { + static f32 D_80AF0750 = 100.0f; + static f32 D_80AF0754 = 255.0f; + static f32 D_80AF0758 = 5.0f; + static f32 D_80AF075C = 10.0f; + static f32 D_80AF0760 = -240.0f; + static f32 D_80AF0764 = 30.0f; + f32 new_var = D_80AF0754 - D_80AF0750; + f32 new_var2 = D_80AF0764 - D_80AF0760; + f32 new_var3 = D_80AF075C - D_80AF0758; + f32 temp_fa0; + f32 phi_fa1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF04BC.s") + temp_fa0 = this->dyna.actor.world.pos.y - D_80AF0760; + if (temp_fa0 < 0.0f) { + phi_fa1 = 0.0f; + } else if (new_var2 < temp_fa0) { + phi_fa1 = 1.0f; + } else { + phi_fa1 = temp_fa0 / new_var2; + } + this->dyna.actor.shape.shadowAlpha = D_80AF0754 - (phi_fa1 * new_var); + this->dyna.actor.shape.shadowScale = D_80AF075C - (phi_fa1 * new_var3); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF04D8.s") +void func_80AF04BC(ObjLupygamelift* this) { + this->timer = 5; + this->actionFunc = func_80AF04D8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF0514.s") +void func_80AF04D8(ObjLupygamelift* this, PlayState* play) { + if (this->timer == 0) { + func_80AF0514(this); + } else { + this->timer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF0530.s") +void func_80AF0514(ObjLupygamelift* this) { + this->actionFunc = func_80AF0530; + this->dyna.actor.speedXZ = this->targetSpeedXZ; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/ObjLupygamelift_Update.s") +void func_80AF0530(ObjLupygamelift* this, PlayState* play) { + f32 step; + Vec3f target; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/ObjLupygamelift_Draw.s") + target.x = this->points[this->pointIndex].x; + target.y = this->points[this->pointIndex].y; + target.z = this->points[this->pointIndex].z; + step = Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &target, this->dyna.actor.speedXZ); + if (step > 30.0f) { + Math_SmoothStepToF(&this->dyna.actor.speedXZ, this->targetSpeedXZ, 0.5f, 5.0f, 0.1f); + } else if (step > 0.0f) { + Math_SmoothStepToF(&this->dyna.actor.speedXZ, 5.0f, 0.5f, 5.0f, 1.0f); + } else { + if (this->pointIndex < (this->count - 1)) { + this->pointIndex++; + } else { + this->pointIndex = 0; + } + } + if (this->dyna.actor.child->update == NULL) { + this->dyna.actor.child = NULL; + } else { + this->dyna.actor.child->world.pos.x = this->dyna.actor.world.pos.x; + this->dyna.actor.child->world.pos.y = this->dyna.actor.world.pos.y; + this->dyna.actor.child->world.pos.z = this->dyna.actor.world.pos.z; + } + func_80AF0394(this); +} + +void ObjLupygamelift_Update(Actor* thisx, PlayState* play) { + ObjLupygamelift* this = THIS; + + this->actionFunc(this, play); +} + +void ObjLupygamelift_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_raillift_DL_0071B8); +} diff --git a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.h b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.h index 95232485a..e2abd8be5 100644 --- a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.h +++ b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.h @@ -3,16 +3,23 @@ #include "global.h" +#define OBJLUPYGAMELIFT_GET_PATH(thisx) ((thisx)->params & 0x7F) +#define OBJLUPYGAMELIFT_GET_7(thisx) (((thisx)->params >> 7) & 0x1F) +#define OBJLUPYGAMELIFT_GET_C(thisx) (((thisx)->params >> 0xC) & 1) + struct ObjLupygamelift; typedef void (*ObjLupygameliftActionFunc)(struct ObjLupygamelift*, PlayState*); typedef struct ObjLupygamelift { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjLupygameliftActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x14]; -} ObjLupygamelift; // size = 0x174 + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjLupygameliftActionFunc actionFunc; + /* 0x160 */ f32 targetSpeedXZ; + /* 0x164 */ s32 count; + /* 0x168 */ s32 pointIndex; + /* 0x16C */ Vec3s* points; + /* 0x170 */ s16 timer; +} ObjLupygamelift; /* size = 0x174 */ extern const ActorInit Obj_Lupygamelift_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index deaf30f95..429333546 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -39,7 +39,7 @@ static ColliderJntSphElementInit D_80A84570[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A84594 = { { COLTYPE_METAL, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A84570, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A84570, // sJntSphElementsInit, }; // static InitChainEntry sInitChain[] = { 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 d0d749207..47366a842 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 @@ -75,7 +75,7 @@ void func_80C06640(ObjMoonStone* this, PlayState* play) { sp1A -= player->actor.shape.rot.y; if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.colChkInfo.health = 1; - Message_StartTextbox(play, 0x5E3U, &this->actor); + Message_StartTextbox(play, 0x5E3, &this->actor); func_80C066F8(this); } else { s32 phi_v0 = ABS_ALT(sp1A); @@ -127,7 +127,7 @@ void func_80C0685C(ObjMoonStone* this) { } void func_80C06870(ObjMoonStone* this, PlayState* play) { - if (Message_GetState(&play->msgCtx) == 6 && Message_ShouldAdvance(play)) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { gSaveContext.save.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 fd9157d8a..3b1b72f2f 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 @@ -45,7 +45,7 @@ void ObjMuPict_Init(Actor* thisx, PlayState* play) { } func_80C06D90(this, play); - this->unk14A = UNK_ACTOR_PARAM; + this->unk14A = OBJMUPICT_GET_F000(&this->actor); this->actor.targetMode = 6; this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 30.0f; @@ -99,16 +99,18 @@ void func_80C06CC4(ObjMuPict* this) { void func_80C06CD8(ObjMuPict* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { - case 0: - case 1: - case 2: - case 3: - case 4: + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + case TEXT_STATE_CHOICE: break; - case 5: + + case TEXT_STATE_5: func_80C06E88(this, play); break; - case 6: + + case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { func_80C06B5C(this); if (this->actor.cutscene >= 0) { diff --git a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.h b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.h index cac772589..f5417d9db 100644 --- a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.h +++ b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.h @@ -5,7 +5,7 @@ struct ObjMuPict; -#define UNK_ACTOR_PARAM ((this->actor.params & 0xF000) >> 0xC) +#define OBJMUPICT_GET_F000(thisx) (((thisx)->params & 0xF000) >> 0xC) typedef void (*ObjMuPictActionFunc)(struct ObjMuPict*, PlayState*); diff --git a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.h b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.h index 4934e635e..03ed6dc4e 100644 --- a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.h +++ b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.h @@ -10,23 +10,23 @@ typedef void (*ObjMureActionFunc)(struct ObjMure*, PlayState*); #define OBJMURE_MAX_SPAWNS 15 typedef struct { - Actor actor; + /* 0x000 */ Actor actor; /* 0x144 */ char unk_144[0x53]; /* 0x197 */ u8 unk_197; -} ObjMureChild; +} ObjMureChild; // size = 0x198 typedef struct ObjMure { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjMureActionFunc actionFunc; - /* 0x0148 */ s16 chNum; - /* 0x014A */ s16 ptn; - /* 0x014C */ s16 svNum; - /* 0x014E */ s16 type; - /* 0x0150 */ Actor* children[OBJMURE_MAX_SPAWNS]; - /* 0x018C */ u8 childrenStates[OBJMURE_MAX_SPAWNS]; - /* 0x019C */ s16 unk_19C; - /* 0x019E */ s16 unk_19E; - /* 0x01A0 */ s16 unk_1A0; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjMureActionFunc actionFunc; + /* 0x148 */ s16 chNum; + /* 0x14A */ s16 ptn; + /* 0x14C */ s16 svNum; + /* 0x14E */ s16 type; + /* 0x150 */ Actor* children[OBJMURE_MAX_SPAWNS]; + /* 0x18C */ u8 childrenStates[OBJMURE_MAX_SPAWNS]; + /* 0x19C */ s16 unk_19C; + /* 0x19E */ s16 unk_19E; + /* 0x1A0 */ s16 unk_1A0; } ObjMure; // size = 0x1A4 extern const ActorInit Obj_Mure_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.h b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.h index fdb6af93c..bf13c3fbc 100644 --- a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.h +++ b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.h @@ -8,9 +8,9 @@ struct ObjMure2; typedef void (*ObjMure2ActionFunc)(struct ObjMure2*, PlayState*); typedef struct ObjMure2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjMure2ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x38]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjMure2ActionFunc actionFunc; + /* 0x148 */ char unk_148[0x38]; } ObjMure2; // size = 0x180 extern const ActorInit Obj_Mure2_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h index edab30561..d21751198 100644 --- a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h +++ b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h @@ -8,9 +8,9 @@ struct ObjMure3; typedef void (*ObjMure3ActionFunc)(struct ObjMure3*, PlayState*); typedef struct ObjMure3 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjMure3ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x20]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjMure3ActionFunc actionFunc; + /* 0x148 */ char unk_148[0x20]; } ObjMure3; // size = 0x168 extern const ActorInit Obj_Mure3_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c index b85ec38cc..85f1b89ce 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -443,7 +443,7 @@ void func_80BA3344(ObjNozoki* this, PlayState* play) { } } else if ((this->dyna.actor.textId == 0) || Actor_TextboxIsClosing(&this->dyna.actor, play)) { play->nextEntranceIndex = 0xE20; - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; } } diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h index 007569ecd..7b4c3a5b8 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h @@ -16,12 +16,12 @@ typedef void (*ObjNozokiActionFunc)(struct ObjNozoki*, PlayState*); #define OBJNOZOKI_400 0x400 typedef struct ObjNozoki { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ u8 unk_15C; - /* 0x015D */ u8 unk_15D; - /* 0x015E */ s8 unk_15E; - /* 0x015F */ s8 unk_15F; - /* 0x0160 */ ObjNozokiActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ u8 unk_15C; + /* 0x15D */ u8 unk_15D; + /* 0x15E */ s8 unk_15E; + /* 0x15F */ s8 unk_15F; + /* 0x160 */ ObjNozokiActionFunc actionFunc; } ObjNozoki; // size = 0x164 extern const ActorInit Obj_Nozoki_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c index 4a2498043..489373acb 100644 --- a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c +++ b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c @@ -5,6 +5,7 @@ */ #include "z_obj_ocarinalift.h" +#include "objects/object_raillift/object_raillift.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,21 @@ void ObjOcarinalift_Destroy(Actor* thisx, PlayState* play); void ObjOcarinalift_Update(Actor* thisx, PlayState* play); void ObjOcarinalift_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_80AC9680(ObjOcarinalift* this); +void func_80AC96A4(ObjOcarinalift* this, PlayState* play); +void func_80AC96B4(ObjOcarinalift* this); +void func_80AC96D0(ObjOcarinalift* this, PlayState* play); +void func_80AC99D4(ObjOcarinalift* this, PlayState* play); +void func_80AC99C0(ObjOcarinalift* this); +void func_80AC9A68(ObjOcarinalift* this); +void func_80AC9A7C(ObjOcarinalift* this, PlayState* play); +void func_80AC9AB8(ObjOcarinalift* this); +void func_80AC9AE0(ObjOcarinalift* this, PlayState* play); +void func_80AC9B48(ObjOcarinalift* this); +void func_80AC9B5C(ObjOcarinalift* this, PlayState* play); +void func_80AC9C20(ObjOcarinalift* this); +void func_80AC9C48(ObjOcarinalift* this, PlayState* play); + const ActorInit Obj_Ocarinalift_InitVars = { ACTOR_OBJ_OCARINALIFT, ACTORCAT_BG, @@ -28,56 +43,227 @@ const ActorInit Obj_Ocarinalift_InitVars = { (ActorFunc)ObjOcarinalift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AC9D70[] = { - ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_CONTINUE), +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80AC94C0(ObjOcarinalift* this, s32 arg1) { + Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, &this->unk170[arg1]); +} -extern InitChainEntry D_80AC9D70[]; +void ObjOcarinalift_Init(Actor* thisx, PlayState* play) { + Path* path; + ObjOcarinalift* this = THIS; -extern UNK_TYPE D_06001E40; -extern UNK_TYPE D_060048D0; + Actor_ProcessInitChain(thisx, sInitChain); + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.rot.z = 0; + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_raillift_Colheader_0048D0); + this->unk160 = thisx->home.rot.z * 0.1f; + if (this->unk160 < 0.01f) { + func_80AC9680(this); + } else { + path = &play->setupPathList[OBJOCARINALIFT_GET_7F(&this->dyna.actor)]; + this->unk168 = OBJOCARINALIFT_GET_1F(&this->dyna.actor); + this->unk164 = path->count - 1; + this->unk16C = 1; + this->unk170 = Lib_SegmentedToVirtual(path->points); + func_80AC94C0(this, this->unk168); + if ((OBJOCARINALIFT_GET_C(&this->dyna.actor) != OBJOCARINALIFT_PARAMSC_1) && + (Flags_GetSwitch(play, OBJOCARINALIFT_GET_SWITCH_FLAG(&this->dyna.actor)))) { + func_80AC96B4(this); + } else { + func_80AC9AB8(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC94C0.s") +void ObjOcarinalift_Destroy(Actor* thisx, PlayState* play) { + ObjOcarinalift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/ObjOcarinalift_Init.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/ObjOcarinalift_Destroy.s") +void func_80AC9680(ObjOcarinalift* this) { + this->dyna.actor.flags &= ~ACTOR_FLAG_10; + this->actionFunc = func_80AC96A4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9680.s") +void func_80AC96A4(ObjOcarinalift* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC96A4.s") +void func_80AC96B4(ObjOcarinalift* this) { + this->actionFunc = func_80AC96D0; + this->dyna.actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC96B4.s") +void func_80AC96D0(ObjOcarinalift* this, PlayState* play) { + Actor* thisx = &this->dyna.actor; + Vec3f sp48; + f32 magnitude; + f32 phi_fv0; + f32 phi_fa0; + s32 paramsC; + s32 sp34; + Vec3s* temp_v1_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC96D0.s") + func_800B9010(thisx, NA_SE_EV_PLATE_LIFT_LEVEL - SFX_FLAG); + Math_Vec3s_ToVec3f(&sp48, this->unk170 + this->unk168 + this->unk16C); + Math_Vec3f_Diff(&sp48, &thisx->world.pos, &thisx->velocity); + magnitude = Math3D_Vec3fMagnitude(&thisx->velocity); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC99C0.s") + if ((magnitude < (this->unk160 * 8.0f)) && (this->unk160 > 2.0f)) { + phi_fv0 = ((this->unk160 - 2.0f) * 0.1f) + 2.0f; + phi_fa0 = this->unk160 * 0.03f; + } else { + phi_fv0 = this->unk160; + phi_fa0 = this->unk160 * 0.16f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC99D4.s") + Math_StepToF(&thisx->speedXZ, phi_fv0, phi_fa0); + if ((thisx->speedXZ + 0.05f) < magnitude) { + Math_Vec3f_Scale(&thisx->velocity, thisx->speedXZ / magnitude); + thisx->world.pos.x += thisx->velocity.x; + thisx->world.pos.y += thisx->velocity.y; + thisx->world.pos.z += thisx->velocity.z; + } else { + paramsC = OBJOCARINALIFT_GET_C(thisx); + sp34 = true; + this->unk168 += this->unk16C; + thisx->speedXZ *= 0.4f; + if (((this->unk168 >= this->unk164) && (this->unk16C > 0)) || ((this->unk168 <= 0) && (this->unk16C < 0))) { + if (paramsC == OBJOCARINALIFT_PARAMSC_0) { + this->unk16C = -this->unk16C; + this->timer = 10; + func_80AC9A68(this); + } else { + temp_v1_2 = this->unk170 + this->unk164; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9A68.s") + if (this->unk16C > 0) { + this->unk168 = 0; + } else { + this->unk168 = this->unk164; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9A7C.s") + if (((this->unk170->x != temp_v1_2->x) || (this->unk170->y != temp_v1_2->y)) || + (this->unk170->z != temp_v1_2->z)) { + func_80AC99C0(this); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + sp34 = false; + } else if ((paramsC == OBJOCARINALIFT_PARAMSC_1) && (this->unk168 == OBJOCARINALIFT_GET_1F(thisx))) { + func_80AC9AB8(this); + } + } + } else if ((paramsC == OBJOCARINALIFT_PARAMSC_1) && (this->unk168 == OBJOCARINALIFT_GET_1F(thisx))) { + func_80AC9AB8(this); + } + if (sp34) { + func_80AC94C0(this, this->unk168); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9AB8.s") +void func_80AC99C0(ObjOcarinalift* this) { + this->actionFunc = func_80AC99D4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9AE0.s") +void func_80AC99D4(ObjOcarinalift* this, PlayState* play) { + if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + func_80AC94C0(this, this->unk168); + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + if ((OBJOCARINALIFT_GET_C(&this->dyna.actor) == OBJOCARINALIFT_PARAMSC_1) && + (this->unk168 == OBJOCARINALIFT_GET_1F(&this->dyna.actor))) { + func_80AC9AB8(this); + } else { + func_80AC96B4(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9B48.s") +void func_80AC9A68(ObjOcarinalift* this) { + this->actionFunc = func_80AC9A7C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9B5C.s") +void func_80AC9A7C(ObjOcarinalift* this, PlayState* play) { + this->timer--; + if (this->timer <= 0) { + func_80AC96B4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9C20.s") +void func_80AC9AB8(ObjOcarinalift* this) { + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000); + this->actionFunc = func_80AC9AE0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/func_80AC9C48.s") +void func_80AC9AE0(ObjOcarinalift* this, PlayState* play) { + if (func_800B8718(&this->dyna.actor, &play->state)) { + func_80152434(play, 1); + func_80AC9B48(this); + } else if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + func_800B8804(&this->dyna.actor, play, 40.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/ObjOcarinalift_Update.s") +void func_80AC9B48(ObjOcarinalift* this) { + this->actionFunc = func_80AC9B5C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Ocarinalift/ObjOcarinalift_Draw.s") +void func_80AC9B5C(ObjOcarinalift* this, PlayState* play) { + if (func_800B886C(&this->dyna.actor, play)) { + if (play->msgCtx.ocarinaMode == 4) { + if (play->msgCtx.unk1202E == 0) { + if (OBJOCARINALIFT_GET_C(&this->dyna.actor) != OBJOCARINALIFT_PARAMSC_1) { + Flags_SetSwitch(play, OBJOCARINALIFT_GET_SWITCH_FLAG(&this->dyna.actor)); + } + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + func_80AC9C20(this); + } + } else { + if (play->msgCtx.ocarinaMode >= 2) { + play->msgCtx.ocarinaMode = 4; + } + func_80AC9AB8(this); + } + } +} + +void func_80AC9C20(ObjOcarinalift* this) { + this->dyna.actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000); + this->actionFunc = func_80AC9C48; +} + +void func_80AC9C48(ObjOcarinalift* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->cutsceneTimer = 50; + func_80AC96B4(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void ObjOcarinalift_Update(Actor* thisx, PlayState* play) { + ObjOcarinalift* this = THIS; + + this->actionFunc(this, play); + Actor_SetFocus(&this->dyna.actor, 10.0f); + if (this->cutsceneTimer > 0) { + this->cutsceneTimer--; + if (this->cutsceneTimer == 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + } + } +} + +void ObjOcarinalift_Draw(Actor* thisx, PlayState* play) { + ObjOcarinalift* this = THIS; + + Gfx_DrawDListOpa(play, object_raillift_DL_001E40); + Gfx_DrawDListXlu(play, object_raillift_DL_001DB0); +} diff --git a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.h b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.h index d8c050286..a542fb840 100644 --- a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.h +++ b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.h @@ -3,17 +3,32 @@ #include "global.h" +#define OBJOCARINALIFT_GET_C(thisx) (((thisx)->params >> 0xC) & 3) +#define OBJOCARINALIFT_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJOCARINALIFT_GET_1F(thisx) (((thisx)->params >> 7) & 0x1F) +#define OBJOCARINALIFT_GET_SWITCH_FLAG(thisx) ((thisx)->home.rot.x & 0x7F) + struct ObjOcarinalift; typedef void (*ObjOcarinaliftActionFunc)(struct ObjOcarinalift*, PlayState*); typedef struct ObjOcarinalift { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjOcarinaliftActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x18]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjOcarinaliftActionFunc actionFunc; + /* 0x160 */ f32 unk160; + /* 0x164 */ s32 unk164; + /* 0x168 */ s32 unk168; + /* 0x16C */ s32 unk16C; + /* 0x170 */ Vec3s* unk170; + /* 0x174 */ s16 timer; + /* 0x176 */ s16 cutsceneTimer; } ObjOcarinalift; // size = 0x178 +typedef enum ObjOcarinaliftParams { + /* 0x0 */ OBJOCARINALIFT_PARAMSC_0, + /* 0x1 */ OBJOCARINALIFT_PARAMSC_1 +} ObjOcarinaliftParams; + extern const ActorInit Obj_Ocarinalift_InitVars; #endif // Z_OBJ_OCARINALIFT_H diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index b6c2a1d8b..4bfb5ba96 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -84,7 +84,7 @@ s32 ObjOshihiki_StrongEnough(ObjOshihiki* this, PlayState* play) { return true; } - if (func_80124020() >= 2) { + if (Player_GetStrength() >= PLAYER_STRENGTH_ZORA) { return true; } return false; diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.h b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.h index d26920203..ade27ca43 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.h +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.h @@ -38,26 +38,26 @@ enum { #define PUSHBLOCK_MOVE_UNDER (1 << 8) typedef struct ObjOshihiki { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ObjOshihikiActionFunc actionFunc; - /* 0x0160 */ u16 stateFlags; - /* 0x0162 */ s16 timer; - /* 0x0164 */ f32 yawSin; - /* 0x0168 */ f32 yawCos; - /* 0x016C */ f32 pushSpeed; - /* 0x0170 */ f32 pushDist; - /* 0x0174 */ f32 direction; - /* 0x0178 */ s32 floorBgIds[5]; - /* 0x018C */ CollisionPoly* floorPolys[5]; - /* 0x01A0 */ f32 floorHeights[5]; - /* 0x01B4 */ s16 highestFloor; - /* 0x01B6 */ u8 cantMove; - /* 0x01B8 */ struct ObjOshihiki* blockUnder; - /* 0x01BC */ f32 underDistX; - /* 0x01C0 */ f32 underDistZ; - /* 0x01C4 */ s8 textureStep; - /* 0x01C5 */ Color_RGB8 color; - /* 0x01C8 */ AnimatedMaterial* texture; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjOshihikiActionFunc actionFunc; + /* 0x160 */ u16 stateFlags; + /* 0x162 */ s16 timer; + /* 0x164 */ f32 yawSin; + /* 0x168 */ f32 yawCos; + /* 0x16C */ f32 pushSpeed; + /* 0x170 */ f32 pushDist; + /* 0x174 */ f32 direction; + /* 0x178 */ s32 floorBgIds[5]; + /* 0x18C */ CollisionPoly* floorPolys[5]; + /* 0x1A0 */ f32 floorHeights[5]; + /* 0x1B4 */ s16 highestFloor; + /* 0x1B6 */ u8 cantMove; + /* 0x1B8 */ struct ObjOshihiki* blockUnder; + /* 0x1BC */ f32 underDistX; + /* 0x1C0 */ f32 underDistZ; + /* 0x1C4 */ s8 textureStep; + /* 0x1C5 */ Color_RGB8 color; + /* 0x1C8 */ AnimatedMaterial* texture; } ObjOshihiki; // size = 0x1CC extern const ActorInit Obj_Oshihiki_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c index b988df889..6255b2cbe 100644 --- a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c +++ b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c @@ -5,6 +5,8 @@ */ #include "z_obj_purify.h" +#include "objects/object_numa_obj/object_numa_obj.h" +#include "objects/object_dekucity_obj/object_dekucity_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -14,7 +16,31 @@ void ObjPurify_Init(Actor* thisx, PlayState* play); void ObjPurify_Destroy(Actor* thisx, PlayState* play); void ObjPurify_Update(Actor* thisx, PlayState* play); -#if 0 +void func_80A84EC0(ObjPurify* this, PlayState* play); +void func_80A851C8(Actor* thisx, PlayState* play); +void func_80A85074(ObjPurify* this, PlayState* play); +void func_80A850B0(ObjPurify* this); +void func_80A850E8(ObjPurify* this, PlayState* play); +void func_80A85304(Actor* thisx, PlayState* play); +void func_80A84FB4(ObjPurify* this, PlayState* play); +void func_80A85010(ObjPurify* this, PlayState* play); +void ObjPurify_DoNothing(ObjPurify* this, PlayState* play); +void func_80A85048(ObjPurify* this); +void func_80A84FA0(ObjPurify* this); +void func_80A8515C(ObjPurify* this); +void func_80A84FEC(ObjPurify* this); +void func_80A84EAC(ObjPurify* this); + +typedef struct ObjPurifyInfo { + /* 0x00 */ s16 objectId; + /* 0x04 */ f32 scale; + /* 0x08 */ Gfx* opaDLists[2]; + /* 0x10 */ Gfx* xluDLists[2]; + /* 0x18 */ AnimatedMaterial* animMat[2]; + /* 0x20 */ CollisionHeader* colHeader; + /* 0x24 */ s32 isDekuCity; +} ObjPurifyInfo; // size = 0x28 + const ActorInit Obj_Purify_InitVars = { ACTOR_OBJ_PURIFY, ACTORCAT_BG, @@ -27,42 +53,248 @@ const ActorInit Obj_Purify_InitVars = { (ActorFunc)NULL, }; -#endif +ObjPurifyInfo sObjPurifyInfo[] = { + { + OBJECT_NUMA_OBJ, + 0.1f, + { NULL, NULL }, + { object_numa_obj_DL_0128E0, object_numa_obj_DL_012D90 }, + { object_numa_obj_Matanimheader_012CF8, object_numa_obj_Matanimheader_0131A8 }, + &object_numa_obj_Colheader_012818, + false, + }, + { + OBJECT_DEKUCITY_OBJ, + 1.0f, + { NULL, NULL }, + { object_dekucity_obj_DL_0004E0, object_dekucity_obj_DL_001030 }, + { object_dekucity_obj_Matanimheader_000E28, object_dekucity_obj_Matanimheader_001978 }, + &object_dekucity_obj_Colheader_0002AC, + true, + }, + { + OBJECT_DEKUCITY_OBJ, + 1.0f, + { object_dekucity_obj_DL_001ED8, object_dekucity_obj_DL_003998 }, + { object_dekucity_obj_DL_001D80, NULL }, + { object_dekucity_obj_Matanimheader_003820, NULL }, + NULL, + true, + }, + { + OBJECT_NUMA_OBJ, + 0.1f, + { NULL, NULL }, + { object_numa_obj_DL_012A60, object_numa_obj_DL_012F10 }, + { object_numa_obj_Matanimheader_012B58, object_numa_obj_Matanimheader_013008 }, + &object_numa_obj_Colheader_012818, + false, + }, + { + OBJECT_NUMA_OBJ, + 0.1f, + { NULL, NULL }, + { object_numa_obj_DL_012BF0, object_numa_obj_DL_0130A0 }, + { object_numa_obj_Matanimheader_012CE8, object_numa_obj_Matanimheader_013198 }, + &object_numa_obj_Colheader_012818, + false, + }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A84CD0.s") +void ObjPurify_SetSysMatrix(f32 yPos) { + Matrix_GetCurrent()->yw = yPos; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A84CF8.s") +s32 ObjPurify_IsPurified(ObjPurify* this) { + ObjPurifyInfo* info = &sObjPurifyInfo[OBJPURIFY_GET_INFO_INDEX(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/ObjPurify_Init.s") + if (!info->isDekuCity) { + // woodfall temple wood flower unraveled + if (gSaveContext.save.weekEventReg[12] & 1) { + return true; + } + } + // woodfall temple purification cutscene watched + else { + if (gSaveContext.save.weekEventReg[20] & 2) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/ObjPurify_Destroy.s") +void ObjPurify_Init(Actor* thisx, PlayState* play) { + s32 pad; + ObjPurify* this = THIS; + ObjPurifyInfo* info = &sObjPurifyInfo[OBJPURIFY_GET_INFO_INDEX(&this->dyna.actor)]; + s32 sp20 = OBJPURIFY_GET_UNK_FLAG(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A84EAC.s") + Actor_SetScale(&this->dyna.actor, info->scale); + if (sp20 == 1) { + DynaPolyActor_Init(&this->dyna, 0); + } + this->objIndex = Object_GetIndex(&play->objectCtx, info->objectId); + if (this->objIndex < 0) { + Actor_MarkForDeath(&this->dyna.actor); + } else if (sp20 == 0) { + func_80A84EAC(this); + } else if (ObjPurify_IsPurified(this)) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + func_80A84EAC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A84EC0.s") +void ObjPurify_Destroy(Actor* thisx, PlayState* play) { + ObjPurify* this = THIS; + if (OBJPURIFY_GET_UNK_FLAG(&this->dyna.actor) == 1) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A84FA0.s") +void func_80A84EAC(ObjPurify* this) { + this->actionFunc = func_80A84EC0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A84FB4.s") +void func_80A84EC0(ObjPurify* this, PlayState* play) { + s32 pad; + s32 sp28; + s32 index; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A84FEC.s") + if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { + sp28 = OBJPURIFY_GET_UNK_FLAG(&this->dyna.actor); + index = OBJPURIFY_GET_INFO_INDEX(&this->dyna.actor); + this->dyna.actor.objBankIndex = this->objIndex; + Actor_SetObjectDependency(play, &this->dyna.actor); + if (sp28 == 1) { + DynaPolyActor_LoadMesh(play, &this->dyna, sObjPurifyInfo[index].colHeader); + func_80A84FA0(this); + } else if (ObjPurify_IsPurified(this)) { + func_80A8515C(this); + } else { + func_80A84FEC(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A85010.s") +void func_80A84FA0(ObjPurify* this) { + this->actionFunc = func_80A84FB4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A85048.s") +void func_80A84FB4(ObjPurify* this, PlayState* play) { + if (ObjPurify_IsPurified(this)) { + Actor_MarkForDeath(&this->dyna.actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A85074.s") +void func_80A84FEC(ObjPurify* this) { + this->dyna.actor.draw = func_80A851C8; + this->gfxIndex = 0; + this->actionFunc = func_80A85010; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A850B0.s") +void func_80A85010(ObjPurify* this, PlayState* play) { + if (ObjPurify_IsPurified(this)) { + func_80A85048(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A850E8.s") +void func_80A85048(ObjPurify* this) { + this->dyna.actor.draw = func_80A851C8; + this->gfxIndex = 0; + this->actionFunc = func_80A85074; + this->timer = 30; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A8515C.s") +void func_80A85074(ObjPurify* this, PlayState* play) { + this->timer--; + if (this->timer <= 0) { + func_80A850B0(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A85194.s") +void func_80A850B0(ObjPurify* this) { + f32 yPos = this->dyna.actor.home.pos.y; + this->dyna.actor.draw = func_80A85304; + this->unk168[1] = yPos - 90.0f; + this->actionFunc = func_80A850E8; + this->unk168[0] = yPos; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/ObjPurify_Update.s") +void func_80A850E8(ObjPurify* this, PlayState* play) { + Math_StepToF(&this->unk168[0], this->dyna.actor.home.pos.y - 90.0f, 0.9f); + if (Math_StepToF(&this->unk168[1], this->dyna.actor.home.pos.y, 0.9f)) { + func_80A8515C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A851C8.s") +void func_80A8515C(ObjPurify* this) { + this->dyna.actor.flags &= ~ACTOR_FLAG_10; + this->dyna.actor.draw = func_80A851C8; + this->gfxIndex = 1; + this->actionFunc = ObjPurify_DoNothing; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Purify/func_80A85304.s") +void ObjPurify_DoNothing(ObjPurify* this, PlayState* play) { +} + +void ObjPurify_Update(Actor* thisx, PlayState* play) { + ObjPurify* this = THIS; + + this->actionFunc(this, play); +} + +void func_80A851C8(Actor* thisx, PlayState* play) { + s32 pad; + ObjPurify* this = THIS; + ObjPurifyInfo* info = &sObjPurifyInfo[OBJPURIFY_GET_INFO_INDEX(&this->dyna.actor)]; + Gfx* opaDList = info->opaDLists[this->gfxIndex]; + Gfx* xluDList = info->xluDLists[this->gfxIndex]; + AnimatedMaterial* animMat = info->animMat[this->gfxIndex]; + + OPEN_DISPS(play->state.gfxCtx); + + if (animMat != NULL) { + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(animMat)); + } + if (opaDList != NULL) { + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, opaDList); + } + if (xluDList != NULL) { + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, xluDList); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +void func_80A85304(Actor* thisx, PlayState* play) { + s32 pad; + ObjPurify* this = THIS; + ObjPurifyInfo* info = &sObjPurifyInfo[OBJPURIFY_GET_INFO_INDEX(&this->dyna.actor)]; + s32 sp6C[2]; + s32 i; + s32 index; + + if (this->unk168[1] < this->unk168[0]) { + sp6C[0] = 1; + sp6C[1] = 0; + } else { + sp6C[0] = 0; + sp6C[1] = 1; + } + + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + for (i = 0; i < ARRAY_COUNT(sp6C); i++) { + index = sp6C[i]; + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(info->animMat[index])); + ObjPurify_SetSysMatrix(this->unk168[index]); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, info->xluDLists[index]); + }; + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.h b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.h index a092a69bd..542938c80 100644 --- a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.h +++ b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.h @@ -8,12 +8,17 @@ struct ObjPurify; typedef void (*ObjPurifyActionFunc)(struct ObjPurify*, PlayState*); typedef struct ObjPurify { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjPurifyActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x10]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjPurifyActionFunc actionFunc; + /* 0x160 */ s32 gfxIndex; + /* 0x164 */ s16 timer; + /* 0x166 */ s16 objIndex; + /* 0x168 */ f32 unk168[2]; } ObjPurify; // size = 0x170 extern const ActorInit Obj_Purify_InitVars; +#define OBJPURIFY_GET_INFO_INDEX(thisx) ((thisx)->params & 0xF) +#define OBJPURIFY_GET_UNK_FLAG(thisx) (((thisx)->params >> 0xC) & 1) + #endif // Z_OBJ_PURIFY_H 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 05349cfac..616fb341c 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c @@ -6,6 +6,7 @@ #include "z_obj_raillift.h" #include "objects/object_raillift/object_raillift.h" +#include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" #define FLAGS (ACTOR_FLAG_10) @@ -74,7 +75,8 @@ void ObjRaillift_Init(Actor* thisx, PlayState* play) { } if (type == DEKU_FLOWER_PLATFORM) { Actor_SpawnAsChild(&play->actorCtx, thisx, play, ACTOR_OBJ_ETCETERA, thisx->world.pos.x, thisx->world.pos.y, - thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, thisx->shape.rot.z, 0); + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, thisx->shape.rot.z, + DEKU_FLOWER_PARAMS(DEKU_FLOWER_TYPE_PINK)); if (isColorful) { thisx->draw = ObjRaillift_DrawDekuFlowerPlatformColorful; } else { 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 a20c8af43..be15ac11a 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h @@ -10,9 +10,9 @@ struct ObjRoomtimer; typedef void (*ObjRoomtimerActionFunc)(struct ObjRoomtimer*, PlayState*); typedef struct ObjRoomtimer { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjRoomtimerActionFunc actionFunc; - /* 0x0148 */ s32 switchFlag; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjRoomtimerActionFunc actionFunc; + /* 0x148 */ s32 switchFlag; } ObjRoomtimer; // size = 0x14C extern const ActorInit Obj_Roomtimer_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c index 2d984f726..9d3476ff6 100644 --- a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c +++ b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c @@ -6,6 +6,7 @@ #include "z_obj_rotlift.h" #include "objects/object_rotlift/object_rotlift.h" +#include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" #define FLAGS 0x00000000 @@ -38,14 +39,14 @@ const ActorInit Obj_Rotlift_InitVars = { struct ModelInfo sModelInfo[] = { { - object_rotlift_DL_000400, - object_rotlift_Matanimheader_001F98, - &object_rotlift_Colheader_002190, + gDekuMoonDungeonRotatingPlatformsDL, + gDekuMoonDungeonRotatingPlatformsUnusedTexAnim, + &gDekuMoonDungeonRotatingPlatformsCol, }, { - object_rotlift_DL_002CE0, - object_rotlift_Matanimheader_004A08, - &object_rotlift_Colheader_004DF0, + gDekuMoonDungeonRotatingSpikesDL, + gDekuMoonDungeonRotatingSpikesUnusedTexAnim, + &gDekuMoonDungeonRotatingSpikesCol, }, }; @@ -64,6 +65,7 @@ void ObjRotlift_MoveDekuFlowers(ObjRotlift* this) { for (i = 0; i < ARRAY_COUNT(this->dekuFlowers); i++, dekuFlower++) { curDekuFlower = *dekuFlower; + if (curDekuFlower->dyna.actor.update == NULL) { *dekuFlower = NULL; } else { @@ -74,6 +76,7 @@ void ObjRotlift_MoveDekuFlowers(ObjRotlift* this) { this->dyna.actor.world.pos.z + posOffset * Math_CosS(this->dyna.actor.shape.rot.y); curDekuFlower->dyna.actor.shape.rot.y = this->dyna.actor.shape.rot.y; } + posOffset -= 600.0f; } } @@ -82,26 +85,32 @@ void ObjRotlift_Init(Actor* thisx, PlayState* play2) { PlayState* play = play2; ObjRotlift* this = THIS; s32 type = OBJROTLIFT_GET_TYPE(&this->dyna.actor); - s32 dekuFlowerType; + s32 dekuFlowerParams; s32 i; ModelInfo* modelInfo; ObjEtcetera** dekuFlowers; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - if (type == 0) { + if (type == OBJROTLIFT_TYPE_PLATFORMS) { for (dekuFlowers = this->dekuFlowers, i = 0; i < ARRAY_COUNT(this->dekuFlowers); i++, dekuFlowers++) { - if (!OBJROTLIFT_GET_4000(thisx) || (i != 0)) { - dekuFlowerType = 0; + // Depending on the params, the platforms can be configured in one of two ways: + // 1. Pink Deku Flower, Pink Deku Flower + // 2. Gold Deku Flower, Pink Deku Flower + if (!OBJROTLIFT_FIRST_DEKU_FLOWER_IS_GOLD(thisx) || (i != 0)) { + dekuFlowerParams = DEKU_FLOWER_PARAMS(DEKU_FLOWER_TYPE_PINK); } else { - dekuFlowerType = 0x100; + dekuFlowerParams = DEKU_FLOWER_PARAMS(DEKU_FLOWER_TYPE_GOLD); } + *dekuFlowers = (ObjEtcetera*)Actor_SpawnAsChild( &play->actorCtx, &this->dyna.actor, play, ACTOR_OBJ_ETCETERA, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, this->dyna.actor.shape.rot.x, - this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, dekuFlowerType); + this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, dekuFlowerParams); } + ObjRotlift_MoveDekuFlowers(this); } + DynaPolyActor_Init(&this->dyna, 3); modelInfo = &sModelInfo[type]; @@ -120,14 +129,16 @@ void ObjRotlift_Update(Actor* thisx, PlayState* play) { s16 angShift; s32 angVelocity; - if (OBJROTLIFT_GET_TYPE(&this->dyna.actor) == 0) { + if (OBJROTLIFT_GET_TYPE(&this->dyna.actor) == OBJROTLIFT_TYPE_PLATFORMS) { ObjRotlift_MoveDekuFlowers(this); } + if (thisx->params >= 0) { angVelocity = -0xC8; } else { angVelocity = 0xC8; } + angShift = angVelocity; this->dyna.actor.shape.rot.y += angShift; } @@ -137,6 +148,7 @@ void ObjRotlift_Draw(Actor* thisx, PlayState* play) { ObjRotlift* this = THIS; ModelInfo* modelInfo = &sModelInfo[OBJROTLIFT_GET_TYPE(&this->dyna.actor)]; + // Neither of the displaylists reference other segments, so this call is ultimately pointless. AnimatedMat_Draw(play, modelInfo->animMat); Gfx_DrawDListOpa(play, modelInfo->dList); } diff --git a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h index cc627a295..46cbef0ee 100644 --- a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h +++ b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h @@ -6,7 +6,12 @@ #include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" #define OBJROTLIFT_GET_TYPE(thisx) ((thisx)->params & 1) -#define OBJROTLIFT_GET_4000(thisx) ((thisx)->params & 0x4000) +#define OBJROTLIFT_FIRST_DEKU_FLOWER_IS_GOLD(thisx) ((thisx)->params & 0x4000) + +typedef enum { + /* 0 */ OBJROTLIFT_TYPE_PLATFORMS, + /* 1 */ OBJROTLIFT_TYPE_SPIKES, +} ObjRotliftType; struct ObjRotlift; diff --git a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c index 7ddc91142..5246b20d4 100644 --- a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c +++ b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c @@ -5,6 +5,7 @@ */ #include "z_obj_shutter.h" +#include "objects/object_f53_obj/object_f53_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -12,10 +13,9 @@ void ObjShutter_Init(Actor* thisx, PlayState* play); void ObjShutter_Destroy(Actor* thisx, PlayState* play); -void ObjShutter_Update(Actor* thisx, PlayState* play); +void ObjShutter_Update(Actor* thisx, PlayState* play2); void ObjShutter_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Obj_Shutter_InitVars = { ACTOR_OBJ_SHUTTER, ACTORCAT_PROP, @@ -28,14 +28,66 @@ const ActorInit Obj_Shutter_InitVars = { (ActorFunc)ObjShutter_Draw, }; -#endif +void ObjShutter_Init(Actor* thisx, PlayState* play) { +} -extern UNK_TYPE D_060011E0; +void ObjShutter_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Shutter/ObjShutter_Init.s") +static u8 sScheduleScript[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 20, 0, 0x9 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_L(2), + /* 0x9 */ SCHEDULE_CMD_RET_VAL_L(1), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Shutter/ObjShutter_Destroy.s") +void ObjShutter_Update(Actor* thisx, PlayState* play2) { + ObjShutter* this = THIS; + PlayState* play = play2; + ScheduleOutput scheduleOutput; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Shutter/ObjShutter_Update.s") + Schedule_RunScript(play, sScheduleScript, &scheduleOutput); + if (scheduleOutput.result == 1) { + if (this->scheduleResult != scheduleOutput.result) { + this->actor.velocity.y = 0.0f; + } + if ((this->verticalOffset >= 80.0f) || (this->scheduleResult == 0)) { + this->actor.velocity.y = 0.0f; + this->verticalOffset = 80.0f; + } else { + this->verticalOffset += 10.0f; + } + } else { + if (this->scheduleResult != scheduleOutput.result) { + this->actor.velocity.y = 0.0f; + } + if (this->verticalOffset != 0.0f) { + this->actor.velocity.y -= 3.0f; + this->verticalOffset += this->actor.velocity.y; + if (this->verticalOffset <= 0.0f) { + this->actor.velocity.y = fabsf(this->actor.velocity.y) * 0.8f; + if ((s32)this->actor.velocity.y == 0) { + this->actor.velocity.y = 0.0f; + this->verticalOffset = 0.0f; + } + } + } + } + this->scheduleResult = scheduleOutput.result; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Shutter/ObjShutter_Draw.s") +void ObjShutter_Draw(Actor* thisx, PlayState* play) { + ObjShutter* this = THIS; + + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->verticalOffset, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gBankShutterDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.h b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.h index 764f5dd2a..b777c64b3 100644 --- a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.h +++ b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.h @@ -7,7 +7,8 @@ struct ObjShutter; typedef struct ObjShutter { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x8]; + /* 0x144 */ u8 scheduleResult; + /* 0x148 */ f32 verticalOffset; } ObjShutter; // size = 0x14C extern const ActorInit Obj_Shutter_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 15bd818fc..3eee8491a 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c @@ -531,7 +531,7 @@ void func_80A22334(ObjSkateblock* this, PlayState* play) { if (sp2C == -1) { sp30 = false; } else if (!(this->unk_1C1 & 2) && (this->unk_172[sp2C] > 10) && (D_80A22A10 == 0) && - !func_80A216D4(this, play, 2.0f, &sp20) && !Player_InCsMode(&play->state)) { + !func_80A216D4(this, play, 2.0f, &sp20) && !Player_InCsMode(play)) { func_80A21C88(this, sp2C); func_80A2244C(this); sp30 = false; diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h index 83131e4d9..97a2e6ede 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h @@ -10,26 +10,26 @@ typedef void (*ObjSkateblockActionFunc)(struct ObjSkateblock*, PlayState*); #define OBJSKAEBLOCK_GET_F(thisx) ((thisx)->params & 0xF) typedef struct { - /* 0x00 */ CollisionPoly* poly; - /* 0x04 */ f32 height; - /* 0x08 */ s32 bgId; + /* 0x0 */ CollisionPoly* poly; + /* 0x4 */ f32 height; + /* 0x8 */ s32 bgId; } ObjSkateblockFloor; // size = 0xC typedef struct ObjSkateblock { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ObjSkateblockActionFunc actionFunc; - /* 0x0160 */ f32 unk_160; - /* 0x0164 */ f32 unk_164; - /* 0x0168 */ f32 unk_168; - /* 0x016C */ f32* unk_16C; - /* 0x0170 */ s16 unk_170; - /* 0x0172 */ s16 unk_172[4]; - /* 0x017A */ s16 unk_17A; - /* 0x017C */ s16 unk_17C; - /* 0x0180 */ f32 unk_180; - /* 0x0184 */ ObjSkateblockFloor unk_184[5]; - /* 0x01C0 */ u8 unk_1C0; - /* 0x01C1 */ u8 unk_1C1; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjSkateblockActionFunc actionFunc; + /* 0x160 */ f32 unk_160; + /* 0x164 */ f32 unk_164; + /* 0x168 */ f32 unk_168; + /* 0x16C */ f32* unk_16C; + /* 0x170 */ s16 unk_170; + /* 0x172 */ s16 unk_172[4]; + /* 0x17A */ s16 unk_17A; + /* 0x17C */ s16 unk_17C; + /* 0x180 */ f32 unk_180; + /* 0x184 */ ObjSkateblockFloor unk_184[5]; + /* 0x1C0 */ u8 unk_1C0; + /* 0x1C1 */ u8 unk_1C1; } ObjSkateblock; // size = 0x1C4 extern const ActorInit Obj_Skateblock_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c index c69dd7ff8..72f452682 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -68,7 +68,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; 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 72c96d25e..937a61d79 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -61,7 +61,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h index 2b88a6b2c..b6990fc1c 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h @@ -11,17 +11,17 @@ typedef void (*ObjSnowball2ActionFunc)(struct ObjSnowball2*, PlayState*); #define ENOBJSNOWBALL2_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) typedef struct ObjSnowball2 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderJntSph collider; - /* 0x0164 */ ColliderJntSphElement colliderElements[1]; - /* 0x01A4 */ ObjSnowball2ActionFunc actionFunc; - /* 0x01A8 */ s16 unk_1A8; - /* 0x01AA */ s16 unk_1AA; - /* 0x01AC */ s8 unk_1AC; - /* 0x01AD */ u8 unk_1AD; - /* 0x01AE */ s8 unk_1AE; - /* 0x01AF */ s8 unk_1AF; - /* 0x01B0 */ UNK_TYPE1 unk1B0[4]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElements[1]; + /* 0x1A4 */ ObjSnowball2ActionFunc actionFunc; + /* 0x1A8 */ s16 unk_1A8; + /* 0x1AA */ s16 unk_1AA; + /* 0x1AC */ s8 unk_1AC; + /* 0x1AD */ u8 unk_1AD; + /* 0x1AE */ s8 unk_1AE; + /* 0x1AF */ s8 unk_1AF; + /* 0x1B0 */ UNK_TYPE1 unk1B0[4]; } ObjSnowball2; // size = 0x1B4 extern const ActorInit Obj_Snowball2_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c index 700145158..4fb83303b 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c @@ -125,7 +125,7 @@ static ColliderTrisInit sTrisInit1 = { OC2_NONE, COLSHAPE_TRIS, }, - 6, + ARRAY_COUNT(sTrisElementsInit1), sTrisElementsInit1, }; @@ -219,7 +219,7 @@ static ColliderTrisInit sTrisInit2 = { OC2_NONE, COLSHAPE_TRIS, }, - 6, + ARRAY_COUNT(sTrisElementsInit2), sTrisElementsInit2, }; @@ -534,14 +534,14 @@ s32 func_80B30480(ObjSpidertent* this, PlayState* play, Vec3f* arg2) { for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { triNorm = &this->collider.elements[i].dim; - if (func_80B2FB94(&player->swordInfo[0].tip, 6.0f, triNorm, &sp58, &sp54) && + if (func_80B2FB94(&player->meleeWeaponInfo[0].tip, 6.0f, triNorm, &sp58, &sp54) && func_80B2FC98(triNorm, &sp58)) { break; } } if (i < ARRAY_COUNT(this->colliderElements)) { - Math_Vec3f_Copy(arg2, &player->swordInfo[0].tip); + Math_Vec3f_Copy(arg2, &player->meleeWeaponInfo[0].tip); return true; } } diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h index 86eeb54b5..3fdb83597 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h @@ -11,20 +11,20 @@ typedef void (*ObjSpidertentActionFunc)(struct ObjSpidertent*, PlayState*); #define OBJSPIDERTENT_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) typedef struct ObjSpidertent { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderTris collider; - /* 0x017C */ ColliderTrisElement colliderElements[6]; - /* 0x03A4 */ Vec3f unk_3A4; - /* 0x03B0 */ f32 unk_3B0[4]; - /* 0x03C0 */ u8 unk_3C0; - /* 0x03C1 */ s8 unk_3C1; - /* 0x03C2 */ u8 unk_3C2; - /* 0x03C3 */ u8 unk_3C3; - /* 0x03C4 */ u8 unk_3C4; - /* 0x03C5 */ u8 unk_3C5; - /* 0x03C6 */ s8 unk_3C6; - /* 0x03C7 */ s8 unk_3C7; - /* 0x03C8 */ ObjSpidertentActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderTris collider; + /* 0x17C */ ColliderTrisElement colliderElements[6]; + /* 0x3A4 */ Vec3f unk_3A4; + /* 0x3B0 */ f32 unk_3B0[4]; + /* 0x3C0 */ u8 unk_3C0; + /* 0x3C1 */ s8 unk_3C1; + /* 0x3C2 */ u8 unk_3C2; + /* 0x3C3 */ u8 unk_3C3; + /* 0x3C4 */ u8 unk_3C4; + /* 0x3C5 */ u8 unk_3C5; + /* 0x3C6 */ s8 unk_3C6; + /* 0x3C7 */ s8 unk_3C7; + /* 0x3C8 */ ObjSpidertentActionFunc actionFunc; } ObjSpidertent; // size = 0x3CC extern const ActorInit Obj_Spidertent_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c index ea4734833..3a1cae372 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c @@ -118,7 +118,7 @@ static ColliderTrisInit sTrisInit = { OC2_NONE, COLSHAPE_TRIS, }, - 6, + ARRAY_COUNT(sTrisElementsInit), sTrisElementsInit, }; @@ -148,7 +148,7 @@ void func_80A1DA50(PlayState* play, ObjSpinyroll* this, Vec3f* arg2, Vec3f* arg3 Math_Vec3f_Sum(arg2, arg3, &sp1C); Math_Vec3f_Scale(&sp1C, 0.5f); - EffectSsHitMark_SpawnFixedScale(play, 3, &sp1C); + EffectSsHitmark_SpawnFixedScale(play, 3, &sp1C); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); } diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h index c265e7d65..741385264 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h @@ -18,9 +18,9 @@ typedef s32 (*ObjSpinyrollColFunc)(CollisionContext*, f32*, CollisionPoly**, s32 #define OBJSPINYROLL_GET_C000_1 1 typedef struct { - /* 0x00 */ f32 unk_00; - /* 0x04 */ CollisionPoly* unk_04; - /* 0x08 */ s32 bgId; + /* 0x0 */ f32 unk_00; + /* 0x4 */ CollisionPoly* unk_04; + /* 0x8 */ s32 bgId; } ObjSpinyrollSubStruct; // size = 0xC typedef struct { @@ -34,26 +34,26 @@ typedef struct { } ObjSpinyrollStruct2; // size = 0xF8? typedef struct ObjSpinyroll { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderTris collider; - /* 0x017C */ ColliderTrisElement colliderElements[6]; - /* 0x03A4 */ ObjSpinyrollStruct2 unk_3A4; - ///* 0x0494 */ ObjSpinyrollStruct* unk_494; // alternative testing - ///* 0x0498 */ s32 unk_498; - /* 0x049C */ s32 unk_49C; - /* 0x04A0 */ ObjSpinyrollActionFunc actionFunc; - /* 0x04A4 */ f32 unk_4A4; - /* 0x04A8 */ s32 unk_4A8; - /* 0x04AC */ Vec3f unk_4AC[2]; - /* 0x04C4 */ Vec3f unk_4C4; - /* 0x04D0 */ f32 unk_4D0; - /* 0x04D4 */ f32 unk_4D4; - /* 0x04D8 */ s16 unk_4D8; - /* 0x04DA */ s16 unk_4DA; - /* 0x04DC */ s16 unk_4DC; - /* 0x04DE */ s16 unk_4DE; - /* 0x04E0 */ s16 unk_4E0; - /* 0x04E2 */ s16 unk_4E2; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderTris collider; + /* 0x17C */ ColliderTrisElement colliderElements[6]; + /* 0x3A4 */ ObjSpinyrollStruct2 unk_3A4; + ///* 0x494 */ ObjSpinyrollStruct* unk_494; // alternative testing + ///* 0x498 */ s32 unk_498; + /* 0x49C */ s32 unk_49C; + /* 0x4A0 */ ObjSpinyrollActionFunc actionFunc; + /* 0x4A4 */ f32 unk_4A4; + /* 0x4A8 */ s32 unk_4A8; + /* 0x4AC */ Vec3f unk_4AC[2]; + /* 0x4C4 */ Vec3f unk_4C4; + /* 0x4D0 */ f32 unk_4D0; + /* 0x4D4 */ f32 unk_4D4; + /* 0x4D8 */ s16 unk_4D8; + /* 0x4DA */ s16 unk_4DA; + /* 0x4DC */ s16 unk_4DC; + /* 0x4DE */ s16 unk_4DE; + /* 0x4E0 */ s16 unk_4E0; + /* 0x4E2 */ s16 unk_4E2; } ObjSpinyroll; // size = 0x4E4 extern const ActorInit Obj_Spinyroll_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index 071828562..801cfc3ce 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -411,7 +411,7 @@ void ObjSwitch_Init(Actor* thisx, PlayState* play) { } } if (type == OBJSWITCH_TYPE_CRYSTAL) { - sCrystalSwitchAnimatedMat = Lib_SegmentedToVirtual(&gCrystalSwitchAnimatedMat); + sCrystalSwitchAnimatedMat = Lib_SegmentedToVirtual(&gCrystalSwitchTexAnim); } if (OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { ObjSwitch_EyeSwitchFrozenInit(this); @@ -595,7 +595,7 @@ void ObjSwitch_FloorSwitchDown(ObjSwitch* this, PlayState* play) { case OBJSWITCH_SUBTYPE_RESET: case OBJSWITCH_SUBTYPE_RESET_INVERTED: if (!DynaPolyActor_IsInSwitchPressedState(&this->dyna) && - (Player_InCsMode(&play->state) == 0 || play->sceneNum == SCENE_SECOM)) { + (!Player_InCsMode(play) || play->sceneNum == SCENE_SECOM)) { if (this->floorSwitchReleaseTimer <= 0) { if (subType == OBJSWITCH_SUBTYPE_RESET) { ObjSwitch_SetSwitchFlagState(this, play, false); @@ -885,7 +885,7 @@ void ObjSwitch_LargeFloorSwitchDown(ObjSwitch* this, PlayState* play) { ObjSwitch_LargeFloorSwitchRiseUpInit(this); } } else if (subType == OBJSWITCH_SUBTYPE_RESET || subType == OBJSWITCH_SUBTYPE_RESET_INVERTED) { - if (!DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna) && !Player_InCsMode(&play->state)) { + if (!DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna) && !Player_InCsMode(play)) { if (this->floorSwitchReleaseTimer <= 0) { if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET) { ObjSwitch_SetSwitchFlagState(this, play, false); @@ -945,7 +945,7 @@ void ObjSwitch_Update(Actor* thisx, PlayState* play) { break; case OBJSWITCH_TYPE_CRYSTAL: case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: - if (!Player_InCsMode(&play->state)) { + if (!Player_InCsMode(play)) { if (this->disableCrystalSwitchTimer > 0) { this->disableCrystalSwitchTimer--; } diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h index 34d7019e8..f208a60cf 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h @@ -33,31 +33,31 @@ typedef enum { #define OBJSWITCH_INVERSE_BLUE 0x30 typedef struct ObjSwitch { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ObjSwitchActionFunc actionFunc; - /* 0x0160 */ s16 floorSwitchReleaseTimer; - /* 0x0162 */ s16 disableCrystalSwitchTimer; - /* 0x0164 */ s8 eyeTexIndex; - /* 0x0165 */ s8 sfxTimer; - /* 0x0168 */ s32 crystalAnimTimer; - /* 0x016C */ Color_RGB8 color; - /* 0x016F */ u8 collisionFlags; - /* 0x0170 */ s8 floorSwitchPlayerSnapState; - /* 0x0171 */ s8 nextSwitchFlagState; - /* 0x0172 */ s8 isPlayingCutscene; - /* 0x0174 */ ObjSwitchSetupActionFunc setupFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjSwitchActionFunc actionFunc; + /* 0x160 */ s16 floorSwitchReleaseTimer; + /* 0x162 */ s16 disableCrystalSwitchTimer; + /* 0x164 */ s8 eyeTexIndex; + /* 0x165 */ s8 sfxTimer; + /* 0x168 */ s32 crystalAnimTimer; + /* 0x16C */ Color_RGB8 color; + /* 0x16F */ u8 collisionFlags; + /* 0x170 */ s8 floorSwitchPlayerSnapState; + /* 0x171 */ s8 nextSwitchFlagState; + /* 0x172 */ s8 isPlayingCutscene; + /* 0x174 */ ObjSwitchSetupActionFunc setupFunc; union { struct { - /* 0x0178 */ ColliderJntSph colliderJntSph; - /* 0x0198 */ ColliderJntSphElement colliderJntSphElements[1]; + /* 0x178 */ ColliderJntSph colliderJntSph; + /* 0x198 */ ColliderJntSphElement colliderJntSphElements[1]; }; struct { - /* 0x0178 */ ColliderTris colliderTris; - /* 0x0198 */ ColliderTrisElement colliderTrisElements[2]; + /* 0x178 */ ColliderTris colliderTris; + /* 0x198 */ ColliderTrisElement colliderTrisElements[2]; }; }; - /* 0x0250 */ f32 floorSwitchUpScale; - /* 0x0254 */ f32 floorSwitchDownScale; + /* 0x250 */ f32 floorSwitchUpScale; + /* 0x254 */ f32 floorSwitchDownScale; } ObjSwitch; // size = 0x258 extern const ActorInit Obj_Switch_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.h b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.h index 4002f25c4..29654f992 100644 --- a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.h +++ b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.h @@ -8,9 +8,9 @@ struct ObjSwprize; typedef void (*ObjSwprizeActionFunc)(struct ObjSwprize*, PlayState*); typedef struct ObjSwprize { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjSwprizeActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjSwprizeActionFunc actionFunc; + /* 0x148 */ char unk_148[0x4]; } ObjSwprize; // size = 0x14C extern const ActorInit Obj_Swprize_InitVars; 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 2d7f2a836..c653bd25d 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -199,7 +199,7 @@ void ObjSyokudai_Update(Actor* thisx, PlayState* play2) { } else if (player->itemActionParam == PLAYER_AP_STICK) { Vec3f stickTipSeparationVec; - Math_Vec3f_Diff(&player->swordInfo[0].tip, &thisx->world.pos, &stickTipSeparationVec); + Math_Vec3f_Diff(&player->meleeWeaponInfo[0].tip, &thisx->world.pos, &stickTipSeparationVec); stickTipSeparationVec.y -= OBJ_SYOKUDAI_STICK_IGNITION_HEIGHT; if (SQXYZ(stickTipSeparationVec) < SQ(OBJ_SYOKUDAI_STICK_IGNITION_RADIUS)) { interaction = OBJ_SYOKUDAI_INTERACTION_STICK; diff --git a/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.h b/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.h index 0b2251d09..603041d9f 100644 --- a/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.h +++ b/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.h @@ -8,9 +8,9 @@ struct ObjTakarayaWall; typedef void (*ObjTakarayaWallActionFunc)(struct ObjTakarayaWall*, PlayState*); typedef struct ObjTakarayaWall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjTakarayaWallActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x98]; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjTakarayaWallActionFunc actionFunc; + /* 0x148 */ char unk_148[0x98]; } ObjTakarayaWall; // size = 0x1E0 extern const ActorInit Obj_Takaraya_Wall_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.h b/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.h index 9e79cf797..d1220bf33 100644 --- a/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.h +++ b/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.h @@ -8,10 +8,10 @@ struct ObjTaru; typedef void (*ObjTaruActionFunc)(struct ObjTaru*, PlayState*); typedef struct ObjTaru { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; - /* 0x01A8 */ ObjTaruActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x64]; + /* 0x1A8 */ ObjTaruActionFunc actionFunc; + /* 0x1AC */ char unk_1AC[0x4]; } ObjTaru; // size = 0x1B0 extern const ActorInit Obj_Taru_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.h b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.h index 1b3f73fcb..537e7ecc7 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.h +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.h @@ -19,7 +19,7 @@ typedef struct ObjTokeiStepPanel { typedef struct ObjTokeiStep { /* 0x000 */ DynaPolyActor dyna; - /* 0x15c */ ObjTokeiStepFunc actionFunc; + /* 0x15C */ ObjTokeiStepFunc actionFunc; /* 0x160 */ ObjTokeiStepPanel panels[7]; } ObjTokeiStep; // size = 0x1EC diff --git a/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.h b/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.h index 8ddd39eb9..49e47af19 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.h +++ b/src/overlays/actors/ovl_Obj_Tokei_Tobira/z_obj_tokei_tobira.h @@ -8,10 +8,10 @@ struct ObjTokeiTobira; typedef void (*ObjTokeiTobiraActionFunc)(struct ObjTokeiTobira*, PlayState*); typedef struct ObjTokeiTobira { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjTokeiTobiraActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x10]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x18]; + /* 0x15C */ ObjTokeiTobiraActionFunc actionFunc; + /* 0x160 */ char unk_160[0x10]; } ObjTokeiTobira; // size = 0x170 extern const ActorInit Obj_Tokei_Tobira_InitVars; 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 a1c7d3fb3..9b78bc273 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -456,13 +456,13 @@ void ObjTokeidai_TowerOpening_EndCutscene(ObjTokeidai* this, PlayState* play) { gSaveContext.save.cutscene = 0; gSaveContext.nextCutsceneIndex = 0; gSaveContext.respawnFlag = 2; - play->sceneLoadFlag = 0x14; - play->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; - play->unk_1887F = 2; - if (gSaveContext.respawn[RESTART_MODE_RETURN].playerParams == 0xCFF) { - gSaveContext.nextTransition = 0x15; + play->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_RETURN].entranceIndex; + play->transitionType = TRANS_TYPE_02; + if (gSaveContext.respawn[RESPAWN_MODE_RETURN].playerParams == 0xCFF) { + gSaveContext.nextTransitionType = TRANS_TYPE_21; } else { - gSaveContext.nextTransition = 2; + gSaveContext.nextTransitionType = TRANS_TYPE_02; } } this->actionFunc = ObjTokeidai_DoNothing; diff --git a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c index 508da5040..4a71acc95 100644 --- a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c +++ b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c @@ -5,6 +5,7 @@ */ #include "z_obj_toudai.h" +#include "objects/object_f53_obj/object_f53_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,6 @@ void ObjToudai_Destroy(Actor* thisx, PlayState* play); void ObjToudai_Update(Actor* thisx, PlayState* play); void ObjToudai_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Obj_Toudai_InitVars = { ACTOR_OBJ_TOUDAI, ACTORCAT_PROP, @@ -28,21 +28,102 @@ const ActorInit Obj_Toudai_InitVars = { (ActorFunc)ObjToudai_Draw, }; -#endif +#include "assets/overlays/ovl_Obj_Toudai/ovl_Obj_Toudai.c" -extern UNK_TYPE D_060023B0; -extern UNK_TYPE D_060024E8; +void func_80A33B00(ObjToudai* this, PlayState* play) { + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toudai/func_80A33B00.s") + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toudai/func_80A33BB4.s") + func_8012C28C(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toudai/func_80A342F4.s") + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_f53_obj_DL_0024E8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toudai/ObjToudai_Init.s") + CLOSE_DISPS(play->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toudai/ObjToudai_Destroy.s") +void func_80A33BB4(ObjToudai* this, PlayState* play) { + u8 sp57; + u8 sp56; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toudai/ObjToudai_Update.s") + this->unk_22C += 1.8f; + this->unk_230 += 0.6f; + sp57 = this->unk_22C; + sp56 = this->unk_230; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toudai/ObjToudai_Draw.s") + this->unk_228 = CLAMP(this->unk_228, 0.0f, 1.0f); + + for (i = 0; i < ARRAY_COUNT(ovl_Obj_Toudai_Vtx_D_80A34590); i++) { + this->unk_148[i].v.cn[3] = ovl_Obj_Toudai_Vtx_D_80A34590[i].v.cn[3] * this->unk_228; + } + + if (this->unk_228 > 0.0f) { + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, sp57, 0x20, 0x80, 1, 0, sp56, 0x20, 0x20)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(this->unk_148)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_f53_obj_DL_0023B0); + + CLOSE_DISPS(play->state.gfxCtx); + } +} + +u8 func_80A342F4(s16 arg0) { + u8 var_v1 = 0; + s16 minutes = TIME_TO_MINUTES_F(gSaveContext.save.time); + s32 hours = minutes / 60; + + if (hours >= 17) { + if ((hours == 17) && ((minutes % 60) < arg0)) { + return var_v1; + } + var_v1 = 2; + } else if (hours < 6) { + if ((hours == 5) && ((minutes % 60) < arg0)) { + return var_v1; + } + var_v1 = 1; + } + return var_v1; +} + +void ObjToudai_Init(Actor* thisx, PlayState* play) { + ObjToudai* this = THIS; + + Lib_MemCpy(this->unk_148, &ovl_Obj_Toudai_Vtx_D_80A34590, sizeof(ovl_Obj_Toudai_Vtx_D_80A34590)); +} + +void ObjToudai_Destroy(Actor* thisx, PlayState* play) { +} + +void ObjToudai_Update(Actor* thisx, PlayState* play) { + ObjToudai* this = THIS; + u8 temp_v0 = func_80A342F4(this->unk_238); + + if (temp_v0 != this->unk_236) { + this->unk_236 = temp_v0; + this->unk_238 = Rand_S16Offset(0, 50); + } + + Math_ApproachF(&this->unk_228, (this->unk_236 == 0) ? 0.0f : 1.0f, 0.01f, 1000.0f); + this->unk_234 += 100; + thisx->shape.rot.y = (s16)(Math_SinS(this->unk_234) * 16000.0f) + thisx->world.rot.y; +} + +void ObjToudai_Draw(Actor* thisx, PlayState* play) { + ObjToudai* this = THIS; + + func_80A33B00(this, play); + func_80A33BB4(this, play); +} diff --git a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.h b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.h index ca28dc786..c1af4d733 100644 --- a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.h +++ b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.h @@ -7,8 +7,16 @@ struct ObjToudai; typedef struct ObjToudai { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xFC]; -} ObjToudai; // size = 0x240 + /* 0x144 */ UNK_TYPE1 pad144[4]; + /* 0x148 */ Vtx unk_148[14]; + /* 0x228 */ f32 unk_228; + /* 0x22C */ f32 unk_22C; + /* 0x230 */ f32 unk_230; + /* 0x234 */ s16 unk_234; + /* 0x236 */ u8 unk_236; + /* 0x238 */ s16 unk_238; + /* 0x23A */ UNK_TYPE1 pad23A[6]; +} ObjToudai;// size = 0x240 extern const ActorInit Obj_Toudai_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 1426849f7..ef55e5ab7 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c @@ -16,9 +16,9 @@ void ObjTree_Destroy(Actor* thisx, PlayState* play); void ObjTree_Update(Actor* thisx, PlayState* play); void ObjTree_Draw(Actor* thisx, PlayState* play); -void ObTree_DoNothing(ObjTree* this, PlayState* play); -void ObTree_SetupDoNothing(ObjTree* this); -void ObTree_Sway(ObjTree* this, PlayState* play); +void ObjTree_DoNothing(ObjTree* this, PlayState* play); +void ObjTree_SetupDoNothing(ObjTree* this); +void ObjTree_Sway(ObjTree* this, PlayState* play); const ActorInit Obj_Tree_InitVars = { ACTOR_OBJ_TREE, @@ -115,7 +115,7 @@ void ObjTree_Init(Actor* thisx, PlayState* play) { this->swayAmplitude = 0.0f; this->swayAngle = 0; this->swayVelocity = 0; - ObTree_SetupDoNothing(this); + ObjTree_SetupDoNothing(this); } void ObjTree_Destroy(Actor* thisx, PlayState* play) { @@ -130,24 +130,24 @@ void ObjTree_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void ObTree_SetupDoNothing(ObjTree* this) { - this->actionFunc = ObTree_DoNothing; +void ObjTree_SetupDoNothing(ObjTree* this) { + this->actionFunc = ObjTree_DoNothing; } -void ObTree_DoNothing(ObjTree* this, PlayState* play) { +void ObjTree_DoNothing(ObjTree* this, PlayState* play) { } -void ObTree_SetupSway(ObjTree* this) { +void ObjTree_SetupSway(ObjTree* this) { this->timer = 0; this->swayAmplitude = 546.0f; this->swayVelocity = 35 * 0x10000 / 360; Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_TREE_SWING); - this->actionFunc = ObTree_Sway; + this->actionFunc = ObjTree_Sway; } -void ObTree_Sway(ObjTree* this, PlayState* play) { +void ObjTree_Sway(ObjTree* this, PlayState* play) { if (this->timer > 80) { - ObTree_SetupDoNothing(this); + ObjTree_SetupDoNothing(this); return; } @@ -159,7 +159,7 @@ void ObTree_Sway(ObjTree* this, PlayState* play) { this->timer++; } -void ObTree_UpdateCollision(ObjTree* this, PlayState* play) { +void ObjTree_UpdateCollision(ObjTree* this, PlayState* play) { Collider_UpdateCylinder(&this->dyna.actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); @@ -167,7 +167,7 @@ void ObTree_UpdateCollision(ObjTree* this, PlayState* play) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if (this->dyna.actor.home.rot.y == 1) { this->dyna.actor.home.rot.y = 0; - ObTree_SetupSway(this); + ObjTree_SetupSway(this); } } } @@ -176,7 +176,7 @@ void ObjTree_Update(Actor* thisx, PlayState* play) { ObjTree* this = THIS; this->actionFunc(this, play); - ObTree_UpdateCollision(this, play); + ObjTree_UpdateCollision(this, play); } void ObjTree_Draw(Actor* thisx, PlayState* play) { 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 d4bc4d34f..779ea2a5e 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -144,7 +144,7 @@ void ObjTsubo_SpawnGoldSkulltula(ObjTsubo* this, PlayState* play, s32 arg2) { if (func_809275C0(this, play)) { params = (OBJ_TSUBO_P001F(&this->actor) << 2) | 0xFF01; child = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_SW, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, (u32)Rand_Next() >> 0x10, 0, params); + this->actor.world.pos.z, 0, Rand_Next() >> 0x10, 0, params); if (child != NULL) { child->parent = &this->actor; child->velocity.y = 0.0f; @@ -507,7 +507,7 @@ void func_809289E4(ObjTsubo* this, PlayState* play) { s16 yawDiff = this->actor.yawTowardsPlayer - GET_PLAYER(play)->actor.world.rot.y; s32 absYawDiff = ABS_ALT(yawDiff); - if (absYawDiff > DEGF_TO_BINANG(120.0f)) { + if (absYawDiff > (0x10000 / 3)) { Actor_PickUp(&this->actor, play, 0, 36.0f, 30.0f); } } diff --git a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h index a12c0b588..28233c911 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h @@ -18,17 +18,17 @@ typedef void (*ObjTsuboUnkFunc)(struct ObjTsubo*, PlayState*); #define OBJ_TSUBO_ZROT(thisx) ((thisx)->home.rot.z) typedef struct ObjTsubo { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjTsuboActionFunc actionFunc; - /* 0x0148 */ ColliderCylinder cylinderCollider; - /* 0x0194 */ s8 unk_194; - /* 0x0195 */ s8 unk_195; - /* 0x0196 */ s8 homeRoom; - /* 0x0197 */ s8 unk_197; - /* 0x0198 */ s8 unk_198; - /* 0x0199 */ s8 objBankIndex; - /* 0x019A */ s8 unk_19A; - /* 0x019B */ u8 unk_19B; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjTsuboActionFunc actionFunc; + /* 0x148 */ ColliderCylinder cylinderCollider; + /* 0x194 */ s8 unk_194; + /* 0x195 */ s8 unk_195; + /* 0x196 */ s8 homeRoom; + /* 0x197 */ s8 unk_197; + /* 0x198 */ s8 unk_198; + /* 0x199 */ s8 objBankIndex; + /* 0x19A */ s8 unk_19A; + /* 0x19B */ u8 unk_19B; } ObjTsubo; // size = 0x19C extern const ActorInit Obj_Tsubo_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Um/z_obj_um.h b/src/overlays/actors/ovl_Obj_Um/z_obj_um.h index b421187e4..d343d3a51 100644 --- a/src/overlays/actors/ovl_Obj_Um/z_obj_um.h +++ b/src/overlays/actors/ovl_Obj_Um/z_obj_um.h @@ -8,10 +8,10 @@ struct ObjUm; typedef void (*ObjUmActionFunc)(struct ObjUm*, PlayState*); typedef struct ObjUm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjUmActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x384]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x18]; + /* 0x15C */ ObjUmActionFunc actionFunc; + /* 0x160 */ char unk_160[0x384]; } ObjUm; // size = 0x4E4 extern const ActorInit Obj_Um_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h index 351bc93b1..7c4cdd8a5 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h @@ -8,10 +8,10 @@ struct ObjUsiyane; typedef void (*ObjUsiyaneActionFunc)(struct ObjUsiyane*, PlayState*); typedef struct ObjUsiyane { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjUsiyaneActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x5E8]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x18]; + /* 0x15C */ ObjUsiyaneActionFunc actionFunc; + /* 0x160 */ char unk_160[0x5E8]; } ObjUsiyane; // size = 0x748 extern const ActorInit Obj_Usiyane_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c index 93400d4a8..6740cc684 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -207,7 +207,7 @@ s32 func_80A3C8D8(ObjVspinyroll* this, PlayState* play, Vec3f* arg2, s32 arg3) { spB4.y += this->dyna.actor.world.pos.y; spB4.z += this->dyna.actor.world.pos.z; - EffectSsHitMark_SpawnFixedScale(play, 3, &spB4); + EffectSsHitmark_SpawnFixedScale(play, 3, &spB4); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); } diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h index 11913355d..38dee86fb 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h @@ -28,19 +28,19 @@ typedef struct { } ObjVspinyrollStruct3; // size = 0x1E8 typedef struct ObjVspinyroll { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ ObjVspinyrollStruct3 unk_1A8; - /* 0x0390 */ ObjVspinyrollActionFunc actionFunc; - /* 0x0394 */ f32 unk_394; - /* 0x0398 */ s32 unk_398; - /* 0x039C */ Vec3f unk_39C[2]; - /* 0x03B4 */ Vec3f unk_3B4; - /* 0x03C0 */ s16 unk_3C0; - /* 0x03C2 */ s16 unk_3C2; - /* 0x03C4 */ s16 unk_3C4; - /* 0x03C6 */ s16 unk_3C6; - /* 0x03C8 */ s16 unk_3C8; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ ObjVspinyrollStruct3 unk_1A8; + /* 0x390 */ ObjVspinyrollActionFunc actionFunc; + /* 0x394 */ f32 unk_394; + /* 0x398 */ s32 unk_398; + /* 0x39C */ Vec3f unk_39C[2]; + /* 0x3B4 */ Vec3f unk_3B4; + /* 0x3C0 */ s16 unk_3C0; + /* 0x3C2 */ s16 unk_3C2; + /* 0x3C4 */ s16 unk_3C4; + /* 0x3C6 */ s16 unk_3C6; + /* 0x3C8 */ s16 unk_3C8; } ObjVspinyroll; // size = 0x3CC extern const ActorInit Obj_Vspinyroll_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index 03e1486d8..ea9b35f5c 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, PlayState* play) { Collider_InitAndSetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); Actor_SetFocus(&this->dyna.actor, 40.0f); - if (!OBJ_WARPSTONE_IS_ACTIVATED(OBJ_WARPSTONE_GET_ID(this))) { + if (!OBJ_WARPSTONE_IS_ACTIVATED(OBJ_WARPSTONE_GET_ID(&this->dyna.actor))) { ObjWarpstone_SetupAction(this, ObjWarpstone_ClosedIdle); } else { ObjWarpstone_SetupAction(this, ObjWarpstone_OpenedIdle); @@ -110,7 +110,7 @@ s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, PlayState* play) { s32 ObjWarpstone_PlayOpeningCutscene(ObjWarpstone* this, PlayState* play) { if (this->openingCSTimer++ >= OBJ_WARPSTONE_TIMER_ACTIVATE_THRESHOLD) { ActorCutscene_Stop(this->dyna.actor.cutscene); - Sram_ActivateOwl(OBJ_WARPSTONE_GET_ID(this)); + Sram_ActivateOwl(OBJ_WARPSTONE_GET_ID(&this->dyna.actor)); ObjWarpstone_SetupAction(this, ObjWarpstone_OpenedIdle); } else if (this->openingCSTimer < OBJ_WARPSTONE_TIMER_OPEN_THRESHOLD) { Math_StepToF(&this->dyna.actor.velocity.x, 0.01f, 0.001f); @@ -138,13 +138,13 @@ void ObjWarpstone_Update(Actor* thisx, PlayState* play) { if (this->isTalking) { if (Actor_TextboxIsClosing(&this->dyna.actor, play)) { this->isTalking = false; - } else if ((Message_GetState(&play->msgCtx) == 4) && Message_ShouldAdvance(play)) { + } else if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { if (play->msgCtx.choiceIndex != 0) { func_8019F208(); play->msgCtx.msgMode = 0x4D; play->msgCtx.unk120D6 = 0; play->msgCtx.unk120D4 = 0; - gSaveContext.save.owlSaveLocation = OBJ_WARPSTONE_GET_ID(this); + gSaveContext.save.owlSaveLocation = OBJ_WARPSTONE_GET_ID(&this->dyna.actor); } else { func_801477B4(play); } diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h index ace6e8896..8d39deef0 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h @@ -28,7 +28,7 @@ typedef struct ObjWarpstone { extern const ActorInit Obj_Warpstone_InitVars; -#define OBJ_WARPSTONE_GET_ID(this) ((u16)(this->dyna.actor.params & 0xF)) -#define OBJ_WARPSTONE_IS_ACTIVATED(owlId) (((void)0, gSaveContext.save.playerData.owlActivationFlags) & (u16)gBitFlags[owlId]) +#define OBJ_WARPSTONE_GET_ID(thisx) ((u16)((thisx)->params & 0xF)) +#define OBJ_WARPSTONE_IS_ACTIVATED(owlId) (((void)0, gSaveContext.save.playerData.owlActivationFlags) & (u16)gBitFlags[(owlId)]) #endif // Z_OBJ_WARPSTONE_H diff --git a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c index bd702c693..5a733ecba 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c @@ -63,20 +63,20 @@ void func_808A7A5C(ObjWturn* this, PlayState* play) { void func_808A7AAC(ObjWturn* this, PlayState* play) { Player* player = GET_PLAYER(play); - Vec3f eye; - Vec3f at; + Vec3f subCamEye; + Vec3f subCamAt; ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); func_8016566C(140); - this->camId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); func_800B7298(play, &this->actor, 21); - at.x = player->actor.focus.pos.x; - at.z = player->actor.focus.pos.z; - at.y = player->actor.focus.pos.y; - eye.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + at.x; - eye.z = (Math_CosS(this->actor.shape.rot.y) * 150.0f) + at.z; - eye.y = at.y + 4.0f; - Play_CameraSetAtEye(play, this->camId, &at, &eye); + subCamAt.x = player->actor.focus.pos.x; + subCamAt.z = player->actor.focus.pos.z; + subCamAt.y = player->actor.focus.pos.y; + subCamEye.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + subCamAt.x; + subCamEye.z = (Math_CosS(this->actor.shape.rot.y) * 150.0f) + subCamAt.z; + subCamEye.y = subCamAt.y + 4.0f; + Play_CameraSetAtEye(play, this->subCamId, &subCamAt, &subCamEye); this->actionFunc = func_808A7BA0; } @@ -85,7 +85,7 @@ void func_808A7BA0(ObjWturn* this, PlayState* play) { func_808A7C04(this, play); } func_800B8FE8(&this->actor, NA_SE_EV_EARTHQUAKE - SFX_FLAG); - Play_CameraSetRoll(play, this->camId, this->actor.shape.rot.z); + Play_CameraSetRoll(play, this->subCamId, this->actor.shape.rot.z); } void func_808A7C04(ObjWturn* this, PlayState* play) { @@ -101,23 +101,23 @@ void func_808A7C04(ObjWturn* this, PlayState* play) { } void func_808A7C78(ObjWturn* this, PlayState* play) { - static Vec3f D_808A7DC0 = { 0.0f, -1.0f, 0.0f }; - Camera* camera = Play_GetCamera(play, this->camId); + static Vec3f sSubCamUp = { 0.0f, -1.0f, 0.0f }; + Camera* subCam = Play_GetCamera(play, this->subCamId); Player* player = GET_PLAYER(play); this->unk_14A++; player->actor.world.pos.y = this->actor.world.pos.y + this->unk_14A * 4.0f; - Play_CameraSetAtEyeUp(play, this->camId, &player->actor.focus.pos, &camera->eye, &D_808A7DC0); + Play_CameraSetAtEyeUp(play, this->subCamId, &player->actor.focus.pos, &subCam->eye, &sSubCamUp); if (this->unk_14A == 1) { - play->unk_1887F = 0x40; - gSaveContext.nextTransition = 3; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_03; gSaveContext.nextCutsceneIndex = 0; if (play->sceneNum == 0x58) { play->nextEntranceIndex = 0xAC00; } else { play->nextEntranceIndex = 0xAA10; } - play->sceneLoadFlag = 0x14; + play->transitionTrigger = TRANS_TRIGGER_START; } } diff --git a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h index 9b498cf4b..9b8674f59 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h @@ -8,10 +8,10 @@ struct ObjWturn; typedef void (*ObjWturnActionFunc)(struct ObjWturn*, PlayState*); typedef struct ObjWturn { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ObjWturnActionFunc actionFunc; - /* 0x0148 */ s16 camId; - /* 0x014A */ s16 unk_14A; + /* 0x000 */ Actor actor; + /* 0x144 */ ObjWturnActionFunc actionFunc; + /* 0x148 */ s16 subCamId; + /* 0x14A */ s16 unk_14A; } ObjWturn; // size = 0x14C extern const ActorInit Obj_Wturn_InitVars; 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 f0f1160da..0b4e2014e 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -512,7 +512,7 @@ void func_808DD3C8(Actor* thisx, PlayState* play2) { f32 temp_f2; f32 tempf; - if ((play->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100) || ((u8)play->envCtx.unk_E2 == 0)) { + if ((play->cameraPtrs[CAM_ID_MAIN]->stateFlags & CAM_STATE_UNDERWATER) || ((u8)play->envCtx.unk_E2 == 0)) { return; } @@ -599,7 +599,7 @@ void func_808DD970(Actor* thisx, PlayState* play2) { phi_f26 = CLAMP_MAX(phi_f26, 1.0f); - if (!(play->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100) || (phi_f26 == 0.0f)) { + if (!(play->cameraPtrs[CAM_ID_MAIN]->stateFlags & CAM_STATE_UNDERWATER) || (phi_f26 == 0.0f)) { return; } } @@ -644,7 +644,7 @@ f32 func_808DDE74(void) { } #ifdef NON_MATCHING -// play->envCtx.unk_F2[1] needs to be laoded into s0 and then copied to s7 +// play->envCtx.unk_F2[1] needs to be loaded into s0 and then copied to s7 void func_808DDE9C(Actor* thisx, PlayState* play2) { PlayState* play = play2; ObjectKankyo* this = THIS; diff --git a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.h b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.h index e7872dd8c..922b1f89b 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.h +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.h @@ -8,9 +8,9 @@ struct OceffSpot; typedef void (*OceffSpotActionFunc)(struct OceffSpot*, PlayState*); typedef struct OceffSpot { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x30]; - /* 0x0174 */ OceffSpotActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x30]; + /* 0x174 */ OceffSpotActionFunc actionFunc; } OceffSpot; // size = 0x178 extern const ActorInit Oceff_Spot_InitVars; diff --git a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.h b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.h index a170215ba..460ede844 100644 --- a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.h +++ b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.h @@ -8,9 +8,9 @@ struct OceffStorm; typedef void (*OceffStormActionFunc)(struct OceffStorm*, PlayState*); typedef struct OceffStorm { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8]; - /* 0x014C */ OceffStormActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x8]; + /* 0x14C */ OceffStormActionFunc actionFunc; } OceffStorm; // size = 0x150 extern const ActorInit Oceff_Storm_InitVars; diff --git a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.h b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.h index 2005c9287..cb25f1553 100644 --- a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.h +++ b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.h @@ -8,10 +8,10 @@ struct ShotSun; typedef void (*ShotSunActionFunc)(struct ShotSun*, PlayState*); typedef struct ShotSun { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; - /* 0x0190 */ ShotSunActionFunc actionFunc; - /* 0x0194 */ char unk_194[0xC]; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x4C]; + /* 0x190 */ ShotSunActionFunc actionFunc; + /* 0x194 */ char unk_194[0xC]; } ShotSun; // size = 0x1A0 extern const ActorInit Shot_Sun_InitVars; 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 6b5e13953..c79697e97 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c @@ -45,7 +45,7 @@ void TGSw_ActionDecider(TGSw* this, PlayState* play) { } unk1F4 = play->actorCtx.unk1F4; if (unk1F4 == 2 || unk1F4 == 0) { - this->actionFunc = &TGSw_ActionExecuteOneShot; + this->actionFunc = TGSw_ActionExecuteOneShot; } } } @@ -89,16 +89,17 @@ void TGSw_ActionExecuteOneShot(TGSw* this, PlayState* play) { void TGSw_Init(Actor* thisx, PlayState* play) { TGSw* this = THIS; + this->actor.cutscene = this->actor.world.rot.z; - this->actionFunc = &TGSw_ActionDecider; + this->actionFunc = TGSw_ActionDecider; } void TGSw_Destroy(Actor* thisx, PlayState* play) { - ; } void TGSw_Update(Actor* thisx, PlayState* play) { TGSw* this = THIS; + this->actionFunc(this, play); } diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c b/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c index 65b8a76ac..7bc2d6966 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c @@ -1,27 +1,59 @@ /* * File: z_eff_ss_g_fire.c * Overlay: ovl_Effect_Ss_G_Fire - * Description: + * Description: Flame Footprints */ #include "z_eff_ss_g_fire.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define PARAMS ((EffectSsGFireInitParams*)initParamsx) -s32 EffectSsGFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsGFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsGFire_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsGFire_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_G_Fire_InitVars = { EFFECT_SS_G_FIRE, EffectSsGFire_Init, }; -#endif +u32 EffectSsGFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsGFireInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Fire/EffectSsGFire_Init.s") + Math_Vec3f_Copy(&this->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&this->accel, &gZeroVec3f); + Math_Vec3f_Copy(&this->pos, &initParams->pos); + this->draw = EffectSsGFire_Draw; + this->update = EffectSsGFire_Update; + this->gfx = gEffFireFootprintDL; + this->life = 8; + this->flags = 0; + this->rgScale = 200; + this->rgTexIndex = 0; + this->rgTexIndexStep = 50; + this->rgPrimColorR = 255; + this->rgPrimColorG = 220; + this->rgPrimColorB = 80; + this->rgPrimColorA = 255; + this->rgEnvColorR = 130; + this->rgEnvColorG = 30; + this->rgEnvColorB = 0; + this->rgEnvColorA = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Fire/EffectSsGFire_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Fire/EffectSsGFire_Update.s") +void EffectSsGFire_Draw(PlayState* play, u32 index, EffectSs* this) { + TexturePtr fireFootprintTextures[] = { + gEffFireFootprint1Tex, gEffFireFootprint2Tex, gEffFireFootprint3Tex, gEffFireFootprint4Tex, + gEffFireFootprint5Tex, gEffFireFootprint6Tex, gEffFireFootprint7Tex, gEffFireFootprint8Tex, + }; + s16 texIndex = (this->rgTexIndex / 100) % 7; + + EffectSs_DrawGEffect(play, this, fireFootprintTextures[texIndex]); +} + +void EffectSsGFire_Update(PlayState* play, u32 index, EffectSs* this) { + this->rgTexIndex += this->rgTexIndexStep; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c index 79cb97234..b820d8168 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c @@ -1,29 +1,138 @@ /* * File: z_eff_ss_g_ripple.c * Overlay: ovl_Effect_Ss_G_Ripple - * Description: + * Description: Water Ripple */ #include "z_eff_ss_g_ripple.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rWaterBoxNum regs[0] +#define rRadius regs[1] +#define rRadiusMax regs[2] +#define rPrimColorR regs[3] +#define rPrimColorG regs[4] +#define rPrimColorB regs[5] +#define rPrimColorA regs[6] +#define rEnvColorR regs[7] +#define rEnvColorG regs[8] +#define rEnvColorB regs[9] +#define rEnvColorA regs[10] +#define rLifespan regs[11] +#define rBgId regs[12] #define PARAMS ((EffectSsGRippleInitParams*)initParamsx) -s32 EffectSsGRipple_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsGRipple_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsGRipple_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsGRipple_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_G_Ripple_InitVars = { EFFECT_SS_G_RIPPLE, EffectSsGRipple_Init, }; -#endif +u32 EffectSsGRipple_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsGRippleInitParams* initParams = PARAMS; + WaterBox* waterBox = NULL; + s32 pad; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Ripple/EffectSsGRipple_Init.s") + Math_Vec3f_Copy(&this->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&this->accel, &gZeroVec3f); + Math_Vec3f_Copy(&this->pos, &initParams->pos); + this->gfx = gEffWaterRippleDL; + this->life = initParams->life + 20; + this->flags = 0; + this->draw = EffectSsGRipple_Draw; + this->update = EffectSsGRipple_Update; + this->rRadius = initParams->radius; + this->rRadiusMax = initParams->radiusMax; + this->rLifespan = initParams->life; + this->rPrimColorR = 255; + this->rPrimColorG = 255; + this->rPrimColorB = 255; + this->rPrimColorA = 255; + this->rEnvColorR = 255; + this->rEnvColorG = 255; + this->rEnvColorB = 255; + this->rEnvColorA = 255; + this->rWaterBoxNum = WaterBox_GetSurface2(play, &play->colCtx, &initParams->pos, 3.0f, &waterBox, &bgId); + this->rBgId = bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Ripple/func_80979C38.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Ripple/EffectSsGRipple_Draw.s") +void EffectSsGRipple_DrawRipple(PlayState* play2, EffectSs* this, TexturePtr tex) { + PlayState* play = play2; + f32 radius; + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + Mtx* mtx; + f32 yPos; + CollisionHeader* colHeader; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Ripple/EffectSsGRipple_Update.s") + OPEN_DISPS(gfxCtx); + + radius = this->rRadius * 0.0025f; + colHeader = BgCheck_GetCollisionHeader(&play->colCtx, this->rBgId); + + if ((this->rWaterBoxNum != -1) && (colHeader != NULL) && (this->rWaterBoxNum < colHeader->numWaterBoxes)) { + yPos = func_800CA568(&play->colCtx, this->rWaterBoxNum, this->rBgId); + } else { + yPos = this->pos.y; + } + + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, yPos, this->pos.z); + SkinMatrix_SetScale(&mfScale, radius, radius, radius); + SkinMatrix_MtxFMtxFMult(&mfTrans, &mfScale, &mfResult); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C974(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + this->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsGRipple_Draw(PlayState* play, u32 index, EffectSs* this) { + if (this->rLifespan == 0) { + EffectSsGRipple_DrawRipple(play, this, gEffWaterRippleTex); + } +} + +void EffectSsGRipple_Update(PlayState* play, u32 index, EffectSs* this) { + f32 radius; + f32 primAlpha; + f32 envAlpha; + WaterBox* waterBox; + s32 bgId; + + this->rWaterBoxNum = WaterBox_GetSurface2(play, &play->colCtx, &this->pos, 3.0f, &waterBox, &bgId); + this->rBgId = bgId; + + if (DECR(this->rLifespan) == 0) { + radius = this->rRadius; + Math_SmoothStepToF(&radius, this->rRadiusMax, 0.2f, 30.0f, 1.0f); + this->rRadius = radius; + + primAlpha = this->rPrimColorA; + envAlpha = this->rEnvColorA; + + Math_SmoothStepToF(&primAlpha, 0.0f, 0.2f, 15.0f, 7.0f); + Math_SmoothStepToF(&envAlpha, 0.0f, 0.2f, 15.0f, 7.0f); + + this->rPrimColorA = primAlpha; + this->rEnvColorA = envAlpha; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c index d465e082e..260541b51 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c @@ -1,30 +1,145 @@ /* * File: z_eff_ss_g_spk.c * Overlay: ovl_Effect_Ss_G_Spk - * Description: + * Description: Sparks */ #include "z_eff_ss_g_spk.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rPrimColorR regs[0] +#define rPrimColorG regs[1] +#define rPrimColorB regs[2] +#define rPrimColorA regs[3] +#define rEnvColorR regs[4] +#define rEnvColorG regs[5] +#define rEnvColorB regs[6] +#define rEnvColorA regs[7] +#define rTexIndex regs[8] +#define rScale regs[9] +#define rScaleStep regs[10] #define PARAMS ((EffectSsGSpkInitParams*)initParamsx) -s32 EffectSsGSpk_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); -void func_80978F40(PlayState* play, u32 index, EffectSs* this); -void func_80979068(PlayState* play, u32 index, EffectSs* this); +u32 EffectSsGSpk_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsGSpk_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsGSpk_UpdateNoAccel(PlayState* play, u32 index, EffectSs* this); void EffectSsGSpk_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_G_Spk_InitVars = { EFFECT_SS_G_SPK, EffectSsGSpk_Init, }; -#endif +static TexturePtr sSparkTextures[] = { + gElectricSpark1Tex, + gElectricSpark2Tex, + gElectricSpark3Tex, + gElectricSpark4Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Spk/EffectSsGSpk_Init.s") +u32 EffectSsGSpk_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsGSpkInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Spk/EffectSsGSpk_Draw.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->gfx = gEffSparkDL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Spk/func_80978F40.s") + if (initParams->updateMode == GSPK_UPDATEMODE_NORMAL) { + this->life = 10; + this->vec.x = initParams->pos.x - initParams->actor->world.pos.x; + this->vec.y = initParams->pos.y - initParams->actor->world.pos.y; + this->vec.z = initParams->pos.z - initParams->actor->world.pos.z; + this->update = EffectSsGSpk_Update; + } else { + this->life = 5; + this->update = EffectSsGSpk_UpdateNoAccel; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Spk/func_80979068.s") + this->draw = EffectSsGSpk_Draw; + this->rPrimColorR = initParams->primColor.r; + this->rPrimColorG = initParams->primColor.g; + this->rPrimColorB = initParams->primColor.b; + this->rPrimColorA = initParams->primColor.a; + this->rEnvColorR = initParams->envColor.r; + this->rEnvColorG = initParams->envColor.g; + this->rEnvColorB = initParams->envColor.b; + this->rEnvColorA = initParams->envColor.a; + this->rTexIndex = 0; + this->rScale = initParams->scale; + this->rScaleStep = initParams->scaleStep; + this->actor = initParams->actor; + + return 1; +} + +void EffectSsGSpk_Draw(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + MtxF mfTransBillboard; + Mtx* mtx; + f32 scale; + GraphicsContext* gfxCtx = play->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + scale = this->rScale * 0.0025f; + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sSparkTextures[this->rTexIndex])); + func_8012C974(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsGSpk_Update(PlayState* play, u32 index, EffectSs* this) { + this->accel.x = (Rand_ZeroOne() - 0.5f) * 3.0f; + this->accel.z = (Rand_ZeroOne() - 0.5f) * 3.0f; + + if (this->actor != NULL) { + if ((this->actor->category == ACTORCAT_EXPLOSIVES) && (this->actor->update != NULL)) { + this->pos.x = this->actor->world.pos.x + this->vec.x; + this->pos.y = this->actor->world.pos.y + this->vec.y; + this->pos.z = this->actor->world.pos.z + this->vec.z; + if (this->actor->depthInWater >= 20.0f) { + this->life = 0; + } + } + } + + this->vec.x += this->accel.x; + this->vec.z += this->accel.z; + + this->rTexIndex++; + this->rTexIndex &= 3; + this->rScale += this->rScaleStep; +} + +// this update mode is unused in the original game +// with this update mode, the sparks dont move randomly in the xz plane, appearing to be on top of each other +void EffectSsGSpk_UpdateNoAccel(PlayState* play, u32 index, EffectSs* this) { + if (this->actor != NULL) { + if ((this->actor->category == ACTORCAT_EXPLOSIVES) && (this->actor->update != NULL)) { + this->pos.x += (Math_SinS(this->actor->world.rot.y) * this->actor->speedXZ); + this->pos.z += (Math_CosS(this->actor->world.rot.y) * this->actor->speedXZ); + } + } + + this->rTexIndex++; + this->rTexIndex &= 3; + this->rScale += this->rScaleStep; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.h b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.h index 1d970d3d2..c44bb9168 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.h +++ b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.h @@ -3,6 +3,11 @@ #include "global.h" +typedef enum EffectSsGSpkUpdatemode { + /* 0 */ GSPK_UPDATEMODE_NORMAL, + /* 1 */ GSPK_UPDATEMODE_NO_ACCEL +} EffectSsGSpkUpdatemode; + typedef struct { /* 0x00 */ Actor* actor; /* 0x04 */ Vec3f pos; diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c index 210ede8f6..78bee9835 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c @@ -5,23 +5,135 @@ */ #include "z_eff_ss_g_splash.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +//! @bug the reuse of regs[11] means that EffectSs_DrawGEffect will treat the type as an object bank index +// this ends up having no effect because the texture provided does not use segment 6 +#define rType regs[11] #define PARAMS ((EffectSsGSplashInitParams*)initParamsx) -s32 EffectSsGSplash_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsGSplash_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsGSplash_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsGSplash_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_G_Splash_InitVars = { EFFECT_SS_G_SPLASH, EffectSsGSplash_Init, }; -#endif +static TexturePtr waterSplashTextures[] = { + gEffWaterSplash1Tex, gEffWaterSplash2Tex, gEffWaterSplash3Tex, gEffWaterSplash4Tex, + gEffWaterSplash5Tex, gEffWaterSplash6Tex, gEffWaterSplash7Tex, gEffWaterSplash8Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Splash/EffectSsGSplash_Init.s") +u32 EffectSsGSplash_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsGSplashInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Splash/EffectSsGSplash_Draw.s") + Math_Vec3f_Copy(&this->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&this->accel, &gZeroVec3f); + Math_Vec3f_Copy(&this->pos, &initParams->pos); + this->draw = EffectSsGSplash_Draw; + this->update = EffectSsGSplash_Update; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_G_Splash/EffectSsGSplash_Update.s") + if (initParams->scale == 0) { + initParams->scale = 600; + } + + this->gfx = gEffWaterSplashDL; + this->life = 8; + this->rgScale = initParams->scale; + this->rgTexIndex = 0; + this->rgTexIndexStep = 100; + + if (initParams->customColor) { + this->rgPrimColorR = initParams->primColor.r; + this->rgPrimColorG = initParams->primColor.g; + this->rgPrimColorB = initParams->primColor.b; + this->rgPrimColorA = initParams->primColor.a; + this->rgEnvColorR = initParams->envColor.r; + this->rgEnvColorG = initParams->envColor.g; + this->rgEnvColorB = initParams->envColor.b; + this->rgEnvColorA = initParams->envColor.a; + this->rType = initParams->type; + } else { + switch (initParams->type) { + case 0: + this->rgPrimColorR = 255; + this->rgPrimColorG = 255; + this->rgPrimColorB = 255; + this->rgPrimColorA = 200; + this->rgEnvColorR = 255; + this->rgEnvColorG = 255; + this->rgEnvColorB = 255; + this->rgEnvColorA = 200; + this->rType = 0; + break; + case 1: + this->rgPrimColorR = 255; + this->rgPrimColorG = 255; + this->rgPrimColorB = 255; + this->rgPrimColorA = 255; + this->rgEnvColorR = 255; + this->rgEnvColorG = 255; + this->rgEnvColorB = 255; + this->rgEnvColorA = 255; + this->rType = 1; + break; + case 2: + this->rgPrimColorR = 255; + this->rgPrimColorG = 255; + this->rgPrimColorB = 255; + this->rgPrimColorA = 200; + this->rgEnvColorR = 255; + this->rgEnvColorG = 255; + this->rgEnvColorB = 255; + this->rgEnvColorA = 200; + this->rType = 2; + break; + } + } + return 1; +} + +void EffectSsGSplash_Draw(PlayState* play, u32 index, EffectSs* this) { + s16 texIndex; + + switch (this->rType) { + case 0: + texIndex = this->rgTexIndex / 100; + if (texIndex > 7) { + texIndex = 7; + } + EffectSs_DrawGEffect(play, this, waterSplashTextures[texIndex]); + break; + + case 1: + texIndex = this->rgTexIndex / 100; + if (texIndex > 7) { + texIndex = 7; + } + EffectSs_DrawGEffect(play, this, waterSplashTextures[texIndex]); + break; + + case 2: + texIndex = this->rgTexIndex / 100; + if (texIndex > 7) { + texIndex = 7; + } + EffectSs_DrawGEffect(play, this, waterSplashTextures[texIndex]); + break; + } +} + +void EffectSsGSplash_Update(PlayState* play, u32 index, EffectSs* this) { + Vec3f newSplashPos; + + if ((this->rType == 1) && (this->life == 5)) { + newSplashPos = this->pos; + newSplashPos.y += ((this->rgScale * 20) * 0.002f); + EffectSsGSplash_Spawn(play, &newSplashPos, 0, 0, 2, this->rgScale / 2); + } + + this->rgTexIndex += this->rgTexIndexStep; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c index 3a2f75606..b4d9ae6fb 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c +++ b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c @@ -1,33 +1,131 @@ /* * File: z_eff_ss_hahen.c * Overlay: ovl_Effect_Ss_Hahen - * Description: + * Description: Fragments */ #include "z_eff_ss_hahen.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rPitch regs[0] +#define rYaw regs[1] +#define rFlags regs[2] +#define rScale regs[3] +#define rObjId regs[4] +#define rObjBankIndex regs[5] +#define rMinLife regs[6] #define PARAMS ((EffectSsHahenInitParams*)initParamsx) -s32 EffectSsHahen_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsHahen_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsHahen_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsHahen_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Hahen_InitVars = { EFFECT_SS_HAHEN, EffectSsHahen_Init, }; -#endif +void EffectSsHahen_CheckForObject(EffectSs* this, PlayState* play) { + if (((this->rObjBankIndex = Object_GetIndex(&play->objectCtx, this->rObjId)) < 0) || + !Object_IsLoaded(&play->objectCtx, this->rObjBankIndex)) { + this->life = -1; + this->draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hahen/func_8097B270.s") +u32 EffectSsHahen_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsHahenInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hahen/EffectSsHahen_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->life = 200; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hahen/func_8097B424.s") + if (initParams->dList != NULL) { + this->gfx = initParams->dList; + this->rObjId = initParams->objId; + EffectSsHahen_CheckForObject(this, play); + } else { + this->gfx = gEffFragments1DL; + this->rObjId = HAHEN_OBJECT_DEFAULT; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hahen/func_8097B504.s") + this->draw = EffectSsHahen_Draw; + this->update = EffectSsHahen_Update; + this->rFlags = initParams->flags; + this->rScale = initParams->scale; + this->rPitch = Rand_ZeroOne() * 314.0f; + this->rYaw = Rand_ZeroOne() * 314.0f; + this->rMinLife = 200 - initParams->life; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hahen/EffectSsHahen_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hahen/EffectSsHahen_Update.s") +void EffectSsHahen_DrawOpa(PlayState* play, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + s32 pad; + + OPEN_DISPS(gfxCtx); + + if (this->rObjId != HAHEN_OBJECT_DEFAULT) { + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->rObjBankIndex].segment); + } + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(play->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, this->gfx); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsHahen_DrawXlu(PlayState* play, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + s32 pad; + + OPEN_DISPS(gfxCtx); + + if (this->rObjId != -1) { + gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[this->rObjBankIndex].segment); + } + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(play->state.gfxCtx); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsHahen_Draw(PlayState* play, u32 index, EffectSs* this) { + f32 scale; + + if (this->rFlags & HAHEN_SMALL) { + scale = this->rScale * (0.001f * 0.1f); + } else { + scale = this->rScale * 0.001f; + } + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_RotateYF(this->rYaw * 0.01f, MTXMODE_APPLY); + Matrix_RotateXFApply(this->rPitch * 0.01f); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + + if (this->rFlags & HAHEN_XLU) { + EffectSsHahen_DrawXlu(play, this); + } else { + EffectSsHahen_DrawOpa(play, this); + } +} + +void EffectSsHahen_Update(PlayState* play, u32 index, EffectSs* this) { + Player* player = GET_PLAYER(play); + + this->rPitch += 0x37; + this->rYaw += 0xA; + + if ((this->pos.y <= player->actor.floorHeight) && (this->life < this->rMinLife)) { + this->life = 0; + } + + if (this->rObjId != HAHEN_OBJECT_DEFAULT) { + EffectSsHahen_CheckForObject(this, play); + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h index d7a160b4f..9a73ac664 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h +++ b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h @@ -5,12 +5,15 @@ #define HAHEN_OBJECT_DEFAULT -1 +#define HAHEN_SMALL (1 << 0) +#define HAHEN_XLU (1 << 1) + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; /* 0x18 */ Vec3f accel; /* 0x24 */ Gfx* dList; - /* 0x28 */ s16 unused; + /* 0x28 */ s16 flags; /* 0x2A */ s16 scale; /* 0x2C */ s16 objId; /* 0x2C */ s16 life; diff --git a/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.c b/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.c index 7094ca4ea..f65e36c7d 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.c +++ b/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.c @@ -1,27 +1,163 @@ /* * File: z_eff_ss_hitmark.c * Overlay: ovl_Effect_Ss_Hitmark - * Description: + * Description: Hit Marks */ #include "z_eff_ss_hitmark.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rTexIndex regs[0] +#define rType regs[1] +#define rPrimColorR regs[2] +#define rPrimColorG regs[3] +#define rPrimColorB regs[4] +#define rEnvColorR regs[5] +#define rEnvColorG regs[6] +#define rEnvColorB regs[7] +#define rScale regs[8] #define PARAMS ((EffectSsHitmarkInitParams*)initParamsx) -s32 EffectSsHitmark_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsHitmark_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsHitmark_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsHitmark_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 +static Color_RGB8 sColors[] = { + { 255, 255, 255 }, { 255, 255, 0 }, // EFFECT_HITMARK_WHITE Init + { 255, 255, 255 }, { 255, 0, 0 }, // EFFECT_HITMARK_WHITE Update + { 255, 200, 100 }, { 200, 150, 0 }, // EFFECT_HITMARK_DUST Init + { 150, 100, 0 }, { 100, 50, 0 }, // EFFECT_HITMARK_DUST Update + { 255, 255, 255 }, { 255, 0, 0 }, // EFFECT_HITMARK_RED Init + { 255, 255, 0 }, { 255, 0, 0 }, // EFFECT_HITMARK_RED Update + { 255, 255, 255 }, { 0, 255, 200 }, // EFFECT_HITMARK_METAL Init + { 255, 255, 255 }, { 150, 0, 255 }, // EFFECT_HITMARK_METAL Update +}; + +static TexturePtr sTextures[] = { + // EFFECT_HITMARK_WHITE + gEffHitmarkWhiteMetal1Tex, + gEffHitmarkWhiteMetal2Tex, + gEffHitmarkWhiteMetal3Tex, + gEffHitmarkWhiteMetal4Tex, + gEffHitmarkWhiteMetal5Tex, + gEffHitmarkWhiteMetal6Tex, + gEffHitmarkWhiteMetal7Tex, + gEffHitmarkWhiteMetal8Tex, + // EFFECT_HITMARK_DUST + gEffHitmarkDust1Tex, + gEffHitmarkDust2Tex, + gEffHitmarkDust3Tex, + gEffHitmarkDust4Tex, + gEffHitmarkDust5Tex, + gEffHitmarkDust6Tex, + gEffHitmarkDust7Tex, + gEffHitmarkDust8Tex, + // EFFECT_HITMARK_RED + gEffHitmarkRed1Tex, + gEffHitmarkRed2Tex, + gEffHitmarkRed3Tex, + gEffHitmarkRed4Tex, + gEffHitmarkRed5Tex, + gEffHitmarkRed6Tex, + gEffHitmarkRed7Tex, + gEffHitmarkRed8Tex, + // EFFECT_HITMARK_METAL + gEffHitmarkWhiteMetal1Tex, + gEffHitmarkWhiteMetal2Tex, + gEffHitmarkWhiteMetal3Tex, + gEffHitmarkWhiteMetal4Tex, + gEffHitmarkWhiteMetal5Tex, + gEffHitmarkWhiteMetal6Tex, + gEffHitmarkWhiteMetal7Tex, + gEffHitmarkWhiteMetal8Tex, +}; + const EffectSsInit Effect_Ss_Hitmark_InitVars = { EFFECT_SS_HITMARK, EffectSsHitmark_Init, }; -#endif +u32 EffectSsHitmark_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsHitmarkInitParams* initParams = PARAMS; + s32 colorIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hitmark/EffectSsHitmark_Init.s") + this->pos = initParams->pos; + this->gfx = gEffHitmarkDL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hitmark/EffectSsHitmark_Draw.s") + if (initParams->type == EFFECT_HITMARK_DUST) { + this->life = 16; + } else { + this->life = 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Hitmark/EffectSsHitmark_Update.s") + this->draw = EffectSsHitmark_Draw; + this->update = EffectSsHitmark_Update; + + colorIndex = initParams->type * 4; + this->rTexIndex = 0; + this->rType = initParams->type; + this->rPrimColorR = sColors[colorIndex].r; + this->rPrimColorG = sColors[colorIndex].g; + this->rPrimColorB = sColors[colorIndex].b; + this->rEnvColorR = sColors[colorIndex + 1].r; + this->rEnvColorG = sColors[colorIndex + 1].g; + this->rEnvColorB = sColors[colorIndex + 1].b; + this->rScale = initParams->scale; + + return 1; +} + +void EffectSsHitmark_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + MtxF mfTransBillboard; + Mtx* mtx; + f32 scale; + TexturePtr tex; + s32 pad; + + OPEN_DISPS(gfxCtx); + + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + scale = this->rScale / 100.0f; + SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + tex = sTextures[(this->rType * 8) + (this->rTexIndex)]; + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(tex)); + func_8012C9BC(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + CLOSE_DISPS(gfxCtx); +} + +void EffectSsHitmark_Update(PlayState* play, u32 index, EffectSs* this) { + s32 colorIndex; + + if (this->rType == EFFECT_HITMARK_DUST) { + this->rTexIndex = (15 - this->life) / 2; + } else { + this->rTexIndex = 7 - this->life; + } + + if (this->rTexIndex != 0) { + colorIndex = this->rType * 4 + 2; + this->rPrimColorR = func_800B096C(this->rPrimColorR, sColors[colorIndex].r, this->life + 1); + this->rPrimColorG = func_800B096C(this->rPrimColorG, sColors[colorIndex].g, this->life + 1); + this->rPrimColorB = func_800B096C(this->rPrimColorB, sColors[colorIndex].b, this->life + 1); + this->rEnvColorR = func_800B096C(this->rEnvColorR, sColors[colorIndex + 1].r, this->life + 1); + this->rEnvColorG = func_800B096C(this->rEnvColorG, sColors[colorIndex + 1].g, this->life + 1); + this->rEnvColorB = func_800B096C(this->rEnvColorB, sColors[colorIndex + 1].b, this->life + 1); + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.h b/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.h index fe6c54eb0..6e38ab8d2 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.h +++ b/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.h @@ -14,7 +14,7 @@ typedef struct { /* 0x00 */ s32 type; /* 0x04 */ s16 scale; /* 0x08 */ Vec3f pos; -} EffectSsHitMarkInitParams; // size = 0x14 +} EffectSsHitmarkInitParams; // size = 0x14 extern const EffectSsInit Effect_Ss_Hitmark_InitVars; diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h index 78c4a9a62..ff8b85723 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h @@ -17,7 +17,6 @@ typedef struct FileChooseContext { /* 0x00248 */ SkyboxContext skyboxCtx; /* 0x00470 */ MessageContext msgCtx; /* 0x12550 */ Font font; - /* 0x242DC */ UNK_TYPE1 unk_242DC[4]; /* 0x242E0 */ EnvironmentContext envCtx; /* 0x243E0 */ Vtx* unk_243E0; /* 0x243E4 */ Vtx* unk_243E4; diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index d4247ca61..4a62de6a2 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -22,11 +22,11 @@ void Select_LoadGame(SelectContext* this, u32 entranceIndex, s32 opt) { Sram_InitDebugSave(); } - gSaveContext.buttonStatus[0] = BTN_ENABLED; - gSaveContext.buttonStatus[1] = BTN_ENABLED; - gSaveContext.buttonStatus[2] = BTN_ENABLED; - gSaveContext.buttonStatus[3] = BTN_ENABLED; - gSaveContext.buttonStatus[4] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; gSaveContext.unk_3F1E = 0; gSaveContext.unk_3F20 = 0; gSaveContext.unk_3F22 = 0; @@ -44,7 +44,7 @@ void Select_LoadGame(SelectContext* this, u32 entranceIndex, s32 opt) { gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; } - gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = 0xFFFF; + gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex = 0xFFFF; gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.showTitleCard = true; diff --git a/tools/disasm/disasm.py b/tools/disasm/disasm.py index cb634d138..0f5e16464 100755 --- a/tools/disasm/disasm.py +++ b/tools/disasm/disasm.py @@ -4,12 +4,12 @@ import argparse, ast, math, os, re, struct import bisect import multiprocessing from pathlib import Path -import mips_isa +import rabbitizer # Consider implementing gpr naming too, but already uses abi names by default fpr_name_options = { - "numeric": mips_isa.numeric_fpr_names, - "o32": mips_isa.o32_fpr_names, + "numeric", + "o32", } parser = argparse.ArgumentParser() @@ -32,12 +32,15 @@ parser.add_argument( required=False, help="Optional list of files to diassemble separated by a space. This is a whitelist, all files will be skipped besides the ones listed here if used.", ) -parser.add_argument("--reg-names", choices=fpr_name_options.keys(), help="How to name registers in the output") +parser.add_argument( + "--reg-names", choices=fpr_name_options, help="How to name registers in the output" +) args = parser.parse_args() jobs = args.jobs -mips_isa.mips_fpr_names = fpr_name_options.get(args.reg_names, mips_isa.mips_fpr_names) +rabbitizer.config.regNames_fprAbiNames = rabbitizer.Abi.fromStr(args.reg_names) +rabbitizer.config.regNames_userFpcCsr = False ASM_OUT = "asm/" @@ -131,76 +134,6 @@ def discard_decomped_files(files_spec, include_files): return new_spec -MIPS_BRANCH_LIKELY_INSNS = [ - mips_isa.MIPS_INS_BEQL, - mips_isa.MIPS_INS_BGEZALL, - mips_isa.MIPS_INS_BGEZL, - mips_isa.MIPS_INS_BGTZL, - mips_isa.MIPS_INS_BLEZL, - mips_isa.MIPS_INS_BLTZALL, - mips_isa.MIPS_INS_BLTZL, - mips_isa.MIPS_INS_BNEL, - mips_isa.MIPS_INS_BC1TL, - mips_isa.MIPS_INS_BC1FL, -] - -MIPS_BRANCH_INSNS = [ - *MIPS_BRANCH_LIKELY_INSNS, - mips_isa.MIPS_INS_BEQ, - mips_isa.MIPS_INS_BGEZ, - mips_isa.MIPS_INS_BGEZAL, - mips_isa.MIPS_INS_BGTZ, - mips_isa.MIPS_INS_BNE, - mips_isa.MIPS_INS_BLTZ, - mips_isa.MIPS_INS_BLTZAL, - mips_isa.MIPS_INS_BLEZ, - mips_isa.MIPS_INS_BC1T, - mips_isa.MIPS_INS_BC1F, - mips_isa.MIPS_INS_BEQZ, - mips_isa.MIPS_INS_BNEZ, - mips_isa.MIPS_INS_B, -] - -MIPS_JUMP_INSNS = [mips_isa.MIPS_INS_JAL, mips_isa.MIPS_INS_JALR, mips_isa.MIPS_INS_J, mips_isa.MIPS_INS_JR] - -MIPS_FP_LOAD_INSNS = [mips_isa.MIPS_INS_LWC1, mips_isa.MIPS_INS_LDC1] - -MIPS_FP_STORE_INSNS = [mips_isa.MIPS_INS_SWC1, mips_isa.MIPS_INS_SDC1] - -MIPS_FP_LOAD_STORE_INSNS = [*MIPS_FP_LOAD_INSNS, *MIPS_FP_STORE_INSNS] - -MIPS_STORE_INSNS = [ - mips_isa.MIPS_INS_SB, - mips_isa.MIPS_INS_SH, - mips_isa.MIPS_INS_SW, - mips_isa.MIPS_INS_SWL, - mips_isa.MIPS_INS_SWR, - mips_isa.MIPS_INS_SD, - mips_isa.MIPS_INS_SDL, - mips_isa.MIPS_INS_SDR, - mips_isa.MIPS_INS_SC, - mips_isa.MIPS_INS_SCD, - *MIPS_FP_STORE_INSNS, -] - -MIPS_LOAD_STORE_INSNS = [ - mips_isa.MIPS_INS_LB, - mips_isa.MIPS_INS_LBU, - mips_isa.MIPS_INS_LH, - mips_isa.MIPS_INS_LHU, - mips_isa.MIPS_INS_LW, - mips_isa.MIPS_INS_LWL, - mips_isa.MIPS_INS_LWR, - mips_isa.MIPS_INS_LWU, - mips_isa.MIPS_INS_LD, - mips_isa.MIPS_INS_LDL, - mips_isa.MIPS_INS_LDR, - mips_isa.MIPS_INS_LL, - mips_isa.MIPS_INS_LLD, - *MIPS_STORE_INSNS, - *MIPS_FP_LOAD_STORE_INSNS, -] - VRAM_BASE = { "code": {"data": 0x801AAAB0, "rodata": 0x801DBDF0, "bss": 0x801E3FA0}, "boot": {"data": 0x800969C0, "rodata": 0x80098190, "bss": 0x80099500}, @@ -573,6 +506,18 @@ def update_symbols_from_dict(symbols_dict): put_text(file[0], file[1]) +def validateLuiImm(imm_value: int, insn: rabbitizer.Instruction) -> bool: + if ((imm_value >> 0x8) & 0xF) != 0 and imm_value < 0x1000: + return True + if imm_value >= 0x8000 and imm_value < 0x80D0: + return True + if imm_value >= 0xA400 and imm_value < 0xA480: + return True + if imm_value < 0x0400 and insn.uniqueId == rabbitizer.InstrId.cpu_addiu: + return True + return False + + 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 @@ -582,6 +527,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): print(f"Finding symbols from .text in {info['name']}") + rodata_words = [] if rodata is not None: rodata_words = as_word_list(rodata) @@ -623,20 +569,20 @@ def find_symbols_in_text(section, rodata_section, data_regions): # that means no code path produces a valid symbol at he convergent code, unless the convergent code provides all the # new registers. - # assert insn.value_forname(insn.fields[0]) is not None - # print(f"insn: {insn.mnemonic}, rt: {insn.rt}, first: {insn.value_forname(insn.fields[0])}") - # assert insn.id not in [MIPS_INS_ORI, mips_isa.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.isBranchLikely(): + if insn.modifiesRd(): + clobber_later.update( + {delayed_insn.getBranchOffset() + delayed_insn.vram: insn.rd} + ) + elif insn.modifiesRt(): + clobber_later.update( + {delayed_insn.getBranchOffset() + delayed_insn.vram: insn.rt} + ) else: - lui_tracker.pop(insn.value_forname(insn.fields[0]), None) + if insn.modifiesRd(): + lui_tracker.pop(insn.rd, None) + elif insn.modifiesRt(): + lui_tracker.pop(insn.rt, None) for region in data_regions: assert region[1] != 0 @@ -646,26 +592,30 @@ def find_symbols_in_text(section, rodata_section, data_regions): insns = [] for i, raw_insn in enumerate(raw_insns, 0): - insn = mips_isa.decode_insn(raw_insn, vram + i * 4) + insn = rabbitizer.Instruction(raw_insn, vram=vram + i * 4) - if insn.id == mips_isa.MIPS_INS_JR and insn.rs != mips_isa.MIPS_REG_RA: - # It's hard to find when two jump tables next to each other end, so do a naive first pass - # to try and find as many jump tables as possible. - # Luckily IDO has a very homogeneous output for jump tables for which it is very unlikely - # that other instructions will break up: - # lui $at, %hi(jtbl) - # addu $at, $at, $reg - # lw $reg, %lo(jtbl)($at) - # jr $reg + if insn.isJrNotRa() and len(insns) > 3: + """ + It's hard to find when two jump tables next to each other end, so do a naive first pass + to try and find as many jump tables as possible. + Luckily IDO has a very homogeneous output for jump tables for which it is very unlikely + that other instructions will break up: + lui $at, %hi(jtbl) + addu $at, $at, $reg + lw $reg, %lo(jtbl)($at) + jr $reg + """ insn_m1 = insns[-1] insn_m2 = insns[-2] insn_m3 = insns[-3] if ( - insn_m1.id == mips_isa.MIPS_INS_LW - and insn_m2.id == mips_isa.MIPS_INS_ADDU - and insn_m3.id == mips_isa.MIPS_INS_LUI + insn_m1.uniqueId == rabbitizer.InstrId.cpu_lw + and insn_m2.uniqueId == rabbitizer.InstrId.cpu_addu + and insn_m3.uniqueId == rabbitizer.InstrId.cpu_lui ): - prospective_jtbls.add((insn_m3.imm << 0x10) + insn_m1.imm) + prospective_jtbls.add( + (insn_m3.getImmediate() << 0x10) + insn_m1.getProcessedImmediate() + ) insns.append(insn) if relocs is not None: @@ -684,26 +634,27 @@ def find_symbols_in_text(section, rodata_section, data_regions): Relocated jump targets give us functions in this section """ assert ( - insn.id == mips_isa.MIPS_INS_JAL - ), f"R_MIPS_26 applied to {insn.mnemonic} when it should be JAL" - put_symbol(symbols_dict, "functions", insn.target) + insn.uniqueId == rabbitizer.InstrId.cpu_jal + ), f"R_MIPS_26 applied to {insn.getOpcodeName()} when it should be JAL" + put_symbol(symbols_dict, "functions", insn.getInstrIndexAsVram()) elif reloc[1] == 5: # R_MIPS_HI16 """ Relocated %hi gives us %hi values to match with associated %lo """ assert ( - insn.id == mips_isa.MIPS_INS_LUI - ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be LUI" - prev_hi = insn.imm + insn.canBeHi() + ), f"R_MIPS_HI16 applied to {insn.getOpcodeName()} when it should be LUI" + prev_hi = insn.getImmediate() 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_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS - ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be ADDIU or a load/store" - symbol_value = (prev_hi << 0x10) + insn.imm + insn.canBeLo() + ), f"R_MIPS_HI16 applied to {insn.getOpcodeName()} when it should be ADDIU or a load/store" + assert prev_hi is not None + symbol_value = (prev_hi << 0x10) + insn.getProcessedImmediate() put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) put_symbols(symbols_dict, "symbols", {vram + reloc[2]: symbol_value}) else: @@ -716,8 +667,6 @@ def find_symbols_in_text(section, rodata_section, data_regions): cur_file = "" cur_vaddr = 0 - segment_dirname = ("" if info["type"] != "overlay" else "overlays/") + info["name"] - delayed_insn = None delay_slot = False @@ -730,14 +679,13 @@ def find_symbols_in_text(section, rodata_section, data_regions): if vaddr in range(region[0], region[1], 4): in_data = True break + if not insn.isValid(): + in_data = True 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}"], + "insn": insn, + "comment": f"/* {i*4:06X} {vaddr:08X} {raw_insns[i]:08X} */", "data": True, } ) @@ -764,19 +712,21 @@ def find_symbols_in_text(section, rodata_section, data_regions): if cl is not None: lui_tracker.pop(cl, None) - if insn.id in MIPS_BRANCH_INSNS: - func_branch_labels.add(insn.offset) + branch_likely_delay_slot_save = None + + if insn.isBranch(): + func_branch_labels.add(insn.getBranchOffset() + insn.vram) delayed_insn = insn - elif insn.id == mips_isa.MIPS_INS_ERET: + elif insn.uniqueId == rabbitizer.InstrId.cpu_eret: put_symbol(symbols_dict, "functions", vaddr + 4) - elif insn.id in MIPS_JUMP_INSNS: - if insn.id == mips_isa.MIPS_INS_JAL: + elif insn.isJump(): + if insn.uniqueId == rabbitizer.InstrId.cpu_jal: # mark function at target - put_symbol(symbols_dict, "functions", insn.target) - elif insn.id == mips_isa.MIPS_INS_J: + put_symbol(symbols_dict, "functions", insn.getInstrIndexAsVram()) + elif insn.uniqueId == rabbitizer.InstrId.cpu_j: # mark label at target - func_branch_labels.add(insn.target) - elif insn.id == mips_isa.MIPS_INS_JR: + func_branch_labels.add(insn.getInstrIndexAsVram()) + elif insn.uniqueId == rabbitizer.InstrId.cpu_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 @@ -802,7 +752,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): symbols_dict, "functions", vaddr + 8 + n_padding * 4 ) delayed_insn = insn - elif insn.id == mips_isa.MIPS_INS_LUI: + elif insn.canBeHi(): """ Process LUI instruction @@ -813,45 +763,47 @@ def find_symbols_in_text(section, rodata_section, data_regions): if ( delay_slot and delayed_insn is not None - and delayed_insn.id in MIPS_BRANCH_LIKELY_INSNS + and delayed_insn.isBranchLikely() ): # 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)}) + branch_likely_delay_slot_save = {insn.rt: (vaddr, insn.getProcessedImmediate())} else: - lui_tracker.update({insn.rt: (vaddr, insn.imm)}) - elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + lui_tracker.update({insn.rt: (vaddr, insn.getProcessedImmediate())}) + elif insn.uniqueId == rabbitizer.InstrId.cpu_ori: + # try match with tracked lui and mark constant + hi_vram, imm_value = lui_tracker.get(insn.rs, (None, None)) + if hi_vram is not None and imm_value is not None: # found match + lo_vram = vaddr + const_value = (imm_value << 0x10) | insn.getProcessedImmediate() + 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 + if insn.rt in lui_tracker.keys(): + clobber_conditionally(insn) + elif insn.canBeLo(): # try match with tracked lui and mark symbol - hi_vram, imm_value = lui_tracker.get( - insn.rs if insn.id == mips_isa.MIPS_INS_ADDIU else insn.base, (None, None) - ) + hi_vram, imm_value = lui_tracker.get(insn.rs, (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_isa.MIPS_INS_ADDIU) + if ( + hi_vram is not None + and imm_value is not None + and validateLuiImm(imm_value, insn) ): lo_vram = vaddr - symbol_value = (imm_value << 0x10) + insn.imm + symbol_value = (imm_value << 0x10) + insn.getProcessedImmediate() put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) put_symbols(symbols_dict, "symbols", {lo_vram: symbol_value}) - if insn.id == mips_isa.MIPS_INS_LW: + if insn.uniqueId == rabbitizer.InstrId.cpu_lw: # try find jr within the same block cur_idx = i lookahead_insn = insns[cur_idx] # TODO fix vaddr here # still in same block unless one of these instructions are found - while lookahead_insn.id not in [ - *MIPS_BRANCH_INSNS, - mips_isa.MIPS_INS_JAL, - mips_isa.MIPS_INS_JALR, - mips_isa.MIPS_INS_J, - ]: - if lookahead_insn.id == mips_isa.MIPS_INS_JR: - if lookahead_insn.rs == ( - insn.ft - if insn.id in MIPS_FP_LOAD_STORE_INSNS - else insn.rt - ): + while lookahead_insn.isJrNotRa() or not ( + lookahead_insn.isBranch() or lookahead_insn.isJump() + ): + if lookahead_insn.uniqueId == rabbitizer.InstrId.cpu_jr: + if lookahead_insn.rs == insn.rt: # read the jtbl and add targets to func_jtbl_labels assert ( rodata is not None @@ -881,104 +833,52 @@ def find_symbols_in_text(section, rodata_section, data_regions): 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:] - ]: - # 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 = insns[cur_idx] # TODO fix vaddr here - elif insn.id == mips_isa.MIPS_INS_LD: # doubleword loads + elif insn.uniqueId == rabbitizer.InstrId.cpu_ld: # doubleword loads put_symbol(symbols_dict, "dwords", symbol_value) - elif insn.id in [mips_isa.MIPS_INS_LWC1, mips_isa.MIPS_INS_SWC1]: # float load/stores - # add float - put_symbol(symbols_dict, "floats", symbol_value) - elif insn.id in [mips_isa.MIPS_INS_LDC1, mips_isa.MIPS_INS_SDC1]: # double load/stores - # add double - put_symbol(symbols_dict, "doubles", symbol_value) - elif ( - insn.id == mips_isa.MIPS_INS_ADDIU and vaddr % 4 == 0 - ): # strings seem to only ever be 4-byte aligned - # add possible string - put_symbol(symbols_dict, "prospective_strings", symbol_value) + elif insn.doesDereference() and insn.isFloat(): + if insn.isDouble(): # double load/stores + # add double + put_symbol(symbols_dict, "doubles", symbol_value) + else: # float load/stores + # add float + put_symbol(symbols_dict, "floats", symbol_value) + elif not insn.doesDereference() and not insn.isUnsigned(): + if 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_isa.MIPS_INS_ADDIU else insn.base) and - if insn.id not in MIPS_STORE_INSNS and insn.id not in MIPS_FP_LOAD_INSNS: - clobber_conditionally(insn) - elif insn.id == mips_isa.MIPS_INS_ORI: - # try match with tracked lui and mark constant - hi_vram, imm_value = lui_tracker.get(insn.rs, (None, None)) - if hi_vram != None: # found match - 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}) - # clear lui tracking state if register is clobbered by the ori instruction itself - # insn.rt == insn.rs or - if insn.rt in lui_tracker.keys(): + if not insn.doesStore() and not (insn.doesLoad() and insn.isFloat()): clobber_conditionally(insn) else: # clear lui tracking if register is clobbered by something unrelated if ( - insn.id == mips_isa.MIPS_INS_ADDU + insn.uniqueId == rabbitizer.InstrId.cpu_addu and insn.rs in lui_tracker.keys() - and (insn.rd == insn.rs) + and insn.rd == insn.rs ): - # array accesses optimisation: - # lui reg, %hi(symbol) - # addu reg, reg, idx - # lw reg, %lo(symbol)(reg) - # instead of clobbering, keep it if the second operand is also the first - # if the output is not currently tracked it will behave as intended anyway + """ + array accesses optimisation: + lui reg, %hi(symbol) + addu reg, reg, idx + lw reg, %lo(symbol)(reg) + instead of clobbering, keep it if the second operand is also the first + 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_isa.MIPS_INS_MTC0, - mips_isa.MIPS_INS_MTC1, - mips_isa.MIPS_INS_DMTC1, - mips_isa.MIPS_INS_MULT, - mips_isa.MIPS_INS_MULTU, - mips_isa.MIPS_INS_DMULT, - mips_isa.MIPS_INS_DMULTU, - mips_isa.MIPS_INS_DIV, - mips_isa.MIPS_INS_DIVU, - mips_isa.MIPS_INS_DDIV, - mips_isa.MIPS_INS_DDIVU, - mips_isa.MIPS_INS_MTHI, - mips_isa.MIPS_INS_MTLO, - mips_isa.MIPS_INS_CTC1, - mips_isa.MIPS_INS_NOP, - mips_isa.MIPS_INS_BREAK, - mips_isa.MIPS_INS_TLBP, - mips_isa.MIPS_INS_TLBR, - mips_isa.MIPS_INS_TLBWI, - mips_isa.MIPS_INS_MOV_S, - mips_isa.MIPS_INS_MOV_D, - mips_isa.MIPS_INS_C_LT_S, - mips_isa.MIPS_INS_C_LT_D, - mips_isa.MIPS_INS_DIV_S, - mips_isa.MIPS_INS_MUL_S, - mips_isa.MIPS_INS_TRUNC_W_S, - mips_isa.MIPS_INS_CVT_S_W, - mips_isa.MIPS_INS_SUB_S, - mips_isa.MIPS_INS_ADD_S, - ]: + else: 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 info["name"] in full_file_list and vaddr in full_file_list[info["name"]]: if cur_file != "": if cur_vaddr in info["syms"]: result_files.append([cur_file, results]) @@ -988,51 +888,10 @@ def find_symbols_in_text(section, rodata_section, data_regions): 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_isa.MIPS_INS_LUI: - op_str = [op_str] - instr["rt"] = insn.rt - - elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: - op_str = [op_str] - instr["rt"] = insn.rt - instr["rs"] = insn.rs - instr["ft"] = insn.ft - instr["base"] = insn.base - - elif insn.id == mips_isa.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, + "insn": insn, + "comment": f"/* {i*4:06X} {vaddr:08X} {raw_insns[i]:08X} */", "data": False, } ) @@ -1041,22 +900,30 @@ def find_symbols_in_text(section, rodata_section, data_regions): if delay_slot and delayed_insn is not None: if ( - delayed_insn.id == mips_isa.MIPS_INS_JAL - or delayed_insn.id == mips_isa.MIPS_INS_JALR - or (delayed_insn.id == mips_isa.MIPS_INS_JR and delayed_insn.rs == mips_isa.MIPS_REG_RA) + delayed_insn.uniqueId == rabbitizer.InstrId.cpu_jal + or delayed_insn.uniqueId == rabbitizer.InstrId.cpu_jalr + or delayed_insn.isJrRa() ): # destroy lui tracking state lui_tracker.clear() - elif delayed_insn.id == mips_isa.MIPS_INS_JR and vaddr == next_jtbl_jr + 4: + elif ( + delayed_insn.uniqueId == rabbitizer.InstrId.cpu_jr + and vaddr == next_jtbl_jr + 4 + ): # save lui tracking state for each jtbl label for label in individual_jtbl_labels[next_jtbl_jr]: save_tracker(label, lui_tracker.copy()) next_jtbl_jr = 0 - else: + elif delayed_insn.isBranch(): # save lui tracking state - save_tracker(delayed_insn.offset, lui_tracker.copy()) + save_tracker( + delayed_insn.getBranchOffset() + delayed_insn.vram, + lui_tracker.copy(), + ) + if branch_likely_delay_slot_save is not None: + save_tracker(delayed_insn.getBranchOffset() + delayed_insn.vram, branch_likely_delay_slot_save) # destroy current lui tracking state for unconditional branches - if delayed_insn.id == mips_isa.MIPS_INS_B: + if delayed_insn.isUnconditionalBranch(): lui_tracker.clear() delayed_insn = None @@ -1221,7 +1088,7 @@ def find_symbols_in_rodata(section): return symbols_dict -def asm_header(section_name): +def asm_header(section_name: str): return f""".include "macro.inc" # assembler directives @@ -1235,6 +1102,43 @@ def asm_header(section_name): """ +def getImmOverride(insn: rabbitizer.Instruction): + if insn.isBranch(): + return f".L{insn.getBranchOffset() + insn.vram:08X}" + elif insn.isJump(): + return proper_name(insn.getInstrIndexAsVram(), in_data=False, is_symbol=True) + + elif insn.uniqueId == rabbitizer.InstrId.cpu_ori: + constant_value = constants.get(insn.vram, None) + if constant_value is not None: + return f"(0x{constant_value:08X} & 0xFFFF)" + + elif insn.canBeHi(): + symbol_value = symbols.get(insn.vram, None) + if symbol_value is not None: + return f"%hi({proper_name(symbol_value)})" + constant_value = constants.get(insn.vram, None) + if constant_value is not None: + return f"(0x{constant_value:08X} >> 16)" + + elif insn.canBeLo(): + symbol_value = symbols.get(insn.vram, None) + if symbol_value is not None: + return f"%lo({proper_name(symbol_value)})" + return None + + +def getLabelForVaddr(vaddr: int, in_data: bool = False) -> str: + label = "" + if vaddr in functions: + label += f"\nglabel {proper_name(vaddr, in_data=in_data)}\n" + if vaddr in jtbl_labels: + label += f"glabel L{vaddr:08X}\n" + if vaddr in branch_labels: + label += f".L{vaddr:08X}:\n" + return label + + def fixup_text_symbols(data, vram, data_regions, info): segment_dirname = "" if info["type"] != "overlay" else "overlays/" if info["type"] in ("boot", "code"): @@ -1251,73 +1155,34 @@ def fixup_text_symbols(data, vram, data_regions, info): # 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}" - + delay_slot = False + disasm_as_data = False + for entry in file: 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 + in_data = entry["data"] + comment = entry["comment"] - elif insn["id"] == mips_isa.MIPS_INS_LUI: - symbol_value = symbols.get(vaddr, None) - if symbol_value is not None: - line += ( - f"{ mips_isa.mips_gpr_names[insn['rt']]}, %hi({proper_name(symbol_value)})" - ) - else: - constant_value = constants.get(vaddr, None) - if constant_value is not None: - line += ( - f"{ mips_isa.mips_gpr_names[insn['rt']]}, (0x{constant_value:08X} >> 16)" - ) - else: - line += entry["op"][0] + text.append(getLabelForVaddr(insn.vram, in_data)) + if insn.vram in functions: + # new function, needs to check this again + disasm_as_data = False - elif insn["id"] == mips_isa.MIPS_INS_ADDIU or insn["id"] in MIPS_LOAD_STORE_INSNS: - symbol_value = symbols.get(vaddr, None) - if symbol_value is not None: - if insn["id"] == mips_isa.MIPS_INS_ADDIU: - line += f"{ mips_isa.mips_gpr_names[insn['rt']]}, { mips_isa.mips_gpr_names[insn['rs']]}, %lo({proper_name(symbol_value)})" - else: - line += f"{mips_isa.mips_fpr_names[insn['ft']] if insn['id'] in MIPS_FP_LOAD_STORE_INSNS else mips_isa.mips_gpr_names[insn['rt']]}, %lo({proper_name(symbol_value)})({ mips_isa.mips_gpr_names[insn['base']]})" - else: - line += entry["op"][0] + if in_data or disasm_as_data: + disasm_as_data = True + text.append(f"{comment} .word 0x{insn.getRaw():08X}\n") + continue - elif insn["id"] == mips_isa.MIPS_INS_ORI: - constant_value = constants.get(vaddr, None) - if constant_value is not None: - line += f"{ mips_isa.mips_gpr_names[insn['rt']]}, { mips_isa.mips_gpr_names[insn['rs']]}, (0x{constant_value:08X} & 0xFFFF)" - else: - line += entry["op"][0] + extraLJust = 0 + if delay_slot: + extraLJust = -1 + comment += " " - 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 + disassembled = insn.disassemble( + immOverride=getImmOverride(insn), extraLJust=extraLJust + ) + text.append(f"{comment} {disassembled}\n") - line += "\n" - text.append(line) + delay_slot = insn.hasDelaySlot() with open(f"{ASM_OUT}/{segment_dirname}/{info['name']}.text.s", "w") as outfile: outfile.write("".join(text)) @@ -1333,15 +1198,12 @@ def disassemble_text(data, vram, data_regions, info): 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): i *= 4 vaddr = vram + i - insn = mips_isa.decode_insn(raw_insns[i // 4], vaddr) - mnemonic = insn.mnemonic - op_str = insn.op_str + insn = rabbitizer.Instruction(raw_insns[i // 4], vram=vaddr) if vaddr in full_file_list[info["name"]]: if cur_file != "": @@ -1372,63 +1234,20 @@ def disassemble_text(data, vram, data_regions, info): ) continue - # LABELS - if vaddr in functions: - result += f"\nglabel {proper_name(vaddr)}\n" - if vaddr in jtbl_labels: - result += f"glabel L{vaddr:08X}\n" - if vaddr in branch_labels: - result += f".L{vaddr:08X}:\n" - - # INSTRUCTIONS FORMATTING/CORRECTING - 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) - delayed_insn = insn - elif insn.id in MIPS_JUMP_INSNS: - op_str_parts = [] - for field in insn.fields: - if field == "target": - op_str_parts.append(proper_name(insn.target, is_symbol=True)) - else: - op_str_parts.append(insn.format_field(field)) - op_str = ", ".join(op_str_parts) - delayed_insn = insn - elif insn.id == mips_isa.MIPS_INS_LUI: - symbol_value = symbols.get(vaddr, None) - if symbol_value is not None: - op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, %hi({proper_name(symbol_value)})" - else: - constant_value = constants.get(vaddr, None) - if constant_value is not None: - op_str = ( - f"{ mips_isa.mips_gpr_names[insn.rt]}, (0x{constant_value:08X} >> 16)" - ) - elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: - symbol_value = symbols.get(vaddr, None) - if symbol_value is not None: - if insn.id == mips_isa.MIPS_INS_ADDIU: - op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, { mips_isa.mips_gpr_names[insn.rs]}, %lo({proper_name(symbol_value)})" - else: - op_str = f"{mips_isa.mips_fpr_names[insn.ft] if insn.id in MIPS_FP_LOAD_STORE_INSNS else mips_isa.mips_gpr_names[insn.rt]}, %lo({proper_name(symbol_value)})({ mips_isa.mips_gpr_names[insn.base]})" - elif insn.id == mips_isa.MIPS_INS_ORI: - constant_value = constants.get(vaddr, None) - if constant_value is not None: - op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, { mips_isa.mips_gpr_names[insn.rs]}, (0x{constant_value:08X} & 0xFFFF)" + result += getLabelForVaddr(vaddr) + comment = f"/* {i:06X} {vaddr:08X} {raw_insn:08X} */" + extraLJust = 0 if delay_slot: - mnemonic = " " + mnemonic - delayed_insn = None - delay_slot = False - if delayed_insn is not None: - delay_slot = True + extraLJust = -1 + comment += " " - result += f"/* {i:06X} {vaddr:08X} {raw_insn:08X} */ {mnemonic:12}{op_str}\n" + disassembled = insn.disassemble( + immOverride=getImmOverride(insn), extraLJust=extraLJust + ) + result += f"{comment} {disassembled}\n" + + delay_slot = insn.hasDelaySlot() with open(f"{ASM_OUT}/{segment_dirname}/{cur_file}.text.s", "w") as outfile: outfile.write(result) @@ -1703,12 +1522,16 @@ def disassemble_rodata(data, vram, end, info): 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" + if 0 in string_data: + 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" + else: + # Not null-terminanted. Can't be a string + strings.remove(symbol) elif symbol % 8 == 0 and data_size % 8 == 0 and symbol in doubles: r += ( "\n".join( @@ -2392,9 +2215,10 @@ for section in all_sections: rodata_section = None pool.apply_async( find_symbols_in_text, - args=(section, rodata_section if rodata_section else None, data_regions), + args=(section, rodata_section, 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 diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index 0d01095b1..f3fca8ff4 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -544,7 +544,7 @@ 0x801BF550 : "z_map_exp", 0x801BF5C0 : "z_msgevent", 0x801BF6C0 : "z_parameter", - 0x801BFDD0 : "z_player_lib", + 0x801BFDA0 : "z_player_lib", 0x801C0EC0 : "z_quake", 0x801C0EF0 : "z_rcp", 0x801C1D10 : "z_room", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index f861588a5..ebcf5d2a4 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -626,9 +626,9 @@ 0x800B242C:("EffectSsSibuki_Spawn",), 0x800B249C:("EffectSsSibuki_SpawnBurst",), 0x800B25D8:("EffectSsStone1_Spawn",), - 0x800B262C:("EffectSsHitMark_Spawn",), - 0x800B2684:("EffectSsHitMark_SpawnFixedScale",), - 0x800B26A8:("EffectSsHitMark_SpawnCustomScale",), + 0x800B262C:("EffectSsHitmark_Spawn",), + 0x800B2684:("EffectSsHitmark_SpawnFixedScale",), + 0x800B26A8:("EffectSsHitmark_SpawnCustomScale",), 0x800B26D4:("EffectSsFhgFlash_SpawnShock",), 0x800B2738:("EffectSsKFire_Spawn",), 0x800B27A0:("EffectSsSolderSrchBall_Spawn",), @@ -1271,15 +1271,15 @@ 0x800DF840:("Camera_ChangeMode",), 0x800DF86C:("func_800DF86C",), 0x800DF8EC:("func_800DF8EC",), - 0x800DFAC8:("func_800DFAC8",), + 0x800DFAC8:("Camera_ChangeSetting",), 0x800DFB14:("Camera_ChangeDataIdx",), 0x800DFC1C:("func_800DFC1C",), 0x800DFC40:("func_800DFC40",), 0x800DFC68:("Camera_GetInputDirYaw",), - 0x800DFC90:("func_800DFC90",), + 0x800DFC90:("Camera_GetCamDir",), 0x800DFCB4:("Camera_GetCamDirPitch",), 0x800DFCDC:("Camera_GetCamDirYaw",), - 0x800DFD04:("func_800DFD04",), + 0x800DFD04:("Camera_AddQuake",), 0x800DFD78:("func_800DFD78",), 0x800DFEF0:("func_800DFEF0",), 0x800DFF18:("func_800DFF18",), @@ -1287,7 +1287,7 @@ 0x800DFF44:("func_800DFF44",), 0x800DFF60:("Camera_SetFlags",), 0x800DFF84:("Camera_ClearFlags",), - 0x800DFFAC:("func_800DFFAC",), + 0x800DFFAC:("Camera_ChangeDoorCam",), 0x800E007C:("func_800E007C",), 0x800E01AC:("func_800E01AC",), 0x800E01B8:("Camera_GetQuakeOffset",), @@ -1657,7 +1657,7 @@ 0x800F20F8:("ActorCutscene_GetLength",), 0x800F2138:("func_800F2138",), 0x800F2178:("func_800F2178",), - 0x800F21B8:("ActorCutscene_GetCurrentCamera",), + 0x800F21B8:("ActorCutscene_GetCurrentSubCamId",), 0x800F21CC:("func_800F21CC",), 0x800F22C4:("func_800F22C4",), 0x800F23C4:("ActorCutscene_SetReturnCamera",), @@ -1994,21 +1994,21 @@ 0x80109E70:("func_80109E70",), 0x80109EF8:("func_80109EF8",), 0x80109F78:("func_80109F78",), - 0x8010A000:("func_8010A000",), - 0x8010A074:("func_8010A074",), + 0x8010A000:("Map_GetDungeonOrBossAreaIndex",), + 0x8010A074:("Map_IsInDungeonOrBossAreaArea",), 0x8010A0A4:("func_8010A0A4",), - 0x8010A0F0:("func_8010A0F0",), - 0x8010A164:("func_8010A164",), - 0x8010A194:("func_8010A194",), - 0x8010A208:("func_8010A208",), + 0x8010A0F0:("Map_GetDungeonAreaIndex",), + 0x8010A164:("Map_IsInDungeonArea",), + 0x8010A194:("Map_GetBossAreaIndex",), + 0x8010A208:("Map_IsInBossArea",), 0x8010A238:("func_8010A238",), 0x8010A2AC:("func_8010A2AC",), - 0x8010A2DC:("func_8010A2DC",), - 0x8010A33C:("func_8010A33C",), - 0x8010A410:("func_8010A410",), - 0x8010A430:("func_8010A430",), - 0x8010A54C:("func_8010A54C",), - 0x8010A580:("func_8010A580",), + 0x8010A2DC:("Minimap_SavePlayerRoomInitInfo",), + 0x8010A33C:("Map_InitRoomData",), + 0x8010A410:("Map_Destroy",), + 0x8010A430:("Map_Init",), + 0x8010A54C:("Minimap_Draw",), + 0x8010A580:("Map_Update",), 0x8010A760:("func_8010A760",), 0x8010A7CC:("func_8010A7CC",), 0x8010A814:("func_8010A814",), @@ -2109,31 +2109,31 @@ 0x801129E4:("func_801129E4",), 0x80112AF4:("func_80112AF4",), 0x80112AFC:("func_80112AFC",), - 0x80112B40:("func_80112B40",), - 0x80112BE4:("func_80112BE4",), + 0x80112B40:("Interface_LoadItemIconImpl",), + 0x80112BE4:("Interface_LoadItemIcon",), 0x80112C0C:("func_80112C0C",), 0x80112E80:("Item_Give",), - 0x801143CC:("func_801143CC",), - 0x80114978:("func_80114978",), - 0x801149A0:("func_801149A0",), - 0x80114A9C:("func_80114A9C",), - 0x80114B84:("func_80114B84",), - 0x80114CA0:("func_80114CA0",), - 0x80114E90:("Interface_HasEmptyBottle",), - 0x80114F2C:("Interface_HasItemInBottle",), - 0x80114FD0:("func_80114FD0",), - 0x80115130:("func_80115130",), - 0x801152B8:("func_801152B8",), + 0x801143CC:("Item_CheckObtainabilityImpl",), + 0x80114978:("Item_CheckObtainability",), + 0x801149A0:("Inventory_DeleteItem",), + 0x80114A9C:("Inventory_UnequipItem",), + 0x80114B84:("Inventory_ReplaceItem",), + 0x80114CA0:("Inventory_UpdateDeitySwordEquip",), + 0x80114E90:("Inventory_HasEmptyBottle",), + 0x80114F2C:("Inventory_HasItemInBottle",), + 0x80114FD0:("Inventory_UpdateBottleItem",), + 0x80115130:("Inventory_ConsumeFairy",), + 0x801152B8:("Inventory_UpdateItem",), 0x801153C8:("func_801153C8",), 0x80115428:("func_80115428",), 0x8011552C:("func_8011552C",), 0x801155B4:("func_801155B4",), 0x80115764:("func_80115764",), 0x80115844:("func_80115844",), - 0x80115908:("func_80115908",), - 0x801159C0:("func_801159c0",), - 0x801159EC:("func_801159EC",), - 0x80115A14:("func_80115A14",), + 0x80115908:("Health_ChangeBy",), + 0x801159C0:("Health_GiveHearts",), + 0x801159EC:("Rupees_ChangeBy",), + 0x80115A14:("Inventory_ChangeAmmo",), 0x80115D14:("Parameter_AddMagic",), 0x80115D5C:("func_80115D5C",), 0x80115DB4:("func_80115DB4",), @@ -2182,29 +2182,29 @@ 0x80122BA4:("func_80122BA4",), 0x80122C20:("func_80122C20",), 0x80122D44:("func_80122D44",), - 0x80122ED8:("func_80122ED8",), - 0x80122EEC:("func_80122EEC",), + 0x80122ED8:("Player_MaskIdToItemId",), + 0x80122EEC:("Player_GetCurMaskItemId",), 0x80122F28:("func_80122F28",), 0x80122F9C:("func_80122F9C",), 0x80122FCC:("func_80122FCC",), 0x8012300C:("func_8012300C",), 0x8012301C:("func_8012301C",), 0x80123140:("func_80123140",), - 0x80123358:("func_80123358",), + 0x80123358:("Player_InBlockingCsMode",), 0x801233E4:("Player_InCsMode",), 0x80123420:("func_80123420",), 0x80123434:("func_80123434",), 0x80123448:("func_80123448",), - 0x801234B0:("func_801234B0",), + 0x801234B0:("Player_IsGoronOrDeku",), 0x801234D4:("func_801234D4",), 0x80123590:("func_80123590",), 0x801235DC:("func_801235DC",), 0x8012364C:("func_8012364C",), 0x80123810:("func_80123810",), - 0x80123960:("func_80123960",), + 0x80123960:("Player_ActionToModelGroup",), 0x801239AC:("func_801239AC",), - 0x80123AA4:("func_80123AA4",), - 0x80123BD4:("func_80123BD4",), + 0x80123AA4:("Player_SetModels",), + 0x80123BD4:("Player_SetModelGroup",), 0x80123C58:("func_80123C58",), 0x80123C90:("Player_SetEquipmentData",), 0x80123D50:("func_80123D50",), @@ -2213,22 +2213,22 @@ 0x80123E90:("func_80123E90",), 0x80123F14:("func_80123F14",), 0x80123F2C:("func_80123F2C",), - 0x80123F48:("func_80123F48",), - 0x80124020:("func_80124020",), + 0x80123F48:("Player_IsBurningStickInRange",), + 0x80124020:("Player_GetStrength",), 0x8012403C:("Player_GetMask",), 0x8012404C:("Player_RemoveMask",), - 0x8012405C:("func_8012405C",), - 0x80124088:("func_80124088",), - 0x801240C8:("func_801240C8",), + 0x8012405C:("Player_HasMirrorShieldEquipped",), + 0x80124088:("Player_IsHoldingMirrorShield",), + 0x801240C8:("Player_IsHoldingHookshot",), 0x801240DC:("func_801240DC",), 0x80124110:("func_80124110",), 0x80124148:("func_80124148",), - 0x80124168:("func_80124168",), - 0x80124190:("func_80124190",), - 0x801241B4:("func_801241B4",), - 0x801241E0:("func_801241E0",), - 0x8012420C:("func_8012420C",), - 0x8012422C:("func_8012422C",), + 0x80124168:("Player_ActionToMeleeWeapon",), + 0x80124190:("Player_GetMeleeWeaponHeld",), + 0x801241B4:("Player_IsHoldingTwoHandedWeapon",), + 0x801241E0:("Player_ActionToBottle",), + 0x8012420C:("Player_GetBottleHeld",), + 0x8012422C:("Player_ActionToExplosive",), 0x80124258:("Player_GetExplosiveHeld",), 0x80124278:("func_80124278",), 0x801242B4:("func_801242B4",), @@ -2244,7 +2244,7 @@ 0x80125318:("func_80125318",), 0x80125340:("func_80125340",), 0x8012536C:("func_8012536C",), - 0x801253A4:("func_801253A4",), + 0x801253A4:("Player_DrawZoraShield",), 0x80125500:("func_80125500",), 0x80125580:("func_80125580",), 0x80125CE0:("func_80125CE0",), @@ -2254,15 +2254,15 @@ 0x80126440:("func_80126440",), 0x801265C8:("func_801265C8",), 0x8012669C:("func_8012669C",), - 0x80126808:("func_80126808",), - 0x8012697C:("func_8012697C",), + 0x80126808:("Player_DrawGetItemImpl",), + 0x8012697C:("Player_DrawGetItem",), 0x80126AB4:("func_80126AB4",), 0x80126B8C:("func_80126B8C",), 0x80126BD0:("func_80126BD0",), 0x801271B0:("func_801271B0",), 0x80127438:("func_80127438",), 0x80127488:("func_80127488",), - 0x8012754C:("func_8012754C",), + 0x8012754C:("Player_DrawCouplesMask",), 0x80127594:("func_80127594",), 0x801278F8:("func_801278F8",), 0x80127A60:("func_80127A60",), @@ -3109,7 +3109,7 @@ 0x80172B3C:("THA_Init",), 0x80172B58:("THA_Ct",), 0x80172B9C:("THA_Dt",), - 0x80172BC0:("func_80172BC0",), + 0x80172BC0:("AudioMgr_StopAllSfxExceptSystem",), 0x80172C30:("func_80172C30",), 0x80172C68:("AudioMgr_HandleRetrace",), 0x80172EAC:("AudioMgr_HandlePRENMI",), @@ -3767,41 +3767,41 @@ 0x80197138:("AudioEffects_NotePortamentoInit",), 0x80197164:("AudioEffects_AdsrInit",), 0x80197188:("AudioEffects_AdsrUpdate",), - 0x801974D0:("func_801974D0",), - 0x80197538:("func_80197538",), - 0x80197714:("func_80197714",), - 0x80197880:("func_80197880",), - 0x801979D8:("func_801979D8",), - 0x80197A54:("func_80197A54",), + 0x801974D0:("AudioSeq_GetScriptControlFlowArgument",), + 0x80197538:("AudioSeq_HandleScriptFlowControl",), + 0x80197714:("AudioSeq_InitSequenceChannel",), + 0x80197880:("AudioSeq_SeqChannelSetLayer",), + 0x801979D8:("AudioSeq_SeqLayerDisable",), + 0x80197A54:("AudioSeq_SeqLayerFree",), 0x80197AA4:("AudioSeq_SequenceChannelDisable",), - 0x80197B14:("func_80197B14",), - 0x80197C0C:("func_80197C0C",), - 0x80197C8C:("func_80197C8C",), + 0x80197B14:("AudioSeq_SequencePlayerSetupChannels",), + 0x80197C0C:("AudioSeq_SequencePlayerDisableChannels",), + 0x80197C8C:("AudioSeq_SequenceChannelEnable",), 0x80197D24:("AudioSeq_SequencePlayerDisableAsFinished",), 0x80197D4C:("AudioSeq_SequencePlayerDisable",), 0x80197E08:("AudioSeq_AudioListPushBack",), 0x80197E48:("AudioSeq_AudioListPopBack",), - 0x80197E88:("func_80197E88",), - 0x80197F28:("func_80197F28",), - 0x80197F3C:("func_80197F3C",), - 0x80197F74:("func_80197F74",), - 0x80197FB4:("func_80197FB4",), - 0x801980D0:("func_801980D0",), - 0x8019815C:("func_8019815C",), - 0x8019825C:("func_8019825C",), - 0x80198640:("func_80198640",), - 0x80198CE0:("func_80198CE0",), - 0x801990F4:("func_801990F4",), - 0x80199124:("func_80199124",), - 0x80199198:("func_80199198",), - 0x80199244:("func_80199244",), - 0x80199268:("func_80199268",), - 0x8019A0BC:("func_8019A0BC",), - 0x8019AA3C:("func_8019AA3C",), - 0x8019AAF0:("func_8019AAF0",), + 0x80197E88:("AudioSeq_InitLayerFreelist",), + 0x80197F28:("AudioSeq_ScriptReadU8",), + 0x80197F3C:("AudioSeq_ScriptReadS16",), + 0x80197F74:("AudioSeq_ScriptReadCompressedU16",), + 0x80197FB4:("AudioSeq_SeqLayerProcessScript",), + 0x801980D0:("AudioSeq_SeqLayerProcessScriptStep1",), + 0x8019815C:("AudioSeq_SeqLayerProcessScriptStep5",), + 0x8019825C:("AudioSeq_SeqLayerProcessScriptStep2",), + 0x80198640:("AudioSeq_SeqLayerProcessScriptStep4",), + 0x80198CE0:("AudioSeq_SeqLayerProcessScriptStep3",), + 0x801990F4:("AudioSeq_SetChannelPriorities",), + 0x80199124:("AudioSeq_GetInstrument",), + 0x80199198:("AudioSeq_SetInstrument",), + 0x80199244:("AudioSeq_SequenceChannelSetVolume",), + 0x80199268:("AudioSeq_SequenceChannelProcessScript",), + 0x8019A0BC:("AudioSeq_SequencePlayerProcessSequence",), + 0x8019AA3C:("AudioSeq_ProcessSequences",), + 0x8019AAF0:("AudioSeq_SkipForwardSequence",), 0x8019AB40:("AudioSeq_ResetSequencePlayer",), 0x8019AC10:("AudioSeq_InitSequencePlayerChannels",), - 0x8019ACEC:("func_8019ACEC",), + 0x8019ACEC:("AudioSeq_InitSequencePlayer",), 0x8019ADBC:("AudioSeq_InitSequencePlayers",), 0x8019AE40:("func_8019AE40",), 0x8019AEC0:("func_8019AEC0",), @@ -5803,9 +5803,9 @@ 0x808AACE0:("EnOssan_WaitForBlink",), 0x808AAD14:("EnOssan_Blink",), 0x808AADB4:("EnOssan_CuriosityShopMan_Init",), - 0x808AAE1C:("EnOssan_PartTimeWorker_Init",), + 0x808AAE1C:("EnOssan_PartTimer_Init",), 0x808AAE84:("EnOssan_CuriosityShopMan_GetWelcome",), - 0x808AAFB0:("EnOssan_PartTimerWorker_GetWelcome",), + 0x808AAFB0:("EnOssan_PartTimer_GetWelcome",), 0x808AB0B0:("EnOssan_SetHaveMet",), 0x808AB16C:("EnOssan_InitShop",), 0x808AB404:("EnOssan_GetCutscenes",), @@ -5814,11 +5814,11 @@ 0x808AB78C:("EnOssan_DrawTextRec",), 0x808AB928:("EnOssan_DrawStickDirectionPrompts",), 0x808ABCD0:("EnOssan_CuriosityShopMan_OverrideLimbDraw",), - 0x808ABD10:("EnOssan_PartTimeWorker_OverrideLimbDraw",), + 0x808ABD10:("EnOssan_PartTimer_OverrideLimbDraw",), 0x808ABD60:("EnOssan_CuriosityShopMan_PostLimbDraw",), - 0x808ABE18:("EnOssan_PartTimeWorker_PostLimbDraw",), + 0x808ABE18:("EnOssan_PartTimer_PostLimbDraw",), 0x808ABE58:("EnOssan_CuriosityShopMan_Draw",), - 0x808ABF30:("EnOssan_PartTimeWorker_Draw",), + 0x808ABF30:("EnOssan_PartTimer_Draw",), 0x808AC920:("EnFamos_Init",), 0x808ACB08:("EnFamos_Destroy",), 0x808ACB58:("EnFamos_SetupAttackDebris",), @@ -7074,44 +7074,44 @@ 0x809294B0:("ObjTsubo_Draw",), 0x80929910:("EnIk_Init",), 0x80929A98:("EnIk_Destroy",), - 0x80929AF8:("func_80929AF8",), - 0x80929B6C:("func_80929B6C",), - 0x80929BEC:("func_80929BEC",), - 0x80929C80:("func_80929C80",), - 0x80929D04:("func_80929D04",), - 0x80929E2C:("func_80929E2C",), - 0x80929E88:("func_80929E88",), - 0x80929F20:("func_80929F20",), - 0x80929FC8:("func_80929FC8",), - 0x8092A020:("func_8092A020",), - 0x8092A124:("func_8092A124",), - 0x8092A188:("func_8092A188",), - 0x8092A28C:("func_8092A28C",), - 0x8092A33C:("func_8092A33C",), - 0x8092A570:("func_8092A570",), - 0x8092A5BC:("func_8092A5BC",), - 0x8092A680:("func_8092A680",), - 0x8092A754:("func_8092A754",), - 0x8092A8D8:("func_8092A8D8",), - 0x8092A994:("func_8092A994",), - 0x8092AA6C:("func_8092AA6C",), - 0x8092AB14:("func_8092AB14",), - 0x8092AB50:("func_8092AB50",), - 0x8092ABD8:("func_8092ABD8",), - 0x8092AC4C:("func_8092AC4C",), - 0x8092ACFC:("func_8092ACFC",), - 0x8092ADB4:("func_8092ADB4",), - 0x8092AE14:("func_8092AE14",), - 0x8092AFB4:("func_8092AFB4",), - 0x8092AFD4:("func_8092AFD4",), - 0x8092B03C:("func_8092B03C",), - 0x8092B098:("func_8092B098",), - 0x8092B1B4:("func_8092B1B4",), - 0x8092B46C:("func_8092B46C",), + 0x80929AF8:("EnIk_Freeze",), + 0x80929B6C:("EnIk_Thaw",), + 0x80929BEC:("EnIk_HitArmor",), + 0x80929C80:("EnIk_IsChangingAction",), + 0x80929D04:("EnIk_ChooseAttack",), + 0x80929E2C:("EnIk_CheckActions",), + 0x80929E88:("EnIk_SetupIdle",), + 0x80929F20:("EnIk_Idle",), + 0x80929FC8:("EnIk_SetupWalk",), + 0x8092A020:("EnIk_WalkTowardsPlayer",), + 0x8092A124:("EnIk_SetupRun",), + 0x8092A188:("EnIk_RunTowardsPlayer",), + 0x8092A28C:("EnIk_SetupVerticalAttack",), + 0x8092A33C:("EnIk_VerticalAttack",), + 0x8092A570:("EnIk_SetupTakeOutAxe",), + 0x8092A5BC:("EnIk_TakeOutAxe",), + 0x8092A680:("EnIk_SetupHorizontalDoubleAttack",), + 0x8092A754:("EnIk_HorizontalDoubleAttack",), + 0x8092A8D8:("EnIk_SetupSingleHorizontalAttack",), + 0x8092A994:("EnIk_SingleHorizontalAttack",), + 0x8092AA6C:("EnIk_SetupEndHorizontalAttack",), + 0x8092AB14:("EnIk_EndHorizontalAttack",), + 0x8092AB50:("EnIk_SetupBlock",), + 0x8092ABD8:("EnIk_Block",), + 0x8092AC4C:("EnIk_SetupReactToAttack",), + 0x8092ACFC:("EnIk_ReactToAttack",), + 0x8092ADB4:("EnIk_SetupDie",), + 0x8092AE14:("EnIk_Die",), + 0x8092AFB4:("EnIk_SetupFrozen",), + 0x8092AFD4:("EnIk_Frozen",), + 0x8092B03C:("EnIk_SetupCutscene",), + 0x8092B098:("EnIk_PlayCutscene",), + 0x8092B1B4:("EnIk_UpdateDamage",), + 0x8092B46C:("EnIk_UpdateArmor",), 0x8092B5FC:("EnIk_Update",), - 0x8092B900:("func_8092B900",), - 0x8092B93C:("func_8092B93C",), - 0x8092BC6C:("func_8092BC6C",), + 0x8092B900:("EnIk_OverrideLimbDraw",), + 0x8092B93C:("EnIk_PostLimbDraw",), + 0x8092BC6C:("EnIk_UpdateArmorDraw",), 0x8092BE14:("EnIk_Draw",), 0x8092C530:("DemoShd_Init",), 0x8092C540:("DemoShd_Destroy",), @@ -8145,8 +8145,8 @@ 0x80978B68:("EffectSsBlast_Update",), 0x80978C30:("EffectSsGSpk_Init",), 0x80978D70:("EffectSsGSpk_Draw",), - 0x80978F40:("func_80978F40",), - 0x80979068:("func_80979068",), + 0x80978F40:("EffectSsGSpk_Update",), + 0x80979068:("EffectSsGSpk_UpdateNoAccel",), 0x809791B0:("func_809791B0",), 0x80979228:("EffectSsDFire_Init",), 0x8097930C:("EffectSsDFire_Draw",), @@ -8155,7 +8155,7 @@ 0x80979738:("EffectSsBubble_Draw",), 0x8097985C:("EffectSsBubble_Update",), 0x80979B30:("EffectSsGRipple_Init",), - 0x80979C38:("func_80979C38",), + 0x80979C38:("EffectSsGRipple_DrawRipple",), 0x80979E48:("EffectSsGRipple_Draw",), 0x80979E80:("EffectSsGRipple_Update",), 0x8097A050:("EffectSsGSplash_Init",), @@ -8171,10 +8171,10 @@ 0x8097AD60:("EffectSsDtBubble_Init",), 0x8097AF50:("EffectSsDtBubble_Draw",), 0x8097B160:("EffectSsDtBubble_Update",), - 0x8097B270:("func_8097B270",), + 0x8097B270:("EffectSsHahen_CheckForObject",), 0x8097B2E4:("EffectSsHahen_Init",), - 0x8097B424:("func_8097B424",), - 0x8097B504:("func_8097B504",), + 0x8097B424:("EffectSsHahen_DrawOpa",), + 0x8097B504:("EffectSsHahen_DrawXlu",), 0x8097B5E4:("EffectSsHahen_Draw",), 0x8097B708:("EffectSsHahen_Update",), 0x8097B810:("EffectSsStick_Init",), @@ -8305,49 +8305,49 @@ 0x80987A3C:("OceffWipe3_Destroy",), 0x80987A70:("OceffWipe3_Update",), 0x80987AD0:("OceffWipe3_Draw",), - 0x80989140:("func_80989140",), - 0x80989204:("func_80989204",), - 0x8098933C:("func_8098933C",), - 0x80989418:("func_80989418",), - 0x809895B4:("func_809895B4",), - 0x80989674:("func_80989674",), - 0x80989864:("func_80989864",), - 0x80989974:("func_80989974",), - 0x809899C8:("func_809899C8",), - 0x80989A08:("func_80989A08",), - 0x80989A48:("func_80989A48",), - 0x80989A9C:("func_80989A9C",), - 0x80989ADC:("func_80989ADC",), - 0x80989BF8:("func_80989BF8",), - 0x80989D38:("func_80989D38",), - 0x80989E18:("func_80989E18",), - 0x80989FC8:("func_80989FC8",), - 0x8098A064:("func_8098A064",), - 0x8098A1B4:("func_8098A1B4",), - 0x8098A234:("func_8098A234",), - 0x8098A468:("func_8098A468",), - 0x8098A55C:("func_8098A55C",), - 0x8098A618:("func_8098A618",), - 0x8098A70C:("func_8098A70C",), - 0x8098A89C:("func_8098A89C",), - 0x8098A938:("func_8098A938",), - 0x8098AAAC:("func_8098AAAC",), - 0x8098AB48:("func_8098AB48",), - 0x8098AC34:("func_8098AC34",), - 0x8098AE58:("func_8098AE58",), - 0x8098AF44:("func_8098AF44",), - 0x8098AF98:("func_8098AF98",), - 0x8098B004:("func_8098B004",), - 0x8098B198:("func_8098B198",), - 0x8098B28C:("func_8098B28C",), - 0x8098B390:("func_8098B390",), - 0x8098B464:("func_8098B464",), - 0x8098B560:("func_8098B560",), - 0x8098B88C:("func_8098B88C",), - 0x8098BA64:("func_8098BA64",), - 0x8098BB10:("func_8098BB10",), - 0x8098BBEC:("func_8098BBEC",), - 0x8098BC54:("func_8098BC54",), + 0x80989140:("EnDg_ChangeAnimation",), + 0x80989204:("EnDg_UpdateCollision",), + 0x8098933C:("EnDg_GetFloorRot",), + 0x80989418:("EnDg_HasReachedPoint",), + 0x809895B4:("EnDg_GetYRotation",), + 0x80989674:("EnDg_MoveAlongPath",), + 0x80989864:("EnDg_SpawnFloorDustRing",), + 0x80989974:("EnDg_PlaySfxWalk",), + 0x809899C8:("EnDg_PlaySfxBark",), + 0x80989A08:("EnDg_PlaySfxAngryBark",), + 0x80989A48:("EnDg_PlaySfxWhine",), + 0x80989A9C:("EnDg_PlaySfxGrowl",), + 0x80989ADC:("EnDg_SetupIdleMove",), + 0x80989BF8:("EnDg_UpdateTextId",), + 0x80989D38:("EnDg_StartTextBox",), + 0x80989E18:("EnDg_TryPickUp",), + 0x80989FC8:("EnDg_FindFollowerForBremenMask",), + 0x8098A064:("EnDg_CheckForBremenMaskMarch",), + 0x8098A1B4:("EnDg_ShouldReactToNonHumanPlayer",), + 0x8098A234:("EnDg_ChooseActionForForm",), + 0x8098A468:("EnDg_IdleMove",), + 0x8098A55C:("EnDg_IdleBark",), + 0x8098A618:("EnDg_BackAwayFromGoron",), + 0x8098A70C:("EnDg_RunAwayFromGoron",), + 0x8098A89C:("EnDg_BarkAtGoron",), + 0x8098A938:("EnDg_ApproachPlayerToAttack",), + 0x8098AAAC:("EnDg_RunAfterAttacking",), + 0x8098AB48:("EnDg_SitNextToPlayer",), + 0x8098AC34:("EnDg_JumpAttack",), + 0x8098AE58:("EnDg_WalkToPlayer",), + 0x8098AF44:("EnDg_SetupBremenMaskApproachPlayer",), + 0x8098AF98:("EnDg_Fall",), + 0x8098B004:("EnDg_ApproachPlayer",), + 0x8098B198:("EnDg_SlowlyBackUpBeforeAttacking",), + 0x8098B28C:("EnDg_BackAwayFromPlayer",), + 0x8098B390:("EnDg_BarkAtPlayer",), + 0x8098B464:("EnDg_SetupSwim",), + 0x8098B560:("EnDg_Swim",), + 0x8098B88C:("EnDg_JumpOutOfWater",), + 0x8098BA64:("EnDg_Held",), + 0x8098BB10:("EnDg_Thrown",), + 0x8098BBEC:("EnDg_SetupTalk",), + 0x8098BC54:("EnDg_Talk",), 0x8098BCA8:("EnDg_Init",), 0x8098BE18:("EnDg_Destroy",), 0x8098BE44:("EnDg_Update",), @@ -8830,7 +8830,7 @@ 0x809AC7F8:("func_809AC7F8",), 0x809AC970:("func_809AC970",), 0x809AC9B8:("BgFireWall_Update",), - 0x809ACB28:("func_809ACB28",), + 0x809ACB28:("BgFireWall_Draw",), 0x809ACD90:("EnBu_Init",), 0x809ACDA8:("EnBu_Destroy",), 0x809ACDB8:("EnBu_DoNothing",), @@ -9295,9 +9295,9 @@ 0x809DA1D0:("func_809DA1D0",), 0x809DA22C:("func_809DA22C",), 0x809DA24C:("func_809DA24C",), - 0x809DA264:("func_809DA264",), - 0x809DA344:("func_809DA344",), - 0x809DA460:("func_809DA460",), + 0x809DA264:("Boss02_SpawnEffectSand",), + 0x809DA344:("Boss02_SpawnEffectFragment",), + 0x809DA460:("Boss02_SpawnEffectFlash",), 0x809DA50C:("func_809DA50C",), 0x809DA5AC:("Boss02_Init",), 0x809DAA64:("Boss02_Destroy",), @@ -9306,13 +9306,13 @@ 0x809DAAA8:("func_809DAAA8",), 0x809DAB78:("func_809DAB78",), 0x809DBFB4:("func_809DBFB4",), - 0x809DC218:("func_809DC218",), - 0x809DC320:("Boss02_Update",), - 0x809DC78C:("func_809DC78C",), - 0x809DCA00:("Boss02_Draw",), - 0x809DD0A8:("func_809DD0A8",), - 0x809DD0CC:("func_809DD0CC",), - 0x809DD2F8:("func_809DD2F8",), + 0x809DC218:("Boss02_Tail_Update",), + 0x809DC320:("Boss02_Twinmold_Update",), + 0x809DC78C:("Boss02_Static_Update",), + 0x809DCA00:("Boss02_Twinmold_Draw",), + 0x809DD0A8:("Boss02_Static_Draw",), + 0x809DD0CC:("Boss02_UpdateEffects",), + 0x809DD2F8:("Boss02_DrawEffects",), 0x809DD934:("func_809DD934",), 0x809DEAC4:("func_809DEAC4",), 0x809E2760:("Boss03_PlayUnderwaterSfx",), @@ -10416,19 +10416,19 @@ 0x80A43274:("EnTest4_Update",), 0x80A434E0:("EnBat_Init",), 0x80A437A0:("EnBat_Destroy",), - 0x80A437CC:("func_80A437CC",), - 0x80A43810:("func_80A43810",), - 0x80A43870:("func_80A43870",), - 0x80A438D4:("func_80A438D4",), - 0x80A438F8:("func_80A438F8",), - 0x80A4392C:("func_80A4392C",), - 0x80A43CA0:("func_80A43CA0",), - 0x80A43CE8:("func_80A43CE8",), - 0x80A43F60:("func_80A43F60",), - 0x80A44114:("func_80A44114",), - 0x80A44294:("func_80A44294",), - 0x80A4431C:("func_80A4431C",), - 0x80A443D8:("func_80A443D8",), + 0x80A437CC:("EnBat_IsGraveyardOnSecondDay",), + 0x80A43810:("EnBat_StepAnimation",), + 0x80A43870:("EnBat_SetupPerch",), + 0x80A438D4:("EnBat_Perch",), + 0x80A438F8:("EnBat_SetupFlyIdle",), + 0x80A4392C:("EnBat_FlyIdle",), + 0x80A43CA0:("EnBat_SetupDiveAttack",), + 0x80A43CE8:("EnBat_DiveAttack",), + 0x80A43F60:("EnBat_SetupDie",), + 0x80A44114:("EnBat_Die",), + 0x80A44294:("EnBat_SetupStunned",), + 0x80A4431C:("EnBat_Stunned",), + 0x80A443D8:("EnBat_UpdateDamage",), 0x80A444B8:("EnBat_Update",), 0x80A44818:("EnBat_Draw",), 0x80A44C80:("EnSekihi_Init",), @@ -10436,9 +10436,9 @@ 0x80A44DE8:("func_80A44DE8",), 0x80A44F40:("func_80A44F40",), 0x80A450B0:("func_80A450B0",), - 0x80A45130:("func_80A45130",), + 0x80A45130:("EnSekihi_DoNothing",), 0x80A45140:("EnSekihi_Update",), - 0x80A45164:("func_80A45164",), + 0x80A45164:("EnSekihi_Draw",), 0x80A45360:("EnWiz_Init",), 0x80A45568:("EnWiz_Destroy",), 0x80A455C4:("func_80A455C4",), @@ -10491,10 +10491,10 @@ 0x80A4BF78:("func_80A4BF78",), 0x80A4C490:("EffChange_Init",), 0x80A4C54C:("EffChange_Destroy",), - 0x80A4C578:("func_80A4C578",), + 0x80A4C578:("EffChange_SetColors",), 0x80A4C5CC:("func_80A4C5CC",), 0x80A4C78C:("EffChange_Update",), - 0x80A4C7B0:("func_80A4C7B0",), + 0x80A4C7B0:("EffChange_Draw",), 0x80A4C9B0:("DmStatue_Init",), 0x80A4C9D4:("DmStatue_Destroy",), 0x80A4C9E4:("DmStatue_Update",), @@ -10515,10 +10515,10 @@ 0x80A4D6A4:("ObjFireshield_Draw",), 0x80A4D9F0:("BgLadder_Init",), 0x80A4DB54:("BgLadder_Destroy",), - 0x80A4DB88:("BgLadder_ActionWait",), - 0x80A4DBD8:("BgLadder_ActionStartCutscene",), - 0x80A4DC48:("BgLadder_ActionFadeIn",), - 0x80A4DCCC:("BgLadder_ActionIdle",), + 0x80A4DB88:("BgLadder_Wait",), + 0x80A4DBD8:("BgLadder_StartCutscene",), + 0x80A4DC48:("BgLadder_FadeIn",), + 0x80A4DCCC:("BgLadder_DoNothing",), 0x80A4DCDC:("BgLadder_Update",), 0x80A4DD00:("BgLadder_Draw",), 0x80A4DED0:("EnMkk_Init",), @@ -10549,7 +10549,7 @@ 0x80A4FB10:("func_80A4FB10",), 0x80A4FB68:("func_80A4FB68",), 0x80A4FCCC:("DemoGetitem_Update",), - 0x80A4FCF0:("func_80A4FCF0",), + 0x80A4FCF0:("DemoGetitem_Draw",), 0x80A4FDD0:("func_80A4FDD0",), 0x80A4FEBC:("func_80A4FEBC",), 0x80A4FFE8:("func_80A4FFE8",), @@ -10749,7 +10749,7 @@ 0x80A60DA0:("func_80A60DA0",), 0x80A60E08:("func_80A60E08",), 0x80A60F68:("BgSpoutFire_Update",), - 0x80A61040:("func_80A61040",), + 0x80A61040:("BgSpoutFire_Draw",), 0x80A612B0:("EnDyExtra_Destroy",), 0x80A612C0:("EnDyExtra_Init",), 0x80A61334:("func_80A61334",), @@ -11197,8 +11197,8 @@ 0x80A83FBC:("func_80A83FBC",), 0x80A84088:("func_80A84088",), 0x80A84338:("func_80A84338",), - 0x80A84CD0:("func_80A84CD0",), - 0x80A84CF8:("func_80A84CF8",), + 0x80A84CD0:("ObjPurify_SetSysMatrix",), + 0x80A84CF8:("ObjPurify_IsPurified",), 0x80A84D68:("ObjPurify_Init",), 0x80A84E68:("ObjPurify_Destroy",), 0x80A84EAC:("func_80A84EAC",), @@ -11212,7 +11212,7 @@ 0x80A850B0:("func_80A850B0",), 0x80A850E8:("func_80A850E8",), 0x80A8515C:("func_80A8515C",), - 0x80A85194:("func_80A85194",), + 0x80A85194:("ObjPurify_DoNothing",), 0x80A851A4:("ObjPurify_Update",), 0x80A851C8:("func_80A851C8",), 0x80A85304:("func_80A85304",), @@ -11547,7 +11547,7 @@ 0x80AA90F4:("func_80AA90F4",), 0x80AA9140:("DmChar01_Update",), 0x80AA922C:("DmChar01_Draw",), - 0x80AAAE30:("func_80AAAE30",), + 0x80AAAE30:("DmChar02_ChangeAnimationByInfo",), 0x80AAAECC:("func_80AAAECC",), 0x80AAAF2C:("func_80AAAF2C",), 0x80AAAF78:("DmChar02_Init",), @@ -11572,12 +11572,12 @@ 0x80AAB9A8:("func_80AAB9A8",), 0x80AAB9BC:("DmChar03_Draw",), 0x80AABA84:("func_80AABA84",), - 0x80AABC40:("func_80AABC40",), + 0x80AABC40:("DmChar04_ChangeAnim",), 0x80AABCDC:("DmChar04_Init",), 0x80AABE24:("DmChar04_Destroy",), 0x80AABE34:("func_80AABE34",), 0x80AABF28:("DmChar04_Update",), - 0x80AABF74:("func_80AABF74",), + 0x80AABF74:("DmChar04_OverrideLimbDraw",), 0x80AAC03C:("DmChar04_Draw",), 0x80AAC5A0:("func_80AAC5A0",), 0x80AAC63C:("func_80AAC63C",), @@ -12387,14 +12387,14 @@ 0x80AE0FA8:("EnTsn_OverrideLimbDraw",), 0x80AE1024:("EnTsn_PostLimbDraw",), 0x80AE1080:("EnTsn_Draw",), - 0x80AE1650:("func_80AE1650",), - 0x80AE16A0:("func_80AE16A0",), - 0x80AE16D8:("func_80AE16D8",), + 0x80AE1650:("EnDs2n_SetupIdle",), + 0x80AE16A0:("EnDs2n_Idle",), + 0x80AE16D8:("EnDs2n_UpdateEyes",), 0x80AE1760:("EnDs2n_Init",), 0x80AE17D0:("EnDs2n_Destroy",), 0x80AE17F4:("EnDs2n_Update",), - 0x80AE1874:("func_80AE1874",), - 0x80AE18B4:("func_80AE18B4",), + 0x80AE1874:("EnDs2n_OverrideLimbDraw",), + 0x80AE18B4:("EnDs2n_PostLimbDraw",), 0x80AE19B8:("EnDs2n_Draw",), 0x80AE1B70:("EnFsn_TestItemSelected",), 0x80AE1BF0:("EnFsn_GetWelcome",), @@ -12791,7 +12791,7 @@ 0x80AFD380:("func_80AFD380",), 0x80AFD4B8:("ElfMsg4_Init",), 0x80AFD5A4:("ElfMsg4_Destroy",), - 0x80AFD5B4:("func_80AFD5B4",), + 0x80AFD5B4:("ElfMsg4_GetTextId",), 0x80AFD5E0:("func_80AFD5E0",), 0x80AFD668:("func_80AFD668",), 0x80AFD770:("func_80AFD770",), @@ -13293,7 +13293,7 @@ 0x80B25448:("EnRacedog_UpdateRunAnimationPlaySpeed",), 0x80B25490:("EnRacedog_IsOverFinishLine",), 0x80B255AC:("EnRacedog_SpawnFloorDustRing",), - 0x80B256BC:("EnRacedog_PlayWalkSfx",), + 0x80B256BC:("EnRacedog_PlaySfxWalk",), 0x80B25708:("EnRacedog_Update",), 0x80B2583C:("EnRacedog_UpdateSelectionArrow",), 0x80B258D8:("EnRacedog_DrawSelectionArrow",), @@ -14005,7 +14005,7 @@ 0x80B529E4:("EnGk_Update",), 0x80B52AD4:("EnGk_OverrideLimbDraw",), 0x80B52AF0:("EnGk_PostLimbDraw",), - 0x80B52D8C:("EnGk_TransformDraw",), + 0x80B52D8C:("EnGk_TransformLimbDraw",), 0x80B52F74:("EnGk_Draw",), 0x80B53840:("func_80B53840",), 0x80B539CC:("func_80B539CC",), @@ -14137,7 +14137,7 @@ 0x80B5EE3C:("EnDragon_RetreatOrIdle",), 0x80B5EF88:("EnDragon_SetupExtend",), 0x80B5EFD0:("EnDragon_Extend",), - 0x80B5F3A4:("EnDragon_CameraSetAtEye",), + 0x80B5F3A4:("EnDragon_SetSubCamEyeAt",), 0x80B5F418:("EnDragon_SetupGrab",), 0x80B5F508:("EnDragon_Grab",), 0x80B5F888:("EnDragon_SetupAttack",), @@ -14574,13 +14574,13 @@ 0x80B7F398:("func_80B7F398",), 0x80B7F474:("BgIkanaBlock_Update",), 0x80B7F564:("func_80B7F564",), - 0x80B7F730:("func_80B7F730",), + 0x80B7F730:("BgIkanaMirror_SetQuadVertices",), 0x80B7F850:("BgIkanaMirror_Init",), 0x80B7FA00:("BgIkanaMirror_Destroy",), - 0x80B7FA84:("func_80B7FA84",), - 0x80B7FA9C:("func_80B7FA9C",), - 0x80B7FB84:("func_80B7FB84",), - 0x80B7FBA4:("func_80B7FBA4",), + 0x80B7FA84:("BgIkanaMirror_SetupWait",), + 0x80B7FA9C:("BgIkanaMirror_Wait",), + 0x80B7FB84:("BgIkanaMirror_SetupEmitLight",), + 0x80B7FBA4:("BgIkanaMirror_EmitLight",), 0x80B7FCB8:("BgIkanaMirror_Update",), 0x80B7FCDC:("BgIkanaMirror_Draw",), 0x80B802E0:("func_80B802E0",), @@ -15168,27 +15168,27 @@ 0x80BA7D30:("EnRailgibud_SinkIntoGround",), 0x80BA7DC8:("EnRailgibud_PerformCutsceneActions",), 0x80BA8050:("EnRailgibud_Cutscene_Update",), - 0x80BA8820:("func_80BA8820",), - 0x80BA886C:("func_80BA886C",), - 0x80BA8C4C:("func_80BA8C4C",), - 0x80BA8C90:("func_80BA8C90",), - 0x80BA8D2C:("func_80BA8D2C",), - 0x80BA8DF4:("func_80BA8DF4",), - 0x80BA8F88:("func_80BA8F88",), - 0x80BA9110:("func_80BA9110",), - 0x80BA9160:("func_80BA9160",), - 0x80BA93AC:("func_80BA93AC",), - 0x80BA9480:("func_80BA9480",), - 0x80BA9758:("func_80BA9758",), - 0x80BA9848:("func_80BA9848",), - 0x80BA98EC:("func_80BA98EC",), - 0x80BA9AB8:("func_80BA9AB8",), - 0x80BA9B24:("func_80BA9B24",), - 0x80BA9B80:("func_80BA9B80",), - 0x80BA9CD4:("func_80BA9CD4",), - 0x80BA9E00:("func_80BA9E00",), - 0x80BA9E10:("func_80BA9E10",), - 0x80BA9E48:("func_80BA9E48",), + 0x80BA8820:("EnBaba_FindBombShopkeeper",), + 0x80BA886C:("EnBaba_HandleConversation",), + 0x80BA8C4C:("EnBaba_TriggerTransition",), + 0x80BA8C90:("EnBaba_UpdateCollider",), + 0x80BA8D2C:("EnBaba_MoveForward",), + 0x80BA8DF4:("EnBaba_UpdateModel",), + 0x80BA8F88:("EnBaba_InitTimePath",), + 0x80BA9110:("EnBaba_ProcessScheduleOutput",), + 0x80BA9160:("EnBaba_FollowTimePath",), + 0x80BA93AC:("EnBaba_HandleSchedule",), + 0x80BA9480:("EnBaba_FinishInit",), + 0x80BA9758:("EnBaba_Idle",), + 0x80BA9848:("EnBaba_FollowSchedule_Talk",), + 0x80BA98EC:("EnBaba_Talk",), + 0x80BA9AB8:("EnBaba_GiveBlastMask",), + 0x80BA9B24:("EnBaba_GaveBlastMask",), + 0x80BA9B80:("EnBaba_FollowSchedule",), + 0x80BA9CD4:("EnBaba_KnockedOver",), + 0x80BA9E00:("EnBaba_DoNothing",), + 0x80BA9E10:("EnBaba_Walk",), + 0x80BA9E48:("EnBaba_FaceForward",), 0x80BA9E6C:("EnBaba_Init",), 0x80BA9F24:("EnBaba_Destroy",), 0x80BA9F50:("EnBaba_Update",), @@ -15668,8 +15668,8 @@ 0x80BCED34:("func_80BCED34",), 0x80BCEDE0:("func_80BCEDE0",), 0x80BCEE98:("EffKamejimaWave_Update",), - 0x80BCEEBC:("func_80BCEEBC",), - 0x80BCEF0C:("func_80BCEF0C",), + 0x80BCEEBC:("EffKamejimaWave_SetVtxAlpha",), + 0x80BCEF0C:("EffKamejimaWave_Draw",), 0x80BCF1D0:("EnHg_Init",), 0x80BCF328:("EnHg_Destroy",), 0x80BCF354:("func_80BCF354",), @@ -15830,10 +15830,10 @@ 0x80BD6218:("BgHakaBombwall_Destroy",), 0x80BD6260:("func_80BD6260",), 0x80BD6274:("func_80BD6274",), - 0x80BD62D0:("func_80BD62D0",), - 0x80BD6314:("func_80BD6314",), - 0x80BD63B4:("func_80BD63B4",), - 0x80BD63D0:("func_80BD63D0",), + 0x80BD62D0:("BgHakaBombwall_SetupPlayCutscene",), + 0x80BD6314:("BgHakaBombwall_PlayCutscene",), + 0x80BD63B4:("BgHakaBombwall_SetupEndCutscene",), + 0x80BD63D0:("BgHakaBombwall_EndCutscene",), 0x80BD6420:("BgHakaBombwall_Update",), 0x80BD6444:("BgHakaBombwall_Draw",), 0x80BD6580:("BgHakaTomb_Init",), @@ -16059,7 +16059,7 @@ 0x80BE1550:("EnTab_Update",), 0x80BE1648:("EnTab_OverrideLimbDraw",), 0x80BE16B4:("EnTab_PostLimbDraw",), - 0x80BE1704:("EnTab_TransformDraw",), + 0x80BE1704:("EnTab_TransformLimbDraw",), 0x80BE1810:("EnTab_Draw",), 0x80BE1C80:("func_80BE1C80",), 0x80BE1CEC:("EnNimotsu_Init",), @@ -16218,7 +16218,7 @@ 0x80BEBEB8:("func_80BEBEB8",), 0x80BEBF78:("func_80BEBF78",), 0x80BEC080:("EffLastday_Update",), - 0x80BEC0A4:("func_80BEC0A4",), + 0x80BEC0A4:("EffLastday_SetVtxAlpha",), 0x80BEC0DC:("EffLastday_Draw",), 0x80BEC240:("BgIkanaDharma_SpawnEffects",), 0x80BEC3F4:("BgIkanaDharma_Init",), @@ -16370,12 +16370,12 @@ 0x80BF6C94:("EnOsk_Draw",), 0x80BF74E0:("EnSth2_Init",), 0x80BF7590:("EnSth2_Destroy",), - 0x80BF75A0:("func_80BF75A0",), + 0x80BF75A0:("EnSth2_UpdateSkelAnime",), 0x80BF75CC:("EnSth2_Update",), - 0x80BF7688:("func_80BF7688",), - 0x80BF76AC:("func_80BF76AC",), - 0x80BF77AC:("func_80BF77AC",), - 0x80BF7814:("func_80BF7814",), + 0x80BF7688:("EnSth2_UpdateActionFunc",), + 0x80BF76AC:("EnSth2_OverrideLimbDraw",), + 0x80BF77AC:("EnSth2_PostLimbDraw",), + 0x80BF7814:("EnSth2_Draw",), 0x80BFA100:("EnYb_Init",), 0x80BFA2D0:("EnYb_Destroy",), 0x80BFA2FC:("func_80BFA2FC",), @@ -16436,17 +16436,17 @@ 0x80BFD148:("EnScopecoin_Destroy",), 0x80BFD158:("EnScopecoin_Update",), 0x80BFD17C:("EnScopecoin_Draw",), - 0x80BFD2E0:("func_80BFD2E0",), - 0x80BFD30C:("func_80BFD30C",), - 0x80BFD3A4:("func_80BFD3A4",), - 0x80BFD434:("func_80BFD434",), - 0x80BFD4FC:("func_80BFD4FC",), - 0x80BFD5E4:("func_80BFD5E4",), - 0x80BFD6BC:("func_80BFD6BC",), - 0x80BFD8F0:("func_80BFD8F0",), - 0x80BFD984:("func_80BFD984",), - 0x80BFDA48:("func_80BFDA48",), - 0x80BFDAE8:("func_80BFDAE8",), + 0x80BFD2E0:("EnBjt_UpdateSkelAnime",), + 0x80BFD30C:("EnBjt_ChangeAnimation",), + 0x80BFD3A4:("EnBjt_UpdateCollision",), + 0x80BFD434:("EnBjt_TakeItem",), + 0x80BFD4FC:("EnBjt_Appear",), + 0x80BFD5E4:("EnBjt_Vanish",), + 0x80BFD6BC:("EnBjt_ChooseBehaviour",), + 0x80BFD8F0:("EnBjt_CheckTalk",), + 0x80BFD984:("EnBjt_ChooseAnimation",), + 0x80BFDA48:("EnBjt_Talk",), + 0x80BFDAE8:("EnBjt_FollowSchedule",), 0x80BFDC98:("EnBjt_Init",), 0x80BFDD80:("EnBjt_Destroy",), 0x80BFDD90:("EnBjt_Update",), @@ -16817,7 +16817,7 @@ 0x80C152F0:("ObjJgameLight_Init",), 0x80C1542C:("ObjJgameLight_Destroy",), 0x80C15474:("func_80C15474",), - 0x80C156C4:("func_80C156C4",), + 0x80C156C4:("ObjJgameLight_UpdateCollision",), 0x80C15718:("func_80C15718",), 0x80C157D4:("ObjJgameLight_Update",), 0x80C15828:("ObjJgameLight_Draw",), @@ -16930,14 +16930,14 @@ 0x80C1B9D4:("func_80C1B9D4",), 0x80C1BAC8:("EnFall2_Update",), 0x80C1BAEC:("EnFall2_Draw",), - 0x80C1BD90:("func_80C1BD90",), + 0x80C1BD90:("DmAl_ChangeAnimation",), 0x80C1BDD8:("func_80C1BDD8",), 0x80C1BF08:("DmAl_Init",), 0x80C1BFB8:("DmAl_Destroy",), 0x80C1BFC8:("DmAl_Update",), - 0x80C1C028:("func_80C1C028",), - 0x80C1C064:("func_80C1C064",), - 0x80C1C11C:("func_80C1C11C",), + 0x80C1C028:("DmAl_OverrideLimbDraw",), + 0x80C1C064:("DmAl_PostLimbDraw",), + 0x80C1C11C:("DmAl_TransformLimbDraw",), 0x80C1C130:("DmAl_Draw",), 0x80C1C410:("func_80C1C410",), 0x80C1C4D8:("func_80C1C4D8",), diff --git a/tools/disasm/mips_isa.py b/tools/disasm/mips_isa.py deleted file mode 100644 index 337bbd021..000000000 --- a/tools/disasm/mips_isa.py +++ /dev/null @@ -1,776 +0,0 @@ -# Register IDs -MIPS_REG_R0 = MIPS_REG_F0 = 0 -MIPS_REG_AT = MIPS_REG_F1 = 1 -MIPS_REG_V0 = MIPS_REG_F2 = 2 -MIPS_REG_V1 = MIPS_REG_F3 = 3 -MIPS_REG_A0 = MIPS_REG_F4 = 4 -MIPS_REG_A1 = MIPS_REG_F5 = 5 -MIPS_REG_A2 = MIPS_REG_F6 = 6 -MIPS_REG_A3 = MIPS_REG_F7 = 7 -MIPS_REG_T0 = MIPS_REG_F8 = 8 -MIPS_REG_T1 = MIPS_REG_F9 = 9 -MIPS_REG_T2 = MIPS_REG_F10 = 10 -MIPS_REG_T3 = MIPS_REG_F11 = 11 -MIPS_REG_T4 = MIPS_REG_F12 = 12 -MIPS_REG_T5 = MIPS_REG_F13 = 13 -MIPS_REG_T6 = MIPS_REG_F14 = 14 -MIPS_REG_T7 = MIPS_REG_F15 = 15 -MIPS_REG_S0 = MIPS_REG_F16 = 16 -MIPS_REG_S1 = MIPS_REG_F17 = 17 -MIPS_REG_S2 = MIPS_REG_F18 = 18 -MIPS_REG_S3 = MIPS_REG_F19 = 19 -MIPS_REG_S4 = MIPS_REG_F20 = 20 -MIPS_REG_S5 = MIPS_REG_F21 = 21 -MIPS_REG_S6 = MIPS_REG_F22 = 22 -MIPS_REG_S7 = MIPS_REG_F23 = 23 -MIPS_REG_T8 = MIPS_REG_F24 = 24 -MIPS_REG_T9 = MIPS_REG_F25 = 25 -MIPS_REG_K0 = MIPS_REG_F26 = 26 -MIPS_REG_K1 = MIPS_REG_F27 = 27 -MIPS_REG_GP = MIPS_REG_F28 = 28 -MIPS_REG_SP = MIPS_REG_F29 = 29 -MIPS_REG_FP = MIPS_REG_F30 = 30 -MIPS_REG_RA = MIPS_REG_F31 = 31 - -# Instruction Unique IDs -MIPS_INS_SLL = 0 -MIPS_INS_SRL = 1 -MIPS_INS_SRA = 2 -MIPS_INS_SLLV = 3 -MIPS_INS_SRLV = 4 -MIPS_INS_SRAV = 5 -MIPS_INS_JR = 6 -MIPS_INS_JALR = 7 -MIPS_INS_SYSCALL = 8 -MIPS_INS_BREAK = 9 -MIPS_INS_SYNC = 10 -MIPS_INS_MFHI = 11 -MIPS_INS_MTHI = 12 -MIPS_INS_MFLO = 13 -MIPS_INS_MTLO = 14 -MIPS_INS_DSLLV = 15 -MIPS_INS_DSRLV = 16 -MIPS_INS_DSRAV = 17 -MIPS_INS_MULT = 18 -MIPS_INS_MULTU = 19 -MIPS_INS_DIV = 20 -MIPS_INS_DIVU = 21 -MIPS_INS_DMULT = 22 -MIPS_INS_DMULTU = 23 -MIPS_INS_DDIV = 24 -MIPS_INS_DDIVU = 25 -MIPS_INS_ADD = 26 -MIPS_INS_ADDU = 27 -MIPS_INS_SUB = 28 -MIPS_INS_SUBU = 29 -MIPS_INS_AND = 30 -MIPS_INS_OR = 31 -MIPS_INS_XOR = 32 -MIPS_INS_NOR = 33 -MIPS_INS_SLT = 34 -MIPS_INS_SLTU = 35 -MIPS_INS_DADD = 36 -MIPS_INS_DADDU = 37 -MIPS_INS_DSUB = 38 -MIPS_INS_DSUBU = 39 -MIPS_INS_TGE = 40 -MIPS_INS_TGEU = 41 -MIPS_INS_TLT = 42 -MIPS_INS_TLTU = 43 -MIPS_INS_TEQ = 44 -MIPS_INS_TNE = 45 -MIPS_INS_DSLL = 46 -MIPS_INS_DSRL = 47 -MIPS_INS_DSRA = 48 -MIPS_INS_DSLL32 = 49 -MIPS_INS_DSRL32 = 50 -MIPS_INS_DSRA32 = 51 -MIPS_INS_BLTZ = 52 -MIPS_INS_BGEZ = 53 -MIPS_INS_BLTZL = 54 -MIPS_INS_BGEZL = 55 -MIPS_INS_TGEI = 56 -MIPS_INS_TGEIU = 57 -MIPS_INS_TLTI = 58 -MIPS_INS_TLTIU = 59 -MIPS_INS_TEQI = 60 -MIPS_INS_TNEI = 61 -MIPS_INS_BLTZAL = 62 -MIPS_INS_BGEZAL = 63 -MIPS_INS_BLTZALL = 64 -MIPS_INS_BGEZALL = 65 -MIPS_INS_J = 66 -MIPS_INS_JAL = 67 -MIPS_INS_BEQ = 68 -MIPS_INS_BNE = 69 -MIPS_INS_BLEZ = 70 -MIPS_INS_BGTZ = 71 -MIPS_INS_ADDI = 72 -MIPS_INS_ADDIU = 73 -MIPS_INS_SLTI = 74 -MIPS_INS_SLTIU = 75 -MIPS_INS_ANDI = 76 -MIPS_INS_ORI = 77 -MIPS_INS_XORI = 78 -MIPS_INS_LUI = 79 -MIPS_INS_MFC0 = 80 -MIPS_INS_MTC0 = 81 -MIPS_INS_TLBR = 82 -MIPS_INS_TLBWI = 83 -MIPS_INS_TLBWR = 84 -MIPS_INS_TLBP = 85 -MIPS_INS_ERET = 86 -MIPS_INS_MFC1 = 87 -MIPS_INS_DMFC1 = 88 -MIPS_INS_CFC1 = 89 -MIPS_INS_MTC1 = 90 -MIPS_INS_DMTC1 = 91 -MIPS_INS_CTC1 = 92 -MIPS_INS_BC1F = 93 -MIPS_INS_BC1T = 94 -MIPS_INS_BC1FL = 95 -MIPS_INS_BC1TL = 96 -MIPS_INS_ADD_S = 97 -MIPS_INS_SUB_S = 98 -MIPS_INS_MUL_S = 99 -MIPS_INS_DIV_S = 100 -MIPS_INS_SQRT_S = 101 -MIPS_INS_ABS_S = 102 -MIPS_INS_MOV_S = 103 -MIPS_INS_NEG_S = 104 -MIPS_INS_ROUND_L_S = 105 -MIPS_INS_TRUNC_L_S = 106 -MIPS_INS_CEIL_L_S = 107 -MIPS_INS_FLOOR_L_S = 108 -MIPS_INS_ROUND_W_S = 109 -MIPS_INS_TRUNC_W_S = 110 -MIPS_INS_CEIL_W_S = 111 -MIPS_INS_FLOOR_W_S = 112 -MIPS_INS_CVT_D_S = 113 -MIPS_INS_CVT_W_S = 114 -MIPS_INS_CVT_L_S = 115 -MIPS_INS_C_F_S = 116 -MIPS_INS_C_UN_S = 117 -MIPS_INS_C_EQ_S = 118 -MIPS_INS_C_UEQ_S = 119 -MIPS_INS_C_OLT_S = 120 -MIPS_INS_C_ULT_S = 121 -MIPS_INS_C_OLE_S = 122 -MIPS_INS_C_ULE_S = 123 -MIPS_INS_C_SF_S = 124 -MIPS_INS_C_NGLE_S = 125 -MIPS_INS_C_SEQ_S = 126 -MIPS_INS_C_NGL_S = 127 -MIPS_INS_C_LT_S = 128 -MIPS_INS_C_NGE_S = 129 -MIPS_INS_C_LE_S = 130 -MIPS_INS_C_NGT_S = 131 -MIPS_INS_ADD_D = 132 -MIPS_INS_SUB_D = 133 -MIPS_INS_MUL_D = 134 -MIPS_INS_DIV_D = 135 -MIPS_INS_SQRT_D = 136 -MIPS_INS_ABS_D = 137 -MIPS_INS_MOV_D = 138 -MIPS_INS_NEG_D = 139 -MIPS_INS_ROUND_L_D = 140 -MIPS_INS_TRUNC_L_D = 141 -MIPS_INS_CEIL_L_D = 142 -MIPS_INS_FLOOR_L_D = 143 -MIPS_INS_ROUND_W_D = 144 -MIPS_INS_TRUNC_W_D = 145 -MIPS_INS_CEIL_W_D = 146 -MIPS_INS_FLOOR_W_D = 147 -MIPS_INS_CVT_S_D = 148 -MIPS_INS_CVT_W_D = 149 -MIPS_INS_CVT_L_D = 150 -MIPS_INS_C_F_D = 151 -MIPS_INS_C_UN_D = 152 -MIPS_INS_C_EQ_D = 153 -MIPS_INS_C_UEQ_D = 154 -MIPS_INS_C_OLT_D = 155 -MIPS_INS_C_ULT_D = 156 -MIPS_INS_C_OLE_D = 157 -MIPS_INS_C_ULE_D = 158 -MIPS_INS_C_SF_D = 159 -MIPS_INS_C_NGLE_D = 160 -MIPS_INS_C_SEQ_D = 161 -MIPS_INS_C_NGL_D = 162 -MIPS_INS_C_LT_D = 163 -MIPS_INS_C_NGE_D = 164 -MIPS_INS_C_LE_D = 165 -MIPS_INS_C_NGT_D = 166 -MIPS_INS_CVT_S_W = 167 -MIPS_INS_CVT_D_W = 168 -MIPS_INS_CVT_S_L = 169 -MIPS_INS_CVT_D_L = 170 -MIPS_INS_BEQL = 171 -MIPS_INS_BNEL = 172 -MIPS_INS_BLEZL = 173 -MIPS_INS_BGTZL = 174 -MIPS_INS_DADDI = 175 -MIPS_INS_DADDIU = 176 -MIPS_INS_LDL = 177 -MIPS_INS_LDR = 178 -MIPS_INS_LB = 179 -MIPS_INS_LH = 180 -MIPS_INS_LWL = 181 -MIPS_INS_LW = 182 -MIPS_INS_LBU = 183 -MIPS_INS_LHU = 184 -MIPS_INS_LWR = 185 -MIPS_INS_LWU = 186 -MIPS_INS_SB = 187 -MIPS_INS_SH = 188 -MIPS_INS_SWL = 189 -MIPS_INS_SW = 190 -MIPS_INS_SDL = 191 -MIPS_INS_SDR = 192 -MIPS_INS_SWR = 193 -MIPS_INS_CACHE = 194 -MIPS_INS_LL = 195 -MIPS_INS_LWC1 = 196 -MIPS_INS_LLD = 197 -MIPS_INS_LDC1 = 198 -#MIPS_INS_INVALID = 199 -MIPS_INS_LD = 200 -MIPS_INS_SC = 201 -MIPS_INS_SWC1 = 202 -MIPS_INS_SCD = 203 -MIPS_INS_SDC1 = 204 -MIPS_INS_SD = 206 - -# Pseudo-Instruction Unique IDs -MIPS_INS_BEQZ = 207 -MIPS_INS_BNEZ = 208 -MIPS_INS_B = 209 -MIPS_INS_NOP = 210 -MIPS_INS_MOVE = 211 -MIPS_INS_NEGU = 212 -MIPS_INS_NOT = 213 - -# Invalid Instruction Unique ID -MIPS_INS_INVALID = -1 - -# Op IDs -# MIPS_OP_RS = 0 -# MIPS_OP_RT = 0 -# MIPS_OP_RD = 0 -# MIPS_OP_IMM = 0 - -# Register Names - -mips_gpr_names = [ - "$zero", - "$at", - "$v0", "$v1", - "$a0", "$a1", "$a2", "$a3", - "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", - "$s0", "$s1", "$s2", "$s3", "$s4", "$s5", "$s6", "$s7", - "$t8", "$t9", - "$k0", "$k1", - "$gp", - "$sp", - "$fp", - "$ra", -] - -mips_cop0_names = [ - "Index" , "Random" , "EntryLo0" , "EntryLo1" , - "Context" , "PageMask" , "Wired" , "Reserved07", - "BadVaddr" , "Count" , "EntryHi" , "Compare" , - "Status" , "Cause" , "EPC" , "PRevID" , - "Config" , "LLAddr" , "WatchLo" , "WatchHi" , - "XContext" , "Reserved21", "Reserved22", "Reserved23", - "Reserved24", "Reserved25", "PErr" , "CacheErr" , - "TagLo" , "TagHi" , "ErrorEPC" , "Reserved31", -] - -numeric_fpr_names = [ - "$f0", "$f1", "$f2", "$f3", - "$f4", "$f5", "$f6", "$f7", "$f8", "$f9", "$f10", "$f11", - "$f12", "$f13", "$f14", "$f15", - "$f16", "$f17", "$f18", "$f19", - "$f20", "$f21", "$f22", "$f23", "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", - "$31", # Floating-point control/status register -] - -o32_fpr_names = [ - "$fv0", "$fv0f", "$fv1", "$fv1f", - "$ft0", "$ft0f", "$ft1", "$ft1f", "$ft2", "$ft2f", "$ft3", "$ft3f", - "$fa0", "$fa0f", "$fa1", "$fa1f", - "$ft4", "$ft4f", "$ft5", "$ft5f", - "$fs0", "$fs0f", "$fs1", "$fs1f", "$fs2", "$fs2f", "$fs3", "$fs3f", "$fs4", "$fs4f", "$fs5", - "$31", # Floating-point control/status register -] - -mips_fpr_names = numeric_fpr_names - -# Instruction field fetching - -def sign_extend_16(value): - return (value & 0x7FFF) - (value & 0x8000) - -def mask_shift(v, s, w): - return (v >> s) & ((1 << w) - 1) - -mips_get_field = lambda raw,vaddr : mask_shift(raw, 26, 6) -mips_get_special = lambda raw,vaddr : mask_shift(raw, 0, 6) -mips_get_cop0 = lambda raw,vaddr : mask_shift(raw, 21, 5) -mips_get_cop1 = lambda raw,vaddr : mask_shift(raw, 21, 5) -mips_get_regimm = lambda raw,vaddr : mask_shift(raw, 16, 5) -mips_get_tlb = lambda raw,vaddr : mask_shift(raw, 0, 5) -mips_get_function = lambda raw,vaddr : mask_shift(raw, 0, 6) - -mips_get_cond = lambda raw,vaddr : mask_shift(raw, 0, 4) -mips_get_fc = lambda raw,vaddr : mask_shift(raw, 2, 2) -mips_get_fd = lambda raw,vaddr : mask_shift(raw, 6, 5) -mips_get_fs = lambda raw,vaddr : mask_shift(raw, 11, 5) -mips_get_ft = lambda raw,vaddr : mask_shift(raw, 16, 5) -mips_get_fmt = lambda raw,vaddr : mask_shift(raw, 21, 5) -mips_get_ndtf = lambda raw,vaddr : mask_shift(raw, 16, 2) - -mips_get_target = lambda raw,vaddr : (0x80000000 | (mask_shift(raw, 0, 26) << 2)) -mips_get_offset = lambda raw,vaddr : vaddr + 4 + sign_extend_16(mask_shift(raw, 0, 16)) * 4 -mips_get_imm = lambda raw,vaddr : mask_shift(raw, 0, 16) - -mips_get_base = lambda raw,vaddr : mask_shift(raw, 21, 5) - -mips_get_cd = lambda raw,vaddr : mask_shift(raw, 11, 5) - -mips_get_code = lambda raw,vaddr : (mask_shift(raw, 6, 20) << 6) >> 16 -mips_get_op = lambda raw,vaddr : mask_shift(raw, 16, 5) - -mips_get_sa = lambda raw,vaddr : mask_shift(raw, 6, 5) - -mips_get_rd = lambda raw,vaddr : mask_shift(raw, 11, 5) -mips_get_rs = lambda raw,vaddr : mask_shift(raw, 21, 5) -mips_get_rt = lambda raw,vaddr : mask_shift(raw, 16, 5) - -# Formatting - -class MipsInsn: - - def __init__(self, raw, vaddr, values): - self.raw = raw - self.vaddr = vaddr - - if values is None: - values = MIPS_INS_INVALID, f"/* Invalid Instruction: 0x{raw:08X} */", () - - self.id, self.mnemonic, self.fields = values - - self.code = self.sa = self.op = self.cd = self.rd = self.rs = self.rt = self.fd = self.fs = self.ft = self.imm = self.offset = self.base = self.target = None - - for field in self.fields: - self.value_forname(field) - - self.op_str = self.format_insn() - - if self.id == MIPS_INS_SLL and self.rd == MIPS_REG_R0 and self.rt == MIPS_REG_R0 and self.sa == 0: - self.id = MIPS_INS_NOP - self.mnemonic = "nop" - self.fields = () - elif self.id == MIPS_INS_BEQ and self.rs == MIPS_REG_R0 and self.rt == MIPS_REG_R0: - self.id = MIPS_INS_B - self.mnemonic = "b" - self.fields = ("offset",) - elif self.id == MIPS_INS_OR and self.rt == MIPS_REG_R0: - self.id = MIPS_INS_MOVE - self.mnemonic = "move" - self.fields = ("rd","rs") - elif self.id == MIPS_INS_BEQ and self.rt == MIPS_REG_R0: - self.id = MIPS_INS_BEQZ - self.mnemonic = "beqz" - self.fields = ("rs","offset") - elif self.id == MIPS_INS_BNE and self.rt == MIPS_REG_R0: - self.id = MIPS_INS_BNEZ - self.mnemonic = "bnez" - self.fields = ("rs","offset") - elif self.id == MIPS_INS_SUBU and self.rs == MIPS_REG_R0: - self.id = MIPS_INS_NEGU - self.mnemonic = "negu" - self.fields = ("rd","rt") - elif self.id == MIPS_INS_NOR and self.rt == MIPS_REG_R0: - self.id = MIPS_INS_NOT - self.mnemonic = "not" - self.fields = ("rd","rs") - - self.op_str = self.format_insn() - - def value_forname(self, name): - field_setters = { - 'code' : self.set_code, - 'sa' : self.set_sa, - 'op' : self.set_op, - 'cd' : self.set_cd, - 'rd' : self.set_rd, - 'rs' : self.set_rs, - 'rt' : self.set_rt, - 'fd' : self.set_fd, - 'fs' : self.set_fs, - 'ft' : self.set_ft, - 'imm' : self.set_imm, - 'offset' : self.set_offset, - 'base' : self.set_base, - 'offset(base)' : self.set_offset_base, - 'target' : self.set_target, - } - - return field_setters[name]() - - def format_field(self, field): - def format_hex(v, signed, zeros, no_zero): - if abs(v) < 10: - if v == 0 and no_zero: - return "" - return f"{v}" - elif not signed: - return f"0x{v:{f'0{zeros}' if zeros > 0 else ''}x}" - else: - return f"{v:#x}" - - format_handlers = { - 'code' : (lambda insn : f'{insn.code}' if insn.code != 0 else ''), - 'cd' : (lambda insn : mips_cop0_names[insn.cd]), - 'rd' : (lambda insn : mips_gpr_names[insn.rd]), - 'rs' : (lambda insn : mips_gpr_names[insn.rs]), - 'rt' : (lambda insn : mips_gpr_names[insn.rt]), - 'fd' : (lambda insn : mips_fpr_names[insn.fd]), - 'fs' : (lambda insn : mips_fpr_names[insn.fs]), - 'ft' : (lambda insn : mips_fpr_names[insn.ft]), - 'sa' : (lambda insn : format_hex(insn.sa, True, 0, False)), - 'op' : (lambda insn : format_hex(insn.op, False, 0, False)), - 'imm' : (lambda insn : format_hex(insn.imm, True, 0, False)), - 'offset(base)' : (lambda insn : f'{format_hex(insn.imm, True, 0, True)}({mips_gpr_names[insn.base]})'), - 'offset' : (lambda insn : f'{format_hex(insn.offset, True, 0, False)}'), - 'target' : (lambda insn : f'{format_hex(insn.target, False, 0, False)}') - } - - return format_handlers[field](self) - - def format_insn(self): - return ", ".join([self.format_field(field) for field in self.fields]) - - def __str__(self): - return f"{self.mnemonic:12}{self.op_str}" - - def set_code(self): - self.code = mips_get_code(self.raw, self.vaddr) - return self.code - - def set_sa(self): - self.sa = mips_get_sa(self.raw, self.vaddr) - return self.sa - - def set_op(self): - self.op = mips_get_op(self.raw, self.vaddr) - return self.op - - def set_cd(self): - self.cd = mips_get_cd(self.raw, self.vaddr) - return self.cd - - def set_rd(self): - self.rd = mips_get_rd(self.raw, self.vaddr) - return self.rd - - def set_rs(self): - self.rs = mips_get_rs(self.raw, self.vaddr) - return self.rs - - def set_rt(self): - self.rt = mips_get_rt(self.raw, self.vaddr) - return self.rt - - def set_fd(self): - self.fd = mips_get_fd(self.raw, self.vaddr) - return self.fd - - def set_fs(self): - self.fs = mips_get_fs(self.raw, self.vaddr) - return self.fs - - def set_ft(self): - self.ft = mips_get_ft(self.raw, self.vaddr) - return self.ft - - def set_imm(self): - do_sign_extend = [ MIPS_INS_ADDIU, MIPS_INS_SLTI, MIPS_INS_ADDI, MIPS_INS_DADDIU, - 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_LWC1, - MIPS_INS_LD, MIPS_INS_LDL, MIPS_INS_LDR, - MIPS_INS_LDC1, - MIPS_INS_LL, MIPS_INS_LLD, - MIPS_INS_SB, - MIPS_INS_SH, - MIPS_INS_SW, MIPS_INS_SWL, MIPS_INS_SWR, - MIPS_INS_SWC1, - MIPS_INS_SD, MIPS_INS_SDL, MIPS_INS_SDR, - MIPS_INS_SDC1, - MIPS_INS_SC, MIPS_INS_SCD, - ] - - self.imm = mips_get_imm(self.raw, self.vaddr) - if self.id in do_sign_extend: # sign extended immediates - self.imm = sign_extend_16(self.imm) - return self.imm - - def set_offset(self): - self.offset = mips_get_offset(self.raw, self.vaddr) - return self.offset - - def set_base(self): - self.base = mips_get_base(self.raw, self.vaddr) - return self.base - - def set_offset_base(self): - self.set_imm() - self.set_base() - return self.imm, self.base - - def set_target(self): - self.target = mips_get_target(self.raw, self.vaddr) - return self.target - -def fetch_insn(raw, vaddr, insn_set, func): - insn = insn_set.get(func(raw, vaddr), None) # default none for invalid instruction encoding - - if insn is not None and type(insn[1]) == dict: # extra decoding required - insn = fetch_insn(raw, vaddr, insn[1], insn[0]) - return insn - -def decode_insn(raw, vaddr): - return MipsInsn(raw, vaddr, fetch_insn(raw, vaddr, mips_insns, mips_get_field)) - -mips_insns = { - 0b000000: (mips_get_special, { - 0b000000: (MIPS_INS_SLL, "sll", ("rd","rt","sa")), - 0b000010: (MIPS_INS_SRL, "srl", ("rd","rt","sa")), - 0b000011: (MIPS_INS_SRA, "sra", ("rd","rt","sa")), - 0b000100: (MIPS_INS_SLLV, "sllv", ("rd","rt","rs")), - 0b000110: (MIPS_INS_SRLV, "srlv", ("rd","rt","rs")), - 0b000111: (MIPS_INS_SRAV, "srav", ("rd","rt","rs")), - 0b001000: (MIPS_INS_JR, "jr", ("rs", )), - 0b001001: (MIPS_INS_JALR, "jalr", ("rs", )), # technically also rd but it's always $ra - 0b001100: (MIPS_INS_SYSCALL, "syscall", ( )), - 0b001101: (MIPS_INS_BREAK, "break", ("code", )), - 0b001111: (MIPS_INS_SYNC, "sync", ( )), - 0b010000: (MIPS_INS_MFHI, "mfhi", ("rd", )), - 0b010001: (MIPS_INS_MTHI, "mthi", ("rs", )), - 0b010010: (MIPS_INS_MFLO, "mflo", ("rd", )), - 0b010011: (MIPS_INS_MTLO, "mtlo", ("rs", )), - 0b010100: (MIPS_INS_DSLLV, "dsllv", ("rd","rt","rs")), - 0b010110: (MIPS_INS_DSRLV, "dsrlv", ("rd","rt","rs")), - 0b010111: (MIPS_INS_DSRAV, "dsrav", ("rd","rt","rs")), - 0b011000: (MIPS_INS_MULT, "mult", ("rs","rt" )), - 0b011001: (MIPS_INS_MULTU, "multu", ("rs","rt" )), - 0b011010: (MIPS_INS_DIV, "div", ("rd","rs","rt")), # for some reason gas hates div instructions - 0b011011: (MIPS_INS_DIVU, "divu", ("rd","rs","rt")), # with the correct number of operands - 0b011100: (MIPS_INS_DMULT, "dmult", ("rs","rt" )), - 0b011101: (MIPS_INS_DMULTU, "dmultu", ("rs","rt" )), - 0b011110: (MIPS_INS_DDIV, "ddiv", ("rd","rs","rt")), - 0b011111: (MIPS_INS_DDIVU, "ddivu", ("rd","rs","rt")), - 0b100000: (MIPS_INS_ADD, "add", ("rd","rs","rt")), - 0b100001: (MIPS_INS_ADDU, "addu", ("rd","rs","rt")), - 0b100010: (MIPS_INS_SUB, "sub", ("rd","rs","rt")), - 0b100011: (MIPS_INS_SUBU, "subu", ("rd","rs","rt")), - 0b100100: (MIPS_INS_AND, "and", ("rd","rs","rt")), - 0b100101: (MIPS_INS_OR, "or", ("rd","rs","rt")), - 0b100110: (MIPS_INS_XOR, "xor", ("rd","rs","rt")), - 0b100111: (MIPS_INS_NOR, "nor", ("rd","rs","rt")), - 0b101010: (MIPS_INS_SLT, "slt", ("rd","rs","rt")), - 0b101011: (MIPS_INS_SLTU, "sltu", ("rd","rs","rt")), - 0b101100: (MIPS_INS_DADD, "dadd", ("rd","rs","rt")), - 0b101101: (MIPS_INS_DADDU, "daddu", ("rd","rs","rt")), - 0b101110: (MIPS_INS_DSUB, "dsub", ("rd","rs","rt")), - 0b101111: (MIPS_INS_DSUBU, "dsubu", ("rd","rs","rt")), - 0b110000: (MIPS_INS_TGE, "tge", ("rs","rt" )), - 0b110001: (MIPS_INS_TGEU, "tgeu", ("rs","rt" )), - 0b110010: (MIPS_INS_TLT, "tlt", ("rs","rt" )), - 0b110011: (MIPS_INS_TLTU, "tltu", ("rs","rt" )), - 0b110100: (MIPS_INS_TEQ, "teq", ("rs","rt" )), - 0b110110: (MIPS_INS_TNE, "tne", ("rs","rt" )), - 0b111000: (MIPS_INS_DSLL, "dsll", ("rd","rt","sa")), - 0b111010: (MIPS_INS_DSRL, "dsrl", ("rd","rt","sa")), - 0b111011: (MIPS_INS_DSRA, "dsra", ("rd","rt","sa")), - 0b111100: (MIPS_INS_DSLL32, "dsll32", ("rd","rt","sa")), - 0b111110: (MIPS_INS_DSRL32, "dsrl32", ("rd","rt","sa")), - 0b111111: (MIPS_INS_DSRA32, "dsra32", ("rd","rt","sa")), - }), - 0b000001: (mips_get_regimm, { - 0b00000: (MIPS_INS_BLTZ, "bltz", ("rs","offset")), - 0b00001: (MIPS_INS_BGEZ, "bgez", ("rs","offset")), - 0b00010: (MIPS_INS_BLTZL, "bltzl", ("rs","offset")), - 0b00011: (MIPS_INS_BGEZL, "bgezl", ("rs","offset")), - 0b01000: (MIPS_INS_TGEI, "tgei", ("rs","imm" )), - 0b01001: (MIPS_INS_TGEIU, "tgeiu", ("rs","imm" )), - 0b01010: (MIPS_INS_TLTI, "tlti", ("rs","imm" )), - 0b01011: (MIPS_INS_TLTIU, "tltiu", ("rs","imm" )), - 0b01100: (MIPS_INS_TEQI, "teqi", ("rs","imm" )), - 0b01110: (MIPS_INS_TNEI, "tnei", ("rs","imm" )), - 0b10000: (MIPS_INS_BLTZAL, "bltzal", ("rs","offset")), - 0b10001: (MIPS_INS_BGEZAL, "bgezal", ("rs","offset")), - 0b10010: (MIPS_INS_BLTZALL, "bltzall", ("rs","offset")), - 0b10011: (MIPS_INS_BGEZALL, "bgezall", ("rs","offset")), - }), - 0b000010: (MIPS_INS_J, "j", ("target", )), - 0b000011: (MIPS_INS_JAL, "jal", ("target", )), - 0b000100: (MIPS_INS_BEQ, "beq", ("rs","rt","offset")), - 0b000101: (MIPS_INS_BNE, "bne", ("rs","rt","offset")), - 0b000110: (MIPS_INS_BLEZ, "blez", ("rs","offset" )), - 0b000111: (MIPS_INS_BGTZ, "bgtz", ("rs","offset" )), - 0b001000: (MIPS_INS_ADDI, "addi", ("rt","rs","imm" )), - 0b001001: (MIPS_INS_ADDIU, "addiu", ("rt","rs","imm" )), - 0b001010: (MIPS_INS_SLTI, "slti", ("rt","rs","imm" )), - 0b001011: (MIPS_INS_SLTIU, "sltiu", ("rt","rs","imm" )), - 0b001100: (MIPS_INS_ANDI, "andi", ("rt","rs","imm" )), - 0b001101: (MIPS_INS_ORI, "ori", ("rt","rs","imm" )), - 0b001110: (MIPS_INS_XORI, "xori", ("rt","rs","imm" )), - 0b001111: (MIPS_INS_LUI, "lui", ("rt","imm" )), - 0b010000: (mips_get_cop0, { - 0b00000: (MIPS_INS_MFC0, "mfc0", ("rt","cd")), - 0b00100: (MIPS_INS_MTC0, "mtc0", ("rt","cd")), - 0b10000: (mips_get_tlb, { - 0b000001: (MIPS_INS_TLBR, "tlbr", ()), - 0b000010: (MIPS_INS_TLBWI, "tlbwi", ()), - 0b000110: (MIPS_INS_TLBWR, "tlbwr", ()), - 0b001000: (MIPS_INS_TLBP, "tlbp", ()), - 0b011000: (MIPS_INS_ERET, "eret", ()), - }), - }), - 0b010001: (mips_get_cop1, { - 0b00000: (MIPS_INS_MFC1, "mfc1", ("rt","fs")), - 0b00001: (MIPS_INS_DMFC1, "dmfc1", ("rt","fs")), - 0b00010: (MIPS_INS_CFC1, "cfc1", ("rt","fs")), - 0b00100: (MIPS_INS_MTC1, "mtc1", ("rt","fs")), - 0b00101: (MIPS_INS_DMTC1, "dmtc1", ("rt","fs")), - 0b00110: (MIPS_INS_CTC1, "ctc1", ("rt","fs")), - 0b01000: (mips_get_ndtf, { - 0b00: (MIPS_INS_BC1F, "bc1f", ("offset",)), - 0b01: (MIPS_INS_BC1T, "bc1t", ("offset",)), - 0b10: (MIPS_INS_BC1FL, "bc1fl", ("offset",)), - 0b11: (MIPS_INS_BC1TL, "bc1tl", ("offset",)), - }), - 0b010000: (mips_get_function, { - 0b000000: (MIPS_INS_ADD_S, "add.s", ("fd","fs","ft")), - 0b000001: (MIPS_INS_SUB_S, "sub.s", ("fd","fs","ft")), - 0b000010: (MIPS_INS_MUL_S, "mul.s", ("fd","fs","ft")), - 0b000011: (MIPS_INS_DIV_S, "div.s", ("fd","fs","ft")), - 0b000100: (MIPS_INS_SQRT_S, "sqrt.s", ("fd","fs" )), - 0b000101: (MIPS_INS_ABS_S, "abs.s", ("fd","fs" )), - 0b000110: (MIPS_INS_MOV_S, "mov.s", ("fd","fs" )), - 0b000111: (MIPS_INS_NEG_S, "neg.s", ("fd","fs" )), - 0b001000: (MIPS_INS_ROUND_L_S, "round.l.s", ("fd","fs" )), - 0b001001: (MIPS_INS_TRUNC_L_S, "trunc.l.s", ("fd","fs" )), - 0b001010: (MIPS_INS_CEIL_L_S, "ceil.l.s", ("fd","fs" )), - 0b001011: (MIPS_INS_FLOOR_L_S, "floor.l.s", ("fd","fs" )), - 0b001100: (MIPS_INS_ROUND_W_S, "round.w.s", ("fd","fs" )), - 0b001101: (MIPS_INS_TRUNC_W_S, "trunc.w.s", ("fd","fs" )), - 0b001110: (MIPS_INS_CEIL_W_S, "ceil.w.s", ("fd","fs" )), - 0b001111: (MIPS_INS_FLOOR_W_S, "floor.w.s", ("fd","fs" )), - 0b100001: (MIPS_INS_CVT_D_S, "cvt.d.s", ("fd","fs" )), - 0b100100: (MIPS_INS_CVT_W_S, "cvt.w.s", ("fd","fs" )), - 0b100101: (MIPS_INS_CVT_L_S, "cvt.l.s", ("fd","fs" )), - 0b110000: (MIPS_INS_C_F_S, "c.f.s", ("fs","ft" )), - 0b110001: (MIPS_INS_C_UN_S, "c.un.s", ("fs","ft" )), - 0b110010: (MIPS_INS_C_EQ_S, "c.eq.s", ("fs","ft" )), - 0b110011: (MIPS_INS_C_UEQ_S, "c.ueq.s", ("fs","ft" )), - 0b110100: (MIPS_INS_C_OLT_S, "c.olt.s", ("fs","ft" )), - 0b110101: (MIPS_INS_C_ULT_S, "c.ult.s", ("fs","ft" )), - 0b110110: (MIPS_INS_C_OLE_S, "c.ole.s", ("fs","ft" )), - 0b110111: (MIPS_INS_C_ULE_S, "c.ule.s", ("fs","ft" )), - 0b111000: (MIPS_INS_C_SF_S, "c.sf.s", ("fs","ft" )), - 0b111001: (MIPS_INS_C_NGLE_S, "c.ngle.s", ("fs","ft" )), - 0b111010: (MIPS_INS_C_SEQ_S, "c.seq.s", ("fs","ft" )), - 0b111011: (MIPS_INS_C_NGL_S, "c.ngl.s", ("fs","ft" )), - 0b111100: (MIPS_INS_C_LT_S, "c.lt.s", ("fs","ft" )), - 0b111101: (MIPS_INS_C_NGE_S, "c.nge.s", ("fs","ft" )), - 0b111110: (MIPS_INS_C_LE_S, "c.le.s", ("fs","ft" )), - 0b111111: (MIPS_INS_C_NGT_S, "c.ngt.s", ("fs","ft" )), - }), - 0b010001: (mips_get_function, { - 0b000000: (MIPS_INS_ADD_D, "add.d", ("fd","fs","ft")), - 0b000001: (MIPS_INS_SUB_D, "sub.d", ("fd","fs","ft")), - 0b000010: (MIPS_INS_MUL_D, "mul.d", ("fd","fs","ft")), - 0b000011: (MIPS_INS_DIV_D, "div.d", ("fd","fs","ft")), - 0b000100: (MIPS_INS_SQRT_D, "sqrt.d", ("fd","fs" )), - 0b000101: (MIPS_INS_ABS_D, "abs.d", ("fd","fs" )), - 0b000110: (MIPS_INS_MOV_D, "mov.d", ("fd","fs" )), - 0b000111: (MIPS_INS_NEG_D, "neg.d", ("fd","fs" )), - 0b001000: (MIPS_INS_ROUND_L_D, "round.l.d", ("fd","fs" )), - 0b001001: (MIPS_INS_TRUNC_L_D, "trunc.l.d", ("fd","fs" )), - 0b001010: (MIPS_INS_CEIL_L_D, "ceil.l.d", ("fd","fs" )), - 0b001011: (MIPS_INS_FLOOR_L_D, "floor.l.d", ("fd","fs" )), - 0b001100: (MIPS_INS_ROUND_W_D, "round.w.d", ("fd","fs" )), - 0b001101: (MIPS_INS_TRUNC_W_D, "trunc.w.d", ("fd","fs" )), - 0b001110: (MIPS_INS_CEIL_W_D, "ceil.w.d", ("fd","fs" )), - 0b001111: (MIPS_INS_FLOOR_W_D, "floor.w.d", ("fd","fs" )), - 0b100000: (MIPS_INS_CVT_S_D, "cvt.s.d", ("fd","fs" )), - 0b100100: (MIPS_INS_CVT_W_D, "cvt.w.d", ("fd","fs" )), - 0b100101: (MIPS_INS_CVT_L_D, "cvt.l.d", ("fd","fs" )), - 0b110000: (MIPS_INS_C_F_D, "c.f.d", ("fs","ft" )), - 0b110001: (MIPS_INS_C_UN_D, "c.un.d", ("fs","ft" )), - 0b110010: (MIPS_INS_C_EQ_D, "c.eq.d", ("fs","ft" )), - 0b110011: (MIPS_INS_C_UEQ_D, "c.ueq.d", ("fs","ft" )), - 0b110100: (MIPS_INS_C_OLT_D, "c.olt.d", ("fs","ft" )), - 0b110101: (MIPS_INS_C_ULT_D, "c.ult.d", ("fs","ft" )), - 0b110110: (MIPS_INS_C_OLE_D, "c.ole.d", ("fs","ft" )), - 0b110111: (MIPS_INS_C_ULE_D, "c.ule.d", ("fs","ft" )), - 0b111000: (MIPS_INS_C_SF_D, "c.sf.d", ("fs","ft" )), - 0b111001: (MIPS_INS_C_NGLE_D, "c.ngle.d", ("fs","ft" )), - 0b111010: (MIPS_INS_C_SEQ_D, "c.seq.d", ("fs","ft" )), - 0b111011: (MIPS_INS_C_NGL_D, "c.ngl.d", ("fs","ft" )), - 0b111100: (MIPS_INS_C_LT_D, "c.lt.d", ("fs","ft" )), - 0b111101: (MIPS_INS_C_NGE_D, "c.nge.d", ("fs","ft" )), - 0b111110: (MIPS_INS_C_LE_D, "c.le.d", ("fs","ft" )), - 0b111111: (MIPS_INS_C_NGT_D, "c.ngt.d", ("fs","ft" )), - }), - 0b010100: (mips_get_function, { - 0b100000: (MIPS_INS_CVT_S_W, "cvt.s.w", ("fd","fs")), - 0b100001: (MIPS_INS_CVT_D_W, "cvt.d.w", ("fd","fs")), - }), - 0b010101: (mips_get_function, { - 0b100000: (MIPS_INS_CVT_S_L, "cvt.s.l", ("fd","fs")), - 0b100001: (MIPS_INS_CVT_D_L, "cvt.d.l", ("fd","fs")), - }), - }), - 0b010100: (MIPS_INS_BEQL, "beql", ("rs","rt","offset" )), - 0b010101: (MIPS_INS_BNEL, "bnel", ("rs","rt","offset" )), - 0b010110: (MIPS_INS_BLEZL, "blezl", ("rs","offset" )), - 0b010111: (MIPS_INS_BGTZL, "bgtzl", ("rs","offset" )), - 0b011000: (MIPS_INS_DADDI, "daddi", ("rt","rs","imm" )), - 0b011001: (MIPS_INS_DADDIU, "daddiu", ("rt","rs","imm" )), - 0b011010: (MIPS_INS_LDL, "ldl", ("rt","offset(base)")), - 0b011011: (MIPS_INS_LDR, "ldr", ("rt","offset(base)")), - 0b100000: (MIPS_INS_LB, "lb", ("rt","offset(base)")), - 0b100001: (MIPS_INS_LH, "lh", ("rt","offset(base)")), - 0b100010: (MIPS_INS_LWL, "lwl", ("rt","offset(base)")), - 0b100011: (MIPS_INS_LW, "lw", ("rt","offset(base)")), - 0b100100: (MIPS_INS_LBU, "lbu", ("rt","offset(base)")), - 0b100101: (MIPS_INS_LHU, "lhu", ("rt","offset(base)")), - 0b100110: (MIPS_INS_LWR, "lwr", ("rt","offset(base)")), - 0b100111: (MIPS_INS_LWU, "lwu", ("rt","offset(base)")), - 0b101000: (MIPS_INS_SB, "sb", ("rt","offset(base)")), - 0b101001: (MIPS_INS_SH, "sh", ("rt","offset(base)")), - 0b101010: (MIPS_INS_SWL, "swl", ("rt","offset(base)")), - 0b101011: (MIPS_INS_SW, "sw", ("rt","offset(base)")), - 0b101100: (MIPS_INS_SDL, "sdl", ("rt","offset(base)")), - 0b101101: (MIPS_INS_SDR, "sdr", ("rt","offset(base)")), - 0b101110: (MIPS_INS_SWR, "swr", ("rt","offset(base)")), - 0b101111: (MIPS_INS_CACHE, "cache", ("op","offset(base)")), - 0b110000: (MIPS_INS_LL, "ll", ("rt","offset(base)")), - 0b110001: (MIPS_INS_LWC1, "lwc1", ("ft","offset(base)")), - 0b110100: (MIPS_INS_LLD, "lld", ("rt","offset(base)")), - 0b110101: (MIPS_INS_LDC1, "ldc1", ("ft","offset(base)")), - # ldc2 - 0b110111: (MIPS_INS_LD, "ld", ("rt","offset(base)")), - 0b111000: (MIPS_INS_SC, "sc", ("rt","offset(base)")), - 0b111001: (MIPS_INS_SWC1, "swc1", ("ft","offset(base)")), - 0b111100: (MIPS_INS_SCD, "scd", ("rt","offset(base)")), - 0b111101: (MIPS_INS_SDC1, "sdc1", ("ft","offset(base)")), - # sdc2 - 0b111111: (MIPS_INS_SD, "sd", ("rt","offset(base)")), -} diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index af45a904d..d702f5880 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -1062,65 +1062,51 @@ 0x801BF5B0:("D_801BF5B0","UNK_TYPE2","",0x2), 0x801BF5C0:("D_801BF5C0","UNK_PTR","",0x4), 0x801BF68C:("D_801BF68C","UNK_TYPE1","",0x1), - 0x801BF6C0:("D_801BF6C0","UNK_TYPE1","",0x1), - 0x801BF79E:("D_801BF79E","UNK_TYPE1","",0x1), + 0x801BF6C0:("sRestrictionFlags","RestrictionFlags","[113]",0x1c4), 0x801BF884:("D_801BF884","UNK_TYPE2","",0x2), 0x801BF888:("D_801BF888","UNK_TYPE2","",0x2), - 0x801BF88C:("D_801BF88C","UNK_TYPE2","",0x2), - 0x801BF890:("D_801BF890","UNK_TYPE2","",0x2), - 0x801BF898:("D_801BF898","UNK_TYPE2","",0x2), - 0x801BF89C:("D_801BF89C","UNK_TYPE2","",0x2), - 0x801BF8A0:("D_801BF8A0","UNK_TYPE2","",0x2), - 0x801BF8A4:("D_801BF8A4","UNK_TYPE2","",0x2), - 0x801BF8A8:("D_801BF8A8","UNK_TYPE2","",0x2), + 0x801BF88C:("sHBAScoreTier","UNK_TYPE2","",0x2), + 0x801BF890:("sMinigameScoreDigits","UNK_TYPE2","",0x2), + 0x801BF898:("sCUpInvisible","UNK_TYPE2","",0x2), + 0x801BF89C:("sCUpTimer","UNK_TYPE2","",0x2), + 0x801BF8A0:("sMagicBarOutlinePrimRed","UNK_TYPE2","",0x2), + 0x801BF8A4:("sMagicBarOutlinePrimGreen","UNK_TYPE2","",0x2), + 0x801BF8A8:("sMagicBarOutlinePrimBlue","UNK_TYPE2","",0x2), 0x801BF8AC:("D_801BF8AC","UNK_TYPE2","",0x2), 0x801BF8B0:("D_801BF8B0","UNK_TYPE2","",0x2), 0x801BF8DC:("D_801BF8DC","UNK_TYPE2","",0x2), 0x801BF8E0:("D_801BF8E0","UNK_TYPE2","",0x2), 0x801BF8E4:("D_801BF8E4","UNK_TYPE2","",0x2), 0x801BF8E8:("D_801BF8E8","UNK_TYPE4","",0x4), - 0x801BF8F0:("D_801BF8F0","UNK_TYPE4","",0x4), - 0x801BF8F4:("D_801BF8F4","UNK_TYPE4","",0x4), - 0x801BF8F8:("D_801BF8F8","UNK_TYPE4","",0x4), - 0x801BF8FC:("D_801BF8FC","UNK_TYPE4","",0x4), - 0x801BF930:("D_801BF930","UNK_TYPE4","",0x4), - 0x801BF934:("D_801BF934","UNK_TYPE4","",0x4), - 0x801BF968:("D_801BF968","UNK_TYPE1","",0x1), - 0x801BF96A:("D_801BF96A","UNK_TYPE1","",0x1), - 0x801BF96C:("D_801BF96C","UNK_TYPE1","",0x1), - 0x801BF96E:("D_801BF96E","UNK_TYPE1","",0x1), - 0x801BF970:("D_801BF970","UNK_TYPE2","",0x2), - 0x801BF972:("D_801BF972","UNK_TYPE1","",0x1), - 0x801BF974:("D_801BF974","UNK_TYPE2","",0x2), - 0x801BF978:("D_801BF978","UNK_TYPE2","",0x2), - 0x801BF97C:("D_801BF97C","UNK_TYPE2","",0x2), + 0x801BF8F0:("D_801BF8F0","u64","",0x8), + 0x801BF8F8:("D_801BF8F8","u64","[7]",0x38), + 0x801BF930:("D_801BF930","u64","[7]",0x38), + 0x801BF968:("D_801BF968","UNK_TYPE4","",0x4), + 0x801BF96C:("D_801BF96C","UNK_TYPE4","",0x4), + 0x801BF970:("D_801BF970","UNK_TYPE4","",0x4), + 0x801BF974:("D_801BF974","UNK_TYPE4","",0x4), + 0x801BF978:("D_801BF978","UNK_TYPE4","",0x4), + 0x801BF97C:("D_801BF97C","UNK_TYPE4","",0x4), 0x801BF980:("D_801BF980","UNK_TYPE4","",0x4), - 0x801BF988:("D_801BF988","UNK_TYPE1","",0x1), - 0x801BF998:("D_801BF998","UNK_TYPE1","",0x1), + 0x801BF988:("D_801BF988","Gfx","[5]",0x28), 0x801BF9B0:("D_801BF9B0","UNK_TYPE2","",0x2), 0x801BF9B4:("D_801BF9B4","UNK_TYPE1","",0x1), 0x801BF9BC:("D_801BF9BC","UNK_TYPE1","",0x1), 0x801BF9C4:("D_801BF9C4","UNK_TYPE1","",0x1), 0x801BF9C8:("D_801BF9C8","UNK_TYPE1","",0x1), 0x801BF9CC:("D_801BF9CC","UNK_TYPE1","",0x1), - 0x801BF9D4:("D_801BF9D4","UNK_TYPE2","",0x2), - 0x801BF9D6:("D_801BF9D6","UNK_TYPE2","",0x2), - 0x801BF9D8:("D_801BF9D8","UNK_TYPE2","",0x2), - 0x801BF9DA:("D_801BF9DA","UNK_TYPE2","",0x2), - 0x801BF9DC:("D_801BF9DC","UNK_TYPE2","",0x2), - 0x801BF9DE:("D_801BF9DE","UNK_TYPE2","",0x2), - 0x801BF9E0:("D_801BF9E0","UNK_TYPE2","",0x2), - 0x801BF9E2:("D_801BF9E2","UNK_TYPE2","",0x2), - 0x801BF9E4:("D_801BF9E4","UNK_TYPE2","",0x2), - 0x801BF9E6:("D_801BF9E6","UNK_TYPE2","",0x2), - 0x801BF9E8:("D_801BF9E8","UNK_TYPE2","",0x2), - 0x801BF9EA:("D_801BF9EA","UNK_TYPE2","",0x2), - 0x801BF9EC:("D_801BF9EC","UNK_TYPE2","",0x2), - 0x801BF9F0:("D_801BF9F0","UNK_TYPE2","",0x2), - 0x801BF9F4:("D_801BF9F4","UNK_TYPE2","",0x2), - 0x801BF9F8:("D_801BF9F8","UNK_TYPE2","",0x2), - 0x801BF9FC:("D_801BF9FC","UNK_TYPE2","",0x2), - 0x801BFA00:("D_801BFA00","UNK_TYPE2","",0x2), + 0x801BF9D4:("D_801BF9D4","UNK_TYPE4","",0x4), + 0x801BF9D8:("D_801BF9D8","UNK_TYPE4","",0x4), + 0x801BF9DC:("D_801BF9DC","UNK_TYPE4","",0x4), + 0x801BF9E0:("D_801BF9E0","UNK_TYPE4","",0x4), + 0x801BF9E4:("D_801BF9E4","UNK_TYPE4","",0x4), + 0x801BF9E8:("D_801BF9E8","UNK_TYPE4","",0x4), + 0x801BF9EC:("sFinalHoursClockDigitsRed","UNK_TYPE4","",0x4), + 0x801BF9F0:("sFinalHoursClockFrameEnvRed","UNK_TYPE2","",0x2), + 0x801BF9F4:("sFinalHoursClockFrameEnvGreen","UNK_TYPE2","",0x2), + 0x801BF9F8:("sFinalHoursClockFrameEnvBlue","UNK_TYPE2","",0x2), + 0x801BF9FC:("sFinalHoursClockColorTimer","UNK_TYPE2","",0x2), + 0x801BFA00:("sFinalHoursClockColorTargetIndex","UNK_TYPE2","",0x2), 0x801BFA04:("D_801BFA04","UNK_TYPE2","",0x2), 0x801BFA1C:("D_801BFA1C","UNK_TYPE2","",0x2), 0x801BFA34:("D_801BFA34","UNK_TYPE2","",0x2), @@ -1128,16 +1114,14 @@ 0x801BFA64:("D_801BFA64","UNK_TYPE2","",0x2), 0x801BFA74:("D_801BFA74","UNK_TYPE2","",0x2), 0x801BFA84:("D_801BFA84","UNK_TYPE4","",0x4), - 0x801BFAB0:("D_801BFAB0","UNK_TYPE1","",0x1), - 0x801BFAB8:("D_801BFAB8","UNK_TYPE1","",0x1), - 0x801BFAC4:("D_801BFAC4","UNK_TYPE1","",0x1), - 0x801BFACC:("D_801BFACC","UNK_TYPE1","",0x1), - 0x801BFAD4:("D_801BFAD4","UNK_TYPE1","",0x1), - 0x801BFAF4:("D_801BFAF4","UNK_TYPE2","",0x2), - 0x801BFAF6:("D_801BFAF6","UNK_TYPE2","",0x2), - 0x801BFAF8:("D_801BFAF8","UNK_TYPE2","",0x2), - 0x801BFAFA:("D_801BFAFA","UNK_TYPE2","",0x2), - 0x801BFAFC:("D_801BFAFC","UNK_TYPE1","",0x1), + 0x801BFAB0:("sDoActionTextures","UNK_TYPE1","",0x1), + 0x801BFAB8:("magicBorderColors","UNK_TYPE1","",0x1), + 0x801BFAC4:("magicBorderIndices","UNK_TYPE1","",0x1), + 0x801BFACC:("magicBorderColorTimerIndex","UNK_TYPE1","",0x1), + 0x801BFAD4:("cUpLabelTextures","UNK_TYPE1","",0x1), + 0x801BFAF4:("D_801BFAF4","UNK_TYPE4","",0x4), + 0x801BFAF8:("D_801BFAF8","UNK_TYPE4","",0x4), + 0x801BFAFC:("D_801BFAFC","UNK_TYPE4","",0x4), 0x801BFB04:("D_801BFB04","UNK_TYPE1","",0x1), 0x801BFB0C:("D_801BFB0C","UNK_TYPE1","",0x1), 0x801BFB14:("D_801BFB14","UNK_TYPE1","",0x1), @@ -1169,27 +1153,19 @@ 0x801BFC14:("D_801BFC14","UNK_TYPE1","",0x1), 0x801BFC40:("D_801BFC40","UNK_TYPE1","",0x1), 0x801BFC50:("D_801BFC50","UNK_TYPE2","",0x2), - 0x801BFC60:("D_801BFC60","UNK_TYPE2","",0x2), - 0x801BFC62:("D_801BFC62","UNK_TYPE2","",0x2), - 0x801BFC64:("D_801BFC64","UNK_TYPE2","",0x2), - 0x801BFC6C:("D_801BFC6C","UNK_TYPE2","",0x2), + 0x801BFC60:("D_801BFC60","s16","[6]",0xC), + 0x801BFC6C:("D_801BFC6C","UNK_TYPE4","",0x4), 0x801BFC7C:("D_801BFC7C","UNK_TYPE2","",0x2), 0x801BFC8C:("D_801BFC8C","UNK_TYPE1","",0x1), 0x801BFC98:("D_801BFC98","UNK_TYPE2","",0x2), 0x801BFCA8:("D_801BFCA8","UNK_TYPE2","",0x2), 0x801BFCB8:("D_801BFCB8","UNK_TYPE1","",0x1), 0x801BFCC4:("D_801BFCC4","UNK_TYPE4","",0x4), - 0x801BFCE4:("D_801BFCE4","UNK_TYPE2","",0x2), - 0x801BFCE8:("D_801BFCE8","UNK_TYPE2","",0x2), - 0x801BFCEA:("D_801BFCEA","UNK_TYPE2","",0x2), - 0x801BFCEC:("D_801BFCEC","UNK_TYPE2","",0x2), - 0x801BFCEE:("D_801BFCEE","UNK_TYPE2","",0x2), - 0x801BFCF0:("D_801BFCF0","UNK_TYPE2","",0x2), - 0x801BFCF2:("D_801BFCF2","UNK_TYPE2","",0x2), - 0x801BFCF4:("D_801BFCF4","UNK_TYPE2","",0x2), - 0x801BFCF8:("D_801BFCF8","UNK_TYPE2","",0x2), - 0x801BFCFC:("D_801BFCFC","UNK_TYPE2","",0x2), - 0x801BFD0C:("D_801BFD0C","UNK_TYPE2","",0x2), + 0x801BFCE4:("D_801BFCE4","UNK_TYPE4","",0x4), + 0x801BFCE8:("D_801BFCE8","u16","[8]",0x10), + 0x801BFCF8:("D_801BFCF8","UNK_TYPE4","",0x4), + 0x801BFCFC:("D_801BFCFC","UNK_TYPE4","",0x4), + 0x801BFD0C:("D_801BFD0C","UNK_TYPE4","",0x4), 0x801BFD1C:("D_801BFD1C","UNK_TYPE1","",0x1), 0x801BFD24:("D_801BFD24","UNK_TYPE1","",0x1), 0x801BFD2C:("D_801BFD2C","UNK_TYPE1","",0x1), @@ -1199,33 +1175,24 @@ 0x801BFD6C:("D_801BFD6C","UNK_TYPE2","",0x2), 0x801BFD84:("D_801BFD84","UNK_TYPE1","",0x1), 0x801BFD8C:("D_801BFD8C","UNK_TYPE1","",0x1), - 0x801BFD94:("D_801BFD94","UNK_TYPE1","",0x1), - 0x801BFD98:("D_801BFD98","UNK_TYPE2","",0x2), - 0x801BFD9E:("D_801BFD9E","UNK_TYPE1","",0x1), + 0x801BFD94:("D_801BFD94","UNK_TYPE4","",0x4), + 0x801BFD98:("D_801BFD98","UNK_TYPE4","[2]",0x8), + 0x801BFDA0:("sMaskObjectIds","s16","[24]",0x30), 0x801BFDD0:("D_801BFDD0","UNK_TYPE1","",0x1), - 0x801BFDE8:("D_801BFDE8","UNK_TYPE1","",0x1), + 0x801BFDE8:("sMaskItemIds","UNK_TYPE1","",0x1), 0x801BFE00:("D_801BFE00","UNK_TYPE1","",0x1), 0x801BFE14:("D_801BFE14","UNK_TYPE1","",0x1), 0x801BFF34:("D_801BFF34","UNK_TYPE2","",0x2), - 0x801BFF3C:("D_801BFF3C","UNK_TYPE1","",0x1), + 0x801BFF3C:("sActionModelGroups","UNK_TYPE1","",0x1), 0x801BFF90:("D_801BFF90","UNK_TYPE1","",0x1), - 0x801BFF98:("D_801BFF98","UNK_TYPE1","",0x1), - 0x801BFFA0:("D_801BFFA0","UNK_TYPE1","",0x1), - 0x801BFFB0:("D_801BFFB0","UNK_TYPE1","",0x1), + 0x801BFF98:("sPlayerStrengths","UNK_TYPE1","",0x1), + 0x801BFFA0:("sEnvironmentTextTriggers","UNK_TYPE1","",0x1), + 0x801BFFB0:("gPlayerModelTypes","UNK_TYPE1","",0x1), 0x801BFFFC:("D_801BFFFC","UNK_TYPE1","",0x1), - 0x801C0000:("D_801C0000","UNK_TYPE1","",0x1), - 0x801C0001:("D_801C0001","UNK_TYPE1","",0x1), - 0x801C0002:("D_801C0002","UNK_TYPE1","",0x1), - 0x801C0008:("D_801C0008","UNK_TYPE1","",0x1), - 0x801C0010:("D_801C0010","UNK_TYPE1","",0x1), 0x801C0024:("D_801C0024","UNK_TYPE1","",0x1), 0x801C0034:("D_801C0034","UNK_TYPE1","",0x1), - 0x801C0040:("D_801C0040","UNK_TYPE1","",0x1), 0x801C005C:("D_801C005C","UNK_TYPE1","",0x1), - 0x801C0060:("D_801C0060","UNK_TYPE1","",0x1), - 0x801C0070:("D_801C0070","UNK_TYPE1","",0x1), 0x801C0084:("D_801C0084","UNK_TYPE1","",0x1), - 0x801C00A0:("D_801C00A0","UNK_TYPE1","",0x1), 0x801C00AC:("D_801C00AC","UNK_TYPE1","",0x1), 0x801C00BC:("D_801C00BC","UNK_TYPE1","",0x1), 0x801C00D4:("D_801C00D4","UNK_TYPE1","",0x1), @@ -1245,7 +1212,7 @@ 0x801C02BC:("D_801C02BC","UNK_TYPE1","",0x1), 0x801C02D0:("D_801C02D0","UNK_TYPE1","",0x1), 0x801C02E4:("D_801C02E4","UNK_TYPE1","",0x1), - 0x801C02F8:("D_801C02F8","UNK_PTR","",0x4), + 0x801C02F8:("sPlayerDListGroups","UNK_PTR","",0x4), 0x801C0340:("D_801C0340","UNK_TYPE1","",0x1), 0x801C0368:("D_801C0368","UNK_TYPE1","",0x1), 0x801C03A0:("D_801C03A0","UNK_TYPE1","",0x1), @@ -1262,9 +1229,7 @@ 0x801C05A8:("D_801C05A8","UNK_TYPE1","",0x1), 0x801C05C8:("D_801C05C8","UNK_TYPE1","",0x1), 0x801C05D8:("D_801C05D8","UNK_TYPE1","",0x1), - 0x801C05F0:("D_801C05F0","UNK_TYPE1","",0x1), - 0x801C05F2:("D_801C05F2","UNK_TYPE2","",0x2), - 0x801C05FA:("D_801C05FA","UNK_TYPE1","",0x1), + 0x801C05F0:("D_801C05F0","struct_80124618","[3]",0x18), 0x801C0608:("D_801C0608","UNK_TYPE1","",0x1), 0x801C0628:("D_801C0628","UNK_TYPE1","",0x1), 0x801C0678:("D_801C0678","UNK_TYPE1","",0x1), @@ -1287,15 +1252,13 @@ 0x801C0860:("D_801C0860","UNK_TYPE1","",0x1), 0x801C0870:("D_801C0870","UNK_PTR","",0x4), 0x801C0890:("D_801C0890","UNK_TYPE1","",0x1), - 0x801C08A0:("D_801C08A0","UNK_TYPE1","",0x1), - 0x801C08A1:("D_801C08A1","UNK_TYPE1","",0x1), + 0x801C08A0:("D_801C08A0","UNK_TYPE1","",0x20), 0x801C08C0:("D_801C08C0","UNK_TYPE1","",0x1), 0x801C08FC:("D_801C08FC","UNK_TYPE1","",0x1), 0x801C0910:("D_801C0910","UNK_TYPE1","",0x1), 0x801C0924:("D_801C0924","UNK_TYPE1","",0x1), 0x801C0938:("D_801C0938","UNK_TYPE1","",0x1), - 0x801C094C:("D_801C094C","UNK_TYPE1","",0x1), - 0x801C0954:("D_801C0954","UNK_TYPE4","",0x4), + 0x801C094C:("D_801C094C","Vec3f","",0xC), 0x801C0958:("D_801C0958","UNK_TYPE4","",0x4), 0x801C095C:("D_801C095C","UNK_PTR","",0x4), 0x801C0964:("D_801C0964","UNK_TYPE1","",0x1), @@ -1321,27 +1284,18 @@ 0x801C0B1C:("D_801C0B1C","UNK_TYPE1","",0x1), 0x801C0B20:("D_801C0B20","UNK_TYPE1","",0x1), 0x801C0B90:("D_801C0B90","UNK_TYPE1","",0x1), - 0x801C0BA8:("D_801C0BA8","UNK_TYPE4","",0x4), - 0x801C0BAC:("D_801C0BAC","UNK_TYPE4","",0x4), - 0x801C0BB0:("D_801C0BB0","UNK_TYPE4","",0x4), - 0x801C0BB4:("D_801C0BB4","UNK_TYPE1","",0x1), - 0x801C0BB8:("D_801C0BB8","UNK_TYPE4","",0x4), + 0x801C0BA8:("D_801C0BA8","Vec3f","",0xC), + 0x801C0BB4:("D_801C0BB4","Vec3f","",0xC), 0x801C0BC0:("D_801C0BC0","UNK_TYPE1","",0x1), 0x801C0BD0:("D_801C0BD0","UNK_TYPE1","",0x1), - 0x801C0BE0:("D_801C0BE0","UNK_TYPE4","",0x4), - 0x801C0BE4:("D_801C0BE4","UNK_TYPE4","",0x4), - 0x801C0BE8:("D_801C0BE8","UNK_TYPE4","",0x4), - 0x801C0BEC:("D_801C0BEC","UNK_TYPE4","",0x4), - 0x801C0BF0:("D_801C0BF0","UNK_TYPE4","",0x4), - 0x801C0BF4:("D_801C0BF4","UNK_TYPE4","",0x4), + 0x801C0BE0:("D_801C0BE0","Vec3f","",0xC), + 0x801C0BEC:("D_801C0BEC","Vec3f","",0xC), 0x801C0BF8:("D_801C0BF8","UNK_TYPE1","",0x1), 0x801C0BFC:("D_801C0BFC","UNK_TYPE1","",0x1), 0x801C0C00:("D_801C0C00","UNK_TYPE1","",0x1), 0x801C0C0C:("D_801C0C0C","UNK_TYPE4","",0x4), 0x801C0C30:("D_801C0C30","UNK_TYPE1","",0x1), - 0x801C0C54:("D_801C0C54","UNK_TYPE1","",0x1), - 0x801C0C78:("D_801C0C78","UNK_TYPE1","",0x1), - 0x801C0C94:("D_801C0C94","UNK_TYPE1","",0x1), + 0x801C0C54:("D_801C0C54","struct_80128388_arg1","",0x54), 0x801C0CA8:("D_801C0CA8","UNK_TYPE1","",0x1), 0x801C0CE8:("D_801C0CE8","UNK_TYPE4","",0x4), 0x801C0D24:("D_801C0D24","UNK_TYPE1","",0x1), @@ -1394,8 +1348,8 @@ 0x801C2650:("tatlMessageFiles","RomFile","[2]",0x10), 0x801C2660:("sceneTextureFiles","RomFile","[9]",0x48), 0x801C26A8:("sceneHeaderFuncTable","scene_header_func","[31]",0x7c), - 0x801C2730:("gLinkFormObjectIndexes","s16","[8]",0x10), - 0x801C2740:("objectFileTable","RomFile","[643]",0x1418), + 0x801C2730:("gPlayerFormObjectIndices","s16","[8]",0x10), + 0x801C2740:("gObjectTable","RomFile","[643]",0x1418), 0x801C3B60:("sSceneDrawDefaultDl","Gfx","[11]",0x58), 0x801C3BB8:("gSceneProcSceneDrawFuncs","SceneDrawConfigFunc","[8]",0x20), 0x801C3BD8:("gSceneProcDrawFuncs","scene_proc_draw_func","[6]",0x18), @@ -2298,7 +2252,7 @@ 0x801D618C:("D_801D618C","UNK_PTR","",0x4), 0x801D6190:("D_801D6190","f32","",0x4), 0x801D6194:("D_801D6194","UNK_TYPE4","",0x4), - 0x801D61A0:("D_801D61A0","u8","[96]",0x60), + 0x801D61A0:("sSeqInstructionArgsTable","u8","[96]",0x60), 0x801D6200:("D_801D6200","UNK_TYPE1","",0x1), 0x801D6600:("D_801D6600","UNK_TYPE1","",0x1), 0x801D6608:("D_801D6608","UNK_TYPE1","",0x1), @@ -4057,9 +4011,7 @@ 0x801F59DC:("D_801F59DC","UNK_TYPE1","",0x1), 0x801F59E0:("D_801F59E0","UNK_TYPE1","",0x1), 0x801F59E4:("D_801F59E4","UNK_TYPE1","",0x1), - 0x801F59E8:("D_801F59E8","UNK_TYPE1","",0x1), - 0x801F59EC:("D_801F59EC","UNK_TYPE1","",0x1), - 0x801F59F0:("D_801F59F0","UNK_TYPE1","",0x1), + 0x801F59E8:("D_801F59E8","Vec3f","",0xC), 0x801F59F4:("D_801F59F4","UNK_TYPE1","",0x1), 0x801F59F8:("D_801F59F8","UNK_TYPE1","",0x1), 0x801F5A00:("sQuakeRequest","QuakeRequest","[4]",0x90), @@ -6407,7 +6359,7 @@ 0x808A8060:("D_808A8060","UNK_TYPE1","",0x1), 0x808AC010:("En_Ossan_InitVars","UNK_TYPE1","",0x1), 0x808AC030:("sAnimationsCuriosityShopMan","UNK_TYPE1","",0x1), - 0x808AC100:("sAnimationsPartTimeWorker","UNK_TYPE1","",0x1), + 0x808AC100:("sAnimationsPartTimer","UNK_TYPE1","",0x1), 0x808AC1C0:("sObjectIds","UNK_TYPE1","",0x1), 0x808AC1C4:("sAnimations","UNK_TYPE1","",0x1), 0x808AC1CC:("sShops","UNK_TYPE1","",0x1), @@ -6427,9 +6379,9 @@ 0x808AC288:("sInitChain","UNK_TYPE1","",0x1), 0x808AC28C:("sSelectedItemPosition","UNK_TYPE4","",0x4), 0x808AC2A4:("sInitFuncs","UNK_TYPE1","",0x1), - 0x808AC2AC:("sPartTimeWorkerFocusOffset","UNK_TYPE1","",0x1), + 0x808AC2AC:("sPartTimerFocusOffset","UNK_TYPE1","",0x1), 0x808AC2B8:("sCuriosityShopManEyeTextures","UNK_TYPE1","",0x1), - 0x808AC2C4:("sPartTimeWorkerEyeTextures","UNK_TYPE1","",0x1), + 0x808AC2C4:("sPartTimerEyeTextures","UNK_TYPE1","",0x1), 0x808AC2D0:("filename1","char","[]",0x1), 0x808AC2E0:("filename2","char","[]",0x1), 0x808AC2F0:("filename3","char","[]",0x1), @@ -9224,8 +9176,8 @@ 0x80989064:("D_80989064","f32","",0x4), 0x80989068:("D_80989068","f32","",0x4), 0x8098C280:("En_Dg_InitVars","UNK_TYPE1","",0x1), - 0x8098C2A0:("D_8098C2A0","UNK_TYPE1","",0x1), - 0x8098C2A4:("D_8098C2A4","UNK_TYPE2","",0x2), + 0x8098C2A0:("sIsAnyDogHeld","UNK_TYPE1","",0x1), + 0x8098C2A4:("sBremenMaskFollower","UNK_TYPE2","",0x2), 0x8098C2A8:("D_8098C2A8","UNK_TYPE2","",0x2), 0x8098C2AC:("D_8098C2AC","UNK_TYPE2","",0x2), 0x8098C2FC:("D_8098C2FC","UNK_TYPE1","",0x1), @@ -10280,12 +10232,12 @@ 0x809E0420:("D_809E0420","UNK_TYPE1","",0x1), 0x809E0421:("D_809E0421","UNK_TYPE1","",0x1), 0x809E0422:("D_809E0422","UNK_TYPE1","",0x1), - 0x809E0424:("D_809E0424","UNK_TYPE4","",0x4), - 0x809E0428:("D_809E0428","UNK_TYPE4","",0x4), - 0x809E042C:("D_809E042C","UNK_TYPE4","",0x4), - 0x809E0430:("D_809E0430","UNK_TYPE1","",0x1), - 0x809E0434:("D_809E0434","UNK_TYPE4","",0x4), - 0x809E0438:("D_809E0438","UNK_TYPE1","",0x1), + 0x809E0424:("sRedTwinmold","UNK_TYPE4","",0x4), + 0x809E0428:("sBlueTwinmold","UNK_TYPE4","",0x4), + 0x809E042C:("sTwinmoldStatic","UNK_TYPE4","",0x4), + 0x809E0430:("sMusicStartTimer","UNK_TYPE1","",0x1), + 0x809E0434:("sBlueWarp","UNK_TYPE4","",0x4), + 0x809E0438:("sEffects","UNK_TYPE1","",0x1), 0x809E8EA0:("D_809E8EA0","UNK_TYPE4","",0x4), 0x809E8EAC:("Boss_03_InitVars","UNK_TYPE1","",0x1), 0x809E8ECC:("D_809E8ECC","UNK_TYPE1","",0x1), @@ -11543,12 +11495,12 @@ 0x80A43364:("D_80A43364","u16","[2]",0x4), 0x80A434D0:("sCutscenes","s16","[2]",0x4), 0x80A434D4:("sCurrentCs","s16","",0x2), - 0x80A449E0:("En_Bat_InitVars","UNK_TYPE1","",0x1), - 0x80A44A00:("D_80A44A00","UNK_TYPE1","",0x1), - 0x80A44A2C:("D_80A44A2C","UNK_TYPE1","",0x1), - 0x80A44A4C:("D_80A44A4C","UNK_TYPE1","",0x1), - 0x80A44A54:("D_80A44A54","UNK_TYPE1","",0x1), - 0x80A44A64:("D_80A44A64","UNK_TYPE1","",0x1), + 0x80A449E0:("En_Bat_InitVars","ActorInit","",0x1), + 0x80A44A00:("sSphereInit","ColliderSphereInit","",0x1), + 0x80A44A2C:("sDamageTable","DamageTable","4",0x1), + 0x80A44A4C:("sColChkInfoInit","CollisionCheckInfoInit","",0x1), + 0x80A44A54:("sInitChain","InitChainEntry","",0x1), + 0x80A44A64:("sWingsDLs","Gfx*[]","9",0x1), 0x80A44A90:("D_80A44A90","f32","",0x4), 0x80A44A94:("D_80A44A94","f32","",0x4), 0x80A44A98:("D_80A44A98","f32","",0x4), @@ -11565,8 +11517,8 @@ 0x80A44AC4:("D_80A44AC4","f32","",0x4), 0x80A44AC8:("D_80A44AC8","f32","",0x4), 0x80A44ACC:("D_80A44ACC","f32","",0x4), - 0x80A44C70:("D_80A44C70","UNK_TYPE1","",0x1), - 0x80A44C74:("D_80A44C74","UNK_TYPE1","",0x1), + 0x80A44C70:("sNumberAttacking","UNK_TYPE1","",0x1), + 0x80A44C74:("sAlreadySpawned","UNK_TYPE1","",0x1), 0x80A45250:("En_Sekihi_InitVars","UNK_TYPE1","",0x1), 0x80A45270:("D_80A45270","UNK_TYPE1","",0x1), 0x80A4527C:("D_80A4527C","UNK_TYPE1","",0x1), @@ -12376,7 +12328,7 @@ 0x80A846A0:("D_80A846A0","f32","",0x4), 0x80A849D0:("D_80A849D0","UNK_TYPE4","",0x4), 0x80A85460:("Obj_Purify_InitVars","UNK_TYPE1","",0x1), - 0x80A85480:("D_80A85480","UNK_TYPE1","",0x1), + 0x80A85480:("ObjPurifyInfoList","UNK_TYPE1","",0x1), 0x80A854A0:("D_80A854A0","UNK_TYPE1","",0x1), 0x80A88910:("D_80A88910","UNK_TYPE1","",0x1), 0x80A88918:("D_80A88918","UNK_TYPE1","",0x1), @@ -14626,8 +14578,8 @@ 0x80B503F0:("D_80B503F0","UNK_TYPE4","",0x4), 0x80B503F4:("D_80B503F4","UNK_TYPE4","",0x4), 0x80B503F8:("D_80B503F8","UNK_TYPE4","",0x4), - 0x80B503FC:("D_80B503FC","UNK_TYPE4","",0x4), - 0x80B50400:("D_80B50400","UNK_TYPE4","",0x4), + 0x80B503FC:("sAlienEyeBeamTexAnim","UNK_TYPE4","",0x4), + 0x80B50400:("sAlienEmptyTexAnim","UNK_TYPE4","",0x4), 0x80B50404:("D_80B50404","UNK_TYPE2","",0x2), 0x80B50406:("D_80B50406","UNK_TYPE2","",0x2), 0x80B5040A:("D_80B5040A","UNK_TYPE1","",0x1), @@ -15872,7 +15824,7 @@ 0x80BCF0C0:("D_80BCF0C0","f32","",0x4), 0x80BCF0C4:("D_80BCF0C4","f32","",0x4), 0x80BCF0C8:("D_80BCF0C8","f32","",0x4), - 0x80BCF1C0:("D_80BCF1C0","UNK_TYPE1","",0x1), + 0x80BCF1C0:("sVtxAlpha","UNK_TYPE1","",0x1), 0x80BCF1C1:("D_80BCF1C1","UNK_TYPE1","",0x1), 0x80BCF1C4:("D_80BCF1C4","UNK_TYPE1","",0x1), 0x80BCFF90:("En_Hg_InitVars","UNK_TYPE1","",0x1), @@ -16630,7 +16582,7 @@ 0x80C1C250:("Dm_Al_InitVars","UNK_TYPE1","",0x1), 0x80C1C270:("D_80C1C270","UNK_TYPE1","",0x1), 0x80C1C280:("D_80C1C280","UNK_TYPE4","",0x4), - 0x80C1C294:("D_80C1C294","UNK_TYPE4","",0x4), + 0x80C1C294:("sDlists","UNK_TYPE4","",0x4), 0x80C1C2AC:("D_80C1C2AC","UNK_TYPE1","",0x1), 0x80C1C2B0:("jtbl_80C1C2B0","UNK_PTR","",0x4), 0x80C1C2E4:("jtbl_80C1C2E4","UNK_PTR","",0x4), diff --git a/tools/namefixer.py b/tools/namefixer.py index 13986658f..06dd21e95 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -23,7 +23,7 @@ wordReplace = { "Actor_GetSwitchFlag": "Flags_GetSwitch", "atan_flip": "Math_Acot2F", "atans": "Math_Atan2S", - + # "SysMatrix_StateAlloc": "Matrix_StateAlloc", # "SysMatrix_StatePush": "Matrix_StatePush", # "SysMatrix_StatePop": "Matrix_StatePop", @@ -100,6 +100,12 @@ wordReplace = { "func_800B78B8": "Actor_UpdateBgCheckInfo", "func_8012403C": "Player_GetMask", "func_8012404c": "Player_RemoveMask", + "func_80123AA4": "Player_SetModels", + "func_80123BD4": "Player_SetModelGroup", + "func_80123F48": "Player_IsBurningStickInRange", + "func_8012405C": "Player_HasMirrorShieldEquipped", + "func_80124088": "Player_IsHoldingMirrorShield", + "func_8012697C": "Player_DrawGetItem", "Actor_SpawnWithParentAndCutscene": "Actor_SpawnAsChildAndCutscene", "Actor_SpawnWithParent": "Actor_SpawnAsChild", "Actor_IsLinkFacingActor": "Player_IsFacingActor", @@ -439,6 +445,10 @@ wordReplace = { "func_800E0308": "Camera_SetTargetActor", "func_800E031C": "Camera_GetWaterYPos", "func_800E02AC": "Camera_SetToTrackActor", + "func_800DFAC8": "Camera_ChangeSetting", + "func_800DFC90": "Camera_GetCamDir", + "func_800DFD04": "Camera_AddQuake", + "func_800DFFAC": "Camera_ChangeDoorCam", "func_801694DC": "Play_CreateSubCamera", "Play_GetActiveCameraIndex": "Play_GetActiveCamId", "func_80169590": "Play_CameraChangeStatus", @@ -458,6 +468,22 @@ wordReplace = { "func_80169E6C": "Play_SetupRespawnPoint", "func_8016A0AC": "Play_IsUnderwater", "func_801690CC": "Play_InCsMode", + "func_80112B40": "Interface_LoadItemIconImpl", + "func_80112BE4": "Interface_LoadItemIcon", + "func_80114978": "Item_CheckObtainability", + "func_801149A0": "Inventory_DeleteItem", + "func_80114A9C": "Inventory_UnequipItem", + "func_80114B84": "Inventory_ReplaceItem", + "func_80114CA0": "Inventory_UpdateDeitySwordEquip", + "Interface_HasEmptyBottle": "Inventory_HasEmptyBottle", + "Interface_HasItemInBottle": "Inventory_HasItemInBottle", + "func_80114FD0": "Inventory_UpdateBottleItem", + "func_80115130": "Inventory_ConsumeFairy", + "func_801152B8": "Inventory_UpdateItem", + "func_80115908": "Health_ChangeBy", + "func_801159c0": "Health_GiveHearts", + "func_801159EC": "Rupees_ChangeBy", + "func_80115A14": "Inventory_ChangeAmmo", "func_8013EC44": "Rumble_Override", "func_8013ECE0": "Rumble_Request", "func_8017D2FC": "Math3D_LineSegVsPlane", @@ -478,8 +504,8 @@ wordReplace = { "func_800EE2F4": "Cutscene_IsPlaying", "func_801343C0": "SkelAnime_DrawTransformFlexOpa", "func_80134148": "SkelAnime_DrawTransformFlexLimbOpa", - "func_80114E90": "Interface_HasEmptyBottle", - "func_80114F2C": "Interface_HasItemInBottle", + "func_80114E90": "Inventory_HasEmptyBottle", + "func_80114F2C": "Inventory_HasItemInBottle", "func_80123C90": "Player_SetEquipmentData", "Quake2_ClearType": "Distortion_ClearType", "Quake2_SetType": "Distortion_SetType", @@ -543,11 +569,29 @@ wordReplace = { "EffectSsKiraKira_SpawnDispersed": "EffectSsKirakira_SpawnDispersed", "EffectSsKiraKira_SpawnFocused": "EffectSsKirakira_SpawnFocused", "Effect_GetGlobalCtx": "Effect_GetPlayState", + "EffectSsHitMark_Spawn": "EffectSsHitmark_Spawn", + "EffectSsHitMark_SpawnFixedScale": "EffectSsHitmark_SpawnFixedScale", + "EffectSsHitMark_SpawnCustomScale": "EffectSsHitmark_SpawnCustomScale", "func_800E8F08": "Actor_TrackNone", "func_800E8FA4": "Actor_TrackPoint", "func_800E9250": "Actor_TrackPlayer", + "func_8010A000": "Map_GetDungeonOrBossAreaIndex", + "func_8010A074": "Map_IsInDungeonOrBossArea", + "func_8010A0F0": "Map_GetDungeonAreaIndex", + "func_8010A164": "Map_IsInDungeonArea", + "func_8010A194": "Map_GetBossAreaIndex", + "func_8010A208": "Map_IsInBossArea", + "func_8010A2DC": "Minimap_SavePlayerRoomInitInfo", + "func_8010A33C": "Map_InitRoomData", + "func_8010A410": "Map_Destroy", + "func_8010A430": "Map_Init", + "func_8010A54C": "Minimap_Draw", + "func_8010A580": "Map_Update", + + "ActorCutscene_GetCurrentCamera": "ActorCutscene_GetCurrentSubCamId", + # Structs "ActorAnimationEntry": "AnimationInfo", "ActorAnimationEntryS": "AnimationInfoS", @@ -555,6 +599,7 @@ wordReplace = { "GlobalContext": "PlayState", "globalCtx": "play", "globalCtx2": "play2", + "ScheduleResult": "ScheduleOutput", # Struct members "skelAnime.unk03": "skelAnime.taper", @@ -573,7 +618,6 @@ wordReplace = { "skelAnime.prevFrameRot": "skelAnime.prevRot", "skelAnime.prevFramePos": "skelAnime.prevTransl", "skelAnime.unk3E": "skelAnime.baseTransl", - "actor.minVelocityY": "actor.terminalVelocity", "actor.yDistToWater": "actor.depthInWater", "actor.yDistToPlayer": "actor.playerHeightRel", @@ -604,8 +648,10 @@ wordReplace = { "gSaveContext.skullTokenCount": "gSaveContext.save.skullTokenCount", "gSaveContext.cutscene": "gSaveContext.save.cutscene", "gSaveContext.health": "gSaveContext.save.playerData.health", + "gSaveContext.equips": "gSaveContext.save.equips", "gSaveContext.unk_1016": "gSaveContext.jinxTimer", "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", + "gSaveContext.unk_48C8": "gSaveContext.dungeonIndex", "player->unk_A87": "player->exchangeItemId", "player->leftHandActor": "player->heldActor", @@ -614,22 +660,38 @@ wordReplace = { "player->unk_388": "player->interactRangeActor", "player->unk_38C": "player->mountSide", "player->unk_394": "player->csMode", + "player->swordQuads": "player->meleeWeaponQuads", + "player->blureEffectIndex": "player->meleeWeaponEffectIndex", + "player->swordAnimation": "player->meleeWeaponAnimation", + "player->swordState": "player->meleeWeaponState", + "player->swordInfo": "player->meleeWeaponInfo", "csCtx.npcActions": "csCtx.actorActions", "csCtx->npcActions": "csCtx->actorActions", "csCtx.unk_12": "csCtx.currentCsIndex", - "play->mf_187FC": "play->billboardMtxF", - "play->projectionMatrix": "play->viewProjectionMtxF", - "play->actorCtx.actorList[": "play->actorCtx.actorLists[", - "play->envCtx.unk_8C": "play->envCtx.lightSettings", - "play->envCtx.unk_E5": "play->envCtx.fillScreen", - "play->envCtx.unk_E6": "play->envCtx.screenFillColor", - "play->envCtx.unk_C3": "play->envCtx.lightSettingOverride", - "play->envCtx.unk_DC": "play->envCtx.lightBlend", + "globalCtx->mf_187FC": "play->billboardMtxF", + "globalCtx->projectionMatrix": "play->viewProjectionMtxF", + "globalCtx->actorCtx.actorList[": "play->actorCtx.actorLists[", + "globalCtx->envCtx.unk_8C": "play->envCtx.lightSettings", + "globalCtx->envCtx.unk_E5": "play->envCtx.fillScreen", + "globalCtx->envCtx.unk_E6": "play->envCtx.screenFillColor", + "globalCtx->envCtx.unk_C3": "play->envCtx.lightSettingOverride", + "globalCtx->envCtx.unk_DC": "play->envCtx.lightBlend", + "globalCtx->interfaceCtx.unk_21E": "play->interfaceCtx.bButtonDoAction", + "play->msgCtx.unk11F04": "play->msgCtx.currentTextId", + "play->msgCtx.unk11F10": "play->msgCtx.msgLength", + "play->msgCtx.unk11F22": "play->msgCtx.msgMode", + "play->msgCtx.unk12023": "play->msgCtx.stateTimer", "play->msgCtx.unk1202A": "play->msgCtx.ocarinaMode", "play->msgCtx.unk1202C": "play->msgCtx.ocarinaAction", - "play->msgCtx.unk11F22": "play->msgCtx.msgMode", - "play->msgCtx.unk11F04": "play->msgCtx.currentTextId", + + "play->sceneLoadFlag": "play->transitionTrigger", + "play->unk_18B4A": "play->transitionMode", + "play->unk_1887F": "play->transitionType", + "gSaveContext.nextTransition": "gSaveContext.nextTransitionType", + "gSaveContext.unk_3F48": "gSaveContext.cutsceneTransitionControl", + "gSaveContext.fadeDuration": "gSaveContext.transFadeDuration", + "gSaveContext.fadeSpeed": "gSaveContext.transWipeSpeed" "D_801D15B0" : "gZeroVec3f", "D_801D15BC" : "gZeroVec3s", diff --git a/tools/permuter_settings.toml b/tools/permuter_settings.toml index 2676d13ee..9b1959be9 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -9,6 +9,7 @@ SET_FULLSCREEN_VIEWPORT = "void" OPEN_DISPS = "void" CLOSE_DISPS = "void" ABS = "int" +ABS_ALT = "int" SQ = "int" CLAMP = "int" CLOCK_TIME = "int" diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index e2409088a..2bd3163a3 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -140,9 +140,9 @@ asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsStick_Spawn.s,Effec asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsSibuki_Spawn.s,EffectSsSibuki_Spawn,0x800B242C,0x1C asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsSibuki_SpawnBurst.s,EffectSsSibuki_SpawnBurst,0x800B249C,0x4F asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsStone1_Spawn.s,EffectSsStone1_Spawn,0x800B25D8,0x15 -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsHitMark_Spawn.s,EffectSsHitMark_Spawn,0x800B262C,0x16 -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsHitMark_SpawnFixedScale.s,EffectSsHitMark_SpawnFixedScale,0x800B2684,0x9 -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsHitMark_SpawnCustomScale.s,EffectSsHitMark_SpawnCustomScale,0x800B26A8,0xB +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsHitmark_Spawn.s,EffectSsHitmark_Spawn,0x800B262C,0x16 +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsHitmark_SpawnFixedScale.s,EffectSsHitmark_SpawnFixedScale,0x800B2684,0x9 +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsHitmark_SpawnCustomScale.s,EffectSsHitmark_SpawnCustomScale,0x800B26A8,0xB asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsFhgFlash_SpawnShock.s,EffectSsFhgFlash_SpawnShock,0x800B26D4,0x19 asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKFire_Spawn.s,EffectSsKFire_Spawn,0x800B2738,0x1A asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsSolderSrchBall_Spawn.s,EffectSsSolderSrchBall_Spawn,0x800B27A0,0x1C @@ -785,15 +785,15 @@ asm/non_matchings/code/z_camera/Camera_SetMode.s,Camera_SetMode,0x800DF4D0,0xDC asm/non_matchings/code/z_camera/Camera_ChangeMode.s,Camera_ChangeMode,0x800DF840,0xB asm/non_matchings/code/z_camera/func_800DF86C.s,func_800DF86C,0x800DF86C,0x20 asm/non_matchings/code/z_camera/func_800DF8EC.s,func_800DF8EC,0x800DF8EC,0x77 -asm/non_matchings/code/z_camera/func_800DFAC8.s,func_800DFAC8,0x800DFAC8,0x13 +asm/non_matchings/code/z_camera/Camera_ChangeSetting.s,Camera_ChangeSetting,0x800DFAC8,0x13 asm/non_matchings/code/z_camera/Camera_ChangeDataIdx.s,Camera_ChangeDataIdx,0x800DFB14,0x42 asm/non_matchings/code/z_camera/func_800DFC1C.s,func_800DFC1C,0x800DFC1C,0x9 asm/non_matchings/code/z_camera/func_800DFC40.s,func_800DFC40,0x800DFC40,0xA asm/non_matchings/code/z_camera/Camera_GetInputDirYaw.s,Camera_GetInputDirYaw,0x800DFC68,0xA -asm/non_matchings/code/z_camera/func_800DFC90.s,func_800DFC90,0x800DFC90,0x9 +asm/non_matchings/code/z_camera/Camera_GetCamDir.s,Camera_GetCamDir,0x800DFC90,0x9 asm/non_matchings/code/z_camera/Camera_GetCamDirPitch.s,Camera_GetCamDirPitch,0x800DFCB4,0xA asm/non_matchings/code/z_camera/Camera_GetCamDirYaw.s,Camera_GetCamDirYaw,0x800DFCDC,0xA -asm/non_matchings/code/z_camera/func_800DFD04.s,func_800DFD04,0x800DFD04,0x1D +asm/non_matchings/code/z_camera/Camera_AddQuake.s,Camera_AddQuake,0x800DFD04,0x1D asm/non_matchings/code/z_camera/func_800DFD78.s,func_800DFD78,0x800DFD78,0x5E asm/non_matchings/code/z_camera/func_800DFEF0.s,func_800DFEF0,0x800DFEF0,0xA asm/non_matchings/code/z_camera/func_800DFF18.s,func_800DFF18,0x800DFF18,0x7 @@ -801,7 +801,7 @@ asm/non_matchings/code/z_camera/func_800DFF34.s,func_800DFF34,0x800DFF34,0x4 asm/non_matchings/code/z_camera/func_800DFF44.s,func_800DFF44,0x800DFF44,0x7 asm/non_matchings/code/z_camera/Camera_SetFlags.s,Camera_SetFlags,0x800DFF60,0x9 asm/non_matchings/code/z_camera/Camera_ClearFlags.s,Camera_ClearFlags,0x800DFF84,0xA -asm/non_matchings/code/z_camera/func_800DFFAC.s,func_800DFFAC,0x800DFFAC,0x34 +asm/non_matchings/code/z_camera/Camera_ChangeDoorCam.s,Camera_ChangeDoorCam,0x800DFFAC,0x34 asm/non_matchings/code/z_camera/func_800E007C.s,func_800E007C,0x800E007C,0x4C asm/non_matchings/code/z_camera/func_800E01AC.s,func_800E01AC,0x800E01AC,0x3 asm/non_matchings/code/z_camera/Camera_GetQuakeOffset.s,Camera_GetQuakeOffset,0x800E01B8,0x9 @@ -1171,7 +1171,7 @@ asm/non_matchings/code/z_eventmgr/ActorCutscene_GetAdditionalCutscene.s,ActorCut asm/non_matchings/code/z_eventmgr/ActorCutscene_GetLength.s,ActorCutscene_GetLength,0x800F20F8,0x10 asm/non_matchings/code/z_eventmgr/func_800F2138.s,func_800F2138,0x800F2138,0x10 asm/non_matchings/code/z_eventmgr/func_800F2178.s,func_800F2178,0x800F2178,0x10 -asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCurrentCamera.s,ActorCutscene_GetCurrentCamera,0x800F21B8,0x5 +asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCurrentSubCamId.s,ActorCutscene_GetCurrentSubCamId,0x800F21B8,0x5 asm/non_matchings/code/z_eventmgr/func_800F21CC.s,func_800F21CC,0x800F21CC,0x3E asm/non_matchings/code/z_eventmgr/func_800F22C4.s,func_800F22C4,0x800F22C4,0x40 asm/non_matchings/code/z_eventmgr/ActorCutscene_SetReturnCamera.s,ActorCutscene_SetReturnCamera,0x800F23C4,0x7 @@ -1508,21 +1508,21 @@ asm/non_matchings/code/z_map_data/func_80109DD8.s,func_80109DD8,0x80109DD8,0x26 asm/non_matchings/code/z_map_data/func_80109E70.s,func_80109E70,0x80109E70,0x22 asm/non_matchings/code/z_map_data/func_80109EF8.s,func_80109EF8,0x80109EF8,0x20 asm/non_matchings/code/z_map_data/func_80109F78.s,func_80109F78,0x80109F78,0x22 -asm/non_matchings/code/z_map_exp/func_8010A000.s,func_8010A000,0x8010A000,0x1D -asm/non_matchings/code/z_map_exp/func_8010A074.s,func_8010A074,0x8010A074,0xC +asm/non_matchings/code/z_map_exp/Map_GetDungeonOrBossAreaIndex.s,Map_GetDungeonOrBossAreaIndex,0x8010A000,0x1D +asm/non_matchings/code/z_map_exp/Map_IsInDungeonOrBossArea.s,Map_IsInDungeonOrBossArea,0x8010A074,0xC asm/non_matchings/code/z_map_exp/func_8010A0A4.s,func_8010A0A4,0x8010A0A4,0x13 -asm/non_matchings/code/z_map_exp/func_8010A0F0.s,func_8010A0F0,0x8010A0F0,0x1D -asm/non_matchings/code/z_map_exp/func_8010A164.s,func_8010A164,0x8010A164,0xC -asm/non_matchings/code/z_map_exp/func_8010A194.s,func_8010A194,0x8010A194,0x1D -asm/non_matchings/code/z_map_exp/func_8010A208.s,func_8010A208,0x8010A208,0xC +asm/non_matchings/code/z_map_exp/Map_GetDungeonAreaIndex.s,Map_GetDungeonAreaIndex,0x8010A0F0,0x1D +asm/non_matchings/code/z_map_exp/Map_IsInDungeonArea.s,Map_IsInDungeonArea,0x8010A164,0xC +asm/non_matchings/code/z_map_exp/Map_GetBossAreaIndex.s,Map_GetBossAreaIndex,0x8010A194,0x1D +asm/non_matchings/code/z_map_exp/Map_IsInBossArea.s,Map_IsInBossArea,0x8010A208,0xC asm/non_matchings/code/z_map_exp/func_8010A238.s,func_8010A238,0x8010A238,0x1D asm/non_matchings/code/z_map_exp/func_8010A2AC.s,func_8010A2AC,0x8010A2AC,0xC -asm/non_matchings/code/z_map_exp/func_8010A2DC.s,func_8010A2DC,0x8010A2DC,0x18 -asm/non_matchings/code/z_map_exp/func_8010A33C.s,func_8010A33C,0x8010A33C,0x35 -asm/non_matchings/code/z_map_exp/func_8010A410.s,func_8010A410,0x8010A410,0x8 -asm/non_matchings/code/z_map_exp/func_8010A430.s,func_8010A430,0x8010A430,0x47 -asm/non_matchings/code/z_map_exp/func_8010A54C.s,func_8010A54C,0x8010A54C,0xD -asm/non_matchings/code/z_map_exp/func_8010A580.s,func_8010A580,0x8010A580,0x78 +asm/non_matchings/code/z_map_exp/Minimap_SavePlayerRoomInitInfo.s,Minimap_SavePlayerRoomInitInfo,0x8010A2DC,0x18 +asm/non_matchings/code/z_map_exp/Map_InitRoomData.s,Map_InitRoomData,0x8010A33C,0x35 +asm/non_matchings/code/z_map_exp/Map_Destroy.s,Map_Destroy,0x8010A410,0x8 +asm/non_matchings/code/z_map_exp/Map_Init.s,Map_Init,0x8010A430,0x47 +asm/non_matchings/code/z_map_exp/Minimap_Draw.s,Minimap_Draw,0x8010A54C,0xD +asm/non_matchings/code/z_map_exp/Map_Update.s,Map_Update,0x8010A580,0x78 asm/non_matchings/code/z_msgevent/func_8010A760.s,func_8010A760,0x8010A760,0x1B asm/non_matchings/code/z_msgevent/func_8010A7CC.s,func_8010A7CC,0x8010A7CC,0x12 asm/non_matchings/code/z_msgevent/func_8010A814.s,func_8010A814,0x8010A814,0x12 @@ -1623,31 +1623,31 @@ asm/non_matchings/code/z_parameter/func_80111CB4.s,func_80111CB4,0x80111CB4,0x34 asm/non_matchings/code/z_parameter/func_801129E4.s,func_801129E4,0x801129E4,0x44 asm/non_matchings/code/z_parameter/func_80112AF4.s,func_80112AF4,0x80112AF4,0x2 asm/non_matchings/code/z_parameter/func_80112AFC.s,func_80112AFC,0x80112AFC,0x11 -asm/non_matchings/code/z_parameter/func_80112B40.s,func_80112B40,0x80112B40,0x29 -asm/non_matchings/code/z_parameter/func_80112BE4.s,func_80112BE4,0x80112BE4,0xA +asm/non_matchings/code/z_parameter/Interface_LoadItemIconImpl.s,Interface_LoadItemIconImpl,0x80112B40,0x29 +asm/non_matchings/code/z_parameter/Interface_LoadItemIcon.s,Interface_LoadItemIcon,0x80112BE4,0xA asm/non_matchings/code/z_parameter/func_80112C0C.s,func_80112C0C,0x80112C0C,0x9D asm/non_matchings/code/z_parameter/Item_Give.s,Item_Give,0x80112E80,0x553 -asm/non_matchings/code/z_parameter/func_801143CC.s,func_801143CC,0x801143CC,0x16B -asm/non_matchings/code/z_parameter/func_80114978.s,func_80114978,0x80114978,0xA -asm/non_matchings/code/z_parameter/func_801149A0.s,func_801149A0,0x801149A0,0x3F -asm/non_matchings/code/z_parameter/func_80114A9C.s,func_80114A9C,0x80114A9C,0x3A -asm/non_matchings/code/z_parameter/func_80114B84.s,func_80114B84,0x80114B84,0x47 -asm/non_matchings/code/z_parameter/func_80114CA0.s,func_80114CA0,0x80114CA0,0x7C -asm/non_matchings/code/z_parameter/Interface_HasEmptyBottle.s,Interface_HasEmptyBottle,0x80114E90,0x27 -asm/non_matchings/code/z_parameter/Interface_HasItemInBottle.s,Interface_HasItemInBottle,0x80114F2C,0x29 -asm/non_matchings/code/z_parameter/func_80114FD0.s,func_80114FD0,0x80114FD0,0x58 -asm/non_matchings/code/z_parameter/func_80115130.s,func_80115130,0x80115130,0x62 -asm/non_matchings/code/z_parameter/func_801152B8.s,func_801152B8,0x801152B8,0x44 +asm/non_matchings/code/z_parameter/Item_CheckObtainabilityImpl.s,Item_CheckObtainabilityImpl,0x801143CC,0x16B +asm/non_matchings/code/z_parameter/Item_CheckObtainability.s,Item_CheckObtainability,0x80114978,0xA +asm/non_matchings/code/z_parameter/Inventory_DeleteItem.s,Inventory_DeleteItem,0x801149A0,0x3F +asm/non_matchings/code/z_parameter/Inventory_UnequipItem.s,Inventory_UnequipItem,0x80114A9C,0x3A +asm/non_matchings/code/z_parameter/Inventory_ReplaceItem.s,Inventory_ReplaceItem,0x80114B84,0x47 +asm/non_matchings/code/z_parameter/Inventory_UpdateDeitySwordEquip.s,Inventory_UpdateDeitySwordEquip,0x80114CA0,0x7C +asm/non_matchings/code/z_parameter/Inventory_HasEmptyBottle.s,Inventory_HasEmptyBottle,0x80114E90,0x27 +asm/non_matchings/code/z_parameter/Inventory_HasItemInBottle.s,Inventory_HasItemInBottle,0x80114F2C,0x29 +asm/non_matchings/code/z_parameter/Inventory_UpdateBottleItem.s,Inventory_UpdateBottleItem,0x80114FD0,0x58 +asm/non_matchings/code/z_parameter/Inventory_ConsumeFairy.s,Inventory_ConsumeFairy,0x80115130,0x62 +asm/non_matchings/code/z_parameter/Inventory_UpdateItem.s,Inventory_UpdateItem,0x801152B8,0x44 asm/non_matchings/code/z_parameter/func_801153C8.s,func_801153C8,0x801153C8,0x18 asm/non_matchings/code/z_parameter/func_80115428.s,func_80115428,0x80115428,0x41 asm/non_matchings/code/z_parameter/func_8011552C.s,func_8011552C,0x8011552C,0x22 asm/non_matchings/code/z_parameter/func_801155B4.s,func_801155B4,0x801155B4,0x6C asm/non_matchings/code/z_parameter/func_80115764.s,func_80115764,0x80115764,0x38 asm/non_matchings/code/z_parameter/func_80115844.s,func_80115844,0x80115844,0x31 -asm/non_matchings/code/z_parameter/func_80115908.s,func_80115908,0x80115908,0x2E -asm/non_matchings/code/z_parameter/func_801159c0.s,func_801159c0,0x801159C0,0xB -asm/non_matchings/code/z_parameter/func_801159EC.s,func_801159EC,0x801159EC,0xA -asm/non_matchings/code/z_parameter/func_80115A14.s,func_80115A14,0x80115A14,0xC0 +asm/non_matchings/code/z_parameter/Health_ChangeBy.s,Health_ChangeBy,0x80115908,0x2E +asm/non_matchings/code/z_parameter/Health_GiveHearts.s,Health_GiveHearts,0x801159C0,0xB +asm/non_matchings/code/z_parameter/Rupees_ChangeBy.s,Rupees_ChangeBy,0x801159EC,0xA +asm/non_matchings/code/z_parameter/Inventory_ChangeAmmo.s,Inventory_ChangeAmmo,0x80115A14,0xC0 asm/non_matchings/code/z_parameter/Parameter_AddMagic.s,Parameter_AddMagic,0x80115D14,0x12 asm/non_matchings/code/z_parameter/func_80115D5C.s,func_80115D5C,0x80115D5C,0x16 asm/non_matchings/code/z_parameter/func_80115DB4.s,func_80115DB4,0x80115DB4,0xB5 @@ -1696,29 +1696,29 @@ asm/non_matchings/code/z_player_lib/func_801229FC.s,func_801229FC,0x801229FC,0x6 asm/non_matchings/code/z_player_lib/func_80122BA4.s,func_80122BA4,0x80122BA4,0x1F asm/non_matchings/code/z_player_lib/func_80122C20.s,func_80122C20,0x80122C20,0x49 asm/non_matchings/code/z_player_lib/func_80122D44.s,func_80122D44,0x80122D44,0x65 -asm/non_matchings/code/z_player_lib/func_80122ED8.s,func_80122ED8,0x80122ED8,0x5 -asm/non_matchings/code/z_player_lib/func_80122EEC.s,func_80122EEC,0x80122EEC,0xF +asm/non_matchings/code/z_player_lib/Player_MaskIdToItemId.s,Player_MaskIdToItemId,0x80122ED8,0x5 +asm/non_matchings/code/z_player_lib/Player_GetCurMaskItemId.s,Player_GetCurMaskItemId,0x80122EEC,0xF asm/non_matchings/code/z_player_lib/func_80122F28.s,func_80122F28,0x80122F28,0x1D asm/non_matchings/code/z_player_lib/func_80122F9C.s,func_80122F9C,0x80122F9C,0xC asm/non_matchings/code/z_player_lib/func_80122FCC.s,func_80122FCC,0x80122FCC,0x10 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/Player_InBlockingCsMode.s,Player_InBlockingCsMode,0x80123358,0x23 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 -asm/non_matchings/code/z_player_lib/func_801234B0.s,func_801234B0,0x801234B0,0x9 +asm/non_matchings/code/z_player_lib/Player_IsGoronOrDeku.s,Player_IsGoronOrDeku,0x801234B0,0x9 asm/non_matchings/code/z_player_lib/func_801234D4.s,func_801234D4,0x801234D4,0x2F asm/non_matchings/code/z_player_lib/func_80123590.s,func_80123590,0x80123590,0x13 asm/non_matchings/code/z_player_lib/func_801235DC.s,func_801235DC,0x801235DC,0x1C asm/non_matchings/code/z_player_lib/func_8012364C.s,func_8012364C,0x8012364C,0x71 asm/non_matchings/code/z_player_lib/func_80123810.s,func_80123810,0x80123810,0x54 -asm/non_matchings/code/z_player_lib/func_80123960.s,func_80123960,0x80123960,0x13 +asm/non_matchings/code/z_player_lib/Player_ActionToModelGroup.s,Player_ActionToModelGroup,0x80123960,0x13 asm/non_matchings/code/z_player_lib/func_801239AC.s,func_801239AC,0x801239AC,0x3E -asm/non_matchings/code/z_player_lib/func_80123AA4.s,func_80123AA4,0x80123AA4,0x4C -asm/non_matchings/code/z_player_lib/func_80123BD4.s,func_80123BD4,0x80123BD4,0x21 +asm/non_matchings/code/z_player_lib/Player_SetModels.s,Player_SetModels,0x80123AA4,0x4C +asm/non_matchings/code/z_player_lib/Player_SetModelGroup.s,Player_SetModelGroup,0x80123BD4,0x21 asm/non_matchings/code/z_player_lib/func_80123C58.s,func_80123C58,0x80123C58,0xE asm/non_matchings/code/z_player_lib/Player_SetEquipmentData.s,Player_SetEquipmentData,0x80123C90,0x30 asm/non_matchings/code/z_player_lib/func_80123D50.s,func_80123D50,0x80123D50,0x15 @@ -1727,22 +1727,22 @@ asm/non_matchings/code/z_player_lib/func_80123DC0.s,func_80123DC0,0x80123DC0,0x3 asm/non_matchings/code/z_player_lib/func_80123E90.s,func_80123E90,0x80123E90,0x21 asm/non_matchings/code/z_player_lib/func_80123F14.s,func_80123F14,0x80123F14,0x6 asm/non_matchings/code/z_player_lib/func_80123F2C.s,func_80123F2C,0x80123F2C,0x7 -asm/non_matchings/code/z_player_lib/func_80123F48.s,func_80123F48,0x80123F48,0x36 -asm/non_matchings/code/z_player_lib/func_80124020.s,func_80124020,0x80124020,0x7 +asm/non_matchings/code/z_player_lib/Player_IsBurningStickInRange.s,Player_IsBurningStickInRange,0x80123F48,0x36 +asm/non_matchings/code/z_player_lib/Player_GetStrength.s,Player_GetStrength,0x80124020,0x7 asm/non_matchings/code/z_player_lib/Player_GetMask.s,Player_GetMask,0x8012403C,0x4 asm/non_matchings/code/z_player_lib/Player_RemoveMask.s,Player_RemoveMask,0x8012404C,0x4 -asm/non_matchings/code/z_player_lib/func_8012405C.s,func_8012405C,0x8012405C,0xB -asm/non_matchings/code/z_player_lib/func_80124088.s,func_80124088,0x80124088,0x10 -asm/non_matchings/code/z_player_lib/func_801240C8.s,func_801240C8,0x801240C8,0x5 +asm/non_matchings/code/z_player_lib/Player_HasMirrorShieldEquipped.s,Player_HasMirrorShieldEquipped,0x8012405C,0xB +asm/non_matchings/code/z_player_lib/Player_IsHoldingMirrorShield.s,Player_IsHoldingMirrorShield,0x80124088,0x10 +asm/non_matchings/code/z_player_lib/Player_IsHoldingHookshot.s,Player_IsHoldingHookshot,0x801240C8,0x5 asm/non_matchings/code/z_player_lib/func_801240DC.s,func_801240DC,0x801240DC,0xD asm/non_matchings/code/z_player_lib/func_80124110.s,func_80124110,0x80124110,0xE asm/non_matchings/code/z_player_lib/func_80124148.s,func_80124148,0x80124148,0x8 -asm/non_matchings/code/z_player_lib/func_80124168.s,func_80124168,0x80124168,0xA -asm/non_matchings/code/z_player_lib/func_80124190.s,func_80124190,0x80124190,0x9 -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/Player_ActionToMeleeWeapon.s,Player_ActionToMeleeWeapon,0x80124168,0xA +asm/non_matchings/code/z_player_lib/Player_GetMeleeWeaponHeld.s,Player_GetMeleeWeaponHeld,0x80124190,0x9 +asm/non_matchings/code/z_player_lib/Player_IsHoldingTwoHandedWeapon.s,Player_IsHoldingTwoHandedWeapon,0x801241B4,0xB +asm/non_matchings/code/z_player_lib/Player_ActionToBottle.s,Player_ActionToBottle,0x801241E0,0xB +asm/non_matchings/code/z_player_lib/Player_GetBottleHeld.s,Player_GetBottleHeld,0x8012420C,0x8 +asm/non_matchings/code/z_player_lib/Player_ActionToExplosive.s,Player_ActionToExplosive,0x8012422C,0xB asm/non_matchings/code/z_player_lib/Player_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 @@ -1758,7 +1758,7 @@ asm/non_matchings/code/z_player_lib/func_801251C4.s,func_801251C4,0x801251C4,0x5 asm/non_matchings/code/z_player_lib/func_80125318.s,func_80125318,0x80125318,0xA asm/non_matchings/code/z_player_lib/func_80125340.s,func_80125340,0x80125340,0xB asm/non_matchings/code/z_player_lib/func_8012536C.s,func_8012536C,0x8012536C,0xE -asm/non_matchings/code/z_player_lib/func_801253A4.s,func_801253A4,0x801253A4,0x57 +asm/non_matchings/code/z_player_lib/Player_DrawZoraShield.s,Player_DrawZoraShield,0x801253A4,0x57 asm/non_matchings/code/z_player_lib/func_80125500.s,func_80125500,0x80125500,0x20 asm/non_matchings/code/z_player_lib/func_80125580.s,func_80125580,0x80125580,0x1D8 asm/non_matchings/code/z_player_lib/func_80125CE0.s,func_80125CE0,0x80125CE0,0x1B @@ -1768,15 +1768,15 @@ asm/non_matchings/code/z_player_lib/func_801263FC.s,func_801263FC,0x801263FC,0x1 asm/non_matchings/code/z_player_lib/func_80126440.s,func_80126440,0x80126440,0x62 asm/non_matchings/code/z_player_lib/func_801265C8.s,func_801265C8,0x801265C8,0x35 asm/non_matchings/code/z_player_lib/func_8012669C.s,func_8012669C,0x8012669C,0x5B -asm/non_matchings/code/z_player_lib/func_80126808.s,func_80126808,0x80126808,0x5D -asm/non_matchings/code/z_player_lib/func_8012697C.s,func_8012697C,0x8012697C,0x4E +asm/non_matchings/code/z_player_lib/Player_DrawGetItemImpl.s,Player_DrawGetItemImpl,0x80126808,0x5D +asm/non_matchings/code/z_player_lib/Player_DrawGetItem.s,Player_DrawGetItem,0x8012697C,0x4E asm/non_matchings/code/z_player_lib/func_80126AB4.s,func_80126AB4,0x80126AB4,0x36 asm/non_matchings/code/z_player_lib/func_80126B8C.s,func_80126B8C,0x80126B8C,0x11 asm/non_matchings/code/z_player_lib/func_80126BD0.s,func_80126BD0,0x80126BD0,0x178 asm/non_matchings/code/z_player_lib/func_801271B0.s,func_801271B0,0x801271B0,0xA2 asm/non_matchings/code/z_player_lib/func_80127438.s,func_80127438,0x80127438,0x14 asm/non_matchings/code/z_player_lib/func_80127488.s,func_80127488,0x80127488,0x31 -asm/non_matchings/code/z_player_lib/func_8012754C.s,func_8012754C,0x8012754C,0x12 +asm/non_matchings/code/z_player_lib/Player_DrawCouplesMask.s,Player_DrawCouplesMask,0x8012754C,0x12 asm/non_matchings/code/z_player_lib/func_80127594.s,func_80127594,0x80127594,0xD9 asm/non_matchings/code/z_player_lib/func_801278F8.s,func_801278F8,0x801278F8,0x5A asm/non_matchings/code/z_player_lib/func_80127A60.s,func_80127A60,0x80127A60,0x41 @@ -2623,7 +2623,7 @@ asm/non_matchings/code/TwoHeadArena/THA_IsCrash.s,THA_IsCrash,0x80172B18,0x9 asm/non_matchings/code/TwoHeadArena/THA_Init.s,THA_Init,0x80172B3C,0x7 asm/non_matchings/code/TwoHeadArena/THA_Ct.s,THA_Ct,0x80172B58,0x11 asm/non_matchings/code/TwoHeadArena/THA_Dt.s,THA_Dt,0x80172B9C,0x9 -asm/non_matchings/code/code_80172BC0/func_80172BC0.s,func_80172BC0,0x80172BC0,0x1C +asm/non_matchings/code/code_80172BC0/AudioMgr_StopAllSfxExceptSystem.s,AudioMgr_StopAllSfxExceptSystem,0x80172BC0,0x1C asm/non_matchings/code/audioMgr/func_80172C30.s,func_80172C30,0x80172C30,0xE asm/non_matchings/code/audioMgr/AudioMgr_HandleRetrace.s,AudioMgr_HandleRetrace,0x80172C68,0x91 asm/non_matchings/code/audioMgr/AudioMgr_HandlePRENMI.s,AudioMgr_HandlePRENMI,0x80172EAC,0x9 @@ -3283,41 +3283,41 @@ asm/non_matchings/code/audio_effects/AudioEffects_NoteVibratoInit.s,AudioEffects asm/non_matchings/code/audio_effects/AudioEffects_NotePortamentoInit.s,AudioEffects_NotePortamentoInit,0x80197138,0xB asm/non_matchings/code/audio_effects/AudioEffects_AdsrInit.s,AudioEffects_AdsrInit,0x80197164,0x9 asm/non_matchings/code/audio_effects/AudioEffects_AdsrUpdate.s,AudioEffects_AdsrUpdate,0x80197188,0xD2 -asm/non_matchings/code/audio_seqplayer/func_801974D0.s,func_801974D0,0x801974D0,0x1A -asm/non_matchings/code/audio_seqplayer/func_80197538.s,func_80197538,0x80197538,0x77 -asm/non_matchings/code/audio_seqplayer/func_80197714.s,func_80197714,0x80197714,0x5B -asm/non_matchings/code/audio_seqplayer/func_80197880.s,func_80197880,0x80197880,0x56 -asm/non_matchings/code/audio_seqplayer/func_801979D8.s,func_801979D8,0x801979D8,0x1F -asm/non_matchings/code/audio_seqplayer/func_80197A54.s,func_80197A54,0x80197A54,0x14 +asm/non_matchings/code/audio_seqplayer/AudioSeq_GetScriptControlFlowArgument.s,AudioSeq_GetScriptControlFlowArgument,0x801974D0,0x1A +asm/non_matchings/code/audio_seqplayer/AudioSeq_HandleScriptFlowControl.s,AudioSeq_HandleScriptFlowControl,0x80197538,0x77 +asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequenceChannel.s,AudioSeq_InitSequenceChannel,0x80197714,0x5B +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqChannelSetLayer.s,AudioSeq_SeqChannelSetLayer,0x80197880,0x56 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerDisable.s,AudioSeq_SeqLayerDisable,0x801979D8,0x1F +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerFree.s,AudioSeq_SeqLayerFree,0x80197A54,0x14 asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelDisable.s,AudioSeq_SequenceChannelDisable,0x80197AA4,0x1C -asm/non_matchings/code/audio_seqplayer/func_80197B14.s,func_80197B14,0x80197B14,0x3E -asm/non_matchings/code/audio_seqplayer/func_80197C0C.s,func_80197C0C,0x80197C0C,0x20 -asm/non_matchings/code/audio_seqplayer/func_80197C8C.s,func_80197C8C,0x80197C8C,0x26 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerSetupChannels.s,AudioSeq_SequencePlayerSetupChannels,0x80197B14,0x3E +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableChannels.s,AudioSeq_SequencePlayerDisableChannels,0x80197C0C,0x20 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelEnable.s,AudioSeq_SequenceChannelEnable,0x80197C8C,0x26 asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableAsFinished.s,AudioSeq_SequencePlayerDisableAsFinished,0x80197D24,0xA asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisable.s,AudioSeq_SequencePlayerDisable,0x80197D4C,0x2F asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPushBack.s,AudioSeq_AudioListPushBack,0x80197E08,0x10 asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPopBack.s,AudioSeq_AudioListPopBack,0x80197E48,0x10 -asm/non_matchings/code/audio_seqplayer/func_80197E88.s,func_80197E88,0x80197E88,0x28 -asm/non_matchings/code/audio_seqplayer/func_80197F28.s,func_80197F28,0x80197F28,0x5 -asm/non_matchings/code/audio_seqplayer/func_80197F3C.s,func_80197F3C,0x80197F3C,0xE -asm/non_matchings/code/audio_seqplayer/func_80197F74.s,func_80197F74,0x80197F74,0x10 -asm/non_matchings/code/audio_seqplayer/func_80197FB4.s,func_80197FB4,0x80197FB4,0x47 -asm/non_matchings/code/audio_seqplayer/func_801980D0.s,func_801980D0,0x801980D0,0x23 -asm/non_matchings/code/audio_seqplayer/func_8019815C.s,func_8019815C,0x8019815C,0x40 -asm/non_matchings/code/audio_seqplayer/func_8019825C.s,func_8019825C,0x8019825C,0xF9 -asm/non_matchings/code/audio_seqplayer/func_80198640.s,func_80198640,0x80198640,0x1A8 -asm/non_matchings/code/audio_seqplayer/func_80198CE0.s,func_80198CE0,0x80198CE0,0x105 -asm/non_matchings/code/audio_seqplayer/func_801990F4.s,func_801990F4,0x801990F4,0xC -asm/non_matchings/code/audio_seqplayer/func_80199124.s,func_80199124,0x80199124,0x1D -asm/non_matchings/code/audio_seqplayer/func_80199198.s,func_80199198,0x80199198,0x2B -asm/non_matchings/code/audio_seqplayer/func_80199244.s,func_80199244,0x80199244,0x9 -asm/non_matchings/code/audio_seqplayer/func_80199268.s,func_80199268,0x80199268,0x395 -asm/non_matchings/code/audio_seqplayer/func_8019A0BC.s,func_8019A0BC,0x8019A0BC,0x260 -asm/non_matchings/code/audio_seqplayer/func_8019AA3C.s,func_8019AA3C,0x8019AA3C,0x2D -asm/non_matchings/code/audio_seqplayer/func_8019AAF0.s,func_8019AAF0,0x8019AAF0,0x14 +asm/non_matchings/code/audio_seqplayer/AudioSeq_InitLayerFreelist.s,AudioSeq_InitLayerFreelist,0x80197E88,0x28 +asm/non_matchings/code/audio_seqplayer/AudioSeq_ScriptReadU8.s,AudioSeq_ScriptReadU8,0x80197F28,0x5 +asm/non_matchings/code/audio_seqplayer/AudioSeq_ScriptReadS16.s,AudioSeq_ScriptReadS16,0x80197F3C,0xE +asm/non_matchings/code/audio_seqplayer/AudioSeq_ScriptReadCompressedU16.s,AudioSeq_ScriptReadCompressedU16,0x80197F74,0x10 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScript.s,AudioSeq_SeqLayerProcessScript,0x80197FB4,0x47 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep1.s,AudioSeq_SeqLayerProcessScriptStep1,0x801980D0,0x23 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep5.s,AudioSeq_SeqLayerProcessScriptStep5,0x8019815C,0x40 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep2.s,AudioSeq_SeqLayerProcessScriptStep2,0x8019825C,0xF9 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep4.s,AudioSeq_SeqLayerProcessScriptStep4,0x80198640,0x1A8 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep3.s,AudioSeq_SeqLayerProcessScriptStep3,0x80198CE0,0x105 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SetChannelPriorities.s,AudioSeq_SetChannelPriorities,0x801990F4,0xC +asm/non_matchings/code/audio_seqplayer/AudioSeq_GetInstrument.s,AudioSeq_GetInstrument,0x80199124,0x1D +asm/non_matchings/code/audio_seqplayer/AudioSeq_SetInstrument.s,AudioSeq_SetInstrument,0x80199198,0x2B +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelSetVolume.s,AudioSeq_SequenceChannelSetVolume,0x80199244,0x9 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelProcessScript.s,AudioSeq_SequenceChannelProcessScript,0x80199268,0x395 +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerProcessSequence.s,AudioSeq_SequencePlayerProcessSequence,0x8019A0BC,0x260 +asm/non_matchings/code/audio_seqplayer/AudioSeq_ProcessSequences.s,AudioSeq_ProcessSequences,0x8019AA3C,0x2D +asm/non_matchings/code/audio_seqplayer/AudioSeq_SkipForwardSequence.s,AudioSeq_SkipForwardSequence,0x8019AAF0,0x14 asm/non_matchings/code/audio_seqplayer/AudioSeq_ResetSequencePlayer.s,AudioSeq_ResetSequencePlayer,0x8019AB40,0x34 asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayerChannels.s,AudioSeq_InitSequencePlayerChannels,0x8019AC10,0x37 -asm/non_matchings/code/audio_seqplayer/func_8019ACEC.s,func_8019ACEC,0x8019ACEC,0x34 +asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayer.s,AudioSeq_InitSequencePlayer,0x8019ACEC,0x34 asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayers.s,AudioSeq_InitSequencePlayers,0x8019ADBC,0x21 asm/non_matchings/code/code_8019AE40/func_8019AE40.s,func_8019AE40,0x8019AE40,0x1C asm/non_matchings/code/code_8019AEC0/func_8019AEC0.s,func_8019AEC0,0x8019AEC0,0x10 diff --git a/undefined_syms.txt b/undefined_syms.txt index ebbdb298d..a9cc3e6f5 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -388,7 +388,6 @@ D_04016360 = 0x04016360; D_0401A4D0 = 0x0401A4D0; D_0401A538 = 0x0401A538; D_0401A590 = 0x0401A590; -D_0401A620 = 0x0401A620; D_0401ACF0 = 0x0401ACF0; D_0401ED00 = 0x0401ED00; D_0401F0F0 = 0x0401F0F0; @@ -424,8 +423,6 @@ D_0402F028 = 0x0402F028; D_0402F0EC = 0x0402F0EC; D_04030100 = 0x04030100; D_040301B0 = 0x040301B0; -D_04032270 = 0x04032270; -D_04035710 = 0x04035710; D_040367B0 = 0x040367B0; D_040377B0 = 0x040377B0; D_04037850 = 0x04037850; @@ -540,11 +537,6 @@ D_06011AB8 = 0x06011AB8; D_06012A80 = 0x06012A80; D_06013138 = 0x06013138; -// ovl_Bg_Botihasira - -D_06000638 = 0x06000638; -D_06001BD8 = 0x06001BD8; - // ovl_Bg_Crace_Movebg D_060003A0 = 0x060003A0; @@ -590,8 +582,6 @@ D_060037F8 = 0x060037F8; // ovl_Bg_Haka_Bombwall -D_06000040 = 0x06000040; -D_06000148 = 0x06000148; D_06001680 = 0x06001680; // ovl_Bg_Hakugin_Bombwall @@ -603,11 +593,6 @@ D_06009830 = 0x06009830; D_0600ACB8 = 0x0600ACB8; D_0600BF40 = 0x0600BF40; -// ovl_Bg_Icefloe - -D_060001E0 = 0x060001E0; -D_06000C90 = 0x06000C90; - // ovl_Bg_Ikana_Bombwall D_06000288 = 0x06000288; @@ -621,19 +606,6 @@ D_06001AD8 = 0x06001AD8; D_06001E18 = 0x06001E18; D_06002358 = 0x06002358; -// ovl_Bg_Iknv_Doukutu - -D_0600DB60 = 0x0600DB60; -D_0600DDD8 = 0x0600DDD8; -D_0600F1C0 = 0x0600F1C0; -D_06010D98 = 0x06010D98; -D_060115E0 = 0x060115E0; -D_060117A0 = 0x060117A0; -D_060117C8 = 0x060117C8; -D_06012700 = 0x06012700; -D_06012728 = 0x06012728; -D_06012788 = 0x06012788; - // ovl_Bg_Kin2_Bombwall D_06000128 = 0x06000128; @@ -650,20 +622,10 @@ D_06000798 = 0x06000798; D_06000098 = 0x06000098; -// ovl_Bg_Open_Shutter - -D_060003E8 = 0x060003E8; -D_06001640 = 0x06001640; - - // ovl_Bg_Sinkai_Kabe D_06000048 = 0x06000048; -// ovl_Bg_Spout_Fire - -D_06000040 = 0x06000040; - // ovl_Bg_Umajump D_06001220 = 0x06001220; @@ -899,18 +861,6 @@ D_06000000 = 0x06000000; D_06000140 = 0x06000140; D_06001AF0 = 0x06001AF0; -// ovl_Eff_Lastday - -D_06000000 = 0x06000000; -D_06000060 = 0x06000060; -D_06000148 = 0x06000148; -D_06000210 = 0x06000210; -D_06000308 = 0x06000308; -D_06000370 = 0x06000370; -D_06000448 = 0x06000448; -D_06000510 = 0x06000510; -D_06000608 = 0x06000608; - // ovl_Eff_Stk D_06008920 = 0x06008920; @@ -991,10 +941,6 @@ D_06004210 = 0x06004210; D_06007C70 = 0x06007C70; D_0600823C = 0x0600823C; -// ovl_En_Bjt - -D_06002390 = 0x06002390; - // ovl_En_Bombal D_06000A00 = 0x06000A00; @@ -1165,21 +1111,6 @@ D_0600B644 = 0x0600B644; D_0600F248 = 0x0600F248; D_06012A58 = 0x06012A58; -// ovl_En_Ik - -D_06000CE8 = 0x06000CE8; -D_060015F8 = 0x060015F8; -D_06001ABC = 0x06001ABC; -D_06002484 = 0x06002484; -D_06002E7C = 0x06002E7C; -D_0600367C = 0x0600367C; -D_0600391C = 0x0600391C; -D_06004A04 = 0x06004A04; -D_06005254 = 0x06005254; -D_060057F4 = 0x060057F4; -D_06006294 = 0x06006294; -D_060136A0 = 0x060136A0; - // ovl_En_Invadepoh_Demo D_06000080 = 0x06000080; @@ -1519,46 +1450,22 @@ D_06000168 = 0x06000168; D_060003F8 = 0x060003F8; D_060004B0 = 0x060004B0; -// ovl_Obj_Chikuwa - -D_06000D10 = 0x06000D10; -D_06000F00 = 0x06000F00; - // ovl_Obj_Danpeilift D_06000180 = 0x06000180; D_06000BA0 = 0x06000BA0; -// ovl_Obj_Jgame_Light - -D_060003A0 = 0x060003A0; - // ovl_Obj_Lift D_06000D10 = 0x06000D10; D_06000F00 = 0x06000F00; -// ovl_Obj_Lupygamelift - -D_060048D0 = 0x060048D0; -D_060071B8 = 0x060071B8; - // ovl_Obj_Mine D_06000030 = 0x06000030; D_06002068 = 0x06002068; D_06002188 = 0x06002188; -// ovl_Obj_Ocarinalift - -D_06001DB0 = 0x06001DB0; -D_06001E40 = 0x06001E40; -D_060048D0 = 0x060048D0; - -// ovl_Obj_Shutter - -D_060011E0 = 0x060011E0; - // ovl_Obj_Takaraya_Wall D_06000B70 = 0x06000B70; @@ -1573,11 +1480,6 @@ D_06001100 = 0x06001100; D_06001140 = 0x06001140; D_06001CB0 = 0x06001CB0; -// ovl_Obj_Toudai - -D_060023B0 = 0x060023B0; -D_060024E8 = 0x060024E8; - // ovl_Obj_Um D_06007E20 = 0x06007E20;